diff --git a/pom.xml b/pom.xml index 3d2587c9..a427d317 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ io.github.rypofalem.armorstandeditor armorstandeditor jar - 1.19-35 + 1.19.1-36 armorstandeditor http://maven.apache.org @@ -52,7 +52,7 @@ glaremasters - https://repo.glaremasters.me/repository/bloodshot + https://repo.glaremasters.me/repository/bloodshot/ @@ -76,7 +76,7 @@ org.spigotmc spigot-api - 1.19-R0.1-SNAPSHOT + 1.19.1-R0.1-SNAPSHOT provided @@ -90,14 +90,14 @@ com.plotsquared PlotSquared-Core - 6.9.0 + 6.9.3 provided com.plotsquared PlotSquared-Bukkit - 6.9.0 + 6.9.3 provided @@ -117,7 +117,7 @@ com.palmergames.bukkit.towny towny - 0.98.2.6 + 0.98.3.2 provided @@ -131,14 +131,14 @@ com.bgsoftware SuperiorSkyblockAPI - 1.10.0 + 1.11.0 provided com.griefdefender api - 2.1.0-20220608.043832-6 + 2.1.0-SNAPSHOT provided diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java index a81bd2a0..4b648d07 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java @@ -37,25 +37,23 @@ import org.bukkit.scoreboard.Scoreboard; import org.bukkit.scoreboard.Team; -import java.io.*; -import java.time.*; -import java.nio.file.Files; -import java.text.SimpleDateFormat; -import java.time.format.DateTimeFormatter; -import java.time.format.FormatStyle; -import java.util.*; 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{ - private static final int SPIGOT_RESOURCE_ID = 94503; //Used for Update Checker + 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 CommandEx execute; private Language lang; + + boolean opUpdateNotification = false; //Server Version Detection: Paper or Spigot and Invalid NMS Version String nmsVersion; public boolean hasSpigot = false; @@ -91,19 +89,7 @@ public class ArmorStandEditorPlugin extends JavaPlugin{ String lockedTeam = "ASLocked"; //Better Debug Output - SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd"); - Date date = Calendar.getInstance().getTime(); - Instant instant = Instant.now(); - DateTimeFormatter formatter = DateTimeFormatter.ofLocalizedDateTime( FormatStyle.SHORT ).withLocale( Locale.UK ).withZone( ZoneId.systemDefault() ); - String dateAsString = dateFormat.format(date); - String timeAsString = formatter.format(instant); - final String debugOutputFileName = getDataFolder() + File.separator + "DEBUG-" + dateAsString + ".log"; - FileOutputStream fos = null; - File f = new File(debugOutputFileName); - - private static ArmorStandEditorPlugin plugin; - - //1.19?: Add in Custom WG Flag? To be seen if needed if WG Protection is enough! + private static ArmorStandEditorPlugin plugin; public ArmorStandEditorPlugin(){ instance = this; @@ -112,14 +98,10 @@ public ArmorStandEditorPlugin(){ @Override public void onEnable(){ - //Run UpdateChecker - runUpdateChecker(); - - scoreboard = this.getServer().getScoreboardManager().getMainScoreboard(); + scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); //Get NMS Version nmsVersion = getNmsVersion(); - print("Net.Minecraft.Server version is: " + nmsVersion); //Load Messages in Console getLogger().info("======= ArmorStandEditor ======="); @@ -146,8 +128,7 @@ public void onEnable(){ nmsVersion.startsWith("v1_10") || nmsVersion.startsWith("v1_11") || nmsVersion.startsWith("v1_12") || - nmsVersion.startsWith("v1_13") - ){ + nmsVersion.startsWith("v1_13")){ getLogger().warning("Minecraft Version: " + nmsVersion + " is not supported. Loading Plugin Failed."); getLogger().info(SEPARATOR_FIELD); getServer().getPluginManager().disablePlugin(this); @@ -165,17 +146,11 @@ public void onEnable(){ } else { getLogger().info("Minecraft Version: " + nmsVersion + " is supported. Loading continuing."); } + getServer().getPluginManager().enablePlugin(this); registerScoreboards(scoreboard); getLogger().info(SEPARATOR_FIELD); - //Is Debug Enabled - debug = getConfig().getBoolean("debug", false); - print("Debug Mode Enabled? Well if you can read this its true"); - if(debug){ - createDebugFile(); - } - //saveResource doesn't accept File.separator on Windows, need to hardcode unix separator "/" instead updateConfig("", "config.yml"); updateConfig("lang/", "test_NA.yml"); @@ -187,10 +162,10 @@ public void onEnable(){ updateConfig("lang/", "ja_JP.yml"); 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); - print("Language in use: " + getConfig().getString("lang")); //Rotation coarseRot = getConfig().getDouble("coarse"); @@ -199,7 +174,6 @@ public void onEnable(){ //Set Tool to be used in game toolType = getConfig().getString("tool"); if (toolType != null) { - print("Edit Tool used to interact with Plugin is: " + toolType); editTool = Material.getMaterial(toolType); //Ignore Warning } else { getLogger().severe("Unable to get Tool for Use with Plugin. Unable to continue!"); @@ -210,71 +184,89 @@ public void onEnable(){ //Custom Model Data allowCustomModelData = getConfig().getBoolean("allowCustomModelData", false); - print("Do we allow CustomModelData?: " + allowCustomModelData); if(allowCustomModelData){ customModelDataInt = getConfig().getInt("customModelDataInt", Integer.MIN_VALUE); - print("CustomModelData Integer is: " + customModelDataInt); } //ArmorStandVisibility Node armorStandVisibility = getConfig().getBoolean("armorStandVisibility", true); - print("ArmorStands allowed to be made visible/invisible?: " + armorStandVisibility); //Is there NBT Required for the tool requireToolData = getConfig().getBoolean("requireToolData", false); - print("NBT Data Required: " + requireToolData); if(requireToolData) { editToolData = getConfig().getInt("toolData", Integer.MIN_VALUE); - print("Tool Data is: " + editToolData); } requireToolLore = getConfig().getBoolean("requireToolLore", false); - print("Lore Required?: " + requireToolLore); if(requireToolLore) { editToolLore = getConfig().getString("toolLore", null); if(editToolLore != null) editToolLore = ChatColor.translateAlternateColorCodes('&', editToolLore); - print("Lore needs to be: " + editToolLore); } //Require Sneaking - Wolfst0rm/ArmorStandEditor#17 requireSneaking = getConfig().getBoolean("requireSneaking", false); - print("Sneaking required to activate the UI: " + requireSneaking); //Send Messages to Action Bar sendToActionBar = getConfig().getBoolean("sendMessagesToActionBar", true); - print("Messages being sent to action bar?: " + sendToActionBar); //All ItemFrame Stuff glowItemFrames = getConfig().getBoolean("glowingItemFrame", true); - print("Are glowing Item Frames enabled for 1.17 Users?: " + glowItemFrames); invisibleItemFrames = getConfig().getBoolean("invisibleItemFrames", true); - print("Can users turn ItemFrames invisible?: " + invisibleItemFrames); + + //Add Ability to check for UpdatePerms that Notify Ops - https://github.com/Wolfieheart/ArmorStandEditor/issues/86 + opUpdateNotification = getConfig().getBoolean("opUpdateNotification", true); + + //Run UpdateChecker - Reports out to Console on Startup ONLY! + if(opUpdateNotification){ + runUpdateCheckerWithOPNotifyOnJoinEnabled(); + } else { + runUpdateCheckerConsoleUpdateCheck(); + } //Get Metrics from bStats getMetrics(); editorManager = new PlayerEditorManager(this); - execute = new CommandEx(this); - getCommand("ase").setExecutor(execute); //Ignore the warning with this. GetCommand is Nullable. Will be fixed in the future + CommandEx execute = new CommandEx(this); + Objects.requireNonNull(getCommand("ase")).setExecutor(execute); //Ignore the warning with this. GetCommand is Nullable. Will be fixed in the future getServer().getPluginManager().registerEvents(editorManager, this); } - private void runUpdateChecker() { - UpdateChecker.init(this, SPIGOT_RESOURCE_ID) - .setDownloadLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/") - .setChangelogLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/history") - .setNotifyOpsOnJoin(true) - .setNotifyByPermissionOnJoin("asedit.update") - .setColoredConsoleOutput(true) - .setUserAgent(new UserAgentBuilder().addPluginNameAndVersion().addServerVersion()) - .checkEveryXHours(72) //Warn people every 72 hours - .checkNow(); + private void runUpdateCheckerConsoleUpdateCheck() { + if (Objects.requireNonNull(getConfig().getString("version")).contains(".x")) { + //noinspection UnnecessaryReturnStatement + return; + } else { + new UpdateChecker(this, UpdateCheckSource.SPIGET, "" + SPIGOT_RESOURCE_ID + "") + .setDownloadLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/") + .setChangelogLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/history") + .setColoredConsoleOutput(true) + .setUserAgent(new UserAgentBuilder().addPluginNameAndVersion().addServerVersion()) + .checkEveryXHours(72) //Warn people every 72 hours + .checkNow(); + } + } + + private void runUpdateCheckerWithOPNotifyOnJoinEnabled() { //We Can Not Dynamically change the setting for NotifyOpsOnJoin :( + if (Objects.requireNonNull(getConfig().getString("version")).contains(".x")) { + //noinspection UnnecessaryReturnStatement + return; + } else { + new UpdateChecker(this, UpdateCheckSource.SPIGET, "" + SPIGOT_RESOURCE_ID + "") + .setDownloadLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/") + .setChangelogLink("https://www.spigotmc.org/resources/armorstandeditor-reborn.94503/history") + .setColoredConsoleOutput(true) + .setNotifyOpsOnJoin(true) + .setUserAgent(new UserAgentBuilder().addPluginNameAndVersion().addServerVersion()) + .checkEveryXHours(72) //Warn people every 72 hours + .checkNow(); + } } //Implement Glow Effects for Wolfstorm/ArmorStandEditor-Issues#5 - Add Disable Slots with Different Glow than Default @@ -283,11 +275,8 @@ private void registerScoreboards(Scoreboard scoreboard) { //Fix for Scoreboard Issue reported by Starnos - Wolfst0rm/ArmorStandEditor-Issues/issues/18 if (scoreboard.getTeam(lockedTeam) == null) { - print("Team '" + lockedTeam + "' does not exist, proceeding to create new team"); scoreboard.registerNewTeam(lockedTeam); - - print("Setting Team '" + lockedTeam + "' color to RED"); - scoreboard.getTeam(lockedTeam).setColor(ChatColor.RED); + Objects.requireNonNull(scoreboard.getTeam(lockedTeam)).setColor(ChatColor.RED); } else { getLogger().info("Scoreboard for ASLocked Already exists. Continuing to load"); } @@ -299,7 +288,6 @@ private void unregisterScoreboards(Scoreboard scoreboard) { team = scoreboard.getTeam(lockedTeam); if(team != null) { //Basic Sanity Check to ensure that the team is there team.unregister(); - print("Team '" + lockedTeam + "' successfully removed."); } else{ getLogger().severe("Team Already Appears to be removed. Please do not do this manually!"); } @@ -317,21 +305,10 @@ public void onDisable(){ if(player.getOpenInventory().getTopInventory().getHolder() == editorManager.getMenuHolder()) player.closeInventory(); } - scoreboard = this.getServer().getScoreboardManager().getMainScoreboard(); + scoreboard = Objects.requireNonNull(this.getServer().getScoreboardManager()).getMainScoreboard(); unregisterScoreboards(scoreboard); } - public void createDebugFile(){ - try { - if (!f.exists() && f.createNewFile()) { - Files.setAttribute(f.toPath(), "dos:hidden", true); - } - } catch (IOException e) { - this.getServer().getLogger().warning(e.getMessage()); - } - } - - public String getNmsVersion(){ return this.getServer().getClass().getPackage().getName().replace(".",",").split(",")[3]; } @@ -339,7 +316,6 @@ public String getNmsVersion(){ public boolean getHasSpigot(){ try { Class.forName("org.spigotmc.SpigotConfig"); - print("SpigotMC Detected."); nmsVersionNotLatest = "SpigotMC ASAP."; return true; } catch (ClassNotFoundException e){ @@ -356,10 +332,10 @@ public boolean getItemFrameVisibility(){ return getConfig().getBoolean("invisibleItemFrames"); } + public boolean getHasPaper(){ try { Class.forName("com.destroystokyo.paper.PaperConfig"); - print("PaperMC Detected."); nmsVersionNotLatest = "SpigotMC ASAP."; return true; } catch (ClassNotFoundException e){ @@ -400,7 +376,7 @@ 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 = itemStk.getItemMeta().getLore(); //Ignore warnings this gives. Will be fixed in the future + List itemLore = Objects.requireNonNull(itemStk.getItemMeta()).getLore(); //Ignore warnings this gives. Will be fixed in the future if (itemLore == null){ return false; } //If the Item does not have Lore - Return False @@ -416,56 +392,14 @@ public boolean isEditTool(ItemStack itemStk){ //If the ItemStack does not have Metadata then we return false if(!itemStk.hasItemMeta()) { return false; } - Integer itemCustomModel = itemStk.getItemMeta().getCustomModelData(); - if (itemCustomModel == null) { return false; } + Integer itemCustomModel = Objects.requireNonNull(itemStk.getItemMeta()).getCustomModelData(); - if(!itemCustomModel.equals(customModelDataInt)) { return false; } + return itemCustomModel.equals(customModelDataInt); } return true; } - public void log(String message){ - //Output to Server Console - Safer than doing a Broadcast to everyone on the Server - String timeMsgSep = ": "; - this.getServer().getLogger().info("ArmorStandEditor: " + message); - - try{ - fos = new FileOutputStream(f, true); - - //Write the Content as Bytes - fos.write(timeAsString.getBytes()); - fos.write(timeMsgSep.getBytes()); - fos.write(message.getBytes()); - fos.write(10); - fos.flush(); - }catch(IOException e){ - this.getServer().getLogger().warning(e.getMessage()); - }finally{ - if(fos != null){ - try { - fos.close(); - } catch (IOException e) { - this.getServer().getLogger().warning(e.getMessage()); - } - } - } - } - - /* - * For Internal Debugging - - * - * set debug: true in Config.yml - * NOTE: NOT RECOMMENDED FOR PROD! INTERNAL TESTING ONLY! - * - * To be refactored - Apart Log File. - */ - public void print(String message){ - if(debug){ - log(message); - } - } - public static ArmorStandEditorPlugin instance(){ return instance; } @@ -517,8 +451,10 @@ private void getMetrics(){ map.put("Romanian", entry); } else if(languageUsed.startsWith("uk")){ map.put("Ukrainian", entry); - } else if(languageUsed.startsWith("zh")){ + } else if(languageUsed.startsWith("zh")) { map.put("Chinese", entry); + } else if(languageUsed.startsWith("pt")) { + map.put("Brazilian", entry); } else{ map.put("Other", entry); } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java b/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java index 72efcf4c..7729422a 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/CommandEx.java @@ -19,6 +19,7 @@ package io.github.rypofalem.armorstandeditor; +import com.jeff_media.updatechecker.UpdateCheckSource; import com.jeff_media.updatechecker.UpdateChecker; import io.github.rypofalem.armorstandeditor.modes.AdjustmentMode; import io.github.rypofalem.armorstandeditor.modes.Axis; @@ -54,14 +55,12 @@ public boolean onCommand(CommandSender sender, Command command, String label, St if (!(sender instanceof Player && checkPermission((Player) sender, "basic", true))) { sender.sendMessage(plugin.getLang().getMessage("noperm", "warn")); - plugin.log("CommandSender is not an instance of Player"); return true; } Player player = (Player) sender; debugPlayerDisplayName = player.getDisplayName(); if (args.length == 0) { - plugin.log("Sending List of Commands to: " + debugPlayerDisplayName); player.sendMessage(LISTMODE); player.sendMessage(LISTAXIS); player.sendMessage(LISTSLOT); @@ -91,7 +90,6 @@ && checkPermission((Player) sender, "basic", true))) { case "give": commandGive(player); break; default: - plugin.log("Sending List of Commands to: " + debugPlayerDisplayName); sender.sendMessage(LISTMODE); sender.sendMessage(LISTAXIS); sender.sendMessage(LISTSLOT); @@ -109,8 +107,6 @@ && checkPermission((Player) sender, "basic", true))) { // https://github.com/Wolfieheart/ArmorStandEditor-Issues/issues/30 - See Remarks OTHER private void commandGive(Player player) { if (plugin.getAllowCustomModelData() && checkPermission(player, "give", true)) { - plugin.log("Does Plugin Allow CustomModelData?: " + plugin.getAllowCustomModelData()); - plugin.log("CustomModelData Int is: " + plugin.getCustomModelDataInt()); ItemStack stack = new ItemStack(plugin.getEditTool()); //Only Support EditTool at the MOMENT ItemMeta meta = stack.getItemMeta(); meta.setCustomModelData(plugin.getCustomModelDataInt()); @@ -134,7 +130,6 @@ private void commandSlot(Player player, String[] args) { try { byte slot = (byte) (Byte.parseByte(args[1]) - 0b1); if (slot >= 0 && slot < 9) { - plugin.log("Copying ArmorStand to slot: " + slot); plugin.editorManager.getPlayerEditor(player.getUniqueId()).setCopySlot(slot); } else { player.sendMessage(LISTSLOT); @@ -155,7 +150,6 @@ private void commandAdj(Player player, String[] args) { if (args.length > 1) { for ( AdjustmentMode adj : AdjustmentMode.values()) { if (adj.toString().toLowerCase().contentEquals(args[1].toLowerCase())) { - plugin.log("Adjustment mode set to: " + adj); plugin.editorManager.getPlayerEditor(player.getUniqueId()).setAdjMode(adj); return; } @@ -173,7 +167,6 @@ private void commandAxis( Player player, String[] args) { if (args.length > 1) { for ( Axis axis : Axis.values()) { if (axis.toString().toLowerCase().contentEquals(args[1].toLowerCase())) { - plugin.log("Axis set to: " + axis); plugin.editorManager.getPlayerEditor(player.getUniqueId()).setAxis(axis); return; } @@ -191,11 +184,9 @@ private void commandMode( Player player, String[] args) { if (args.length > 1) { for ( EditMode mode : EditMode.values()) { if (mode.toString().toLowerCase().contentEquals(args[1].toLowerCase())) { - plugin.log("Argument 1 is: " + args[1].toLowerCase()); if (args[1].equals("invisible") && !checkPermission(player, "armorstand.invisible", true)) return; if (args[1].equals("itemframe") && !checkPermission(player, "itemframe.invisible", true)) return; plugin.editorManager.getPlayerEditor(player.getUniqueId()).setMode(mode); - plugin.log("Mode set to '" + mode + "' for player '" + debugPlayerDisplayName + "'"); return; } } @@ -203,7 +194,6 @@ private void commandMode( Player player, String[] args) { } private void commandHelp( Player player) { - plugin.log("Player '" + debugPlayerDisplayName + "' has ran the help command, closing Inventory"); player.closeInventory(); player.playSound(player.getLocation(), Sound.ENTITY_EXPERIENCE_ORB_PICKUP, 1f, 1f); player.sendMessage(plugin.getLang().getMessage("help", "info", plugin.editTool.name())); @@ -214,31 +204,26 @@ private void commandHelp( Player player) { } private void commandUpdate(Player player) { - if(!(checkPermission(player, "update", true))) return; - plugin.log("Running the Built in UpdateChecker - Activated by '" + debugPlayerDisplayName + "'"); - UpdateChecker.getInstance().checkNow(player); + if (!(checkPermission(player, "update", true))) return; + new UpdateChecker(plugin, UpdateCheckSource.SPIGOT, "" + ArmorStandEditorPlugin.SPIGOT_RESOURCE_ID + "").checkNow(player); //Runs Update Check + } private void commandVersion(Player player) { if (!(checkPermission(player, "update", true))) return; String verString = plugin.pdfFile.getVersion(); - plugin.log("Output of VerString: " + verString); player.sendMessage(ChatColor.YELLOW + "[ArmorStandEditor] Version: " + verString); - UpdateChecker.getInstance().checkNow(player); } - private boolean checkPermission( Player player, String permName, boolean sendMessageOnInvalidation) { if (permName.equalsIgnoreCase("paste")) { permName = "copy"; } if (player.hasPermission("asedit." + permName.toLowerCase())) { - plugin.print("Player '"+ player.getDisplayName() +" has Permission: asedit." + permName.toLowerCase()); return true; } else { if (sendMessageOnInvalidation) { - plugin.print("Player '"+ player.getDisplayName() +" does not have Permission: asedit." + permName.toLowerCase()); player.sendMessage(plugin.getLang().getMessage("noperm", "warn")); } return false; diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/Metrics.java b/src/main/java/io/github/rypofalem/armorstandeditor/Metrics.java index 6d7848c6..84cc1d97 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/Metrics.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/Metrics.java @@ -860,4 +860,4 @@ public String toString() { } } } -} \ No newline at end of file +} diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java index dda1e01a..05b198b0 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java @@ -238,6 +238,7 @@ public void reverseEditArmorStand(ArmorStand armorStand) { } private void move(ArmorStand armorStand) { + if(!getPlayer().hasPermission("asedit.placement")) return; Location loc = armorStand.getLocation(); switch (axis) { case X: @@ -254,6 +255,7 @@ private void move(ArmorStand armorStand) { } private void reverseMove(ArmorStand armorStand) { + if(!getPlayer().hasPermission("asedit.placement")) return; Location loc = armorStand.getLocation(); switch (axis) { case X: @@ -364,9 +366,6 @@ void toggleArms(ArmorStand armorStand) { void toggleVisible(ArmorStand armorStand) { if (!getPlayer().hasPermission("asedit.armorstand.invisible") || !plugin.armorStandVisibility) return; //Option to use perms or Config - String asLoc = armorStand.getLocation().toString(); - String result = String.valueOf(!armorStand.isVisible()); - plugin.log("Player (" + getPlayer().getDisplayName() + ") has made the ArmorStand at " + asLoc + " " + result); armorStand.setVisible(!armorStand.isVisible()); } @@ -428,14 +427,11 @@ public void setTarget(ArrayList armorStands) { target = null; targetList = null; sendMessage("notarget", null); - plugin.log("ArmorStand targeted: UNLOCKED"); } else { - if (targetList == null) { targetList = armorStands; targetIndex = 0; sendMessage("target", null); - plugin.log("ArmorStand targeted: UNLOCKED"); } else { boolean same = targetList.size() == armorStands.size(); if (same) for (ArmorStand as : armorStands) { @@ -449,7 +445,6 @@ public void setTarget(ArrayList armorStands) { targetList = armorStands; targetIndex = 0; sendMessage("target", null); - plugin.log("ArmorStand targeted: LOCKED"); } } target = targetList.get(targetIndex); @@ -465,14 +460,12 @@ public void setFrameTarget(ArrayList itemFrames) { frameTarget = null; frameTargetList = null; sendMessage("noframetarget", null); - plugin.log("ItemFrame targeted: UNLOCKED"); } else { if (frameTargetList == null) { frameTargetList = itemFrames; frameTargetIndex = 0; sendMessage("frametarget", null); - plugin.log("ItemFrame targeted: UNLOCKED"); } else { boolean same = frameTargetList.size() == itemFrames.size(); if (same) for (final ItemFrame itemf : itemFrames) { @@ -486,7 +479,6 @@ public void setFrameTarget(ArrayList itemFrames) { frameTargetList = itemFrames; frameTargetIndex = 0; sendMessage("frametarget", null); - plugin.log("ItemFrame targeted: LOCKED"); } frameTarget = frameTargetList.get(frameTargetIndex); } 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 ecaf4061..22bd900b 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/menu/Menu.java @@ -35,11 +35,10 @@ import java.util.ArrayList; public class Menu { - private Inventory menuInv; - private PlayerEditor pe; + private final Inventory menuInv; + private final PlayerEditor pe; private static String name = "Armor Stand Editor Menu"; - public Menu(PlayerEditor pe) { this.pe = pe; name = pe.plugin.getLang().getMessage("mainmenutitle", "menutitle"); @@ -48,38 +47,38 @@ public Menu(PlayerEditor pe) { } private void fillInventory() { + menuInv.clear(); - ItemStack xAxis = null; - ItemStack yAxis = null; - ItemStack zAxis = null; - ItemStack coarseAdj = null; - ItemStack fineAdj = null; - ItemStack rotate = null; + ItemStack xAxis; + ItemStack yAxis; + ItemStack zAxis; + ItemStack coarseAdj; + ItemStack fineAdj; + ItemStack rotate; ItemStack place = null; - ItemStack headPos = null; - ItemStack rightArmPos = null; - ItemStack bodyPos = null; - ItemStack leftArmPos = null; - ItemStack reset = null; - ItemStack showArms = null; - ItemStack visibility = null; - ItemStack size = null; - ItemStack rightLegPos = null; + ItemStack headPos; + ItemStack rightArmPos; + ItemStack bodyPos; + ItemStack leftArmPos; + ItemStack reset; + ItemStack showArms; + ItemStack visibility; + ItemStack size; + ItemStack rightLegPos; ItemStack equipment = null; - ItemStack leftLegPos = null; + ItemStack leftLegPos; ItemStack disableSlots = null; ItemStack gravity = null; - ItemStack plate = null; - ItemStack copy = null; - ItemStack paste = null; - ItemStack slot1 = null; - ItemStack slot2 = null; - ItemStack slot3 = null; - ItemStack slot4 = null; - ItemStack help = null; - ItemStack itemFrameVisible = null; - ItemStack itemFrameGlow = null; //Unused? + ItemStack plate; + ItemStack copy; + ItemStack paste; + ItemStack slot1; + ItemStack slot2; + ItemStack slot3; + ItemStack slot4; + ItemStack help; + ItemStack itemFrameVisible; xAxis = createIcon(new ItemStack(Material.RED_WOOL, 1), "xaxis", "axis x"); @@ -124,21 +123,22 @@ private void fillInventory() { //Praise Start - Sikatsu and cowgod, Nicely spotted this being broken if (pe.getPlayer().hasPermission("asedit.armorstand.invisible") || - pe.plugin.getArmorStandVisibility() ) { + pe.plugin.getArmorStandVisibility()) { visibility = new ItemStack(Material.POTION, 1); PotionMeta potionMeta = (PotionMeta) visibility.getItemMeta(); PotionEffect eff1 = new PotionEffect(PotionEffectType.INVISIBILITY, 1, 0); + assert potionMeta != null; potionMeta.addCustomEffect(eff1, true); visibility.setItemMeta(potionMeta); - visibility = createIcon(visibility, "invisible", "mode invisible"); + createIcon(visibility, "invisible", "mode invisible"); } else { visibility = null; } if (pe.getPlayer().hasPermission("asedit.itemframe.invisible") || - pe.plugin.getItemFrameVisibility() ) { + pe.plugin.getItemFrameVisibility()) { itemFrameVisible = new ItemStack(Material.ITEM_FRAME, 1); - itemFrameVisible = createIcon(itemFrameVisible, "itemframevisible", "mode itemframe"); + createIcon(itemFrameVisible, "itemframevisible", "mode itemframe"); } else { itemFrameVisible = null; } @@ -152,18 +152,22 @@ private void fillInventory() { disableSlots = createIcon(new ItemStack(Material.BARRIER), "disableslots", "mode disableslots"); } - gravity = createIcon(new ItemStack(Material.SAND), "gravity", "mode gravity"); + if (pe.getPlayer().hasPermission("asedit.gravity")) { + gravity = createIcon(new ItemStack(Material.SAND), "gravity", "mode gravity"); + } plate = createIcon(new ItemStack(Material.STONE_SLAB, 1), "baseplate", "mode baseplate"); - place = createIcon(new ItemStack(Material.MINECART, 1), - "placement", "mode placement"); + if (pe.getPlayer().hasPermission("asedit.placement")) { + place = createIcon(new ItemStack(Material.MINECART, 1), + "placement", "mode placement"); + } rotate = createIcon(new ItemStack(Material.COMPASS, 1), "rotate", "mode rotate"); - if(pe.getPlayer().hasPermission("asedit.equipment")) { + if (pe.getPlayer().hasPermission("asedit.equipment")) { equipment = createIcon(new ItemStack(Material.CHEST, 1), "equipment", "mode equipment"); } @@ -200,12 +204,13 @@ private void fillInventory() { menuInv.setContents(items); } - private ItemStack createIcon( ItemStack icon, String path, String command) { + private ItemStack createIcon(ItemStack icon, String path, String command) { return createIcon(icon, path, command, null); } - private ItemStack createIcon( ItemStack icon, String path, String command, String option) { + private ItemStack createIcon(ItemStack icon, String path, String command, String option) { ItemMeta meta = icon.getItemMeta(); + assert meta != null; meta.getPersistentDataContainer().set(ArmorStandEditorPlugin.instance().getIconKey(), PersistentDataType.STRING, "ase " + command); meta.setDisplayName(getIconName(path, option)); ArrayList loreList = new ArrayList<>(); @@ -218,12 +223,12 @@ private ItemStack createIcon( ItemStack icon, String path, String command, St } - private String getIconName( String path, String option) { + private String getIconName(String path, String option) { return pe.plugin.getLang().getMessage(path, "iconname", option); } - private String getIconDescription( String path, String option) { + private String getIconDescription(String path, String option) { return pe.plugin.getLang().getMessage(path + ".description", "icondescription", option); } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java index 9b4509ff..bee0fb38 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java @@ -8,19 +8,16 @@ import org.bukkit.Location; import org.bukkit.block.Block; import org.bukkit.entity.Player; -import org.bukkit.plugin.Plugin; import static com.griefdefender.api.claim.TrustTypes.BUILDER; -import static com.griefdefender.api.claim.TrustTypes.RESIDENT; public class GriefDefenderProtection { - private boolean gdEnabled; + private final boolean gdEnabled; public GriefDefenderProtection() { gdEnabled = Bukkit.getPluginManager().isPluginEnabled("GriefDefender"); - if (!gdEnabled) return; } public boolean checkPermission(Block block, Player player) { @@ -35,16 +32,8 @@ public boolean checkPermission(Block block, Player player) { if (landClaim == null || landClaim.isWilderness() || landClaim.isAdminClaim()) { return true; - } else if (landClaim.isBasicClaim() && - !landClaim.isUserTrusted(player.getUniqueId(), RESIDENT) && - !landClaim.allowEdit(player.getUniqueId()) || - landClaim.isBasicClaim() && - !landClaim.isUserTrusted(player.getUniqueId(), BUILDER) && - !landClaim.allowEdit(player.getUniqueId())) { - return false; - } else { - return true; - } + } else + return (!landClaim.isBasicClaim() || landClaim.isUserTrusted(player.getUniqueId(), BUILDER) || landClaim.allowEdit(player.getUniqueId())); } else { return true; } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java index 96f23354..2b30e655 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/SkyblockProtection.java @@ -14,23 +14,25 @@ public SkyblockProtection(){ //IF YOU WANT YOUR SKYBLOCK ADDED, PLEASE SUBMIT A FEATURE REQUEST! skyblockEnabled = Bukkit.getPluginManager().isPluginEnabled("SuperiorSkyblock2"); - if (!skyblockEnabled) return; } - public boolean checkPermission(Player player){ - if(!skyblockEnabled) return true; - if(player.isOp()) return true; - if(player.hasPermission("asedit.ignoreProtection.skyblock")) return true; //Add Additional Permission + public boolean checkPermission(Player player) { + if (!skyblockEnabled) return true; + if (player.isOp()) return true; + if (player.hasPermission("asedit.ignoreProtection.skyblock")) return true; //Add Additional Permission SuperiorPlayer sp = SuperiorSkyblockAPI.getPlayer(player); //GET ISLAND FOR A GIVEN LOCATION Island island = SuperiorSkyblockAPI.getIslandAt(sp.getLocation()); - - if(!island.isMember(sp) && !island.isCoop(sp) && !sp.hasBypassModeEnabled()){ - return false; - } else { + if (island == null) { return true; + } else { + if (!island.isMember(sp) && !island.isCoop(sp) && !sp.hasBypassModeEnabled()) { + return false; + } else { + return true; + } } } } diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java index 47d779e3..f9b52413 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/TownyProtection.java @@ -16,7 +16,6 @@ public class TownyProtection { public TownyProtection(){ tEnabled = Bukkit.getPluginManager().isPluginEnabled("Towny"); - if (!tEnabled) return; } public boolean checkPermission(Block block, Player player){ diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java index 41d1cc60..0cda9b42 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/WorldGuardProtection.java @@ -34,12 +34,11 @@ public class WorldGuardProtection { private final boolean wgEnabled; - private RegionQuery regionQry = null; + private RegionQuery regionQry; public WorldGuardProtection(){ wgEnabled = Bukkit.getPluginManager().isPluginEnabled("WorldGuard"); - if(!wgEnabled) return; RegionContainer regionContainer = WorldGuard.getInstance().getPlatform().getRegionContainer(); regionQry = regionContainer.createQuery(); } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index dbaa2054..7dbc7c10 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.19-35 +version: "1.19.1-36" #----------- LANGUAGE #Name of the language file you wish to use @@ -12,6 +12,10 @@ version: 1.19-35 #Please read the comments at the top of that file before editing/changing/modifying. lang: en_US.yml +#----------- UPDATE NOTIFICATIONS +#Set this to allow your operators to get messages w.r.t Plugin updates +opUpdateNotification: false + #----------- TOOL SETTINGS #Name of the edit tool's item Material. You can find a full list at https://hub.spigotmc.org/javadocs/bukkit/org/bukkit/Material.html @@ -26,8 +30,9 @@ requireToolLore: false toolLore: Let's get dangerous #(Optional) Allow the use of CustomModelData - NOTE: This looks at the editTool set by Config -#and at the Int set here to know what to set. Also please if you are using this, ensure that -#you also give people the ability asedit.give in order to allow them to change their edit +#and at the Int set here to know what to set. +#Also please if you are using this, ensure that you also give people the ability asedit.give in +#order to allow them to change their edit #tool for the right Custom Model Data allowCustomModelData: false customModelDataInt: 0 @@ -41,8 +46,12 @@ coarse: 12 fine: 120 #Allow the option to toggle invisibility for ItemFrames and ArmorStand -invisibleItemFrames: true +#YOu can either use this or the below permissions to allow visibility changes +#asedit.armorstand.invisible armorStandVisibility: true +#asedit.itemframe.invisible +invisibleItemFrames: true + #------ GUI Options @@ -53,8 +62,4 @@ requireSneaking: false #(Optional) Glowing Item Frames Support for Item Frames in 1.17 - WILL NOT WORK IN 1.16 OR LOWER AND 1.17.1 OR HIGHER #If true, players can make itemFrames glow by right-clicking with a Glow Ink Sac -glowingItemFrame: true - -#DO NOT ENABLE - For Testing Purposes. Can lead to unwanted side effects -#Enable if you are submitting a bug report PLEASE! -debug: false \ No newline at end of file +glowingItemFrame: true \ No newline at end of file diff --git a/src/main/resources/lang/pt_BR.yml b/src/main/resources/lang/pt_BR.yml new file mode 100644 index 00000000..84094412 --- /dev/null +++ b/src/main/resources/lang/pt_BR.yml @@ -0,0 +1,239 @@ +#Traduzido por thiagogebrim + +iconname: e +icondescription: 6 +info: 6 +warn: c +menutitle: 8 + +#info +setmode: + msg: "Modo definido: ." + head: Posição da Cabeça + body: Posição do corpo + leftleg: Posição da perna esquerda + rightleg: Posição da perna direita + leftarm: Posição do braço esquerdo + rightarm: Posição do braço direito + equipment: Equipamento + showarms: Alternar exibição de braços + invisible: Toggle Visibility + size: Alterar tamanho + disableslots: Alternar Desativar Slots + gravity: Toggle Gravity + baseplate: Alternar a placa da base + placement: Placement + rotate: Rotação + copy: Copiar + paste: Colar + reset: Redefinir posição + itemframe: Toggle Itemframe Visibility +setaxis: + msg: Configurando o eixo para . + x: X + y: Y + z: Z +setslot: + msg: Configurando o slot de cópia para . +setadj: + msg: Ajuste definido para . + coarse: Grande + fine: Pequeno +setgravity: + msg: A gravidade virou . + true: sim + false: não +nomode: + msg: Primeiro clique com a ferramenta de edição sem olhar para um suporte de armadura para selecionar um modo de edição! +nomodeif: + msg: Click with the Edit Tool away from the ItemFrame to select a mode first! +copied: + msg: ArmorStand state copied to slot . +pasted: + msg: ArmorStand state pasted from slot . +disabledslots: + msg: Toggled Equipment locks +target: + msg: ArmorStand target locked. +notarget: + msg: ArmorStand target unlocked. +frametarget: + msg: Itemframe target locked +noframetarget: + msg: Itemframe target unlocked. +give: + msg: Player given Item with CustomModelData +doubletarget: + msg: Please look at either an ArmorStand or an ItemFrame, not both! +reloaded: + msg: Configuration File has been reloaded. +help: + msg: "1. Segure a ferramenta de edição em sua mão principal. + + 2. Clique com o botão esquerdo ou direito longe de um suporte de armadura para abrir o menu. + + 3. Selecione as opções no menu. + + 4. Clique com o botão esquerdo no suporte de armadura com a ferramenta de edição na mão para aplicar as opções. + + 5. Clique com o botão direito para editar ao contrário!" +helptips: + msg: "Tips: + + 1. Press the \"Swap Item in Hands\" key (default F) while holding the edit tool to target a specific armor stand, if other armor stands are in the way. + + 2. You can apply NameTags to armor stands. You may use the & symbol to make colored names. + + 3. You can use crouch + scroll wheel while holding the edit tool to change Axis without opening the menu" +helpurl: + msg: "" + +#warn +cantedit: + msg: Sorry, you cannot edit armor stands here! +noperm: + msg: You don't have permission to use this! +noslotnumcom: + msg: You must specify a slot number! +noadjcom: + msg: You must specify Coarse or Fine adjustment! +noaxiscom: + msg: You must specify an Axis! +nomodecom: + msg: You must specify a Mode! +noreloadcom: + msg: You don't have permission to use the reload command! +nogive: + msg: You do not have permission to use the give command. + +#menutitle +mainmenutitle: + msg: Editor do suporte de armaduras +equiptitle: + msg: Suporte de armaduras equipamentos + +#icons +xaxis: + msg: Eixo X + description: + msg: Girar partes do corpo ao longo do eixo X +yaxis: + msg: Eixo Y + description: + msg: Girar partes do corpo ao longo do eixo Y +zaxis: + msg: Eixo Z + description: + msg: Girar partes do corpo ao longo do eixo Z +coarseadj: + msg: Ajuste grande + description: + msg: Faça grandes ajustes +fineadj: + msg: Ajuste pequeno + description: + msg: Faça pequenos ajustes +head: + msg: Posição da cabeça + description: + msg: Rotaciona a cabeça +body: + msg: Posição do corpo + description: + msg: Rotaciona o corpo +leftleg: + msg: Posição da perna esquerda + description: + msg: Rotaciona a perna esquerda +rightleg: + msg: Posição da perna direita + description: + msg: Rotaciona a perna direita +leftarm: + msg: Posição do braço esquerdo + description: + msg: Rotaciona o braço esquerdo +rightarm: + msg: Posição do braço direito + description: + msg: Rotaciona o braço direito +equipment: + msg: Equipamento + description: + msg: Edita o equipamento +showarms: + msg: Exibir braços + description: + msg: Defina braços aparentes ou escondidos +invisible: + msg: Visibility + description: + msg: Make it visibile or invisible +size: + msg: Tamanho + description: + msg: Defina como grande ou pequeno +disableslots: + msg: Desativar slots + description: + msg: Habilitar e desabilitar o bloqueio do equipamento +gravity: + msg: Gravidade + description: + msg: (não funciona) +baseplate: + msg: Placa da base + description: + msg: Ativar ou desativar a placa da base +placement: + msg: Placement + description: + msg: Move the entire armorstand +rotate: + msg: Girar + description: + msg: Gira a entidade do suporte de armaduras +copy: + msg: Copiar + description: + msg: Copie as configurações do suporte de armaduras +paste: + msg: Colar + description: + msg: Cole as configurações do suporte de armaduras +copyslot: + msg: Copiar Slot + description: + msg: Selecionar esse slot para copiar as configurações +reset: + msg: Resetar Posição + description: + msg: Redefinir a posição da parte do corpo para o padrão +helpgui: + msg: Ajuda! + description: + msg: Clique para conseguir ajuda! +itemframevisible: + msg: Itemframe Visibility + description: + msg: Toggles an itemframes visibility + +#icons (equipment menu) +disabled: + msg: Desativado +equipslot: + msg: + description: + msg: Arraste seu para o slot abaixo + helm: Capacete + chest: Peitoral + pants: Calças + boots: Botas + rhand: Item na mão direita + lhand: Item na mão esquerda + helm: Capacete + chest: Peitoral + pants: Calças + boots: Botas + rhand: Mão direita + lhand: Mão esquerda \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 44310662..ea07ff8c 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.19-35 +version: 1.19.1-36 api-version: "1.13" website: https://www.spigotmc.org/resources/94503/ author: Wolfstorm @@ -39,7 +39,13 @@ permissions: asedit.equipment: description: Access armorstand equipment GUI default: true - asedit.disableslots: + asedit.gravity: + description: Changes whether the armor stand has gravity + default: true + asedit.placement: + description: Changes whether the armor stand can be moved using the item for editing + default: true + asedit.disableSlots: description: Allows locking and unlocking the contents of an ArmorStand. When locked, armor and equipement can not be added or removed without unlocking it first. default: true asedit.give: @@ -49,6 +55,7 @@ permissions: description: Allows the checking for updates. default: false + asedit.ignoreProtection.towny: description: Allows user to ignore Towny's Protection Limitations. default: false @@ -95,7 +102,9 @@ permissions: children: asedit.basic: true asedit.equipment: true - asedit.disableslots: true + asedit.gravity: true + asedit.placement: true + asedit.disableSlots: true asedit.rename: true asedit.update: false asedit.give: false @@ -107,7 +116,9 @@ permissions: asedit.itemframe.invisible: true asedit.armorstand.invisible: true asedit.equipment: true - asedit.disableslots: true + asedit.gravity: true + asedit.placement: true + asedit.disableSlots: true asedit.rename: true asedit.update: true asedit.ignorePermissions.*: true \ No newline at end of file