Fixed a heckload of warnings

This commit is contained in:
Sauilitired 2014-11-09 12:51:17 +01:00
parent 87a0cecb2f
commit 182f4cbd22
17 changed files with 153 additions and 163 deletions

View File

@ -42,11 +42,14 @@ import java.util.Set;
@SuppressWarnings({"unused", "javadoc"}) @SuppressWarnings({"unused", "javadoc"})
public class PlotAPI { public class PlotAPI {
/**
* Admin Permission
*/
public static final String ADMIN_PERMISSION = "plots.admin";
private static PlotHelper plotHelper; private static PlotHelper plotHelper;
private static PlayerFunctions playerFunctions; private static PlayerFunctions playerFunctions;
private static FlagManager flagManager; private static FlagManager flagManager;
private static SchematicHandler schematicHandler; private static SchematicHandler schematicHandler;
private static C c;
// Methods/fields in PlotMain class // Methods/fields in PlotMain class
@ -63,15 +66,21 @@ public class PlotAPI {
// PlotMain.removePlot(world, id, callEvent) // PlotMain.removePlot(world, id, callEvent)
// PlotMain.teleportPlayer(player, from, plot) // PlotMain.teleportPlayer(player, from, plot)
// PlotMain.updatePlot(plot); // PlotMain.updatePlot(plot);
private static C c;
// Reference
// To access plotMain stuff. // To access plotMain stuff.
private final PlotMain plotMain; 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 * Get all plots
@ -122,16 +131,6 @@ public class PlotAPI {
return PlotMain.storage; 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> * Get the main class for this plugin <br>
* - Contains a lot of fields and methods - not very well organized <br> * - Contains a lot of fields and methods - not very well organized <br>
@ -288,7 +287,7 @@ public class PlotAPI {
* @return array of Flag[] * @return array of Flag[]
*/ */
public AbstractFlag[] getFlags() { public AbstractFlag[] getFlags() {
return FlagManager.getFlags().toArray(new AbstractFlag[0]); return FlagManager.getFlags().toArray(new AbstractFlag[FlagManager.getFlags().size()]);
} }
/** /**

View File

@ -31,9 +31,6 @@ import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
/**
* Created by Citymonstret on 2014-08-01.
*/
public class Inbox extends SubCommand { public class Inbox extends SubCommand {
public Inbox() { public Inbox() {

View File

@ -36,6 +36,7 @@ import java.util.UUID;
/** /**
* @author Citymonstret * @author Citymonstret
*/ */
@SuppressWarnings({"unused", "deprecated", "javadoc"})
public class Info extends SubCommand { public class Info extends SubCommand {
public Info() { public Info() {
@ -55,7 +56,7 @@ public class Info extends SubCommand {
plot = PlayerFunctions.getCurrentPlot(player); plot = PlayerFunctions.getCurrentPlot(player);
} else { } else {
if (args.length < 2) { if (args.length < 2) {
PlayerFunctions.sendMessage(player, C.INFO_SYNTAX_CONSOLE); PlayerFunctions.sendMessage(null, C.INFO_SYNTAX_CONSOLE);
return false; return false;
} }
final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]); final PlotWorld plotworld = PlotMain.getWorldSettings(args[0]);

View File

@ -28,9 +28,7 @@ import com.intellectualcrafters.plot.PlotMain;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** @SuppressWarnings({"unused", "deprecation", "javadoc"})
* Created by Citymonstret on 2014-08-01.
*/
public class Kick extends SubCommand { public class Kick extends SubCommand {
public Kick() { public Kick() {

View File

@ -24,9 +24,6 @@ package com.intellectualcrafters.plot.commands;
import com.intellectualcrafters.plot.*; import com.intellectualcrafters.plot.*;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/**
* Created by Citymonstret on 2014-10-12.
*/
public class Paste extends SubCommand { public class Paste extends SubCommand {
public Paste() { public Paste() {

View File

@ -28,9 +28,7 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.database.DBFunc; import com.intellectualcrafters.plot.database.DBFunc;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** @SuppressWarnings({"unused", "deprecated", "javadoc"})
* @Deprecated
*/
public class Purge extends SubCommand { public class Purge extends SubCommand {
public Purge() { public Purge() {
@ -54,12 +52,12 @@ public class Purge extends SubCommand {
} }
if (!PlotMain.isPlotWorld(world)) { if (!PlotMain.isPlotWorld(world)) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_WORLD); PlayerFunctions.sendMessage(null, C.NOT_VALID_PLOT_WORLD);
return false; return false;
} }
PlotMain.getPlots(world).remove(id); PlotMain.getPlots(world).remove(id);
DBFunc.purge(world, 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; return true;
} catch (final Exception e) { } catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID); PlayerFunctions.sendMessage(plr, C.NOT_VALID_PLOT_ID);

View File

@ -26,9 +26,7 @@ import com.intellectualcrafters.plot.PlayerFunctions;
import com.intellectualcrafters.plot.Plot; import com.intellectualcrafters.plot.Plot;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** @SuppressWarnings({"unused", "deprecated", "javadoc"})
* Created by Citymonstret on 2014-10-02.
*/
public class Rate extends SubCommand { public class Rate extends SubCommand {
/* /*

View File

@ -27,9 +27,6 @@ import com.intellectualcrafters.plot.PlotMain;
import com.intellectualcrafters.plot.PlotWorld; import com.intellectualcrafters.plot.PlotWorld;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/**
* @Deprecated
*/
public class Reload extends SubCommand { public class Reload extends SubCommand {
public Reload() { public Reload() {

View File

@ -31,21 +31,22 @@ import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin; import org.bukkit.plugin.Plugin;
import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
public class Schematic extends SubCommand { public class Schematic extends SubCommand {
private int counter = 0;
private boolean running = false;
private Plot[] plots;
private int task;
public Schematic() { public Schematic() {
super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false); super("schematic", "plots.schematic", "Schematic Command", "schematic {arg}", "sch", CommandCategory.ACTIONS, false);
// TODO command to fetch schematic from worldedit directory // TODO command to fetch schematic from worldedit directory
} }
private int counter = 0;
private boolean running = false;
private Plot[] plots;
private int task;
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (args.length < 1) { if (args.length < 1) {
@ -186,16 +187,16 @@ public class Schematic extends SubCommand {
return false; return false;
} }
if (args.length != 2) { 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; return false;
} }
final HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]); final HashMap<PlotId, Plot> plotmap = PlotMain.getPlots(args[1]);
if ((plotmap == null) || (plotmap.size() == 0)) { 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; return false;
} }
if (this.running) { if (this.running) {
PlayerFunctions.sendMessage(plr, "&cTask is already running."); PlayerFunctions.sendMessage(null, "&cTask is already running.");
return false; return false;
} }
@ -206,7 +207,8 @@ public class Schematic extends SubCommand {
final Plugin plugin = Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"); 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.running = true;
this.counter = 0; this.counter = 0;
@ -224,17 +226,17 @@ public class Schematic extends SubCommand {
final String o = UUIDHandler.getName(plot.owner); final String o = UUIDHandler.getName(plot.owner);
final String owner = o == null ? "unknown" : o; final String owner = o == null ? "unknown" : o;
if (sch == null) { if (sch == null) {
PlayerFunctions.sendMessage(plr, "&7 - Skipped plot &c" + plot.id); PlayerFunctions.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
} else { } else {
Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(Bukkit.getServer().getPluginManager().getPlugin("PlotSquared"), new Runnable() {
@Override @Override
public void run() { 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"); final boolean result = SchematicHandler.save(sch, Settings.SCHEMATIC_SAVE_PATH + "/" + plot.id.x + ";" + plot.id.y + "," + worldname + "," + owner + ".schematic");
if (!result) { if (!result) {
PlayerFunctions.sendMessage(plr, "&7 - Failed to save &c" + plot.id); PlayerFunctions.sendMessage(null, "&7 - Failed to save &c" + plot.id);
} else { } 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 String[] split = args[2].split(";");
final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1])); final PlotId i = new PlotId(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
if ((PlotMain.getPlots(world) == null) || (PlotMain.getPlots(world).get(i) == null)) { 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; return false;
} }
p2 = PlotMain.getPlots(world).get(i); p2 = PlotMain.getPlots(world).get(i);
} catch (final Exception e) { } 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; return false;
} }
} else { } 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; return false;
} }
} }

View File

@ -42,13 +42,13 @@ import java.util.List;
*/ */
public class Set extends SubCommand { 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() { public Set() {
super(Command.SET, "Set a plot value", "set {arg} {value...}", CommandCategory.ACTIONS, true); 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") @SuppressWarnings("deprecation")
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
@ -66,10 +66,7 @@ public class Set extends SubCommand {
return false; return false;
} }
if (args.length < 1) { if (args.length < 1) {
final StringBuilder builder = new StringBuilder(); PlayerFunctions.sendMessage(plr, C.SUBCOMMAND_SET_OPTIONS_HEADER.s() + getArgumentList(values));
builder.append(C.SUBCOMMAND_SET_OPTIONS_HEADER.s());
builder.append(getArgumentList(values));
PlayerFunctions.sendMessage(plr, builder.toString());
return false; return false;
} }
for (int i = 0; i < aliases.length; i++) { for (int i = 0; i < aliases.length; i++) {
@ -79,13 +76,11 @@ public class Set extends SubCommand {
} }
} }
/* TODO: Implement option */ /* TODO: Implement option */
final boolean advanced_permissions = true; // final boolean advanced_permissions = true;
if (advanced_permissions) {
if (!PlotMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) { if (!PlotMain.hasPermission(plr, "plots.set." + args[0].toLowerCase())) {
PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase()); PlayerFunctions.sendMessage(plr, C.NO_PERMISSION, "plots.set." + args[0].toLowerCase());
return false; return false;
} }
}
if (args[0].equalsIgnoreCase("flag")) { if (args[0].equalsIgnoreCase("flag")) {
if (args.length < 2) { if (args.length < 2) {
@ -141,8 +136,8 @@ public class Set extends SubCommand {
if (oldFlag != null) { if (oldFlag != null) {
newflags.remove(oldFlag); newflags.remove(oldFlag);
} }
plot.settings.setFlags(newflags.toArray(new Flag[0])); plot.settings.setFlags(newflags.toArray(new Flag[newflags.size()]));
DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[0])); DBFunc.setFlags(plr.getWorld().getName(), plot, newflags.toArray(new Flag[newflags.size()]));
PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED); PlayerFunctions.sendMessage(plr, C.FLAG_REMOVED);
PlotListener.plotEntry(plr, plot); PlotListener.plotEntry(plr, plot);
return true; return true;
@ -169,7 +164,8 @@ public class Set extends SubCommand {
return false; return false;
} }
plot.settings.addFlag(flag); 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); PlayerFunctions.sendMessage(plr, C.FLAG_ADDED);
PlotListener.plotEntry(plr, plot); PlotListener.plotEntry(plr, plot);
return true; return true;
@ -312,8 +308,7 @@ public class Set extends SubCommand {
// //
int index = 0; int index = 0;
// //
byte b = (byte) 0; Material m;
Material m = null;
// //
final PlotBlock[] blocks = new PlotBlock[strings.length]; 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); blocks[index] = new PlotBlock((short) m.getId(), (byte) 0);
} else { } else {
byte b;
try { try {
b = (byte) Integer.parseInt(ss[1]); b = (byte) Integer.parseInt(ss[1]);
} catch (final Exception e) { } catch (final Exception e) {
@ -396,10 +392,11 @@ public class Set extends SubCommand {
return true; return true;
} }
{ {
AbstractFlag af = new AbstractFlag(""); AbstractFlag af;
try { try {
af = new AbstractFlag(args[0].toLowerCase()); af = new AbstractFlag(args[0].toLowerCase());
} catch (final Exception e) { } catch (final Exception e) {
af = new AbstractFlag("");
} }
if (FlagManager.getFlags().contains(af)) { if (FlagManager.getFlags().contains(af)) {
final StringBuilder a = new StringBuilder(); final StringBuilder a = new StringBuilder();

View File

@ -38,34 +38,14 @@ import java.util.HashMap;
import java.util.Map; 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 class Setup extends SubCommand implements Listener {
public static Map<String, SetupObject> setupMap = new HashMap<>(); 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() { public Setup() {
super("setup", "plots.admin", "Setup a PlotWorld", "setup {world} {generator}", "setup", CommandCategory.ACTIONS, false); 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 ChunkGenerator generator = plugin.getDefaultWorldGenerator(world, "");
final World myworld = WorldCreator.name(world).generator(generator).createWorld(); final World myworld = WorldCreator.name(world).generator(generator).createWorld();
PlayerFunctions.sendMessage(plr, "&aLoaded world."); PlayerFunctions.sendMessage(plr, "&aLoaded world.");
if (plr != null) {
plr.teleport(myworld.getSpawnLocation()); plr.teleport(myworld.getSpawnLocation());
}
break; break;
} }
} }
@ -183,7 +165,7 @@ public class Setup extends SubCommand implements Listener {
return true; return true;
} }
final ArrayList<String> generators = new ArrayList<String>(); final ArrayList<String> generators = new ArrayList<>();
ChunkGenerator generator = null; 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;
}
}
} }

View File

@ -30,6 +30,7 @@ import org.bukkit.entity.Player;
* *
* @author Citymonstret * @author Citymonstret
*/ */
@SuppressWarnings({"deprecation", "unused", "javadoc"})
public abstract class SubCommand { public abstract class SubCommand {
public boolean isPlayer; public boolean isPlayer;
/** /**

View File

@ -27,6 +27,7 @@ import org.bukkit.Bukkit;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
/** /**
* @author Citymonstret * @author Citymonstret
*/ */
@ -79,9 +80,13 @@ public class TP extends SubCommand {
} }
a = split[0]; a = split[0];
} }
@SuppressWarnings("deprecation")
final Player player = Bukkit.getPlayer(a); final Player player = Bukkit.getPlayer(a);
if (player != null) { 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) { if (plots.length > index) {
return plots[index]; return plots[index];
} }

View File

@ -44,18 +44,16 @@ public class Unlink extends SubCommand {
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (!PlayerFunctions.isInPlot(plr)) { if (!PlayerFunctions.isInPlot(plr)) {
PlayerFunctions.sendMessage(plr, "You're not in a plot."); return sendMessage(plr, C.NOT_IN_PLOT);
return true;
} }
final Plot plot = PlayerFunctions.getCurrentPlot(plr); final Plot plot = PlayerFunctions.getCurrentPlot(plr);
if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) { if (((plot == null) || !plot.hasOwner() || !plot.getOwner().equals(plr.getUniqueId())) && !PlotMain.hasPermission(plr, "plots.admin")) {
PlayerFunctions.sendMessage(plr, C.NO_PLOT_PERMS); return sendMessage(plr, C.NO_PLOT_PERMS);
return true;
} }
if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) { if (PlayerFunctions.getTopPlot(plr.getWorld(), plot).equals(PlayerFunctions.getBottomPlot(plr.getWorld(), plot))) {
PlayerFunctions.sendMessage(plr, C.UNLINK_IMPOSSIBLE); return sendMessage(plr, C.UNLINK_IMPOSSIBLE);
return true;
} }
final World world = plr.getWorld(); final World world = plr.getWorld();
final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id; final PlotId pos1 = PlayerFunctions.getBottomPlot(world, plot).id;
final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id; final PlotId pos2 = PlayerFunctions.getTopPlot(world, plot).id;
@ -117,7 +115,13 @@ public class Unlink extends SubCommand {
SetBlockFast.update(plr); SetBlockFast.update(plr);
} }
} catch (final Exception e) { } 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); manager.finishPlotUnlink(world, plotworld, ids);

View File

@ -21,7 +21,10 @@
package com.intellectualcrafters.plot.commands; 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 org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
@ -46,38 +49,31 @@ public class Visit extends SubCommand {
@Override @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (args.length < 1) { if (args.length < 1) {
PlayerFunctions.sendMessage(plr, C.NEED_USER); return sendMessage(plr, C.NEED_USER);
return true;
} }
final String username = args[0]; final String username = args[0];
final UUID uuid = UUIDHandler.getUUID(username); final UUID uuid = UUIDHandler.getUUID(username);
List<Plot> plots = null; List<Plot> plots = null;
if (uuid != null) { if (uuid != null) {
plots = getPlots(uuid); plots = getPlots(uuid);
} }
if ((uuid == null) || plots.isEmpty()) { if ((uuid == null) || plots.isEmpty()) {
PlayerFunctions.sendMessage(plr, C.FOUND_NO_PLOTS); return sendMessage(plr, C.FOUND_NO_PLOTS);
return true;
} }
if (args.length < 2) { if (args.length < 2) {
final Plot plot = plots.get(0); PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(0));
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
return true; return true;
} }
int i; int i;
try { try {
i = Integer.parseInt(args[1]); i = Integer.parseInt(args[1]);
} catch (final Exception e) { } catch (final Exception e) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return sendMessage(plr, C.NOT_VALID_NUMBER);
return true;
} }
if ((i < 0) || (i >= plots.size())) { if ((i < 0) || (i >= plots.size())) {
PlayerFunctions.sendMessage(plr, C.NOT_VALID_NUMBER); return sendMessage(plr, C.NOT_VALID_NUMBER);
return true;
} }
final Plot plot = plots.get(i); PlotMain.teleportPlayer(plr, plr.getLocation(), plots.get(i));
PlotMain.teleportPlayer(plr, plr.getLocation(), plot);
return true; return true;
} }
} }

View File

@ -37,6 +37,17 @@ public class list extends SubCommand {
super(Command.LIST, "List all plots", "list {mine|shared|all|world}", CommandCategory.INFO, false); 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 @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
if (args.length < 1) { if (args.length < 1) {
@ -52,7 +63,7 @@ public class list extends SubCommand {
} }
if (args[0].equalsIgnoreCase("mine") && (plr != null)) { if (args[0].equalsIgnoreCase("mine") && (plr != null)) {
final StringBuilder string = new StringBuilder(); 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; int idx = 0;
for (final Plot p : PlotMain.getPlots(plr)) { 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"); 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; return true;
} else if (args[0].equalsIgnoreCase("shared") && (plr != null)) { } else if (args[0].equalsIgnoreCase("shared") && (plr != null)) {
final StringBuilder string = new StringBuilder(); 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()) { for (final Plot p : PlotMain.getPlotsSorted()) {
if (p.helpers.contains(plr.getUniqueId())) { 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"); 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(); 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; Plot p;
// This might work xD // This might work xD
@ -125,7 +136,7 @@ public class list extends SubCommand {
return true; return true;
} else if (args[0].equalsIgnoreCase("world") && (plr != null)) { } else if (args[0].equalsIgnoreCase("world") && (plr != null)) {
final StringBuilder string = new StringBuilder(); 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()); final HashMap<PlotId, Plot> plots = PlotMain.getPlots(plr.getWorld());
for (final Plot p : plots.values()) { 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"); 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) { private String getArgumentList(final String[] strings) {
final StringBuilder builder = new StringBuilder(); final StringBuilder builder = new StringBuilder();
for (final String s : strings) { for (final String s : strings) {

View File

@ -35,12 +35,12 @@ import java.util.ArrayList;
public class plugin extends SubCommand { public class plugin extends SubCommand {
public static String downloads, version;
public plugin() { public plugin() {
super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO, false); super("plugin", "plots.use", "Show plugin information", "plugin", "pl", CommandCategory.INFO, false);
} }
public static String downloads, version;
public static void setup(final JavaPlugin plugin) { public static void setup(final JavaPlugin plugin) {
plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() { plugin.getServer().getScheduler().runTaskLaterAsynchronously(plugin, new Runnable() {
@Override @Override
@ -65,6 +65,30 @@ public class plugin extends SubCommand {
}, 200l); }, 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 @Override
public boolean execute(final Player plr, final String... args) { public boolean execute(final Player plr, final String... args) {
Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() { Bukkit.getScheduler().runTaskAsynchronously(JavaPlugin.getPlugin(PlotMain.class), new Runnable() {
@ -87,32 +111,4 @@ public class plugin extends SubCommand {
return true; 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;
}
} }