mirror of
https://github.com/ProjectSWGCore/NGECore2.git
synced 2026-09-11 21:45:43 -04:00
Fixed warnings, improvements
This commit is contained in:
@@ -6,9 +6,6 @@ import main.NGECore;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.config.Config;
|
||||
import engine.resources.config.DefaultConfig;
|
||||
|
||||
public class ChatFriendsListUpdate extends SWGMessage {
|
||||
|
||||
private String friendName;
|
||||
|
||||
@@ -26,8 +26,6 @@ import java.nio.ByteBuffer;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.common.StringUtilities;
|
||||
|
||||
public class SetWaypointColor extends SWGMessage {
|
||||
|
||||
private long objectId;
|
||||
|
||||
@@ -26,7 +26,6 @@ import java.nio.ByteOrder;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import protocol.swg.ObjControllerMessage;
|
||||
import protocol.swg.SWGMessage;
|
||||
|
||||
public class Animation extends ObjControllerObject {
|
||||
|
||||
|
||||
@@ -21,12 +21,8 @@
|
||||
******************************************************************************/
|
||||
package protocol.swg.objectControllerObjects;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.Utilities;
|
||||
|
||||
public class ChangeRoleIconChoice extends ObjControllerObject {
|
||||
|
||||
private long objectId = 0;
|
||||
|
||||
@@ -23,7 +23,6 @@ package resources.common;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import resources.z.exp.objects.Baseline;
|
||||
import resources.objects.Delta;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -85,7 +84,7 @@ public class Stf extends Delta {
|
||||
synchronized(objectMutex) {
|
||||
int size = stfFilename.getBytes().length + 4 + stfName.getBytes().length;
|
||||
|
||||
IoBuffer buffer = Baseline.createBuffer(size);
|
||||
IoBuffer buffer = createBuffer(size);
|
||||
buffer.put(stfFilename.getBytes());
|
||||
buffer.putInt(spacer);
|
||||
buffer.put(stfName.getBytes());
|
||||
|
||||
@@ -27,6 +27,8 @@ import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import engine.resources.common.Utilities;
|
||||
|
||||
public class StringUtilities {
|
||||
|
||||
final protected static char[] hexArray = {'0','1','2','3','4','5','6','7','8','9','A','B','C','D','E','F'};
|
||||
@@ -166,16 +168,20 @@ public class StringUtilities {
|
||||
}
|
||||
|
||||
public static String bytesToHex(byte[] bytes) {
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
int v;
|
||||
|
||||
for ( int j = 0; j < bytes.length; j++ ) {
|
||||
v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
|
||||
return new String(hexChars);
|
||||
char[] hexChars = new char[bytes.length * 2];
|
||||
int v;
|
||||
|
||||
for ( int j = 0; j < bytes.length; j++ ) {
|
||||
v = bytes[j] & 0xFF;
|
||||
hexChars[j * 2] = hexArray[v >>> 4];
|
||||
hexChars[j * 2 + 1] = hexArray[v & 0x0F];
|
||||
}
|
||||
|
||||
return new String(hexChars);
|
||||
}
|
||||
|
||||
public static void printBytes(byte[] bytes) {
|
||||
System.out.println(Utilities.getHexString(bytes));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -22,9 +22,6 @@
|
||||
package resources.common;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
@@ -64,7 +61,7 @@ public final class UString extends Delta {
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
try {
|
||||
return IoBuffer.allocate(4 + string.length(), false).order(ByteOrder.LITTLE_ENDIAN).putInt(string.length()).put(string.getBytes("UTF-16LE")).flip().array();
|
||||
return createBuffer(4 + (string.length() * 2)).putInt(string.length()).put(string.getBytes("UTF-16LE")).flip().array();
|
||||
} catch (UnsupportedEncodingException e) {
|
||||
e.printStackTrace();
|
||||
return new byte[] { 0x00, 0x00, 0x00, 0x00 };
|
||||
|
||||
@@ -21,15 +21,13 @@
|
||||
******************************************************************************/
|
||||
package resources.gcw;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent
|
||||
@Persistent(version=0)
|
||||
public class CurrentServerGCWZoneHistory extends Delta implements Cloneable {
|
||||
|
||||
private int lastUpdateTime;
|
||||
@@ -40,6 +38,10 @@ public class CurrentServerGCWZoneHistory extends Delta implements Cloneable {
|
||||
this.lastUpdateTime = zone.getLastUpdateTime();
|
||||
}
|
||||
|
||||
public CurrentServerGCWZoneHistory() {
|
||||
|
||||
}
|
||||
|
||||
public int getLastUpdateTime() {
|
||||
synchronized(objectMutex) {
|
||||
return lastUpdateTime;
|
||||
@@ -54,7 +56,7 @@ public class CurrentServerGCWZoneHistory extends Delta implements Cloneable {
|
||||
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
IoBuffer buffer = bufferPool.allocate((8), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = createBuffer(8);
|
||||
buffer.putInt(lastUpdateTime);
|
||||
buffer.putInt(percent);
|
||||
return buffer.array();
|
||||
|
||||
@@ -23,7 +23,6 @@ package resources.gcw;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.MathContext;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
@@ -33,7 +32,7 @@ import engine.resources.scene.Point2D;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent
|
||||
@Persistent(version=0)
|
||||
public class CurrentServerGCWZonePercent extends Delta implements Cloneable {
|
||||
|
||||
private Point2D position;
|
||||
@@ -53,6 +52,10 @@ public class CurrentServerGCWZonePercent extends Delta implements Cloneable {
|
||||
this.percent = new BigDecimal("50.0", MathContext.DECIMAL128);
|
||||
}
|
||||
|
||||
public CurrentServerGCWZonePercent() {
|
||||
|
||||
}
|
||||
|
||||
public Point2D getPosition() {
|
||||
synchronized(objectMutex) {
|
||||
return position.clone();
|
||||
@@ -148,7 +151,7 @@ public class CurrentServerGCWZonePercent extends Delta implements Cloneable {
|
||||
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
IoBuffer buffer = bufferPool.allocate(4, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = createBuffer(4);
|
||||
buffer.putInt(percent.intValue());
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@@ -21,15 +21,13 @@
|
||||
******************************************************************************/
|
||||
package resources.gcw;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
@Persistent
|
||||
@Persistent(version=0)
|
||||
public class OtherServerGCWZonePercent extends Delta implements Cloneable {
|
||||
|
||||
private String zone = "";
|
||||
@@ -39,6 +37,10 @@ public class OtherServerGCWZonePercent extends Delta implements Cloneable {
|
||||
this.zone = zone;
|
||||
}
|
||||
|
||||
public OtherServerGCWZonePercent() {
|
||||
|
||||
}
|
||||
|
||||
public String getZone() {
|
||||
synchronized(objectMutex) {
|
||||
return zone;
|
||||
@@ -60,7 +62,7 @@ public class OtherServerGCWZonePercent extends Delta implements Cloneable {
|
||||
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
IoBuffer buffer = bufferPool.allocate((2 + zone.length() + 4), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = createBuffer((2 + zone.length() + 4));
|
||||
buffer.put(getAsciiString(zone));
|
||||
buffer.putInt(percent);
|
||||
return buffer.array();
|
||||
|
||||
@@ -21,15 +21,17 @@
|
||||
******************************************************************************/
|
||||
package resources.guild;
|
||||
|
||||
import java.nio.ByteOrder;
|
||||
import java.util.List;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
|
||||
import resources.objects.Delta;
|
||||
|
||||
import engine.resources.objects.SWGObject;
|
||||
|
||||
@Persistent(version=0)
|
||||
public class Guild extends Delta {
|
||||
|
||||
private int id;
|
||||
@@ -46,6 +48,10 @@ public class Guild extends Delta {
|
||||
this.members.add(leader);
|
||||
}
|
||||
|
||||
public Guild() {
|
||||
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
synchronized(objectMutex) {
|
||||
return id;
|
||||
@@ -83,17 +89,19 @@ public class Guild extends Delta {
|
||||
}
|
||||
|
||||
public String getString() {
|
||||
synchronized(objectMutex) {
|
||||
return (Integer.toString(id) + ":" + abbreviation);
|
||||
}
|
||||
return (Integer.toString(getId()) + ":" + getAbbreviation());
|
||||
}
|
||||
|
||||
public SWGObject getLeader() {
|
||||
return leader;
|
||||
synchronized(objectMutex) {
|
||||
return leader;
|
||||
}
|
||||
}
|
||||
|
||||
public void setLeader(SWGObject leader) {
|
||||
this.leader = leader;
|
||||
synchronized(objectMutex) {
|
||||
this.leader = leader;
|
||||
}
|
||||
}
|
||||
|
||||
public List<SWGObject> getMembers() {
|
||||
@@ -102,7 +110,7 @@ public class Guild extends Delta {
|
||||
|
||||
public byte[] getBytes() {
|
||||
synchronized(objectMutex) {
|
||||
IoBuffer buffer = bufferPool.allocate((getString().length() + 2), false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
IoBuffer buffer = createBuffer((getString().length() + 2));
|
||||
buffer.put(getAsciiString(getString()));
|
||||
return buffer.array();
|
||||
}
|
||||
|
||||
@@ -22,8 +22,10 @@
|
||||
package resources.objects;
|
||||
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.ByteOrder;
|
||||
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.core.buffer.SimpleBufferAllocator;
|
||||
|
||||
import com.sleepycat.persist.model.NotPersistent;
|
||||
import com.sleepycat.persist.model.Persistent;
|
||||
@@ -34,10 +36,12 @@ import resources.common.StringUtilities;
|
||||
public abstract class Delta implements IDelta {
|
||||
|
||||
@NotPersistent
|
||||
protected final Object objectMutex;
|
||||
protected final Object objectMutex = new Object();
|
||||
@NotPersistent
|
||||
private static SimpleBufferAllocator bufferPool = new SimpleBufferAllocator();
|
||||
|
||||
public Delta() {
|
||||
objectMutex = new Object();
|
||||
|
||||
}
|
||||
|
||||
protected String getAsciiString(ByteBuffer buffer) {
|
||||
@@ -61,7 +65,7 @@ public abstract class Delta implements IDelta {
|
||||
}
|
||||
|
||||
public static IoBuffer createBuffer(int size) {
|
||||
return Baseline.createBuffer(size);
|
||||
return bufferPool.allocate(size, false).order(ByteOrder.LITTLE_ENDIAN);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -23,7 +23,6 @@ package services.travel;
|
||||
|
||||
import java.util.concurrent.ExecutorService;
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
|
||||
import resources.common.Console;
|
||||
import resources.common.SpawnPoint;
|
||||
|
||||
Reference in New Issue
Block a user