mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +01:00
info
This commit is contained in:
parent
625f1698cd
commit
5f5d794c66
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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 {
|
||||
|
@ -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();
|
||||
}
|
||||
}
|
||||
|
@ -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() {
|
||||
|
@ -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" })
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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;
|
||||
|
||||
/**
|
||||
|
@ -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")
|
||||
|
@ -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());
|
||||
}
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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);
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user