optimizations

This commit is contained in:
boy0001 2015-03-24 16:55:38 +11:00
parent 98232107f9
commit 336b22303f
3 changed files with 15 additions and 19 deletions

View File

@ -802,15 +802,15 @@ public class SQLManager implements AbstractDB {
}
@Override
public void movePlot(final String world, final PlotId originalPlot, final PlotId newPlot) {
public void movePlot(Plot original, final Plot newPlot) {
TaskManager.runTaskAsync(new Runnable() {
@Override
public void run() {
try {
final int id = getId(world, originalPlot);
final int id = getId(original.world, original.id);
final PreparedStatement stmt = SQLManager.this.connection.prepareStatement("UPDATE `" + SQLManager.this.prefix + "plot` SET `plot_id_x` = ?, `plot_id_z` = ? WHERE `id` = ?");
stmt.setInt(1, newPlot.x);
stmt.setInt(2, newPlot.y);
stmt.setInt(1, newPlot.id.x);
stmt.setInt(2, newPlot.id.y);
stmt.setInt(3, id);
stmt.executeUpdate();
stmt.close();

View File

@ -11,6 +11,7 @@ import org.bukkit.plugin.Plugin;
import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.api.PlotAPI;
import com.intellectualcrafters.plot.config.C;
import com.intellectualcrafters.plot.object.ChunkLoc;
import com.intellectualcrafters.plot.object.PlotBlock;

View File

@ -949,12 +949,12 @@ public class BukkitChunkManager extends ChunkManager {
int X = chunk.getX();
int Z = chunk.getX();
Entity[] ents = chunk.getEntities();
if (X == bx || X == tx || Z == bz || Z == tz) {
for (final Entity entity : ents) {
if (!(entity instanceof Creature)) {
continue;
}
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
for (final Entity entity : ents) {
if (!(entity instanceof Creature)) {
continue;
}
if (X == bx || X == tx || Z == bz || Z == tz) {
final PlotId id = MainUtil.getPlotId(BukkitUtil.getLocation(entity));
if (plot.id.equals(id)) {
count[0]++;
if (entity instanceof Animals) {
@ -964,21 +964,16 @@ public class BukkitChunkManager extends ChunkManager {
count[2]++;
}
}
}
}
else {
for (final Entity entity : ents) {
if (!(entity instanceof Creature)) {
continue;
}
count[0]++;
}
else {
count[0]++;
if (entity instanceof Animals) {
count[1]++;
}
else {
count[2]++;
}
}
}
}
}
}