From c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9 Mon Sep 17 00:00:00 2001 From: Fuwn Date: Thu, 12 Feb 2026 22:33:32 -0800 Subject: Initial commit --- NET/worlds/network/PropertyList.java | 84 ++++++++++++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 NET/worlds/network/PropertyList.java (limited to 'NET/worlds/network/PropertyList.java') diff --git a/NET/worlds/network/PropertyList.java b/NET/worlds/network/PropertyList.java new file mode 100644 index 0000000..8a83be8 --- /dev/null +++ b/NET/worlds/network/PropertyList.java @@ -0,0 +1,84 @@ +package NET.worlds.network; + +import java.io.IOException; +import java.io.UTFDataFormatException; +import java.util.Vector; + +public class PropertyList { + private Vector _propList = new Vector(); + + public void addProperty(net2Property prop) { + this._propList.addElement(prop); + } + + public int size() { + return this._propList.size(); + } + + public net2Property elementAt(int i) { + return this._propList.elementAt(i); + } + + public net2Property getProperty(int propID) { + for (int i = this._propList.size() - 1; i >= 0; i--) { + if (this.elementAt(i).property() == propID) { + return this.elementAt(i); + } + } + + return null; + } + + void parseNetData(ServerInputStream data) throws IOException { + this._propList = new Vector(); + + while (!data.isEmpty()) { + try { + net2Property tmpProp = new net2Property(); + tmpProp.parseNetData(data); + this._propList.addElement(tmpProp); + } catch (UTFDataFormatException var4) { + System.out.println("Property list discarded; invalid UTF property."); + this._propList.removeAllElements(); + data.skipBytes(data.bytesLeft()); + + assert data.isEmpty(); + + return; + } + } + } + + int packetSize() { + int len = 0; + + for (int i = this._propList.size() - 1; i >= 0; i--) { + net2Property tmpProp = this._propList.elementAt(i); + len += tmpProp.packetSize(); + } + + return len; + } + + void send(ServerOutputStream o) throws IOException { + int maxidx = this._propList.size(); + + for (int i = 0; i < maxidx; i++) { + net2Property tmpProp = this._propList.elementAt(i); + tmpProp.send(o); + } + } + + @Override + public String toString() { + String out = "("; + int maxidx = this._propList.size(); + + for (int i = 0; i < maxidx; i++) { + net2Property tmpProp = this._propList.elementAt(i); + out = out + tmpProp + " "; + } + + return out + ")"; + } +} -- cgit v1.2.3