mirror of
https://github.com/simon987/Much-Assembly-Required.git
synced 2025-12-18 00:59:05 +00:00
Loading & Saving support for MongoDB
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
package net.simon987.cubotplugin;
|
||||
|
||||
import com.mongodb.BasicDBObject;
|
||||
import com.mongodb.DBObject;
|
||||
import net.simon987.server.GameServer;
|
||||
import net.simon987.server.assembly.CpuHardware;
|
||||
import net.simon987.server.assembly.Status;
|
||||
import net.simon987.server.game.Action;
|
||||
import net.simon987.server.game.TileMap;
|
||||
import org.json.simple.JSONObject;
|
||||
|
||||
public class CubotDrill extends CpuHardware {
|
||||
|
||||
@@ -62,15 +63,17 @@ public class CubotDrill extends CpuHardware {
|
||||
}
|
||||
|
||||
@Override
|
||||
public JSONObject serialise() {
|
||||
JSONObject json = new JSONObject();
|
||||
json.put("hwid", (int) HWID);
|
||||
json.put("cubot", cubot.getObjectId());
|
||||
public BasicDBObject mongoSerialise() {
|
||||
|
||||
return json;
|
||||
BasicDBObject dbObject = new BasicDBObject();
|
||||
|
||||
dbObject.put("hwid", (int) HWID);
|
||||
dbObject.put("cubot", cubot.getObjectId());
|
||||
|
||||
return dbObject;
|
||||
}
|
||||
|
||||
public static CubotDrill deserialize(JSONObject hwJSON) {
|
||||
return new CubotDrill((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((int) (long) hwJSON.get("cubot")));
|
||||
public static CubotDrill deserialize(DBObject obj) {
|
||||
return new CubotDrill((Cubot) GameServer.INSTANCE.getGameUniverse().getObject((long) obj.get("cubot")));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user