This commit is contained in:
boy0001 2015-02-23 11:33:48 +11:00
parent d1e9ccb3e8
commit 430f4fca41
12 changed files with 49 additions and 51 deletions

View File

@ -300,7 +300,6 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} catch (final Throwable e) { } catch (final Throwable e) {
MainUtil.canSendChunk = false; MainUtil.canSendChunk = false;
} }
System.out.print("SET BLOCK MANAGER");
return BlockManager.manager = new BukkitUtil(); return BlockManager.manager = new BukkitUtil();
} }

View File

@ -721,7 +721,7 @@ public class PlotSquared {
setupStyle(); setupStyle();
} catch (final Exception err) { } catch (final Exception err) {
Logger.add(LogLevel.DANGER, "Failed to save style.yml"); Logger.add(LogLevel.DANGER, "Failed to save style.yml");
System.out.println("failed to save style.yml"); log("failed to save style.yml");
} }
try { try {
configFile = new File(IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml"); configFile = new File(IMP.getDirectory() + File.separator + "config" + File.separator + "settings.yml");
@ -734,7 +734,7 @@ public class PlotSquared {
setupConfig(); setupConfig();
} catch (final Exception err_trans) { } catch (final Exception err_trans) {
Logger.add(LogLevel.DANGER, "Failed to save settings.yml"); Logger.add(LogLevel.DANGER, "Failed to save settings.yml");
System.out.println("Failed to save settings.yml"); log("Failed to save settings.yml");
} }
try { try {
storageFile = new File(IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml"); storageFile = new File(IMP.getDirectory() + File.separator + "config" + File.separator + "storage.yml");
@ -747,7 +747,7 @@ public class PlotSquared {
setupStorage(); setupStorage();
} catch (final Exception err_trans) { } catch (final Exception err_trans) {
Logger.add(LogLevel.DANGER, "Failed to save storage.yml"); Logger.add(LogLevel.DANGER, "Failed to save storage.yml");
System.out.println("Failed to save storage.yml"); log("Failed to save storage.yml");
} }
try { try {
style.save(styleFile); style.save(styleFile);

View File

@ -92,7 +92,7 @@ public class DebugClear extends SubCommand {
final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1); final Location pos1 = MainUtil.getPlotBottomLoc(loc.getWorld(), plot.id).add(1, 0, 1);
final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id); final Location pos2 = MainUtil.getPlotTopLoc(loc.getWorld(), plot.id);
if (MainUtil.runners.containsKey(plot)) { if (MainUtil.runners.containsKey(plot)) {
MainUtil.sendMessage(null, C.WAIT_FOR_TIMER); MainUtil.sendMessage(plr, C.WAIT_FOR_TIMER);
return false; return false;
} }
MainUtil.runners.put(plot, 1); MainUtil.runners.put(plot, 1);

View File

@ -84,7 +84,6 @@ public class MainCommand {
} }
final List<String> help = new ArrayList<>(); final List<String> help = new ArrayList<>();
help.add(C.HELP_HEADER.s()); help.add(C.HELP_HEADER.s());
System.out.print(C.HELP_HEADER.s());
// HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"), // HELP_CATEGORY("&cCategory: &6%category%&c, Page: %current%&c/&6%max%&c, Displaying: &6%dis%&c/&6%total%"),
help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size())); help.add(C.HELP_CATEGORY.s().replace("%category%", category == null ? "All" : category.toString()).replace("%current%", "" + (page + 1)).replace("%max%", "" + (totalPages + 1)).replace("%dis%", "" + (commands.size() % perPage)).replace("%total%", "" + commands.size()));
SubCommand cmd; SubCommand cmd;

View File

@ -128,7 +128,7 @@ public class Trim extends SubCommand {
final ChunkLoc loc = new ChunkLoc(x, z); final ChunkLoc loc = new ChunkLoc(x, z);
empty.add(loc); empty.add(loc);
} catch (final Exception e) { } catch (final Exception e) {
System.out.print("INVALID MCA: " + name); PlotSquared.log("INVALID MCA: " + name);
} }
} else { } else {
final Path path = Paths.get(file.getPath()); final Path path = Paths.get(file.getPath());
@ -145,7 +145,7 @@ public class Trim extends SubCommand {
final ChunkLoc loc = new ChunkLoc(x, z); final ChunkLoc loc = new ChunkLoc(x, z);
empty.add(loc); empty.add(loc);
} catch (final Exception e) { } catch (final Exception e) {
System.out.print("INVALID MCA: " + name); PlotSquared.log("INVALID MCA: " + name);
} }
} }
} catch (final Exception e) { } catch (final Exception e) {
@ -180,7 +180,6 @@ public class Trim extends SubCommand {
while ((System.currentTimeMillis() - start) < 50) { while ((System.currentTimeMillis() - start) < 50) {
if (plots.size() == 0) { if (plots.size() == 0) {
empty.addAll(chunks); empty.addAll(chunks);
System.out.print("DONE!");
Trim.TASK = false; Trim.TASK = false;
TaskManager.runTaskAsync(whenDone); TaskManager.runTaskAsync(whenDone);
PlotSquared.TASK.cancelTask(Trim.TASK_ID); PlotSquared.TASK.cancelTask(Trim.TASK_ID);

View File

@ -83,6 +83,7 @@ public class HybridPlotManager extends ClassicPlotManager {
@Override @Override
public void run() { public void run() {
MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor); MainUtil.setCuboid(world, new Location(world, pos1.getX(), dpw.PLOT_HEIGHT, pos1.getZ()), new Location(world, pos2.getX() + 1, dpw.PLOT_HEIGHT + 1, pos2.getZ() + 1), plotfloor);
TaskManager.runTask(whenDone);
} }
}, 5); }, 5);
} }

View File

@ -87,7 +87,6 @@ public class HybridPlotWorld extends ClassicPlotWorld {
PlotSquared.log("&c - road schematics are disabled for this world."); PlotSquared.log("&c - road schematics are disabled for this world.");
this.ROAD_SCHEMATIC_ENABLED = false; this.ROAD_SCHEMATIC_ENABLED = false;
} }
System.out.print("LOADED!");
} }
public void setupSchematics() { public void setupSchematics() {

View File

@ -9,13 +9,13 @@ public abstract class TaskManager {
public abstract int taskRepeat(final Runnable r, int interval); public abstract int taskRepeat(final Runnable r, int interval);
public abstract int taskAsync(final Runnable r); public abstract void taskAsync(final Runnable r);
public abstract int task(final Runnable r); public abstract void task(final Runnable r);
public abstract int taskLater(final Runnable r, int delay); public abstract void taskLater(final Runnable r, int delay);
public abstract int taskLaterAsync(final Runnable r, int delay); public abstract void taskLaterAsync(final Runnable r, int delay);
public abstract void cancelTask(int task); public abstract void cancelTask(int task);
@ -26,31 +26,27 @@ public abstract class TaskManager {
return -1; return -1;
} }
public static int runTaskAsync(final Runnable r) { public static void runTaskAsync(final Runnable r) {
if (r != null) { if (r != null) {
return PlotSquared.TASK.taskAsync(r); PlotSquared.TASK.taskAsync(r);
} }
return -1;
} }
public static int runTask(final Runnable r) { public static void runTask(final Runnable r) {
if (r != null) { if (r != null) {
return PlotSquared.TASK.task(r); PlotSquared.TASK.task(r);
} }
return -1;
} }
public static int runTaskLater(final Runnable r, final int delay) { public static void runTaskLater(final Runnable r, final int delay) {
if (r != null) { if (r != null) {
return PlotSquared.TASK.taskLater(r, delay); PlotSquared.TASK.taskLater(r, delay);
} }
return -1;
} }
public static int runTaskLaterAsync(final Runnable r, final int delay) { public static void runTaskLaterAsync(final Runnable r, final int delay) {
if (r != null) { if (r != null) {
return PlotSquared.TASK.taskLaterAsync(r, delay); PlotSquared.TASK.taskLaterAsync(r, delay);
} }
return -1;
} }
} }

View File

@ -1,6 +1,7 @@
package com.intellectualcrafters.plot.util.bukkit; package com.intellectualcrafters.plot.util.bukkit;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.scheduler.BukkitTask;
import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.BukkitMain;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
@ -12,23 +13,23 @@ public class BukkitTaskManager extends TaskManager {
} }
@Override @Override
public int taskAsync(final Runnable r) { public void taskAsync(final Runnable r) {
return BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId(); BukkitMain.THIS.getServer().getScheduler().runTaskAsynchronously(BukkitMain.THIS, r).getTaskId();
} }
@Override @Override
public int task(final Runnable r) { public void task(final Runnable r) {
return BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId(); BukkitMain.THIS.getServer().getScheduler().runTask(BukkitMain.THIS, r).getTaskId();
} }
@Override @Override
public int taskLater(final Runnable r, final int delay) { public void taskLater(final Runnable r, final int delay) {
return BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId(); BukkitMain.THIS.getServer().getScheduler().runTaskLater(BukkitMain.THIS, r, delay).getTaskId();
} }
@Override @Override
public int taskLaterAsync(final Runnable r, final int delay) { public void taskLaterAsync(final Runnable r, final int delay) {
return BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay).getTaskId(); BukkitTask runnable = BukkitMain.THIS.getServer().getScheduler().runTaskLaterAsynchronously(BukkitMain.THIS, r, delay);
} }
@Override @Override

View File

@ -151,10 +151,10 @@ public class ChunkManager extends AChunkManager {
final int relZ = newPos.getZ() - pos1.getZ(); final int relZ = newPos.getZ() - pos1.getZ();
final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ()); final RegionWrapper region = new RegionWrapper(pos1.getX(), pos2.getX(), pos1.getZ(), pos2.getZ());
final World world = Bukkit.getWorld(pos1.getWorld()); final World world = Bukkit.getWorld(pos1.getWorld());
final Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); final Chunk c1 = world.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4);
final Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); final Chunk c2 = world.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4);
final Chunk c3 = world.getChunkAt((pos1.getX() + relX), (pos1.getZ() + relZ)); final Chunk c3 = world.getChunkAt((pos1.getX() + relX) >> 4, (pos1.getZ() + relZ) >> 4);
final Chunk c4 = world.getChunkAt((pos2.getX() + relX), (pos2.getZ() + relZ)); final Chunk c4 = world.getChunkAt((pos2.getX() + relX) >> 4, (pos2.getZ() + relZ) >> 4);
final int sx = pos1.getX(); final int sx = pos1.getX();
final int sz = pos1.getZ(); final int sz = pos1.getZ();
final int ex = pos2.getX(); final int ex = pos2.getX();
@ -172,7 +172,7 @@ public class ChunkManager extends AChunkManager {
// Load chunks // Load chunks
for (int x = c1x; x <= c2x; x++) { for (int x = c1x; x <= c2x; x++) {
for (int z = c1z; z <= c2z; z++) { for (int z = c1z; z <= c2z; z++) {
final Chunk chunk = world.getChunkAt(x << 4, z << 4); final Chunk chunk = world.getChunkAt(x, z);
toGenerate.add(chunk); toGenerate.add(chunk);
} }
} }
@ -210,24 +210,24 @@ public class ChunkManager extends AChunkManager {
public void run() { public void run() {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
while ((System.currentTimeMillis() - start) < 25) { while ((System.currentTimeMillis() - start) < 25) {
final int x = mx.intValue(); final int xv = mx.intValue();
for (int z = sz; z <= ez; z++) { for (int z = sz; z <= ez; z++) {
saveBlocks(world, maxY, x, z); saveBlocks(world, maxY, xv, z);
for (int y = 1; y <= maxY; y++) { for (int y = 1; y <= maxY; y++) {
final Block block = world.getBlockAt(x, y, z); final Block block = world.getBlockAt(xv, y, z);
final int id = block.getTypeId(); final int id = block.getTypeId();
final byte data = block.getData(); final byte data = block.getData();
SetBlockManager.setBlockManager.set(world, x + relX, y, z + relZ, id, data); SetBlockManager.setBlockManager.set(world, xv + relX, y, z + relZ, id, data);
} }
} }
mx.increment(); mx.increment();
if (x == ex) { // done! if (xv == ex) { // done!
restoreBlocks(world, relX, relZ); restoreBlocks(world, relX, relZ);
SetBlockManager.setBlockManager.update(chunks); SetBlockManager.setBlockManager.update(chunks);
for (final Chunk chunk : chunks) { for (final Chunk chunk : chunks) {
chunk.unload(true, true); chunk.unload(true, true);
} }
TaskManager.runTaskLater(whenDone, 1); TaskManager.runTask(whenDone);
Bukkit.getScheduler().cancelTask(tasks.get(currentIndex)); Bukkit.getScheduler().cancelTask(tasks.get(currentIndex));
tasks.remove(currentIndex); tasks.remove(currentIndex);
return; return;
@ -256,8 +256,8 @@ public class ChunkManager extends AChunkManager {
index.increment(); index.increment();
final Plugin plugin = BukkitMain.THIS; final Plugin plugin = BukkitMain.THIS;
final World world = Bukkit.getWorld(pos1.getWorld()); final World world = Bukkit.getWorld(pos1.getWorld());
final Chunk c1 = world.getChunkAt(pos1.getX(), pos1.getZ()); final Chunk c1 = world.getChunkAt(pos1.getX() >> 4, pos1.getZ() >> 4);
final Chunk c2 = world.getChunkAt(pos2.getX(), pos2.getZ()); final Chunk c2 = world.getChunkAt(pos2.getX() >> 4, pos2.getZ() >> 4);
final int sx = pos1.getX(); final int sx = pos1.getX();
final int sz = pos1.getZ(); final int sz = pos1.getZ();
final int ex = pos2.getX(); final int ex = pos2.getX();
@ -266,6 +266,7 @@ public class ChunkManager extends AChunkManager {
final int c1z = c1.getZ(); final int c1z = c1.getZ();
final int c2x = c2.getX(); final int c2x = c2.getX();
final int c2z = c2.getZ(); final int c2z = c2.getZ();
final ArrayList<Chunk> chunks = new ArrayList<Chunk>(); final ArrayList<Chunk> chunks = new ArrayList<Chunk>();
for (int x = c1x; x <= c2x; x++) { for (int x = c1x; x <= c2x; x++) {
for (int z = c1z; z <= c2z; z++) { for (int z = c1z; z <= c2z; z++) {
@ -407,7 +408,7 @@ public class ChunkManager extends AChunkManager {
try { try {
entity.spawn(world, x_offset, z_offset); entity.spawn(world, x_offset, z_offset);
} catch (final Exception e) { } catch (final Exception e) {
System.out.print("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id)); PlotSquared.log("Failed to restore entity " + entity.x + "," + entity.y + "," + entity.z + " : " + entity.id + " : " + EntityType.fromId(entity.id));
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -758,7 +759,7 @@ public class ChunkManager extends AChunkManager {
@Override @Override
public boolean loadChunk(String world, ChunkLoc loc) { public boolean loadChunk(String world, ChunkLoc loc) {
return BukkitUtil.getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); return BukkitUtil.getWorld(world).getChunkAt(loc.x, loc.z).load(false);
} }
@Override @Override

View File

@ -49,6 +49,8 @@ import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile; import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import com.intellectualcrafters.plot.PlotSquared;
public class Metrics { public class Metrics {
/** /**
* The current revision number * The current revision number
@ -523,7 +525,7 @@ public class Metrics {
connection.addRequestProperty("Connection", "close"); connection.addRequestProperty("Connection", "close");
connection.setDoOutput(true); connection.setDoOutput(true);
if (this.debug) { if (this.debug) {
System.out.println("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length); PlotSquared.log("[Metrics] Prepared request for " + pluginName + " uncompressed=" + uncompressed.length + " compressed=" + compressed.length);
} }
// Write the data // Write the data
final OutputStream os = connection.getOutputStream(); final OutputStream os = connection.getOutputStream();

View File

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import com.google.common.base.Charsets; import com.google.common.base.Charsets;
import com.google.common.collect.BiMap; import com.google.common.collect.BiMap;
import com.intellectualcrafters.plot.PlotSquared;
import com.intellectualcrafters.plot.object.BukkitOfflinePlayer; import com.intellectualcrafters.plot.object.BukkitOfflinePlayer;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.object.StringWrapper;
@ -81,7 +82,7 @@ public class OfflineUUIDWrapper extends UUIDWrapper {
return p.toArray(new Player[0]); return p.toArray(new Player[0]);
} }
} catch (final Exception e) { } catch (final Exception e) {
System.out.print("Failed to resolve online players"); PlotSquared.log("Failed to resolve online players");
this.getOnline = null; this.getOnline = null;
return Bukkit.getOnlinePlayers().toArray(new Player[0]); return Bukkit.getOnlinePlayers().toArray(new Player[0]);
} }