diff --git a/.gitignore b/.gitignore index 72b2208e..9d631327 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ target/ /src/main/java/META-INF/*.MF /src/main/java/META-INF/ /TODO-LIST.MD +/dependency-reduced-pom.xml diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java index 467d488e..dee54abb 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java @@ -39,6 +39,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Objects; +import java.util.logging.Level; public class ArmorStandEditorPlugin extends JavaPlugin{ @@ -52,6 +53,8 @@ public class ArmorStandEditorPlugin extends JavaPlugin{ //Server Version Detection: Paper or Spigot and Invalid NMS Version String nmsVersion; + String languageFolderLocation = "lang/"; + String warningMCVer = "Minecraft Version: "; public boolean hasSpigot = false; public boolean hasPaper = false; String nmsVersionNotLatest = null; @@ -117,7 +120,7 @@ public void onEnable() { nmsVersion.startsWith("v1_11") || nmsVersion.startsWith("v1_12") || nmsVersion.startsWith("v1_13")){ - getLogger().warning("Minecraft Version: " + nmsVersion + " is not supported. Loading Plugin Failed."); + getLogger().log(Level.WARNING,"Minecraft Version: {0} is unsupported. Please Update Immediately. Loading failed.",nmsVersion); getLogger().info(SEPARATOR_FIELD); getServer().getPluginManager().disablePlugin(this); return; @@ -130,10 +133,10 @@ public void onEnable() { nmsVersion.startsWith("v1_17") || nmsVersion.startsWith("v1_18") ){ //Revert NMS Check for any 1.19 Version - getLogger().warning("Minecraft Version: " + nmsVersion + " is supported, but not latest."); - getLogger().warning("ArmorStandEditor will still work, but please update to the latest Version of " + nmsVersionNotLatest + ". Loading continuing."); + getLogger().log(Level.WARNING,"Minecraft Version: {0} is supported, but not latest.",nmsVersion); + getLogger().log(Level.WARNING, "ArmorStandEditor will still work on your current version. Loading Continuing."); } else { - getLogger().info("Minecraft Version: " + nmsVersion + " is supported. Loading continuing."); + getLogger().log(Level.INFO, "Minecraft Version: {0} is supported. Loading Continuing.",nmsVersion); } //Spigot Check hasSpigot = getHasSpigot(); @@ -147,9 +150,10 @@ public void onEnable() { return; } else { if (hasSpigot) { - getLogger().info("SpigotMC: " + hasSpigot); + getLogger().log(Level.INFO,"SpigotMC: {0}",hasSpigot); + //getLogger().info("SpigotMC: " + hasSpigot); } else { - getLogger().info("PaperMC: " + hasPaper); + getLogger().log(Level.INFO,"PaperMC: {0}",hasPaper); } } @@ -159,17 +163,17 @@ public void onEnable() { //saveResource doesn't accept File.separator on Windows, need to hardcode unix separator "/" instead updateConfig("", "config.yml"); - updateConfig("lang/", "test_NA.yml"); - updateConfig("lang/", "nl_NL.yml"); - updateConfig("lang/", "uk_UA.yml"); - updateConfig("lang/", "ru_RU.yml"); - updateConfig("lang/", "zh_CN.yml"); - updateConfig("lang/", "fr_FR.yml"); - updateConfig("lang/", "ro_RO.yml"); - updateConfig("lang/", "ja_JP.yml"); - updateConfig("lang/", "de_DE.yml"); - updateConfig("lang/", "es_ES.yml"); - updateConfig("lang/", "pt_BR.yml"); + updateConfig(languageFolderLocation, "test_NA.yml"); + updateConfig(languageFolderLocation, "nl_NL.yml"); + updateConfig(languageFolderLocation, "uk_UA.yml"); + updateConfig(languageFolderLocation, "ru_RU.yml"); + updateConfig(languageFolderLocation, "zh_CN.yml"); + updateConfig(languageFolderLocation, "fr_FR.yml"); + updateConfig(languageFolderLocation, "ro_RO.yml"); + updateConfig(languageFolderLocation, "ja_JP.yml"); + updateConfig(languageFolderLocation, "de_DE.yml"); + updateConfig(languageFolderLocation, "es_ES.yml"); + updateConfig(languageFolderLocation, "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); @@ -392,7 +396,6 @@ public boolean isEditTool(ItemStack itemStk){ if (editTool != itemStk.getType()) { return false; } //FIX: Depreciated Stack for getDurability - // if(requireToolData && item.getDurability() != (short)editToolData) return false; if (requireToolData){ Damageable d1 = (Damageable) itemStk.getItemMeta(); //Get the Damageable Options for itemStk if (d1 != null) { //We do this to prevent NullPointers diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java index 05b198b0..4b3b750f 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditor.java @@ -66,7 +66,6 @@ public class PlayerEditor { int frameTargetIndex = 0; EquipmentMenu equipMenu; long lastCancelled = 0; - private boolean state; public PlayerEditor(UUID uuid, ArmorStandEditorPlugin plugin) { this.uuid = uuid; @@ -171,6 +170,10 @@ public void editArmorStand(ArmorStand armorStand) { case NONE: sendMessage("nomode", null); break; + default: + sendMessage("nomode", null); + break; + } } @@ -182,9 +185,13 @@ public void editItemFrame(ItemFrame itemFrame) { break; case RESET: itemFrame.setVisible(true); + break; case NONE: sendMessage("nomodeif", null); break; + default: + sendMessage("nomodeif", null); + break; } } @@ -500,7 +507,7 @@ ArmorStand attemptTarget(ArmorStand armorStand) { void sendMessage(String path, String format, String option) { String message = plugin.getLang().getMessage(path, format, option); if (plugin.sendToActionBar) { - if (ArmorStandEditorPlugin.instance().hasSpigot || ArmorStandEditorPlugin.instance().hasPaper) { //Paper and Spigot having the same Interaction for sendToActionBar + if (ArmorStandEditorPlugin.instance().getHasPaper() || ArmorStandEditorPlugin.instance().getHasSpigot()) { //Paper and Spigot having the same Interaction for sendToActionBar plugin.getServer().getPlayer(getUUID()).spigot().sendMessage(ChatMessageType.ACTION_BAR, new TextComponent(message)); } else { String rawText = plugin.getLang().getRawMessage(path, format, option); diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java index b3d6954f..59a29f26 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/PlayerEditorManager.java @@ -22,7 +22,7 @@ import com.google.common.collect.ImmutableList; import io.github.rypofalem.armorstandeditor.menu.ASEHolder; import io.github.rypofalem.armorstandeditor.protections.*; -import me.ryanhamshire.GriefPrevention.GriefPrevention; + import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -60,7 +60,8 @@ public class PlayerEditorManager implements Listener { // Instantiate protections used to determine whether a player may edit an armor stand or item frame private final List protections = ImmutableList.of( new GriefDefenderProtection(), new GriefPreventionProtection(), new LandsProtection(), - new PlotSquaredProtection(), new SkyblockProtection(), new TownyProtection(), new WorldGuardProtection()); + new PlotSquaredProtection(), new SkyblockProtection(), new TownyProtection(), new WorldGuardProtection(), + new BentoBoxProtection()); PlayerEditorManager( ArmorStandEditorPlugin plugin) { this.plugin = plugin; 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 60ac7919..18221a7c 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefDefenderProtection.java @@ -18,7 +18,6 @@ public class GriefDefenderProtection implements Protection { public GriefDefenderProtection() { gdEnabled = Bukkit.getPluginManager().isPluginEnabled("GriefDefender"); - if(!gdEnabled) return; } public boolean checkPermission(Block block, Player player) { diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java index 7e92e0e7..bd494cbf 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/GriefPreventionProtection.java @@ -9,12 +9,14 @@ import org.bukkit.block.Block; import org.bukkit.entity.Player; +/** @deprecated **/ public class GriefPreventionProtection implements Protection { private boolean gpEnabled; private GriefPrevention griefPrevention = null; + /** @deprecated **/ public GriefPreventionProtection(){ gpEnabled = Bukkit.getPluginManager().isPluginEnabled("GriefPrevention"); @@ -22,6 +24,7 @@ public GriefPreventionProtection(){ griefPrevention = (GriefPrevention) Bukkit.getPluginManager().getPlugin("GriefPrevention"); } + /** @deprecated **/ public boolean checkPermission(Block block, Player player){ if(!gpEnabled) return true; if(player.hasPermission("asedit.ignoreProtection.griefPrevention")) return true; diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java b/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java index b04a1bb8..3eee0ffb 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/protections/LandsProtection.java @@ -4,7 +4,6 @@ import me.angeschossen.lands.api.LandsIntegration; import me.angeschossen.lands.api.land.Area; import me.angeschossen.lands.api.land.Land; -import me.angeschossen.lands.api.player.LandPlayer; import org.bukkit.Bukkit; import org.bukkit.block.Block; import org.bukkit.entity.Player; @@ -33,12 +32,12 @@ public boolean checkPermission(Block block, Player player) { //Get the Area that the block is in Area area = land.getArea(block.getLocation()); - //Get the Lands Player - LandPlayer lPlayer = lands.getLandPlayer(player.getUniqueId()); - - //Return if Trusted in the area or not either based on BukktiPlayer or LandsPlayer - return area == null ? area.isTrusted(player.getUniqueId()) : area.isTrusted(lPlayer.getUID()); + if(area != null) + //Return if Trusted in the area or not either based on BukkitPlayer + return area.isTrusted(player.getUniqueId()); + else + return false; } } 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 9c5a1da0..46c9f6d7 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 implements Protection { public TownyProtection(){ tEnabled = Bukkit.getPluginManager().isPluginEnabled("Towny"); - if(!tEnabled) return; } public boolean checkPermission(Block block, Player player){ @@ -27,9 +26,7 @@ public boolean checkPermission(Block block, Player player){ Location playerLoc = player.getLocation(); if (TownyAPI.getInstance().isWilderness(playerLoc)) return false; - if (!TownyActionEventExecutor.canDestroy(player, block.getLocation(), Material.ARMOR_STAND)) return false; - - return true; + return TownyActionEventExecutor.canDestroy(player, block.getLocation(), Material.ARMOR_STAND); } }