diff --git a/changelog.md b/changelog.md index 666d857..4e47c6c 100644 --- a/changelog.md +++ b/changelog.md @@ -20,6 +20,7 @@ These changes will (most likely) be included in the next version. - Food levels no longer deplete for players in the lobby and spectator area. - Wither skeletons now correctly spawn with stone swords. - Mobs now correctly take damage from player-made iron golems. +- Cat and parrot pets now also sit when their owner joins an arena (although parrots perching on players' shoulders will still follow them into the arena). - Support for denoting potion effects by magic number IDs has been dropped. This means that if your config-file has any such magic numbers in it, MobArena will no longer successfully parse them and will throw an error on startup. ## [0.103.2] - 2019-04-23 diff --git a/src/main/java/com/garbagemule/MobArena/steps/SitPets.java b/src/main/java/com/garbagemule/MobArena/steps/SitPets.java index 950f3d9..c975e7f 100644 --- a/src/main/java/com/garbagemule/MobArena/steps/SitPets.java +++ b/src/main/java/com/garbagemule/MobArena/steps/SitPets.java @@ -1,10 +1,9 @@ package com.garbagemule.MobArena.steps; import org.bukkit.entity.Entity; -import org.bukkit.entity.Ocelot; import org.bukkit.entity.Player; +import org.bukkit.entity.Sittable; import org.bukkit.entity.Tameable; -import org.bukkit.entity.Wolf; import java.util.Collections; import java.util.List; @@ -45,34 +44,27 @@ class SitPets extends PlayerStep { private static Predicate isPetOwnedBy(Player player) { return entity -> { - switch (entity.getType()) { - case WOLF: - case OCELOT: - return player.equals(((Tameable) entity).getOwner()); + if (entity instanceof Tameable) { + Tameable tameable = (Tameable) entity; + return player.equals(tameable.getOwner()); } return false; }; } private static boolean isFollowing(Entity entity) { - switch (entity.getType()) { - case WOLF: - return !((Wolf) entity).isSitting(); - case OCELOT: - return !((Ocelot) entity).isSitting(); + if (entity instanceof Sittable) { + Sittable sittable = (Sittable) entity; + return !sittable.isSitting(); } return false; } private static Consumer setSitting(boolean sitting) { return entity -> { - switch (entity.getType()) { - case WOLF: - ((Wolf) entity).setSitting(sitting); - break; - case OCELOT: - ((Ocelot) entity).setSitting(sitting); - break; + if (entity instanceof Sittable) { + Sittable sittable = (Sittable) entity; + sittable.setSitting(sitting); } }; }