forked from Upstream/mmocore
!Small command fixes
This commit is contained in:
parent
5b67d2cca8
commit
d8f1e8d9e9
@ -1,7 +1,10 @@
|
|||||||
package net.Indyuce.mmocore.command.rpg.admin;
|
package net.Indyuce.mmocore.command.rpg.admin;
|
||||||
|
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import net.Indyuce.mmocore.MMOCore;
|
||||||
|
import net.Indyuce.mmocore.api.player.PlayerData;
|
||||||
import net.Indyuce.mmocore.command.api.CommandMap;
|
import net.Indyuce.mmocore.command.api.CommandMap;
|
||||||
|
|
||||||
public class AdminCommandMap extends CommandMap {
|
public class AdminCommandMap extends CommandMap {
|
||||||
@ -30,6 +33,9 @@ public class AdminCommandMap extends CommandMap {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandSender sender, String[] args) {
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
|
|
||||||
|
MMOCore.plugin.lootChests.getRegion("test-region").spawnChest(PlayerData.get((Player) sender));
|
||||||
|
|
||||||
return CommandResult.THROW_USAGE;
|
return CommandResult.THROW_USAGE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -14,31 +14,41 @@ public class StatValueCommandMap extends CommandEnd {
|
|||||||
public StatValueCommandMap(CommandMap parent) {
|
public StatValueCommandMap(CommandMap parent) {
|
||||||
super(parent, "statvalue");
|
super(parent, "statvalue");
|
||||||
|
|
||||||
addParameter(new Parameter("<stat>", list -> { for(StatType stat : StatType.values()) list.add(stat.name()); }));
|
addParameter(new Parameter("<stat>", list -> {
|
||||||
addParameter(new Parameter("(formatted)", list -> { list.add("true"); }));
|
for (StatType stat : StatType.values())
|
||||||
|
list.add(stat.name());
|
||||||
|
}));
|
||||||
|
addParameter(new Parameter("(formatted)", list -> {
|
||||||
|
list.add("true");
|
||||||
|
}));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public CommandResult execute(CommandSender sender, String[] args) {
|
public CommandResult execute(CommandSender sender, String[] args) {
|
||||||
if (args.length < 3 )
|
if (args.length < 3)
|
||||||
return CommandResult.THROW_USAGE;
|
return CommandResult.THROW_USAGE;
|
||||||
|
|
||||||
if(!(sender instanceof Player)) {
|
if (!(sender instanceof Player)) {
|
||||||
sender.sendMessage(ChatColor.RED + "This command can only be used by a player.");
|
sender.sendMessage(ChatColor.RED + "This command can only be used by a player.");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
PlayerData data = PlayerData.get((Player) sender);
|
PlayerData data = PlayerData.get((Player) sender);
|
||||||
|
|
||||||
StatType stat = StatType.valueOf(args[2]);
|
StatType stat;
|
||||||
if (stat == null) {
|
try {
|
||||||
|
stat = StatType.valueOf(args[2].toUpperCase().replace("-", "_").replace(" ", "_"));
|
||||||
|
} catch (IllegalArgumentException exception) {
|
||||||
sender.sendMessage(ChatColor.RED + "Could not find stat: " + args[2] + ".");
|
sender.sendMessage(ChatColor.RED + "Could not find stat: " + args[2] + ".");
|
||||||
return CommandResult.FAILURE;
|
return CommandResult.FAILURE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if(args.length > 3 && args[3].equals("true"))
|
if (args.length > 3 && args[3].equals("true"))
|
||||||
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
|
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
|
||||||
else sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): " + ChatColor.GREEN + data.getStats().getStat(stat));
|
+ ChatColor.GREEN + stat.format(data.getStats().getStat(stat)) + ChatColor.WHITE + " *");
|
||||||
|
else
|
||||||
|
sender.sendMessage(DebugCommandMap.commandPrefix + "Stat Value (" + ChatColor.BLUE + stat.name() + ChatColor.WHITE + "): "
|
||||||
|
+ ChatColor.GREEN + data.getStats().getStat(stat));
|
||||||
|
|
||||||
return CommandResult.SUCCESS;
|
return CommandResult.SUCCESS;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user