use of net.minecraft.command.PlayerNotFoundException in project BloodMagic by WayofTime.
the class SubCommandBind method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
if (commandSender.getEntityWorld().isRemote)
return;
try {
EntityPlayer player = CommandBase.getCommandSenderAsPlayer(commandSender);
ItemStack held = player.getHeldItemMainhand();
boolean bind = true;
if (held.getItem() instanceof IBindable) {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("help"))
return;
if (isBoolean(args[0])) {
bind = Boolean.parseBoolean(args[0]);
if (args.length > 2)
player = CommandBase.getPlayer(server, commandSender, args[1]);
} else {
player = CommandBase.getPlayer(server, commandSender, args[0]);
}
}
if (bind) {
Binding binding = new Binding(player.getGameProfile().getId(), player.getGameProfile().getName());
BindableHelper.applyBinding(held, binding);
commandSender.sendMessage(new TextComponentTranslation("commands.bind.success"));
} else {
Binding binding = ((IBindable) held.getItem()).getBinding(held);
if (binding != null) {
held.getTagCompound().removeTag("binding");
commandSender.sendMessage(new TextComponentTranslation("commands.bind.remove.success"));
}
}
}
} catch (PlayerNotFoundException e) {
commandSender.sendMessage(new TextComponentTranslation(TextHelper.localizeEffect("commands.error.404")));
}
}
use of net.minecraft.command.PlayerNotFoundException in project BloodMagic by WayofTime.
the class SubCommandNetwork method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
if (args.length > 1) {
if (args[0].equalsIgnoreCase("help"))
return;
try {
EntityPlayer player = CommandBase.getPlayer(server, commandSender, args[1]);
try {
ValidCommands command = ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH));
command.run(player, commandSender, args.length > 0 && args.length < 2, args);
} catch (IllegalArgumentException e) {
}
} catch (PlayerNotFoundException e) {
CommandBloodMagic.displayErrorString(commandSender, e.getLocalizedMessage());
}
} else {
CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.missing");
}
}
use of net.minecraft.command.PlayerNotFoundException in project BloodMagic by WayofTime.
the class SubCommandOrb method execute.
@Override
public void execute(MinecraftServer server, ICommandSender commandSender, String[] args) throws CommandException {
if (args.length > 0) {
if (args[0].equalsIgnoreCase("help"))
return;
try {
String givenName = commandSender.getName();
if (args.length > 1)
givenName = args[1];
EntityPlayer player = CommandBase.getPlayer(server, commandSender, givenName);
String uuid = PlayerHelper.getUUIDFromPlayer(player).toString();
SoulNetwork network = NetworkHelper.getSoulNetwork(uuid);
boolean displayHelp = args.length > 0 && args.length < 2;
try {
switch(ValidCommands.valueOf(args[0].toUpperCase(Locale.ENGLISH))) {
case SET:
{
if (displayHelp) {
CommandBloodMagic.displayHelpString(commandSender, ValidCommands.SET.help);
break;
}
if (args.length == 3) {
if (Utils.isInteger(args[2])) {
int amount = Integer.parseInt(args[2]);
network.setOrbTier(amount);
CommandBloodMagic.displaySuccessString(commandSender, "commands.success");
} else {
CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.invalid");
}
} else {
CommandBloodMagic.displayErrorString(commandSender, "commands.error.arg.missing");
}
break;
}
case GET:
{
if (displayHelp) {
CommandBloodMagic.displayHelpString(commandSender, ValidCommands.GET.help);
break;
}
if (args.length > 1)
commandSender.sendMessage(new TextComponentString(TextHelper.localizeEffect("message.orb.currenttier", network.getOrbTier())));
break;
}
}
} catch (IllegalArgumentException e) {
CommandBloodMagic.displayErrorString(commandSender, "commands.error.404");
}
} catch (PlayerNotFoundException e) {
CommandBloodMagic.displayErrorString(commandSender, "commands.error.404");
}
}
}
use of net.minecraft.command.PlayerNotFoundException in project Minestuck by mraof.
the class CommandCheckLand method execute.
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
if (!(sender instanceof EntityPlayerMP))
throw new PlayerNotFoundException("commands.playerOnly");
EntityPlayerMP player = (EntityPlayerMP) sender;
if (MinestuckDimensionHandler.isLandDimension(player.dimension)) {
LandAspectRegistry.AspectCombination aspects = MinestuckDimensionHandler.getAspects(player.dimension);
ChunkProviderLands chunkProvider = (ChunkProviderLands) player.world.provider.createChunkGenerator();
ITextComponent aspect1 = new TextComponentTranslation("land." + aspects.aspectTerrain.getNames()[chunkProvider.nameIndex1]);
ITextComponent aspect2 = new TextComponentTranslation("land." + aspects.aspectTitle.getNames()[chunkProvider.nameIndex2]);
ITextComponent toSend;
if (chunkProvider.nameOrder)
toSend = new TextComponentTranslation("land.message.check", aspect1, aspect2);
else
toSend = new TextComponentTranslation("land.message.check", aspect2, aspect1);
player.sendMessage(toSend);
} else {
player.sendMessage(new TextComponentTranslation("land.message.checkFail"));
}
}
Aggregations