From 4b49b147e3998e4ddbf3df700e5667ac402ac5d2 Mon Sep 17 00:00:00 2001 From: libraryaddict Date: Fri, 31 Jul 2020 16:29:55 +1200 Subject: [PATCH] Allow /undisguiseradius to work for command blocks --- .../undisguise/UndisguiseRadiusCommand.java | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java b/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java index 1dc3840c..1d3105f1 100644 --- a/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java +++ b/src/main/java/me/libraryaddict/disguise/commands/undisguise/UndisguiseRadiusCommand.java @@ -4,6 +4,8 @@ import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.utilities.LibsPremium; import me.libraryaddict.disguise.utilities.translations.LibsMsg; import org.bukkit.ChatColor; +import org.bukkit.Location; +import org.bukkit.command.BlockCommandSender; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -54,11 +56,21 @@ public class UndisguiseRadiusCommand implements CommandExecutor { } } + Location center; + + if (sender instanceof Player) { + center = ((Player) sender).getLocation(); + } else { + center = ((BlockCommandSender) sender).getBlock().getLocation().add(0.5, 0, 0.5); + } + int disguisedEntitys = 0; - for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) { + + for (Entity entity : center.getWorld().getNearbyEntities(center, radius, radius, radius)) { if (entity == sender) { continue; } + if (DisguiseAPI.isDisguised(entity)) { DisguiseAPI.undisguiseToAll(entity); disguisedEntitys++;