From 17453743d67ad4206b552a09d1afea310f1c70e7 Mon Sep 17 00:00:00 2001 From: "Larry (Wolfieheart)" Date: Tue, 11 Oct 2022 10:07:02 +0200 Subject: [PATCH] [CORE] ArmorStandEditor 1.19.2-38 * [CORE] Fix BStats Language and Add TODOs Fix TODOs * [CORE] ArmorStandEditor 1.19.2-38: Prerequisits (#105) * [CORE] Bump to 1.xx.x-37 (1.xx as I dont know when we will have to update again) Signed-off-by: Wolfieheart * [CI] Bump PlotSquared-Core to v6.9.4 (#112) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CI] Bump PlotSquared-Bukkit to v6.9.4 (#111) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CI] Bump SuperiorSkyblockAPI to v1.11.1 (#109) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CI] Bump towny to v0.98.3.4 (#108) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CORE] Bump Towny to 0.98.3.8 (#115) * [CORE] Add Lands protection (#116) * Add Lands protection and clean up protection system a bit * Didn't mean to add that * Add Lands to softdepend * Bump version * Bump version * Add comment * Add author * Add another comment * Add override permission check and add comment Co-Authored with: PlanetTeamSpeakk * [CORE] Add Lands Protection Bypass to permpack Add in Lands Protection Byspass to the relevant Permpacks - Extension done at the end of #106 * Update dependency com.palmergames.bukkit.towny:towny to v0.98.3.8 Co-authored-by: PlanetTeamSpeak Co-authored-by: Larry (Wolfieheart) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CORE] Remove Discord Closing of the community Discord for the time being. * [CORE] Bump LandsAPI to v6.14.4 (#117) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Larry (Wolfieheart) * [CORE] Hotfix - Protections not detecting Plugins Enabled Correctly. Closes #120 Signed-off-by: Wolfieheart * [CORE] Bump to 1.19.2-37.2 Signed-off-by: Wolfieheart * [CORE] Add in Functionality for Custom Names * [CORE] Bump to 1.19.2-37.3 * [CORE] Bump to 1.19.2-37.3 * [CORE] Bump PlotSquared to 6.9.4 * [CORE] Optimize Imports * [CORE] Fix Bugs in Implementation Part 1 - Objests.RequireNonNull * [CORE] Fix Bug in Checking String Comparison * [CORE] Fix Build Compliation due to incorrect variable Signed-off-by: Wolfieheart Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: PlanetTeamSpeak * [CORE] Bump Version to 1.19.2-38 (something forgotten) * [CORE] Build Compilation Fix. * [CORE] Fix as this is DEV not for Production Use * [CORE] Bump SuperiorSkyblockAPI to v1.11.1 (#126) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CORE] Clean Up TODOs and add message regarding development builds Signed-off-by: Wolfieheart * [CORE] Fix the idiotic bug of ListSTring Indexes Signed-off-by: Wolfieheart * Update dependency org.apache.maven.plugins:maven-shade-plugin to v3.4.0 (#128) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency com.bgsoftware:SuperiorSkyblockAPI to v2022 (#129) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: Larry (Wolfieheart) * Update dependency com.palmergames.bukkit.towny:towny to v0.98.3.10 (#131) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency com.plotsquared:PlotSquared-Bukkit to v6.10.1 (#132) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * Update dependency com.plotsquared:PlotSquared-Core to v6.10.1 (#133) Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> * [CORE] Define that that Warning is NAB and shouldnt be reported! * [CORE] CR Remarks Signed-off-by: Wolfieheart Signed-off-by: Wolfieheart Signed-off-by: Wolfieheart Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com> Co-authored-by: PlanetTeamSpeak --- pom.xml | 12 +- .../ArmorStandEditorPlugin.java | 106 +++++++++--------- 2 files changed, 60 insertions(+), 58 deletions(-) diff --git a/pom.xml b/pom.xml index f8fbe29d..ba7e63c8 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.rypofalem.armorstandeditor armorstandeditor jar - 1.19.2-37.3 + 1.19.2-38 armorstandeditor http://maven.apache.org @@ -90,14 +90,14 @@ com.plotsquared PlotSquared-Core - 6.9.4 + 6.10.1 provided com.plotsquared PlotSquared-Bukkit - 6.9.4 + 6.10.1 provided @@ -117,7 +117,7 @@ com.palmergames.bukkit.towny towny - 0.98.3.8 + 0.98.3.10 provided @@ -131,7 +131,7 @@ com.bgsoftware SuperiorSkyblockAPI - 1.11.0 + 2022.8.1 provided @@ -190,7 +190,7 @@ org.apache.maven.plugins maven-shade-plugin - 3.3.0 + 3.4.0 package diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java index 65dd151d..1aeec1fd 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java @@ -37,21 +37,19 @@ import java.io.File; import java.util.HashMap; -import java.util.List; import java.util.Map; import java.util.Objects; public class ArmorStandEditorPlugin extends JavaPlugin{ - public static final int SPIGOT_RESOURCE_ID = 94503; //Used for Update Checker + //!!! DO NOT REMOVE THESE UNDER ANY CIRCUMSTANCES !!! + public static final int SPIGOT_RESOURCE_ID = 94503; //Used for Update Checker private static final int PLUGIN_ID = 12668; //Used for BStats Metrics private NamespacedKey iconKey; private static ArmorStandEditorPlugin instance; private Language lang; - - - boolean opUpdateNotification = false; + //Server Version Detection: Paper or Spigot and Invalid NMS Version String nmsVersion; public boolean hasSpigot = false; @@ -61,23 +59,27 @@ public class ArmorStandEditorPlugin extends JavaPlugin{ static final String SEPARATOR_FIELD = "================================"; public PlayerEditorManager editorManager; - + + //Output for Updates + boolean opUpdateNotification = false; + + //Edit Tool Information Material editTool; String toolType; - boolean requireToolData = false; - boolean sendToActionBar = true; - int editToolData = Integer.MIN_VALUE; - boolean requireSneaking = false; + boolean requireToolData = false; boolean requireToolName = false; String editToolName = null; boolean requireToolLore = false; String editToolLore = null; boolean allowCustomModelData = false; Integer customModelDataInt = Integer.MIN_VALUE; - - - boolean debug = false; //weather or not to broadcast messages via print(String message) + + //GUI Settings + boolean requireSneaking = false; + boolean sendToActionBar = true; + + //Armor Stand Specific Settings double coarseRot; double fineRot; boolean glowItemFrames = false; @@ -89,7 +91,6 @@ public class ArmorStandEditorPlugin extends JavaPlugin{ public Team team; String lockedTeam = "ASLocked"; - //Better Debug Output private static ArmorStandEditorPlugin plugin; public ArmorStandEditorPlugin(){ @@ -97,7 +98,7 @@ public ArmorStandEditorPlugin(){ } @Override - public void onEnable(){ + public void onEnable() { scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); @@ -108,21 +109,6 @@ public void onEnable(){ getLogger().info("======= ArmorStandEditor ======="); getLogger().info("Plugin Version: " + pdfFile.getVersion()); - //Spigot Check - hasSpigot = getHasSpigot(); - getLogger().info("SpigotMC: " + hasSpigot); - - //Paper Check - hasPaper = getHasPaper(); - getLogger().info("PaperMC: " + hasPaper); - - //If Paper and Spigot are both FALSE - Disable the plugin - if (!hasPaper && !hasSpigot){ - getLogger().severe("This plugin requires either Paper, Spigot or one of its forks to run"); - getServer().getPluginManager().disablePlugin(this); - return; - } - //Minimum Version Check - No Lower than 1.13-API. Will be tuned out in the future if ( nmsVersion.startsWith("v1_8") || nmsVersion.startsWith("v1_9") || @@ -147,6 +133,23 @@ public void onEnable(){ } else { getLogger().info("Minecraft Version: " + nmsVersion + " is supported. Loading continuing."); } + //Spigot Check + hasSpigot = getHasSpigot(); + hasPaper = getHasPaper(); + + //If Paper and Spigot are both FALSE - Disable the plugin + if (!hasPaper && !hasSpigot){ + getLogger().severe("This plugin requires either Paper, Spigot or one of its forks to run"); + getServer().getPluginManager().disablePlugin(this); + getLogger().info(SEPARATOR_FIELD); + return; + } else { + if (hasSpigot) { + getLogger().info("SpigotMC: " + hasSpigot); + } else { + getLogger().info("PaperMC: " + hasPaper); + } + } getServer().getPluginManager().enablePlugin(this); registerScoreboards(scoreboard); @@ -164,6 +167,7 @@ public void onEnable(){ updateConfig("lang/", "de_DE.yml"); updateConfig("lang/", "es_ES.yml"); updateConfig("lang/", "pt_BR.yml"); + //English is the default language and needs to be unaltered to so that there is always a backup message string saveResource("lang/en_US.yml", true); lang = new Language(getConfig().getString("lang"), this); @@ -182,6 +186,13 @@ public void onEnable(){ getServer().getPluginManager().disablePlugin(this); return; } + + //Do we require a custom tool name? + requireToolName = getConfig().getBoolean("requireToolName", false); + if(requireToolName){ + editToolName = getConfig().getString("toolName", null); + if(editToolName != null) editToolName = ChatColor.translateAlternateColorCodes('&', editToolName); + } //Custom Model Data allowCustomModelData = getConfig().getBoolean("allowCustomModelData", false); @@ -193,13 +204,6 @@ public void onEnable(){ //ArmorStandVisibility Node armorStandVisibility = getConfig().getBoolean("armorStandVisibility", true); - //Do we require a custom tool name? - requireToolName = getConfig().getBoolean("requireToolName", false); - if(requireToolName){ - editToolName = getConfig().getString("toolName", null); - if(editToolName != null) editToolName = ChatColor.translateAlternateColorCodes('&', editToolName); - } - //Is there NBT Required for the tool requireToolData = getConfig().getBoolean("requireToolData", false); @@ -222,7 +226,6 @@ public void onEnable(){ //All ItemFrame Stuff glowItemFrames = getConfig().getBoolean("glowingItemFrame", true); - invisibleItemFrames = getConfig().getBoolean("invisibleItemFrames", true); //Add Ability to check for UpdatePerms that Notify Ops - https://github.com/Wolfieheart/ArmorStandEditor/issues/86 @@ -248,8 +251,10 @@ public void onEnable(){ private void runUpdateCheckerConsoleUpdateCheck() { if (Objects.requireNonNull(getConfig().getString("version")).contains(".x")) { - //noinspection UnnecessaryReturnStatement - return; + getLogger().warning("It appears that you are using the development version of ArmorStandEditor"); + getLogger().warning("This version can be unstable and is not recommended for Production Environments."); + getLogger().warning("Please, report bugs to: https://github.com/Wolfieheart/ArmorStandEditor . This warning"); + getLogger().warning("is intended to be displayed when using a Dev build and is NOT A BUG!"); } else { new UpdateChecker(this, UpdateCheckSource.SPIGET, "" + SPIGOT_RESOURCE_ID + "") .setDownloadLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/") @@ -261,10 +266,12 @@ private void runUpdateCheckerConsoleUpdateCheck() { } } - private void runUpdateCheckerWithOPNotifyOnJoinEnabled() { //We Can Not Dynamically change the setting for NotifyOpsOnJoin :( + private void runUpdateCheckerWithOPNotifyOnJoinEnabled() { if (Objects.requireNonNull(getConfig().getString("version")).contains(".x")) { - //noinspection UnnecessaryReturnStatement - return; + getLogger().warning("It appears that you are using the development version of ArmorStandEditor"); + getLogger().warning("This version can be unstable and is not recommended for Production Environments."); + getLogger().warning("Please, report bugs to: https://github.com/Wolfieheart/ArmorStandEditor . This warning"); + getLogger().warning("is intended to be displayed when using a Dev build and is NOT A BUG!"); } else { new UpdateChecker(this, UpdateCheckSource.SPIGET, "" + SPIGOT_RESOURCE_ID + "") .setDownloadLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/") @@ -395,26 +402,23 @@ public boolean isEditTool(ItemStack itemStk){ if(!itemStk.hasItemMeta()) { return false; } //Get the lore of the Item and if it is null - Return False - List itemLore = Objects.requireNonNull(itemStk.getItemMeta()).getLore(); + String itemLore = String.valueOf(Objects.requireNonNull(itemStk.getItemMeta()).getLore()); //If the Item does not have Lore - Return False boolean hasTheItemLore = itemStk.getItemMeta().hasLore(); if (!hasTheItemLore) { return false; } //Item the first thing in the ItemLore List does not Equal the Config Value "editToolLore" - return false - if (!itemLore.get(0).equals(editToolLore)) { return false; } //Does not need simplified - IntelliJ likes to complain here + if (!itemLore.equals(editToolLore)) { return false; } //Does not need simplified - IntelliJ likes to complain here } if (allowCustomModelData && customModelDataInt != null) { //If the ItemStack does not have Metadata then we return false if(!itemStk.hasItemMeta()) { return false; } - Integer itemCustomModel = Objects.requireNonNull(itemStk.getItemMeta()).getCustomModelData(); - return itemCustomModel.equals(customModelDataInt); } - return true; } @@ -445,8 +449,6 @@ private void getMetrics(){ Map entry = new HashMap<>(); String languageUsed = getConfig().getString("lang"); - entry.put(languageUsed, 1); - assert languageUsed != null; if (languageUsed.startsWith("nl")) { @@ -485,8 +487,8 @@ private void getMetrics(){ //ArmorStandInvis Config metrics.addCustomChart(new SimplePie("itemframe_invisibility_used", () -> getConfig().getString("invisibleItemFrames"))); - //TODO: Add tracking to see who is using Custom Naming in BStats - AKA Remove this soon TM - //metrics.addCustomChart(new SimplePie("custom_toolname_enabled", () -> getConfig().getString("requireToolName"))); + //Add tracking to see who is using Custom Naming in BStats + metrics.addCustomChart(new SimplePie("custom_toolname_enabled", () -> getConfig().getString("requireToolName"))); }