summaryrefslogtreecommitdiff
path: root/NET/worlds/network/textCmd.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2026-02-12 22:33:32 -0800
committerFuwn <[email protected]>2026-02-12 22:33:32 -0800
commitc7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 (patch)
treedf9f48bf128a6c0186a8e91857d6ff30fe0e9f18 /NET/worlds/network/textCmd.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/network/textCmd.java')
-rw-r--r--NET/worlds/network/textCmd.java141
1 files changed, 141 insertions, 0 deletions
diff --git a/NET/worlds/network/textCmd.java b/NET/worlds/network/textCmd.java
new file mode 100644
index 0000000..f5ba287
--- /dev/null
+++ b/NET/worlds/network/textCmd.java
@@ -0,0 +1,141 @@
+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 + "<b> " + filteredName + "> </b> ";
+ 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;
+ }
+}