Skip to content

Commit

Permalink
Fix permission issues & add DCM (#138)
Browse files Browse the repository at this point in the history
* permission fixes

* version change
  • Loading branch information
Myuuiii authored Dec 14, 2024
1 parent a309489 commit fc2ad1b
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 16 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>com.myuuiii</groupId>
<artifactId>EmpireWandPlus</artifactId>
<version>2.2.4</version>
<version>2.2.5</version>
<packaging>jar</packaging>

<name>EmpireWandPlus</name>
Expand Down
15 changes: 8 additions & 7 deletions src/main/java/com/myuuiii/empirewandplus/Abstracts/Wand.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> Spells;
public String permissionBase = "";
public String Identifier = "";

public abstract String getDisplayName();

Expand All @@ -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) {
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -15,7 +18,7 @@ public class WandCommandCompleter implements TabCompleter {
public List<String> 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;
}
Expand Down
12 changes: 10 additions & 2 deletions src/main/java/com/myuuiii/empirewandplus/Wands/BloodWand.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,18 @@
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;
import java.util.List;


public class BloodWand extends Wand {

public final static String Identifier = "Blood";

public static List<String> Spells = new ArrayList<>() {
{
add(SpellNames.Spark);
Expand All @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

public class ElementosWand extends Wand {

public final static String Identifier = "Elementos";

public static List<String> Spells = new ArrayList<>() {
{
add(SpellNames.Spark);
Expand All @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@

public class EmpireWand extends Wand {

public final static String Identifier = "Empire";

public static List<String> Spells = new ArrayList<>() {
{
add(SpellNames.Spark);
Expand Down Expand Up @@ -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";
Expand All @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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));

Expand Down

0 comments on commit fc2ad1b

Please sign in to comment.