Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed unused implementations of Persistable #603

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import com.projectswg.common.data.encodables.mongo.MongoData;
import com.projectswg.common.data.encodables.mongo.MongoPersistable;
import com.projectswg.common.data.location.Terrain;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.gameplay.crafting.resource.raw.RawResource;
import org.jetbrains.annotations.NotNull;

Expand All @@ -40,11 +38,10 @@
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Supplier;
import java.util.stream.Collectors;

import static java.util.stream.Collectors.groupingBy;

public class GalacticResource implements Persistable, MongoPersistable {
public class GalacticResource implements MongoPersistable {

private final GalacticResourceStats stats;
private final List<GalacticResourceSpawn> spawns;
Expand Down Expand Up @@ -122,24 +119,6 @@ public void removeSpawn(@NotNull GalacticResourceSpawn spawn) {
});
}

@Override
public void read(NetBufferStream stream) {
stream.getByte();
id = stream.getLong();
name = stream.getAscii();
rawId = stream.getLong();
stats.read(stream);
}

@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
stream.addLong(id);
stream.addAscii(name);
stream.addLong(rawId);
stats.save(stream);
}

@Override
public void readMongo(MongoData data) {
spawns.clear();
Expand Down Expand Up @@ -179,14 +158,4 @@ public int hashCode() {
return Long.hashCode(id);
}

public static GalacticResource create(NetBufferStream stream) {
GalacticResource resource = new GalacticResource();
resource.read(stream);
return resource;
}

public void save(NetBufferStream stream, GalacticResource resource) {
resource.save(stream);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,14 @@
import com.projectswg.common.data.encodables.mongo.MongoData;
import com.projectswg.common.data.encodables.mongo.MongoPersistable;
import com.projectswg.common.data.location.Terrain;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.support.data.server_info.mongodb.PswgDatabase;

import java.time.Instant;
import java.time.temporal.ChronoUnit;
import java.util.Random;
import java.util.concurrent.ThreadLocalRandom;

public class GalacticResourceSpawn implements Persistable, MongoPersistable {
public class GalacticResourceSpawn implements MongoPersistable {

private static final int MAP_SIZE = 16384;
private static final int MUST_MAP_SIZE = 8000;
Expand Down Expand Up @@ -199,40 +197,6 @@ private int capPosition(int x) {
return Math.max(-MAP_SIZE/2, Math.min(MAP_SIZE/2, x));
}

@Override
public void read(NetBufferStream stream) {
stream.getByte();
// Resource
this.resourceId = stream.getLong();
this.minConcentration = stream.getInt();
this.maxConcentration = stream.getInt();
// Location
this.terrain = Terrain.valueOf(stream.getAscii());
this.x = stream.getInt();
this.z = stream.getInt();
this.radius = stream.getInt();
// Time
this.startTime = Instant.ofEpochMilli(stream.getLong());
this.endTime = Instant.ofEpochMilli(stream.getLong());
}

@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
// Resource
stream.addLong(resourceId);
stream.addInt(minConcentration);
stream.addInt(maxConcentration);
// Location
stream.addAscii(terrain.name());
stream.addInt(x);
stream.addInt(z);
stream.addInt(radius);
// Time
stream.addLong(startTime.toEpochMilli());
stream.addLong(endTime.toEpochMilli());
}

@Override
public void readMongo(MongoData data) {
{
Expand Down Expand Up @@ -311,14 +275,4 @@ public int hashCode() {
return Long.hashCode(resourceId) * 7 + x * 23 + z * 89;
}

public static GalacticResourceSpawn create(NetBufferStream stream) {
GalacticResourceSpawn spawn = new GalacticResourceSpawn();
spawn.read(stream);
return spawn;
}

public static void save(NetBufferStream stream, GalacticResourceSpawn spawn) {
spawn.save(stream);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@

import com.projectswg.common.data.encodables.mongo.MongoData;
import com.projectswg.common.data.encodables.mongo.MongoPersistable;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.gameplay.crafting.resource.raw.RawResource;

import java.util.Random;

public class GalacticResourceStats implements Persistable, MongoPersistable {
public class GalacticResourceStats implements MongoPersistable {

private int coldResistance;
private int conductivity;
Expand Down Expand Up @@ -77,38 +75,6 @@ public void generateRandomStats(RawResource resource) {
this.unitToughness = resource.isAttrUnitToughness() ? generateRandomNumber(random) : 0;
}

@Override
public void read(NetBufferStream stream) {
stream.getByte();
this.coldResistance = stream.getShort();
this.conductivity = stream.getShort();
this.decayResistance = stream.getShort();
this.entangleResistance = stream.getShort();
this.flavor = stream.getShort();
this.heatResistance = stream.getShort();
this.malleability = stream.getShort();
this.overallQuality = stream.getShort();
this.potentialEnergy = stream.getShort();
this.shockResistance = stream.getShort();
this.unitToughness = stream.getShort();
}

@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
stream.addShort(coldResistance);
stream.addShort(conductivity);
stream.addShort(decayResistance);
stream.addShort(entangleResistance);
stream.addShort(flavor);
stream.addShort(heatResistance);
stream.addShort(malleability);
stream.addShort(overallQuality);
stream.addShort(potentialEnergy);
stream.addShort(shockResistance);
stream.addShort(unitToughness);
}

@Override
public void readMongo(MongoData data) {
coldResistance = data.getInteger("coldResistance", coldResistance);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,11 @@

import com.projectswg.common.encoding.Encodable;
import com.projectswg.common.network.NetBuffer;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;

import java.util.BitSet;

public class SWGBitSet extends BitSet implements Encodable, Persistable {
public class SWGBitSet extends BitSet implements Encodable {

private static final long serialVersionUID = 1L;

Expand Down Expand Up @@ -75,16 +73,6 @@ public int getLength() {
return 8 + (super.length()+7) / 8;
}

@Override
public void save(NetBufferStream stream) {
stream.addArray(toByteArray());
}

@Override
public void read(NetBufferStream stream) {
read(stream.getArray());
}

public void read(byte[] bytes) {
clear();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,12 @@

import com.projectswg.common.encoding.Encodable;
import com.projectswg.common.network.NetBuffer;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;

import java.util.Arrays;
import java.util.BitSet;

public class SWGFlag extends BitSet implements Encodable, Persistable {
public class SWGFlag extends BitSet implements Encodable {

private static final long serialVersionUID = 2L;

Expand Down Expand Up @@ -81,17 +79,6 @@ public int getLength() {
return 4 + (int) Math.ceil(super.size()/32.0);
}

@Override
public void save(NetBufferStream stream) {
stream.addArray(toByteArray());
}

@Override
public void read(NetBufferStream stream) {
clear();
xor(valueOf(stream.getArray()));
}

@Override
public boolean equals(Object o) {
if (!(o instanceof SWGFlag))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,10 @@
import com.projectswg.common.data.location.Point3D;
import com.projectswg.common.data.location.Quaternion;
import com.projectswg.common.data.location.Terrain;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
import org.jetbrains.annotations.NotNull;

public class InstanceLocation implements Persistable, MongoPersistable {
public class InstanceLocation implements MongoPersistable {

private Location location;
private InstanceType instanceType;
Expand All @@ -49,18 +47,6 @@ public InstanceLocation() {
this.instanceNumber = 0;
}

@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
location.save(stream);
}

@Override
public void read(NetBufferStream stream) {
stream.getByte();
location.read(stream);
}

@Override
public void readMongo(MongoData data) {
instanceNumber = data.getInteger("number", 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,18 +27,11 @@
package com.projectswg.holocore.resources.support.data.persistable;

import com.projectswg.common.data.encodables.mongo.MongoData;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.holocore.resources.support.objects.ObjectCreator;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;

public class SWGObjectFactory {

public static void save(SWGObject obj, NetBufferStream stream) {
stream.addLong(obj.getObjectId());
stream.addAscii(obj.getTemplate());
obj.save(stream);
}

public static MongoData save(SWGObject obj) {
return save(obj, new MongoData());
}
Expand All @@ -52,14 +45,6 @@ public static MongoData save(SWGObject obj, MongoData data) {
return data;
}

public static SWGObject create(NetBufferStream stream) {
long objectId = stream.getLong();
String template = stream.getAscii();
SWGObject obj = ObjectCreator.createObjectFromTemplate(objectId, template);
obj.read(stream);
return obj;
}

public static SWGObject create(MongoData data) {
long objectId = data.getLong("id", 0);
String template = data.getString("template");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,13 @@
import com.projectswg.common.network.NetBuffer;
import com.projectswg.common.network.NetBufferStream;
import com.projectswg.common.network.packets.swg.zone.baselines.Baseline;
import com.projectswg.common.persistable.Persistable;
import com.projectswg.holocore.resources.support.data.persistable.SWGObjectFactory;
import com.projectswg.holocore.resources.support.objects.swg.SWGObject;
import com.projectswg.holocore.resources.support.objects.swg.tangible.TangibleObject;
import com.projectswg.holocore.resources.support.objects.swg.weapon.WeaponObject;
import me.joshlarson.jlcommon.log.Log;

public class Equipment implements Encodable, Persistable {
public class Equipment implements Encodable {

private TangibleObject weapon;
private byte[] customizationString;
Expand Down Expand Up @@ -99,29 +98,6 @@ private int getLength(int weaponLength) {
return 15 + weaponLength + customizationString.length + template.getLength();
}

@Override
public void save(NetBufferStream stream) {
stream.addByte(0);
stream.addLong(objectId);
stream.addInt(arrangementId);
stream.addInt(template.getCrc());
stream.addArray(customizationString);
stream.addBoolean(weapon != null);
if (weapon != null)
SWGObjectFactory.save(weapon, stream);
}

@Override
public void read(NetBufferStream stream) {
stream.getByte();
objectId = stream.getLong();
arrangementId = stream.getInt();
template = new CRC(stream.getInt());
customizationString = stream.getArray();
if (stream.getBoolean())
weapon = (TangibleObject) SWGObjectFactory.create(stream);
}

public byte [] getCustomizationString() {return customizationString;}
public void setCustomizationString(byte [] customizationString) { this.customizationString = customizationString; }

Expand Down
Loading