Fix the build

This commit is contained in:
Bradley Hilton 2019-04-15 12:29:00 -05:00
parent e75e735cef
commit eb92967e03
2 changed files with 45 additions and 11 deletions

View File

@ -773,7 +773,6 @@ public class JailIO {
long st = System.currentTimeMillis(); long st = System.currentTimeMillis();
try { try {
if(con == null) this.prepareStorage(false);
PreparedStatement ps = getConnection().prepareStatement("REPLACE INTO " PreparedStatement ps = getConnection().prepareStatement("REPLACE INTO "
+ prefix + "jails (`name`, `world`, `top.x`, `top.y`, `top.z`, `bottom.x`, `bottom.y`," + prefix + "jails (`name`, `world`, `top.x`, `top.y`, `top.z`, `bottom.x`, `bottom.y`,"
+ "`bottom.z`, `tps.in.x`, `tps.in.y`, `tps.in.z`, `tps.in.yaw`, `tps.in.pitch`," + "`bottom.z`, `tps.in.x`, `tps.in.y`, `tps.in.z`, `tps.in.yaw`, `tps.in.pitch`,"
@ -996,10 +995,15 @@ public class JailIO {
case 1: case 1:
case 2: case 2:
try { try {
Connection con = getConnection();
if (con == null) {
break;
}
pl.debug("Saving the cell " + c.getName()); pl.debug("Saving the cell " + c.getName());
boolean hasId = c.getDatabaseID() != -1; boolean hasId = c.getDatabaseID() != -1;
PreparedStatement cPS = getConnection().prepareStatement((hasId ? "REPLACE" : "INSERT") PreparedStatement cPS = con.prepareStatement((hasId ? "REPLACE" : "INSERT")
+ " INTO `" + prefix + "cells` (" + (hasId ? "`cellid`, " : "") + " INTO `" + prefix + "cells` (" + (hasId ? "`cellid`, " : "")
+ "`name`, `jail`, `tp.x`, `tp.y`, `tp.z`, `tp.yaw`," + "`name`, `jail`, `tp.x`, `tp.y`, `tp.z`, `tp.yaw`,"
+ "`tp.pitch`, `chest.x`, `chest.y`, `chest.z`, `signs`) VALUES (" + "`tp.pitch`, `chest.x`, `chest.y`, `chest.z`, `signs`) VALUES ("
@ -1030,7 +1034,7 @@ public class JailIO {
if(c.hasPrisoner()) { if(c.hasPrisoner()) {
Prisoner p = c.getPrisoner(); Prisoner p = c.getPrisoner();
PreparedStatement pPS = getConnection().prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`," PreparedStatement pPS = con.prepareStatement("REPLACE INTO `" + prefix + "prisoners` (`uuid`, `name`, `jail`, `cell`, `muted`, `time`,"
+ "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)"); + "`offlinePending`, `toBeTransferred`, `jailer`, `reason`, `inventory`, `armor`, `previousLocation`, `previousGameMode`) VALUES (?,?,?,?,?,?,?,?,?,?,?,?,?,?)");
pPS.setString(1, p.getUUID().toString()); pPS.setString(1, p.getUUID().toString());
pPS.setString(2, p.getLastKnownName()); pPS.setString(2, p.getLastKnownName());
@ -1087,7 +1091,12 @@ public class JailIO {
case 1: case 1:
case 2: case 2:
try { try {
PreparedStatement pp = getConnection().prepareStatement("delete from `" + prefix + "prisoners` where uuid = ?"); Connection con = getConnection();
if (con == null) {
break;
}
PreparedStatement pp = con.prepareStatement("delete from `" + prefix + "prisoners` where uuid = ?");
pp.setString(1, p.getUUID().toString()); pp.setString(1, p.getUUID().toString());
pl.debug("Removing " + p.getLastKnownName() + " (" + p.getUUID().toString() + ") from " + (storage == 2 ? "MySQL" : "SQLite") + " database."); pl.debug("Removing " + p.getLastKnownName() + " (" + p.getUUID().toString() + ") from " + (storage == 2 ? "MySQL" : "SQLite") + " database.");
@ -1134,7 +1143,12 @@ public class JailIO {
switch(storage) { switch(storage) {
case 1: case 1:
try { try {
PreparedStatement p = getConnection().prepareStatement("delete from `" + prefix + "cells` where name = ? and jail = ?;"); Connection con = getConnection();
if (con == null) {
break;
}
PreparedStatement p = con.prepareStatement("delete from `" + prefix + "cells` where name = ? and jail = ?;");
p.setString(1, c.getName()); p.setString(1, c.getName());
p.setString(2, j.getName()); p.setString(2, j.getName());
@ -1148,7 +1162,12 @@ public class JailIO {
break; break;
case 2: case 2:
try { try {
PreparedStatement p = getConnection().prepareStatement("delete from `" + prefix + "cells` where name = ? and jail = ? limit 1;"); Connection con = getConnection();
if (con == null) {
break;
}
PreparedStatement p = con.prepareStatement("delete from `" + prefix + "cells` where name = ? and jail = ? limit 1;");
p.setString(1, c.getName()); p.setString(1, c.getName());
p.setString(2, j.getName()); p.setString(2, j.getName());
@ -1192,7 +1211,12 @@ public class JailIO {
} }
try { try {
PreparedStatement p = getConnection().prepareStatement("delete from `" + prefix + "jails` where name = ?"); Connection c = getConnection();
if (c == null) {
break;
}
PreparedStatement p = c.prepareStatement("delete from `" + prefix + "jails` where name = ?");
p.setString(1, name); p.setString(1, name);
p.executeUpdate(); p.executeUpdate();
@ -1233,7 +1257,12 @@ public class JailIO {
break; break;
case 2: case 2:
try { try {
PreparedStatement p = getConnection().prepareStatement("insert into `" + prefix + "records` (`uuid`, `username`, `jailer`, `date`, `time`, `reason`) VALUES (?,?,?,?,?,?);"); Connection c = getConnection();
if (c == null) {
break;
}
PreparedStatement p = c.prepareStatement("insert into `" + prefix + "records` (`uuid`, `username`, `jailer`, `date`, `time`, `reason`) VALUES (?,?,?,?,?,?);");
p.setString(1, uuid); p.setString(1, uuid);
p.setString(2, username); p.setString(2, username);
p.setString(3, jailer); p.setString(3, jailer);
@ -1284,7 +1313,12 @@ public class JailIO {
break; break;
case 2: case 2:
try { try {
PreparedStatement ps = getConnection().prepareStatement("SELECT * FROM " + prefix + "records where uuid = ?"); Connection c = getConnection();
if (c == null) {
break;
}
PreparedStatement ps = c.prepareStatement("SELECT * FROM " + prefix + "records where uuid = ?");
ps.setString(1, uuid.toString()); ps.setString(1, uuid.toString());
ResultSet set = ps.executeQuery(); ResultSet set = ps.executeQuery();

View File

@ -29,7 +29,7 @@ public class TestUtilClass {
list.add(Material.WHEAT_SEEDS.toString()); list.add(Material.WHEAT_SEEDS.toString());
list.add("coal_ore"); list.add("coal_ore");
list.add("torch"); list.add("torch");
array = new String[] { Material.SEEDS.toString(), "coal_ore", "torch" }; array = new String[] { Material.WHEAT_SEEDS.toString(), "coal_ore", "torch" };
bottomCorner = new Vector(-10.50, 50.25, 100.00); bottomCorner = new Vector(-10.50, 50.25, 100.00);
topCorner = new Vector(50, 100, 250); topCorner = new Vector(50, 100, 250);
} }
@ -67,7 +67,7 @@ public class TestUtilClass {
@Test @Test
public void testInArray() { public void testInArray() {
assertTrue(Util.isStringInsideArray("seeds", array)); assertTrue(Util.isStringInsideArray("wheat_seeds", array));
assertTrue(Util.isStringInsideArray(Material.COAL_ORE.toString(), array)); assertTrue(Util.isStringInsideArray(Material.COAL_ORE.toString(), array));
assertTrue(Util.isStringInsideArray("tOrCh", array)); assertTrue(Util.isStringInsideArray("tOrCh", array));
} }