From fc2ad1b57c08b823438af601373ef1795b219054 Mon Sep 17 00:00:00 2001 From: Maya Date: Sat, 14 Dec 2024 13:56:17 +0100 Subject: [PATCH] Fix permission issues & add DCM (#138) * permission fixes * version change --- pom.xml | 2 +- .../myuuiii/empirewandplus/Abstracts/Wand.java | 15 ++++++++------- .../Commands/WandCommandCompleter.java | 5 ++++- .../myuuiii/empirewandplus/Wands/BloodWand.java | 12 ++++++++++-- .../empirewandplus/Wands/ElementosWand.java | 9 +++++++-- .../myuuiii/empirewandplus/Wands/EmpireWand.java | 9 +++++++-- .../myuuiii/empirewandplus/Wands/WandMethods.java | 2 +- 7 files changed, 38 insertions(+), 16 deletions(-) diff --git a/pom.xml b/pom.xml index 0448dbf..23264ed 100644 --- a/pom.xml +++ b/pom.xml @@ -6,7 +6,7 @@ com.myuuiii EmpireWandPlus - 2.2.4 + 2.2.5 jar EmpireWandPlus diff --git a/src/main/java/com/myuuiii/empirewandplus/Abstracts/Wand.java b/src/main/java/com/myuuiii/empirewandplus/Abstracts/Wand.java index d01103f..80ea010 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Abstracts/Wand.java +++ b/src/main/java/com/myuuiii/empirewandplus/Abstracts/Wand.java @@ -14,12 +14,11 @@ import com.myuuiii.empirewandplus.Wands.ElementosWand; import com.myuuiii.empirewandplus.Wands.EmpireWand; -import java.util.ArrayList; import java.util.List; public abstract class Wand { public List Spells; - public String permissionBase = ""; + public String Identifier = ""; public abstract String getDisplayName(); @@ -28,16 +27,18 @@ public abstract class Wand { public abstract ItemStack getItem(); // Permission Names - public String getObtainPermissionName() { - return permissionBase + "obtain"; - } + public abstract String getPermissionBase(); public String getUsePermissionName() { - return permissionBase + "use"; + return getPermissionBase() + "use"; } public String getSwitchSpellPermissionName() { - return permissionBase + "switch"; + return getPermissionBase() + "switch"; + } + + public String getObtainPermissionName() { + return getPermissionBase() + "obtain"; } public boolean checkWandHeldState(final PlayerInteractEvent playerInteractionEvent, final Wand wand) { diff --git a/src/main/java/com/myuuiii/empirewandplus/Commands/WandCommandCompleter.java b/src/main/java/com/myuuiii/empirewandplus/Commands/WandCommandCompleter.java index 577e1c0..62e9818 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Commands/WandCommandCompleter.java +++ b/src/main/java/com/myuuiii/empirewandplus/Commands/WandCommandCompleter.java @@ -1,5 +1,8 @@ package com.myuuiii.empirewandplus.Commands; +import com.myuuiii.empirewandplus.Wands.BloodWand; +import com.myuuiii.empirewandplus.Wands.ElementosWand; +import com.myuuiii.empirewandplus.Wands.EmpireWand; import org.bukkit.command.Command; import org.bukkit.command.CommandSender; import org.bukkit.command.TabCompleter; @@ -15,7 +18,7 @@ public class WandCommandCompleter implements TabCompleter { public List onTabComplete(CommandSender sender, Command cmd, String label, String[] args) { if (args.length == 1) { return StringUtil.copyPartialMatches(args[0], - Arrays.asList("Empire", "Blood", "Elementos"), new ArrayList<>()); + Arrays.asList(EmpireWand.Identifier, BloodWand.Identifier, ElementosWand.Identifier), new ArrayList<>()); } return null; } diff --git a/src/main/java/com/myuuiii/empirewandplus/Wands/BloodWand.java b/src/main/java/com/myuuiii/empirewandplus/Wands/BloodWand.java index 94efa18..25dacb2 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Wands/BloodWand.java +++ b/src/main/java/com/myuuiii/empirewandplus/Wands/BloodWand.java @@ -12,6 +12,8 @@ import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.meta.ItemMeta; +import javax.naming.Name; + import static com.myuuiii.empirewandplus.Extensions.colorText; import java.util.ArrayList; @@ -19,6 +21,9 @@ public class BloodWand extends Wand { + + public final static String Identifier = "Blood"; + public static List Spells = new ArrayList<>() { { add(SpellNames.Spark); @@ -27,8 +32,6 @@ public class BloodWand extends Wand { } }; - public final String permissionBase = EmpireWandPlus.PermissionPrefix + "bloodwand."; - @Override public String getDisplayName() { return ChatColor.RED + "Blood Wand"; @@ -53,6 +56,11 @@ public ItemStack getItem() { return wand; } + @Override + public String getPermissionBase() { + return EmpireWandPlus.PermissionPrefix + "blood."; + } + @Override public void Handle(PlayerInteractEvent e) { final BloodWand bloodWand = (BloodWand) EmpireWandPlus.wandHashMap.get("blood"); diff --git a/src/main/java/com/myuuiii/empirewandplus/Wands/ElementosWand.java b/src/main/java/com/myuuiii/empirewandplus/Wands/ElementosWand.java index e76b02a..bea956d 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Wands/ElementosWand.java +++ b/src/main/java/com/myuuiii/empirewandplus/Wands/ElementosWand.java @@ -20,6 +20,8 @@ public class ElementosWand extends Wand { + public final static String Identifier = "Elementos"; + public static List Spells = new ArrayList<>() { { add(SpellNames.Spark); @@ -31,8 +33,6 @@ public class ElementosWand extends Wand { } }; - public final String permissionBase = EmpireWandPlus.PermissionPrefix + "elementoswand."; - @Override public String getDisplayName() { return ChatColor.AQUA + "Elementos Wand"; @@ -58,6 +58,11 @@ public ItemStack getItem() { return wand; } + @Override + public String getPermissionBase() { + return EmpireWandPlus.PermissionPrefix + "elementos."; + } + @Override public void Handle(PlayerInteractEvent e) { final ElementosWand elementosWand = (ElementosWand) EmpireWandPlus.wandHashMap.get("elementos"); diff --git a/src/main/java/com/myuuiii/empirewandplus/Wands/EmpireWand.java b/src/main/java/com/myuuiii/empirewandplus/Wands/EmpireWand.java index e4e381c..1115685 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Wands/EmpireWand.java +++ b/src/main/java/com/myuuiii/empirewandplus/Wands/EmpireWand.java @@ -20,6 +20,8 @@ public class EmpireWand extends Wand { + public final static String Identifier = "Empire"; + public static List Spells = new ArrayList<>() { { add(SpellNames.Spark); @@ -59,8 +61,6 @@ public class EmpireWand extends Wand { } }; - public final String permissionBase = EmpireWandPlus.PermissionPrefix + "empirewand."; - @Override public String getDisplayName() { return ChatColor.GOLD + "Empire Wand"; @@ -85,6 +85,11 @@ public ItemStack getItem() { return wand; } + @Override + public String getPermissionBase() { + return EmpireWandPlus.PermissionPrefix + "empire."; + } + @Override public void Handle(PlayerInteractEvent e) { final EmpireWand empireWand = (EmpireWand) EmpireWandPlus.wandHashMap.get("empire"); diff --git a/src/main/java/com/myuuiii/empirewandplus/Wands/WandMethods.java b/src/main/java/com/myuuiii/empirewandplus/Wands/WandMethods.java index 7e620ec..a39a614 100644 --- a/src/main/java/com/myuuiii/empirewandplus/Wands/WandMethods.java +++ b/src/main/java/com/myuuiii/empirewandplus/Wands/WandMethods.java @@ -36,7 +36,7 @@ public static void CycleSpell(Player p, ItemStack wandItem, ItemMeta meta, List< public static void ExecuteSpellOnLeftClick(PlayerInteractEvent e, Player p, ItemStack wand) { if (e.getAction() == Action.LEFT_CLICK_AIR || e.getAction() == Action.LEFT_CLICK_BLOCK) { e.setCancelled(true); - + // Retrieve the spell that is to be executed Spell spell = EmpireWandPlus.spellHashMap.get(wand.getItemMeta().getLore().get(0));