2016-03-14 19:00:03 -07:00
|
|
|
package WayofTime.bloodmagic.command.sub;
|
|
|
|
|
2016-06-12 13:41:02 -07:00
|
|
|
import WayofTime.bloodmagic.api.saving.SoulNetwork;
|
2016-03-14 19:00:03 -07:00
|
|
|
import WayofTime.bloodmagic.api.util.helper.NetworkHelper;
|
|
|
|
import WayofTime.bloodmagic.api.util.helper.PlayerHelper;
|
|
|
|
import WayofTime.bloodmagic.command.SubCommandBase;
|
|
|
|
import WayofTime.bloodmagic.util.Utils;
|
|
|
|
import WayofTime.bloodmagic.util.helper.TextHelper;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.command.CommandBase;
|
2016-03-14 19:00:03 -07:00
|
|
|
import net.minecraft.command.ICommand;
|
|
|
|
import net.minecraft.command.ICommandSender;
|
|
|
|
import net.minecraft.command.PlayerNotFoundException;
|
|
|
|
import net.minecraft.entity.player.EntityPlayer;
|
2016-03-17 13:00:44 -07:00
|
|
|
import net.minecraft.server.MinecraftServer;
|
|
|
|
import net.minecraft.util.text.TextComponentString;
|
2016-03-14 19:00:03 -07:00
|
|
|
|
|
|
|
import java.util.Locale;
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
public class SubCommandOrb extends SubCommandBase
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
public SubCommandOrb(ICommand parent)
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
super(parent, "orb");
|
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-16 18:41:06 -04:00
|
|
|
public String getArgUsage(ICommandSender commandSender)
|
|
|
|
{
|
2016-03-17 13:00:44 -07:00
|
|
|
return TextHelper.localizeEffect("commands.orb.usage");
|
2016-03-14 19:00:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-16 18:41:06 -04:00
|
|
|
public String getHelpText()
|
|
|
|
{
|
2016-03-17 13:00:44 -07:00
|
|
|
return TextHelper.localizeEffect("commands.orb.help");
|
2016-03-14 19:00:03 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
@Override
|
2016-03-17 13:00:44 -07:00
|
|
|
public void processSubCommand(MinecraftServer server, ICommandSender commandSender, String[] args)
|
2016-03-16 18:41:06 -04:00
|
|
|
{
|
2016-03-17 13:00:44 -07:00
|
|
|
super.processSubCommand(server, commandSender, args);
|
2016-03-14 19:00:03 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
if (args.length > 0)
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
|
|
|
|
if (args[0].equalsIgnoreCase("help"))
|
|
|
|
return;
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
try
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
String givenName = commandSender.getName();
|
|
|
|
|
|
|
|
if (args.length > 1)
|
|
|
|
givenName = args[1];
|
|
|
|
|
2016-03-17 13:00:44 -07:00
|
|
|
EntityPlayer player = CommandBase.getPlayer(server, commandSender, givenName);
|
2016-03-14 19:00:03 -07:00
|
|
|
String uuid = PlayerHelper.getUUIDFromPlayer(player).toString();
|
|
|
|
SoulNetwork network = NetworkHelper.getSoulNetwork(uuid);
|
|
|
|
|
|
|
|
boolean displayHelp = isBounded(0, 2, args.length);
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
try
|
|
|
|
{
|
|
|
|
switch (ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH)))
|
|
|
|
{
|
|
|
|
case SET:
|
|
|
|
{
|
|
|
|
if (displayHelp)
|
|
|
|
{
|
|
|
|
displayHelpString(commandSender, ValidCommands.SET.help);
|
|
|
|
break;
|
|
|
|
}
|
2016-03-14 19:00:03 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
if (args.length == 3)
|
|
|
|
{
|
|
|
|
if (Utils.isInteger(args[2]))
|
|
|
|
{
|
|
|
|
int amount = Integer.parseInt(args[2]);
|
|
|
|
network.setOrbTier(amount);
|
|
|
|
displaySuccessString(commandSender, "commands.success");
|
|
|
|
} else
|
|
|
|
{
|
|
|
|
displayErrorString(commandSender, "commands.error.arg.invalid");
|
2016-03-14 19:00:03 -07:00
|
|
|
}
|
2016-03-16 18:41:06 -04:00
|
|
|
} else
|
|
|
|
{
|
|
|
|
displayErrorString(commandSender, "commands.error.arg.missing");
|
|
|
|
}
|
2016-03-14 19:00:03 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
case GET:
|
|
|
|
{
|
|
|
|
if (displayHelp)
|
|
|
|
{
|
|
|
|
displayHelpString(commandSender, ValidCommands.GET.help);
|
2016-03-14 19:00:03 -07:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
if (args.length > 1)
|
2016-03-17 13:00:44 -07:00
|
|
|
commandSender.addChatMessage(new TextComponentString(TextHelper.localizeEffect("message.orb.currenttier", network.getOrbTier())));
|
2016-03-14 19:00:03 -07:00
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
break;
|
|
|
|
}
|
2016-03-14 19:00:03 -07:00
|
|
|
}
|
2016-03-16 18:41:06 -04:00
|
|
|
} catch (IllegalArgumentException e)
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
displayErrorString(commandSender, "commands.error.404");
|
|
|
|
}
|
2016-03-16 18:41:06 -04:00
|
|
|
} catch (PlayerNotFoundException e)
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
displayErrorString(commandSender, "commands.error.404");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
private enum ValidCommands
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
SET("commands.orb.set.help"),
|
|
|
|
GET("commands.orb.get.help");
|
|
|
|
|
|
|
|
public String help;
|
|
|
|
|
2016-03-16 18:41:06 -04:00
|
|
|
ValidCommands(String help)
|
|
|
|
{
|
2016-03-14 19:00:03 -07:00
|
|
|
this.help = help;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|