diff --git a/src/main/java/gg/quartzdev/qxpboosts/boost/BoostManager.java b/src/main/java/gg/quartzdev/qxpboosts/boost/BoostManager.java index 26b04f8..5ef8b14 100644 --- a/src/main/java/gg/quartzdev/qxpboosts/boost/BoostManager.java +++ b/src/main/java/gg/quartzdev/qxpboosts/boost/BoostManager.java @@ -1,11 +1,11 @@ package gg.quartzdev.qxpboosts.boost; import gg.quartzdev.qxpboosts.qConfig; -import gg.quartzdev.qxpboosts.qPermission; import gg.quartzdev.qxpboosts.qXpBoosts; +import gg.quartzdev.qxpboosts.util.Language; import gg.quartzdev.qxpboosts.util.qLogger; +import org.apache.commons.lang3.text.WordUtils; import org.bukkit.entity.Player; -import org.bukkit.permissions.PermissionAttachmentInfo; import org.jetbrains.annotations.NotNull; import java.util.HashMap; @@ -31,6 +31,7 @@ public BoostManager(){ this.boosts = new HashMap<>(); this.playerTracker = new HashMap<>(); + this.boostTracker = new HashMap<>(); this.defaultBoost = new Boost("default", 1.25); } @@ -60,4 +61,31 @@ public void loadBoosts(){ } + public Set listBoosts(){ + Set boostList = new HashSet<>(); + + boostList.add(this.getBoostInfo(this.defaultBoost)); + + for(Boost boost : boosts.values()) + boostList.add(this.getBoostInfo(boost)); + + return boostList; + } + + public String getBoostInfo(Boost boost){ + + String boostStatus = Language.BOOST_STATUS_ERROR.toString(); + + if(boostTracker.get(boost) != null) + boostStatus = (boostTracker.get(boost)) ? Language.BOOST_STATUS_ACTIVE.toString() : Language.BOOST_STATUS_DISABLED.toString(); + + String bootInfo = Language.BOOST_INFO.toString() + .replaceAll("", WordUtils.capitalizeFully(boost.getName())) + .replaceAll("", String.valueOf(defaultBoost.getMultiplier())) + .replaceAll("", boostStatus) + .replaceAll("", Language.CHAT_PREFIX.name()); + + return bootInfo; + } + } diff --git a/src/main/java/gg/quartzdev/qxpboosts/commands/CMDlist.java b/src/main/java/gg/quartzdev/qxpboosts/commands/CMDlist.java index 071a424..1ed3e06 100644 --- a/src/main/java/gg/quartzdev/qxpboosts/commands/CMDlist.java +++ b/src/main/java/gg/quartzdev/qxpboosts/commands/CMDlist.java @@ -1,4 +1,33 @@ package gg.quartzdev.qxpboosts.commands; -public class CMDlist { +import gg.quartzdev.qxpboosts.qXpBoosts; +import gg.quartzdev.qxpboosts.util.Language; +import gg.quartzdev.qxpboosts.util.qUtil; +import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.minimessage.MiniMessage; +import org.bukkit.command.CommandSender; + +import java.util.Set; + +public class CMDlist extends qCMD{ + + public CMDlist(String name, String label) { + super(name, label); + this.permissionGroup = "qmbde.admin"; + this.permissionNode = "qmbde.command.reload"; + } + + @Override + public boolean logic(CommandSender sender, String[] args) { + + Set boostList = qXpBoosts.getInstance().boostManager.listBoosts(); + + String message = String.join("", boostList); + MiniMessage mm = MiniMessage.miniMessage(); + Component component = mm.deserialize(message); + sender.sendMessage(component); + + return false; + } + } diff --git a/src/main/java/gg/quartzdev/qxpboosts/commands/CommandManager.java b/src/main/java/gg/quartzdev/qxpboosts/commands/CommandManager.java index 8f87b3f..4b52314 100644 --- a/src/main/java/gg/quartzdev/qxpboosts/commands/CommandManager.java +++ b/src/main/java/gg/quartzdev/qxpboosts/commands/CommandManager.java @@ -30,9 +30,17 @@ public CommandManager(String name){ @Override public boolean execute(@NotNull CommandSender sender, @NotNull String labelOrAlias, @NotNull String[] args) { - if(args.length >= 1) - if(args[0].equalsIgnoreCase("reload")) + if(args.length >= 1) { + if (args[0].equalsIgnoreCase("reload")) { return (new CMDreload(args[0], labelOrAlias)).run(sender, args); + } + if (args[0].equalsIgnoreCase("list")) { + return (new CMDlist(args[0], labelOrAlias)).run(sender, args); + } +// if (args[0].equalsIgnoreCase("enable")) { +// return (new CMDreload(args[0], labelOrAlias)).run(sender, args); +// } + } return (new CMD(null, labelOrAlias)).run(sender, args); diff --git a/src/main/java/gg/quartzdev/qxpboosts/util/Language.java b/src/main/java/gg/quartzdev/qxpboosts/util/Language.java index adf70a0..6131908 100644 --- a/src/main/java/gg/quartzdev/qxpboosts/util/Language.java +++ b/src/main/java/gg/quartzdev/qxpboosts/util/Language.java @@ -18,7 +18,8 @@ public enum Language { XP_CHAT_GAIN(" Gained x XP"), // Boost - BOOST_INFO(" - "), + BOOST_INFO(" - - "), + BOOST_STATUS_ERROR("Error"), BOOST_STATUS_ACTIVE("Active"), BOOST_STATUS_DISABLED("Disabled");