@Override public String getCommandUsage(ICommandSender sender) { ChatComponentText chatcomponenttranslation1 = new ChatComponentText("creeperhostserver.command.pregen.usage1"); chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.RED); sender.addChatMessage(chatcomponenttranslation1); ChatComponentText chatcomponenttranslation2 = new ChatComponentText("creeperhostserver.command.pregen.usage2"); chatcomponenttranslation2.getChatStyle().setColor(EnumChatFormatting.RED); sender.addChatMessage(chatcomponenttranslation2); ChatComponentText chatcomponenttranslation3 = new ChatComponentText("creeperhostserver.command.pregen.usage3"); chatcomponenttranslation3.getChatStyle().setColor(EnumChatFormatting.RED); sender.addChatMessage(chatcomponenttranslation3); ChatComponentText chatcomponenttranslation4 = new ChatComponentText("creeperhostserver.command.pregen.usage4"); chatcomponenttranslation4.getChatStyle().setColor(EnumChatFormatting.RED); sender.addChatMessage(chatcomponenttranslation4); return "creeperhostserver.command.pregen.usage5"; }
public static void tellOwnerAboutAmmo(Entity_AA turret, boolean secondRail) { // Is empty, so telling the owner about this EntityPlayer owner = turret.worldObj.getPlayerEntityByName(turret.ownerName); if (owner == null) { return; } // Might not be online right now // My name String turretName = "[ARMS ASSISTANT " + turret.getEntityId() + "]"; if (turret.getCustomNameTag() != null && !turret.getCustomNameTag().isEmpty()) { turretName = "[" + turret.getCustomNameTag() + "]"; } if (secondRail) { owner.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + turretName + ": Second rail is out of ammunition.")); } else { owner.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + turretName + ": First rail is out of ammunition.")); } }
/** * Updates a specified sign with the specified text lines */ public void handleUpdateSign(S33PacketUpdateSign packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.gameController); boolean flag = false; if (this.gameController.theWorld.isBlockLoaded(packetIn.getPos())) { TileEntity tileentity = this.gameController.theWorld.getTileEntity(packetIn.getPos()); if (tileentity instanceof TileEntitySign) { TileEntitySign tileentitysign = (TileEntitySign) tileentity; if (tileentitysign.getIsEditable()) { System.arraycopy(packetIn.getLines(), 0, tileentitysign.signText, 0, 4); tileentitysign.markDirty(); } flag = true; } } if (!flag && this.gameController.thePlayer != null) { this.gameController.thePlayer.addChatMessage(new ChatComponentText("Unable to locate sign at " + packetIn.getPos().getX() + ", " + packetIn.getPos().getY() + ", " + packetIn.getPos().getZ())); } }
/** * Get the formatted ChatComponent that will be used for the sender's username in chat */ public IChatComponent getDisplayName() { if (this.hasCustomName()) { ChatComponentText chatcomponenttext = new ChatComponentText(this.entityName); chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent()); chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString()); return chatcomponenttext; } else { ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation(this.getName(), new Object[0]); chatcomponenttranslation.getChatStyle().setChatHoverEvent(this.getHoverEvent()); chatcomponenttranslation.getChatStyle().setInsertion(this.getUniqueID().toString()); return chatcomponenttranslation; } }
public void removeAll() { synchronized (this.connections) { Iterator<NetworkManager> iterator = this.connections.iterator(); while (iterator.hasNext()) { NetworkManager networkmanager = (NetworkManager)iterator.next(); if (networkmanager.isChannelOpen()) { iterator.remove(); networkmanager.closeChannel(new ChatComponentText("Cancelled")); } } } }
public void checkDisconnected() { if (this.channel != null && !this.channel.isOpen()) { if (!this.disconnected) { this.disconnected = true; if (this.getExitMessage() != null) { this.getNetHandler().onDisconnect(this.getExitMessage()); } else if (this.getNetHandler() != null) { this.getNetHandler().onDisconnect(new ChatComponentText("Disconnected")); } } else { logger.warn("handleDisconnection() called twice"); } } }
public void clearPendingNetworks() { synchronized (this.pingDestinations) { Iterator<NetworkManager> iterator = this.pingDestinations.iterator(); while (iterator.hasNext()) { NetworkManager networkmanager = (NetworkManager)iterator.next(); if (networkmanager.isChannelOpen()) { iterator.remove(); networkmanager.closeChannel(new ChatComponentText("Cancelled")); } } } }
/** * Get a ChatComponent for this Item's display name that shows this Item on hover */ public IChatComponent getChatComponent() { ChatComponentText chatcomponenttext = new ChatComponentText(this.getDisplayName()); if (this.hasDisplayName()) { chatcomponenttext.getChatStyle().setItalic(Boolean.valueOf(true)); } IChatComponent ichatcomponent = (new ChatComponentText("[")).appendSibling(chatcomponenttext).appendText("]"); if (this.item != null) { NBTTagCompound nbttagcompound = new NBTTagCompound(); this.writeToNBT(nbttagcompound); ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_ITEM, new ChatComponentText(nbttagcompound.toString()))); ichatcomponent.getChatStyle().setColor(this.getRarity().rarityColor); } return ichatcomponent; }
public static IChatComponent join(List<IChatComponent> components) { IChatComponent ichatcomponent = new ChatComponentText(""); for (int i = 0; i < components.size(); ++i) { if (i > 0) { if (i == components.size() - 1) { ichatcomponent.appendText(" and "); } else if (i > 0) { ichatcomponent.appendText(", "); } } ichatcomponent.appendSibling((IChatComponent)components.get(i)); } return ichatcomponent; }
public IChatComponent getFormattedChatText() { String text = StatCollector.translateToLocal("neiLotr.versionChecker.notification.chat"); String[] parts = text.split("7"); String text1 = parts[0]; String text2 = parts[1]; String text3 = parts[2]; String text4 = parts[3]; ChatComponentText chat1 = (ChatComponentText) new ChatComponentText("[NEI LOTR]: ") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.GREEN)); ChatComponentText chat2 = (ChatComponentText) new ChatComponentText(text1 + " ") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE)); ChatComponentText chat3 = (ChatComponentText) new ChatComponentText(text2) .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.BLUE).setUnderlined(true) .setChatClickEvent( new ClickEvent(Action.OPEN_URL, "https://goo.gl/EkxFlC")) .setChatHoverEvent( new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT, new ChatComponentText(StatCollector .translateToLocal("neiLotr.versionChecker.notification.changelog") .replace("/", "\n"))))); ChatComponentText chat4 = (ChatComponentText) new ChatComponentText(" " + text3 + " ") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE)); ChatComponentText chat5 = (ChatComponentText) new ChatComponentText(state.toString() + " " + version) .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.YELLOW).setUnderlined(true) .setChatClickEvent( new ClickEvent(Action.OPEN_URL, url)) .setChatHoverEvent( new HoverEvent(net.minecraft.event.HoverEvent.Action.SHOW_TEXT, new ChatComponentText(StatCollector .translateToLocal("neiLotr.versionChecker.notification.newVersion") .replace("/", "\n"))))); ChatComponentText chat6 = (ChatComponentText) new ChatComponentText(" " + text4 + " ") .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE)); ChatComponentText chat7 = (ChatComponentText) new ChatComponentText(mcVersion) .setChatStyle(new ChatStyle().setColor(EnumChatFormatting.WHITE)); return chat1.appendSibling(chat2).appendSibling(chat3).appendSibling(chat4).appendSibling(chat5) .appendSibling(chat6).appendSibling(chat7); }
@Override protected void actionPerformed(GuiButton button) { if (button.id == 0) { if (captiveConnecting != null) { if (lastNetworkManager != null) { lastNetworkManager.closeChannel(new ChatComponentText("Aborted")); } try { if (cancelField == null) { cancelField = ReflectionHelper.findField(GuiConnecting.class, "field_146373_h", "cancel"); } cancelField.set(captiveConnecting, true); } catch (Throwable e) { } } } super.actionPerformed(button); }
protected HoverEvent getHoverEvent() { NBTTagCompound nbttagcompound = new NBTTagCompound(); String s = EntityList.getEntityString(this); nbttagcompound.setString("id", this.getUniqueID().toString()); if (s != null) { nbttagcompound.setString("type", s); } nbttagcompound.setString("name", this.getName()); return new HoverEvent(HoverEvent.Action.SHOW_ENTITY, new ChatComponentText(nbttagcompound.toString())); }
public String func_175355_a(EnumDifficulty p_175355_1_) { IChatComponent ichatcomponent = new ChatComponentText(""); ichatcomponent.appendSibling(new ChatComponentTranslation("options.difficulty", new Object[0])); ichatcomponent.appendText(": "); ichatcomponent.appendSibling(new ChatComponentTranslation(p_175355_1_.getDifficultyResourceKey(), new Object[0])); return ichatcomponent.getFormattedText(); }
public void processUpdateSign(C12PacketUpdateSign packetIn) { PacketThreadUtil.checkThreadAndEnqueue(packetIn, this, this.playerEntity.getServerForPlayer()); this.playerEntity.markPlayerActive(); WorldServer worldserver = this.serverController.worldServerForDimension(this.playerEntity.dimension); BlockPos blockpos = packetIn.getPosition(); if (worldserver.isBlockLoaded(blockpos)) { TileEntity tileentity = worldserver.getTileEntity(blockpos); if (!(tileentity instanceof TileEntitySign)) { return; } TileEntitySign tileentitysign = (TileEntitySign)tileentity; if (!tileentitysign.getIsEditable() || tileentitysign.getPlayer() != this.playerEntity) { this.serverController.logWarning("Player " + this.playerEntity.getName() + " just tried to change non-editable sign"); return; } IChatComponent[] aichatcomponent = packetIn.getLines(); for (int i = 0; i < aichatcomponent.length; ++i) { tileentitysign.signText[i] = new ChatComponentText(EnumChatFormatting.getTextWithoutFormattingCodes(aichatcomponent[i].getUnformattedText())); } tileentitysign.markDirty(); worldserver.markBlockForUpdate(blockpos); } }
/** * Callback when the command is invoked */ public void processCommand(ICommandSender sender, String[] args) throws CommandException { int i = MinecraftServer.getServer().getCurrentPlayerCount(); sender.addChatMessage(new ChatComponentTranslation("commands.players.list", new Object[] {Integer.valueOf(i), Integer.valueOf(MinecraftServer.getServer().getMaxPlayers())})); sender.addChatMessage(new ChatComponentText(MinecraftServer.getServer().getConfigurationManager().func_181058_b(args.length > 0 && "uuids".equalsIgnoreCase(args[0])))); sender.setCommandStat(CommandResultStats.Type.QUERY_RESULT, i); }
public static IChatComponent getChatComponentFromNthArg(ICommandSender sender, String[] args, int index, boolean p_147176_3_) throws PlayerNotFoundException { IChatComponent ichatcomponent = new ChatComponentText(""); for (int i = index; i < args.length; ++i) { if (i > index) { ichatcomponent.appendText(" "); } IChatComponent ichatcomponent1 = new ChatComponentText(args[i]); if (p_147176_3_) { IChatComponent ichatcomponent2 = PlayerSelector.matchEntitiesToChatComponent(sender, args[i]); if (ichatcomponent2 == null) { if (PlayerSelector.hasArguments(args[i])) { throw new PlayerNotFoundException(); } } else { ichatcomponent1 = ichatcomponent2; } } ichatcomponent.appendSibling(ichatcomponent1); } return ichatcomponent; }
public void func_180605_a(String p_180605_1_, ChatRawMessage[] p_180605_2_) { for (ChatRawMessage chatrawmessage : p_180605_2_) { this.func_176027_a(chatrawmessage.userName, chatrawmessage); if (this.func_176028_a(chatrawmessage.modes, chatrawmessage.subscriptions, this.mc.gameSettings.streamChatUserFilter)) { IChatComponent ichatcomponent = new ChatComponentText(chatrawmessage.userName); IChatComponent ichatcomponent1 = new ChatComponentTranslation("chat.stream." + (chatrawmessage.action ? "emote" : "text"), new Object[] {this.twitchComponent, ichatcomponent, EnumChatFormatting.getTextWithoutFormattingCodes(chatrawmessage.message)}); if (chatrawmessage.action) { ichatcomponent1.getChatStyle().setItalic(Boolean.valueOf(true)); } IChatComponent ichatcomponent2 = new ChatComponentText(""); ichatcomponent2.appendSibling(new ChatComponentTranslation("stream.userinfo.chatTooltip", new Object[0])); for (IChatComponent ichatcomponent3 : GuiTwitchUserMode.func_152328_a(chatrawmessage.modes, chatrawmessage.subscriptions, (IStream)null)) { ichatcomponent2.appendText("\n"); ichatcomponent2.appendSibling(ichatcomponent3); } ichatcomponent.getChatStyle().setChatHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, ichatcomponent2)); ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.TWITCH_USER_INFO, chatrawmessage.userName)); this.mc.ingameGUI.getChatGUI().printChatMessage(ichatcomponent1); } } }
/** * Send a chat message to the CommandSender */ public void addChatMessage(IChatComponent component) { if (this.trackOutput && this.getEntityWorld() != null && !this.getEntityWorld().isRemote) { this.lastOutput = (new ChatComponentText("[" + timestampFormat.format(new Date()) + "] ")).appendSibling(component); this.updateCommand(); } }
public GuiTwitchUserMode(IStream streamIn, ChatUserInfo p_i1064_2_) { this.stream = streamIn; this.field_152337_h = p_i1064_2_; this.field_152338_i = new ChatComponentText(p_i1064_2_.displayName); this.field_152332_r.addAll(func_152328_a(p_i1064_2_.modes, p_i1064_2_.subscriptions, streamIn)); }
/** * There are two recognized intentions for initiating a handshake: logging in and acquiring server status. The * NetworkManager's protocol will be reconfigured according to the specified intention, although a login-intention * must pass a versioncheck or receive a disconnect otherwise */ public void processHandshake(C00Handshake packetIn) { switch (packetIn.getRequestedState()) { case LOGIN: this.networkManager.setConnectionState(EnumConnectionState.LOGIN); if (packetIn.getProtocolVersion() > 47) { ChatComponentText chatcomponenttext = new ChatComponentText("Outdated server! I\'m still on 1.8.8"); this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext)); this.networkManager.closeChannel(chatcomponenttext); } else if (packetIn.getProtocolVersion() < 47) { ChatComponentText chatcomponenttext1 = new ChatComponentText("Outdated client! Please use 1.8.8"); this.networkManager.sendPacket(new S00PacketDisconnect(chatcomponenttext1)); this.networkManager.closeChannel(chatcomponenttext1); } else { this.networkManager.setNetHandler(new NetHandlerLoginServer(this.server, this.networkManager)); } break; case STATUS: this.networkManager.setConnectionState(EnumConnectionState.STATUS); this.networkManager.setNetHandler(new NetHandlerStatusServer(this.server, this.networkManager)); break; default: throw new UnsupportedOperationException("Invalid intention " + packetIn.getRequestedState()); } }
public static void tellOwnerAboutDeath(Entity_AA turret) { // Is empty, so telling the owner about this EntityPlayer owner = turret.worldObj.getPlayerEntityByName(turret.ownerName); if (owner == null) { return; } // Might not be online right now // My name String turretName = "ARMS ASSISTANT " + turret.getEntityId(); if (turret.getCustomNameTag() != null && !turret.getCustomNameTag().isEmpty()) { turretName = turret.getCustomNameTag(); } owner.addChatMessage(new ChatComponentText(EnumChatFormatting.GRAY + turretName + " was destroyed!")); }
public static List<IChatComponent> func_152328_a(Set<ChatUserMode> p_152328_0_, Set<ChatUserSubscription> p_152328_1_, IStream p_152328_2_) { String s = p_152328_2_ == null ? null : p_152328_2_.func_152921_C(); boolean flag = p_152328_2_ != null && p_152328_2_.func_152927_B(); List<IChatComponent> list = Lists.<IChatComponent>newArrayList(); for (ChatUserMode chatusermode : p_152328_0_) { IChatComponent ichatcomponent = func_152329_a(chatusermode, s, flag); if (ichatcomponent != null) { IChatComponent ichatcomponent1 = new ChatComponentText("- "); ichatcomponent1.appendSibling(ichatcomponent); list.add(ichatcomponent1); } } for (ChatUserSubscription chatusersubscription : p_152328_1_) { IChatComponent ichatcomponent2 = func_152330_a(chatusersubscription, s, flag); if (ichatcomponent2 != null) { IChatComponent ichatcomponent3 = new ChatComponentText("- "); ichatcomponent3.appendSibling(ichatcomponent2); list.add(ichatcomponent3); } } return list; }
protected void listPlayers(ICommandSender p_147195_1_, String[] p_147195_2_, int p_147195_3_) throws CommandException { Scoreboard scoreboard = this.getScoreboard(); if (p_147195_2_.length > p_147195_3_) { String s = getEntityName(p_147195_1_, p_147195_2_[p_147195_3_]); Map<ScoreObjective, Score> map = scoreboard.getObjectivesForEntity(s); p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, map.size()); if (map.size() <= 0) { throw new CommandException("commands.scoreboard.players.list.player.empty", new Object[] {s}); } ChatComponentTranslation chatcomponenttranslation = new ChatComponentTranslation("commands.scoreboard.players.list.player.count", new Object[] {Integer.valueOf(map.size()), s}); chatcomponenttranslation.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); p_147195_1_.addChatMessage(chatcomponenttranslation); for (Score score : map.values()) { p_147195_1_.addChatMessage(new ChatComponentTranslation("commands.scoreboard.players.list.player.entry", new Object[] {Integer.valueOf(score.getScorePoints()), score.getObjective().getDisplayName(), score.getObjective().getName()})); } } else { Collection<String> collection = scoreboard.getObjectiveNames(); p_147195_1_.setCommandStat(CommandResultStats.Type.QUERY_RESULT, collection.size()); if (collection.size() <= 0) { throw new CommandException("commands.scoreboard.players.list.empty", new Object[0]); } ChatComponentTranslation chatcomponenttranslation1 = new ChatComponentTranslation("commands.scoreboard.players.list.count", new Object[] {Integer.valueOf(collection.size())}); chatcomponenttranslation1.getChatStyle().setColor(EnumChatFormatting.DARK_GREEN); p_147195_1_.addChatMessage(chatcomponenttranslation1); p_147195_1_.addChatMessage(new ChatComponentText(joinNiceString(collection.toArray()))); } }
/** * Get the formatted ChatComponent that will be used for the sender's username in chat */ public IChatComponent getDisplayName() { ChatComponentText chatcomponenttext = new ChatComponentText(this.getName()); chatcomponenttext.getChatStyle().setChatHoverEvent(this.getHoverEvent()); chatcomponenttext.getChatStyle().setInsertion(this.getUniqueID().toString()); return chatcomponenttext; }
/** * Get the formatted ChatComponent that will be used for the sender's username in chat */ public IChatComponent getDisplayName() { IChatComponent ichatcomponent = new ChatComponentText(ScorePlayerTeam.formatPlayerName(this.getTeam(), this.getName())); ichatcomponent.getChatStyle().setChatClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/msg " + this.getName() + " ")); ichatcomponent.getChatStyle().setChatHoverEvent(this.getHoverEvent()); ichatcomponent.getChatStyle().setInsertion(this.getName()); return ichatcomponent; }
@Override protected void drawCountDown(int secondsRemaining) { ChatComponentText text = new ChatComponentText("" + secondsRemaining + "..."); ChatStyle style = new ChatStyle(); style.setBold(true); if (secondsRemaining <= 5) style.setColor(EnumChatFormatting.RED); text.setChatStyle(style); Minecraft.getMinecraft().ingameGUI.getChatGUI().printChatMessageWithOptionalDeletion(text, 1); }
@SubscribeEvent public void eventPlayerInteractEvent(PlayerInteractEvent event) { World world = event.world; int x = event.x; int y = event.y; int z = event.z; EntityPlayer player = event.entityPlayer; if (player != null && player.getHeldItem() != null && player.getHeldItem().getItem() == Items.stick) { if (TOConfig.debugEnable && TOConfig.debugScanner && !world.isRemote && event.action.equals(Action.RIGHT_CLICK_BLOCK) && player.capabilities.isCreativeMode) { int radius = TOConfig.debugRemoverScannerRadius; int[] counter = new int[] { 0, 0, 0, 0, 0, 0 }; for (int xx = x - radius; xx < x + radius; xx++) for (int zz = z - radius; zz < z + radius; zz++) for (int yy = 0; yy < 257; yy++) if ((world.getBlock(xx, yy, zz) instanceof BlockInfusedBlockOre) && world.getBlockMetadata(xx, yy, zz) < 6) counter[world.getBlockMetadata(xx, yy, zz)]++; String text = "[DEBUG " + ThaumOresMod.NAME + "] Scanned blocks at " + x + ";" + z + " with radius " + radius; for (int meta = 0; meta < 6; meta++) text += "\n Count ores with meta " + meta + " = " + counter[meta]; for (String string : text.split("\n")) { ThaumOresMod.log.info(string); player.addChatMessage(new ChatComponentText(string)); } } } }