bug fixes

This commit is contained in:
boy0001 2014-09-22 21:43:53 +10:00
parent e6849e4ace
commit 333a237655
9 changed files with 51 additions and 31 deletions

View File

@ -83,6 +83,8 @@ public enum C {
*/ */
NOT_IN_PLOT("&cYou're not in a plot"), NOT_IN_PLOT("&cYou're not in a plot"),
NOT_IN_PLOT_WORLD("&cYou're not in a plot world"), NOT_IN_PLOT_WORLD("&cYou're not in a plot world"),
NOT_VALID_WORLD("&cThat is not a valid world (case sensitive)"),
NOT_VALID_PLOT_WORLD("&cThat is not a valid plot world (case sensitive)"),
NO_PLOTS("&cYou don't have any plots"), NO_PLOTS("&cYou don't have any plots"),
/* /*
Block List Block List
@ -147,7 +149,8 @@ public enum C {
Clearing Clearing
*/ */
CLEARING_PLOT("&cClearing plot."), CLEARING_PLOT("&cClearing plot."),
CLEARING_DONE("&aDone! Took %time% seconds"), CLEARING_DONE("&6Done, took &a%time%&6 ms!"),
CLEARING_DONE_PACKETS("&6(&a%time% &6ms for packets)"),
/* /*
Claiming Claiming
*/ */

View File

@ -10,6 +10,7 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Biome; import org.bukkit.block.Biome;

View File

@ -50,8 +50,9 @@ public class PlotHelper {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void setSign(Player plr, Plot p) { public static void setSign(Player plr, Plot p) {
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(p.world)); World world = Bukkit.getWorld(p.world);
Location pl = new Location(plr.getWorld(), getPlotBottomLoc(plr.getWorld(), p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(plr.getWorld(), p.id).getBlockZ()); PlotWorld plotworld = PlotMain.getWorldSettings(world);
Location pl = new Location(world, getPlotBottomLoc(world, p.id).getBlockX() , plotworld.ROAD_HEIGHT + 1, getPlotBottomLoc(world, p.id).getBlockZ());
Block bs = pl.add(0,0,-1).getBlock(); Block bs = pl.add(0,0,-1).getBlock();
bs.setType(Material.AIR); bs.setType(Material.AIR);
bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false); bs.setTypeIdAndData(Material.WALL_SIGN.getId(), (byte) 2, false);
@ -61,6 +62,7 @@ public class PlotHelper {
sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(1, C.OWNER_SIGN_LINE_2.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(2, C.OWNER_SIGN_LINE_3.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName())); sign.setLine(3, C.OWNER_SIGN_LINE_4.translated().replaceAll("%id%", id).replaceAll("%plr%", plr.getName()));
System.out.print(10);
sign.update(true); sign.update(true);
} }
@ -440,7 +442,7 @@ public class PlotHelper {
public static void clear(final Player requester, final Plot plot) { public static void clear(final Player requester, final Plot plot) {
PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world)); PlotWorld plotworld = PlotMain.getWorldSettings(Bukkit.getWorld(plot.world));
long start = System.currentTimeMillis(); long start = System.nanoTime();
PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST); PlotHelper.setBiome(requester.getWorld(), plot, Biome.FOREST);
PlotHelper.removeSign(requester, plot); PlotHelper.removeSign(requester, plot);
PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT); PlayerFunctions.sendMessage(requester, C.CLEARING_PLOT);
@ -465,14 +467,21 @@ public class PlotHelper {
filling[i] = result[0]; filling[i] = result[0];
filling_data[i] = result[1]; filling_data[i] = result[1];
} }
try { try {
setBlockClass = new SetBlockFast(); setBlockClass = new SetBlockFast();
regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data});
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.nanoTime()-start)/1000000.0)));
SetBlockFast.update(requester);
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE_PACKETS.s().replaceAll("%time%", ""+((System.nanoTime()-start)/1000000.0)));
return;
} }
catch (NoClassDefFoundError e) { catch (NoClassDefFoundError e) {
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cFast plot clearing is currently not enabled."); PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&cFast plot clearing is currently not enabled.");
PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&c - Please get PlotSquared for "+Bukkit.getVersion()+" for improved performance"); PlotMain.sendConsoleSenderMessage(C.PREFIX.s() + "&c - Please get PlotSquared for "+Bukkit.getVersion()+" for improved performance");
} }
if (pos2.getBlockX()-pos1.getBlockX()<16) { if (pos2.getBlockX()-pos1.getBlockX()<16) {
regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); regenerateCuboid(pos1, pos2,requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data});
return; return;
@ -534,9 +543,6 @@ public class PlotHelper {
regenerateCuboid(new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX, height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //8 regenerateCuboid(new Location(world, max.getBlockX(), 0, max.getBlockZ()), new Location(world, plotMaxX, height, plotMaxZ),requester,plotworld, new Object[] {plotfloors,plotfloors_data}, new Object[] {filling, filling_data}); //8
} }
PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.currentTimeMillis()-start)/1000.0))); PlayerFunctions.sendMessage(requester, C.CLEARING_DONE.s().replaceAll("%time%", ""+((System.currentTimeMillis()-start)/1000.0)));
if (setBlockClass!=null) {
SetBlockFast.update(requester);
}
} }
public static void regenerateCuboid(Location pos1, Location pos2,Player player, PlotWorld plotworld, Object[] plotfloors, Object[] filling) { public static void regenerateCuboid(Location pos1, Location pos2,Player player, PlotWorld plotworld, Object[] plotfloors, Object[] filling) {
World world = pos1.getWorld(); World world = pos1.getWorld();

View File

@ -52,8 +52,7 @@ import java.util.UUID;
import static org.bukkit.Material.*; import static org.bukkit.Material.*;
/** /**
* @awesome @author Empire92 * @awesome @author Citymonstret, Empire92
* @author Citymonstret
* PlotMain class. * PlotMain class.
*/ */
public class PlotMain extends JavaPlugin { public class PlotMain extends JavaPlugin {
@ -175,8 +174,8 @@ public class PlotMain extends JavaPlugin {
/** /**
* get all plot worlds * get all plot worlds
*/ */
public static World[] getPlotWorlds() { public static String[] getPlotWorlds() {
return (worlds.keySet().toArray(new World[0])); return (worlds.keySet().toArray(new String[0]));
} }
public static String[] getPlotWorldsString() { public static String[] getPlotWorldsString() {
return plots.keySet().toArray(new String[0]); return plots.keySet().toArray(new String[0]);
@ -209,6 +208,7 @@ public class PlotMain extends JavaPlugin {
/** /**
* Replace the plot object with an updated version * Replace the plot object with an updated version
* *
* @param id plot Id
* @param plot plot object * @param plot plot object
*/ */
public static void updatePlot(Plot plot) { public static void updatePlot(Plot plot) {
@ -327,7 +327,6 @@ public class PlotMain extends JavaPlugin {
if (C.ENABLED.s().length() > 0) { if (C.ENABLED.s().length() > 0) {
Broadcast(C.ENABLED); Broadcast(C.ENABLED);
} }
if (Settings.DB.USE_MYSQL) { if (Settings.DB.USE_MYSQL) {
try { try {
mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT, mySQL = new MySQL(this, Settings.DB.HOST_NAME, Settings.DB.PORT,
@ -600,8 +599,8 @@ public class PlotMain extends JavaPlugin {
long error = 0l; long error = 0l;
@Override @Override
public void run() { public void run() {
for (World w: getPlotWorlds()) { for (String w: getPlotWorlds()) {
World world = w; World world = Bukkit.getWorld(w);
try { try {
if(world.getLoadedChunks().length < 1) { if(world.getLoadedChunks().length < 1) {
return; return;

View File

@ -65,7 +65,7 @@ public class PlotWorld {
/** /**
* Default main block: 1 * Default main block: 1
*/ */
public static String[] MAIN_BLOCK_DEFAULT = new String[] {"1:0"}; public static String[] MAIN_BLOCK_DEFAULT = new String[] {"1"};
/** /**
* Top blocks * Top blocks
*/ */
@ -73,7 +73,7 @@ public class PlotWorld {
/** /**
* Default top blocks: {"2"} * Default top blocks: {"2"}
*/ */
public static String[] TOP_BLOCK_DEFAULT = new String[] {"2:0"}; public static String[] TOP_BLOCK_DEFAULT = new String[] {"2"};
/** /**
* Wall block * Wall block

View File

@ -113,8 +113,6 @@ public class WorldGenerator extends ChunkGenerator {
plotsize = plotworld.PLOT_WIDTH; plotsize = plotworld.PLOT_WIDTH;
pathsize = plotworld.ROAD_WIDTH; pathsize = plotworld.ROAD_WIDTH;
bottom = (short) Material.BEDROCK.getId(); bottom = (short) Material.BEDROCK.getId();
filling = new Short[plotworld.MAIN_BLOCK.length];
plotfloors = new Short[plotworld.TOP_BLOCK.length];
floor1 = getBlock(plotworld.ROAD_BLOCK); floor1 = getBlock(plotworld.ROAD_BLOCK);
// floor2 = getBlock(plotworld.ROAD_STRIPES); // floor2 = getBlock(plotworld.ROAD_STRIPES);
@ -122,8 +120,8 @@ public class WorldGenerator extends ChunkGenerator {
size = pathsize + plotsize; size = pathsize + plotsize;
wall = getBlock(plotworld.WALL_BLOCK); wall = getBlock(plotworld.WALL_BLOCK);
Short[] plotfloors = new Short[plotworld.TOP_BLOCK.length]; plotfloors = new Short[plotworld.TOP_BLOCK.length];
Short[] plotfloors_data = new Short[plotworld.TOP_BLOCK.length]; filling = new Short[plotworld.TOP_BLOCK.length];
for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) { for (int i = 0; i < plotworld.TOP_BLOCK.length; i++) {
plotfloors[i] = getBlock(plotworld.TOP_BLOCK[i]); plotfloors[i] = getBlock(plotworld.TOP_BLOCK[i]);

View File

@ -151,7 +151,7 @@ public class PlotAPI {
* Get all plot worlds * Get all plot worlds
* @return World[] - array of plot worlds * @return World[] - array of plot worlds
*/ */
public World[] getPlotWorlds() { public String[] getPlotWorlds() {
return PlotMain.getPlotWorlds(); return PlotMain.getPlotWorlds();
} }
/** /**
@ -160,11 +160,7 @@ public class PlotAPI {
* @return boolean (if plot world or not) * @return boolean (if plot world or not)
*/ */
public boolean isPlotWorld(World world) { public boolean isPlotWorld(World world) {
for (World w:PlotMain.getPlotWorlds()) { return PlotMain.isPlotWorld(world);
if (w.equals(world))
return true;
}
return false;
} }
/** /**
* Get the settings for a world (settings bundled in PlotWorld class) * Get the settings for a world (settings bundled in PlotWorld class)

View File

@ -16,6 +16,7 @@ import com.intellectualcrafters.plot.PlotHelper;
import com.intellectualcrafters.plot.PlotId; import com.intellectualcrafters.plot.PlotId;
import com.intellectualcrafters.plot.PlotMain; import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -29,13 +30,29 @@ public class Auto extends SubCommand {
public boolean execute(Player plr, String ... args) { public boolean execute(Player plr, String ... args) {
World world; World world;
if (PlotMain.getPlotWorlds().length==1) if (PlotMain.getPlotWorlds().length==1)
world = PlotMain.getPlotWorlds()[0]; world = Bukkit.getWorld(PlotMain.getPlotWorlds()[0]);
else { else {
if (PlotMain.isPlotWorld(plr.getWorld())) if (PlotMain.isPlotWorld(plr.getWorld()))
world = plr.getWorld(); world = plr.getWorld();
else { else {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD); if (args.length==1) {
return true; world = Bukkit.getWorld(args[0]);
if (world!=null) {
if (!PlotMain.isPlotWorld(world)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
return true;
}
}
else {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_WORLD);
return true;
}
}
else {
PlayerFunctions.sendMessage(plr, C.NOT_IN_PLOT_WORLD);
return true;
}
} }
} }

View File

@ -76,8 +76,8 @@ public class Debug extends SubCommand{
*/ */
{ {
StringBuilder worlds = new StringBuilder(""); StringBuilder worlds = new StringBuilder("");
for (World world: PlotMain.getPlotWorlds()) for (String world: PlotMain.getPlotWorlds())
worlds.append(world.getName()+" "); worlds.append(world+" ");
information.append(header); information.append(header);
information.append(getSection(section, "Lag / TPS")); information.append(getSection(section, "Lag / TPS"));
information.append(getLine(line, "Ticks Per Second", Lag.getTPS())); information.append(getLine(line, "Ticks Per Second", Lag.getTPS()));