From 4eae78590fcbd845a0e27ec49b758bb6af93fb51 Mon Sep 17 00:00:00 2001 From: boy0001 Date: Fri, 31 Jul 2015 03:24:01 +1000 Subject: [PATCH] Refactor + optimizations --- .../intellectualcrafters/plot/IPlotMain.java | 7 + .../plot/api/PlotAPI.java | 6 +- .../plot/commands/Add.java | 2 +- .../plot/commands/DebugExec.java | 2 +- .../plot/commands/Deny.java | 2 +- .../plot/commands/FlagCmd.java | 3 +- .../plot/commands/Inbox.java | 2 - .../plot/commands/Info.java | 5 +- .../plot/commands/Merge.java | 3 +- .../plot/commands/Rate.java | 2 - .../plot/commands/Remove.java | 2 +- .../plot/commands/Set.java | 2 - .../plot/commands/Setup.java | 3 +- .../plot/commands/TP.java | 1 - .../plot/commands/Trust.java | 2 +- .../plot/commands/Undeny.java | 2 +- .../plot/commands/list.java | 4 +- .../plot/object/ConsolePlayer.java | 7 +- .../plot/object/Plot.java | 9 + .../plot/object/PlotPlayer.java | 278 +++++++++++++++--- .../plot/object/PlotSettings.java | 10 - .../plot/util/Permissions.java | 6 +- .../com/plotsquared/bukkit/BukkitMain.java | 57 ++-- .../{util/bukkit => }/chat/ArrayWrapper.java | 2 +- .../{util/bukkit => }/chat/FancyMessage.java | 4 +- .../chat/JsonRepresentedObject.java | 2 +- .../{util/bukkit => }/chat/JsonString.java | 2 +- .../{util/bukkit => }/chat/MessagePart.java | 2 +- .../{util/bukkit => }/chat/Reflection.java | 2 +- .../bukkit => }/chat/TextualComponent.java | 2 +- .../bukkit/generator/AugmentedPopulator.java | 4 +- .../bukkit/generator/BukkitPlotGenerator.java | 1 - .../BukkitPlotPopulator.java | 2 +- .../bukkit/generator/HybridGen.java | 1 - .../bukkit/generator/HybridPop.java | 1 - .../bukkit/listeners/ChatListener.java | 2 +- .../bukkit/listeners/ForceFieldListener.java | 4 +- .../bukkit/listeners/PlayerEvents.java | 54 +++- .../bukkit/listeners/PlayerEvents_1_8.java | 2 +- .../bukkit/listeners/PlayerEvents_1_8_3.java | 2 +- .../bukkit/listeners/PlotPlusListener.java | 2 +- .../bukkit/listeners/TNTListener.java | 2 +- .../listeners/worldedit/WEListener.java | 2 +- .../bukkit/object/BukkitPlayer.java | 59 +--- .../util/{bukkit => }/BukkitChunkManager.java | 2 +- .../{commands => util}/BukkitCommand.java | 3 +- .../util/{bukkit => }/BukkitEconHandler.java | 2 +- .../util/{bukkit => }/BukkitEventUtil.java | 2 +- .../bukkit/util/BukkitHybridUtils.java | 1 - .../{bukkit => }/BukkitInventoryUtil.java | 2 +- .../{bukkit => }/BukkitPlayerFunctions.java | 2 +- .../{bukkit => }/BukkitSchematicHandler.java | 2 +- .../{bukkit => }/BukkitSetBlockManager.java | 2 +- .../util/{bukkit => }/BukkitSetupUtils.java | 2 +- .../util/{bukkit => }/BukkitTaskManager.java | 2 +- .../bukkit/util/{bukkit => }/BukkitUtil.java | 3 +- .../bukkit/util/{bukkit => }/Metrics.java | 2 +- .../util/{bukkit => }/OfflinePlayerUtil.java | 2 +- .../bukkit/util/{bukkit => }/SendChunk.java | 2 +- .../util/{bukkit => }/SetBlockFast.java | 2 +- .../util/{bukkit => }/SetBlockFast_1_8.java | 2 +- .../util/{bukkit => }/SetBlockSlow.java | 2 +- .../bukkit/util/{bukkit => }/SetGenCB.java | 2 +- .../bukkit => }/uuid/FileUUIDHandler.java | 2 +- .../bukkit => }/uuid/SQLUUIDHandler.java | 2 +- .../com/plotsquared/sponge/SpongeMain.java | 27 +- .../sponge/generator/WorldModify.java | 4 - .../sponge/listener/MainListener.java | 34 ++- .../sponge/{ => object}/SpongePlayer.java | 59 +--- .../sponge/util/SpongeBlockManager.java | 1 - .../sponge/{ => util}/SpongeChunkManager.java | 9 +- .../sponge/util/SpongeCommand.java | 1 - .../sponge/util/SpongeInventoryUtil.java | 2 +- .../sponge/{ => util}/SpongeTitleManager.java | 5 +- .../plotsquared/sponge/util/SpongeUtil.java | 2 +- .../sponge/uuid/SpongeOnlineUUIDWrapper.java | 2 +- 76 files changed, 457 insertions(+), 303 deletions(-) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/ArrayWrapper.java (98%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/FancyMessage.java (99%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/JsonRepresentedObject.java (90%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/JsonString.java (95%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/MessagePart.java (99%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/Reflection.java (99%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/chat/TextualComponent.java (99%) rename src/main/java/com/plotsquared/bukkit/{object => generator}/BukkitPlotPopulator.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitChunkManager.java (99%) rename src/main/java/com/plotsquared/bukkit/{commands => util}/BukkitCommand.java (97%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitEconHandler.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitEventUtil.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitInventoryUtil.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitPlayerFunctions.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitSchematicHandler.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitSetBlockManager.java (95%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitSetupUtils.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitTaskManager.java (96%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/BukkitUtil.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/Metrics.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/OfflinePlayerUtil.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/SendChunk.java (98%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/SetBlockFast.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/SetBlockFast_1_8.java (99%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/SetBlockSlow.java (96%) rename src/main/java/com/plotsquared/bukkit/util/{bukkit => }/SetGenCB.java (98%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/uuid/FileUUIDHandler.java (99%) rename src/main/java/com/plotsquared/bukkit/{util/bukkit => }/uuid/SQLUUIDHandler.java (99%) rename src/main/java/com/plotsquared/sponge/{ => object}/SpongePlayer.java (82%) rename src/main/java/com/plotsquared/sponge/{ => util}/SpongeChunkManager.java (93%) rename src/main/java/com/plotsquared/sponge/{ => util}/SpongeTitleManager.java (79%) diff --git a/src/main/java/com/intellectualcrafters/plot/IPlotMain.java b/src/main/java/com/intellectualcrafters/plot/IPlotMain.java index 3e16674cc..b287db26f 100644 --- a/src/main/java/com/intellectualcrafters/plot/IPlotMain.java +++ b/src/main/java/com/intellectualcrafters/plot/IPlotMain.java @@ -30,6 +30,13 @@ public interface IPlotMain { */ File getDirectory(); + /** + * Wrap a player into a PlotPlayer object + * @param obj + * @return + */ + PlotPlayer wrapPlayer(Object obj); + /** * Disable the implementation * - If a full disable isn't feasibly, just disable what it can diff --git a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java index ae195a051..7f6f32822 100644 --- a/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java +++ b/src/main/java/com/intellectualcrafters/plot/api/PlotAPI.java @@ -50,8 +50,8 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitSetBlockManager; +import com.plotsquared.bukkit.util.BukkitUtil; /** * PlotSquared API @@ -185,7 +185,7 @@ import com.plotsquared.bukkit.util.bukkit.BukkitUtil; * * @return BukkitSetBlockManager * - * @see com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager + * @see com.plotsquared.bukkit.util.BukkitSetBlockManager */ public BukkitSetBlockManager getBukkitBlockManager() { return BukkitSetBlockManager.setBlockManager; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Add.java b/src/main/java/com/intellectualcrafters/plot/commands/Add.java index d4fae324a..6ae047878 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Add.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Add.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java index a510f3b00..445c15ee7 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/DebugExec.java @@ -30,7 +30,6 @@ import java.util.Date; import java.util.List; import java.util.UUID; -import com.intellectualcrafters.plot.util.StringMan; import org.bukkit.Bukkit; import com.intellectualcrafters.plot.PS; @@ -47,6 +46,7 @@ import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.ExpireManager; import com.intellectualcrafters.plot.util.MainUtil; +import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.util.BukkitHybridUtils; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java index f78dfc633..4d84b6649 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Deny.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Deny.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java index 525388248..b61512601 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/FlagCmd.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; -import com.intellectualcrafters.plot.util.StringMan; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.AbstractFlag; @@ -37,6 +35,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 05a43718d..dc2775c70 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -23,8 +23,6 @@ package com.intellectualcrafters.plot.commands; import java.util.ArrayList; import java.util.List; -import com.intellectualcrafters.plot.util.StringMan; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/src/main/java/com/intellectualcrafters/plot/commands/Info.java index 4ac7b18c5..305c8d941 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -25,9 +25,6 @@ import java.util.Collection; import java.util.UUID; import java.util.regex.Matcher; -import com.intellectualcrafters.plot.util.StringMan; - -import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.database.DBFunc; @@ -146,7 +143,7 @@ public class Info extends SubCommand { }; UUID uuid = player.getUUID(); String name = MainUtil.getName(plot.owner); - inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { "&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name, "&cAlias: &6" + plot.getSettings().getAlias(), "&cBiome: &6" + plot.getSettings().getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), "&cIs Denied: &6" + plot.isDenied(uuid)})); + inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cPlot Info", new String[] { "&cID: &6" + plot.getId().toString(), "&cOwner: &6" + name, "&cAlias: &6" + plot.getSettings().getAlias(), "&cBiome: &6" + plot.getBiome().toString().replaceAll("_", "").toLowerCase(), "&cCan Build: &6" + plot.isAdded(uuid), "&cIs Denied: &6" + plot.isDenied(uuid)})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cTrusted", new String[] {"&cAmount: &6" + plot.getTrusted().size(), "&8Click to view a list of the trusted users"})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cMembers", new String[] {"&cAmount: &6" + plot.getMembers().size(), "&8Click to view a list of plot members"})); inv.setItem(1, new PlotItemStack(388, (short) 0, 1, "&cDenied", new String[] {"&cDenied", "&cAmount: &6" + plot.getDenied().size(), "&8Click to view a list of denied players"})); diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java index 949373d40..62eb9b6c2 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Merge.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Merge.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.HashSet; import java.util.UUID; -import com.intellectualcrafters.plot.util.StringMan; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; @@ -38,6 +36,7 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; +import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 93d592be4..71e20e08a 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -26,8 +26,6 @@ import java.util.Comparator; import java.util.Map.Entry; import java.util.UUID; -import com.intellectualcrafters.plot.util.StringMan; - import org.apache.commons.lang.mutable.MutableInt; import org.bukkit.Bukkit; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Remove.java b/src/main/java/com/intellectualcrafters/plot/commands/Remove.java index f1f567dd8..22519b91e 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Remove.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Remove.java @@ -31,7 +31,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 81dd1cdc9..95527208b 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -24,8 +24,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.intellectualcrafters.plot.util.StringMan; - import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Setup.java b/src/main/java/com/intellectualcrafters/plot/commands/Setup.java index 9f4af6dc3..b92be1cbe 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Setup.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Setup.java @@ -25,8 +25,6 @@ import java.util.Arrays; import java.util.List; import java.util.Map.Entry; -import com.intellectualcrafters.plot.util.StringMan; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.ConfigurationNode; import com.intellectualcrafters.plot.config.Settings; @@ -36,6 +34,7 @@ import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SetupUtils; +import com.intellectualcrafters.plot.util.StringMan; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( diff --git a/src/main/java/com/intellectualcrafters/plot/commands/TP.java b/src/main/java/com/intellectualcrafters/plot/commands/TP.java index 5de0a1572..394f3938c 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/TP.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/TP.java @@ -20,7 +20,6 @@ //////////////////////////////////////////////////////////////////////////////////////////////////// package com.intellectualcrafters.plot.commands; -import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.object.Location; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Trust.java b/src/main/java/com/intellectualcrafters/plot/commands/Trust.java index e5c69c597..3dd3c23e3 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Trust.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Trust.java @@ -32,7 +32,7 @@ import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java b/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java index 6a9d82764..29613f264 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/Undeny.java @@ -30,7 +30,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.plotsquared.general.commands.Argument; import com.plotsquared.general.commands.CommandDeclaration; diff --git a/src/main/java/com/intellectualcrafters/plot/commands/list.java b/src/main/java/com/intellectualcrafters/plot/commands/list.java index b3b7e007d..9b0b58cf8 100644 --- a/src/main/java/com/intellectualcrafters/plot/commands/list.java +++ b/src/main/java/com/intellectualcrafters/plot/commands/list.java @@ -27,7 +27,6 @@ import java.util.List; import java.util.Map.Entry; import java.util.UUID; -import com.intellectualcrafters.plot.util.StringMan; import org.bukkit.ChatColor; import com.intellectualcrafters.plot.PS; @@ -43,9 +42,10 @@ import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.StringComparison; +import com.intellectualcrafters.plot.util.StringMan; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.bukkit.chat.FancyMessage; import com.plotsquared.bukkit.object.BukkitPlayer; -import com.plotsquared.bukkit.util.bukkit.chat.FancyMessage; import com.plotsquared.general.commands.CommandDeclaration; @CommandDeclaration( diff --git a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java index fc7b27267..422ec4428 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java +++ b/src/main/java/com/intellectualcrafters/plot/object/ConsolePlayer.java @@ -12,7 +12,7 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotWeather; -public class ConsolePlayer implements PlotPlayer { +public class ConsolePlayer extends PlotPlayer { private static ConsolePlayer instance; private Location loc; @@ -82,11 +82,6 @@ public class ConsolePlayer implements PlotPlayer { this.loc = loc; } - @Override - public boolean isOp() { - return true; - } - @Override public boolean isOnline() { return true; diff --git a/src/main/java/com/intellectualcrafters/plot/object/Plot.java b/src/main/java/com/intellectualcrafters/plot/object/Plot.java index 1512e020b..f46fba209 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/Plot.java +++ b/src/main/java/com/intellectualcrafters/plot/object/Plot.java @@ -29,6 +29,7 @@ import java.util.UUID; import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.Flag; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; @@ -473,6 +474,14 @@ public class Plot { MainUtil.setBiome(this, biome, whenDone); } + /** + * Get the biome (String) + */ + public String getBiome() { + final Location loc = getBottom().add(1, 0, 1); + return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ()); + } + /** * Return the top location for the plot * @return diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java index 673200167..e80b8bbcf 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotPlayer.java @@ -1,9 +1,15 @@ package com.intellectualcrafters.plot.object; +import java.util.Set; import java.util.UUID; +import java.util.concurrent.ConcurrentHashMap; +import com.intellectualcrafters.plot.PS; +import com.intellectualcrafters.plot.commands.RequiredType; +import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotWeather; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.general.commands.CommandCaller; /** @@ -11,33 +17,214 @@ import com.plotsquared.general.commands.CommandCaller; * * @author Citymonstret */ -public interface PlotPlayer extends CommandCaller { +public abstract class PlotPlayer implements CommandCaller { - long getPreviousLogin(); - - Location getLocation(); - - Location getLocationFull(); - - UUID getUUID(); - - boolean hasPermission(final String perm); - - void sendMessage(final String message); + /** + * The metadata map + */ + private ConcurrentHashMap meta; - void teleport(final Location loc); + /** + * Wrap a Player object to get a PlotPlayer
+ * - This will usually be cached, so no new object creation + * @param obj + * @return + */ + public static PlotPlayer wrap(Object obj) { + return PS.get().IMP.wrapPlayer(obj); + } - boolean isOp(); + /** + * Get the cached PlotPlayer from a username
+ * - This will return null if the player has just logged in or is not online + * @param name + * @return + */ + public static PlotPlayer get(String name) { + return UUIDHandler.getPlayer(name); + } + + /** + * Set some session only metadata for the player + * @param key + * @param value + */ + public void setMeta(String key, Object value) { + if (this.meta == null) { + this.meta = new ConcurrentHashMap(); + } + this.meta.put(key, value); + } - boolean isOnline(); + /** + * Get the metadata for a key + * @param key + * @return + */ + public Object getMeta(String key) { + if (this.meta != null) { + return this.meta.get(key); + } + return null; + } - String getName(); + /** + * Delete the metadata for a key
+ * - metadata is session only + * - deleting other plugin's metadata may cause issues + * @param key + */ + public void deleteMeta(String key) { + if (this.meta != null) { + this.meta.remove(key); + } + } - void setCompassTarget(Location loc); + /** + * Returns the player's name + * @see #getName() + */ + public String toString() { + return getName(); + } - void loadData(); + /** + * Get the player's current plot
+ * - This is cached + * @return + */ + public Plot getCurrentPlot() { + return (Plot) getMeta("lastplot"); + } - void saveData(); + /** + * Get the total number of allowed plots + * @return + */ + public int getAllowedPlots() { + return MainUtil.getAllowedPlots(this); + } + + /** + * Get the number of plots the player owns + * @return + */ + public int getPlotCount() { + return MainUtil.getPlayerPlotCount(this); + } + + /** + * Get the number of plots the player owns in the world + * @param world + * @return + */ + public int getPlotCount(String world) { + return MainUtil.getPlayerPlotCount(world, this); + } + + /** + * Get the plots the player owns + * @see #PS.java for more searching functions + * @return Set of plots + */ + public Set getPlots() { + return PS.get().getPlots(this); + } + + /** + * Return the PlotWorld the player is currently in, or null + * @return + */ + public PlotWorld getPlotWorld() { + return PS.get().getPlotWorld(getLocation().getWorld()); + } + + @Override + public RequiredType getSuperCaller() { + return RequiredType.PLAYER; + } + + /////////////// PLAYER META /////////////// + + ////////////// PARTIALLY IMPLEMENTED /////////// + /** + * Get the player's last recorded location + * @return + */ + public Location getLocation() { + Location loc = (Location) getMeta("location"); + if (loc != null) { + return loc; + } + return null; + } + + //////////////////////////////////////////////// + + /** + * Get the previous time the player logged in + * @return + */ + public abstract long getPreviousLogin(); + + + + /** + * Get the player's full location (including yaw/pitch) + * @return + */ + public abstract Location getLocationFull(); + + /** + * Get the player's UUID + * @return + */ + public abstract UUID getUUID(); + + /** + * Check the player's permissions
+ * - Will be cached if permission caching is enabled + */ + public abstract boolean hasPermission(final String perm); + + /** + * Send the player a message + */ + public abstract void sendMessage(final String message); + + /** + * Teleport the player to a location + * @param loc + */ + public abstract void teleport(final Location loc); + + /** + * Is the player online + * @return + */ + public abstract boolean isOnline(); + + /** + * Get the player's name + * @return + */ + public abstract String getName(); + + /** + * Set the compass target + * @param loc + */ + public abstract void setCompassTarget(Location loc); + + /** + * Load the player data from disk (if applicable) + */ + public abstract void loadData(); + + /** + * Save the player data from disk (if applicable) + */ + public abstract void saveData(); /** * Set player data that will persist restarts @@ -45,35 +232,60 @@ public interface PlotPlayer extends CommandCaller { * - For session only data use meta * @param key */ - void setAttribute(String key); + public abstract void setAttribute(String key); /** * The attribute will be either true or false * @param key */ - boolean getAttribute(String key); + public abstract boolean getAttribute(String key); /** * Remove an attribute from a player * @param key */ - void removeAttribute(String key); + public abstract void removeAttribute(String key); - void setMeta(String key, Object value); - Object getMeta(String key); - void deleteMeta(String key); + /** + * Set the player's local weather + * @param weather + */ + public abstract void setWeather(PlotWeather weather); - void setWeather(PlotWeather weather); + /** + * Get the player's gamemode + * @return + */ + public abstract PlotGamemode getGamemode(); - PlotGamemode getGamemode(); + /** + * Set the player's gamemode + * @param gamemode + */ + public abstract void setGamemode(PlotGamemode gamemode); - void setGamemode(PlotGamemode gamemode); + /** + * Set the player's local time + * @param time + */ + public abstract void setTime(long time); - void setTime(long time); + /** + * Set the player's fly mode + * @param fly + */ + public abstract void setFlight(boolean fly); - void setFlight(boolean fly); + /** + * Play music at a location for the player + * @param loc + * @param id + */ + public abstract void playMusic(Location loc, int id); - void playMusic(Location loc, int id); - - void kick(String message); + /** + * Kick the player from the game + * @param message + */ + public abstract void kick(String message); } diff --git a/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index 7534e3e86..f1fc57a37 100644 --- a/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -28,8 +28,6 @@ import java.util.UUID; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.comment.PlotComment; -import com.intellectualcrafters.plot.util.BlockManager; -import com.intellectualcrafters.plot.util.MainUtil; /** * plot settings @@ -111,14 +109,6 @@ public class PlotSettings { this.merged[direction] = merged; } - /** - * @return biome at plot loc - */ - public String getBiome() { - final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); - return BlockManager.manager.getBiome(loc.getWorld(), loc.getX(), loc.getZ()); - } - public BlockLoc getPosition() { if (this.position == null) { return new BlockLoc(0, 0, 0); diff --git a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java index de0a53f45..d1809004a 100644 --- a/src/main/java/com/intellectualcrafters/plot/util/Permissions.java +++ b/src/main/java/com/intellectualcrafters/plot/util/Permissions.java @@ -35,7 +35,7 @@ public enum Permissions { public static boolean hasPermission(final PlotPlayer player, final String perm) { - if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { + if ((player == null) || player.hasPermission(ADMIN.s)) { return true; } if (player.hasPermission(perm)) { @@ -53,7 +53,7 @@ public enum Permissions { } public static boolean hasPermission(final PlotPlayer player, final String perm, boolean notify) { - if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { + if ((player == null) || player.hasPermission(ADMIN.s)) { return true; } if (player.hasPermission(perm)) { @@ -74,7 +74,7 @@ public enum Permissions { } public static int hasPermissionRange(final PlotPlayer player, final String stub, final int range) { - if ((player == null) || player.isOp() || player.hasPermission(ADMIN.s)) { + if ((player == null) || player.hasPermission(ADMIN.s)) { return Integer.MAX_VALUE; } if (player.hasPermission(stub + ".*")) { diff --git a/src/main/java/com/plotsquared/bukkit/BukkitMain.java b/src/main/java/com/plotsquared/bukkit/BukkitMain.java index 68236a262..18f2404d9 100644 --- a/src/main/java/com/plotsquared/bukkit/BukkitMain.java +++ b/src/main/java/com/plotsquared/bukkit/BukkitMain.java @@ -2,13 +2,16 @@ package com.plotsquared.bukkit; import java.io.File; import java.util.Arrays; +import java.util.UUID; import org.bukkit.Bukkit; import org.bukkit.ChatColor; import org.bukkit.Location; +import org.bukkit.OfflinePlayer; import org.bukkit.World; import org.bukkit.command.PluginCommand; import org.bukkit.entity.Entity; +import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.generator.ChunkGenerator; import org.bukkit.plugin.Plugin; @@ -36,9 +39,9 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; -import com.plotsquared.bukkit.commands.BukkitCommand; import com.plotsquared.bukkit.database.plotme.ClassicPlotMeConnector; import com.plotsquared.bukkit.database.plotme.LikePlotMeConverter; import com.plotsquared.bukkit.database.plotme.PlotMeConnector_017; @@ -55,27 +58,28 @@ import com.plotsquared.bukkit.listeners.WorldEvents; import com.plotsquared.bukkit.listeners.worldedit.WEListener; import com.plotsquared.bukkit.listeners.worldedit.WESubscriber; import com.plotsquared.bukkit.titles.DefaultTitle; +import com.plotsquared.bukkit.util.BukkitChunkManager; +import com.plotsquared.bukkit.util.BukkitCommand; +import com.plotsquared.bukkit.util.BukkitEconHandler; +import com.plotsquared.bukkit.util.BukkitEventUtil; import com.plotsquared.bukkit.util.BukkitHybridUtils; -import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager; -import com.plotsquared.bukkit.util.bukkit.BukkitEconHandler; -import com.plotsquared.bukkit.util.bukkit.BukkitEventUtil; -import com.plotsquared.bukkit.util.bukkit.BukkitInventoryUtil; -import com.plotsquared.bukkit.util.bukkit.BukkitSchematicHandler; -import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; -import com.plotsquared.bukkit.util.bukkit.BukkitSetupUtils; -import com.plotsquared.bukkit.util.bukkit.BukkitTaskManager; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; -import com.plotsquared.bukkit.util.bukkit.Metrics; -import com.plotsquared.bukkit.util.bukkit.SendChunk; -import com.plotsquared.bukkit.util.bukkit.SetBlockFast; -import com.plotsquared.bukkit.util.bukkit.SetBlockFast_1_8; -import com.plotsquared.bukkit.util.bukkit.SetBlockSlow; -import com.plotsquared.bukkit.util.bukkit.SetGenCB; -import com.plotsquared.bukkit.util.bukkit.uuid.FileUUIDHandler; -import com.plotsquared.bukkit.util.bukkit.uuid.SQLUUIDHandler; +import com.plotsquared.bukkit.util.BukkitInventoryUtil; +import com.plotsquared.bukkit.util.BukkitSchematicHandler; +import com.plotsquared.bukkit.util.BukkitSetBlockManager; +import com.plotsquared.bukkit.util.BukkitSetupUtils; +import com.plotsquared.bukkit.util.BukkitTaskManager; +import com.plotsquared.bukkit.util.BukkitUtil; +import com.plotsquared.bukkit.util.Metrics; +import com.plotsquared.bukkit.util.SendChunk; +import com.plotsquared.bukkit.util.SetBlockFast; +import com.plotsquared.bukkit.util.SetBlockFast_1_8; +import com.plotsquared.bukkit.util.SetBlockSlow; +import com.plotsquared.bukkit.util.SetGenCB; import com.plotsquared.bukkit.uuid.DefaultUUIDWrapper; +import com.plotsquared.bukkit.uuid.FileUUIDHandler; import com.plotsquared.bukkit.uuid.LowerOfflineUUIDWrapper; import com.plotsquared.bukkit.uuid.OfflineUUIDWrapper; +import com.plotsquared.bukkit.uuid.SQLUUIDHandler; import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.bukkit.WorldEditPlugin; @@ -543,4 +547,21 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain { // Already initialized in UUID handler return AbstractTitle.TITLE_CLASS; } + + @Override + public PlotPlayer wrapPlayer(Object obj) { + if (obj instanceof Player) { + return BukkitUtil.getPlayer((Player) obj); + } + else if (obj instanceof OfflinePlayer) { + return BukkitUtil.getPlayer((OfflinePlayer) obj); + } + else if (obj instanceof String) { + return UUIDHandler.getPlayer((String) obj); + } + else if (obj instanceof UUID) { + return UUIDHandler.getPlayer((UUID) obj); + } + return null; + } } diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/ArrayWrapper.java b/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/ArrayWrapper.java rename to src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java index d9d38ea15..d027bb08a 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/ArrayWrapper.java +++ b/src/main/java/com/plotsquared/bukkit/chat/ArrayWrapper.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.lang.reflect.Array; import java.util.Arrays; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/FancyMessage.java b/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/FancyMessage.java rename to src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java index d2857d4af..9e998f8d8 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/FancyMessage.java +++ b/src/main/java/com/plotsquared/bukkit/chat/FancyMessage.java @@ -1,6 +1,6 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; -import static com.plotsquared.bukkit.util.bukkit.chat.TextualComponent.rawText; +import static com.plotsquared.bukkit.chat.TextualComponent.rawText; import java.io.IOException; import java.io.StringWriter; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonRepresentedObject.java b/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java similarity index 90% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonRepresentedObject.java rename to src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java index 82506611f..cffcaa621 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonRepresentedObject.java +++ b/src/main/java/com/plotsquared/bukkit/chat/JsonRepresentedObject.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.io.IOException; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonString.java b/src/main/java/com/plotsquared/bukkit/chat/JsonString.java similarity index 95% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonString.java rename to src/main/java/com/plotsquared/bukkit/chat/JsonString.java index 071536ad9..3ee438c0f 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/JsonString.java +++ b/src/main/java/com/plotsquared/bukkit/chat/JsonString.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.io.IOException; import java.util.HashMap; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/MessagePart.java b/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/MessagePart.java rename to src/main/java/com/plotsquared/bukkit/chat/MessagePart.java index c5105b5fd..4669560c0 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/MessagePart.java +++ b/src/main/java/com/plotsquared/bukkit/chat/MessagePart.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.io.IOException; import java.util.ArrayList; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/Reflection.java b/src/main/java/com/plotsquared/bukkit/chat/Reflection.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/Reflection.java rename to src/main/java/com/plotsquared/bukkit/chat/Reflection.java index 2a8523a12..b02d6858d 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/Reflection.java +++ b/src/main/java/com/plotsquared/bukkit/chat/Reflection.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.lang.reflect.Field; import java.lang.reflect.Method; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/TextualComponent.java b/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/chat/TextualComponent.java rename to src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java index d46305fa5..08c491f5f 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/chat/TextualComponent.java +++ b/src/main/java/com/plotsquared/bukkit/chat/TextualComponent.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.chat; +package com.plotsquared.bukkit.chat; import java.io.IOException; import java.util.HashMap; diff --git a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java index 3782d0e9b..9cec44063 100644 --- a/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java +++ b/src/main/java/com/plotsquared/bukkit/generator/AugmentedPopulator.java @@ -23,8 +23,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.ChunkManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.TaskManager; -import com.plotsquared.bukkit.util.bukkit.BukkitChunkManager; -import com.plotsquared.bukkit.util.bukkit.BukkitSetBlockManager; +import com.plotsquared.bukkit.util.BukkitChunkManager; +import com.plotsquared.bukkit.util.BukkitSetBlockManager; public class AugmentedPopulator extends BlockPopulator { public final PlotWorld plotworld; diff --git a/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java b/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java index c232d998d..1505a3f2e 100644 --- a/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java +++ b/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotGenerator.java @@ -40,7 +40,6 @@ import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.SetupObject; import com.intellectualcrafters.plot.util.ChunkManager; import com.plotsquared.bukkit.listeners.WorldEvents; -import com.plotsquared.bukkit.object.BukkitPlotPopulator; public abstract class BukkitPlotGenerator extends ChunkGenerator { diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlotPopulator.java b/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotPopulator.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/object/BukkitPlotPopulator.java rename to src/main/java/com/plotsquared/bukkit/generator/BukkitPlotPopulator.java index 5b8e735b3..4f71a76d3 100644 --- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlotPopulator.java +++ b/src/main/java/com/plotsquared/bukkit/generator/BukkitPlotPopulator.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.object; +package com.plotsquared.bukkit.generator; import java.util.HashMap; import java.util.Map.Entry; diff --git a/src/main/java/com/plotsquared/bukkit/generator/HybridGen.java b/src/main/java/com/plotsquared/bukkit/generator/HybridGen.java index 463d8b9f2..1b8f742f0 100644 --- a/src/main/java/com/plotsquared/bukkit/generator/HybridGen.java +++ b/src/main/java/com/plotsquared/bukkit/generator/HybridGen.java @@ -36,7 +36,6 @@ import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; -import com.plotsquared.bukkit.object.BukkitPlotPopulator; /** * The default generator is very messy, as we have decided to try externalize all calculations from within the loop. - diff --git a/src/main/java/com/plotsquared/bukkit/generator/HybridPop.java b/src/main/java/com/plotsquared/bukkit/generator/HybridPop.java index 9b9ad0857..38051e082 100644 --- a/src/main/java/com/plotsquared/bukkit/generator/HybridPop.java +++ b/src/main/java/com/plotsquared/bukkit/generator/HybridPop.java @@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.object.PseudoRandom; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.object.schematic.PlotItem; import com.intellectualcrafters.plot.util.BlockManager; -import com.plotsquared.bukkit.object.BukkitPlotPopulator; /** * @author Citymonstret diff --git a/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java b/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java index e6b8dcaba..2dd5a032c 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/ChatListener.java @@ -18,7 +18,7 @@ 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.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; /** * Created 2015-07-13 for PlotSquaredGit diff --git a/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java b/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java index 07a3eadfd..6ef613717 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/ForceFieldListener.java @@ -36,8 +36,8 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; -import com.plotsquared.bukkit.util.bukkit.BukkitPlayerFunctions; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitPlayerFunctions; +import com.plotsquared.bukkit.util.BukkitUtil; /** * @author Citymonstret diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java index ebddd4317..af26d8cbc 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents.java @@ -142,7 +142,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.listeners.worldedit.WEManager; import com.plotsquared.bukkit.object.BukkitLazyBlock; import com.plotsquared.bukkit.object.BukkitPlayer; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; /** * Player Events involving plots @@ -445,6 +445,10 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen player.saveData(); } final PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Set last location + pp.setMeta("location", BukkitUtil.getLocation(player.getLocation())); + final String username = pp.getName(); final StringWrapper name = new StringWrapper(username); final UUID uuid = pp.getUUID(); @@ -485,6 +489,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen org.bukkit.Location to = event.getTo(); int x2; if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { + Player player = event.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Set last location + pp.setMeta("location", BukkitUtil.getLocation(to)); + String worldname = to.getWorld().getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); if (plotworld == null) { @@ -492,8 +502,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); - Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -547,6 +555,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } int z2; if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { + Player player = event.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Set last location + pp.setMeta("location", BukkitUtil.getLocation(to)); + String worldname = to.getWorld().getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); if (plotworld == null) { @@ -554,8 +568,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); - Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -722,13 +734,19 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onWorldChanged(final PlayerChangedWorldEvent event) { - final PlotPlayer player = BukkitUtil.getPlayer(event.getPlayer()); + Player player = event.getPlayer(); + final PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Delete last location + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location"); + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); + if (PS.get().worldEdit != null) { - if (!Permissions.hasPermission(player, PERMISSION_WORLDEDIT_BYPASS)) { - WEManager.bypass.remove(player.getName()); + if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) { + WEManager.bypass.remove(pp.getName()); } else { - WEManager.bypass.add(player.getName()); + WEManager.bypass.add(pp.getName()); } } ((BukkitPlayer) player).hasPerm = new HashSet<>(); @@ -1382,6 +1400,8 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onTeleport(final PlayerTeleportEvent event) { if (event.getTo() == null || event.getFrom() == null) { + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location"); + BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot"); return; } final org.bukkit.Location from = event.getFrom(); @@ -1389,6 +1409,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen int x2; if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { + Player player = event.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Set last location + pp.setMeta("location", BukkitUtil.getLocation(to)); + String worldname = to.getWorld().getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); if (plotworld == null) { @@ -1396,8 +1422,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); - Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -1451,6 +1475,12 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } int z2; if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { + Player player = event.getPlayer(); + PlotPlayer pp = BukkitUtil.getPlayer(player); + + // Set last location + pp.setMeta("location", BukkitUtil.getLocation(to)); + String worldname = to.getWorld().getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); if (plotworld == null) { @@ -1458,8 +1488,6 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); - Player player = event.getPlayer(); - PlotPlayer pp = BukkitUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java index 046f131d6..9de65b28e 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8.java @@ -27,7 +27,7 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlotListener; public class PlayerEvents_1_8 extends PlotListener implements Listener { diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java index 486f54af1..3e19ddf17 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlayerEvents_1_8_3.java @@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; public class PlayerEvents_1_8_3 implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) diff --git a/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java b/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java index 82a8ce7e4..8f4d4d277 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/PlotPlusListener.java @@ -54,7 +54,7 @@ import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.events.PlayerEnterPlotEvent; import com.plotsquared.bukkit.events.PlayerLeavePlotEvent; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; import com.plotsquared.listener.PlotListener; /** diff --git a/src/main/java/com/plotsquared/bukkit/listeners/TNTListener.java b/src/main/java/com/plotsquared/bukkit/listeners/TNTListener.java index 53894c631..9d77a2121 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/TNTListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/TNTListener.java @@ -17,7 +17,7 @@ import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.util.MainUtil; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; public class TNTListener implements Listener { private double lastRadius; diff --git a/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java b/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java index 273b323c6..536f610b8 100644 --- a/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java +++ b/src/main/java/com/plotsquared/bukkit/listeners/worldedit/WEListener.java @@ -19,7 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.RegionWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.bukkit.selections.Selection; diff --git a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java index ba0eb3d1a..927630cc4 100644 --- a/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java +++ b/src/main/java/com/plotsquared/bukkit/object/BukkitPlayer.java @@ -1,6 +1,5 @@ package com.plotsquared.bukkit.object; -import java.util.HashMap; import java.util.HashSet; import java.util.UUID; @@ -13,7 +12,6 @@ import org.bukkit.entity.Player; import org.bukkit.permissions.Permission; import org.bukkit.permissions.PermissionDefault; -import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.object.Location; @@ -23,19 +21,16 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.UUIDHandler; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; +import com.plotsquared.bukkit.util.BukkitUtil; -public class BukkitPlayer implements PlotPlayer { +public class BukkitPlayer extends PlotPlayer { public final Player player; private UUID uuid; private String name; - private int op = 0; private long last = 0; public HashSet hasPerm = new HashSet<>(); public HashSet noPerm = new HashSet<>(); - - private HashMap meta; /** * Please do not use this method. Instead use BukkitUtil.getPlayer(Player), as it caches player objects. @@ -54,7 +49,8 @@ public class BukkitPlayer implements PlotPlayer { @Override public Location getLocation() { - return BukkitUtil.getLocation(this.player); + Location loc = super.getLocation(); + return loc == null ? BukkitUtil.getLocation(this.player) : loc; } @Override @@ -100,20 +96,6 @@ public class BukkitPlayer implements PlotPlayer { this.player.teleport(new org.bukkit.Location(BukkitUtil.getWorld(loc.getWorld()), loc.getX() + 0.5, loc.getY(), loc.getZ() + 0.5, loc.getYaw(), loc.getPitch())); } - @Override - public boolean isOp() { - if (this.op != 0) { - return this.op != 1; - } - final boolean result = this.player.isOp(); - if (!result) { - this.op = 1; - return false; - } - this.op = 2; - return true; - } - @Override public String getName() { if (this.name == null) { @@ -138,34 +120,6 @@ public class BukkitPlayer implements PlotPlayer { return BukkitUtil.getLocationFull(this.player); } - @Override - public void setMeta(String key, Object value) { - if (this.meta == null) { - this.meta = new HashMap(); - } - this.meta.put(key, value); - } - - @Override - public Object getMeta(String key) { - if (this.meta != null) { - return this.meta.get(key); - } - return null; - } - - @Override - public void deleteMeta(String key) { - if (this.meta != null) { - this.meta.remove(key); - } - } - - @Override - public String toString() { - return getName(); - } - @Override public void setAttribute(String key) { key = "plotsquared_user_attributes." + key; @@ -202,11 +156,6 @@ public class BukkitPlayer implements PlotPlayer { player.saveData(); } - @Override - public RequiredType getSuperCaller() { - return RequiredType.PLAYER; - } - @Override public void setWeather(PlotWeather weather) { switch (weather) { diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitChunkManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitChunkManager.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java index 00291e0c6..2db99a025 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitChunkManager.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitChunkManager.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.io.File; import java.util.ArrayList; diff --git a/src/main/java/com/plotsquared/bukkit/commands/BukkitCommand.java b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java similarity index 97% rename from src/main/java/com/plotsquared/bukkit/commands/BukkitCommand.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java index 96db9e5bc..d04f5d680 100644 --- a/src/main/java/com/plotsquared/bukkit/commands/BukkitCommand.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitCommand.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.commands; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.Collections; @@ -16,7 +16,6 @@ import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.StringComparison; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; import com.plotsquared.general.commands.Command; /** diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEconHandler.java b/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEconHandler.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java index 2f2856bc3..e5ef70211 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEconHandler.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitEconHandler.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import net.milkbowl.vault.economy.Economy; import net.milkbowl.vault.permission.Permission; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEventUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEventUtil.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java index ae4088f13..e71c14598 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitEventUtil.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitEventUtil.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.UUID; diff --git a/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java b/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java index 0ac44bf8c..51dc67f50 100644 --- a/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitHybridUtils.java @@ -37,7 +37,6 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.TaskManager; import com.plotsquared.bukkit.BukkitMain; -import com.plotsquared.bukkit.util.bukkit.BukkitUtil; public class BukkitHybridUtils extends HybridUtils { diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitInventoryUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitInventoryUtil.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java index 63f386793..35f94d52d 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitInventoryUtil.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitInventoryUtil.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.List; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitPlayerFunctions.java b/src/main/java/com/plotsquared/bukkit/util/BukkitPlayerFunctions.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitPlayerFunctions.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitPlayerFunctions.java index 861e4ba5c..8456b2123 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitPlayerFunctions.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitPlayerFunctions.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.HashSet; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSchematicHandler.java b/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSchematicHandler.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java index d5529e699..0ad812071 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSchematicHandler.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitSchematicHandler.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.HashMap; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetBlockManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitSetBlockManager.java similarity index 95% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetBlockManager.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitSetBlockManager.java index 7bf6eb32c..b4346d127 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetBlockManager.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitSetBlockManager.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.ArrayList; import java.util.Collection; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetupUtils.java b/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetupUtils.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java index a2ca7bb9f..774f9b268 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitSetupUtils.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitSetupUtils.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.io.IOException; import java.util.Map.Entry; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitTaskManager.java b/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java similarity index 96% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitTaskManager.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java index 94b4cabde..4e2194b02 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitTaskManager.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitTaskManager.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import org.bukkit.Bukkit; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitUtil.java b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitUtil.java rename to src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java index fcc054931..4306b0154 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/BukkitUtil.java +++ b/src/main/java/com/plotsquared/bukkit/util/BukkitUtil.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.Arrays; import java.util.HashMap; @@ -23,7 +23,6 @@ import org.bukkit.material.Step; import org.bukkit.material.Tree; import org.bukkit.material.WoodenStep; import org.bukkit.material.Wool; -import org.spongepowered.api.world.extent.Extent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/Metrics.java b/src/main/java/com/plotsquared/bukkit/util/Metrics.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/Metrics.java rename to src/main/java/com/plotsquared/bukkit/util/Metrics.java index 3ff0460de..1d24aeb90 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/Metrics.java +++ b/src/main/java/com/plotsquared/bukkit/util/Metrics.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.io.BufferedReader; import java.io.ByteArrayOutputStream; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/OfflinePlayerUtil.java b/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/OfflinePlayerUtil.java rename to src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java index e44498d50..bd112238d 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/OfflinePlayerUtil.java +++ b/src/main/java/com/plotsquared/bukkit/util/OfflinePlayerUtil.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import static com.intellectualcrafters.plot.util.ReflectionUtils.callConstructor; import static com.intellectualcrafters.plot.util.ReflectionUtils.callMethod; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/SendChunk.java b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/SendChunk.java rename to src/main/java/com/plotsquared/bukkit/util/SendChunk.java index 4f963cfda..21f925227 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/SendChunk.java +++ b/src/main/java/com/plotsquared/bukkit/util/SendChunk.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast.java rename to src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java index 95b1378eb..c7b1387a0 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast_1_8.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast_1_8.java rename to src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java index 989c6137a..db02a6e64 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockFast_1_8.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockFast_1_8.java @@ -18,7 +18,7 @@ // / // You can contact us via: support@intellectualsites.com / //////////////////////////////////////////////////////////////////////////////////////////////////// -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import static com.intellectualcrafters.plot.util.ReflectionUtils.getRefClass; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockSlow.java b/src/main/java/com/plotsquared/bukkit/util/SetBlockSlow.java similarity index 96% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockSlow.java rename to src/main/java/com/plotsquared/bukkit/util/SetBlockSlow.java index c892dedcd..2a9f00aff 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetBlockSlow.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetBlockSlow.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.util.Collection; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetGenCB.java b/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java similarity index 98% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/SetGenCB.java rename to src/main/java/com/plotsquared/bukkit/util/SetGenCB.java index 73034696c..439654a27 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/SetGenCB.java +++ b/src/main/java/com/plotsquared/bukkit/util/SetGenCB.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit; +package com.plotsquared.bukkit.util; import java.lang.reflect.Constructor; import java.lang.reflect.Field; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/FileUUIDHandler.java b/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/FileUUIDHandler.java rename to src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java index 3729d8ff5..083afb9c9 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/FileUUIDHandler.java +++ b/src/main/java/com/plotsquared/bukkit/uuid/FileUUIDHandler.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.uuid; +package com.plotsquared.bukkit.uuid; import java.io.File; import java.io.FileInputStream; diff --git a/src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/SQLUUIDHandler.java b/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java similarity index 99% rename from src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/SQLUUIDHandler.java rename to src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java index 60186d7cc..7a218ec41 100644 --- a/src/main/java/com/plotsquared/bukkit/util/bukkit/uuid/SQLUUIDHandler.java +++ b/src/main/java/com/plotsquared/bukkit/uuid/SQLUUIDHandler.java @@ -1,4 +1,4 @@ -package com.plotsquared.bukkit.util.bukkit.uuid; +package com.plotsquared.bukkit.uuid; import java.io.BufferedReader; import java.io.IOException; diff --git a/src/main/java/com/plotsquared/sponge/SpongeMain.java b/src/main/java/com/plotsquared/sponge/SpongeMain.java index 081809b2b..3a1f16f4f 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeMain.java +++ b/src/main/java/com/plotsquared/sponge/SpongeMain.java @@ -11,6 +11,7 @@ import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Map.Entry; +import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; import org.slf4j.Logger; @@ -23,7 +24,6 @@ import org.spongepowered.api.block.BlockTypes; import org.spongepowered.api.data.manipulator.block.StoneData; import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.gamemode.GameModes; -import org.spongepowered.api.event.EventHandler; import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.entity.player.PlayerChatEvent; import org.spongepowered.api.event.state.PreInitializationEvent; @@ -38,7 +38,6 @@ import org.spongepowered.api.text.translation.Translation; import org.spongepowered.api.world.DimensionTypes; import org.spongepowered.api.world.GeneratorTypes; import org.spongepowered.api.world.World; -import org.spongepowered.api.world.gen.WorldGeneratorModifier; import com.google.common.base.Optional; import com.google.inject.Inject; @@ -49,21 +48,18 @@ import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Configuration; import com.intellectualcrafters.plot.config.Settings; import com.intellectualcrafters.plot.generator.HybridUtils; -import com.intellectualcrafters.plot.generator.PlotGenerator; import com.intellectualcrafters.plot.object.PlotBlock; -import com.intellectualcrafters.plot.object.PlotManager; import com.intellectualcrafters.plot.object.PlotPlayer; -import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.util.AbstractTitle; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.ChunkManager; -import com.intellectualcrafters.plot.util.ConsoleColors; import com.intellectualcrafters.plot.util.EconHandler; import com.intellectualcrafters.plot.util.EventUtil; import com.intellectualcrafters.plot.util.InventoryUtil; import com.intellectualcrafters.plot.util.SchematicHandler; import com.intellectualcrafters.plot.util.SetupUtils; import com.intellectualcrafters.plot.util.TaskManager; +import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.util.UUIDHandlerImplementation; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.sponge.generator.SpongeBasicGen; @@ -72,11 +68,13 @@ import com.plotsquared.sponge.generator.WorldModify; import com.plotsquared.sponge.listener.MainListener; import com.plotsquared.sponge.util.KillRoadMobs; import com.plotsquared.sponge.util.SpongeBlockManager; +import com.plotsquared.sponge.util.SpongeChunkManager; import com.plotsquared.sponge.util.SpongeCommand; import com.plotsquared.sponge.util.SpongeEventUtil; import com.plotsquared.sponge.util.SpongeInventoryUtil; import com.plotsquared.sponge.util.SpongeMetrics; import com.plotsquared.sponge.util.SpongeTaskManager; +import com.plotsquared.sponge.util.SpongeTitleManager; import com.plotsquared.sponge.util.SpongeUtil; import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper; import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper; @@ -596,4 +594,21 @@ public class SpongeMain implements IPlotMain, PluginContainer { public AbstractTitle initTitleManager() { return new SpongeTitleManager(); } + + @Override + public PlotPlayer wrapPlayer(Object obj) { + if (obj instanceof Player) { + return SpongeUtil.getPlayer((Player) obj); + } +// else if (obj instanceof OfflinePlayer) { +// return BukkitUtil.getPlayer((OfflinePlayer) obj); +// } + else if (obj instanceof String) { + return UUIDHandler.getPlayer((String) obj); + } + else if (obj instanceof UUID) { + return UUIDHandler.getPlayer((UUID) obj); + } + return null; + } } \ No newline at end of file diff --git a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java index 6fa618e37..1f9d9febb 100644 --- a/src/main/java/com/plotsquared/sponge/generator/WorldModify.java +++ b/src/main/java/com/plotsquared/sponge/generator/WorldModify.java @@ -4,10 +4,6 @@ import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.world.WorldCreationSettings; import org.spongepowered.api.world.gen.WorldGenerator; import org.spongepowered.api.world.gen.WorldGeneratorModifier; -import org.spongepowered.common.world.gen.SpongeWorldGenerator; - -import com.intellectualcrafters.plot.PS; -import com.plotsquared.sponge.SpongeMain; public class WorldModify implements WorldGeneratorModifier { diff --git a/src/main/java/com/plotsquared/sponge/listener/MainListener.java b/src/main/java/com/plotsquared/sponge/listener/MainListener.java index c25baff15..a7b79c1f8 100644 --- a/src/main/java/com/plotsquared/sponge/listener/MainListener.java +++ b/src/main/java/com/plotsquared/sponge/listener/MainListener.java @@ -22,7 +22,6 @@ import org.spongepowered.api.block.BlockState; import org.spongepowered.api.entity.Entity; import org.spongepowered.api.entity.EntityTypes; import org.spongepowered.api.entity.player.Player; -import org.spongepowered.api.event.Cancellable; import org.spongepowered.api.event.Subscribe; import org.spongepowered.api.event.block.BlockMoveEvent; import org.spongepowered.api.event.block.BlockRedstoneUpdateEvent; @@ -36,20 +35,16 @@ import org.spongepowered.api.event.entity.player.PlayerChangeWorldEvent; import org.spongepowered.api.event.entity.player.PlayerChatEvent; import org.spongepowered.api.event.entity.player.PlayerInteractBlockEvent; import org.spongepowered.api.event.entity.player.PlayerJoinEvent; -import org.spongepowered.api.event.entity.player.PlayerMessageEvent; import org.spongepowered.api.event.entity.player.PlayerMoveEvent; import org.spongepowered.api.event.entity.player.PlayerPlaceBlockEvent; import org.spongepowered.api.event.entity.player.PlayerQuitEvent; import org.spongepowered.api.event.message.CommandEvent; import org.spongepowered.api.event.network.PlayerConnectionEvent; -import org.spongepowered.api.event.world.ChunkLoadEvent; import org.spongepowered.api.event.world.ChunkPreGenerateEvent; -import org.spongepowered.api.event.world.ChunkPrePopulateEvent; import org.spongepowered.api.network.PlayerConnection; import org.spongepowered.api.text.Text; import org.spongepowered.api.text.Texts; import org.spongepowered.api.util.command.CommandSource; -import org.spongepowered.api.util.event.callback.EventCallback; import org.spongepowered.api.world.World; import org.spongepowered.api.world.extent.Extent; @@ -80,7 +75,7 @@ import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.bukkit.object.BukkitPlayer; import com.plotsquared.listener.PlotListener; import com.plotsquared.sponge.SpongeMain; -import com.plotsquared.sponge.SpongePlayer; +import com.plotsquared.sponge.object.SpongePlayer; import com.plotsquared.sponge.util.SpongeUtil; public class MainListener { @@ -557,10 +552,14 @@ public class MainListener { org.spongepowered.api.world.Location to = event.getNewLocation(); int x2; if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { + Player player = event.getUser(); + PlotPlayer pp = SpongeUtil.getPlayer(player); Extent extent = to.getExtent(); if (!(extent instanceof World)) { + pp.deleteMeta("location"); return; } + pp.setMeta("location", SpongeUtil.getLocation(player)); World world = (World) extent; String worldname = ((World) extent).getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); @@ -569,8 +568,6 @@ public class MainListener { } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); - Player player = event.getUser(); - PlotPlayer pp = SpongeUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -622,10 +619,14 @@ public class MainListener { } int z2; if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { + Player player = event.getUser(); + PlotPlayer pp = SpongeUtil.getPlayer(player); Extent extent = to.getExtent(); if (!(extent instanceof World)) { + pp.deleteMeta("location"); return; } + pp.setMeta("location", SpongeUtil.getLocation(player)); World world = (World) extent; String worldname = ((World) extent).getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); @@ -634,8 +635,6 @@ public class MainListener { } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); - Player player = event.getUser(); - PlotPlayer pp = SpongeUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -694,10 +693,14 @@ public class MainListener { org.spongepowered.api.world.Location to = event.getNewLocation(); int x2; if (getInt(from.getX()) != (x2 = getInt(to.getX()))) { + Player player = (Player) entity; + PlotPlayer pp = SpongeUtil.getPlayer(player); Extent extent = to.getExtent(); if (!(extent instanceof World)) { + pp.deleteMeta("location"); return; } + pp.setMeta("location", SpongeUtil.getLocation(player)); World world = (World) extent; String worldname = ((World) extent).getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); @@ -706,8 +709,6 @@ public class MainListener { } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ())); - Player player = (Player) entity; - PlotPlayer pp = SpongeUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -759,10 +760,14 @@ public class MainListener { } int z2; if (getInt(from.getZ()) != (z2 = getInt(to.getZ())) ) { + Player player = (Player) entity; + PlotPlayer pp = SpongeUtil.getPlayer(player); Extent extent = to.getExtent(); if (!(extent instanceof World)) { + pp.deleteMeta("location"); return; } + pp.setMeta("location", SpongeUtil.getLocation(player)); World world = (World) extent; String worldname = ((World) extent).getName(); PlotWorld plotworld = PS.get().getPlotWorld(worldname); @@ -771,8 +776,6 @@ public class MainListener { } PlotManager plotManager = PS.get().getPlotManager(worldname); PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2); - Player player = (Player) entity; - PlotPlayer pp = SpongeUtil.getPlayer(player); Plot lastPlot = (Plot) pp.getMeta("lastplot"); if (id == null) { if (lastPlot == null) { @@ -828,6 +831,9 @@ public class MainListener { public void onWorldChange(PlayerChangeWorldEvent event) { final PlotPlayer player = SpongeUtil.getPlayer(event.getUser()); + player.deleteMeta("location"); + player.deleteMeta("lastplot"); + // TODO worldedit mask ((BukkitPlayer) player).hasPerm = new HashSet<>(); diff --git a/src/main/java/com/plotsquared/sponge/SpongePlayer.java b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java similarity index 82% rename from src/main/java/com/plotsquared/sponge/SpongePlayer.java rename to src/main/java/com/plotsquared/sponge/object/SpongePlayer.java index acd2900e1..cf097a6ad 100644 --- a/src/main/java/com/plotsquared/sponge/SpongePlayer.java +++ b/src/main/java/com/plotsquared/sponge/object/SpongePlayer.java @@ -1,20 +1,14 @@ -package com.plotsquared.sponge; +package com.plotsquared.sponge.object; -import java.util.HashMap; import java.util.HashSet; import java.util.UUID; import org.spongepowered.api.entity.player.Player; import org.spongepowered.api.entity.player.gamemode.GameMode; import org.spongepowered.api.entity.player.gamemode.GameModes; -import org.spongepowered.api.service.permission.PermissionService; -import org.spongepowered.api.text.Texts; import org.spongepowered.api.text.chat.ChatTypes; -import org.spongepowered.api.text.title.Title; -import org.spongepowered.api.world.World; import com.flowpowered.math.vector.Vector3d; -import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.RequiredType; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.config.Settings; @@ -25,19 +19,17 @@ import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.PlotGamemode; import com.intellectualcrafters.plot.util.PlotWeather; import com.intellectualcrafters.plot.util.UUIDHandler; +import com.plotsquared.sponge.SpongeMain; import com.plotsquared.sponge.util.SpongeUtil; -public class SpongePlayer implements PlotPlayer { +public class SpongePlayer extends PlotPlayer { public final Player player; private UUID uuid; private String name; - private int op = 0; private long last = 0; private HashSet hasPerm = new HashSet<>(); private HashSet noPerm = new HashSet<>(); - - private HashMap meta; public SpongePlayer(Player player) { this.player = player; @@ -60,7 +52,8 @@ public class SpongePlayer implements PlotPlayer { @Override public Location getLocation() { - return SpongeUtil.getLocation(player); + Location loc = super.getLocation(); + return loc == null ? SpongeUtil.getLocation(this.player) : loc; } @Override @@ -114,20 +107,6 @@ public class SpongePlayer implements PlotPlayer { } } - @Override - public boolean isOp() { - if (this.op != 0) { - return this.op != 1; - } - final boolean result = this.player.hasPermission("*"); - if (!result) { - this.op = 1; - return false; - } - this.op = 2; - return true; - } - @Override public boolean isOnline() { return player.isOnline(); @@ -159,34 +138,6 @@ public class SpongePlayer implements PlotPlayer { throw new UnsupportedOperationException("NOT IMPLEMENTED YET"); } - @Override - public void setMeta(String key, Object value) { - if (this.meta == null) { - this.meta = new HashMap(); - } - this.meta.put(key, value); - } - - @Override - public Object getMeta(String key) { - if (this.meta != null) { - return this.meta.get(key); - } - return null; - } - - @Override - public void deleteMeta(String key) { - if (this.meta != null) { - this.meta.remove(key); - } - } - - @Override - public String toString() { - return getName(); - } - @Override public void setAttribute(String key) { key = "plotsquared_user_attributes." + key; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java index 802abb53b..04e6a6266 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeBlockManager.java @@ -12,7 +12,6 @@ import org.spongepowered.api.world.World; import org.spongepowered.api.world.biome.BiomeType; import org.spongepowered.api.world.biome.BiomeTypes; -import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.PlotBlock; import com.intellectualcrafters.plot.object.schematic.PlotItem; diff --git a/src/main/java/com/plotsquared/sponge/SpongeChunkManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java similarity index 93% rename from src/main/java/com/plotsquared/sponge/SpongeChunkManager.java rename to src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java index ffe030271..6f66f4f08 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeChunkManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeChunkManager.java @@ -1,27 +1,22 @@ -package com.plotsquared.sponge; +package com.plotsquared.sponge.util; -import java.io.File; import java.util.ArrayList; import java.util.List; -import org.bukkit.Bukkit; import org.spongepowered.api.data.DataContainer; import org.spongepowered.api.world.Chunk; import org.spongepowered.api.world.World; import org.spongepowered.api.world.storage.ChunkDataStream; -import org.spongepowered.api.world.storage.WorldStorage; import com.google.common.base.Optional; -import com.google.common.util.concurrent.ListenableFuture; 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.util.ChunkManager; -import com.intellectualcrafters.plot.util.TaskManager; import com.intellectualcrafters.plot.util.SetBlockQueue.ChunkWrapper; -import com.plotsquared.sponge.util.SpongeUtil; +import com.intellectualcrafters.plot.util.TaskManager; public class SpongeChunkManager extends ChunkManager { diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java index 24d8d67ef..2a4bb47a9 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeCommand.java @@ -14,7 +14,6 @@ import org.spongepowered.api.util.command.CommandResult; import org.spongepowered.api.util.command.CommandSource; import com.google.common.base.Optional; -import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.commands.MainCommand; import com.intellectualcrafters.plot.object.ConsolePlayer; import com.intellectualcrafters.plot.object.PlotPlayer; diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java index 942d2ec49..3b7e823b1 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeInventoryUtil.java @@ -20,7 +20,7 @@ import com.intellectualcrafters.plot.object.PlotItemStack; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.InventoryUtil; import com.plotsquared.sponge.SpongeMain; -import com.plotsquared.sponge.SpongePlayer; +import com.plotsquared.sponge.object.SpongePlayer; public class SpongeInventoryUtil extends InventoryUtil { diff --git a/src/main/java/com/plotsquared/sponge/SpongeTitleManager.java b/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java similarity index 79% rename from src/main/java/com/plotsquared/sponge/SpongeTitleManager.java rename to src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java index a4f177b89..25a157ee2 100644 --- a/src/main/java/com/plotsquared/sponge/SpongeTitleManager.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeTitleManager.java @@ -1,10 +1,11 @@ -package com.plotsquared.sponge; +package com.plotsquared.sponge.util; import org.spongepowered.api.text.title.Title; -import com.intellectualcrafters.plot.PS; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.AbstractTitle; +import com.plotsquared.sponge.SpongeMain; +import com.plotsquared.sponge.object.SpongePlayer; public class SpongeTitleManager extends AbstractTitle { diff --git a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java index c6165d5df..35e56f228 100644 --- a/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java +++ b/src/main/java/com/plotsquared/sponge/util/SpongeUtil.java @@ -13,7 +13,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MathMan; import com.intellectualcrafters.plot.util.UUIDHandler; import com.plotsquared.sponge.SpongeMain; -import com.plotsquared.sponge.SpongePlayer; +import com.plotsquared.sponge.object.SpongePlayer; public class SpongeUtil { diff --git a/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java b/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java index 10464e82f..a9f1aec4e 100644 --- a/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java +++ b/src/main/java/com/plotsquared/sponge/uuid/SpongeOnlineUUIDWrapper.java @@ -7,7 +7,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.UUIDHandler; import com.intellectualcrafters.plot.uuid.UUIDWrapper; import com.plotsquared.sponge.SpongeMain; -import com.plotsquared.sponge.SpongePlayer; +import com.plotsquared.sponge.object.SpongePlayer; public class SpongeOnlineUUIDWrapper extends UUIDWrapper {