Work on the tests and change up some performance issues.

1. In the player move event we looped through the jailed players more
than once which really is an issue when you have several hundred jailed
and since the move event is called several times a second, that was a
huge performance hit.
2. Don't save the prisoner data as soon as they are jailed, we take care
of that else where with the shutting down and counting down time.
This commit is contained in:
graywolf336
2014-05-30 15:54:11 -05:00
parent 45bd4ac8c1
commit 7ad5fedfd1
14 changed files with 196 additions and 71 deletions

View File

@ -357,10 +357,10 @@ public class JailIO {
j.setWorld(set.getString("world"));
j.setMaxPoint(new int[] { set.getInt("top.x"), set.getInt("top.y"), set.getInt("top.z") });
j.setMinPoint(new int[] { set.getInt("bottom.x"), set.getInt("bottom.y"), set.getInt("bottom.z") });
j.setTeleportIn(new SimpleLocation(j.getWorldName(), set.getDouble("tps.in.x"),
j.setTeleportIn(new Location(pl.getServer().getWorld(j.getWorldName()), set.getDouble("tps.in.x"),
set.getDouble("tps.in.y"), set.getDouble("tps.in.z"),
set.getFloat("tps.in.yaw"), set.getFloat("tps.in.pitch")));
j.setTeleportFree(new SimpleLocation(set.getString("tps.free.world"), set.getDouble("tps.free.x"),
j.setTeleportFree(new Location(pl.getServer().getWorld(j.getWorldName()), set.getDouble("tps.free.x"),
set.getDouble("tps.free.y"), set.getDouble("tps.free.z"),
set.getFloat("tps.free.yaw"), set.getFloat("tps.free.pitch")));
pl.getJailManager().addJail(j, false);
@ -551,15 +551,15 @@ public class JailIO {
j.setMaxPoint(new int[] {flat.getInt(node + "top.x"), flat.getInt(node + "top.y"), flat.getInt(node + "top.z")});
j.setMinPoint(new int[] {flat.getInt(node + "bottom.x"), flat.getInt(node + "bottom.y"), flat.getInt(node + "bottom.z")});
j.setTeleportIn(new SimpleLocation(
flat.getString(node + "world"),
j.setTeleportIn(new Location(
pl.getServer().getWorld(flat.getString(node + "world")),
flat.getDouble(node + "tps.in.x"),
flat.getDouble(node + "tps.in.y"),
flat.getDouble(node + "tps.in.z"),
(float) flat.getDouble(node + "tps.in.yaw"),
(float) flat.getDouble(node + "tps.in.pitch")));
j.setTeleportFree(new SimpleLocation(
flat.getString(node + "tps.free.world"),
j.setTeleportFree(new Location(
pl.getServer().getWorld(flat.getString(node + "world")),
flat.getDouble(node + "tps.free.x"),
flat.getDouble(node + "tps.free.y"),
flat.getDouble(node + "tps.free.z"),

View File

@ -38,6 +38,7 @@ public class JailMain extends JavaPlugin {
private JailTimer jt;
private PrisonerManager pm;
private ScoreBoardManager sbm;
private MoveProtectionListener mpl;
private boolean debug = false;
public void onEnable() {
@ -94,7 +95,8 @@ public class JailMain extends JavaPlugin {
//But doing this also forces people to restart their server if they to
//enable it after disabling it.
if(getConfig().getBoolean(Settings.MOVEPROTECTION.getPath())) {
plm.registerEvents(new MoveProtectionListener(this), this);
this.mpl = new MoveProtectionListener(this);
plm.registerEvents(this.mpl, this);
}
jt = new JailTimer(this);
@ -262,4 +264,8 @@ public class JailMain extends JavaPlugin {
public void debug(String message) {
if(inDebug()) getLogger().info("[Debug]: " + message);
}
public MoveProtectionListener getPlayerMoveListener() {
return this.mpl;
}
}

View File

@ -74,9 +74,6 @@ public class PrisonerManager {
cell.setPrisoner(prisoner);
}
//Save the jail after adding them to the jail
pl.getJailIO().saveJail(jail);
//If they are NOT offline, jail them
if(!prisoner.isOfflinePending()) {
jailPrisoner(jail, cell, player, prisoner);

View File

@ -25,7 +25,7 @@ public class Jail {
private HashMap<UUID, Prisoner> nocellPrisoners;//prisoners who aren't in a cell
private String name = "", world = "";
private int minX, minY, minZ, maxX, maxY, maxZ;
private SimpleLocation in, free;
private Location in, free;
public Jail(JailMain plugin, String name) {
this.plugin = plugin;
@ -110,26 +110,26 @@ public class Jail {
return plugin.getServer().getWorld(world);
}
/** Sets the {@link SimpleLocation location} of the teleport <strong>in</strong>. */
public void setTeleportIn(SimpleLocation location) {
if(this.world.isEmpty()) this.world = location.getWorldName();
/** Sets the {@link Location location} of the teleport <strong>in</strong>. */
public void setTeleportIn(Location location) {
if(this.world.isEmpty()) this.world = location.getWorld().getName();
this.in = location;
}
/** Gets the {@link Location location} of the teleport in. */
public Location getTeleportIn() {
return this.in.getLocation();
return this.in;
}
/** Sets the {@link SimpleLocation location} of the teleport for the <strong>free</strong> spot. */
public void setTeleportFree(SimpleLocation location) {
/** Sets the {@link Location location} of the teleport for the <strong>free</strong> spot. */
public void setTeleportFree(Location location) {
this.free = location;
}
/** Gets the {@link Location location} of the teleport free spot.*/
public Location getTeleportFree() {
return this.free.getLocation();
return this.free;
}
/** Add a prisoner to this jail. */

View File

@ -92,8 +92,8 @@ public class OldInputOutput {
j.setWorld(teleWorld);
j.setMaxPoint(new Location(pl.getServer().getWorld(teleWorld), X1, Y1, Z1));
j.setMinPoint(new Location(pl.getServer().getWorld(teleWorld), X2, Y2, Z2));
j.setTeleportIn(new SimpleLocation(teleWorld, teleX, teleY, teleZ));
j.setTeleportFree(new SimpleLocation(freeWorld, freeX, freeY, freeZ));
j.setTeleportIn(new Location(pl.getServer().getWorld(teleWorld), teleX, teleY, teleZ));
j.setTeleportFree(new Location(pl.getServer().getWorld(freeWorld), freeX, freeY, freeZ));
pl.getJailManager().addJail(j, false);
}

View File

@ -46,7 +46,7 @@ public class MoveProtectionListener implements Listener {
if (!j.isInside(event.getTo())) {
try {
long add = Util.getTime(pl.getConfig().getString(Settings.MOVEPENALTY.getPath()));
pl.getJailManager().getPrisoner(event.getPlayer().getUniqueId()).addTime(add);
p.addTime(add);
String msg = "";
if(add == 0L) {

View File

@ -134,8 +134,8 @@ public class JailCreationSteps {
jail.setMinPoint(cp.getCornerOne());
jail.setMaxPoint(cp.getCornerTwo());
jail.setTeleportIn(cp.getTeleportInSL());
jail.setTeleportFree(cp.getTeleportFreeSL());
jail.setTeleportIn(cp.getTeleportInSL().getLocation());
jail.setTeleportFree(cp.getTeleportFreeSL().getLocation());
jm.addJail(jail, true);