!Added debug commands for dev./bug tracking

This commit is contained in:
Aria 2019-11-02 19:23:31 +01:00
parent b719d88a55
commit b09f88e157
4 changed files with 71 additions and 0 deletions

View File

@ -15,6 +15,7 @@ import net.Indyuce.mmocore.command.rpg.NoteCommandMap;
import net.Indyuce.mmocore.command.rpg.ReloadCommandMap; import net.Indyuce.mmocore.command.rpg.ReloadCommandMap;
import net.Indyuce.mmocore.command.rpg.admin.AdminCommandMap; import net.Indyuce.mmocore.command.rpg.admin.AdminCommandMap;
import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandMap; import net.Indyuce.mmocore.command.rpg.booster.BoosterCommandMap;
import net.Indyuce.mmocore.command.rpg.debug.DebugCommandMap;
import net.Indyuce.mmocore.command.rpg.waypoint.WaypointsCommandMap; import net.Indyuce.mmocore.command.rpg.waypoint.WaypointsCommandMap;
public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabCompleter { public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabCompleter {
@ -25,6 +26,7 @@ public class MMOCoreCommand extends CommandRoot implements CommandExecutor, TabC
addFloor(new CoinsCommandMap(this)); addFloor(new CoinsCommandMap(this));
addFloor(new NoteCommandMap(this)); addFloor(new NoteCommandMap(this));
addFloor(new AdminCommandMap(this)); addFloor(new AdminCommandMap(this));
addFloor(new DebugCommandMap(this));
addFloor(new BoosterCommandMap(this)); addFloor(new BoosterCommandMap(this));
addFloor(new WaypointsCommandMap(this)); addFloor(new WaypointsCommandMap(this));
} }

View File

@ -0,0 +1,7 @@
package net.Indyuce.mmocore.command.rpg.debug;
import org.bukkit.ChatColor;
public class Debug {
public static final String cmdPrefix = ChatColor.YELLOW + "[" + ChatColor.RED + "DEBUG" + ChatColor.GOLD + "] " + ChatColor.RESET;
}

View File

@ -0,0 +1,18 @@
package net.Indyuce.mmocore.command.rpg.debug;
import org.bukkit.command.CommandSender;
import net.Indyuce.mmocore.command.api.CommandMap;
public class DebugCommandMap extends CommandMap {
public DebugCommandMap(CommandMap parent) {
super(parent, "debug");
addFloor(new StatValueCommandMap(this));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
return CommandResult.THROW_USAGE;
}
}

View File

@ -0,0 +1,44 @@
package net.Indyuce.mmocore.command.rpg.debug;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import net.Indyuce.mmocore.api.player.PlayerData;
import net.Indyuce.mmocore.api.player.stats.StatType;
import net.Indyuce.mmocore.command.api.CommandEnd;
import net.Indyuce.mmocore.command.api.CommandMap;
import net.Indyuce.mmocore.command.api.Parameter;
public class StatValueCommandMap extends CommandEnd {
public StatValueCommandMap(CommandMap parent) {
super(parent, "statvalue");
addParameter(new Parameter("<stat>", list -> { for(StatType stat : StatType.values()) list.add(stat.name()); }));
addParameter(new Parameter("(formatted)", list -> { list.add("true"); }));
}
@Override
public CommandResult execute(CommandSender sender, String[] args) {
if (args.length < 3 )
return CommandResult.THROW_USAGE;
if(!(sender instanceof Player)) {
sender.sendMessage(ChatColor.RED + "This command can only be used by a player.");
return CommandResult.FAILURE;
}
PlayerData data = PlayerData.get((Player) sender);
StatType stat = StatType.valueOf(args[2]);
if (stat == null) {
sender.sendMessage(ChatColor.RED + "Could not find stat: " + args[2] + ".");
return CommandResult.FAILURE;
}
if(args.length > 3 && args[3].equals("true"))
sender.sendMessage(Debug.cmdPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
else sender.sendMessage(Debug.cmdPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + data.getStats().getStat(stat));
return CommandResult.SUCCESS;
}
}