diff options
Diffstat (limited to 'NET/worlds/network/PropertyList.java')
| -rw-r--r-- | NET/worlds/network/PropertyList.java | 108 |
1 files changed, 108 insertions, 0 deletions
diff --git a/NET/worlds/network/PropertyList.java b/NET/worlds/network/PropertyList.java new file mode 100644 index 0000000..4ad228d --- /dev/null +++ b/NET/worlds/network/PropertyList.java @@ -0,0 +1,108 @@ +/* */ package NET.worlds.network; +/* */ +/* */ import java.io.IOException; +/* */ import java.io.PrintStream; +/* */ import java.io.UTFDataFormatException; +/* */ import java.util.Vector; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class PropertyList +/* */ { +/* */ private Vector<net2Property> _propList; +/* */ +/* */ public PropertyList() +/* */ { +/* 26 */ this._propList = new Vector(); +/* */ } +/* */ +/* */ public void addProperty(net2Property prop) { +/* 30 */ this._propList.addElement(prop); +/* */ } +/* */ +/* */ public int size() { +/* 34 */ return this._propList.size(); +/* */ } +/* */ +/* */ public net2Property elementAt(int i) { +/* 38 */ return (net2Property)this._propList.elementAt(i); +/* */ } +/* */ +/* */ public net2Property getProperty(int propID) { +/* 42 */ for (int i = this._propList.size() - 1; i >= 0; i--) { +/* 43 */ if (elementAt(i).property() == propID) +/* 44 */ return elementAt(i); +/* */ } +/* 46 */ return null; +/* */ } +/* */ +/* */ +/* */ +/* */ void parseNetData(ServerInputStream data) +/* */ throws IOException +/* */ { +/* 54 */ this._propList = new Vector(); +/* 55 */ while (!data.isEmpty()) { +/* */ try { +/* 57 */ net2Property tmpProp = new net2Property(); +/* 58 */ tmpProp.parseNetData(data); +/* 59 */ this._propList.addElement(tmpProp); +/* */ } +/* */ catch (UTFDataFormatException e) { +/* 62 */ System.out.println("Property list discarded; invalid UTF property."); +/* 63 */ this._propList.removeAllElements(); +/* 64 */ data.skipBytes(data.bytesLeft()); +/* 65 */ assert (data.isEmpty()); +/* 66 */ return; +/* */ } +/* */ } +/* */ } +/* */ +/* */ int packetSize() { +/* 72 */ int len = 0; +/* */ +/* 74 */ for (int i = this._propList.size() - 1; i >= 0; i--) { +/* 75 */ net2Property tmpProp = (net2Property)this._propList.elementAt(i); +/* 76 */ len += tmpProp.packetSize(); +/* */ } +/* 78 */ return len; +/* */ } +/* */ +/* */ void send(ServerOutputStream o) throws IOException { +/* 82 */ int maxidx = this._propList.size(); +/* */ +/* 84 */ for (int i = 0; i < maxidx; i++) { +/* 85 */ net2Property tmpProp = (net2Property)this._propList.elementAt(i); +/* 86 */ tmpProp.send(o); +/* */ } +/* */ } +/* */ +/* */ public String toString() +/* */ { +/* 92 */ String out = "("; +/* 93 */ int maxidx = this._propList.size(); +/* */ +/* 95 */ for (int i = 0; i < maxidx; i++) { +/* 96 */ net2Property tmpProp = (net2Property)this._propList.elementAt(i); +/* 97 */ out = out + tmpProp + " "; +/* */ } +/* 99 */ out = out + ")"; +/* 100 */ return out; +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\network\PropertyList.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |