package NET.worlds.network; import NET.worlds.console.BBChatCommand; import NET.worlds.console.BlackBox; import NET.worlds.console.Console; import NET.worlds.console.GammaTextArea; import NET.worlds.console.MuteListPart; import NET.worlds.core.IniFile; import NET.worlds.scape.Drone; import NET.worlds.scape.Pilot; import NET.worlds.scape.PosableDrone; import java.io.IOException; public class textCmd extends receivedNetPacket { public static final byte TEXTCMD = 14; protected ObjID _senderID; protected String _text; public textCmd() { this._commandType = 14; } public textCmd(String text) { super(null, 14); this._senderID = new ObjID(""); this._text = text; } @Override void parseNetData(ServerInputStream data) throws IOException { this._senderID = new ObjID(); this._senderID.parseNetData(data); this._text = data.readUTF(); } @Override int packetSize() { return ServerOutputStream.utfLength(this._text) + 1 + this._senderID.packetSize() + super.packetSize(); } @Override void send(ServerOutputStream o) throws IOException { super.send(o); this._senderID.send(o); o.writeUTF(this._text); } @Override void process(WorldServer _serv) throws Exception { String name; if (this._senderID.longID() == null) { name = "[Unknown Name (#" + String.valueOf(this._senderID.shortID()) + ")]"; } else { name = this._senderID.longID(); if (MuteListPart.isMuted(_serv, name)) { return; } } handleActionText(_serv, this._text, name, this._senderID); if (!this._text.startsWith("&|+")) { this.displayText(name, this._text); } } protected void displayText(String name, String text) { String filteredName = FilthFilter.get().filterName(name); String line = ""; if (IniFile.gamma().getIniInt("classicChatBox", 1) == 1) { line = filteredName + "> "; line = line + FilthFilter.get().filter(text); BlackBox.getInstance().submitEvent(new BBChatCommand(line)); Console.println(line); } else { boolean colored = false; if (Drone.isEmployeeAccount(name)) { line = GammaTextArea.colorStartBlueTag + " "; colored = true; } else if (name.toLowerCase().startsWith(Console.message("host"))) { line = GammaTextArea.colorStartRedTag + " "; colored = true; } else if (name.toLowerCase().startsWith(Console.message("guest-"))) { line = GammaTextArea.colorStartMagentaTag + " "; colored = true; } line = line + " " + filteredName + "> "; if (colored) { line = line + " " + GammaTextArea.colorEndTag + " "; } line = line + FilthFilter.get().filter(text); BlackBox.getInstance().submitEvent(new BBChatCommand(line)); Console.println(line); } } public static void handleActionText(WorldServer _serv, String msg, String name, ObjID senderID) { if (msg.startsWith("&|+action>")) { NetworkObject o = _serv.getObject(senderID); if (o == null) { return; } String act = msg.substring(10); if (!(o instanceof PosableDrone)) { return; } ((PosableDrone)o).animate(act); } if (msg.startsWith("&|+action2>")) { int idx = msg.indexOf("|sender|"); String senderAction = null; String receiverAction = null; if (idx != -1) { senderAction = msg.substring(idx); receiverAction = msg.substring(11, idx); NetworkObject ox = _serv.getObject(senderID); if (ox != null && ox instanceof PosableDrone) { ((PosableDrone)ox).animate(senderAction); Pilot.sendText("&|+action>" + senderAction); } } else { receiverAction = msg.substring(11); } try { Console.getActive().getPilot().animate(receiverAction); } catch (Exception var8) { System.out.println("Error animating pilot " + var8.toString()); } } } @Override public String toString(WorldServer serv) { return "TEXT " + this._senderID.toString(serv) + ": " + this._text; } }