好的,所以我收到了这个错误。我试着让房子可序列化,但它仍然不起作用?我现在不知道该怎么做。如果有人可以提供帮助,我将不胜感激!
ERROR! THREAD NAME: New I/O worker #1
java.io.WriteAbortedException: writing aborted; java.io.NotSerializableException: com.rs.game.player.content.construction.House
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.defaultReadFields(Unknown Source)
at java.io.ObjectInputStream.readSerialData(Unknown Source)
at java.io.ObjectInputStream.readOrdinaryObject(Unknown Source)
at java.io.ObjectInputStream.readObject0(Unknown Source)
at java.io.ObjectInputStream.readObject(Unknown Source)
at com.rs.utils.SerializableFilesManager.loadSerializedFile(SerializableFilesManager.java:67)
at com.rs.utils.SerializableFilesManager.loadPlayer(SerializableFilesManager.java:25)
at com.rs.net.decoders.LoginPacketsDecoder.decodeWorldLogin(LoginPacketsDecoder.java:184)
at com.rs.net.decoders.LoginPacketsDecoder.decode(LoginPacketsDecoder.java:51)
at com.rs.net.ServerChannelHandler.messageReceived(ServerChannelHandler.java:98)
at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:95)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:563)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:268)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:255)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:91)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.processSelectedKeys(AbstractNioWorker.java:373)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.run(AbstractNioWorker.java:247)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:35)
at org.jboss.netty.util.ThreadRenamingRunnable.run(ThreadRenamingRunnable.java:102)
at org.jboss.netty.util.internal.DeadLockProofWorker$1.run(DeadLockProofWorker.java:42)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
Caused by: java.io.NotSerializableException: com.rs.game.player.content.construction.House
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.defaultWriteFields(Unknown Source)
at java.io.ObjectOutputStream.writeSerialData(Unknown Source)
at java.io.ObjectOutputStream.writeOrdinaryObject(Unknown Source)
at java.io.ObjectOutputStream.writeObject0(Unknown Source)
at java.io.ObjectOutputStream.writeObject(Unknown Source)
at com.rs.utils.SerializableFilesManager.storeSerializableClass(SerializableFilesManager.java:76)
at com.rs.utils.SerializableFilesManager.savePlayer(SerializableFilesManager.java:53)
at com.rs.game.player.Player.realFinish(Player.java:1136)
at com.rs.game.player.Player.finish(Player.java:1116)
at com.rs.game.player.Player.finish(Player.java:1088)
at com.rs.net.ServerChannelHandler.channelDisconnected(ServerChannelHandler.java:76)
at org.jboss.netty.channel.SimpleChannelHandler.handleUpstream(SimpleChannelHandler.java:127)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:563)
at org.jboss.netty.channel.DefaultChannelPipeline.sendUpstream(DefaultChannelPipeline.java:558)
at org.jboss.netty.channel.Channels.fireChannelDisconnected(Channels.java:399)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.close(AbstractNioWorker.java:617)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.write0(AbstractNioWorker.java:526)
at org.jboss.netty.channel.socket.nio.AbstractNioWorker.writeFromUserCode(AbstractNioWorker.java:427)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.handleAcceptedSocket(NioServerSocketPipelineSink.java:127)
at org.jboss.netty.channel.socket.nio.NioServerSocketPipelineSink.eventSunk(NioServerSocketPipelineSink.java:66)
at org.jboss.netty.channel.DefaultChannelPipeline$DefaultChannelHandlerContext.sendDownstream(DefaultChannelPipeline.java:779)
at org.jboss.netty.channel.SimpleChannelHandler.writeRequested(SimpleChannelHandler.java:299)
at org.jboss.netty.channel.SimpleChannelHandler.handleDownstream(SimpleChannelHandler.java:261)
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:590)
at org.jboss.netty.channel.DefaultChannelPipeline.sendDownstream(DefaultChannelPipeline.java:581)
at org.jboss.netty.channel.Channels.write(Channels.java:712)
at org.jboss.netty.channel.Channels.write(Channels.java:679)
at org.jboss.netty.channel.AbstractChannel.write(AbstractChannel.java:246)
at com.rs.net.Session.write(Session.java:41)
at com.rs.net.encoders.WorldPacketsEncoder.sendMapRegion(WorldPacketsEncoder.java:880)
at com.rs.game.player.Player.loadMapRegions(Player.java:696)
at com.rs.game.player.Player.start(Player.java:613)
at com.rs.net.decoders.LoginPacketsDecoder.decodeWorldLogin(LoginPacketsDecoder.java:208)
... 16 more
我明白了,到目前为止我什么都没试过。
这是我的房子.java
package com.rs.game.player.content.construction;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import com.rs.game.DynamicRegion;
import com.rs.game.Region;
import com.rs.game.RegionBuilder;
import com.rs.game.World;
import com.rs.game.WorldObject;
import com.rs.game.WorldTile;
import com.rs.game.item.Item;
import com.rs.game.player.Player;
import com.rs.utils.Logger;
public class House {
private List<RoomReference> rooms;
private byte place, look;
private Player player;
public House(Player player) {
this.player = player;
rooms = player.getRooms();
place = (byte) player.getPlace(); //desert
}
public void refresh(Player player, int[] boundChuncks) {
player.setForceNextMapLoadRefresh(true);
constructHouse(boundChuncks, true);
player.loadMapRegions();
}
public void sendFurnitureInterface(Item[] items) {
player.getPackets().sendItems(396, items);
}
public void constructHouse(int[] boundChuncks, boolean buildMode) {
Logger.log(this, place);
Object[][][][] data = new Object[4][8][8][];
for(RoomReference reference : rooms) {
data[reference.getPlane()][reference.getX()][reference.getY()] =
new Object[] {reference.getRoom().getChunkX(), reference.getRoom().getChunkY(),
reference.getRotation(), reference.getRoom().isShowRoof()};
}
if(!buildMode) { //construct roof
for(int x = 1; x < 7; x++) {
skipY: for(int y = 1; y < 7; y++) {
for(int plane = 2; plane >= 0; plane--) {
if(data[plane][x][y] != null) {
boolean hasRoof = (boolean) data[plane][x][y][3];
if(hasRoof) {
byte rotation = (byte) data[plane][x][y][2];
//TODO find best Roof
data[plane+1][x][y] = new Object[] {
Roof.ROOF1.getChunkX(),
Roof.ROOF1.getChunkY(), rotation, true};
continue skipY;
}
}
}
}
}
}
for(int plane = 0; plane < data.length; plane++) {
for(int x = 0; x < data[plane].length; x++) {
for(int y = 0; y < data[plane][x].length; y++) {
if(data[plane][x][y] != null)
RegionBuilder.copyChunk((int)data[plane][x][y][0] +
((boolean)data[plane][x][y][3] && look >= 4 ? 8 : 0)
, (int)data[plane][x][y][1],
(boolean)data[plane][x][y][3] ? look % 4 : place
, boundChuncks[0]+x, boundChuncks[1]+y, plane,(byte)data[plane][x][y][2]);
else if (plane == 0)
RegionBuilder.copyChunk(LAND[0], LAND[1], place, boundChuncks[0]+x, boundChuncks[1]+y, plane, 0);
}
}
}
Region region = World.getRegion(RegionBuilder.getRegionHash(boundChuncks[0]/8, boundChuncks[1]/8));
List<WorldObject> spawnedObjects = region.getSpawnedObjects();
if(spawnedObjects != null)
spawnedObjects.clear();
List<WorldObject> removedObjects = region.getRemovedObjects();
if(removedObjects != null)
removedObjects.clear();
for(RoomReference reference : rooms) {
int boundX = reference.getX() * 8;
int boundY = reference.getY() * 8;
int boundX1 = boundChuncks[0] * 8;
int boundY1 = boundChuncks[1] * 8;
int chunkRotation = region.getRotation(reference.getPlane(), boundX, boundY);
for(int x = boundX; x < boundX+8; x++) {
for(int y = boundY; y < boundY+8; y++) {
WorldObject[] objects = region.getObjects(reference.getPlane(), x, y);
if(objects != null) {
for(WorldObject object : objects) {
/*
* Remove the build hotspots (not 100%)
*/
if(!buildMode && object.getDefinitions().containsOption("Build")) {
//object = new WorldObject(object.getId(), object.getType(), (object.getRotation() + chunkRotation) % 4, x + boundChuncks[0]*8,y + boundChuncks[1]*8, reference.getPlane());
if (object.getDefinitions().name.equalsIgnoreCase("door hotspot")) {
WorldObject object1 = new WorldObject(getDoorId(), object.getType(), object.getRotation() + 1, object.getX(), object.getY(), reference.getPlane());
World.removeObject(object, true);
}
else if (object.getDefinitions().name.equalsIgnoreCase("window space")) {
System.out.println(object.getId());
} else {
World.removeObject(object, true);
}
try {
System.out.println("spawning portal");
WorldObject o = new WorldObject(13405, 10, 4, boundChuncks[0]*8 + 35, boundChuncks[1]*8 + 35, 0);
World.spawnObject(o, true);
for (WorldObject o1 : player.getConObjectsToBeLoaded()) {
System.out.println(o1.getDefinitions().getOption(5));
World.spawnObject(o1, true);
}
} catch (NullPointerException e) {
e.printStackTrace();
}
}
/*
* Spawn the objects & the hotspots
*/
else if (object.getDefinitions().name.equals("Window")) {
object = new WorldObject(getWindowId(), object.getType(), (object.getRotation() + chunkRotation) % 4, x + boundChuncks[0]*8,y + boundChuncks[1]*8, reference.getPlane());
World.spawnObject(object, true);
}
else {
try {
for (WorldObject o1 : player.getConObjectsToBeLoaded()) {
World.spawnObject(o1, true);
}
WorldObject o = new WorldObject(13405, 10, 4, boundChuncks[0]*8 + 35, boundChuncks[1]*8 + 35, 0);
World.spawnObject(o, true);
} catch (NullPointerException e) {
System.out.println("Player objects are null");
e.printStackTrace();
}
}
}
}
}
}
}
}
public void previewRoom(Player player, int[] boundChuncks, RoomReference reference, boolean remove) {
int boundX = reference.getX() * 8;
int boundY = reference.getY() * 8;
Region region = World.getRegion(RegionBuilder.getRegionHash(reference.getRoom().getChunkX()/8, reference.getRoom().getChunkY()/8));
int boundX2 = (reference.getRoom().getChunkX() - (reference.getRoom().getChunkX() / 8 * 8)) * 8;
int boundY2 = (reference.getRoom().getChunkY() - (reference.getRoom().getChunkY() / 8 * 8)) * 8;
DynamicRegion house = (DynamicRegion) World.getRegion(RegionBuilder.getRegionHash(player.getBoundChuncks()[0]/8, player.getBoundChuncks()[1]/8));
house.getRegionCoords()[reference.getPlane()][reference.getX()][reference.getY()][3] = reference.getRotation();
for(int x = 0; x < 8; x++) {
for(int y = 0; y < 8; y++) {
WorldObject[] objects = region.getObjects(reference.getPlane(), boundX2+x, boundY2+y);
if(objects != null) {
for(WorldObject object : objects) {
if(object.getDefinitions().containsOption("Build")) {
System.out.println("test");
int x2 = x;
int y2 = y;
for (int rotate = 0; rotate < reference.getRotation(); rotate++) {
int fakeChunckX = x2;
int fakeChunckY = y2;
x2 = fakeChunckY;
y2 = 7 - fakeChunckX;
}
object = new WorldObject(object.getId(), object.getType(), (object.getRotation() + reference.getRotation()) % 4, boundX + x2 + boundChuncks[0]*8, boundY + y2 + boundChuncks[1]*8, reference.getPlane());
if(remove)
player.getPackets().sendDestroyObject(object);
else
player.getPackets().sendSpawnedObject(object);
}
}
}
}
}
}
public int getWindowId() {
switch(place) {
case 0:
return 13099;
case 1:
return 13115;
case 2:
return 0;
case 3:
return 0;
default:
return 13115;
}
}
public int getDoorId() {
switch(place) {
case 0:
return 13100;
default:
return 1058;
}
}
private static final int[] LAND = {233, 632};
}