From d49de5297b800f88a6757a284d996034d50766ae Mon Sep 17 00:00:00 2001 From: MattBDev Date: Tue, 5 Apr 2016 23:50:04 -0400 Subject: [PATCH] Tweaks --- .../plot/api/PlotAPI.java | 20 +-- .../bukkit/listeners/PlayerEvents.java | 3 +- .../bukkit/object/entity/EntityWrapper.java | 158 ++++++++++++------ .../object/entity/LivingEntityStats.java | 7 +- .../bukkit/util/BukkitChunkManager.java | 42 ++--- .../bukkit/uuid/SQLUUIDHandler.java | 14 +- .../plot/commands/Area.java | 19 ++- .../plot/commands/Delete.java | 4 +- .../plot/util/UUIDHandlerImplementation.java | 3 +- .../sponge/uuid/SpongeUUIDHandler.java | 16 +- 10 files changed, 165 insertions(+), 121 deletions(-) diff --git a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index a19c9de7d..a8bfb68e4 100644 --- a/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/Bukkit/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -33,17 +33,17 @@ import java.util.UUID; /** * PlotSquared API. - *
- *
- * Useful classes:
- * @see BukkitUtil - * @see PlotPlayer - * @see Plot - * @see com.intellectualcrafters.plot.object.Location - * @see PlotArea - * @see PS + * + *

Useful classes:

+ * * @version 3.3.3 ->>>>>>> origin/master */ public class PlotAPI { diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index 6500620fd..b856f7f85 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -22,7 +22,6 @@ import com.intellectualcrafters.plot.util.RegExUtil; import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.BukkitMain; import com.plotsquared.bukkit.object.BukkitLazyBlock; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.bukkit.util.BukkitUtil; @@ -738,7 +737,7 @@ public class PlayerEvents extends PlotListener implements Listener { plotExit(pp, plot); } - if (BukkitMain.worldEdit != null && PS.get().worldedit != null) { + if (true && PS.get().worldedit != null) { if (!Permissions.hasPermission(pp, C.PERMISSION_WORLDEDIT_BYPASS)) { if (pp.getAttribute("worldedit")) { pp.removeAttribute("worldedit"); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java index ebb1369a3..71291c0a8 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/EntityWrapper.java @@ -9,6 +9,8 @@ import org.bukkit.World; import org.bukkit.block.BlockFace; import org.bukkit.entity.Ageable; import org.bukkit.entity.ArmorStand; +import org.bukkit.entity.Bat; +import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Guardian; @@ -16,6 +18,7 @@ import org.bukkit.entity.Horse; import org.bukkit.entity.Horse.Color; import org.bukkit.entity.Horse.Style; import org.bukkit.entity.Horse.Variant; +import org.bukkit.entity.IronGolem; import org.bukkit.entity.Item; import org.bukkit.entity.ItemFrame; import org.bukkit.entity.LivingEntity; @@ -25,6 +28,7 @@ import org.bukkit.entity.Rabbit.Type; import org.bukkit.entity.Sheep; import org.bukkit.entity.Skeleton; import org.bukkit.entity.Skeleton.SkeletonType; +import org.bukkit.entity.Slime; import org.bukkit.entity.Tameable; import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.InventoryHolder; @@ -39,10 +43,10 @@ public class EntityWrapper { public final float pitch; public final short depth; private final int hash; + private final EntityBaseStats base = new EntityBaseStats(); public double x; public double y; public double z; - public EntityBaseStats base = null; // Extended public ItemStack stack; public ItemStack[] inventory; @@ -52,10 +56,9 @@ public class EntityWrapper { public LivingEntityStats lived; public AgeableStats aged; public TameableStats tamed; + ArmorStandStats stand; private HorseStats horse; - private ArmorStandStats stand; - - @SuppressWarnings("deprecation") + public EntityWrapper(Entity entity, short depth) { this.hash = entity.getEntityId(); this.depth = depth; @@ -69,10 +72,9 @@ public class EntityWrapper { if (depth == 0) { return; } - this.base = new EntityBaseStats(); - Entity p = entity.getPassenger(); - if (p != null) { - this.base.passenger = new EntityWrapper(p, depth); + Entity passenger = entity.getPassenger(); + if (passenger != null) { + this.base.passenger = new EntityWrapper(passenger, depth); } this.base.fall = entity.getFallDistance(); this.base.fire = (short) entity.getFireTicks(); @@ -168,10 +170,10 @@ public class EntityWrapper { this.horse.variant = getOrdinal(Variant.values(), horse.getVariant()); this.horse.style = getOrdinal(Style.values(), horse.getStyle()); this.horse.color = getOrdinal(Color.values(), horse.getColor()); - storeTameable((Tameable) entity); - storeAgeable((Ageable) entity); - storeLiving((LivingEntity) entity); - storeInventory((InventoryHolder) entity); + storeTameable(horse); + storeAgeable(horse); + storeLiving(horse); + storeInventory(horse); return; // END INVENTORY HOLDER // case WOLF: @@ -185,8 +187,8 @@ public class EntityWrapper { Sheep sheep = (Sheep) entity; this.dataByte = (byte) (sheep.isSheared() ? 1 : 0); this.dataByte2 = sheep.getColor().getDyeData(); - storeAgeable((Ageable) entity); - storeLiving((LivingEntity) entity); + storeAgeable(sheep); + storeLiving(sheep); return; case VILLAGER: case CHICKEN: @@ -196,26 +198,25 @@ public class EntityWrapper { storeAgeable((Ageable) entity); storeLiving((LivingEntity) entity); return; - case RABBIT: // NEW + case RABBIT: this.dataByte = getOrdinal(Type.values(), ((Rabbit) entity).getRabbitType()); storeAgeable((Ageable) entity); storeLiving((LivingEntity) entity); return; // END AGEABLE // - case GUARDIAN: // NEW + case GUARDIAN: this.dataByte = (byte) (((Guardian) entity).isElder() ? 1 : 0); storeLiving((LivingEntity) entity); return; - case SKELETON: // NEW + case SKELETON: this.dataByte = (byte) ((Skeleton) entity).getSkeletonType().getId(); storeLiving((LivingEntity) entity); return; - case ARMOR_STAND: // NEW - // CHECK positions + case ARMOR_STAND: ArmorStand stand = (ArmorStand) entity; this.inventory = new ItemStack[]{stand.getItemInHand().clone(), stand.getHelmet().clone(), stand.getChestplate().clone(), stand.getLeggings().clone(), stand.getBoots().clone()}; - storeLiving((LivingEntity) entity); + storeLiving(stand); this.stand = new ArmorStandStats(); EulerAngle head = stand.getHeadPose(); @@ -264,9 +265,19 @@ public class EntityWrapper { this.stand.small = true; } return; - case ENDERMITE: // NEW + case ENDERMITE: + return; case BAT: + if (((Bat) entity).isAwake()) { + this.dataByte = (byte) 1; + } else { + this.dataByte = (byte) 0; + } + return; case ENDER_DRAGON: + EnderDragon entity1 = (EnderDragon) entity; + this.dataByte = (byte) entity1.getPhase().ordinal(); + return; case GHAST: case MAGMA_CUBE: case SQUID: @@ -283,8 +294,16 @@ public class EntityWrapper { case BLAZE: case SHULKER: case SNOWMAN: - case IRON_GOLEM: storeLiving((LivingEntity) entity); + return; + case IRON_GOLEM: + if (((IronGolem) entity).isPlayerCreated()) { + this.dataByte = (byte) 1; + } else { + this.dataByte = (byte) 0; + } + storeLiving((LivingEntity) entity); + return; // END LIVING // } } @@ -303,7 +322,7 @@ public class EntityWrapper { this.inventory = held.getInventory().getContents().clone(); } - private void restoreLiving(LivingEntity entity) { + void restoreLiving(LivingEntity entity) { entity.setCanPickupItems(this.lived.loot); if (this.lived.name != null) { entity.setCustomName(this.lived.name); @@ -315,12 +334,7 @@ public class EntityWrapper { entity.setRemainingAir(this.lived.air); entity.setRemoveWhenFarAway(this.lived.persistent); if (this.lived.equipped) { - EntityEquipment equipment = entity.getEquipment(); - equipment.setItemInHand(this.lived.hands); - equipment.setHelmet(this.lived.helmet); - equipment.setChestplate(this.lived.chestplate); - equipment.setLeggings(this.lived.leggings); - equipment.setBoots(this.lived.boots); + this.restoreEquipment(entity); } if (this.lived.leashed) { // TODO leashes @@ -331,6 +345,20 @@ public class EntityWrapper { } } + void restoreEquipment(LivingEntity entity) { + EntityEquipment equipment = entity.getEquipment(); + if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) { + equipment.setItemInMainHand(this.lived.mainHand); + equipment.setItemInOffHand(this.lived.offHand); + } else { + equipment.setItemInHand(this.lived.mainHand); + } + equipment.setHelmet(this.lived.helmet); + equipment.setChestplate(this.lived.chestplate); + equipment.setLeggings(this.lived.leggings); + equipment.setBoots(this.lived.boots); + } + private void restoreInventory(InventoryHolder entity) { entity.getInventory().setContents(this.inventory); } @@ -354,14 +382,24 @@ public class EntityWrapper { EntityEquipment equipment = lived.getEquipment(); this.lived.equipped = equipment != null; if (this.lived.equipped) { - this.lived.hands = equipment.getItemInHand().clone(); - this.lived.boots = equipment.getBoots().clone(); - this.lived.leggings = equipment.getLeggings().clone(); - this.lived.chestplate = equipment.getChestplate().clone(); - this.lived.helmet = equipment.getHelmet().clone(); + storeEquipment(equipment); } } + void storeEquipment(EntityEquipment equipment) { + if (PS.get().checkVersion(PS.get().IMP.getServerVersion(), 1, 9, 0)) { + this.lived.mainHand = equipment.getItemInMainHand().clone(); + this.lived.offHand = equipment.getItemInOffHand().clone(); + } else { + this.lived.mainHand = equipment.getItemInHand().clone(); + this.lived.offHand = null; + } + this.lived.boots = equipment.getBoots().clone(); + this.lived.leggings = equipment.getLeggings().clone(); + this.lived.chestplate = equipment.getChestplate().clone(); + this.lived.helmet = equipment.getHelmet().clone(); + } + private void restoreTameable(Tameable entity) { if (this.tamed.tamed) { if (this.tamed.owner != null) { @@ -394,7 +432,6 @@ public class EntityWrapper { this.tamed.tamed = tamed.isTamed(); } - @SuppressWarnings("deprecation") public Entity spawn(World world, int x_offset, int z_offset) { Location loc = new Location(world, this.x + x_offset, this.y, this.z + z_offset); loc.setYaw(this.yaw); @@ -449,6 +486,7 @@ public class EntityWrapper { case ENDER_CRYSTAL: case ENDER_PEARL: case ENDER_SIGNAL: + case DROPPED_ITEM: case EXPERIENCE_ORB: case FALLING_BLOCK: case FIREBALL: @@ -463,11 +501,19 @@ public class EntityWrapper { case PLAYER: case PRIMED_TNT: case SLIME: + ((Slime) entity).setSize(this.dataByte); + return entity; case SMALL_FIREBALL: case SNOWBALL: case SPLASH_POTION: case THROWN_EXP_BOTTLE: case WEATHER: + case TIPPED_ARROW: + case SPECTRAL_ARROW: + case SHULKER_BULLET: + case LINGERING_POTION: + case AREA_EFFECT_CLOUD: + case DRAGON_FIREBALL: case WITHER_SKULL: case MINECART_FURNACE: case UNKNOWN: @@ -503,10 +549,10 @@ public class EntityWrapper { horse.setVariant(Variant.values()[this.horse.variant]); horse.setStyle(Style.values()[this.horse.style]); horse.setColor(Color.values()[this.horse.color]); - restoreTameable((Tameable) entity); - restoreAgeable((Ageable) entity); - restoreLiving((LivingEntity) entity); - restoreInventory((InventoryHolder) entity); + restoreTameable(horse); + restoreAgeable(horse); + restoreLiving(horse); + restoreInventory(horse); return entity; // END INVENTORY HOLDER // case WOLF: @@ -524,9 +570,9 @@ public class EntityWrapper { if (this.dataByte2 != 0) { sheep.setColor(DyeColor.getByDyeData(this.dataByte2)); } - restoreAgeable((Ageable) entity); - restoreLiving((LivingEntity) entity); - return entity; + restoreAgeable(sheep); + restoreLiving(sheep); + return sheep; case VILLAGER: case CHICKEN: case COW: @@ -536,26 +582,26 @@ public class EntityWrapper { restoreLiving((LivingEntity) entity); return entity; // END AGEABLE // - case RABBIT: // NEW + case RABBIT: if (this.dataByte != 0) { ((Rabbit) entity).setRabbitType(Type.values()[this.dataByte]); } restoreAgeable((Ageable) entity); restoreLiving((LivingEntity) entity); return entity; - case GUARDIAN: // NEW + case GUARDIAN: if (this.dataByte != 0) { ((Guardian) entity).setElder(true); } restoreLiving((LivingEntity) entity); return entity; - case SKELETON: // NEW + case SKELETON: if (this.dataByte != 0) { ((Skeleton) entity).setSkeletonType(SkeletonType.values()[this.dataByte]); } storeLiving((LivingEntity) entity); return entity; - case ARMOR_STAND: // NEW + case ARMOR_STAND: // CHECK positions ArmorStand stand = (ArmorStand) entity; if (this.inventory[0] != null) { @@ -612,11 +658,21 @@ public class EntityWrapper { if (this.stand.small) { stand.setSmall(true); } + restoreLiving(stand); + return stand; + case BAT: + if (this.dataByte != 0) { + ((Bat) entity).setAwake(true); + } restoreLiving((LivingEntity) entity); return entity; - case ENDERMITE: // NEW - case BAT: case ENDER_DRAGON: + if (this.dataByte != 0) { + ((EnderDragon) entity).setPhase(EnderDragon.Phase.values()[this.dataByte]); + } + restoreLiving((LivingEntity) entity); + return entity; + case ENDERMITE: case GHAST: case MAGMA_CUBE: case SQUID: @@ -632,7 +688,13 @@ public class EntityWrapper { case CREEPER: case BLAZE: case SNOWMAN: + case SHULKER: + restoreLiving((LivingEntity) entity); + return entity; case IRON_GOLEM: + if (this.dataByte != 0) { + ((IronGolem) entity).setPlayerCreated(true); + } restoreLiving((LivingEntity) entity); return entity; // END LIVING // diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/LivingEntityStats.java b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/LivingEntityStats.java index 42ceea6ee..e6717eb47 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/LivingEntityStats.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/object/entity/LivingEntityStats.java @@ -1,10 +1,10 @@ package com.plotsquared.bukkit.object.entity; -import java.util.Collection; - import org.bukkit.inventory.ItemStack; import org.bukkit.potion.PotionEffect; +import java.util.Collection; + public class LivingEntityStats { public boolean loot; public String name; @@ -17,10 +17,11 @@ public class LivingEntityStats { public short leash_y; public short leash_z; public boolean equipped; - public ItemStack hands; + public ItemStack mainHand; public ItemStack helmet; public ItemStack boots; public ItemStack leggings; public ItemStack chestplate; public Collection potions; + public ItemStack offHand; } diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 30b8e3b25..f9f76c85e 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -854,25 +854,20 @@ public class BukkitChunkManager extends ChunkManager { BlockState state = block.getState(); if (state instanceof Skull) { Object[] data = blockLocEntry.getValue(); - if (data[0] != null) { - ((Skull) state).setOwner((String) data[0]); - } - if ((Integer) data[1] != 0) { - ((Skull) state).setRotation(BlockFace.values()[(int) data[1]]); - } - if ((Integer) data[2] != 0) { - ((Skull) state).setSkullType(SkullType.values()[(int) data[2]]); + if ((Boolean) data[0]) { + ((Skull) state).setOwner((String) data[1]); } + ((Skull) state).setRotation((BlockFace) data[2]); + ((Skull) state).setSkullType((SkullType) data[3]); state.update(true); } else { PS.debug("&c[WARN] Plot clear failed to restore skull: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry - .getKey().y - + "," + ( - blockLocEntry.getKey().z + zOffset)); + .getKey().y + "," + (blockLocEntry.getKey().z + zOffset)); } } catch (Exception e) { PS.debug("&c[WARN] Plot clear failed to regenerate skull (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry .getKey().y + "," + (blockLocEntry.getKey().z + zOffset)); + e.printStackTrace(); } } for (Entry blockLocEntry : this.hopperContents.entrySet()) { @@ -989,10 +984,7 @@ public class BukkitChunkManager extends ChunkManager { } } catch (IllegalArgumentException e) { PS.debug("&c[WARN] Plot clear failed to regenerate brewing stand (e): " + (blockLocEntry.getKey().x + xOffset) + "," - + blockLocEntry - .getKey().y + "," + ( - blockLocEntry.getKey().z - + zOffset)); + + blockLocEntry.getKey().y + "," + (blockLocEntry.getKey().z + zOffset)); } } for (Entry blockLocEntry : this.furnaceTime.entrySet()) { @@ -1007,14 +999,12 @@ public class BukkitChunkManager extends ChunkManager { } else { PS.debug( "&c[WARN] Plot clear failed to restore furnace cooking: " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry - .getKey().y + "," + ( - blockLocEntry.getKey().z + zOffset)); + .getKey().y + "," + (blockLocEntry.getKey().z + zOffset)); } } catch (Exception e) { PS.debug( "&c[WARN] Plot clear failed to restore furnace cooking (e): " + (blockLocEntry.getKey().x + xOffset) + "," + blockLocEntry - .getKey().y + "," + ( - blockLocEntry.getKey().z + zOffset)); + .getKey().y + "," + (blockLocEntry.getKey().z + zOffset)); } } for (Entry blockLocEntry : this.furnaceContents.entrySet()) { @@ -1048,15 +1038,11 @@ public class BukkitChunkManager extends ChunkManager { state.update(true); } else { PS.debug("&c[WARN] Plot clear failed to regenerate banner: " + (blockLocByteEntry.getKey().x + xOffset) + "," - + blockLocByteEntry - .getKey().y + "," + ( - blockLocByteEntry.getKey().z + zOffset)); + + blockLocByteEntry.getKey().y + "," + (blockLocByteEntry.getKey().z + zOffset)); } } catch (Exception e) { PS.debug("&c[WARN] Plot clear failed to regenerate banner (e): " + (blockLocByteEntry.getKey().x + xOffset) + "," - + blockLocByteEntry - .getKey().y + "," + ( - blockLocByteEntry.getKey().z + zOffset)); + + blockLocByteEntry.getKey().y + "," + (blockLocByteEntry.getKey().z + zOffset)); } } } @@ -1134,11 +1120,7 @@ public class BukkitChunkManager extends ChunkManager { } } else if (block.getState() instanceof Skull) { Skull skull = (Skull) block.getState(); - String o = skull.getOwner(); - byte skullType = getOrdinal(SkullType.values(), skull.getSkullType()); - skull.getRotation(); - short rot = getOrdinal(BlockFace.values(), skull.getRotation()); - this.skullData.put(bl, new Object[]{o, rot, skullType}); + this.skullData.put(bl, new Object[]{skull.hasOwner(), skull.getOwner(), skull.getRotation(), skull.getSkullType()}); } else if (block.getState() instanceof Banner) { Banner banner = (Banner) block.getState(); DyeColor base = banner.getBaseColor(); diff --git a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index a358501e4..a7ec204c2 100644 --- a/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java +++ b/Bukkit/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -74,14 +74,14 @@ public class SQLUUIDHandler extends UUIDHandlerImplementation { public void run() { try { HashBiMap toAdd = HashBiMap.create(new HashMap()); - PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`"); - ResultSet resultSet = statement.executeQuery(); - while (resultSet.next()) { - StringWrapper username = new StringWrapper(resultSet.getString("username")); - UUID uuid = UUID.fromString(resultSet.getString("uuid")); - toAdd.put(new StringWrapper(username.value), uuid); + try (PreparedStatement statement = getConnection().prepareStatement("SELECT `uuid`, `username` FROM `usercache`"); + ResultSet resultSet = statement.executeQuery()) { + while (resultSet.next()) { + StringWrapper username = new StringWrapper(resultSet.getString("username")); + UUID uuid = UUID.fromString(resultSet.getString("uuid")); + toAdd.put(new StringWrapper(username.value), uuid); + } } - statement.close(); add(toAdd); add(new StringWrapper("*"), DBFunc.everyone); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java index cfd8d45e6..c58954355 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Area.java @@ -141,7 +141,7 @@ public class Area extends SubCommand { } }; if (hasConfirmation(player)) { - CmdConfirm.addPending(player, "/plot area create pos2 (Creates world)", run); + CmdConfirm.addPending(player, getCommandString() + " create pos2 (Creates world)", run); } else { run.run(); } @@ -172,7 +172,7 @@ public class Area extends SubCommand { for (int i = 2; i < args.length; i++) { String[] pair = args[i].split("="); if (pair.length != 2) { - C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [=]..."); + C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [=]..."); return false; } switch (pair[0].toLowerCase()) { @@ -218,7 +218,7 @@ public class Area extends SubCommand { object.type = pa.TYPE; break; default: - C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [=]..."); + C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [=]..."); return false; } } @@ -254,14 +254,14 @@ public class Area extends SubCommand { } }; if (hasConfirmation(player)) { - CmdConfirm.addPending(player, "/plot area " + StringMan.join(args, " "), run); + CmdConfirm.addPending(player, getCommandString() + " " + StringMan.join(args, " "), run); } else { run.run(); } return true; } if (pa.id == null) { - C.COMMAND_SYNTAX.send(player, "/plot area create [world[:id]] [=]..."); + C.COMMAND_SYNTAX.send(player, getCommandString() + " create [world[:id]] [=]..."); return false; } if (WorldUtil.IMP.isWorld(pa.worldname)) { @@ -275,7 +275,7 @@ public class Area extends SubCommand { player.teleport(WorldUtil.IMP.getSpawn(pa.worldname)); } player.setMeta("area_create_area", pa); - MainUtil.sendMessage(player, "$1Go to the first corner and use: $2/plot area create pos1"); + MainUtil.sendMessage(player, "$1Go to the first corner and use: $2 " + getCommandString() + " create pos1"); break; } return true; @@ -294,7 +294,7 @@ public class Area extends SubCommand { area = PS.get().getPlotAreaByString(args[1]); break; default: - C.COMMAND_SYNTAX.send(player, "/plot area info [area]"); + C.COMMAND_SYNTAX.send(player, getCommandString() + " info [area]"); return false; } if (area == null) { @@ -351,7 +351,7 @@ public class Area extends SubCommand { break; } default: - C.COMMAND_SYNTAX.send(player, "/plot area list [#]"); + C.COMMAND_SYNTAX.send(player, getCommandString() + " list [#]"); return false; } ArrayList areas = new ArrayList<>(PS.get().getPlotAreas()); @@ -388,7 +388,8 @@ public class Area extends SubCommand { message.text("[").color("$3") .text(i + "").command(visit).tooltip(visit).color("$1") .text("]").color("$3") - .text(" " + name).tooltip(tooltip).command("/plot area info " + area).color("$1").text(" - ").color("$2") + .text(" " + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ") + .color("$2") .text(area.TYPE + ":" + area.TERRAIN).color("$3"); } }, "/plot area list", C.AREA_LIST_HEADER_PAGED.s()); diff --git a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java index fac36dbc0..bb600c711 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/commands/Delete.java @@ -60,7 +60,7 @@ public class Delete extends SubCommand { sendMessage(plr, C.ADDED_BALANCE, value + ""); } } - MainUtil.sendMessage(plr, C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + MainUtil.sendMessage(plr, C.CLEARING_DONE, System.currentTimeMillis() - start); } }); if (result) { @@ -71,7 +71,7 @@ public class Delete extends SubCommand { } }; if (hasConfirmation(plr)) { - CmdConfirm.addPending(plr, "/plot delete " + plot.getId(), run); + CmdConfirm.addPending(plr, getCommandString() + ' ' + plot.getId(), run); } else { TaskManager.runTask(run); } diff --git a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java index 6dd62f0a2..2fdc8d0b1 100644 --- a/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java +++ b/Core/src/main/java/com/intellectualcrafters/plot/util/UUIDHandlerImplementation.java @@ -25,7 +25,7 @@ public abstract class UUIDHandlerImplementation { public final ConcurrentHashMap players; public final HashSet unknown = new HashSet<>(); - public UUIDWrapper uuidWrapper = null; + public UUIDWrapper uuidWrapper; private boolean cached = false; private BiMap uuidMap = HashBiMap.create(new HashMap()); @@ -181,7 +181,6 @@ public abstract class UUIDHandlerImplementation { public void handleShutdown() { this.players.clear(); this.uuidMap.clear(); - this.uuidWrapper = null; } public String getName(UUID uuid) { diff --git a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java index 611edac2c..21414df33 100644 --- a/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java +++ b/Sponge/src/main/java/com/plotsquared/sponge/uuid/SpongeUUIDHandler.java @@ -12,22 +12,22 @@ import org.spongepowered.api.profile.GameProfile; import java.util.UUID; public class SpongeUUIDHandler extends UUIDHandlerImplementation { - - public SpongeUUIDHandler(final UUIDWrapper wrapper) { + + public SpongeUUIDHandler(UUIDWrapper wrapper) { super(wrapper); } @Override - public boolean startCaching(final Runnable whenDone) { + public boolean startCaching(Runnable whenDone) { if (!super.startCaching(whenDone)) { return false; } return cache(whenDone); } - - public boolean cache(final Runnable whenDone) { + + public boolean cache(Runnable whenDone) { add(new StringWrapper("*"), DBFunc.everyone); - for (final GameProfile profile : SpongeMain.THIS.getResolver().getCachedProfiles()) { + for (GameProfile profile : SpongeMain.THIS.getServer().getGameProfileManager().getCache().getProfiles()) { String name = profile.getName().orElse(null); if (name != null) { add(new StringWrapper(name), profile.getUniqueId()); @@ -37,11 +37,11 @@ public class SpongeUUIDHandler extends UUIDHandlerImplementation { } @Override - public void fetchUUID(final String name, final RunnableVal ifFetch) { + public void fetchUUID(String name, RunnableVal ifFetch) { TaskManager.runTaskAsync(new Runnable() { @Override public void run() { - ifFetch.value = uuidWrapper.getUUID(name); + ifFetch.value = SpongeUUIDHandler.this.uuidWrapper.getUUID(name); TaskManager.runTask(ifFetch); } });