From 5cfac1d8cff9f6ff612b14eb27b8be79d2a0c8c9 Mon Sep 17 00:00:00 2001 From: "Larry (Wolfieheart)" Date: Thu, 19 Oct 2023 17:24:45 +0200 Subject: [PATCH] [CORE] ArmorStandEditor 1.20.2-44.1 - QoL Hotfixes (#349) * [CORE] Bump to 1.20.2-44.1 * [CORE] Allow easy way to allow all worlds by default. Fixes #348 * [CORE] Forgot to change the call for the check to see if a user can RMB to activate the UI. Fixes #348 * [CORE] Update Folia Check and Fix Scoreboard is Null Errors * [CORE] Stricter Check for `/ase stats` usage * [CORE] Better Implementation for the Per World Support Fix * [CORE] Make Per World Support a toggleable thing instead of having a default * [CORE] Merge if Statements when checking PerWorld Signed-off-by: Wolfieheart * [CORE] Fix Folia Leftoever, Fix P2 Protection and add Debug in a few places. Signed-off-by: Wolfieheart * [CORE] Move glowing Item to a better slot Signed-off-by: Wolfieheart * [CORE] Update Config.yml comments to better explain the ASE Per World Implementation Signed-off-by: Wolfieheart --------- Signed-off-by: Wolfieheart --- pom.xml | 2 +- .../ArmorStandEditorPlugin.java | 84 ++++-- .../rypofalem/armorstandeditor/CommandEx.java | 243 +++++++++--------- .../armorstandeditor/PlayerEditorManager.java | 17 +- .../rypofalem/armorstandeditor/Scheduler.java | 11 +- .../rypofalem/armorstandeditor/menu/Menu.java | 4 +- .../protections/PlotSquaredProtection.java | 7 +- src/main/resources/config.yml | 15 +- src/main/resources/plugin.yml | 3 +- 9 files changed, 227 insertions(+), 159 deletions(-) diff --git a/pom.xml b/pom.xml index b7787352..addddfd0 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.rypofalem.armorstandeditor armorstandeditor jar - 1.20.2-44 + 1.20.2-44.1 armorstandeditor http://maven.apache.org diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java index 43179151..b6a8d3bd 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java @@ -26,10 +26,7 @@ import io.github.rypofalem.armorstandeditor.Metrics.*; import io.github.rypofalem.armorstandeditor.language.Language; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; -import org.bukkit.Material; -import org.bukkit.NamespacedKey; +import org.bukkit.*; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.Damageable; @@ -59,9 +56,10 @@ public class ArmorStandEditorPlugin extends JavaPlugin { String warningMCVer = "Minecraft Version: "; public boolean hasSpigot = false; public boolean hasPaper = false; + public boolean hasFolia = false; String nmsVersionNotLatest = null; PluginDescriptionFile pdfFile = this.getDescription(); - static final String SEPARATOR_FIELD = "================================"; + public static final String SEPARATOR_FIELD = "================================"; public PlayerEditorManager editorManager; @@ -79,6 +77,7 @@ public class ArmorStandEditorPlugin extends JavaPlugin { String editToolName = null; boolean requireToolLore = false; List editToolLore = null; + boolean enablePerWorld = false; List allowedWorldList = null; boolean allowCustomModelData = false; Integer customModelDataInt = Integer.MIN_VALUE; @@ -103,6 +102,9 @@ public class ArmorStandEditorPlugin extends JavaPlugin { public Team team; String lockedTeam = "ASLocked"; + //Debugging Options.... Not Exposed + boolean debugFlag; + private static ArmorStandEditorPlugin plugin; public ArmorStandEditorPlugin() { @@ -143,6 +145,7 @@ public void onEnable() { //Spigot Check hasSpigot = getHasSpigot(); hasPaper = getHasPaper(); + hasFolia = Scheduler.isFolia(); //If Paper and Spigot are both FALSE - Disable the plugin if (!hasPaper && !hasSpigot) { @@ -159,7 +162,15 @@ public void onEnable() { } getServer().getPluginManager().enablePlugin(this); - if (!Scheduler.isFolia()) registerScoreboards(scoreboard); + + if (!hasFolia) { + scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); + registerScoreboards(scoreboard); + } else { + getServer().getLogger().warning("Scoreboards currently do not work on Folia. Scoreboard Coloring will not work"); + } + + getLogger().info(SEPARATOR_FIELD); //saveResource doesn't accept File.separator on Windows, need to hardcode unix separator "/" instead @@ -226,7 +237,13 @@ public void onEnable() { editToolLore = getConfig().getList("toolLore", null); } - allowedWorldList = getConfig().getList("allowed-worlds", null); + enablePerWorld = getConfig().getBoolean("enablePerWorldSupport", false); + if(enablePerWorld) { + allowedWorldList = getConfig().getList("allowed-worlds", null); + if (allowedWorldList != null && allowedWorldList.get(0).equals("*")) { + allowedWorldList = getServer().getWorlds().stream().map(World::getName).toList(); + } + } //Require Sneaking - Wolfst0rm/ArmorStandEditor#17 requireSneaking = getConfig().getBoolean("requireSneaking", false); @@ -250,8 +267,17 @@ public void onEnable() { adminOnlyNotifications = getConfig().getBoolean("adminOnlyNotifications", true); + debugFlag = getConfig().getBoolean("debugFlag", false); + if(debugFlag){ + getServer().getLogger().warning(ArmorStandEditorPlugin.SEPARATOR_FIELD); + getServer().getLogger().warning(" ArmorStandEditor - Debug Mode "); + getServer().getLogger().warning(" Debug Mode: ENABLED! "); + getServer().getLogger().warning(" USE THIS FOR DEVELOPMENT PURPOSES ONLY! "); + getServer().getLogger().warning(ArmorStandEditorPlugin.SEPARATOR_FIELD); + } + //Run UpdateChecker - Reports out to Console on Startup ONLY! - if (!Scheduler.isFolia() && runTheUpdateChecker) { + if (!hasFolia && runTheUpdateChecker) { if (opUpdateNotification) { runUpdateCheckerWithOPNotifyOnJoinEnabled(); @@ -316,14 +342,14 @@ private void runUpdateCheckerWithOPNotifyOnJoinEnabled() { //Implement Glow Effects for Wolfstorm/ArmorStandEditor-Issues#5 - Add Disable Slots with Different Glow than Default private void registerScoreboards(Scoreboard scoreboard) { - getLogger().info("Registering Scoreboards required for Glowing Effects"); + getServer().getLogger().info("Registering Scoreboards required for Glowing Effects"); //Fix for Scoreboard Issue reported by Starnos - Wolfst0rm/ArmorStandEditor-Issues/issues/18 if (scoreboard.getTeam(lockedTeam) == null) { scoreboard.registerNewTeam(lockedTeam); - Objects.requireNonNull(scoreboard.getTeam(lockedTeam)).setColor(ChatColor.RED); + scoreboard.getTeam(lockedTeam).setColor(ChatColor.RED); } else { - getLogger().info("Scoreboard for ASLocked Already exists. Continuing to load"); + getServer().getLogger().info("Scoreboard for ASLocked Already exists. Continuing to load"); } } @@ -350,7 +376,7 @@ public void onDisable() { if (player.getOpenInventory().getTopInventory().getHolder() == editorManager.getMenuHolder()) player.closeInventory(); } - if (!Scheduler.isFolia()) { + if (!hasFolia) { scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); unregisterScoreboards(scoreboard); } @@ -374,7 +400,7 @@ public boolean getHasSpigot() { public boolean getHasPaper() { try { Class.forName("com.destroystokyo.paper.PaperConfig"); - nmsVersionNotLatest = "SpigotMC ASAP."; + nmsVersionNotLatest = "PaperMC ASAP."; return true; } catch (ClassNotFoundException e) { nmsVersionNotLatest = ""; @@ -382,6 +408,9 @@ public boolean getHasPaper() { } } + public boolean getHasFolia() { + return Scheduler.isFolia(); + } public String getArmorStandEditorVersion() { return getConfig().getString("version"); @@ -496,12 +525,10 @@ public boolean isEditTool(ItemStack itemStk) { } return true; } - - - public void performReload() { + public void performReload() { //Unregister Scoreboard before before performing the reload - if (!Scheduler.isFolia()) { + if (!hasFolia) { scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); unregisterScoreboards(scoreboard); } @@ -510,7 +537,7 @@ public void performReload() { reloadConfig(); //Re-Register Scoreboards - if (!Scheduler.isFolia()) registerScoreboards(scoreboard); + if (!hasFolia) registerScoreboards(scoreboard); //Reload Config File reloadConfig(); @@ -559,7 +586,14 @@ public void performReload() { editToolLore = getConfig().getList("toolLore", null); } - allowedWorldList = getConfig().getList("allowed-worlds", null); + + enablePerWorld = getConfig().getBoolean("enablePerWorldSupport", false); + if(enablePerWorld) { + allowedWorldList = getConfig().getList("allowed-worlds", null); + if (allowedWorldList != null && allowedWorldList.get(0).equals("*")) { + allowedWorldList = getServer().getWorlds().stream().map(World::getName).toList(); + } + } //Require Sneaking - Wolfst0rm/ArmorStandEditor#17 requireSneaking = getConfig().getBoolean("requireSneaking", false); @@ -583,7 +617,7 @@ public void performReload() { updateCheckerInterval = getConfig().getDouble("updateCheckerInterval", 24); //Run UpdateChecker - Reports out to Console on Startup ONLY! - if (!Scheduler.isFolia() && runTheUpdateChecker) { + if (!hasFolia && runTheUpdateChecker) { if (opUpdateNotification) { runUpdateCheckerWithOPNotifyOnJoinEnabled(); @@ -671,4 +705,14 @@ public NamespacedKey getIconKey() { return iconKey; } + /** + * For debugging ASE - Do not use this outside of Development or stuff + */ + public boolean isDebug() { + return debugFlag; + } + + public void debugMsgHandler(String msg){ + if(isDebug()) getServer().getLogger().log(Level.WARNING, "[ASE-DEBUG]: {0}", msg); + } } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java b/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java index 409d6814..ee1f3fb9 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java @@ -74,6 +74,7 @@ public CommandEx(ArmorStandEditorPlugin armorStandEditorPlugin) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (sender instanceof ConsoleCommandSender) { //Fix to Support #267 + if(plugin.isDebug()) plugin.debugMsgHandler("Sender is CONSOLE!"); if (args.length == 0) { sender.sendMessage(VERSION); sender.sendMessage(HELP); @@ -93,11 +94,13 @@ public boolean onCommand(CommandSender sender, Command command, String label, St } if (sender instanceof Player player && !getPermissionBasic(player)) { + if(plugin.isDebug()) plugin.debugMsgHandler("Sender is Player but asedit.basic is" + getPermissionBasic(player)); sender.sendMessage(plugin.getLang().getMessage("nopermoption", "warn", "basic")); return true; } else { - Player player = (Player) sender; + + if(plugin.isDebug()) plugin.debugMsgHandler("Sender is Player and asedit.basic is" + getPermissionBasic(player)); if (args.length == 0) { player.sendMessage(LISTMODE); player.sendMessage(LISTAXIS); @@ -161,6 +164,7 @@ private void commandGive(Player player) { } private void commandGivePlayerHead(Player player, String[] args) { + if (plugin.getAllowedToRetrievePlayerHead() && checkPermission(player, "head", true)) { if (args.length == 2) { @@ -309,6 +313,7 @@ private void commandMode(Player player, String[] args) { if (args[1].equals("invisible") && !(checkPermission(player, "togglearmorstandvisibility", true) || plugin.getArmorStandVisibility())) return; if (args[1].equals("itemframe") && !(checkPermission(player, "toggleitemframevisibility", true) || plugin.getItemFrameVisibility())) return; plugin.editorManager.getPlayerEditor(player.getUniqueId()).setMode(mode); + if(plugin.isDebug()) plugin.debugMsgHandler(player.getDisplayName() + " chose the mode: " + mode); return; } } @@ -339,13 +344,14 @@ private void commandUpdate(Player player) { if (!(checkPermission(player, "update", true))) return; //Only Run if the Update Command Works + if (plugin.isDebug()) plugin.debugMsgHandler("Current ArmorStandEditor Version is: " + plugin.getArmorStandEditorVersion()); if (plugin.getArmorStandEditorVersion().contains(".x")) { player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Update Checker will not work on Development Versions."); player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Report all bugs to: https://github.com/Wolfieheart/ArmorStandEditor/issues"); } else { - if (!Scheduler.isFolia() && plugin.getRunTheUpdateChecker()) { + if (!plugin.getHasFolia() && plugin.getRunTheUpdateChecker()) { new UpdateChecker(plugin, UpdateCheckSource.SPIGOT, "" + ArmorStandEditorPlugin.SPIGOT_RESOURCE_ID + "").checkNow(player); //Runs Update Check - } else if (Scheduler.isFolia()) { + } else if (plugin.getHasFolia()) { player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Update Checker does not currently work on Folia."); player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Report all bugs to: https://github.com/Wolfieheart/ArmorStandEditor/issues"); } else { @@ -355,6 +361,8 @@ private void commandUpdate(Player player) { } private void commandVersion(Player player) { + if (plugin.isDebug()) plugin.debugMsgHandler(player.getDisplayName() + " permission check for asedit.update: " + getPermissionUpdate(player)); + if (!(getPermissionUpdate(player))) return; String verString = plugin.getArmorStandEditorVersion(); player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Version: " + verString); @@ -366,6 +374,8 @@ private void commandVersionConsole(CommandSender sender) { } private void commandReload(Player player) { + if (plugin.isDebug()) plugin.debugMsgHandler(player.getDisplayName() + " permission check for asedit.reload: " + getPermissionReload(player)); + if (!(getPermissionReload(player))) return; plugin.performReload(); player.sendMessage(plugin.getLang().getMessage("reloaded", "")); @@ -377,119 +387,122 @@ private void commandReloadConsole(CommandSender sender) { } private void commandStats(Player player) { - if(!getPermissionStats(player)) return; - for(Entity e : player.getNearbyEntities(1,1,1)){ - if(e instanceof ArmorStand as){ - - //Calculation TIME - Might move this out later, but is OK here for now - double headX = as.getHeadPose().getX(); - headX = Math.toDegrees(headX); - headX = Math.rint(headX); - - double headY = as.getHeadPose().getY(); - headY = Math.toDegrees(headY); - headY = Math.rint(headY); - - double headZ = as.getHeadPose().getZ(); - headZ = Math.toDegrees(headZ); - headZ = Math.rint(headZ); - - //Body - double bodyX = as.getBodyPose().getX(); - bodyX = Math.toDegrees(bodyX); - bodyX = Math.rint(bodyX); - - double bodyY = as.getBodyPose().getY(); - bodyY = Math.toDegrees(bodyY); - bodyY = Math.rint(bodyY); - - double bodyZ = as.getBodyPose().getZ(); - bodyZ = Math.toDegrees(bodyZ); - bodyZ = Math.rint(bodyZ); - - - //Arms - double rightArmX = as.getRightArmPose().getX(); - rightArmX = Math.toDegrees(rightArmX); - rightArmX = Math.rint(rightArmX); - - double rightArmY = as.getRightArmPose().getY(); - rightArmY = Math.toDegrees(rightArmY); - rightArmY = Math.rint(rightArmY); - - double rightArmZ = as.getRightArmPose().getZ(); - rightArmZ = Math.toDegrees(rightArmZ); - rightArmZ = Math.rint(rightArmZ); - - - double leftArmX = as.getLeftArmPose().getX(); - leftArmX = Math.toDegrees(leftArmX); - leftArmX = Math.rint(leftArmX); - - double leftArmY = as.getLeftArmPose().getY(); - leftArmY = Math.toDegrees(leftArmY); - leftArmY = Math.rint(leftArmY); - - double leftArmZ = as.getLeftArmPose().getZ(); - leftArmZ = Math.toDegrees(leftArmZ); - leftArmZ = Math.rint(leftArmZ); - - //Legs - double rightLegX = as.getRightLegPose().getX(); - rightLegX = Math.toDegrees(rightLegX); - rightLegX = Math.rint(rightLegX); - - double rightLegY = as.getRightLegPose().getY(); - rightLegY = Math.toDegrees(rightLegY); - rightLegY = Math.rint(rightLegY); - - double rightLegZ = as.getRightLegPose().getZ(); - rightLegZ = Math.toDegrees(rightLegZ); - rightArmX = Math.rint(rightLegZ); - - double leftLegX = as.getLeftLegPose().getX(); - leftLegX = Math.toDegrees(leftLegX); - leftLegX = Math.rint(leftLegX); - - double leftLegY = as.getLeftLegPose().getY(); - leftLegY = Math.toDegrees(leftLegY); - leftLegY = Math.rint(leftLegY); - - double leftLegZ = as.getLeftLegPose().getZ(); - leftLegZ = Math.toDegrees(leftLegZ); - leftLegZ = Math.rint(leftLegZ); - - //Coordinates - float locationX = (float) as.getLocation().getX(); - float locationY = (float) as.getLocation().getY(); - float locationZ = (float) as.getLocation().getZ(); - - //Toggles - boolean isVisible = as.isVisible(); - boolean armsVisible = as.hasArms(); - boolean basePlateVisible = as.hasBasePlate(); - boolean isVulnerable = as.isInvulnerable(); - boolean hasGravity = as.hasGravity(); - boolean isSmall = as.isSmall(); - boolean isGlowing = as.isGlowing(); - boolean isLocked = plugin.scoreboard.getTeam(plugin.lockedTeam).hasEntry(as.getUniqueId().toString()); - - player.sendMessage(ChatColor.YELLOW + "----------- Armor Stand Statistics -----------"); - player.sendMessage(ChatColor.YELLOW + plugin.getLang().getMessage("stats")); - player.sendMessage(ChatColor.YELLOW + "Head: " + ChatColor.AQUA + headX + " / " + headY + " / " + headZ); - player.sendMessage(ChatColor.YELLOW + "Body: " + ChatColor.AQUA + bodyX + " / " + bodyY + " / " + bodyZ); - player.sendMessage(ChatColor.YELLOW + "Right Arm: " + ChatColor.AQUA + rightArmX + " / " + rightArmY + " / " + rightArmZ); - player.sendMessage(ChatColor.YELLOW + "Left Arm: " + ChatColor.AQUA + leftArmX + " / " + leftArmY + " / " + leftArmZ); - player.sendMessage(ChatColor.YELLOW + "Right Leg: " + ChatColor.AQUA + rightLegX + " / " + rightLegY + " / " + rightLegZ); - player.sendMessage(ChatColor.YELLOW + "Left Leg: " + ChatColor.AQUA + leftLegX + " / " + leftLegY + " / " + leftLegZ); - player.sendMessage(ChatColor.YELLOW + "Coordinates: " + ChatColor.AQUA + " x: " + locationX + " / y: " + locationY + " / z: " + locationZ); - player.sendMessage(ChatColor.YELLOW + "Is Visible: " + ChatColor.AQUA + isVisible + ". " + ChatColor.YELLOW + "Arms Visible: " + ChatColor.AQUA + armsVisible + ". " + ChatColor.YELLOW + "Base Plate Visible: "+ ChatColor.AQUA + basePlateVisible); - player.sendMessage(ChatColor.YELLOW + "Is Vulnerable: " + ChatColor.AQUA + isVulnerable + ". " + ChatColor.YELLOW + "Affected by Gravity: " + ChatColor.AQUA + hasGravity); - player.sendMessage(ChatColor.YELLOW + "Is Small: " + ChatColor.AQUA + isSmall + ". " + ChatColor.YELLOW + "Is Glowing: " + ChatColor.AQUA + isGlowing + ". " + ChatColor.YELLOW + "Is Locked: " + ChatColor.AQUA + isLocked); - player.sendMessage(ChatColor.YELLOW + "----------------------------------------------"); - } else{ - player.sendMessage(plugin.getLang().getMessage("norangeforstats", "warn")); + if (plugin.isDebug()) plugin.debugMsgHandler(player.getDisplayName() + " permission check for asedit.stats: " + getPermissionStats(player)); + + if(getPermissionStats(player)) { + for (Entity e : player.getNearbyEntities(1, 1, 1)) { + if (e instanceof ArmorStand as) { + + //Calculation TIME - Might move this out later, but is OK here for now + double headX = as.getHeadPose().getX(); + headX = Math.toDegrees(headX); + headX = Math.rint(headX); + + double headY = as.getHeadPose().getY(); + headY = Math.toDegrees(headY); + headY = Math.rint(headY); + + double headZ = as.getHeadPose().getZ(); + headZ = Math.toDegrees(headZ); + headZ = Math.rint(headZ); + + //Body + double bodyX = as.getBodyPose().getX(); + bodyX = Math.toDegrees(bodyX); + bodyX = Math.rint(bodyX); + + double bodyY = as.getBodyPose().getY(); + bodyY = Math.toDegrees(bodyY); + bodyY = Math.rint(bodyY); + + double bodyZ = as.getBodyPose().getZ(); + bodyZ = Math.toDegrees(bodyZ); + bodyZ = Math.rint(bodyZ); + + + //Arms + double rightArmX = as.getRightArmPose().getX(); + rightArmX = Math.toDegrees(rightArmX); + rightArmX = Math.rint(rightArmX); + + double rightArmY = as.getRightArmPose().getY(); + rightArmY = Math.toDegrees(rightArmY); + rightArmY = Math.rint(rightArmY); + + double rightArmZ = as.getRightArmPose().getZ(); + rightArmZ = Math.toDegrees(rightArmZ); + rightArmZ = Math.rint(rightArmZ); + + + double leftArmX = as.getLeftArmPose().getX(); + leftArmX = Math.toDegrees(leftArmX); + leftArmX = Math.rint(leftArmX); + + double leftArmY = as.getLeftArmPose().getY(); + leftArmY = Math.toDegrees(leftArmY); + leftArmY = Math.rint(leftArmY); + + double leftArmZ = as.getLeftArmPose().getZ(); + leftArmZ = Math.toDegrees(leftArmZ); + leftArmZ = Math.rint(leftArmZ); + + //Legs + double rightLegX = as.getRightLegPose().getX(); + rightLegX = Math.toDegrees(rightLegX); + rightLegX = Math.rint(rightLegX); + + double rightLegY = as.getRightLegPose().getY(); + rightLegY = Math.toDegrees(rightLegY); + rightLegY = Math.rint(rightLegY); + + double rightLegZ = as.getRightLegPose().getZ(); + rightLegZ = Math.toDegrees(rightLegZ); + rightArmX = Math.rint(rightLegZ); + + double leftLegX = as.getLeftLegPose().getX(); + leftLegX = Math.toDegrees(leftLegX); + leftLegX = Math.rint(leftLegX); + + double leftLegY = as.getLeftLegPose().getY(); + leftLegY = Math.toDegrees(leftLegY); + leftLegY = Math.rint(leftLegY); + + double leftLegZ = as.getLeftLegPose().getZ(); + leftLegZ = Math.toDegrees(leftLegZ); + leftLegZ = Math.rint(leftLegZ); + + //Coordinates + float locationX = (float) as.getLocation().getX(); + float locationY = (float) as.getLocation().getY(); + float locationZ = (float) as.getLocation().getZ(); + + //Toggles + boolean isVisible = as.isVisible(); + boolean armsVisible = as.hasArms(); + boolean basePlateVisible = as.hasBasePlate(); + boolean isVulnerable = as.isInvulnerable(); + boolean hasGravity = as.hasGravity(); + boolean isSmall = as.isSmall(); + boolean isGlowing = as.isGlowing(); + boolean isLocked = plugin.scoreboard.getTeam(plugin.lockedTeam).hasEntry(as.getUniqueId().toString()); + + player.sendMessage(ChatColor.YELLOW + "----------- Armor Stand Statistics -----------"); + player.sendMessage(ChatColor.YELLOW + plugin.getLang().getMessage("stats")); + player.sendMessage(ChatColor.YELLOW + "Head: " + ChatColor.AQUA + headX + " / " + headY + " / " + headZ); + player.sendMessage(ChatColor.YELLOW + "Body: " + ChatColor.AQUA + bodyX + " / " + bodyY + " / " + bodyZ); + player.sendMessage(ChatColor.YELLOW + "Right Arm: " + ChatColor.AQUA + rightArmX + " / " + rightArmY + " / " + rightArmZ); + player.sendMessage(ChatColor.YELLOW + "Left Arm: " + ChatColor.AQUA + leftArmX + " / " + leftArmY + " / " + leftArmZ); + player.sendMessage(ChatColor.YELLOW + "Right Leg: " + ChatColor.AQUA + rightLegX + " / " + rightLegY + " / " + rightLegZ); + player.sendMessage(ChatColor.YELLOW + "Left Leg: " + ChatColor.AQUA + leftLegX + " / " + leftLegY + " / " + leftLegZ); + player.sendMessage(ChatColor.YELLOW + "Coordinates: " + ChatColor.AQUA + " X: " + locationX + " / Y: " + locationY + " / Z: " + locationZ); + player.sendMessage(ChatColor.YELLOW + "Is Visible: " + ChatColor.AQUA + isVisible + ". " + ChatColor.YELLOW + "Arms Visible: " + ChatColor.AQUA + armsVisible + ". " + ChatColor.YELLOW + "Base Plate Visible: " + ChatColor.AQUA + basePlateVisible); + player.sendMessage(ChatColor.YELLOW + "Is Vulnerable: " + ChatColor.AQUA + isVulnerable + ". " + ChatColor.YELLOW + "Affected by Gravity: " + ChatColor.AQUA + hasGravity); + player.sendMessage(ChatColor.YELLOW + "Is Small: " + ChatColor.AQUA + isSmall + ". " + ChatColor.YELLOW + "Is Glowing: " + ChatColor.AQUA + isGlowing + ". " + ChatColor.YELLOW + "Is Locked: " + ChatColor.AQUA + isLocked); + player.sendMessage(ChatColor.YELLOW + "----------------------------------------------"); + } } + }else{ + player.sendMessage(plugin.getLang().getMessage("norangeforstats", "warn")); } } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java index 2ae09182..9dfb5c14 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java @@ -361,20 +361,19 @@ void applyRightTool(Player player, ArmorStand as) { @EventHandler(priority = EventPriority.LOWEST) void onRightClickTool(PlayerInteractEvent e) { if (!(e.getAction() == Action.LEFT_CLICK_AIR - || e.getAction() == Action.RIGHT_CLICK_AIR - || e.getAction() == Action.LEFT_CLICK_BLOCK - || e.getAction() == Action.RIGHT_CLICK_BLOCK)) return; + || e.getAction() == Action.RIGHT_CLICK_AIR + || e.getAction() == Action.LEFT_CLICK_BLOCK + || e.getAction() == Action.RIGHT_CLICK_BLOCK)) return; Player player = e.getPlayer(); if (!plugin.isEditTool(player.getInventory().getItemInMainHand())) return; if (plugin.requireSneaking && !player.isSneaking()) return; if (!player.hasPermission("asedit.basic")) return; - - if (!plugin.allowedWorldList.contains(player.getWorld().getName())) { //Implementation for Per World ASE - getPlayerEditor(player.getUniqueId()).sendMessage("notincorrectworld", "warn"); - e.setCancelled(true); - return; + if (plugin.enablePerWorld && (!plugin.allowedWorldList.contains(player.getWorld().getName()))) { + //Implementation for Per World ASE + getPlayerEditor(player.getUniqueId()).sendMessage("notincorrectworld", "warn"); + e.setCancelled(true); + return; } - e.setCancelled(true); getPlayerEditor(player.getUniqueId()).openMenu(); } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/Scheduler.java b/src/main/java/io/github/rypofalem/armorstandeditor/Scheduler.java index 1dad84d8..b2014351 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/Scheduler.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/Scheduler.java @@ -56,8 +56,13 @@ private static boolean methodExist(Class clazz, String methodName, Class.. } public static Boolean isFolia() { - if (IS_FOLIA == null) IS_FOLIA = methodExist(Bukkit.class, "getGlobalRegionScheduler"); - return IS_FOLIA; + try { + Class.forName("io.papermc.paper.threadedregions.ThreadedRegionizer"); + } + catch (Exception e) { + return false; + } + return true; } public static Object getGlobalRegionScheduler() { @@ -97,7 +102,7 @@ public static void runTaskLater(Plugin plugin, Runnable runnable, long delayedTi } public static void teleport(Entity entity, Location location) { - if (IS_FOLIA) callMethod(Entity.class, entity, "teleportAsync", new Class[]{Location.class}, location); + if (isFolia()) callMethod(Entity.class, entity, "teleportAsync", new Class[]{Location.class}, location); else entity.teleport(location); } } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java b/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java index 38e2e4c1..5db9d701 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java @@ -239,10 +239,10 @@ private void fillInventory() { ItemStack[] items = { blankSlot, blankSlot, blankSlot, xAxis, yAxis, zAxis, blankSlot, blankSlot, help, - copy, paste, blankSlot, playerHead, headPos, reset, blankSlot, itemFrameVisible, blankSlot, + copy, paste, blankSlot, playerHead, headPos, reset, blankSlot, itemFrameVisible, glowing, slot1, slot2, blankSlot, rightArmPos, bodyPos, leftArmPos, blankSlot, rotate, place, slot3, slot4, blankSlot, rightLegPos, equipment, leftLegPos, blankSlot, coarseAdj, fineAdj, - blankSlot, glowing, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, + blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, blankSlot, showArms, visibility, size, gravity, plate, toggleVulnerabilty, disableSlots, blankSlot }; diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java index b1f78436..780c56cf 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/PlotSquaredProtection.java @@ -49,15 +49,14 @@ public boolean checkPermission(Block block, Player player) { if (player.hasPermission("asedit.ignoreProtection.plotSquared")) return true; if (plotAPI == null) plotAPI = new PlotAPI(); - //Get the Location of the Plot - Location plotLocation = Location.at(player.getWorld().getName(), BlockVector3.at(block.getX(), block.getY(), block.getZ())); + //Get the Location of the Plot + Location plotLocation = Location.at(block.getWorld().getName(), BlockVector3.at(block.getX(), block.getY(), block.getZ())); //Get the Area of the PLot PlotArea area = plotLocation.getPlotArea(); //If the Area is not a Plot, then we assume its a road, we return if a player can build on roads or not - if(area == null) - return player.hasPermission("plots.admin.build.road"); + if(area == null) return true; //Get the Plot Plot plot = area.getPlot(plotLocation); diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 601c6f23..7fffef6e 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -3,7 +3,7 @@ #-----------------------------# #DO NOT CHANGE THIS - CHANGES AUTOMATICALLY PER UPDATE -version: "1.20.2-44" +version: "1.20.2-44.1" #----------- LANGUAGE #Name of the language file you wish to use @@ -23,12 +23,15 @@ check-interval: 24 opUpdateNotification: false #----------- WORLD SETTINGS +# Enable Per World Support for ArmorStandEditor - Not Enabling this +# means it will work for all worlds by default +enablePerWorldSupport: false + # Add in a list of Worlds where ArmorStandEditing is allowed to happen # Please add your own worlds to this list. All Default Worlds are supported. +# To allow ALL Worlds by default - Make sure that your first listed world is "*" allowed-worlds: - - world - - world_nether - - world_the_end + - "*" #----------- TOOL SETTINGS @@ -97,3 +100,7 @@ allowedToRetrievePlayerHead: false #Each time the command is used, the admins will be notified that this has been ran but only #if this setting is made true adminOnlyNotifications: false + +#Debug Mode - For Development and Support Purposes ONLY! +# Do Not Enable. Will Generate ALOT OF NOISE in your Log Files +debugFlag: false diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index b8f90924..0fade9b5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,6 +1,6 @@ name: ArmorStandEditor main: io.github.rypofalem.armorstandeditor.ArmorStandEditorPlugin -version: 1.20.2-44 +version: 1.20.2-44.1 api-version: "1.17" folia-supported: true website: https://www.spigotmc.org/resources/94503/ @@ -159,6 +159,7 @@ permissions: asedit.copy: true asedit.paste: true asedit.reset: true + asedit.stats: true asedit.toggleInvulnerability: true asedit.togglebaseplate: true asedit.togglearms: true