mirror of
https://github.com/sirjonasxx/G-Earth.git
synced 2024-11-27 02:40:51 +01:00
HPacket Long
This commit is contained in:
parent
a29b620579
commit
6ae5306899
@ -204,6 +204,7 @@ public class PacketStringUtils {
|
|||||||
else if (c == 'd') builder.append("{d:").append(p.readDouble()).append('}');
|
else if (c == 'd') builder.append("{d:").append(p.readDouble()).append('}');
|
||||||
else if (c == 'b') builder.append("{b:").append(p.readByte()).append('}');
|
else if (c == 'b') builder.append("{b:").append(p.readByte()).append('}');
|
||||||
else if (c == 'B') builder.append("{b:").append(p.readBoolean()).append('}');
|
else if (c == 'B') builder.append("{b:").append(p.readBoolean()).append('}');
|
||||||
|
else if (c == 'l') builder.append("{l:").append(p.readLong()).append('}');
|
||||||
else return;
|
else return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -247,6 +247,14 @@ public class HPacket implements StringifyAble {
|
|||||||
}
|
}
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HPacket replaceLong(int index, long l) {
|
||||||
|
isEdited = true;
|
||||||
|
ByteBuffer b = ByteBuffer.allocate(8).putLong(l);
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
packetInBytes[index + j] = b.array()[j];
|
||||||
|
}
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public HPacket replaceDouble(int index, double d) {
|
public HPacket replaceDouble(int index, double d) {
|
||||||
isEdited = true;
|
isEdited = true;
|
||||||
ByteBuffer b = ByteBuffer.allocate(8).putDouble(d);
|
ByteBuffer b = ByteBuffer.allocate(8).putDouble(d);
|
||||||
@ -415,6 +423,16 @@ public class HPacket implements StringifyAble {
|
|||||||
fixLength();
|
fixLength();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
public HPacket appendLong(long l) {
|
||||||
|
isEdited = true;
|
||||||
|
packetInBytes = Arrays.copyOf(packetInBytes, packetInBytes.length + 8);
|
||||||
|
ByteBuffer byteBuffer = ByteBuffer.allocate(8).putLong(l);
|
||||||
|
for (int j = 0; j < 8; j++) {
|
||||||
|
packetInBytes[packetInBytes.length - 8 + j] = byteBuffer.array()[j];
|
||||||
|
}
|
||||||
|
fixLength();
|
||||||
|
return this;
|
||||||
|
}
|
||||||
public HPacket appendDouble(double d) {
|
public HPacket appendDouble(double d) {
|
||||||
isEdited = true;
|
isEdited = true;
|
||||||
packetInBytes = Arrays.copyOf(packetInBytes, packetInBytes.length + 8);
|
packetInBytes = Arrays.copyOf(packetInBytes, packetInBytes.length + 8);
|
||||||
@ -502,6 +520,9 @@ public class HPacket implements StringifyAble {
|
|||||||
else if (o instanceof Boolean) {
|
else if (o instanceof Boolean) {
|
||||||
appendBoolean((Boolean) o);
|
appendBoolean((Boolean) o);
|
||||||
}
|
}
|
||||||
|
else if (o instanceof Long) {
|
||||||
|
appendLong((Long) o);
|
||||||
|
}
|
||||||
else {
|
else {
|
||||||
throw new InvalidParameterException();
|
throw new InvalidParameterException();
|
||||||
}
|
}
|
||||||
@ -509,20 +530,6 @@ public class HPacket implements StringifyAble {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public HPacket removeFrom(int index) {
|
|
||||||
return removeRange(index, packetInBytes.length - index);
|
|
||||||
}
|
|
||||||
public HPacket removeRange(int index, int length) {
|
|
||||||
isEdited = true;
|
|
||||||
for (int i = index; i < packetInBytes.length - length; i++) {
|
|
||||||
packetInBytes[i] = packetInBytes[i + length];
|
|
||||||
}
|
|
||||||
packetInBytes = Arrays.copyOf(packetInBytes, packetInBytes.length - length);
|
|
||||||
fixLength();
|
|
||||||
return this;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isReplaced() {
|
public boolean isReplaced() {
|
||||||
return isEdited;
|
return isEdited;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user