diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java index ec5384ab5..a512189f7 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PaperListener.java @@ -60,7 +60,6 @@ import org.bukkit.event.entity.CreatureSpawnEvent; import org.bukkit.projectiles.ProjectileSource; import java.util.ArrayList; -import java.util.Arrays; import java.util.Collection; import java.util.List; import java.util.Locale; @@ -280,7 +279,7 @@ public class PaperListener implements Listener { } final int tileEntityCount = event.getBlock().getChunk().getTileEntities(false).length; if (tileEntityCount >= Settings.Chunk_Processor.MAX_TILES) { - final PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); + final PlotPlayer plotPlayer = BukkitUtil.getPlayer(event.getPlayer()); Captions.TILE_ENTITY_CAP_REACHED.send(plotPlayer, Settings.Chunk_Processor.MAX_TILES); event.setCancelled(true); event.setBuild(false); @@ -309,7 +308,7 @@ public class PaperListener implements Listener { if (!PlotSquared.get().hasPlotArea(location.getWorld())) { return; } - PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); + PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); Plot plot = location.getOwnedPlot(); if (plot != null && !plot.isAdded(pp.getUUID())) { entity.remove(); @@ -334,14 +333,14 @@ public class PaperListener implements Listener { final String[] unprocessedArgs = buffer.split(Pattern.quote(" ")); if (unprocessedArgs.length == 1) { return; // We don't do anything in this case - } else if (!Arrays.asList("plot", "plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap") + } else if (!Settings.Enabled_Components.TAB_COMPLETED_ALIASES .contains(unprocessedArgs[0].toLowerCase(Locale.ENGLISH))) { return; } final String[] args = new String[unprocessedArgs.length - 1]; System.arraycopy(unprocessedArgs, 1, args, 0, args.length); try { - final PlotPlayer player = BukkitUtil.getPlayer((Player) event.getSender()); + final PlotPlayer player = BukkitUtil.getPlayer((Player) event.getSender()); final Collection objects = MainCommand.getInstance().tab(player, args, buffer.endsWith(" ")); if (objects == null) { return; diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java index 2ac326b93..f94c54638 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listener/PlayerEvents.java @@ -253,7 +253,7 @@ public class PlayerEvents extends PlotListener implements Listener { int z = bloc.getBlockZ(); int distance = Bukkit.getViewDistance() * 16; - for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { + for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { Location location = player.getLocation(); if (location.getWorld().equals(world)) { if (16 * Math.abs(location.getX() - x) / 16 > distance @@ -313,7 +313,7 @@ public class PlayerEvents extends PlotListener implements Listener { Location location = BukkitUtil.getLocation(e.getEntity()); if (location.isPlotArea()) { if (e.getEntity() instanceof Player) { - PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity()); + PlotPlayer player = BukkitUtil.getPlayer((Player) e.getEntity()); Plot plot = player.getCurrentPlot(); if (plot != null) { if (!plot.isAdded(player.getUUID())) { @@ -346,6 +346,7 @@ public class PlayerEvents extends PlotListener implements Listener { } if (!plot.getFlag(RedstoneFlag.class)) { event.setNewCurrent(0); + plot.debug("Redstone event was cancelled because redstone = false"); return; } if (Settings.Redstone.DISABLE_OFFLINE) { @@ -372,12 +373,13 @@ public class PlayerEvents extends PlotListener implements Listener { } if (disable) { event.setNewCurrent(0); + plot.debug("Redstone event was cancelled because no trusted player was in the plot"); return; } } } if (Settings.Redstone.DISABLE_UNOCCUPIED) { - for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { + for (final PlotPlayer player : PlotSquared.imp().getPlayerManager().getPlayers()) { if (plot.equals(player.getCurrentPlot())) { return; } @@ -484,7 +486,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (!PlotSquared.get().hasPlotArea(location.getWorld())) { return; } - PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); + PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); Plot plot = location.getOwnedPlot(); if (plot != null && !plot.isAdded(pp.getUUID())) { entity.remove(); @@ -505,7 +507,7 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = area.getPlot(location); ProjectileSource shooter = entity.getShooter(); if (shooter instanceof Player) { - PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); + PlotPlayer pp = BukkitUtil.getPlayer((Player) shooter); if (plot == null) { if (!Permissions.hasPermission(pp, Captions.PERMISSION_PROJECTILE_UNOWNED)) { entity.remove(); @@ -547,7 +549,7 @@ public class PlayerEvents extends PlotListener implements Listener { return; } Player player = event.getPlayer(); - PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); + PlotPlayer plotPlayer = BukkitUtil.getPlayer(player); Location location = plotPlayer.getLocation(); PlotArea area = location.getPlotArea(); if (area == null) { @@ -652,7 +654,7 @@ public class PlayerEvents extends PlotListener implements Listener { public void onConnect(PlayerJoinEvent event) { final Player player = event.getPlayer(); BukkitUtil.removePlayer(player.getName()); - final PlotPlayer pp = BukkitUtil.getPlayer(player); + final PlotPlayer pp = BukkitUtil.getPlayer(player); Location location = pp.getLocation(); PlotArea area = location.getPlotArea(); @@ -691,7 +693,7 @@ public class PlayerEvents extends PlotListener implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void playerRespawn(PlayerRespawnEvent event) { Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); + PlotPlayer pp = BukkitUtil.getPlayer(player); PlotSquared.get().getEventDispatcher().doRespawnTask(pp); } @@ -958,7 +960,7 @@ public class PlayerEvents extends PlotListener implements Listener { Set recipients = event.getRecipients(); recipients.clear(); Set spies = new HashSet<>(); - for (final PlotPlayer pp : PlotSquared.imp().getPlayerManager().getPlayers()) { + for (final PlotPlayer pp : PlotSquared.imp().getPlayerManager().getPlayers()) { if (pp.getAttribute("chatspy")) { spies.add(((BukkitPlayer) pp).player); } else { @@ -1106,6 +1108,8 @@ public class PlayerEvents extends PlotListener implements Listener { } } return; + } else { + plot.debug("Explosion was cancelled because explosion = false"); } } event.setCancelled(true); @@ -1150,6 +1154,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (area != null) { Plot plot = area.getOwnedPlot(location); if (plot != null && plot.getFlag(MobPlaceFlag.class)) { + plot.debug(e.getType() + " could not change block because mob-place = false"); return; } event.setCancelled(true); @@ -1179,6 +1184,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (!plot.hasOwner()) { BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (plot.getFlag(IceFormFlag.class)) { + plot.debug("Ice could not be formed because ice-form = false"); return; } event.setCancelled(true); @@ -1187,6 +1193,7 @@ public class PlayerEvents extends PlotListener implements Listener { BukkitPlayer plotPlayer = BukkitUtil.getPlayer(player); if (!plot.isAdded(plotPlayer.getUUID())) { if (plot.getFlag(IceFormFlag.class)) { + plot.debug("Ice could not be formed because ice-form = false"); return; } event.setCancelled(true); @@ -1218,21 +1225,25 @@ public class PlayerEvents extends PlotListener implements Listener { switch (event.getSource().getType()) { case GRASS_BLOCK: if (!plot.getFlag(GrassGrowFlag.class)) { + plot.debug("Grass could not grow because grass-grow = false"); event.setCancelled(true); } break; case MYCELIUM: if (!plot.getFlag(MycelGrowFlag.class)) { + plot.debug("Mycelium could not grow because mycel-grow = false"); event.setCancelled(true); } break; case VINE: if (!plot.getFlag(VineGrowFlag.class)) { + plot.debug("Vine could not grow because vine-grow = false"); event.setCancelled(true); } break; case KELP: if (!plot.getFlag(KelpGrowFlag.class)) { + plot.debug("Kelp could not grow because kelp-grow = false"); event.setCancelled(true); } break; @@ -1259,6 +1270,7 @@ public class PlayerEvents extends PlotListener implements Listener { case SNOW: case SNOW_BLOCK: if (!plot.getFlag(SnowFormFlag.class)) { + plot.debug("Snow could not form because snow-form = false"); event.setCancelled(true); } return; @@ -1266,6 +1278,7 @@ public class PlayerEvents extends PlotListener implements Listener { case FROSTED_ICE: case PACKED_ICE: if (!plot.getFlag(IceFormFlag.class)) { + plot.debug("Ice could not form because ice-form = false"); event.setCancelled(true); } } @@ -1315,6 +1328,8 @@ public class PlayerEvents extends PlotListener implements Listener { .hasPermission(plotPlayer, Captions.PERMISSION_ADMIN_DESTROY_OTHER)) { return; } + plot.debug(player.getName() + " could not break " + block.getType() + + " because it was not in the break flag"); event.setCancelled(true); return; } @@ -1343,16 +1358,19 @@ public class PlayerEvents extends PlotListener implements Listener { switch (block.getType()) { case ICE: if (!plot.getFlag(IceMeltFlag.class)) { + plot.debug("Ice could not melt because ice-melt = false"); event.setCancelled(true); } break; case SNOW: if (!plot.getFlag(SnowMeltFlag.class)) { + plot.debug("Snow could not melt because snow-melt = false"); event.setCancelled(true); } break; case FARMLAND: if (!plot.getFlag(SoilDryFlag.class)) { + plot.debug("Soil could not dry because soil-dry = false"); event.setCancelled(true); } break; @@ -1372,6 +1390,7 @@ public class PlayerEvents extends PlotListener implements Listener { case FIRE_CORAL_FAN: case HORN_CORAL_FAN: if (!plot.getFlag(CoralDryFlag.class)) { + plot.debug("Coral could not dry because coral-dry = false"); event.setCancelled(true); } break; @@ -1390,6 +1409,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (plot != null && plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event .getBlock().isLiquid()) { + plot.debug("Liquid could now flow because liquid-flow = disabled"); event.setCancelled(true); return; } @@ -1413,11 +1433,13 @@ public class PlayerEvents extends PlotListener implements Listener { return; } if (plot.getFlag(DisablePhysicsFlag.class)) { + plot.debug(event.getBlock().getType() + " could not update because disable-physics = true"); event.setCancelled(true); return; } if (plot.getFlag(LiquidFlowFlag.class) == LiquidFlowFlag.FlowStatus.DISABLED && event .getBlock().isLiquid()) { + plot.debug("Liquid could not flow because liquid-flow = disabled"); event.setCancelled(true); } } else if (!area.contains(fLocation.getX(), fLocation.getZ()) || !Objects @@ -1698,6 +1720,7 @@ public class PlayerEvents extends PlotListener implements Listener { !Permissions.hasPermission(pp, Captions.PERMISSION_ADMIN_INTERACT_OTHER)) { final ItemStack newStack = new ItemStack(newItem.getType(), newItem.getAmount()); event.setCursor(newStack); + plot.debug(player.getName() + " could not creative-copy an item because prevent-creative-copy = true"); } return; } @@ -1845,6 +1868,7 @@ public class PlayerEvents extends PlotListener implements Listener { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.interact.other"); e.setCancelled(true); + plot.debug(pp.getName() + " could not interact with " + entity.getType() + " bcause misc-interact = false"); } } } @@ -1872,6 +1896,9 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = area.getOwnedPlot(location); if (plot == null || !plot.getFlag(ExplosionFlag.class)) { event.setCancelled(true); + if (plot != null) { + plot.debug("Explosion was cancelled because explosion = false"); + } } event.blockList().removeIf( blox -> !plot.equals(area.getOwnedPlot(BukkitUtil.getLocation(blox.getLocation())))); @@ -2137,6 +2164,7 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = area.getOwnedPlotAbs(location); if (plot == null || plot.getFlag(DisablePhysicsFlag.class)) { event.setCancelled(true); + plot.debug("Falling block event was cancelled because disable-physics = true"); return; } if (event.getTo().hasGravity()) { @@ -2172,6 +2200,7 @@ public class PlayerEvents extends PlotListener implements Listener { Plot plot = location.getOwnedPlot(); if (plot == null || !plot.getFlag(BlockBurnFlag.class)) { + plot.debug("Block burning was cancelled because block-burn = false"); event.setCancelled(true); } @@ -2225,6 +2254,7 @@ public class PlayerEvents extends PlotListener implements Listener { if (ignitingEntity != null) { if (!plot.getFlag(BlockIgnitionFlag.class)) { event.setCancelled(true); + plot.debug("Block ignition was cancelled because block-ignition = false"); return; } if (igniteCause == BlockIgniteEvent.IgniteCause.FIREBALL) { @@ -2475,6 +2505,7 @@ public class PlayerEvents extends PlotListener implements Listener { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_OTHER); event.setCancelled(true); + plot.debug(p.getName() + " could not break hanging entity because hanging-break = false"); } } } else if (remover instanceof Projectile) { @@ -2503,6 +2534,7 @@ public class PlayerEvents extends PlotListener implements Listener { MainUtil.sendMessage(player, Captions.NO_PERMISSION_EVENT, Captions.PERMISSION_ADMIN_DESTROY_OTHER); event.setCancelled(true); + plot.debug(player.getName() + " could not break hanging entity because hanging-break = false"); } } } @@ -2621,6 +2653,7 @@ public class PlayerEvents extends PlotListener implements Listener { MainUtil.sendMessage(pp, Captions.NO_PERMISSION_EVENT, "plots.admin.vehicle.break.other"); event.setCancelled(true); + plot.debug(pp.getName() + " could not break vehicle because vehicle-break = false"); } } } @@ -2815,6 +2848,9 @@ public class PlayerEvents extends PlotListener implements Listener { if (!Permissions.hasPermission(plotPlayer, "plots.admin.destroy." + stub)) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, "plots.admin.destroy." + stub); + if (plot != null) { + plot.debug(player.getName() + " could not break armor stand because misc-break = false"); + } return false; } } else if (EntityCategories.HOSTILE.contains(entityType)) { @@ -2825,6 +2861,9 @@ public class PlayerEvents extends PlotListener implements Listener { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); + if (plot != null) { + plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR hostile-attack = false"); + } return false; } } else if (EntityCategories.TAMEABLE.contains(entityType)) { // victim is tameable @@ -2835,6 +2874,9 @@ public class PlayerEvents extends PlotListener implements Listener { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); + if (plot != null) { + plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR tamned-attack = false"); + } return false; } } else if (EntityCategories.PLAYER.contains(entityType)) { @@ -2843,6 +2885,7 @@ public class PlayerEvents extends PlotListener implements Listener { .hasPermission(plotPlayer, "plots.admin.pvp." + stub)) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, "plots.admin.pvp." + stub); + plot.debug(player.getName() + " could not attack " + entityType + " because pve = false"); return false; } else { return true; @@ -2856,6 +2899,7 @@ public class PlayerEvents extends PlotListener implements Listener { } else if (EntityCategories.ANIMAL.contains(entityType)) { // victim is animal if (plot != null && (plot.getFlag(AnimalAttackFlag.class) || plot .getFlag(PveFlag.class) || plot.isAdded(plotPlayer.getUUID()))) { + plot.debug(player.getName() + " could not attack " + entityType + " because pve = false OR animal-attack = false"); return true; } if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { @@ -2874,6 +2918,9 @@ public class PlayerEvents extends PlotListener implements Listener { if (!Permissions.hasPermission(plotPlayer, "plots.admin.pve." + stub)) { MainUtil.sendMessage(plotPlayer, Captions.NO_PERMISSION_EVENT, "plots.admin.pve." + stub); + if (plot != null) { + plot.debug(player.getName() + " could not attack " + entityType + " because pve = false"); + } return false; } } diff --git a/Core/src/main/java/com/plotsquared/core/command/Debug.java b/Core/src/main/java/com/plotsquared/core/command/Debug.java index 8a4ef1737..91997a4ec 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Debug.java +++ b/Core/src/main/java/com/plotsquared/core/command/Debug.java @@ -72,6 +72,13 @@ public class Debug extends SubCommand { MainUtil.sendMessage(player, String.format("There are %d cached UUIDs", mappings.size())); return true; } + if (args.length > 0 && "debug-players".equalsIgnoreCase(args[0])) { + MainUtil.sendMessage(player, "Player in debug mode: " ); + for (final PlotPlayer pp : PlotPlayer.getDebugModePlayers()) { + MainUtil.sendMessage(player, "- " + pp.getName()); + } + return true; + } if (args.length > 0 && "entitytypes".equalsIgnoreCase(args[0])) { EntityCategories.init(); player.sendMessage(Captions.PREFIX.getTranslated() + "§cEntity Categories: "); diff --git a/Core/src/main/java/com/plotsquared/core/command/Toggle.java b/Core/src/main/java/com/plotsquared/core/command/Toggle.java index c0085fb6c..e9e46ac7a 100644 --- a/Core/src/main/java/com/plotsquared/core/command/Toggle.java +++ b/Core/src/main/java/com/plotsquared/core/command/Toggle.java @@ -129,7 +129,7 @@ public class Toggle extends Command { public void debug(Command command, PlotPlayer player, String[] args, RunnableVal3 confirm, RunnableVal2 whenDone) { - if (toggle(player, "debug")) { + if (!toggle(player, "debug")) { MainUtil.sendMessage(player, Captions.TOGGLE_ENABLED, command.toString()); } else { MainUtil.sendMessage(player, Captions.TOGGLE_DISABLED, command.toString()); diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java index 03f08cda9..03874da48 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Captions.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Captions.java @@ -805,7 +805,7 @@ public enum Captions implements Caption { // // - PLOT_DEBUG("$1Plot Debug ($2%plot%$1): %message%", "Plot-Debug"), + PLOT_DEBUG("$2Plot Debug ($1%plot%$2): %message%", "Plot-Debug"), // /** diff --git a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java index dc10790d8..7b0196412 100644 --- a/Core/src/main/java/com/plotsquared/core/configuration/Settings.java +++ b/Core/src/main/java/com/plotsquared/core/configuration/Settings.java @@ -568,6 +568,8 @@ public class Settings extends Config { "Read more about components here: https://wiki.intellectualsites.com/en/plotsquared/installation/plot-components"}) public static boolean COMPONENT_PRESETS = true; @Comment("Use UUID cache to complete usernames") public static boolean EXTENDED_USERNAME_COMPLETION = true; + @Comment("Command aliases that will be tab completed") + public static List TAB_COMPLETED_ALIASES = Arrays.asList("plot", "plots", "p", "plotsquared", "plot2", "p2", "ps", "2", "plotme", "plotz", "ap"); } } diff --git a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java index 47470d80e..a9af02b65 100644 --- a/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java +++ b/Core/src/main/java/com/plotsquared/core/player/PlotPlayer.java @@ -87,7 +87,7 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer private ConcurrentHashMap meta; private int hash; - public static PlotPlayer from(@NonNull final T object) { + public static PlotPlayer from(@NonNull final T object) { if (!converters.containsKey(object.getClass())) { throw new IllegalArgumentException(String .format("There is no registered PlotPlayer converter for type %s", @@ -101,7 +101,11 @@ public abstract class PlotPlayer

implements CommandCaller, OfflinePlotPlayer converters.put(clazz, converter); } - public static Collection> getDebugModePlayerInPlot(@NotNull final Plot plot) { + public static Collection> getDebugModePlayers() { + return Collections.unmodifiableCollection(debugModeEnabled); + } + + public static Collection> getDebugModePlayersInPlot(@NotNull final Plot plot) { if (debugModeEnabled.isEmpty()) { return Collections.emptyList(); } diff --git a/Core/src/main/java/com/plotsquared/core/plot/Plot.java b/Core/src/main/java/com/plotsquared/core/plot/Plot.java index 85410628c..83e616e9f 100644 --- a/Core/src/main/java/com/plotsquared/core/plot/Plot.java +++ b/Core/src/main/java/com/plotsquared/core/plot/Plot.java @@ -2925,7 +2925,7 @@ public class Plot { } public void debug(@NotNull final String message) { - final Collection> players = PlotPlayer.getDebugModePlayerInPlot(this); + final Collection> players = PlotPlayer.getDebugModePlayersInPlot(this); if (players.isEmpty()) { return; }