|
3 | 3 | import com.palmergames.bukkit.towny.*;
|
4 | 4 | import com.palmergames.bukkit.towny.event.damage.*;
|
5 | 5 | import com.palmergames.bukkit.towny.event.executors.TownyActionEventExecutor;
|
6 |
| -import com.palmergames.bukkit.towny.listeners.TownyEntityListener; |
7 | 6 | import com.palmergames.bukkit.towny.object.*;
|
8 | 7 | import com.palmergames.bukkit.towny.object.TownyPermission.ActionType;
|
9 | 8 | import com.palmergames.bukkit.util.BukkitTools;
|
10 | 9 | import org.bukkit.Bukkit;
|
11 | 10 | import org.bukkit.Material;
|
12 | 11 | import org.bukkit.block.Block;
|
13 | 12 | import org.bukkit.entity.*;
|
| 13 | +import org.bukkit.entity.memory.MemoryKey; |
14 | 14 | import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
15 | 15 | import org.bukkit.projectiles.BlockProjectileSource;
|
16 | 16 | import org.jetbrains.annotations.NotNull;
|
17 | 17 |
|
18 |
| -import java.util.Collections; |
19 |
| -import java.util.List; |
20 |
| -import java.util.Set; |
21 |
| -import java.util.WeakHashMap; |
| 18 | +import java.util.*; |
22 | 19 |
|
23 | 20 | /**
|
24 | 21 | *
|
@@ -275,20 +272,11 @@ private static boolean preventDamageCall(TownyWorld world, Entity attackingEntit
|
275 | 272 | }
|
276 | 273 |
|
277 | 274 | /*
|
278 |
| - * Actually "clear" axolotl's target. |
279 |
| - * See TownyEntityListener#onAxolotlTarget for more information. |
280 |
| - * This also makes it possible to make a nice fish tank where |
281 |
| - * the axolotls won't have attack behaviours on other fish |
282 |
| - * if Fish is specified in the protection.mob_types list. |
| 275 | + * Clear axolotl's target. |
283 | 276 | * */
|
284 |
| - if (attackingEntity.getType() == EntityType.AXOLOTL && EntityTypeUtil.isInstanceOfAny(TownySettings.getProtectedEntityTypes(), defendingEntity)) { |
285 |
| - if (TownyEntityListener.axolotlTargetExempt.containsKey(defendingEntity)) { |
286 |
| - TownyEntityListener.axolotlTargetExempt.get(defendingEntity).add(attackingEntity); |
287 |
| - } else { |
288 |
| - Set<Entity> axolotlSet = Collections.newSetFromMap(new WeakHashMap<>()); // axolotl attackers |
289 |
| - axolotlSet.add(attackingEntity); |
290 |
| - TownyEntityListener.axolotlTargetExempt.put(defendingEntity, axolotlSet); |
291 |
| - } |
| 277 | + if (attackingEntity instanceof Axolotl axolotl && EntityTypeUtil.isInstanceOfAny(TownySettings.getProtectedEntityTypes(), defendingEntity)) { |
| 278 | + axolotl.setTarget(null); |
| 279 | + axolotl.setMemory(MemoryKey.HAS_HUNTING_COOLDOWN, true); |
292 | 280 | return true;
|
293 | 281 | }
|
294 | 282 | }
|
|
0 commit comments