Search in sources :

Example 1 with PlayerNotFoundException

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")));
    }
}
Also used : Binding(WayofTime.bloodmagic.core.data.Binding) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) IBindable(WayofTime.bloodmagic.iface.IBindable) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException) ItemStack(net.minecraft.item.ItemStack)

Example 2 with PlayerNotFoundException

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");
    }
}
Also used : EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException)

Example 3 with PlayerNotFoundException

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");
        }
    }
}
Also used : SoulNetwork(WayofTime.bloodmagic.core.data.SoulNetwork) EntityPlayer(net.minecraft.entity.player.EntityPlayer) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException) TextComponentString(net.minecraft.util.text.TextComponentString) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 4 with PlayerNotFoundException

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"));
    }
}
Also used : ChunkProviderLands(com.mraof.minestuck.world.lands.gen.ChunkProviderLands) TextComponentTranslation(net.minecraft.util.text.TextComponentTranslation) ITextComponent(net.minecraft.util.text.ITextComponent) PlayerNotFoundException(net.minecraft.command.PlayerNotFoundException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) LandAspectRegistry(com.mraof.minestuck.world.lands.LandAspectRegistry)

Aggregations

PlayerNotFoundException (net.minecraft.command.PlayerNotFoundException)4 EntityPlayer (net.minecraft.entity.player.EntityPlayer)3 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)2 Binding (WayofTime.bloodmagic.core.data.Binding)1 SoulNetwork (WayofTime.bloodmagic.core.data.SoulNetwork)1 IBindable (WayofTime.bloodmagic.iface.IBindable)1 LandAspectRegistry (com.mraof.minestuck.world.lands.LandAspectRegistry)1 ChunkProviderLands (com.mraof.minestuck.world.lands.gen.ChunkProviderLands)1 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)1 ItemStack (net.minecraft.item.ItemStack)1 ITextComponent (net.minecraft.util.text.ITextComponent)1 TextComponentString (net.minecraft.util.text.TextComponentString)1