Code cleanup

maybe a bug fix or two
This commit is contained in:
MattBDev
2016-03-28 17:31:40 -04:00
parent 8d4f042abc
commit 76e2b1f416
18 changed files with 99 additions and 97 deletions

View File

@ -41,7 +41,7 @@ import java.util.UUID;
usage = "/plot add <player>",
category = CommandCategory.SETTINGS,
permission = "plots.add",
requiredType = RequiredType.NONE)
requiredType = RequiredType.PLAYER)
public class Add extends SubCommand {
public Add() {

View File

@ -39,7 +39,7 @@ import java.util.Set;
description = "Create a new PlotArea",
aliases = "world",
usage = "/plot area <create|info|list|tp|regen>",
confirmation=true)
confirmation = true)
public class Area extends SubCommand {
@Override

View File

@ -41,7 +41,7 @@ import java.util.UUID;
description = "Deny a user from a plot",
usage = "/plot deny <player>",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE)
requiredType = RequiredType.PLAYER)
public class Deny extends SubCommand {
public Deny() {

View File

@ -28,6 +28,7 @@ import com.intellectualcrafters.plot.util.MainUtil;
import com.intellectualcrafters.plot.util.Permissions;
import com.intellectualcrafters.plot.util.UUIDHandler;
import com.intellectualcrafters.plot.util.WorldUtil;
import com.plotsquared.general.commands.Argument;
import com.plotsquared.general.commands.CommandDeclaration;
@CommandDeclaration(command = "kick",
@ -35,9 +36,13 @@ import com.plotsquared.general.commands.CommandDeclaration;
description = "Kick a player from your plot",
permission = "plots.kick",
category = CommandCategory.TELEPORT,
requiredType = RequiredType.NONE)
requiredType = RequiredType.PLAYER)
public class Kick extends SubCommand {
public Kick() {
super(Argument.PlayerName);
}
@Override
public boolean onCommand(PlotPlayer plr, String[] args) {
Location loc = plr.getLocation();

View File

@ -46,8 +46,8 @@ import java.util.UUID;
confirmation=true)
public class Merge extends SubCommand {
public final static String[] values = new String[]{"north", "east", "south", "west", "auto"};
public final static String[] aliases = new String[]{"n", "e", "s", "w", "all"};
public static final String[] values = new String[]{"north", "east", "south", "west", "auto"};
public static final String[] aliases = new String[]{"n", "e", "s", "w", "all"};
public static String direction(float yaw) {
yaw = yaw / 90;

View File

@ -40,7 +40,7 @@ import java.util.UUID;
description = "Remove a player from a plot",
usage = "/plot remove <player>",
category = CommandCategory.SETTINGS,
requiredType = RequiredType.NONE,
requiredType = RequiredType.PLAYER,
permission = "plots.remove")
public class Remove extends SubCommand {

View File

@ -52,8 +52,8 @@ import java.util.HashSet;
requiredType = RequiredType.NONE)
public class Set extends SubCommand {
public final static String[] values = new String[]{"biome", "alias", "home", "flag"};
public final static String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
public static final String[] values = new String[]{"biome", "alias", "home", "flag"};
public static final String[] aliases = new String[]{"b", "w", "wf", "f", "a", "h", "fl"};
private final SetCommand component;

View File

@ -37,7 +37,7 @@ import java.util.UUID;
@CommandDeclaration(
command = "trust",
aliases = {"t"},
requiredType = RequiredType.NONE,
requiredType = RequiredType.PLAYER,
usage = "/plot trust <player>",
description = "Allow a player to build in a plot",
category = CommandCategory.SETTINGS)

View File

@ -46,9 +46,9 @@ import java.util.Set;
*/
public class FlagManager {
private final static HashSet<String> reserved = new HashSet<>();
private static final HashSet<String> reserved = new HashSet<>();
private final static HashSet<AbstractFlag> flags = new HashSet<>();
private static final HashSet<AbstractFlag> flags = new HashSet<>();
/**
* Reserve a flag so that it cannot be set by players

View File

@ -25,7 +25,8 @@ public class BlockLoc {
public static BlockLoc fromString(String string) {
String[] parts = string.split(",");
float yaw, pitch;
float yaw;
float pitch;
if (parts.length == 3) {
yaw = 0f;
pitch = 0f;

View File

@ -20,23 +20,20 @@
////////////////////////////////////////////////////////////////////////////////////////////////////
package com.intellectualcrafters.plot.object;
/**
*/
public class PlotBlock {
public final static PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0);
public static final PlotBlock EVERYTHING = new PlotBlock((short) 0, (byte) 0);
public final short id;
public final byte data;
public PlotBlock(final short id, final byte data) {
public PlotBlock(short id, byte data) {
this.id = id;
this.data = data;
}
@Override
public boolean equals(final Object obj) {
public boolean equals(Object obj) {
if (this == obj) {
return true;
}
@ -46,20 +43,20 @@ public class PlotBlock {
if (getClass() != obj.getClass()) {
return false;
}
final PlotBlock other = (PlotBlock) obj;
return ((id == other.id) && ((data == other.data) || (data == -1) || (other.data == -1)));
PlotBlock other = (PlotBlock) obj;
return (this.id == other.id) && ((this.data == other.data) || (this.data == -1) || (other.data == -1));
}
@Override
public int hashCode() {
return id;
return this.id;
}
@Override
public String toString() {
if (data == -1) {
return id + "";
if (this.data == -1) {
return this.id + "";
}
return id + ":" + data;
return this.id + ":" + this.data;
}
}

View File

@ -62,19 +62,19 @@ public class BO3Handler {
}
/**
* Save a plot as a BO3 file<br>
* Save a plot as a BO3 file.
* - Use null for the player object if no player is applicable
* @param plr
* @param player
* @param plot
* @return
*/
public static boolean saveBO3(PlotPlayer plr, Plot plot, RunnableVal<BO3> saveTask) {
public static boolean saveBO3(PlotPlayer player, Plot plot, RunnableVal<BO3> saveTask) {
if (saveTask == null) {
throw new IllegalArgumentException("Save task cannot be null!");
}
PlotArea plotworld = plot.getArea();
if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) {
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
MainUtil.sendMessage(player, "BO3 exporting only supports type 0 classic generation.");
return false;
}
String alias = plot.toString();
@ -150,7 +150,7 @@ public class BO3Handler {
}
if (!content) {
MainUtil.sendMessage(plr, "No content found!");
MainUtil.sendMessage(player, "No content found!");
return false;
}
@ -177,7 +177,7 @@ public class BO3Handler {
}
}
if (parentLoc == null) {
MainUtil.sendMessage(plr,
MainUtil.sendMessage(player,
"Exporting BO3 cancelled due to detached chunk: " + chunk + " - Make sure you only have one object per plot");
return false;
}
@ -189,7 +189,7 @@ public class BO3Handler {
saveTask.run(entry.getValue());
}
MainUtil.sendMessage(plr, "BO3 exporting was successful!");
MainUtil.sendMessage(player, "BO3 exporting was successful!");
return true;
}

View File

@ -473,7 +473,11 @@ public abstract class Command {
String arg = args[0].toLowerCase();
if (space) {
Command cmd = getCommand(arg);
return (cmd != null && cmd.canExecute(player, false)) ? cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space) : null;
if (cmd != null && cmd.canExecute(player, false)) {
return cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space);
} else {
return null;
}
} else {
Set<Command> commands = new HashSet<Command>();
for (Map.Entry<String, Command> entry : this.staticCommands.entrySet()) {
@ -485,7 +489,11 @@ public abstract class Command {
}
default:
Command cmd = getCommand(args[0]);
return cmd != null ? cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space) : null;
if (cmd != null) {
return cmd.tab(player, Arrays.copyOfRange(args, 1, args.length), space);
} else {
return null;
}
}
}