From 5f5d794c669d1aaa176bdb34e68f24b693e343ea Mon Sep 17 00:00:00 2001 From: boy0001 Date: Sun, 22 Feb 2015 18:13:27 +1100 Subject: [PATCH] info --- .../plot/commands/Denied.java | 5 -- .../plot/commands/Helpers.java | 4 -- .../plot/commands/Inbox.java | 2 - .../plot/commands/Info.java | 53 ++++++++----------- .../plot/commands/MusicSubcommand.java | 1 - .../plot/commands/Rate.java | 1 - .../plot/commands/Set.java | 1 - .../plot/commands/Swap.java | 1 - .../plot/commands/Trusted.java | 1 - .../plot/object/InfoInventory.java | 4 +- .../plot/object/PlotSettings.java | 5 +- .../plot/util/BlockManager.java | 2 + .../plot/util/bukkit/BukkitUtil.java | 5 +- 13 files changed, 31 insertions(+), 54 deletions(-) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java index e10febc96..923b22deb 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Denied.java @@ -22,19 +22,14 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerPlotDeniedEvent; import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Denied extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java index 0d303b7c5..1640b2e18 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Helpers.java @@ -22,17 +22,13 @@ package com.intellectualcrafters.plot.commands; import java.util.UUID; -import org.bukkit.Bukkit; - import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; -import com.intellectualcrafters.plot.events.PlayerPlotHelperEvent; import com.intellectualcrafters.plot.object.Location; 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.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Helpers extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java index 03ecb900d..77bedefaf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Inbox.java @@ -25,7 +25,6 @@ import java.util.Arrays; import java.util.List; import java.util.UUID; -import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.object.Location; @@ -35,7 +34,6 @@ import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.Permissions; import com.intellectualcrafters.plot.util.TaskManager; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; public class Inbox extends SubCommand { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java index c7dd552ce..a58797282 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Info.java @@ -24,23 +24,19 @@ import java.util.ArrayList; import java.util.UUID; import org.apache.commons.lang.StringUtils; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.entity.Player; import com.intellectualcrafters.plot.PlotSquared; import com.intellectualcrafters.plot.config.C; import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.flag.FlagManager; import com.intellectualcrafters.plot.object.InfoInventory; +import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.object.PlotWorld; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** @@ -54,20 +50,19 @@ public class Info extends SubCommand { @Override public boolean execute(final PlotPlayer player, String... args) { - World world; Plot plot; + String world; if (player != null) { Location loc = player.getLocation(); - String world = loc.getWorld(); + world = loc.getWorld(); if (!PlotSquared.isPlotWorld(world)) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_IN_PLOT_WORLD); + MainUtil.sendMessage(player, C.NOT_IN_PLOT_WORLD); return false; } - final Plot plot = MainUtil.getPlot(loc); - if (plot == null) { - return !sendMessage(plr, C.NOT_IN_PLOT); - } plot = MainUtil.getPlot(loc); + if (plot == null) { + return !sendMessage(player, C.NOT_IN_PLOT); + } } else { if (args.length < 2) { MainUtil.sendMessage(null, C.INFO_SYNTAX_CONSOLE); @@ -75,25 +70,25 @@ public class Info extends SubCommand { } final PlotWorld plotworld = PlotSquared.getPlotWorld(args[0]); if (plotworld == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_WORLD); + MainUtil.sendMessage(player, C.NOT_VALID_WORLD); return false; } try { final String[] split = args[1].split(";"); final PlotId id = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); - plot = MainUtil.getPlot(Bukkit.getWorld(plotworld.worldname), id); + plot = MainUtil.getPlot(plotworld.worldname, id); if (plot == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.NOT_VALID_PLOT_ID); + MainUtil.sendMessage(player, C.NOT_VALID_PLOT_ID); return false; } - world = Bukkit.getWorld(args[0]); + world = args[0]; if (args.length == 3) { args = new String[] { args[2] }; } else { args = new String[0]; } } catch (final Exception e) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.INFO_SYNTAX_CONSOLE); + MainUtil.sendMessage(player, C.INFO_SYNTAX_CONSOLE); return false; } } @@ -111,7 +106,7 @@ public class Info extends SubCommand { } // Unclaimed? if (!hasOwner && !containsEveryone && !trustedEveryone) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); + MainUtil.sendMessage(player, C.PLOT_INFO_UNCLAIMED, (plot.id.x + ";" + plot.id.y)); return true; } String owner = "none"; @@ -125,13 +120,13 @@ public class Info extends SubCommand { if (args.length == 1) { info = getCaption(args[0].toLowerCase()); if (info == null) { - MainUtil.sendMessage(BukkitUtil.getPlayer(player), "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); + MainUtil.sendMessage(player, "&6Categories&7: &ahelpers&7, &aalias&7, &abiome&7, &adenied&7, &aflags&7, &aid&7, &asize&7, &atrusted&7, &aowner&7, &arating"); return false; } } info = format(info, world, plot, player); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), C.PLOT_INFO_HEADER); - MainUtil.sendMessage(BukkitUtil.getPlayer(player), info, false); + MainUtil.sendMessage(player, C.PLOT_INFO_HEADER); + MainUtil.sendMessage(player, info, false); return true; } @@ -162,18 +157,18 @@ public class Info extends SubCommand { } } - private String format(String info, final World world, final Plot plot, final Player player) { + private String format(String info, final String world, final Plot plot, final PlotPlayer player) { final PlotId id = plot.id; - final PlotId id2 = MainUtil.getTopPlot(world, plot).id; + final PlotId id2 = MainUtil.getTopPlot(plot).id; final int num = MainUtil.getPlotSelectionIds(id, id2).size(); final String alias = plot.settings.getAlias().length() > 0 ? plot.settings.getAlias() : "none"; - final String biome = getBiomeAt(plot).toString(); + final String biome = BlockManager.manager.getBiome(MainUtil.getPlotBottomLoc(world, plot.id).add(1, 0, 1)); final String helpers = getPlayerList(plot.helpers); final String trusted = getPlayerList(plot.trusted); final String denied = getPlayerList(plot.denied); final String rating = String.format("%.1f", DBFunc.getRatings(plot)); final String flags = "&6" + (StringUtils.join(FlagManager.getPlotFlags(plot), "").length() > 0 ? StringUtils.join(FlagManager.getPlotFlags(plot), "&7, &6") : "none"); - final boolean build = (player == null) || plot.hasRights(player); + final boolean build = (player == null) || plot.isAdded(player.getUUID()); String owner = "none"; if (plot.owner != null) { owner = UUIDHandler.getName(plot.owner); @@ -226,10 +221,4 @@ public class Info extends SubCommand { } return name; } - - private Biome getBiomeAt(final Plot plot) { - final World w = Bukkit.getWorld(plot.world); - final Location bl = MainUtil.getPlotTopLoc(w, plot.id); - return bl.getBlock().getBiome(); - } } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java index 9d9e839b8..45a02eb21 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/MusicSubcommand.java @@ -33,7 +33,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; public class MusicSubcommand extends SubCommand { public MusicSubcommand() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java index 435dc061e..2998aa84b 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Rate.java @@ -26,7 +26,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings({ "unused", "deprecated", "javadoc" }) diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java index 1a302f0b4..a043251a7 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Set.java @@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.object.PlotWorld; import com.intellectualcrafters.plot.object.StringWrapper; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.StringComparison; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java index fe50a2b6f..6ce585498 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Swap.java @@ -30,7 +30,6 @@ import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotId; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; /** diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java index 629e5765f..1ae3155f5 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/commands/Trusted.java @@ -31,7 +31,6 @@ import com.intellectualcrafters.plot.object.Location; import com.intellectualcrafters.plot.object.Plot; import com.intellectualcrafters.plot.object.PlotPlayer; import com.intellectualcrafters.plot.util.MainUtil; -import com.intellectualcrafters.plot.util.bukkit.BukkitPlayerFunctions; import com.intellectualcrafters.plot.util.bukkit.UUIDHandler; @SuppressWarnings("deprecation") diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java index d1da24fb4..61741c1bf 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/InfoInventory.java @@ -31,9 +31,9 @@ public class InfoInventory implements InventoryHolder { * * @param plot from which we take information */ - public InfoInventory(final Plot plot, final Player player) { + public InfoInventory(final Plot plot, final PlotPlayer plr) { this.plot = plot; - this.player = player; + this.player = ((BukkitPlayer) plr).player; this.inventory = Bukkit.createInventory(this, 9, "Plot: " + plot.id.toString()); } diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java index cf5928a1f..238c055b2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/object/PlotSettings.java @@ -27,6 +27,7 @@ import org.bukkit.block.Biome; import com.intellectualcrafters.plot.flag.Flag; import com.intellectualcrafters.plot.flag.FlagManager; +import com.intellectualcrafters.plot.util.BlockManager; import com.intellectualcrafters.plot.util.MainUtil; import com.intellectualcrafters.plot.util.bukkit.BukkitUtil; @@ -106,9 +107,9 @@ public class PlotSettings { /** * @return biome at plot loc */ - public Biome getBiome() { + public String getBiome() { final Location loc = MainUtil.getPlotBottomLoc(this.plot.world, this.plot.getId()).add(1, 0, 1); - return BukkitUtil.getBiome(loc); + return BlockManager.manager.getBiome(loc); } public BlockLoc getPosition() { diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java index 272e25422..afed23651 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/BlockManager.java @@ -29,6 +29,8 @@ public abstract class BlockManager { return (int) r; } + public abstract String getBiome(Location loc); + public abstract Location getSpawn(String world); public abstract String[] getSign(Location loc); diff --git a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java index c3bb572d9..ea44975a2 100644 --- a/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java +++ b/PlotSquared/src/main/java/com/intellectualcrafters/plot/util/bukkit/BukkitUtil.java @@ -52,8 +52,9 @@ public class BukkitUtil extends BlockManager { return lastPlotPlayer; } - public static Biome getBiome(final Location loc) { - return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()); + @Override + public String getBiome(final Location loc) { + return getWorld(loc.getWorld()).getBiome(loc.getX(), loc.getZ()).name(); } public static Location getLocation(org.bukkit.Location loc) {