summaryrefslogtreecommitdiff
path: root/NET/worlds/network/net2Property.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/net2Property.java
downloadworldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.tar.xz
worldsplayer-c7a9d4a6bd53ed7d61731770f2f10e8b9fd435f9.zip
Initial commit
Diffstat (limited to 'NET/worlds/network/net2Property.java')
-rw-r--r--NET/worlds/network/net2Property.java171
1 files changed, 171 insertions, 0 deletions
diff --git a/NET/worlds/network/net2Property.java b/NET/worlds/network/net2Property.java
new file mode 100644
index 0000000..eb88175
--- /dev/null
+++ b/NET/worlds/network/net2Property.java
@@ -0,0 +1,171 @@
+package NET.worlds.network;
+
+import java.io.IOException;
+import java.io.UTFDataFormatException;
+
+public class net2Property {
+ private int _propID;
+ protected int _flags;
+ protected int _access;
+ protected String _stringValue;
+ protected byte[] _binValue;
+
+ public net2Property(int p, int flags, int access, byte[] data) {
+ this._propID = p;
+ this._flags = flags;
+ this._access = access;
+
+ assert (flags & 16) > 0;
+
+ this._binValue = data;
+ this._stringValue = null;
+ }
+
+ public net2Property(int p, int flags, int access, String data) {
+ this._propID = p;
+ this._flags = flags;
+ this._access = access;
+
+ assert (flags & 16) == 0;
+
+ this._stringValue = data;
+ this._binValue = null;
+ }
+
+ public net2Property() {
+ this._propID = 0;
+ this._flags = 0;
+ this._access = 0;
+ this._stringValue = null;
+ this._binValue = null;
+ }
+
+ public int property() {
+ return this._propID;
+ }
+
+ public int flags() {
+ return this._flags;
+ }
+
+ public int access() {
+ return this._access;
+ }
+
+ public byte[] data() {
+ if ((this._flags & 16) > 0) {
+ return this._binValue;
+ } else {
+ byte[] data = new byte[this._stringValue.length()];
+ this._stringValue.getBytes(0, this._stringValue.length(), data, 0);
+ return data;
+ }
+ }
+
+ public String value() {
+ return (this._flags & 16) == 0 ? this._stringValue : new String(this._binValue);
+ }
+
+ int packetSize() {
+ if ((this._flags & 16) > 0) {
+ assert this._binValue != null;
+
+ return 4 + this._binValue.length;
+ } else {
+ assert this._stringValue != null;
+
+ return 4 + ServerOutputStream.utfLength(this._stringValue);
+ }
+ }
+
+ void parseNetData(ServerInputStream data) throws IOException, UTFDataFormatException {
+ this._propID = data.readUnsignedByte();
+ this._flags = data.readUnsignedByte();
+ this._access = data.readUnsignedByte();
+ if ((this._flags & 16) > 0) {
+ int size = data.readUnsignedByte();
+ this._binValue = new byte[size];
+ data.readFully(this._binValue);
+ this._stringValue = null;
+ } else {
+ try {
+ this._stringValue = data.readUTF();
+ } catch (UTFDataFormatException var3) {
+ this._stringValue = "";
+ throw var3;
+ }
+
+ this._binValue = null;
+ }
+ }
+
+ void send(ServerOutputStream o) throws IOException {
+ o.writeByte(this._propID);
+ o.writeByte(this._flags);
+ o.writeByte(this._access);
+ if ((this._flags & 16) > 0) {
+ o.writeByte(this._binValue.length);
+ o.write(this._binValue);
+ } else {
+ o.writeUTF(this._stringValue);
+ }
+ }
+
+ private String flagString() {
+ String out = "";
+ if ((this._flags & 128) > 0) {
+ out = out + "DBSTORE ";
+ }
+
+ if ((this._flags & 64) > 0) {
+ out = out + "AUTOUPDATE ";
+ }
+
+ if ((this._flags & 32) > 0) {
+ out = out + "FINGER ";
+ }
+
+ if ((this._flags & 16) > 0) {
+ out = out + "BINARY ";
+ }
+
+ if (out.length() == 0) {
+ out = "NONE";
+ }
+
+ return out;
+ }
+
+ private String accessString() {
+ String out = "";
+ if ((this._access & 1) > 0) {
+ out = out + "POSSESS ";
+ }
+
+ if ((this._access & 2) > 0) {
+ out = out + "PRIVATE ";
+ }
+
+ if (out.length() == 0) {
+ out = "NONE";
+ }
+
+ return out;
+ }
+
+ @Override
+ public String toString() {
+ String tmp = "#" + this._propID + " [" + this.flagString() + "/" + this.accessString() + "] ";
+ if ((this._flags & 16) == 0) {
+ return tmp + this._stringValue;
+ } else {
+ tmp = tmp + "val=[";
+
+ for (int i = 0; i < this._binValue.length; i++) {
+ tmp = tmp + Integer.toString(this._binValue[i], 16) + " ";
+ }
+
+ return tmp + "] (" + this._binValue + ")";
+ }
+ }
+}