Java Code Examples for net.minecraft.command.ICommandSender#sendMessage()
The following examples show how to use
net.minecraft.command.ICommandSender#sendMessage() .
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: CommandSource.java From OpenModsLib with MIT License | 6 votes |
@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 2
Source File: GTCommandTeleport.java From GT-Classic with GNU Lesser General Public License v3.0 | 6 votes |
@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 3
Source File: CommandSignals.java From Signals with GNU General Public License v3.0 | 6 votes |
private boolean debug(MinecraftServer server, ICommandSender sender, String[] args){ World overworld = server.getWorld(0); if(args.length < 2) { sender.sendMessage(new TextComponentString("Trains loaded: " + RailNetworkManager.getServerInstance().getState().getTrainStream().filter(x -> !((MCTrain)x).getCarts().isEmpty()).count())); return true; } else { int z = Integer.parseInt(args[1]); for(int i = 0; i < 10000; i++) { EntityMinecartEmpty cart = new EntityMinecartEmpty(overworld, i, 64, z); cart.forceSpawn = true; boolean success = overworld.spawnEntity(cart); if(i % 1000 == 0) { sender.sendMessage(new TextComponentString("Spawned " + i + " / 100.000")); } } return true; } }
Example 4
Source File: CommandSignals.java From Signals with GNU General Public License v3.0 | 6 votes |
@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 5
Source File: CommandWorldgenReload.java From GregTech with GNU Lesser General Public License v3.0 | 5 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { try { WorldGenRegistry.INSTANCE.reinitializeRegisteredVeins(); sender.sendMessage(new TextComponentTranslation("gregtech.command.worldgen.reload.success") .setStyle(new Style().setColor(TextFormatting.GREEN))); } catch (IOException | RuntimeException exception) { GTLog.logger.error("Failed to reload worldgen config", exception); sender.sendMessage(new TextComponentTranslation("gregtech.command.worldgen.reload.failed") .setStyle(new Style().setColor(TextFormatting.RED))); } }
Example 6
Source File: HICommand.java From HoloInventory with MIT License | 5 votes |
private void showHelp(ICommandSender sender) { sender.sendMessage(new TextComponentString(HoloInventory.MODID).setStyle(new Style().setColor(TextFormatting.AQUA)).appendSibling(new TextComponentString(" by Dries007").setStyle(new Style().setColor(TextFormatting.WHITE)))); sender.sendMessage(new TextComponentString("This command depends on the context in which it is used.")); sender.sendMessage(new TextComponentString("On a server (OP only) it can be used to (un)ban a block type, server wide.")); sender.sendMessage(new TextComponentString("On a client (SSP) it can be used to (un)ban a block type, client side only.")); sender.sendMessage(new TextComponentString("Syntax:").setStyle(new Style().setUnderlined(true))); sender.sendMessage(new TextComponentString("/" + getName() + " <ban>")); sender.sendMessage(new TextComponentString(" Ban the next block you right click.")); sender.sendMessage(new TextComponentString("/" + getName() + " <unban> [name]")); sender.sendMessage(new TextComponentString(" Un ban the next block you right click, or specified via the name.")); sender.sendMessage(new TextComponentString("/" + getName() + " <list>")); sender.sendMessage(new TextComponentString(" Print a list of banned block types on the current side.")); }
Example 7
Source File: WorldCommand.java From AdvancedRocketry with MIT License | 5 votes |
private void printStarHelp(ICommandSender sender) { sender.sendMessage(new TextComponentString("star list")); sender.sendMessage(new TextComponentString("star get temp <star id>")); sender.sendMessage(new TextComponentString("star get planets <star id>")); sender.sendMessage(new TextComponentString("star get pos <star id>")); sender.sendMessage(new TextComponentString("star set temp <star id> <temperature>")); sender.sendMessage(new TextComponentString("star set pos <star id> <x> <y>")); sender.sendMessage(new TextComponentString("star generate <name> <temp> <x> <y>")); }
Example 8
Source File: CommandReloadConfig.java From ExNihiloAdscensio with MIT License | 5 votes |
@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 9
Source File: HICommand.java From HoloInventory with MIT License | 5 votes |
@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 10
Source File: CommandFindBiome.java From Traverse-Legacy-1-12-2 with MIT License | 5 votes |
@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 11
Source File: CommandFindBiome.java From CommunityMod with GNU Lesser General Public License v2.1 | 5 votes |
@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 12
Source File: PhysSettingsCommand.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { sender.sendMessage(new TextComponentString(DEPRECATION_MESSAGE)); }
Example 13
Source File: AirshipMapCommand.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { String term = args[0]; if (term.equals("tpto")) { StringBuilder shipName = new StringBuilder(args.length < 2 ? "" : args[1]); if (args.length > 2) { for (int i = 2; i < args.length; i++) { shipName.append(" ").append(args[i]); } } Entity player = sender.getCommandSenderEntity(); if (!(player instanceof EntityPlayer)) { return; } Optional<ShipData> shipDataOptional = ValkyrienUtils.getQueryableData(player.world) .getShipFromName(shipName.toString()); if (shipDataOptional.isPresent()) { ShipPositionData positionData = shipDataOptional.get().getPositionData(); double posX = positionData.getPosX(); double posY = positionData.getPosY(); double posZ = positionData.getPosZ(); // Time to teleport! if (player instanceof EntityPlayerMP) { EntityPlayerMP playerMP = (EntityPlayerMP) player; ((EntityPlayerMP) player).connection.setPlayerLocation(posX, posY, posZ, 0, 0); } } else { sender.sendMessage(new TextComponentString("That's not a valid ship!")); } } if (term.equals("help")) { sender.sendMessage(new TextComponentString("tpto")); } }
Example 14
Source File: VSConfigCommandBase.java From Valkyrien-Skies with Apache License 2.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) { args = VSCommandUtil.toProperArgs(args); ConfigCommandNode currentNode = root; for (int i = 0; i < args.length; i++) { if (currentNode instanceof ConfigCommandParentNode) { currentNode = ((ConfigCommandParentNode) currentNode).getChild(args[i]); } if (currentNode instanceof ConfigCommandEndNode && i < args.length - 1) { // setting the option ((ConfigCommandEndNode) currentNode).getOptionSetter().accept(args[i + 1]); try { sync.invoke(null); } catch (Exception e) { throw new RuntimeException(e); //blah blaah } sender.sendMessage(new TextComponentString("Set " + currentNode.getName() + " = " + ((ConfigCommandEndNode) currentNode).getOptionGetter().get().toString() )); break; } else if (currentNode instanceof ConfigCommandEndNode && i == args.length - 1) { // getting the option sender.sendMessage(new TextComponentString(currentNode.getName() + " = " + ((ConfigCommandEndNode) currentNode).getOptionGetter().get().toString() )); break; } else if (i == args.length - 1) { sender.sendMessage(new TextComponentString( "That is a subcategory, please specify additional fields")); } if (currentNode == null) { sender.sendMessage(new TextComponentString( String.format("Unrecognized option: %s", args[i]) )); } } }
Example 15
Source File: YouTubeChatMock.java From youtube-chat-for-minecraft with Apache License 2.0 | 4 votes |
private void showMessage(String message, ICommandSender sender) { sender.sendMessage(new TextComponentString(message)); }
Example 16
Source File: ChatService.java From youtube-chat-for-minecraft with Apache License 2.0 | 4 votes |
private void showMessage(String message, ICommandSender sender) { sender.sendMessage(new TextComponentString(message)); }
Example 17
Source File: PlatformCommand.java From YUNoMakeGoodMap with Apache License 2.0 | 4 votes |
@Override public void execute(MinecraftServer server, ICommandSender sender, String[] args) throws CommandException { if (args.length < 1) throw new WrongUsageException(getUsage(sender)); String cmd = args[0].toLowerCase(Locale.ENGLISH); if ("list".equals(cmd)) { sender.sendMessage(new TextComponentString("Known Platforms:")); for (ResourceLocation rl : getPlatforms()) { sender.sendMessage(new TextComponentString(" " + rl.toString())); } } else if ("spawn".equals(cmd) || "preview".equals(cmd)) { if (args.length < 2) throw new WrongUsageException(getUsage(sender)); Entity ent = sender.getCommandSenderEntity(); PlacementSettings settings = new PlacementSettings(); WorldServer world = (WorldServer)sender.getEntityWorld(); if (args.length >= 3) { //TODO: Preview doesnt quite work correctly with rotations.... String rot = args[2].toLowerCase(Locale.ENGLISH); if ("0".equals(rot) || "none".equals(rot)) settings.setRotation(Rotation.NONE); else if ("90".equals(rot)) settings.setRotation(Rotation.CLOCKWISE_90); else if ("180".equals(rot)) settings.setRotation(Rotation.CLOCKWISE_180); else if ("270".equals(rot)) settings.setRotation(Rotation.COUNTERCLOCKWISE_90); else throw new WrongUsageException("Only rotations none, 0, 90, 180, and 270 allowed."); } BlockPos pos; if (args.length >= 6) pos = CommandBase.parseBlockPos(sender, args, 3, false); else if (ent != null) pos = ent.getPosition(); else throw new WrongUsageException("Must specify a position if the command sender is not an entity"); Template temp = StructureUtil.loadTemplate(new ResourceLocation(args[1]), world, true); BlockPos spawn = StructureUtil.findSpawn(temp, settings); if (spawn != null) pos = pos.subtract(spawn); if ("spawn".equals(cmd)) { sender.sendMessage(new TextComponentString("Building \"" + args[1] +"\" 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! } else { BlockPos tpos = pos.down(); if (spawn != null) tpos = tpos.add(spawn); sender.sendMessage(new TextComponentString("Previewing \"" + args[1] +"\" at " + pos.toString())); world.setBlockState(tpos, Blocks.STRUCTURE_BLOCK.getDefaultState().withProperty(BlockStructure.MODE, TileEntityStructure.Mode.LOAD)); TileEntityStructure te = (TileEntityStructure)world.getTileEntity(tpos); if (spawn != null) te.setPosition(te.getPosition().subtract(spawn)); te.setSize(temp.getSize()); te.setMode(Mode.LOAD); te.markDirty(); } } else throw new WrongUsageException(getUsage(sender)); }
Example 18
Source File: CommandUtils.java From OpenModsLib with MIT License | 4 votes |
public static void respondText(ICommandSender sender, String message) { sender.sendMessage(new TextComponentString(message)); }
Example 19
Source File: CommandUtils.java From OpenModsLib with MIT License | 4 votes |
public static void respond(ICommandSender sender, String format, Object... args) { sender.sendMessage(new TextComponentTranslation(format, args)); }
Example 20
Source File: CommandCalcFactory.java From OpenModsLib with MIT License | 4 votes |
@Override public void execute(ICommandSender sender, IWhitespaceSplitter args) { sender.sendMessage(new TextComponentString(args.getTail())); }