use of net.minecraft.command.WrongUsageException in project Galacticraft by micdoodle8.
the class CommandPlanetTeleport method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
EntityPlayerMP playerBase = null;
if (args.length < 2) {
try {
if (args.length == 1) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[0], true);
} else {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
}
if (playerBase != null) {
MinecraftServer server = MinecraftServer.getServer();
WorldServer worldserver = server.worldServerForDimension(GCCoreUtil.getDimensionID(server.worldServers[0]));
BlockPos spawnPoint = worldserver.getSpawnPoint();
GCPlayerStats stats = GCPlayerStats.get(playerBase);
stats.setRocketStacks(new ItemStack[2]);
stats.setRocketType(IRocketType.EnumRocketType.DEFAULT.ordinal());
stats.setRocketItem(GCItems.rocketTier1);
stats.setFuelLevel(1000);
stats.setCoordsTeleportedFromX(spawnPoint.getX());
stats.setCoordsTeleportedFromZ(spawnPoint.getZ());
try {
WorldUtil.toCelestialSelection(playerBase, stats, Integer.MAX_VALUE);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
CommandBase.notifyOperators(sender, this, "commands.dimensionteleport", new Object[] { String.valueOf(EnumColor.GREY + "[" + playerBase.getName()), "]" });
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
}
}
use of net.minecraft.command.WrongUsageException in project Galacticraft by micdoodle8.
the class CommandJoinSpaceRace method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
MinecraftServer server = MinecraftServer.getServer();
EntityPlayerMP playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(server, sender.getName(), true);
if (args.length == 0) {
try {
if (playerBase != null) {
GCPlayerStats stats = GCPlayerStats.get(playerBase);
if (stats.getSpaceRaceInviteTeamID() > 0) {
SpaceRaceManager.sendSpaceRaceData(server, playerBase, SpaceRaceManager.getSpaceRaceFromID(stats.getSpaceRaceInviteTeamID()));
GalacticraftCore.packetPipeline.sendTo(new PacketSimple(EnumSimplePacket.C_OPEN_JOIN_RACE_GUI, GCCoreUtil.getDimensionID(playerBase.worldObj), new Object[] { stats.getSpaceRaceInviteTeamID() }), playerBase);
} else {
throw new Exception("You haven't been invited to a space race team!");
}
} else {
throw new Exception("Could not find player with name: " + args[0]);
}
} catch (final Exception var6) {
throw new CommandException(var6.getMessage(), new Object[0]);
}
} else {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.joinrace.no_team", this.getCommandUsage(sender)), new Object[0]);
}
}
use of net.minecraft.command.WrongUsageException in project Galacticraft by micdoodle8.
the class CommandGCAstroMiner method processCommand.
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
if (args.length > 2) {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.dimensiontp.too_many", this.getCommandUsage(sender)), new Object[0]);
}
if (args.length < 1) {
throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getCommandUsage(sender)), new Object[0]);
}
int type = 0;
int newvalue = 0;
if (args[0].equalsIgnoreCase("show")) {
type = 1;
} else if (args[0].equalsIgnoreCase("reset")) {
type = 2;
} else if (args[0].length() > 3 && args[0].substring(0, 3).equalsIgnoreCase("set")) {
String number = args[0].substring(3);
try {
newvalue = Integer.parseInt(number);
if (newvalue > 0) {
type = 3;
}
} catch (NumberFormatException ex) {
}
}
// Proceed if syntax of show|reset|set<number> was correct
if (type > 0) {
EntityPlayerMP playerBase = null;
try {
if (args.length == 2) {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(args[1], true);
} else {
playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
}
if (playerBase != null) {
GCPlayerStats stats = GCPlayerStats.get(playerBase);
switch(type) {
case 1:
sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + stats.getAstroMinerCount())));
break;
case 2:
stats.setAstroMinerCount(0);
sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + 0)));
break;
case 3:
stats.setAstroMinerCount(newvalue);
sender.addChatMessage(new ChatComponentText(GCCoreUtil.translateWithFormat("command.gcastrominer.count", PlayerUtil.getName(playerBase), "" + newvalue)));
break;
}
} else {
throw new Exception("Could not find player with name: " + args[1]);
}
} catch (final Exception e) {
throw new CommandException(e.getMessage(), new Object[0]);
}
return;
}
}
use of net.minecraft.command.WrongUsageException in project Bewitchment by Um-Mitternacht.
the class CommandIncantation method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (args.length < 1)
throw new WrongUsageException("commands.incantation.usage");
if (sender.getCommandSenderEntity() == null)
return;
final String command = args[0];
if (ModIncantations.getCommands().containsKey(command)) {
IIncantation incantation = ModIncantations.getCommands().get(command);
if (sender.getCommandSenderEntity() instanceof EntityPlayer) {
EntityPlayer player = (EntityPlayer) sender.getCommandSenderEntity();
Optional<IEnergy> ienopt = EnergyHandler.getEnergy(player);
if (ienopt.isPresent()) {
if (ienopt.get().get() >= incantation.getCost()) {
EnergyHandler.addEnergy(player, -incantation.getCost());
incantation.cast(player, args);
} else {
throw new CommandException("commands.incantation.no_energy", sender.getName());
}
} else {
throw new CommandException("commands.incantation.no_energy", sender.getName());
}
}
} else {
throw new CommandException("commands.incantation.notFound", sender.getName());
}
}
use of net.minecraft.command.WrongUsageException in project Wizardry by TeamWizardry.
the class CommandWizardry method execute.
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args) throws CommandException {
if (args.length < 1)
throw new WrongUsageException(getUsage(sender));
if (args[0].equalsIgnoreCase("reload")) {
ModuleRegistry.INSTANCE.loadUnprocessedModules();
ModuleRegistry.INSTANCE.copyMissingModulesFromResources(CommonProxy.directory);
ModuleRegistry.INSTANCE.processModules();
if (server.isDedicatedServer()) {
PacketHandler.NETWORK.sendToAll(new PacketSyncModules(ModuleRegistry.INSTANCE.modules));
}
notifyCommandListener(sender, this, "wizardry.command.success");
} else if (args[0].equalsIgnoreCase("reset")) {
notifyCommandListener(sender, this, "wizardry.command.reset");
File moduleDirectory = new File(CommonProxy.directory, "modules");
if (moduleDirectory.exists()) {
File[] files = moduleDirectory.listFiles();
if (files != null)
for (File file : files) {
String name = file.getName();
if (!file.delete()) {
throw new CommandException("wizardry.command.fail", name);
} else {
notifyCommandListener(sender, this, "wizardry.command.success_delete", name);
}
}
if (!moduleDirectory.delete()) {
throw new CommandException("wizardry.command.fail_dir_delete");
}
}
if (!moduleDirectory.exists())
if (!moduleDirectory.mkdirs()) {
throw new CommandException("wizardry.command.fail_dir_create");
}
ModuleRegistry.INSTANCE.setDirectory(moduleDirectory);
ModuleRegistry.INSTANCE.loadUnprocessedModules();
ModuleRegistry.INSTANCE.copyMissingModulesFromResources(CommonProxy.directory);
ModuleRegistry.INSTANCE.processModules();
if (server.isDedicatedServer()) {
PacketHandler.NETWORK.sendToAll(new PacketSyncModules(ModuleRegistry.INSTANCE.modules));
}
notifyCommandListener(sender, this, "wizardry.command.success");
} else if (args[0].equalsIgnoreCase("listModules")) {
notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\");
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module List");
for (Module module : ModuleRegistry.INSTANCE.modules) {
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + module.getID() + TextFormatting.RESET + ": " + TextFormatting.GRAY + module.getReadableName());
}
notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
} else if (args[0].equalsIgnoreCase("debug")) {
if (args.length < 2)
throw new WrongUsageException(getUsage(sender));
Module module = ModuleRegistry.INSTANCE.getModule(args[1]);
if (module == null) {
notifyCommandListener(sender, this, "Module not found.");
return;
}
notifyCommandListener(sender, this, TextFormatting.YELLOW + " ________________________________________________\\\\");
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | " + TextFormatting.GRAY + "Module " + module.getReadableName() + ":");
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Description " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getDescription());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Item Stack " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getItemStack().getDisplayName());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Burnout Fill " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutFill());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_ " + TextFormatting.DARK_GREEN + "Burnout Multiplier" + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getBurnoutMultiplier());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Mana Drain " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaDrain());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_" + TextFormatting.DARK_GREEN + "Mana Multiplier " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getManaMultiplier());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Power Multiplier " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getPowerMultiplier());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Charge Up Time " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getChargeupTime());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Cooldown Time " + TextFormatting.GRAY + " | " + TextFormatting.GRAY + module.getCooldownTime());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Primary Color " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getPrimaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getPrimaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getPrimaryColor().getBlue());
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Secondary Color " + TextFormatting.GRAY + " | " + TextFormatting.RED + module.getSecondaryColor().getRed() + TextFormatting.GRAY + ", " + TextFormatting.GREEN + module.getSecondaryColor().getGreen() + TextFormatting.GRAY + ", " + TextFormatting.BLUE + module.getSecondaryColor().getBlue());
if (!module.getAttributes().isEmpty())
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Default AttributeRegistry");
for (AttributeModifier attributeModifier : module.getAttributes()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " | | |_ " + TextFormatting.GRAY + attributeModifier.toString());
ModuleModifier[] modifierList = module.applicableModifiers();
if (modifierList != null) {
notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.GREEN + "Applicable Modifiers ");
for (ModuleModifier modifier : modifierList) notifyCommandListener(sender, this, TextFormatting.YELLOW + " | |_ " + TextFormatting.DARK_GREEN + modifier.getID());
}
notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
} else {
throw new WrongUsageException(getUsage(sender));
}
}
Aggregations