62fed83e2f
Started rewriting our packet handling code. Deleted PacketHandler in favor of using sided (Server-, Client-) packet handlers to make it easier to follow what's going on in our code. Added some event-based handling of updates which greatly simplified signaling that data needs to be sent, but it's not completely done yet.
73 lines
No EOL
1.7 KiB
Java
73 lines
No EOL
1.7 KiB
Java
package StevenDimDoors.mod_pocketDim.dungeon;
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
import StevenDimDoors.mod_pocketDim.dungeon.pack.DungeonType;
|
|
import StevenDimDoors.mod_pocketDim.helpers.DungeonHelper;
|
|
import StevenDimDoors.mod_pocketDim.schematic.InvalidSchematicException;
|
|
|
|
public class DungeonData
|
|
{
|
|
private final int weight;
|
|
private final boolean isOpen;
|
|
private final boolean isInternal;
|
|
private final String schematicPath;
|
|
private final String schematicName;
|
|
private final DungeonType dungeonType;
|
|
|
|
public DungeonData(String schematicPath, boolean isInternal, DungeonType dungeonType, boolean isOpen, int weight)
|
|
{
|
|
this.schematicPath = schematicPath;
|
|
this.schematicName = getSchematicName(schematicPath);
|
|
this.dungeonType = dungeonType;
|
|
this.isInternal = isInternal;
|
|
this.isOpen = isOpen;
|
|
this.weight = weight;
|
|
}
|
|
|
|
private static String getSchematicName(String schematicPath)
|
|
{
|
|
int indexA = schematicPath.lastIndexOf('\\');
|
|
int indexB = schematicPath.lastIndexOf('/');
|
|
indexA = Math.max(indexA, indexB) + 1;
|
|
|
|
return schematicPath.substring(indexA, schematicPath.length() - DungeonHelper.SCHEMATIC_FILE_EXTENSION.length() - indexA);
|
|
}
|
|
|
|
public int weight()
|
|
{
|
|
return weight;
|
|
}
|
|
|
|
public boolean isOpen()
|
|
{
|
|
return isOpen;
|
|
}
|
|
|
|
public String schematicPath()
|
|
{
|
|
return schematicPath;
|
|
}
|
|
|
|
public DungeonType dungeonType()
|
|
{
|
|
return dungeonType;
|
|
}
|
|
|
|
public String schematicName()
|
|
{
|
|
return schematicName;
|
|
}
|
|
|
|
public DungeonSchematic loadSchematic() throws InvalidSchematicException, FileNotFoundException
|
|
{
|
|
if (isInternal)
|
|
{
|
|
return DungeonSchematic.readFromResource(schematicPath);
|
|
}
|
|
else
|
|
{
|
|
return DungeonSchematic.readFromFile(schematicPath);
|
|
}
|
|
}
|
|
} |