use of net.minecraft.command.CommandException in project BiomeTweaker by superckl.
the class CommandReloadScript method execute.
@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
if (args.length != 1) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.usage.text").setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
try {
final File operateIn = BiomeTweaker.getInstance().getConfig().getBtConfigFolder();
final File scriptFile = new File(operateIn, args[0]);
if (!scriptFile.exists() || !scriptFile.isFile()) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.nofile.text", scriptFile.getName()).setStyle(new Style().setColor(TextFormatting.RED)));
return;
}
BiomeTweaker.getInstance().parseScript(scriptFile);
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.success.text", scriptFile.getName()).setStyle(new Style().setColor(TextFormatting.AQUA)));
} catch (final Exception e) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reloadscript.failure.text", args[0]).setStyle(new Style().setColor(TextFormatting.RED)));
LogHelper.error(String.format("Failed to reload script %s!", args[0]));
e.printStackTrace();
}
}
use of net.minecraft.command.CommandException in project BiomeTweaker by superckl.
the class CommandReload method execute.
@Override
public void execute(final MinecraftServer server, final ICommandSender sender, final String[] args) throws CommandException {
try {
BiomeTweaker.getInstance().getConfig().loadValues();
BiomeTweaker.getInstance().getCommandManager().reset();
BiomeTweaker.getInstance().parseScripts();
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reload.success.text").setStyle(new Style().setColor(TextFormatting.AQUA)));
} catch (final Exception e) {
sender.sendMessage(new TextComponentTranslation("biometweaker.msg.reload.failure.text").setStyle(new Style().setColor(TextFormatting.RED)));
LogHelper.error("Failed to reload scripts!");
e.printStackTrace();
}
}
use of net.minecraft.command.CommandException 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.CommandException in project BuildCraft by BuildCraft.
the class SubCommandDeop method processSubCommand.
@Override
public void processSubCommand(ICommandSender sender, String[] args) throws CommandException {
MinecraftServer server = sender.getServer();
if (server == null) {
throw new CommandException("No server!");
} else {
server.getPlayerList().removeOp(BuildCraftCore.gameProfile);
CommandHelpers.sendLocalizedChatMessage(sender, "commands.deop.success", "[BuildCraft]");
}
}
use of net.minecraft.command.CommandException in project BuildCraft by BuildCraft.
the class SubCommandOp method processSubCommand.
@Override
public void processSubCommand(ICommandSender sender, String[] args) throws CommandException {
MinecraftServer server = sender.getServer();
if (server == null) {
throw new CommandException("No server!");
} else {
server.getPlayerList().addOp(BuildCraftCore.gameProfile);
CommandHelpers.sendLocalizedChatMessage(sender, "commands.op.success", "[BuildCraft]");
}
}
Aggregations