mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Fixed a heckload of warnings
This commit is contained in:
parent
87a0cecb2f
commit
182f4cbd22
@ -42,11 +42,14 @@ import java.util.Set;
|
||||
@SuppressWarnings({"unused", "javadoc"})
|
||||
public class PlotAPI {
|
||||
|
||||
/**
|
||||
* Admin Permission
|
||||
*/
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
private static PlotHelper plotHelper;
|
||||
private static PlayerFunctions playerFunctions;
|
||||
private static FlagManager flagManager;
|
||||
private static SchematicHandler schematicHandler;
|
||||
private static C c;
|
||||
|
||||
// Methods/fields in PlotMain class
|
||||
|
||||
@ -63,15 +66,21 @@ public class PlotAPI {
|
||||
// PlotMain.removePlot(world, id, callEvent)
|
||||
// PlotMain.teleportPlayer(player, from, plot)
|
||||
// PlotMain.updatePlot(plot);
|
||||
private static C c;
|
||||
|
||||
// Reference
|
||||
// To access plotMain stuff.
|
||||
private final PlotMain plotMain;
|
||||
|
||||
// Reference
|
||||
/**
|
||||
* Admin Permission
|
||||
* Constructor. Insert any Plugin.
|
||||
* (Optimally the plugin that is accessing the method)
|
||||
*
|
||||
* @param plugin Plugin used to access this method
|
||||
*/
|
||||
public static final String ADMIN_PERMISSION = "plots.admin";
|
||||
public PlotAPI(final JavaPlugin plugin) {
|
||||
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get all plots
|
||||
@ -122,16 +131,6 @@ public class PlotAPI {
|
||||
return PlotMain.storage;
|
||||
}
|
||||
|
||||
/**
|
||||
* Constructor. Insert any Plugin.
|
||||
* (Optimally the plugin that is accessing the method)
|
||||
*
|
||||
* @param plugin Plugin used to access this method
|
||||
*/
|
||||
public PlotAPI(final JavaPlugin plugin) {
|
||||
this.plotMain = JavaPlugin.getPlugin(PlotMain.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the main class for this plugin <br>
|
||||
* - Contains a lot of fields and methods - not very well organized <br>
|
||||
@ -288,7 +287,7 @@ public class PlotAPI {
|
||||
* @return array of Flag[]
|
||||
*/
|
||||
public AbstractFlag[] getFlags() {
|
||||
return FlagManager.getFlags().toArray(new AbstractFlag[0]);
|
||||
return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -31,9 +31,6 @@ import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
*/
|
||||
public class Inbox extends SubCommand {
|
||||
|
||||
public Inbox() {
|
||||
|
@ -36,6 +36,7 @@ import java.util.UUID;
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecated", "javadoc"})
|
||||
public class Info extends SubCommand {
|
||||
|
||||
public Info() {
|
||||
@ -55,7 +56,7 @@ public class Info extends SubCommand {
|
||||
plot = PlayerFunctions.getCurrentPlot(player);
|
||||
} else {
|
||||
if (args.length < 2) {
|
||||
PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE);
|
||||
PlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE);
|
||||
return false;
|
||||
}
|
||||
final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]);
|
||||
|
@ -28,9 +28,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-08-01.
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecation", "javadoc"})
|
||||
public class Kick extends SubCommand {
|
||||
|
||||
public Kick() {
|
||||
|
@ -24,9 +24,6 @@ package com.intellectualcrafters.plot.commands;
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-12.
|
||||
*/
|
||||
public class Paste extends SubCommand {
|
||||
|
||||
public Paste() {
|
||||
|
@ -28,9 +28,7 @@ import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @Deprecated
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecated", "javadoc"})
|
||||
public class Purge extends SubCommand {
|
||||
|
||||
public Purge() {
|
||||
@ -54,12 +52,12 @@ public class Purge extends SubCommand {
|
||||
}
|
||||
|
||||
if (!PlotMain.isPlotWorld(world)) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
PlotMain.getPlots(world).remove(id);
|
||||
DBFunc.purge(world, id);
|
||||
PlayerFunctions.sendMessage(plr, "&aPurge of '" + args[0] + "' was successful!");
|
||||
PlayerFunctions.sendMessage(null, "&aPurge of '" + args[0] + "' was successful!");
|
||||
return true;
|
||||
} catch (final Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
|
@ -26,9 +26,7 @@ import com.intellectualcrafters.plot.PlayerFunctions;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-10-02.
|
||||
*/
|
||||
@SuppressWarnings({"unused", "deprecated", "javadoc"})
|
||||
public class Rate extends SubCommand {
|
||||
|
||||
/*
|
||||
|
@ -27,9 +27,6 @@ import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.PlotWorld;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* @Deprecated
|
||||
*/
|
||||
public class Reload extends SubCommand {
|
||||
|
||||
public Reload() {
|
||||
|
@ -31,21 +31,22 @@ import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
|
||||
public class Schematic extends SubCommand {
|
||||
|
||||
private int counter = 0;
|
||||
private boolean running = false;
|
||||
private Plot[] plots;
|
||||
private int task;
|
||||
|
||||
public Schematic() {
|
||||
super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false);
|
||||
|
||||
// TODO command to fetch schematic from worldedit directory
|
||||
}
|
||||
|
||||
private int counter = 0;
|
||||
private boolean running = false;
|
||||
private Plot[] plots;
|
||||
private int task;
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
if (args.length < 1) {
|
||||
@ -186,16 +187,16 @@ public class Schematic extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length != 2) {
|
||||
PlayerFunctions.sendMessage(plr, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
||||
PlayerFunctions.sendMessage(null, "&cNeed world arg. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
}
|
||||
final HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]);
|
||||
if ((plotmap == null) || (plotmap.size() == 0)) {
|
||||
PlayerFunctions.sendMessage(plr, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||
PlayerFunctions.sendMessage(null, "&cInvalid world. Use &7/plots sch exportall <world>");
|
||||
return false;
|
||||
}
|
||||
if (this.running) {
|
||||
PlayerFunctions.sendMessage(plr, "&cTask is already running.");
|
||||
PlayerFunctions.sendMessage(null, "&cTask is already running.");
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -206,7 +207,8 @@ public class Schematic extends SubCommand {
|
||||
|
||||
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared");
|
||||
|
||||
this.plots = plotmap.values().toArray(new Plot[0]);
|
||||
Collection<Plot> values = plotmap.values();
|
||||
this.plots = values.toArray(new Plot[values.size()]);
|
||||
this.running = true;
|
||||
this.counter = 0;
|
||||
|
||||
@ -224,17 +226,17 @@ public class Schematic extends SubCommand {
|
||||
final String o = UUIDHandler.getName(plot.owner);
|
||||
final String owner = o == null ? "unknown" : o;
|
||||
if (sch == null) {
|
||||
PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id);
|
||||
PlayerFunctions.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
PlayerFunctions.sendMessage(plr, "&6ID: " + plot.id);
|
||||
PlayerFunctions.sendMessage(null, "&6ID: " + plot.id);
|
||||
final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic");
|
||||
if (!result) {
|
||||
PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id);
|
||||
PlayerFunctions.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, "&7 - &aExport success: " + plot.id);
|
||||
PlayerFunctions.sendMessage(null, "&7 - &aExport success: " + plot.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -274,16 +276,16 @@ public class Schematic extends SubCommand {
|
||||
final String[] split = args[2].split(";");
|
||||
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
if ((PlotMain.getPlots(world) == null) || (PlotMain.getPlots(world).get(i) == null)) {
|
||||
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
return false;
|
||||
}
|
||||
p2 = PlotMain.getPlots(world).get(i);
|
||||
} catch (final Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
PlayerFunctions.sendMessage(plr, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
PlayerFunctions.sendMessage(null, "&cInvalid world or id. Use &7/plots sch save <world> <id>");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -42,13 +42,13 @@ import java.util.List;
|
||||
*/
|
||||
public class Set extends SubCommand {
|
||||
|
||||
public static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
|
||||
public static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
||||
|
||||
public Set() {
|
||||
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true);
|
||||
}
|
||||
|
||||
public static String[] values = new String[]{"biome", "wall", "wall_filling", "floor", "alias", "home", "flag"};
|
||||
public static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
@ -66,10 +66,7 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
if (args.length < 1) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
|
||||
builder.append(getArgumentList(values));
|
||||
PlayerFunctions.sendMessage(plr, builder.toString());
|
||||
PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values));
|
||||
return false;
|
||||
}
|
||||
for (int i = 0; i < aliases.length; i++) {
|
||||
@ -79,13 +76,11 @@ public class Set extends SubCommand {
|
||||
}
|
||||
}
|
||||
/* TODO: Implement option */
|
||||
final boolean advanced_permissions = true;
|
||||
if (advanced_permissions) {
|
||||
// final boolean advanced_permissions = true;
|
||||
if (!PlotMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("flag")) {
|
||||
if (args.length < 2) {
|
||||
@ -141,8 +136,8 @@ public class Set extends SubCommand {
|
||||
if (oldFlag != null) {
|
||||
newflags.remove(oldFlag);
|
||||
}
|
||||
plot.settings.setFlags(newflags.toArray(new Flag[0]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0]));
|
||||
plot.settings.setFlags(newflags.toArray(new Flag[newflags.size()]));
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[newflags.size()]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
|
||||
PlotListener.plotEntry(plr, plot);
|
||||
return true;
|
||||
@ -169,7 +164,8 @@ public class Set extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
plot.settings.addFlag(flag);
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, plot.settings.getFlags().toArray(new Flag[0]));
|
||||
java.util.Set<Flag> flags = plot.settings.getFlags();
|
||||
DBFunc.setFlags(plr.getWorld().getName(), plot, flags.toArray(new Flag[flags.size()]));
|
||||
PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
|
||||
PlotListener.plotEntry(plr, plot);
|
||||
return true;
|
||||
@ -312,8 +308,7 @@ public class Set extends SubCommand {
|
||||
//
|
||||
int index = 0;
|
||||
//
|
||||
byte b = (byte) 0;
|
||||
Material m = null;
|
||||
Material m;
|
||||
//
|
||||
final PlotBlock[] blocks = new PlotBlock[strings.length];
|
||||
|
||||
@ -341,6 +336,7 @@ public class Set extends SubCommand {
|
||||
|
||||
blocks[index] = new PlotBlock((short) m.getId(), (byte) 0);
|
||||
} else {
|
||||
byte b;
|
||||
try {
|
||||
b = (byte) Integer.parseInt(ss[1]);
|
||||
} catch (final Exception e) {
|
||||
@ -396,10 +392,11 @@ public class Set extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
{
|
||||
AbstractFlag af = new AbstractFlag("");
|
||||
AbstractFlag af;
|
||||
try {
|
||||
af = new AbstractFlag(args[0].toLowerCase());
|
||||
} catch (final Exception e) {
|
||||
af = new AbstractFlag("");
|
||||
}
|
||||
if (FlagManager.getFlags().contains(af)) {
|
||||
final StringBuilder a = new StringBuilder();
|
||||
|
@ -38,34 +38,14 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* Created by Citymonstret on 2014-09-26.
|
||||
* Created 2014-09-26 for PlotSquared
|
||||
*
|
||||
* @author Citymonstret, Empire92
|
||||
*/
|
||||
public class Setup extends SubCommand implements Listener {
|
||||
|
||||
public static Map<String, SetupObject> setupMap = new HashMap<>();
|
||||
|
||||
private class SetupObject {
|
||||
String world;
|
||||
String plugin;
|
||||
int current = 0;
|
||||
|
||||
ConfigurationNode[] step;
|
||||
|
||||
public SetupObject(final String world, final PlotWorld plotworld, final String plugin) {
|
||||
this.world = world;
|
||||
this.step = plotworld.getSettingNodes();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public int getCurrent() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return this.step.length;
|
||||
}
|
||||
}
|
||||
|
||||
public Setup() {
|
||||
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false);
|
||||
}
|
||||
@ -109,7 +89,9 @@ public class Setup extends SubCommand implements Listener {
|
||||
final ChunkGenerator generator = plugin.getDefaultWorldGenerator(world, "");
|
||||
final World myworld = WorldCreator.name(world).generator(generator).createWorld();
|
||||
PlayerFunctions.sendMessage(plr, "&aLoaded world.");
|
||||
if (plr != null) {
|
||||
plr.teleport(myworld.getSpawnLocation());
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -183,7 +165,7 @@ public class Setup extends SubCommand implements Listener {
|
||||
return true;
|
||||
}
|
||||
|
||||
final ArrayList<String> generators = new ArrayList<String>();
|
||||
final ArrayList<String> generators = new ArrayList<>();
|
||||
|
||||
ChunkGenerator generator = null;
|
||||
|
||||
@ -220,4 +202,26 @@ public class Setup extends SubCommand implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
private class SetupObject {
|
||||
String world;
|
||||
String plugin;
|
||||
int current = 0;
|
||||
|
||||
ConfigurationNode[] step;
|
||||
|
||||
public SetupObject(final String world, final PlotWorld plotworld, final String plugin) {
|
||||
this.world = world;
|
||||
this.step = plotworld.getSettingNodes();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
public int getCurrent() {
|
||||
return this.current;
|
||||
}
|
||||
|
||||
public int getMax() {
|
||||
return this.step.length;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
|
||||
*
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@SuppressWarnings({"deprecation", "unused", "javadoc"})
|
||||
public abstract class SubCommand {
|
||||
public boolean isPlayer;
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* @author Citymonstret
|
||||
*/
|
||||
@ -79,9 +80,13 @@ public class TP extends SubCommand {
|
||||
}
|
||||
a = split[0];
|
||||
}
|
||||
@SuppressWarnings("deprecation")
|
||||
final Player player = Bukkit.getPlayer(a);
|
||||
if (player != null) {
|
||||
final Plot[] plots = PlotMain.getPlots(world, player).toArray(new Plot[0]);
|
||||
final java.util.Set<Plot> plotMainPlots =
|
||||
PlotMain.getPlots(world, player);
|
||||
final Plot[] plots =
|
||||
plotMainPlots.toArray(new Plot[plotMainPlots.size()]);
|
||||
if (plots.length > index) {
|
||||
return plots[index];
|
||||
}
|
||||
|
@ -44,18 +44,16 @@ public class Unlink extends SubCommand {
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
if (!PlayerFunctions.isInPlot(plr)) {
|
||||
PlayerFunctions.sendMessage(plr, "You're not in a plot.");
|
||||
return true;
|
||||
return sendMessage(plr, C.NOT_IN_PLOT);
|
||||
}
|
||||
final Plot plot = PlayerFunctions.getCurrentPlot(plr);
|
||||
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
|
||||
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
return true;
|
||||
return sendMessage(plr, C.NO_PLOT_PERMS);
|
||||
}
|
||||
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
|
||||
PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||
return true;
|
||||
return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
|
||||
}
|
||||
|
||||
final World world = plr.getWorld();
|
||||
final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
|
||||
final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
|
||||
@ -117,7 +115,13 @@ public class Unlink extends SubCommand {
|
||||
SetBlockFast.update(plr);
|
||||
}
|
||||
} catch (final Exception e) {
|
||||
|
||||
// execute(final Player plr, final String... args) {
|
||||
try {
|
||||
PlotMain.sendConsoleSenderMessage(
|
||||
"Error on: " + getClass().getMethod("execute", Player.class, String[].class).toGenericString() + ":119, when trying to use \"SetBlockFast#update\"");
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
manager.finishPlotUnlink(world, plotworld, ids);
|
||||
|
@ -21,7 +21,10 @@
|
||||
|
||||
package com.intellectualcrafters.plot.commands;
|
||||
|
||||
import com.intellectualcrafters.plot.*;
|
||||
import com.intellectualcrafters.plot.C;
|
||||
import com.intellectualcrafters.plot.Plot;
|
||||
import com.intellectualcrafters.plot.PlotMain;
|
||||
import com.intellectualcrafters.plot.UUIDHandler;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -46,38 +49,31 @@ public class Visit extends SubCommand {
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
if (args.length < 1) {
|
||||
PlayerFunctions.sendMessage(plr, C.NEED_USER);
|
||||
return true;
|
||||
return sendMessage(plr, C.NEED_USER);
|
||||
}
|
||||
final String username = args[0];
|
||||
|
||||
final UUID uuid = UUIDHandler.getUUID(username);
|
||||
List<Plot> plots = null;
|
||||
if (uuid != null) {
|
||||
plots = getPlots(uuid);
|
||||
}
|
||||
if ((uuid == null) || plots.isEmpty()) {
|
||||
PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
return true;
|
||||
return sendMessage(plr, C.FOUND_NO_PLOTS);
|
||||
}
|
||||
if (args.length < 2) {
|
||||
final Plot plot = plots.get(0);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(0));
|
||||
return true;
|
||||
}
|
||||
int i;
|
||||
try {
|
||||
i = Integer.parseInt(args[1]);
|
||||
} catch (final Exception e) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
}
|
||||
if ((i < 0) || (i >= plots.size())) {
|
||||
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
return true;
|
||||
return sendMessage(plr, C.NOT_VALID_NUMBER);
|
||||
}
|
||||
final Plot plot = plots.get(i);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
|
||||
PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(i));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,17 @@ public class list extends SubCommand {
|
||||
super(Command.LIST, "List all plots", "list {mine|shared|all|world}", CommandCategory.INFO, false);
|
||||
}
|
||||
|
||||
private static String getName(final UUID id) {
|
||||
if (id == null) {
|
||||
return "none";
|
||||
}
|
||||
/*
|
||||
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
|
||||
* null) { return "none"; } return name;
|
||||
*/
|
||||
return UUIDHandler.getName(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
if (args.length < 1) {
|
||||
@ -52,7 +63,7 @@ public class list extends SubCommand {
|
||||
}
|
||||
if (args[0].equalsIgnoreCase("mine") && (plr != null)) {
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your") + "\n");
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "your")).append("\n");
|
||||
int idx = 0;
|
||||
for (final Plot p : PlotMain.getPlots(plr)) {
|
||||
string.append(C.PLOT_LIST_ITEM_ORDERED.s().replaceAll("%in", idx + 1 + "").replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
|
||||
@ -67,7 +78,7 @@ public class list extends SubCommand {
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("shared") && (plr != null)) {
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")).append("\n");
|
||||
for (final Plot p : PlotMain.getPlotsSorted()) {
|
||||
if (p.helpers.contains(plr.getUniqueId())) {
|
||||
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
|
||||
@ -111,7 +122,7 @@ public class list extends SubCommand {
|
||||
|
||||
final StringBuilder string = new StringBuilder();
|
||||
|
||||
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all") + "\n");
|
||||
string.append(C.PLOT_LIST_HEADER_PAGED.s().replaceAll("%cur", page + 1 + "").replaceAll("%max", totalPages + 1 + "").replaceAll("%word%", "all")).append("\n");
|
||||
Plot p;
|
||||
|
||||
// This might work xD
|
||||
@ -125,7 +136,7 @@ public class list extends SubCommand {
|
||||
return true;
|
||||
} else if (args[0].equalsIgnoreCase("world") && (plr != null)) {
|
||||
final StringBuilder string = new StringBuilder();
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all") + "\n");
|
||||
string.append(C.PLOT_LIST_HEADER.s().replaceAll("%word%", "all")).append("\n");
|
||||
final HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
|
||||
for (final Plot p : plots.values()) {
|
||||
string.append(C.PLOT_LIST_ITEM.s().replaceAll("%id", p.id.toString()).replaceAll("%world", p.world).replaceAll("%owner", getName(p.owner))).append("\n");
|
||||
@ -140,17 +151,6 @@ public class list extends SubCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private static String getName(final UUID id) {
|
||||
if (id == null) {
|
||||
return "none";
|
||||
}
|
||||
/*
|
||||
* String name = Bukkit.getOfflinePlayer(id).getName(); if (name ==
|
||||
* null) { return "none"; } return name;
|
||||
*/
|
||||
return UUIDHandler.getName(id);
|
||||
}
|
||||
|
||||
private String getArgumentList(final String[] strings) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final String s : strings) {
|
||||
|
@ -35,12 +35,12 @@ import java.util.ArrayList;
|
||||
|
||||
public class plugin extends SubCommand {
|
||||
|
||||
public static String downloads, version;
|
||||
|
||||
public plugin() {
|
||||
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO, false);
|
||||
}
|
||||
|
||||
public static String downloads, version;
|
||||
|
||||
public static void setup(final JavaPlugin plugin) {
|
||||
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
|
||||
@Override
|
||||
@ -65,6 +65,30 @@ public class plugin extends SubCommand {
|
||||
}, 200l);
|
||||
}
|
||||
|
||||
private static String convertToNumericString(final String str, final boolean dividers) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final char c : str.toCharArray()) {
|
||||
if (Character.isDigit(c)) {
|
||||
builder.append(c);
|
||||
} else if (dividers && ((c == ',') || (c == '.') || (c == '-') || (c == '_'))) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
private static String getInfo(final String link) throws Exception {
|
||||
final URLConnection connection = new URL(link).openConnection();
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String document = "", line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
document += (line + "\n");
|
||||
}
|
||||
reader.close();
|
||||
return document;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean execute(final Player plr, final String... args) {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
|
||||
@ -87,32 +111,4 @@ public class plugin extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
|
||||
private static String convertToNumericString(final String str, final boolean dividers) {
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (final char c : str.toCharArray()) {
|
||||
if (Character.isDigit(c)) {
|
||||
builder.append(c);
|
||||
} else if (dividers && ((c == ',') || (c == '.') || (c == '-') || (c == '_'))) {
|
||||
builder.append(c);
|
||||
}
|
||||
}
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* @param link
|
||||
* @return
|
||||
*/
|
||||
private static String getInfo(final String link) throws Exception {
|
||||
final URLConnection connection = new URL(link).openConnection();
|
||||
connection.addRequestProperty("User-Agent", "Mozilla/4.0");
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||
String document = "", line;
|
||||
while ((line = reader.readLine()) != null) {
|
||||
document += (line + "\n");
|
||||
}
|
||||
reader.close();
|
||||
return document;
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user