Search in sources :

Example 71 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project Galacticraft by micdoodle8.

the class CommandGCKit method execute.

@Override
public void execute(MinecraftServer server, 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) {
                ItemHandlerHelper.giveItemToPlayer(playerBase, new ItemStack(GCItems.emergencyKit), 0);
                CommandBase.notifyCommandListener(sender, this, "commands.emergencykit", 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.getUsage(sender)), new Object[0]);
    }
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) CommandException(net.minecraft.command.CommandException) ItemStack(net.minecraft.item.ItemStack) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException)

Example 72 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project Galacticraft by micdoodle8.

the class CommandSpaceStationAddOwner method execute.

@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
    String var3 = null;
    EntityPlayerMP playerBase = null;
    if (args.length > 0) {
        var3 = args[0];
        try {
            playerBase = PlayerUtil.getPlayerBaseServerFromPlayerUsername(sender.getName(), true);
            if (playerBase != null) {
                GCPlayerStats stats = GCPlayerStats.get(playerBase);
                if (stats.getSpaceStationDimensionData().isEmpty()) {
                    throw new WrongUsageException(GCCoreUtil.translate("commands.ssinvite.not_found"), new Object[0]);
                } else {
                    for (Map.Entry<Integer, Integer> ownedStations : stats.getSpaceStationDimensionData().entrySet()) {
                        final SpaceStationWorldData data = SpaceStationWorldData.getStationData(playerBase.world, ownedStations.getValue(), playerBase);
                        if (var3.equalsIgnoreCase("+all")) {
                            data.setAllowedAll(true);
                            playerBase.sendMessage(new TextComponentString(GCCoreUtil.translateWithFormat("gui.spacestation.allow_all_true")));
                            return;
                        }
                        if (var3.equalsIgnoreCase("-all")) {
                            data.setAllowedAll(false);
                            playerBase.sendMessage(new TextComponentString(GCCoreUtil.translateWithFormat("gui.spacestation.allow_all_false", var3)));
                            return;
                        }
                        if (!data.getAllowedPlayers().contains(var3)) {
                            data.getAllowedPlayers().add(var3);
                            data.markDirty();
                        }
                    }
                }
                final EntityPlayerMP playerToAdd = PlayerUtil.getPlayerBaseServerFromPlayerUsername(var3, true);
                if (playerToAdd != null) {
                    playerToAdd.sendMessage(new TextComponentString(GCCoreUtil.translateWithFormat("gui.spacestation.added", PlayerUtil.getName(playerBase))));
                }
            }
        } catch (final Exception var6) {
            throw new CommandException(var6.getMessage(), new Object[0]);
        }
    } else {
        throw new WrongUsageException(GCCoreUtil.translateWithFormat("commands.ssinvite.wrong_usage", this.getUsage(sender)), new Object[0]);
    }
    if (playerBase != null) {
        playerBase.sendMessage(new TextComponentString(GCCoreUtil.translateWithFormat("gui.spacestation.addsuccess", var3)));
    }
}
Also used : SpaceStationWorldData(micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData) WrongUsageException(net.minecraft.command.WrongUsageException) GCPlayerStats(micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats) EntityPlayerMP(net.minecraft.entity.player.EntityPlayerMP) TextComponentString(net.minecraft.util.text.TextComponentString) CommandException(net.minecraft.command.CommandException) Map(java.util.Map) CommandException(net.minecraft.command.CommandException) WrongUsageException(net.minecraft.command.WrongUsageException) TextComponentString(net.minecraft.util.text.TextComponentString)

Example 73 with WrongUsageException

use of net.minecraft.command.WrongUsageException in project Wizardry by TeamWizardry.

the class CommandDebug method execute.

@Override
public void execute(@NotNull MinecraftServer server, @NotNull ICommandSender sender, @NotNull String[] args) throws WrongUsageException {
    if (args.length < 2)
        throw new WrongUsageException(getUsage(sender));
    ModuleInstance module = ModuleRegistry.INSTANCE.getModule(args[1]);
    if (module == null) {
        notifyCommandListener(sender, this, "wizardry.command." + getName() + ".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.getAttributeModifiers().isEmpty())
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Default AttributeRegistry");
    for (AttributeModifier attributeModifier : module.getAttributeModifiers()) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |  |_ " + TextFormatting.GRAY + attributeModifier.toString());
    ModuleInstanceModifier[] modifierList = module.applicableModifiers();
    if (modifierList != null) {
        notifyCommandListener(sender, this, TextFormatting.YELLOW + " |  |_ " + TextFormatting.GREEN + "Applicable Modifiers ");
        for (ModuleInstanceModifier modifier : modifierList) notifyCommandListener(sender, this, TextFormatting.YELLOW + " |     |_ " + TextFormatting.DARK_GREEN + modifier.getNBTKey());
    }
    notifyCommandListener(sender, this, TextFormatting.YELLOW + " |________________________________________________//");
}
Also used : WrongUsageException(net.minecraft.command.WrongUsageException) AttributeModifier(com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier) ModuleInstance(com.teamwizardry.wizardry.api.spell.module.ModuleInstance) ModuleInstanceModifier(com.teamwizardry.wizardry.api.spell.module.ModuleInstanceModifier)

Aggregations

WrongUsageException (net.minecraft.command.WrongUsageException)73 EntityPlayerMP (net.minecraft.entity.player.EntityPlayerMP)37 CommandException (net.minecraft.command.CommandException)30 EntityPlayer (net.minecraft.entity.player.EntityPlayer)21 GCPlayerStats (micdoodle8.mods.galacticraft.core.entities.player.GCPlayerStats)16 ItemStack (net.minecraft.item.ItemStack)13 BlockPos (net.minecraft.util.math.BlockPos)8 ChatComponentText (net.minecraft.util.ChatComponentText)7 TextComponentString (net.minecraft.util.text.TextComponentString)7 SpaceStationWorldData (micdoodle8.mods.galacticraft.core.dimension.SpaceStationWorldData)6 MinecraftServer (net.minecraft.server.MinecraftServer)5 PacketSimple (micdoodle8.mods.galacticraft.core.network.PacketSimple)4 Entity (net.minecraft.entity.Entity)4 TextComponentTranslation (net.minecraft.util.text.TextComponentTranslation)4 World (net.minecraft.world.World)4 WorldServer (net.minecraft.world.WorldServer)4 NBTTagCompound (net.minecraft.nbt.NBTTagCompound)3 Affinity (am2.api.spell.enums.Affinity)2 PlayerIdentifier (com.mraof.minestuck.util.IdentifierHandler.PlayerIdentifier)2 AttributeModifier (com.teamwizardry.wizardry.api.spell.attribute.AttributeModifier)2