Skip to content

Commit

Permalink
Fix issue with /remove skeletonhorse (#3477)
Browse files Browse the repository at this point in the history
Fixes a problem where skeleton trapped horses cannot be killed in commands such as `/remove skeletonhorse` (or even `/remove all`) because they are tamed by non-player entities. There is a separate command for killing tamed entities, however this kills other player-owned entities which is undesirable.

This can be replicated easily by spawning some skeleton traps like so:
`/summon skeleton_horse ~ ~ ~ {SkeletonTrap:1}`
and then attempting to run `/killall skeletonhorse`.

After this small change, any tamed skeleton horses will be retained, but non-player-owned skeleton horses will be removed as appropriate.

Closes #3475.
  • Loading branch information
pop4959 authored Jul 9, 2020
1 parent 07fa87d commit 6c64aae
Showing 1 changed file with 3 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import com.earth2me.essentials.Mob;
import com.earth2me.essentials.User;
import org.bukkit.Chunk;
import org.bukkit.OfflinePlayer;
import org.bukkit.Server;
import org.bukkit.World;
import org.bukkit.entity.*;
Expand Down Expand Up @@ -126,8 +127,8 @@ private void removeHandler(CommandSource sender, List<String> types, List<String

for (ToRemove toRemove : removeTypes) {

// We should skip any TAMED animals unless we are specifially targetting them.
if (e instanceof Tameable && ((Tameable) e).isTamed() && !removeTypes.contains(ToRemove.TAMED)) {
// We should skip any animals tamed by players unless we are specifially targetting them.
if (e instanceof Tameable && ((Tameable) e).isTamed() && (((Tameable) e).getOwner() instanceof Player || ((Tameable) e).getOwner() instanceof OfflinePlayer) && !removeTypes.contains(ToRemove.TAMED)) {
continue;
}

Expand Down

0 comments on commit 6c64aae

Please sign in to comment.