Finish loading cells and check for chest when we are removing a cell.
This commit is contained in:
parent
3a6a76a86c
commit
262f1dc4f9
@ -366,18 +366,27 @@ public class JailIO {
|
|||||||
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "cells");
|
PreparedStatement ps = con.prepareStatement("SELECT * FROM " + prefix + "cells");
|
||||||
ResultSet set = ps.executeQuery();
|
ResultSet set = ps.executeQuery();
|
||||||
|
|
||||||
List<Integer> remove = new LinkedList<Integer>(); //TODO: Set up something to remove these
|
//This list contains an integer which refers to the cellid column in sql
|
||||||
|
//this list only gets populated if there are cells which reference a jail
|
||||||
|
//that doesn't exist anymore
|
||||||
|
//TODO: Implement this
|
||||||
|
List<Integer> remove = new LinkedList<Integer>();
|
||||||
|
|
||||||
while(set.next()) {
|
while(set.next()) {
|
||||||
Jail j = pl.getJailManager().getJail(set.getString("jail"));
|
Jail j = pl.getJailManager().getJail(set.getString("jail"));
|
||||||
|
|
||||||
if(j != null) {
|
if(j != null) {
|
||||||
Cell c = new Cell(set.getString("name"));
|
Cell c = new Cell(set.getString("name"));
|
||||||
c.setTeleport(new SimpleLocation(j.getWorldName(), set.getDouble("tp.x"),
|
c.setTeleport(new SimpleLocation(j.getWorldName(), set.getDouble("tp.x"), set.getDouble("tp.y"), set.getDouble("tp.z"),
|
||||||
set.getDouble("tp.y"), set.getDouble("tp.z"),
|
|
||||||
set.getFloat("tp.yaw"), set.getFloat("tp.pitch")));
|
set.getFloat("tp.yaw"), set.getFloat("tp.pitch")));
|
||||||
|
|
||||||
//TODO: Finish loading the cells and fix the sql requiring everything, whoops
|
c.setChestLocation(new Location(j.getWorld(), set.getInt("chest.x"), set.getInt("chest.y"), set.getInt("chest.z")));
|
||||||
|
|
||||||
|
String[] signs = set.getString("signs").split(";");
|
||||||
|
for(String s : signs) {
|
||||||
|
String[] co = s.split(",");
|
||||||
|
c.addSign(new SimpleLocation(co[0], co[1], co[2], co[4]));
|
||||||
|
}
|
||||||
|
|
||||||
j.addCell(c, false);
|
j.addCell(c, false);
|
||||||
}else {
|
}else {
|
||||||
|
@ -160,11 +160,14 @@ public class Jail {
|
|||||||
|
|
||||||
/** Removes the cell from the jail. */
|
/** Removes the cell from the jail. */
|
||||||
public void removeCell(String name) {
|
public void removeCell(String name) {
|
||||||
//Clear the chest and reset the sign
|
Cell c = this.cells.get(name);
|
||||||
this.cells.get(name).getChest().getInventory().clear();
|
//If we have a chest, clear the inventory
|
||||||
|
if(c.hasChest()) {
|
||||||
|
c.getChest().getInventory().clear();
|
||||||
|
}
|
||||||
|
|
||||||
//For each sign, clear the lines on the sign
|
//For each sign, clear the lines on the sign
|
||||||
for(SimpleLocation s : this.cells.get(name).getSigns()) {
|
for(SimpleLocation s : c.getSigns()) {
|
||||||
if(s.getLocation().getBlock() instanceof Sign) {
|
if(s.getLocation().getBlock() instanceof Sign) {
|
||||||
Sign sign = (Sign) s.getLocation().getBlock();
|
Sign sign = (Sign) s.getLocation().getBlock();
|
||||||
for(int i = 0; i < 4; i++) {
|
for(int i = 0; i < 4; i++) {
|
||||||
@ -174,7 +177,7 @@ public class Jail {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//remove the information from the storage first as it requires an instance
|
//remove the information from the storage first as it requires an instance
|
||||||
plugin.getJailIO().removeCell(this, this.cells.remove(name));
|
plugin.getJailIO().removeCell(this, c);
|
||||||
//now remove it from the local storage
|
//now remove it from the local storage
|
||||||
this.cells.remove(name);
|
this.cells.remove(name);
|
||||||
}
|
}
|
||||||
|
@ -49,6 +49,23 @@ public class SimpleLocation {
|
|||||||
this.pitch = location.getPitch();
|
this.pitch = location.getPitch();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new Simple Location with all the inputs being in string.
|
||||||
|
*
|
||||||
|
* @param world the name of the world
|
||||||
|
* @param x coordinate as a string
|
||||||
|
* @param y coordinate as a string
|
||||||
|
* @param z coordinate as a string
|
||||||
|
*/
|
||||||
|
public SimpleLocation(String world, String x, String y, String z) {
|
||||||
|
this.world = world;
|
||||||
|
this.x = Double.valueOf(x);
|
||||||
|
this.y = Double.valueOf(y);
|
||||||
|
this.z = Double.valueOf(z);
|
||||||
|
this.yaw = 0;
|
||||||
|
this.pitch = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/** Returns the instance from Bukkit of the world this location is in. */
|
/** Returns the instance from Bukkit of the world this location is in. */
|
||||||
public World getWorld() {
|
public World getWorld() {
|
||||||
return Bukkit.getWorld(world);
|
return Bukkit.getWorld(world);
|
||||||
|
Loading…
Reference in New Issue
Block a user