From 22836376603fcbd0be5a2995144739719c6446e8 Mon Sep 17 00:00:00 2001 From: Professor Bloodstone Date: Fri, 26 Jun 2020 09:25:49 +0200 Subject: [PATCH 1/2] Add optional NamespacedKey requirement to tool and publicize some fields. This allows plugins to hook into ASE and provide their own, custom tool. --- .../ArmorStandEditorPlugin.java | 22 +++++++++++++------ src/main/resources/config.yml | 2 +- 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java index c7ee9efc..9eddafeb 100644 --- a/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java +++ b/src/main/java/io/github/rypofalem/armorstandeditor/ArmorStandEditorPlugin.java @@ -25,6 +25,7 @@ import org.bukkit.NamespacedKey; import org.bukkit.entity.Player; import org.bukkit.inventory.ItemStack; +import org.bukkit.persistence.PersistentDataType; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; @@ -34,16 +35,19 @@ public class ArmorStandEditorPlugin extends JavaPlugin{ private NamespacedKey iconKey; private static ArmorStandEditorPlugin instance; + public final PersistentDataType editToolKeyType = PersistentDataType.BYTE; + public final NamespacedKey editToolKey = new NamespacedKey(this, "ASE"); private CommandEx execute; private Language lang; public boolean hasSpigot; public PlayerEditorManager editorManager; public Material editTool = Material.FLINT; - boolean requireToolData = false; - boolean sendToActionBar = true; - int editToolData = Integer.MIN_VALUE; - boolean requireToolLore = false; - String editToolLore = null; + public boolean requireToolData = false; + public boolean sendToActionBar = true; + public int editToolData = Integer.MIN_VALUE; + public boolean requireToolLore = false; + public String editToolLore = null; + public boolean requireToolKey = false; // Not configurable through config, since it's up to plugin to hook into boolean debug = false; //weather or not to broadcast messages via print(String message) double coarseRot; double fineRot; @@ -76,7 +80,7 @@ public void onEnable(){ if(requireToolData) editToolData = getConfig().getInt("toolData", Integer.MIN_VALUE); requireToolLore = getConfig().getBoolean("requireToolLore", false); if(requireToolLore) editToolLore= getConfig().getString("toolLore", null); - debug = getConfig().getBoolean("debug", true); + debug = getConfig().getBoolean("debug", false); sendToActionBar = getConfig().getBoolean("sendMessagesToActionBar", true); editorManager = new PlayerEditorManager(this); @@ -145,6 +149,10 @@ public boolean isEditTool(ItemStack item){ if(item.getItemMeta().getLore().isEmpty()) return false; if(!item.getItemMeta().getLore().get(0).equals(editToolLore)) return false; } + if(requireToolKey) { + if(!item.hasItemMeta()) return false; + if(item.getItemMeta().getPersistentDataContainer().get(editToolKey, editToolKeyType) == null) return false; + } return true; } @@ -155,4 +163,4 @@ public NamespacedKey getIconKey() { } //todo: //Access to "DisabledSlots" data (probably simplified just a toggle enable/disable) -//Access to the "Marker" switch (so you can make the hitbox super small) \ No newline at end of file +//Access to the "Marker" switch (so you can make the hitbox super small) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 56a6f773..2a9c3579 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -22,4 +22,4 @@ lang: en_US.yml sendMessagesToActionBar: true #Don't set to true unless you want players to see random messages or other undesirable behavior -debug: false \ No newline at end of file +debug: false From 79b59b74afc7dfbb8e34816529385c9466caafa2 Mon Sep 17 00:00:00 2001 From: Professor Bloodstone Date: Sat, 4 Jul 2020 10:41:48 +0200 Subject: [PATCH 2/2] Skip unit tests by default, since JUnit is no longer a dependency To run tests, use `mvn -DskipTests=false`, but requires to add JUnit dependency first anyway. https://maven.apache.org/plugins-archives/maven-surefire-plugin-2.12.4/examples/skipping-test.html --- pom.xml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/pom.xml b/pom.xml index 9a2fa77c..490265bb 100644 --- a/pom.xml +++ b/pom.xml @@ -10,6 +10,7 @@ UTF-8 + true @@ -39,6 +40,7 @@ 1.8 1.8 + ${skipTests}