From 4cf92c4a0a78fe3650068e9ff7c522f28751f450 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sat, 21 Feb 2015 15:27:01 +1100 Subject: [PATCH] cache player --- .../intellectualcrafters/plot/BukkitMain.java | 54 +++++++++++-------- .../intellectualcrafters/plot/IPlotMain.java | 7 +-- .../plot/commands/Auto.java | 2 +- .../plot/commands/DebugClear.java | 2 +- .../plot/commands/MainCommand.java | 17 +++--- .../plot/commands/Reload.java | 1 + .../plot/commands/SubCommand.java | 6 +-- .../plot/commands/Trim.java | 2 +- .../plot/commands/WE_Anywhere.java | 2 +- .../plot/generator/AugmentedPopulator.java | 1 - .../plot/generator/BukkitHybridUtils.java | 1 - .../plot/generator/HybridPlotManager.java | 14 ----- .../plot/generator/SquarePlotManager.java | 1 - .../plot/listeners/InventoryListener.java | 4 +- .../plot/listeners/PlayerEvents.java | 8 +-- .../plot/listeners/PlayerEvents_1_8.java | 2 +- .../plot/listeners/PlotListener.java | 1 - .../plot/listeners/PlotPlusListener.java | 2 +- .../plot/listeners/WorldEditListener.java | 2 +- .../plot/object/BukkitPlayer.java | 1 + .../plot/object/PlotManager.java | 2 - .../plot/object/PlotPlayer.java | 3 -- .../plot/util/ClusterManager.java | 4 +- .../plot/util/ExpireManager.java | 5 +- .../plot/util/MainUtil.java | 6 --- .../plot/util/Permissions.java | 1 - .../util/bukkit/BukkitPlayerFunctions.java | 44 ++++++--------- .../plot/util/bukkit/BukkitUtil.java | 16 ++++++ .../plot/util/bukkit/ChunkManager.java | 3 +- .../plot/util/bukkit/PWE.java | 1 - 30 files changed, 98 insertions(+), 117 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java index e93ae098f..aa8241d28 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/BukkitMain.java @@ -1,25 +1,7 @@ package com.intellectualcrafters.plot; -import com.intellectualcrafters.plot.commands.Buy; -import com.intellectualcrafters.plot.commands.MainCommand; -import com.intellectualcrafters.plot.commands.WE_Anywhere; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.database.PlotMeConverter; -import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; -import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.generator.HybridGen; -import com.intellectualcrafters.plot.listeners.*; -import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.Location; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.util.ConsoleColors; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.*; -import com.sk89q.worldedit.bukkit.WorldEditPlugin; +import java.io.File; +import java.util.Arrays; import net.milkbowl.vault.economy.Economy; @@ -39,8 +21,34 @@ import org.bukkit.plugin.Plugin; import org.bukkit.plugin.RegisteredServiceProvider; import org.bukkit.plugin.java.JavaPlugin; -import java.io.File; -import java.util.Arrays; +import com.intellectualcrafters.plot.commands.Buy; +import com.intellectualcrafters.plot.commands.MainCommand; +import com.intellectualcrafters.plot.commands.WE_Anywhere; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.config.Settings; +import com.intellectualcrafters.plot.database.PlotMeConverter; +import com.intellectualcrafters.plot.events.PlotDeleteEvent; +import com.intellectualcrafters.plot.generator.HybridGen; +import com.intellectualcrafters.plot.listeners.ForceFieldListener; +import com.intellectualcrafters.plot.listeners.InventoryListener; +import com.intellectualcrafters.plot.listeners.PlayerEvents; +import com.intellectualcrafters.plot.listeners.PlayerEvents_1_8; +import com.intellectualcrafters.plot.listeners.PlotPlusListener; +import com.intellectualcrafters.plot.listeners.WorldEditListener; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.util.ConsoleColors; +import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitTaskManager; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; +import com.intellectualcrafters.plot.util.bukkit.Metrics; +import com.intellectualcrafters.plot.util.bukkit.SendChunk; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast; +import com.intellectualcrafters.plot.util.bukkit.SetBlockFast_1_8; +import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; +import com.intellectualcrafters.plot.util.bukkit.SetBlockSlow; +import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; +import com.sk89q.worldedit.bukkit.WorldEditPlugin; public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { public static BukkitMain THIS = null; @@ -79,7 +87,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { if (Settings.USE_PLOTME_ALIAS) { player.performCommand(message.replace("/plotme", "plots")); } else { - MainUtil.sendMessage(new BukkitPlayer(player), C.NOT_USING_PLOTME); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_USING_PLOTME); } event.setCancelled(true); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index f7f7250ec..1894c5d22 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -1,11 +1,12 @@ package com.intellectualcrafters.plot; +import java.io.File; + +import net.milkbowl.vault.economy.Economy; + import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.TaskManager; -import net.milkbowl.vault.economy.Economy; - -import java.io.File; public interface IPlotMain { public void log(String message); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java index 1e3912f18..df81089b7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Auto.java @@ -37,8 +37,8 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.ClusterManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; public class Auto extends SubCommand { public Auto() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java index 7514de024..b2aa400a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/DebugClear.java @@ -32,8 +32,8 @@ import com.intellectualcrafters.plot.generator.SquarePlotWorld; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class DebugClear extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java index 85d2b3139..0d72e1e8d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MainCommand.java @@ -20,20 +20,21 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; + +import org.bukkit.ChatColor; +import org.bukkit.command.Command; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.StringComparison; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import org.bukkit.ChatColor; -import org.bukkit.command.Command; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; /** * PlotSquared command class diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java index 945b676f7..cf82c6376 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Reload.java @@ -25,6 +25,7 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class Reload extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java index bcfe550a5..03d625b7d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/SubCommand.java @@ -20,13 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; +import java.util.ArrayList; +import java.util.Arrays; + import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; -import java.util.ArrayList; -import java.util.Arrays; - /** * SubCommand class * diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java index d665c91f6..612baa903 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trim.java @@ -40,8 +40,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.ChunkManager; public class Trim extends SubCommand { public static boolean TASK = false; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java index 33f56eb09..b7688645f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/WE_Anywhere.java @@ -24,8 +24,8 @@ import org.bukkit.entity.Player; import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.util.bukkit.PWE; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.PWE; public class WE_Anywhere extends SubCommand { public WE_Anywhere() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java index cd69cf2c6..e167c49ff 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/AugmentedPopulator.java @@ -18,7 +18,6 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.AChunkManager; -import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java index 12d78baa0..b788efd39 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/BukkitHybridUtils.java @@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; public class BukkitHybridUtils extends HybridUtils { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java index 098a8cc3c..90bf4e149 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/HybridPlotManager.java @@ -20,27 +20,13 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.generator; -import java.io.File; -import java.util.ArrayList; -import java.util.HashMap; - -import com.intellectualcrafters.jnbt.CompoundTag; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; -import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") public class HybridPlotManager extends ClassicPlotManager { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java index 87b838295..4ac024cac 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/generator/SquarePlotManager.java @@ -8,7 +8,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.AChunkManager; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.ChunkManager; /** * A plot manager with a square grid layout, with square shaped plots diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java index c44248d10..15004e90f 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/InventoryListener.java @@ -9,7 +9,7 @@ import org.bukkit.event.inventory.InventoryInteractEvent; import org.bukkit.inventory.Inventory; import com.intellectualcrafters.plot.object.InfoInventory; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.MainUtil; /** * Created 2014-11-18 for PlotSquared @@ -36,7 +36,7 @@ public class InventoryListener implements Listener { case 4: case 5: case 6: - BukkitPlayerFunctions.sendMessage(player, "This is not implemented yet"); + MainUtil.sendMessage(player, "This is not implemented yet"); break; default: break; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java index 0938277b4..0d4d50273 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents.java @@ -97,12 +97,13 @@ import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.PlotGenerator; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -143,7 +144,8 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi if (!player.hasPlayedBefore()) { player.saveData(); } - final String username = player.getName(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + final String username = pp.getName(); final StringWrapper name = new StringWrapper(username); final UUID uuid = UUIDHandler.getUUID(player); UUIDHandler.add(name, uuid); @@ -154,7 +156,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi } if (Settings.TELEPORT_ON_LOGIN) { BukkitUtil.teleportPlayer(player, MainUtil.getPlotHomeDefault(plot)); - BukkitPlayerFunctions.sendMessage(event.getPlayer(), C.TELEPORTED_TO_ROAD); + MainUtil.sendMessage(pp, C.TELEPORTED_TO_ROAD); } plotEntry(player, plot); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java index 5f7c23ff0..5301f9cdd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlayerEvents_1_8.java @@ -13,8 +13,8 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class PlayerEvents_1_8 extends PlotListener implements Listener { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java index d1754a687..0b8b089a6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotListener.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.listeners; -import java.util.ArrayList; import java.util.Arrays; import java.util.UUID; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java index 0ff8ee142..b695bf5dd 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/PlotPlusListener.java @@ -53,8 +53,8 @@ import com.intellectualcrafters.plot.events.PlayerLeavePlotEvent; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java index ba8da2423..453f6b144 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/listeners/WorldEditListener.java @@ -48,9 +48,9 @@ import com.intellectualcrafters.plot.events.PlotDeleteEvent; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.PWE; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.LocalSession; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java index f20bf2043..f69742be5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/BukkitPlayer.java @@ -13,6 +13,7 @@ public class BukkitPlayer implements PlotPlayer { UUID uuid; String name; + public BukkitPlayer(Player player, String name, UUID uuid) { this.player = player; this.name = name; diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java index 17667fe95..62bd5aab5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotManager.java @@ -22,8 +22,6 @@ package com.intellectualcrafters.plot.object; import java.util.ArrayList; -import org.bukkit.block.Biome; - public abstract class PlotManager { /* * Plot locations (methods with Abs in them will not need to consider mega diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 2d0b7d62c..f5682afdf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -1,8 +1,5 @@ package com.intellectualcrafters.plot.object; -import com.intellectualcrafters.plot.BukkitMain; -import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; - import java.util.UUID; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java index 33731488c..67cd05ef3 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ClusterManager.java @@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.generator.AugmentedPopulator; import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotCluster; @@ -25,7 +24,6 @@ import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SetBlockManager; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @@ -262,7 +260,7 @@ public class ClusterManager { ClusterManager.regenerating.remove(cluster.world + ":" + cluster.getName()); final Player owner = UUIDHandler.uuidWrapper.getPlayer(cluster.owner); if (owner != null) { - MainUtil.sendMessage(new BukkitPlayer(owner), C.CLEARING_DONE); + MainUtil.sendMessage(BukkitUtil.getPlayer(owner), C.CLEARING_DONE); } } }, (interval * chunks.size()) + 20); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java index 974a58b0c..4647058f6 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/ExpireManager.java @@ -19,11 +19,10 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.events.PlotDeleteEvent; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; +import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class ExpireManager { @@ -105,7 +104,7 @@ public class ExpireManager { for (final UUID helper : plot.helpers) { final Player player = UUIDHandler.uuidWrapper.getPlayer(helper); if (player != null) { - MainUtil.sendMessage(new BukkitPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_REMOVED_HELPER, plot.id.toString()); } } final PlotManager manager = PlotSquared.getPlotManager(world); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java index 577758b33..fab915f6c 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/MainUtil.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerTeleportToPlotEvent; import com.intellectualcrafters.plot.object.BlockLoc; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; @@ -43,7 +42,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotSettings; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.SendChunk; /** @@ -961,8 +959,4 @@ public class MainUtil { } return getPlot(loc.getWorld(), id); } - - public static void setBlock(String world, int i, int j, int k, int l, byte b) { - BlockManager.setBl - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index 6bf280849..bbb3bc475 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -1,6 +1,5 @@ package com.intellectualcrafters.plot.util; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.object.PlotPlayer; public class Permissions { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java index c18c41b31..1b9d6b4a5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitPlayerFunctions.java @@ -20,30 +20,23 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.util.bukkit; -import com.intellectualcrafters.plot.BukkitMain; -import com.intellectualcrafters.plot.PlotSquared; -import com.intellectualcrafters.plot.config.C; -import com.intellectualcrafters.plot.config.Settings; -import com.intellectualcrafters.plot.object.BukkitPlayer; -import com.intellectualcrafters.plot.object.Plot; -import com.intellectualcrafters.plot.object.PlotId; -import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; -import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.Permissions; - -import net.milkbowl.vault.economy.Economy; - -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; -import org.bukkit.entity.Player; -import org.bukkit.util.ChatPaginator; - import java.util.ArrayList; import java.util.HashSet; import java.util.Set; import java.util.UUID; +import net.milkbowl.vault.economy.Economy; + +import org.bukkit.OfflinePlayer; +import org.bukkit.entity.Player; + +import com.intellectualcrafters.plot.PlotSquared; +import com.intellectualcrafters.plot.config.C; +import com.intellectualcrafters.plot.object.Plot; +import com.intellectualcrafters.plot.object.PlotId; +import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.MainUtil; + /** * Functions involving players, plots and locations. */ @@ -54,13 +47,6 @@ public class BukkitPlayerFunctions { * - We will try to move as many functions as we can out of this class and into the MainUtil class */ - - - - - - - /** * Clear a plot. Use null player if no player is present * @param player @@ -74,7 +60,7 @@ public class BukkitPlayerFunctions { @Override public void run() { if ((player != null) && player.isOnline()) { - MainUtil.sendMessage(new BukkitPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); + MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.CLEARING_DONE, "" + (System.currentTimeMillis() - start)); } } }; @@ -99,11 +85,11 @@ public class BukkitPlayerFunctions { if (cost > 0d) { final Economy economy = PlotSquared.economy; if (economy.getBalance(plr) < cost) { - MainUtil.sendMessage(new BukkitPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); + MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.CANNOT_AFFORD_MERGE, "" + cost); return false; } economy.withdrawPlayer(plr, cost); - MainUtil.sendMessage(new BukkitPlayer(plr), C.REMOVED_BALANCE, cost + ""); + MainUtil.sendMessage(BukkitUtil.getPlayer(plr), C.REMOVED_BALANCE, cost + ""); } } return MainUtil.mergePlots(world, plotIds, true); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index d2fb33be9..ce762e986 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -15,9 +15,11 @@ import org.bukkit.block.Sign; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; +import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; +import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; public class BukkitUtil extends BlockManager { @@ -25,6 +27,20 @@ public class BukkitUtil extends BlockManager { private static String lastString = null; private static World lastWorld = null; + private static HashMap players = new HashMap<>(); + private static Player lastPlayer = null; + private static PlotPlayer lastPlotPlayer = null; + + public static PlotPlayer getPlayer(Player player) { + if (player == lastPlayer) { + return lastPlotPlayer; + } + lastPlotPlayer = new BukkitPlayer(player); + players.put(lastPlotPlayer.getName(), lastPlotPlayer); + lastPlayer = player; + return lastPlotPlayer; + } + public static boolean loadChunk(String world, ChunkLoc loc) { return getWorld(world).getChunkAt(loc.x << 4, loc.z << 4).load(false); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java index 109be47c9..331df271d 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/ChunkManager.java @@ -45,7 +45,6 @@ import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.listeners.PlotListener; import com.intellectualcrafters.plot.object.BlockLoc; -import com.intellectualcrafters.plot.object.BukkitPlayer; import com.intellectualcrafters.plot.object.ChunkLoc; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; @@ -748,7 +747,7 @@ public class ChunkManager extends AChunkManager { if (plot.id.equals(id)) { if (entity instanceof Player) { final Player player = (Player) entity; - MainUtil.teleportPlayer(new BukkitPlayer(player), BukkitUtil.getLocation(entity), plot); + MainUtil.teleportPlayer(BukkitUtil.getPlayer(player), BukkitUtil.getLocation(entity), plot); PlotListener.plotExit(player, plot); } else { entity.remove(); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java index a7fe97869..6f61cf1ce 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/PWE.java @@ -22,7 +22,6 @@ package com.intellectualcrafters.plot.util.bukkit; import org.bukkit.entity.Player; -import com.intellectualcrafters.plot.BukkitMain; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager;