net.minecraft.command.CommandException Java Examples

The following examples show how to use net.minecraft.command.CommandException. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CommandStat.java    From AgriCraft with MIT License 6 votes vote down vote up
private void getStat(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nonnull IAgriStat stat, @Nonnull String target) throws CommandException {
    switch (target) {
        case "id":
            MessageUtil.messagePlayer(player, "ID: {0}", stat.getId());
            break;
        case "growth":
            MessageUtil.messagePlayer(player, "Growth: {0}", stat.getGrowth());
            break;
        case "gain":
            MessageUtil.messagePlayer(player, "Gain: {0}", stat.getGrowth());
            break;
        case "strength":
            MessageUtil.messagePlayer(player, "Strength: {0}", stat.getGrowth());
            break;
        case "all":
            MessageUtil.messagePlayer(player, "ID: {0}", stat.getId());
            MessageUtil.messagePlayer(player, "Growth: {0}", stat.getGrowth());
            MessageUtil.messagePlayer(player, "Gain: {0}", stat.getGain());
            MessageUtil.messagePlayer(player, "Strength: {0}", stat.getStrength());
            break;
        default:
            throw new CommandException("Invalid target: \"%s\"!", target);
    }
}
 
Example #2
Source File: CommandSource.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if (args.length < 1) throw new SyntaxErrorException();

	final String subCommand = args[0];

	if (subCommand.equals(COMMAND_CLASS)) {
		if (args.length < 2) throw new SyntaxErrorException();
		final String clsName = args[1];
		final ClassMeta meta = getMeta(clsName);

		sender.sendMessage(new TextComponentTranslation("openmodslib.command.class_source", meta.cls.getName(), meta.source()));

		final ApiInfo api = meta.api;
		if (api != null) {
			sender.sendMessage(new TextComponentTranslation("openmodslib.command.api_class",
					api.api, api.owner, api.version));
		}

		for (Map.Entry<File, Set<String>> e : meta.providerMods.entrySet())
			sender.sendMessage(new TextComponentTranslation("openmodslib.command.class_provider",
					e.getKey().getAbsolutePath(),
					Joiner.on(',').join(e.getValue())));
	}
}
 
Example #3
Source File: CommandSignals.java    From Signals with GNU General Public License v3.0 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException{
    if(args.length == 0) throw new WrongUsageException("command.signals.noArgs");
    String subCommand = args[0];
    if(subCommand.equals("rebuildNetwork")) {
        RailNetworkManager.getServerInstance().rebuildNetwork();
        sender.sendMessage(new TextComponentTranslation("command.signals.networkCleared"));
    } else if(subCommand.equals("debug") && sender.getName().startsWith("Player" /* Playerx */)) {
        if(debug(server, sender, args)) {
            sender.sendMessage(new TextComponentString("DEBUG EXECUTED"));
        } else {
            sender.sendMessage(new TextComponentString("Could not execute debug!"));
        }
    } else {
        throw new WrongUsageException("command.signals.invalidSubCommand", subCommand);
    }
}
 
Example #4
Source File: CommandLevelTool.java    From TinkersToolLeveling with MIT License 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
  EntityPlayer player = getCommandSenderAsPlayer(sender);
  ItemStack itemStack = player.getHeldItemMainhand();

  if(itemStack != null && itemStack.getItem() instanceof ToolCore) {
    int xp;
    if(args.length > 0) {
      xp = parseInt(args[0]);
    }
    else {
      ToolLevelNBT data = new ToolLevelNBT(TinkerUtil.getModifierTag(itemStack, TinkerToolLeveling.modToolLeveling.getModifierIdentifier()));
      xp = TinkerToolLeveling.modToolLeveling.getXpForLevelup(data.level, itemStack);
    }
    TinkerToolLeveling.modToolLeveling.addXp(itemStack, xp, player);
  }
  else {
    throw new CommandException("No tinker tool in hand");
  }
}
 
Example #5
Source File: CommandGlDebug.java    From OpenModsLib with MIT License 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if (args.length != 1) throw new CommandException("commands.generic.syntax");
	final String arg = args[0].toLowerCase(Locale.ROOT);
	if (arg.equals("disable")) {
		GL11.glDisable(KHRDebug.GL_DEBUG_OUTPUT);
	} else {
		final Set<Integer> allowedLevels = ALLOWED_LEVELS.get(arg);
		if (allowedLevels == null) throw new CommandException("commands.generic.syntax");

		GL11.glEnable(KHRDebug.GL_DEBUG_OUTPUT);
		for (int level : ALL_LEVELS) {
			final boolean isEnabled = allowedLevels.contains(level);
			KHRDebug.glDebugMessageControl(GL11.GL_DONT_CARE, GL11.GL_DONT_CARE, level, null, isEnabled);
		}
		KHRDebug.glDebugMessageCallback(new KHRDebugCallback());
	}

}
 
Example #6
Source File: YouTubeChatMock.java    From youtube-chat-for-minecraft with Apache License 2.0 6 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args)
    throws CommandException {
  StringBuilder builder = new StringBuilder();
  if (args.length < 2) {
    showMessage(getUsage(sender), sender);
    return;
  }

  String author = args[0];
  for (int i = 1; i < args.length; i++) {
    if (i > 1) {
      builder.append(" ");
    }
    builder.append(args[i]);
  }
  String message = builder.toString();
  System.out.println(String.format("YouTubeChatMock received %1$s from %2$s", message, author));
  LiveChatMessageAuthorDetails authorDetails = new LiveChatMessageAuthorDetails();
  authorDetails.setDisplayName(author);
  authorDetails.setChannelId(author);
  ((ChatService) YouTubeChat.getService()).broadcastMessage(
      authorDetails, new LiveChatSuperChatDetails(), message);
}
 
Example #7
Source File: GTCommandTeleport.java    From GT-Classic with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public void execute(@Nonnull MinecraftServer server, @Nonnull ICommandSender sender, @Nonnull String[] args)
		throws CommandException {
	if (!IC2.platform.isOp(sender.getCommandSenderEntity().getUniqueID())) {
		sender.sendMessage(new TextComponentString(TextFormatting.RED
				+ "You do not have permission to use this command"));
		return;
	}
	if (args.length < 1) {
		return;
	}
	String s = args[0];
	int dim;
	try {
		dim = Integer.parseInt(s);
	} catch (NumberFormatException e) {
		sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error parsing dimension!"));
		return;
	}
	if (sender instanceof EntityPlayer) {
		GTCommandTeleporter.teleportToDimension((EntityPlayer) sender, dim, 0, 100, 0);
	}
}
 
Example #8
Source File: CommandStat.java    From AgriCraft with MIT License 6 votes vote down vote up
private void setStat(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nonnull IAgriStat stat, @Nonnull String target, @Nonnull int value) throws CommandException {
    switch (target) {
        case "growth":
            MessageUtil.messagePlayer(player, "Growth: {0} -> {1}", stat.getGrowth(), value);
            stat.withGrowth(value);
            break;
        case "gain":
            MessageUtil.messagePlayer(player, "Gain: {0} -> {1}", stat.getGain(), value);
            stat.withGain(value);
            break;
        case "strength":
            MessageUtil.messagePlayer(player, "Strength: {0} -> {1}", stat.getStrength(), value);
            stat.withStrength(value);
            break;
        case "all":
            MessageUtil.messagePlayer(player, "Growth: {0} -> {1}", stat.getGrowth(), value);
            stat.withGrowth(value);
            MessageUtil.messagePlayer(player, "Gain: {0} -> {1}", stat.getGain(), value);
            stat.withGain(value);
            MessageUtil.messagePlayer(player, "Strength: {0} -> {1}", stat.getStrength(), value);
            stat.withStrength(value);
            break;
        default:
            throw new CommandException("Invalid target: \"{0}\"!", target);
    }
}
 
Example #9
Source File: CounterCommand.java    From fabric-carpet with MIT License 6 votes vote down vote up
private static int resetCounter(ServerCommandSource source, String color)
{
    if (color == null)
    {
        HopperCounter.resetAll(source.getMinecraftServer());
        Messenger.m(source, "w Restarted all counters");
    }
    else
    {
        HopperCounter counter = HopperCounter.getCounter(color);
        if (counter == null) throw new CommandException(Messenger.s("Unknown wool color"));
        counter.reset(source.getMinecraftServer());
        Messenger.m(source, "w Restarted "+color+" counter");
    }
    return 1;
}
 
Example #10
Source File: CommandNbt.java    From AgriCraft with MIT License 5 votes vote down vote up
private void listNbt(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nonnull NBTTagCompound tag) throws CommandException {
    for (String key : tag.getKeySet()) {
        final NBTBase entry = tag.getTag(key);
        final String type = NBTBase.NBT_TYPES[entry.getId()];
        MessageUtil.messagePlayer(player, "`l`3{0}`r `b{1}`r: `2{2}`r", type, key, entry);
    }
}
 
Example #11
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.world.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #12
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.worldObj.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #13
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.worldObj.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #14
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.world.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #15
Source File: CommandNbt.java    From AgriCraft with MIT License 5 votes vote down vote up
private void getNbt(@Nonnull EntityPlayer player, @Nonnull ItemStack stack, @Nonnull NBTTagCompound tag, @Nonnull String key) throws CommandException {
    if (tag.hasKey(key)) {
        final NBTBase entry = tag.getTag(key);
        final String type = NBTBase.NBT_TYPES[entry.getId()];
        MessageUtil.messagePlayer(player, "`l`3{0}`r `b{1}`r: `2{2}`r", type, key, entry);
    } else {
        throw new CommandException("Active player stack does not have NBT tag: \"%s\"!", key);
    }
}
 
Example #16
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void processCommand(ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.worldObj.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #17
Source File: ForgeCommand.java    From FastAsyncWorldedit with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer minecraftServer, ICommandSender sender, String[] args) throws CommandException {
    if ((sender instanceof EntityPlayerMP)) {
        EntityPlayerMP player = (EntityPlayerMP) sender;
        if (player.worldObj.isRemote) {
            return;
        }
        FawePlayer<Object> fp = FawePlayer.wrap(player);
        cmd.executeSafe(fp, args);
    }
}
 
Example #18
Source File: CommandBaseAdv.java    From LookingGlass with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Returns the given ICommandSender as a EntityPlayer or throw an exception.
 */
public static TileEntity getCommandSenderAsTileEntity(ICommandSender sender) {
	try {
		World world = sender.getEntityWorld();
		ChunkCoordinates coords = sender.getPlayerCoordinates();
		return world.getTileEntity(coords.posX, coords.posY, coords.posZ);
	} catch (Exception e) {
		throw new CommandException("Could not get tile entity");
	}
}
 
Example #19
Source File: NewSpawnPlatformCommand.java    From YUNoMakeGoodMap with Apache License 2.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (args.length != 2)
        throw new WrongUsageException(getUsage(sender));

    EntityPlayer player = getPlayer(server, sender, args[1]);

    if (player != null)
    {
        PlacementSettings settings = new PlacementSettings();
        WorldServer world = (WorldServer) sender.getEntityWorld();

        int platformNumber = SpawnPlatformSavedData.get(world).addAndGetPlatformNumber();
        BlockPos pos = getPositionOfPlatform(world, platformNumber);

        Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[0]), world, true);
        BlockPos spawn = StructureUtil.findSpawn(temp, settings);
        spawn = spawn == null ? pos : spawn.add(pos);

        sender.sendMessage(new TextComponentString("Building \"" + args[0] + "\" at " + pos.toString()));
        temp.addBlocksToWorld(world, pos, settings, 2); //Push to world, with no neighbor notifications!
        world.getPendingBlockUpdates(new StructureBoundingBox(pos, pos.add(temp.getSize())), true); //Remove block updates, so that sand doesn't fall!

        if (player instanceof EntityPlayerMP) {
            ((EntityPlayerMP) player).setPositionAndUpdate(spawn.getX() + 0.5, spawn.getY() + 1.6, spawn.getZ() + 0.5);
        }

        player.setSpawnChunk(spawn, true, world.provider.getDimension());
    }
    else
    {
        throw new WrongUsageException(getUsage(sender));
    }
}
 
Example #20
Source File: CommandReloadConfig.java    From ExNihiloAdscensio with MIT License 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    ExNihiloAdscensio.loadConfigs();
    Config.doNormalConfig(new File(ExNihiloAdscensio.configDirectory, "ExNihiloAdscensio.cfg"));
    sender.sendMessage(new TextComponentTranslation("commands.enreloadconfig.confirm"));
}
 
Example #21
Source File: CommandClearCyberware.java    From Cyberware with MIT License 5 votes vote down vote up
/**
 * Callback for when the command is executed
 */
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
	EntityPlayerMP entityplayermp = args.length == 0 ? getCommandSenderAsPlayer(sender) : getPlayer(server, sender, args[0]);
	NBTTagCompound nbttagcompound = null;

	CyberwareAPI.getCapability(entityplayermp).resetWare(entityplayermp);
	CyberwareAPI.updateData(entityplayermp);
	
	notifyCommandListener(sender, this, "cyberware.commands.clearCyberware.success", new Object[] {entityplayermp.getName()});
}
 
Example #22
Source File: CounterCommand.java    From fabric-carpet with MIT License 5 votes vote down vote up
private static int displayCounter(ServerCommandSource source, String color, boolean realtime)
{
    HopperCounter counter = HopperCounter.getCounter(color);
    if (counter == null) throw new CommandException(Messenger.s("Unknown wool color: "+color));

    for (BaseText message: counter.format(source.getMinecraftServer(), realtime, false))
    {
        source.sendFeedback(message, false);
    }
    return 1;
}
 
Example #23
Source File: CommandFindBiome.java    From CommunityMod with GNU Lesser General Public License v2.1 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	Biome biome = null;
	if (args.length == 0) {
		sender.sendMessage(new TextComponentString("No biome specified"));
		return;
	}
	for (Biome b : ForgeRegistries.BIOMES.getValues()) {
		String name = b.getRegistryName().toString().replaceAll(" ", "_").toLowerCase();
		if (args[0].equalsIgnoreCase(name)) {
			biome = b;
		}
	}
	if (biome == null) {
		sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' cannot be found!"));
		return;
	}
	long start = System.currentTimeMillis();
	final Biome finalBiome = biome;
	new Thread(() -> {
		BlockPos pos = spiralOutwardsLookingForBiome(sender, sender.getEntityWorld(), finalBiome, sender.getPosition().getX(), sender.getPosition().getZ(), TraverseConfig.findBiomeCommandTimeout);
		if (pos == null) {
			server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' could not be found after " + TextFormatting.GRAY + TraverseConfig.findBiomeCommandTimeout + "ms" + TextFormatting.RED + ".")));
			return;
		}
		if (sender instanceof EntityPlayerMP) {
			server.addScheduledTask(() -> {
				EntityPlayerMP playerMP = (EntityPlayerMP) sender;
				playerMP.connection.setPlayerLocation(pos.getX(), 150, pos.getZ(), 0, 0);
				sender.sendMessage(new TextComponentString(TextFormatting.WHITE + "Found '" + finalBiome.getRegistryName().toString() + "' Biome! " + TextFormatting.GRAY + "(" + (System.currentTimeMillis() - start) + "ms)"));
			});
			return;
		}
		server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! An unknown error occurred.")));
	}, "Biome Finder - Traverse").start();
}
 
Example #24
Source File: VanillaCommandWrapper.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
    if (!testPermission(sender)) return true;

    ICommandSender icommandlistener = getListener(sender);
    try {
        dispatchVanillaCommand(sender, icommandlistener, args);
    } catch (CommandException commandexception) {
        // Taken from CommandHandler
        TextComponentTranslation chatmessage = new TextComponentTranslation(commandexception.getMessage(), commandexception.getErrorObjects());
        chatmessage.getStyle().setColor(TextFormatting.RED);
        icommandlistener.sendMessage(chatmessage);
    }
    return true;
}
 
Example #25
Source File: VanillaCommandWrapper.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
private int getPlayerListSize(String as[]) throws CommandException {
    for (int i = 0; i < as.length; i++) {
        if (vanillaCommand.isUsernameIndex(as, i) && EntitySelector.matchesMultiplePlayersDefault(as[i])) {
            return i;
        }
    }
    return -1;
}
 
Example #26
Source File: CommandWrapper.java    From Kettle with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender iCommandSender, String[] args) throws CommandException {
    try {
        this.command.execute(sender, name, args);
    } catch (Exception e) {
        throw new CommandException(e.getMessage());
    }
}
 
Example #27
Source File: HICommand.java    From HoloInventory with MIT License 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException
{
    if (isOP(sender)) throw new CommandException(getUsage(sender));
    else if (args.length == 0 || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("h") || args[0].equalsIgnoreCase("?"))  showHelp(sender);
    else if (args[0].equalsIgnoreCase("ban"))
    {
        ServerEventHandler.catchNext = ServerEventHandler.Type.BAN;
        sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA)));
    }
    else if (args[0].equalsIgnoreCase("unban"))
    {
        if (args.length == 1)
        {
            ServerEventHandler.catchNext = ServerEventHandler.Type.UNBAN;
            sender.sendMessage(new TextComponentString("Right click a block.").setStyle(new Style().setColor(TextFormatting.AQUA)));
        }
        else
        {
            boolean wasBanned = Helper.banned.remove(args[1]);
            if (wasBanned)
                sender.sendMessage(new TextComponentString("Unbanned " + args[1]).setStyle(new Style().setColor(TextFormatting.GREEN)));
            else
                sender.sendMessage(new TextComponentString(args[1] + " is not banned.").setStyle(new Style().setColor(TextFormatting.RED)));
        }
    }
    else if (args[0].equalsIgnoreCase("list"))
    {
        sender.sendMessage(new TextComponentString(HoloInventory.MODID.concat(" banlist:")).setStyle(new Style().setColor(TextFormatting.AQUA)));
        for (String type : Helper.banned)
        {
            sender.sendMessage(new TextComponentString(type));
        }
    }
    else throw new WrongUsageException(getUsage(sender));
}
 
Example #28
Source File: CommandFindBiome.java    From Traverse-Legacy-1-12-2 with MIT License 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	Biome biome = null;
	if (args.length == 0) {
		sender.sendMessage(new TextComponentString("No biome specified"));
		return;
	}
	for (Biome b : ForgeRegistries.BIOMES.getValues()) {
		String name = b.getRegistryName().toString().replaceAll(" ", "_").toLowerCase();
		if (args[0].equalsIgnoreCase(name)) {
			biome = b;
		}
	}
	if (biome == null) {
		sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' cannot be found!"));
		return;
	}
	long start = System.currentTimeMillis();
	final Biome finalBiome = biome;
	new Thread(() -> {
		BlockPos pos = spiralOutwardsLookingForBiome(sender, sender.getEntityWorld(), finalBiome, sender.getPosition().getX(), sender.getPosition().getZ(), TraverseConfig.findBiomeCommandTimeout);
		if (pos == null) {
			server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! Biome '" + args[0] + "' could not be found after " + TextFormatting.GRAY + TraverseConfig.findBiomeCommandTimeout + "ms" + TextFormatting.RED + ".")));
			return;
		}
		if (sender instanceof EntityPlayerMP) {
			server.addScheduledTask(() -> {
				EntityPlayerMP playerMP = (EntityPlayerMP) sender;
				playerMP.connection.setPlayerLocation(pos.getX(), 150, pos.getZ(), 0, 0);
				sender.sendMessage(new TextComponentString(TextFormatting.WHITE + "Found '" + finalBiome.getRegistryName().toString() + "' Biome! " + TextFormatting.GRAY + "(" + (System.currentTimeMillis() - start) + "ms)"));
			});
			return;
		}
		server.addScheduledTask(() -> sender.sendMessage(new TextComponentString(TextFormatting.RED + "Error! An unknown error occurred.")));
	}, "Biome Finder - Traverse").start();
}
 
Example #29
Source File: CommandGenCape.java    From Wizardry with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {
	if(sender instanceof EntityPlayer) {
		ItemStack cape = new ItemStack(ModItems.CAPE);
		NBTHelper.setInt(cape, "maxTick", 1000000);
		((EntityPlayer)sender).inventory.addItemStackToInventory(cape);
	} else {
		notifyCommandListener(sender, this, "wizardry.command.notplayer");
	}
}
 
Example #30
Source File: ToroQuestCommand.java    From ToroQuest with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException {

	if (!(sender instanceof EntityPlayer)) {
		return;
	}

	EntityPlayer player = (EntityPlayer) sender;

	if (args.length < 1) {
		throw new WrongUsageException("commands.tq.usage", new Object[0]);
	}

	String command = args[0];

	System.out.println("command " + command);

	if ("rep".equals(command)) {
		adjustRep(server, player, args);
	} else if ("list".equals(command)) {
		listCommand(player, args);
	} else if ("gen".equals(command)) {
		genCommand(player, args);
	} else if ("gui".equals(command)) {
		guiCommand(player, args);
	} else if ("quest".equals(command)) {
		questCommand(player, args);
	} else if ("book".equals(command)) {
		bookCommand(player, args);
	} else {
		throw new WrongUsageException("commands.tq.usage", new Object[0]);
	}
}