misc fixes

This commit is contained in:
boy0001 2015-02-23 11:05:25 +11:00
parent 22700aa88b
commit d1e9ccb3e8
9 changed files with 67 additions and 42 deletions

View File

@ -42,6 +42,7 @@ import com.intellectualcrafters.plot.listeners.WorldEditListener;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.titles.AbstractTitle; import com.intellectualcrafters.plot.titles.AbstractTitle;
import com.intellectualcrafters.plot.titles.DefaultTitle; import com.intellectualcrafters.plot.titles.DefaultTitle;
import com.intellectualcrafters.plot.util.AChunkManager;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.ConsoleColors;
import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MainUtil;
@ -50,6 +51,7 @@ import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils; import com.intellectualcrafters.plot.util.bukkit.BukkitSetupUtils;
import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager;
import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
import com.intellectualcrafters.plot.util.bukkit.Metrics; import com.intellectualcrafters.plot.util.bukkit.Metrics;
import com.intellectualcrafters.plot.util.bukkit.SendChunk; import com.intellectualcrafters.plot.util.bukkit.SendChunk;
import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; import com.intellectualcrafters.plot.util.bukkit.SetBlockFast;
@ -298,6 +300,7 @@ 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();
} }
@ -376,4 +379,9 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
} }
return UUIDHandler.uuidWrapper; return UUIDHandler.uuidWrapper;
} }
@Override
public AChunkManager initChunkManager() {
return new ChunkManager();
}
} }

View File

@ -6,9 +6,11 @@ import net.milkbowl.vault.economy.Economy;
import com.intellectualcrafters.plot.generator.HybridUtils; import com.intellectualcrafters.plot.generator.HybridUtils;
import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.util.AChunkManager;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.SetupUtils;
import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.TaskManager;
import com.intellectualcrafters.plot.util.bukkit.ChunkManager;
import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.intellectualcrafters.plot.uuid.UUIDWrapper;
public interface IPlotMain { public interface IPlotMain {
@ -40,6 +42,8 @@ public interface IPlotMain {
public BlockManager initBlockManager(); public BlockManager initBlockManager();
public AChunkManager initChunkManager();
public SetupUtils initSetupUtils(); public SetupUtils initSetupUtils();
public HybridUtils initHybridUtils(); public HybridUtils initHybridUtils();

View File

@ -49,6 +49,7 @@ import com.intellectualcrafters.plot.object.PlotId;
import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotManager;
import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotPlayer;
import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PlotWorld;
import com.intellectualcrafters.plot.util.AChunkManager;
import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.BlockManager;
import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.ClusterManager;
import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.ExpireManager;
@ -445,6 +446,8 @@ public class PlotSquared {
SetupUtils.manager = IMP.initSetupUtils(); SetupUtils.manager = IMP.initSetupUtils();
// Set block // Set block
BlockManager.manager = IMP.initBlockManager(); BlockManager.manager = IMP.initBlockManager();
// Set chunk
AChunkManager.manager = IMP.initChunkManager();
// PlotMe // PlotMe
TaskManager.runTaskLater(new Runnable() { TaskManager.runTaskLater(new Runnable() {
@Override @Override

View File

@ -22,11 +22,10 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
@Override @Override
public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) { public boolean onCommand(CommandSender commandSender, Command command, String commandLabel, String[] args) {
Player player = null;
if (commandSender instanceof Player) { if (commandSender instanceof Player) {
player = (Player) commandSender; return MainCommand.onCommand(BukkitUtil.getPlayer((Player) commandSender), commandLabel, args);
} }
return MainCommand.onCommand(BukkitUtil.getPlayer(player), commandLabel, args); return MainCommand.onCommand(null, commandLabel, args);
} }
@Override @Override

View File

@ -219,16 +219,16 @@ public class Set extends SubCommand {
final String[] components = manager.getPlotComponents(plotworld, plot.id); final String[] components = manager.getPlotComponents(plotworld, plot.id);
for (final String component : components) { for (final String component : components) {
if (component.equalsIgnoreCase(args[0])) { if (component.equalsIgnoreCase(args[0])) {
if (args.length < 2) {
MainUtil.sendMessage(plr, C.NEED_BLOCK);
return true;
}
PlotBlock[] blocks; PlotBlock[] blocks;
try { try {
blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseObject(args[2]); blocks = (PlotBlock[]) Configuration.BLOCKLIST.parseString(args[1]);
} catch (final Exception e) { } catch (final Exception e) {
try { try {
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[2]), (byte) 0) }; if (args.length < 2) {
MainUtil.sendMessage(plr, C.NEED_BLOCK);
return true;
}
blocks = new PlotBlock[] { new PlotBlock((short) BlockManager.manager.getBlockIdFromString(args[1]), (byte) 0) };
} catch (final Exception e2) { } catch (final Exception e2) {
MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK); MainUtil.sendMessage(plr, C.NOT_VALID_BLOCK);
return false; return false;

View File

@ -49,7 +49,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
return false; return false;
} }
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1, 0, 1);
int x, z; int x, z;
z = bottom.getZ(); z = bottom.getZ();
int length = top.getX() - bottom.getX(); int length = top.getX() - bottom.getX();
@ -59,7 +59,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
final int[] zl = new int[size]; final int[] zl = new int[size];
final PlotBlock[] bl = new PlotBlock[size]; final PlotBlock[] bl = new PlotBlock[size];
int i = 0; int i = 0;
for (x = bottom.getX(); x < (top.getX() + 1); x++) { for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
@ -68,8 +68,8 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
i++; i++;
} }
} }
x = top.getX() + 1; x = top.getX();
for (z = bottom.getZ(); z < (top.getZ() + 1); z++) { for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
@ -78,8 +78,8 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
i++; i++;
} }
} }
z = top.getZ() + 1; z = top.getZ();
for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) { for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
@ -89,7 +89,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
} }
} }
x = bottom.getX(); x = bottom.getX();
for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) { for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) { for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
@ -98,7 +98,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
i++; i++;
} }
} }
BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, blocks); BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl);
return true; return true;
} }
@ -108,7 +108,7 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
return false; return false;
} }
final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid); final Location bottom = MainUtil.getPlotBottomLoc(plotworld.worldname, plotid);
final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid); final Location top = MainUtil.getPlotTopLoc(plotworld.worldname, plotid).add(1,0,1);
int length = top.getX() - bottom.getX(); int length = top.getX() - bottom.getX();
int size = (length) * 4; int size = (length) * 4;
final int[] xl = new int[size]; final int[] xl = new int[size];
@ -119,23 +119,23 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
z = bottom.getZ(); z = bottom.getZ();
int i = 0; int i = 0;
int y = dpw.WALL_HEIGHT + 1; int y = dpw.WALL_HEIGHT + 1;
for (x = bottom.getX(); x < (top.getX() + 1); x++) { for (x = bottom.getX(); x <= (top.getX() - 1); x++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
yl[i] = y; yl[i] = y;
bl[i] = blocks[BlockManager.random(blocks.length)]; bl[i] = blocks[BlockManager.random(blocks.length)];
i++; i++;
} }
x = top.getX() + 1; x = top.getX();
for (z = bottom.getZ(); z < (top.getZ() + 1); z++) { for (z = bottom.getZ(); z <= (top.getZ() - 1); z++) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
yl[i] = y; yl[i] = y;
bl[i] = blocks[BlockManager.random(blocks.length)]; bl[i] = blocks[BlockManager.random(blocks.length)];
i++; i++;
} }
z = top.getZ() + 1; z = top.getZ();
for (x = top.getX() + 1; x > (bottom.getX() - 1); x--) { for (x = top.getX(); x >= (bottom.getX() + 1); x--) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
yl[i] = y; yl[i] = y;
@ -143,14 +143,14 @@ public abstract class ClassicPlotManager extends SquarePlotManager {
i++; i++;
} }
x = bottom.getX(); x = bottom.getX();
for (z = top.getZ() + 1; z > (bottom.getZ() - 1); z--) { for (z = top.getZ(); z >= (bottom.getZ() + 1); z--) {
xl[i] = x; xl[i] = x;
zl[i] = z; zl[i] = z;
yl[i] = y; yl[i] = y;
bl[i] = blocks[BlockManager.random(blocks.length)]; bl[i] = blocks[BlockManager.random(blocks.length)];
i++; i++;
} }
BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, blocks); BlockManager.setBlocks(plotworld.worldname, xl, yl, zl, bl);
return true; return true;
} }

View File

@ -70,6 +70,7 @@ import org.bukkit.event.inventory.InventoryClickEvent;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent; import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerBucketFillEvent; import org.bukkit.event.player.PlayerBucketFillEvent;
import org.bukkit.event.player.PlayerChangedWorldEvent;
import org.bukkit.event.player.PlayerEggThrowEvent; import org.bukkit.event.player.PlayerEggThrowEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
@ -90,6 +91,7 @@ import com.intellectualcrafters.plot.config.Settings;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.Flag;
import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.flag.FlagManager;
import com.intellectualcrafters.plot.object.BukkitPlayer;
import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Location;
import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.Plot;
import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotBlock;
@ -331,6 +333,13 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
} }
} }
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onWorldChanged(final PlayerChangedWorldEvent event) {
PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer());
((BukkitPlayer) player).hasPerm = null;
((BukkitPlayer) player).noPerm = null;
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true) @EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) { public static void onPeskyMobsChangeTheWorldLikeWTFEvent(final EntityChangeBlockEvent event) {
final String world = event.getBlock().getWorld().getName(); final String world = event.getBlock().getWorld().getName();

View File

@ -13,8 +13,8 @@ public class BukkitPlayer implements PlotPlayer {
public final Player player; public final Player player;
UUID uuid; UUID uuid;
String name; String name;
private HashSet<String> hasPerm; public HashSet<String> hasPerm;
private HashSet<String> noPerm; public HashSet<String> noPerm;
private int op = 0; private int op = 0;
/** /**

View File

@ -845,12 +845,14 @@ public class MainUtil {
return new String(b); return new String(b);
} }
public static boolean sendMessage(final PlotPlayer plr, final String msg, final boolean prefix) { public static boolean sendMessage(final PlotPlayer plr, String msg, final boolean prefix) {
msg = colorise('&', msg);
String prefixStr = colorise('&', C.PREFIX.s());
if ((msg.length() > 0) && !msg.equals("")) { if ((msg.length() > 0) && !msg.equals("")) {
if (plr == null) { if (plr == null) {
PlotSquared.log(C.PREFIX.s() + msg); PlotSquared.log(prefixStr + msg);
} else { } else {
sendMessageWrapped(plr, colorise('&', C.PREFIX.s() + msg)); sendMessageWrapped(plr, prefixStr + msg);
} }
} }
return true; return true;
@ -930,17 +932,17 @@ public class MainUtil {
* @param msg Was used to wrap the chat client length (Packets out--) * @param msg Was used to wrap the chat client length (Packets out--)
*/ */
public static void sendMessageWrapped(final PlotPlayer plr, String msg) { public static void sendMessageWrapped(final PlotPlayer plr, String msg) {
if (msg.length() > 65) { // if (msg.length() > 65) {
final String[] ss = wordWrap(msg, 65); // final String[] ss = wordWrap(msg, 65);
final StringBuilder b = new StringBuilder(); // final StringBuilder b = new StringBuilder();
for (final String p : ss) { // for (final String p : ss) {
b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n "); // b.append(p).append(p.equals(ss[ss.length - 1]) ? "" : "\n ");
} // }
msg = b.toString(); // msg = b.toString();
} // }
if (msg.endsWith("\n")) { // if (msg.endsWith("\n")) {
msg = msg.substring(0, msg.length() - 2); // msg = msg.substring(0, msg.length() - 2);
} // }
plr.sendMessage(msg); plr.sendMessage(msg);
} }
@ -963,7 +965,7 @@ public class MainUtil {
} }
} }
if (plr == null) { if (plr == null) {
PlotSquared.log(msg); PlotSquared.log(colorise('&', msg));
} else { } else {
sendMessage(plr, msg, c.usePrefix()); sendMessage(plr, msg, c.usePrefix());
} }