mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-25 02:04:44 +02:00
Bug Fix and Cleanup
This commit is contained in:
@ -51,7 +51,6 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
config.load(file);
|
||||
} catch (InvalidConfigurationException | IOException ex) {
|
||||
try {
|
||||
file.getAbsolutePath();
|
||||
File dest = new File(file.getAbsolutePath() + "_broken");
|
||||
int i = 0;
|
||||
while (dest.exists()) {
|
||||
@ -126,7 +125,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
input = (Map<?, ?>) yaml.load(contents);
|
||||
} catch (final YAMLException e) {
|
||||
throw new InvalidConfigurationException(e);
|
||||
} catch (final ClassCastException e) {
|
||||
} catch (final ClassCastException ignored) {
|
||||
throw new InvalidConfigurationException("Top level is not a Map.");
|
||||
}
|
||||
|
||||
@ -189,7 +188,7 @@ public class YamlConfiguration extends FileConfiguration {
|
||||
if (options().copyHeader()) {
|
||||
final Configuration def = getDefaults();
|
||||
|
||||
if (def != null && def instanceof FileConfiguration) {
|
||||
if (def instanceof FileConfiguration) {
|
||||
final FileConfiguration filedefaults = (FileConfiguration) def;
|
||||
final String defaultsHeader = filedefaults.buildHeader();
|
||||
|
||||
|
@ -209,7 +209,7 @@ public class ConfigurationSerialization {
|
||||
} else {
|
||||
return result;
|
||||
}
|
||||
} catch (Throwable ex) {
|
||||
} catch (IllegalAccessException | InvocationTargetException | IllegalArgumentException ex) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName())
|
||||
.log(Level.SEVERE, "Could not call method '" + method.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
@ -222,7 +222,7 @@ public class ConfigurationSerialization {
|
||||
protected ConfigurationSerializable deserializeViaCtor(Constructor<? extends ConfigurationSerializable> ctor, Map<String, ?> args) {
|
||||
try {
|
||||
return ctor.newInstance(args);
|
||||
} catch (Throwable ex) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException | InstantiationException ex) {
|
||||
Logger.getLogger(ConfigurationSerialization.class.getName())
|
||||
.log(Level.SEVERE, "Could not call constructor '" + ctor.toString() + "' of " + this.clazz
|
||||
+ " for deserialization",
|
||||
@ -238,22 +238,17 @@ public class ConfigurationSerialization {
|
||||
}
|
||||
ConfigurationSerializable result = null;
|
||||
Method method = getMethod("deserialize", true);
|
||||
|
||||
if (method != null) {
|
||||
result = deserializeViaMethod(method, args);
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
method = getMethod("valueOf", true);
|
||||
|
||||
if (method != null) {
|
||||
result = deserializeViaMethod(method, args);
|
||||
}
|
||||
}
|
||||
|
||||
if (result == null) {
|
||||
Constructor<? extends ConfigurationSerializable> constructor = getConstructor();
|
||||
|
||||
if (constructor != null) {
|
||||
result = deserializeViaCtor(constructor, args);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ public final class ByteArrayTag extends Tag {
|
||||
}
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte_Array" + append + ": " + hex;
|
||||
|
@ -36,7 +36,7 @@ public final class ByteTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Byte" + append + ": " + this.value;
|
||||
|
@ -373,7 +373,7 @@ public final class CompoundTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
|
@ -16,7 +16,7 @@ public class CompoundTagBuilder {
|
||||
* Create a new instance.
|
||||
*/
|
||||
CompoundTagBuilder() {
|
||||
this.entries = new HashMap<String, Tag>();
|
||||
this.entries = new HashMap<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public final class DoubleTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Double" + append + ": " + this.value;
|
||||
|
@ -36,7 +36,7 @@ public final class FloatTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Float" + append + ": " + this.value;
|
||||
|
@ -48,7 +48,7 @@ public final class IntArrayTag extends Tag {
|
||||
}
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Int_Array" + append + ": " + hex;
|
||||
|
@ -36,7 +36,7 @@ public final class IntTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Int" + append + ": " + this.value;
|
||||
|
@ -378,7 +378,7 @@ public final class ListTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
|
@ -23,7 +23,7 @@ public class ListTagBuilder {
|
||||
ListTagBuilder(Class<? extends Tag> type) {
|
||||
checkNotNull(type);
|
||||
this.type = type;
|
||||
this.entries = new ArrayList<Tag>();
|
||||
this.entries = new ArrayList<>();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -36,7 +36,7 @@ public final class LongTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Long" + append + ": " + this.value;
|
||||
|
@ -36,7 +36,7 @@ public final class ShortTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_Short" + append + ": " + this.value;
|
||||
|
@ -40,7 +40,7 @@ public final class StringTag extends Tag {
|
||||
public String toString() {
|
||||
String name = getName();
|
||||
String append = "";
|
||||
if (name != null && !name.equals("")) {
|
||||
if (name != null && !name.isEmpty()) {
|
||||
append = "(\"" + getName() + "\")";
|
||||
}
|
||||
return "TAG_String" + append + ": " + this.value;
|
||||
|
@ -1330,7 +1330,7 @@ public class JSONObject {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (Throwable exception) {
|
||||
} catch (JSONException exception) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -12,5 +12,5 @@ public interface JSONString {
|
||||
*
|
||||
* @return A strictly syntactically correct JSON text.
|
||||
*/
|
||||
public String toJSONString();
|
||||
String toJSONString();
|
||||
}
|
||||
|
@ -342,7 +342,7 @@ public class JSONTokener {
|
||||
}
|
||||
back();
|
||||
string = sb.toString().trim();
|
||||
if (string != null && string.isEmpty()) {
|
||||
if (string.isEmpty()) {
|
||||
throw syntaxError("Missing value");
|
||||
}
|
||||
return JSONObject.stringToValue(string);
|
||||
@ -370,7 +370,7 @@ public class JSONTokener {
|
||||
index = startIndex;
|
||||
character = startCharacter;
|
||||
line = startLine;
|
||||
return c;
|
||||
return 0;
|
||||
}
|
||||
} while (c != to);
|
||||
} catch (final IOException exception) {
|
||||
|
@ -137,7 +137,7 @@ public class PS {
|
||||
try {
|
||||
URL url = PS.class.getProtectionDomain().getCodeSource().getLocation();
|
||||
this.file = new File(new URL(url.toURI().toString().split("\\!")[0].replaceAll("jar:file", "file")).toURI().getPath());
|
||||
} catch (MalformedURLException | URISyntaxException | SecurityException | NullPointerException e) {
|
||||
} catch (MalformedURLException | URISyntaxException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
this.file = new File(this.IMP.getDirectory().getParentFile(), "PlotSquared.jar");
|
||||
if (!this.file.exists()) {
|
||||
@ -489,11 +489,10 @@ public class PS {
|
||||
return areas[0];
|
||||
} else if (id == null) {
|
||||
return null;
|
||||
} else {
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
for (PlotArea area : areas) {
|
||||
if (StringMan.isEqual(id, area.id)) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -1474,7 +1473,7 @@ public class PS {
|
||||
return;
|
||||
}
|
||||
if (type == 1) {
|
||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + type + "`");
|
||||
throw new IllegalArgumentException("Invalid type for multi-area world. Expected `2`, got `" + 1 + "`");
|
||||
}
|
||||
for (String areaId : areasSection.getKeys(false)) {
|
||||
PS.log(C.PREFIX + "&3 - " + areaId);
|
||||
|
@ -112,7 +112,7 @@ public class Area extends SubCommand {
|
||||
object.plotManager = "PlotSquared";
|
||||
object.setupGenerator = "PlotSquared";
|
||||
object.step = area.getSettingNodes();
|
||||
final String path = "worlds." + area.worldname + ".areas." + area.id + "-" + object.min + "-" + object.max;
|
||||
final String path = "worlds." + area.worldname + ".areas." + area.id + '-' + object.min + '-' + object.max;
|
||||
Runnable run = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -254,7 +254,7 @@ public class Area extends SubCommand {
|
||||
}
|
||||
};
|
||||
if (hasConfirmation(player)) {
|
||||
CmdConfirm.addPending(player, getCommandString() + " " + StringMan.join(args, " "), run);
|
||||
CmdConfirm.addPending(player, getCommandString() + ' ' + StringMan.join(args, " "), run);
|
||||
} else {
|
||||
run.run();
|
||||
}
|
||||
@ -310,11 +310,11 @@ public class Area extends SubCommand {
|
||||
int claimed = area.getPlotCount();
|
||||
int clusters = area.getClusters().size();
|
||||
String region;
|
||||
String generator = area.getGenerator() + "";
|
||||
String generator = String.valueOf(area.getGenerator());
|
||||
if (area.TYPE == 2) {
|
||||
PlotId min = area.getMin();
|
||||
PlotId max = area.getMax();
|
||||
name = area.worldname + ";" + area.id + ";" + min + ";" + max;
|
||||
name = area.worldname + ';' + area.id + ';' + min + ';' + max;
|
||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||
region = area.getRegion().toString();
|
||||
@ -326,7 +326,7 @@ public class Area extends SubCommand {
|
||||
String value = "&r$1NAME: " + name
|
||||
+ "\n$1Type: $2" + area.TYPE
|
||||
+ "\n$1Terrain: $2" + area.TERRAIN
|
||||
+ "\n$1Usage: $2" + String.format("%.2f", percent) + "%"
|
||||
+ "\n$1Usage: $2" + String.format("%.2f", percent) + '%'
|
||||
+ "\n$1Claimed: $2" + claimed
|
||||
+ "\n$1Clusters: $2" + clusters
|
||||
+ "\n$1Region: $2" + region
|
||||
@ -363,11 +363,11 @@ public class Area extends SubCommand {
|
||||
int claimed = area.getPlotCount();
|
||||
int clusters = area.getClusters().size();
|
||||
String region;
|
||||
String generator = area.getGenerator() + "";
|
||||
String generator = String.valueOf(area.getGenerator());
|
||||
if (area.TYPE == 2) {
|
||||
PlotId min = area.getMin();
|
||||
PlotId max = area.getMax();
|
||||
name = area.worldname + ";" + area.id + ";" + min + ";" + max;
|
||||
name = area.worldname + ';' + area.id + ';' + min + ';' + max;
|
||||
int size = (max.x - min.x + 1) * (max.y - min.y + 1);
|
||||
percent = claimed == 0 ? 0 : size / (double) claimed;
|
||||
region = area.getRegion().toString();
|
||||
@ -377,18 +377,18 @@ public class Area extends SubCommand {
|
||||
region = "N/A";
|
||||
}
|
||||
PlotMessage tooltip = new PlotMessage()
|
||||
.text("Claimed=").color("$1").text("" + claimed).color("$2")
|
||||
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + "%").color("$2")
|
||||
.text("\nClusters=").color("$1").text("" + clusters).color("$2")
|
||||
.text("Claimed=").color("$1").text(String.valueOf(claimed)).color("$2")
|
||||
.text("\nUsage=").color("$1").text(String.format("%.2f", percent) + '%').color("$2")
|
||||
.text("\nClusters=").color("$1").text(String.valueOf(clusters)).color("$2")
|
||||
.text("\nRegion=").color("$1").text(region).color("$2")
|
||||
.text("\nGenerator=").color("$1").text(generator).color("$2");
|
||||
|
||||
// type / terrain
|
||||
String visit = "/plot area tp " + area.toString();
|
||||
message.text("[").color("$3")
|
||||
.text(i + "").command(visit).tooltip(visit).color("$1")
|
||||
.text(String.valueOf(i)).command(visit).tooltip(visit).color("$1")
|
||||
.text("]").color("$3")
|
||||
.text(" " + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
||||
.text(' ' + name).tooltip(tooltip).command(getCommandString() + " info " + area).color("$1").text(" - ")
|
||||
.color("$2")
|
||||
.text(area.TYPE + ":" + area.TERRAIN).color("$3");
|
||||
}
|
||||
|
@ -72,7 +72,7 @@ public class Auto extends SubCommand {
|
||||
if (args.length > 1) {
|
||||
schematic = args[1];
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
size_x = 1;
|
||||
size_z = 1;
|
||||
schematic = args[0];
|
||||
|
@ -92,7 +92,7 @@ public class DebugClaimTest extends SubCommand {
|
||||
}
|
||||
if (uuid != null) {
|
||||
MainUtil.sendMessage(plr, " - &aFound plot: " + plot.getId() + " : " + line);
|
||||
plot.owner = uuid;
|
||||
plot.setOwner(uuid);
|
||||
plots.add(plot);
|
||||
} else {
|
||||
MainUtil.sendMessage(plr, " - &cInvalid PlayerName: " + plot.getId() + " : " + line);
|
||||
|
@ -31,11 +31,6 @@ import java.util.Map;
|
||||
permission = "plots.flag")
|
||||
public class FlagCmd extends SubCommand {
|
||||
|
||||
@Override
|
||||
public String getUsage() {
|
||||
return super.getUsage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] args) {
|
||||
|
||||
|
@ -5,6 +5,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.Command;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.util.ArrayList;
|
||||
@ -58,7 +59,7 @@ public class GenerateDocs {
|
||||
String comment = GenerateDocs.getComments(lines);
|
||||
|
||||
GenerateDocs.log("#### Description");
|
||||
GenerateDocs.log("`" + command.getDescription() + "`");
|
||||
GenerateDocs.log('`' + command.getDescription() + '`');
|
||||
if (!comment.isEmpty()) {
|
||||
GenerateDocs.log("##### Comments");
|
||||
GenerateDocs.log("``` java");
|
||||
@ -76,18 +77,18 @@ public class GenerateDocs {
|
||||
GenerateDocs.log(" - `" + StringMan.join(usages, "`\n - `") + "` ");
|
||||
GenerateDocs.log("");
|
||||
} else {
|
||||
GenerateDocs.log("`" + mainUsage + "` ");
|
||||
GenerateDocs.log('`' + mainUsage + "` ");
|
||||
}
|
||||
|
||||
if (command.getRequiredType() != RequiredType.NONE) {
|
||||
GenerateDocs.log("#### Required callers");
|
||||
GenerateDocs.log("`" + command.getRequiredType().name() + "`");
|
||||
GenerateDocs.log('`' + command.getRequiredType().name() + '`');
|
||||
}
|
||||
|
||||
List<String> aliases = command.getAliases();
|
||||
if (!aliases.isEmpty()) {
|
||||
GenerateDocs.log("#### Aliases");
|
||||
GenerateDocs.log("`" + StringMan.getString(command.getAliases()) + "`");
|
||||
GenerateDocs.log('`' + StringMan.getString(command.getAliases()) + '`');
|
||||
}
|
||||
|
||||
GenerateDocs.log("#### Permissions");
|
||||
@ -96,21 +97,21 @@ public class GenerateDocs {
|
||||
GenerateDocs.log(" - `" + command.getPermission() + "` ");
|
||||
GenerateDocs.log("");
|
||||
GenerateDocs.log("##### Other");
|
||||
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + "`");
|
||||
GenerateDocs.log(" - `" + StringMan.join(perms, "`\n - `") + '`');
|
||||
GenerateDocs.log("");
|
||||
} else {
|
||||
GenerateDocs.log("`" + command.getPermission() + "` ");
|
||||
GenerateDocs.log('`' + command.getPermission() + "` ");
|
||||
}
|
||||
GenerateDocs.log("***");
|
||||
GenerateDocs.log("");
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getUsage(String cmd, List<String> lines) {
|
||||
Pattern p = Pattern.compile("\"([^\"]*)\"");
|
||||
HashSet<String> usages = new HashSet<String>();
|
||||
HashSet<String> usages = new HashSet<>();
|
||||
for (String line : lines) {
|
||||
if (line.contains("COMMAND_SYNTAX") && !line.contains("getUsage()")) {
|
||||
Matcher m = p.matcher(line);
|
||||
@ -203,7 +204,7 @@ public class GenerateDocs {
|
||||
line = line.trim();
|
||||
if (line.startsWith("/** ") || line.startsWith("*/ ") || line.startsWith("* ")) {
|
||||
line = line.replaceAll("/[*][*] ", "").replaceAll("[*]/ ", "").replaceAll("[*] ", "").trim();
|
||||
result.append(line + "\n");
|
||||
result.append(line + '\n');
|
||||
}
|
||||
}
|
||||
return result.toString().trim();
|
||||
|
@ -245,12 +245,10 @@ public class ListCmd extends SubCommand {
|
||||
}
|
||||
plots = new ArrayList<>();
|
||||
for (Plot plot : PS.get().getPlots()) {
|
||||
/*
|
||||
Flag price = FlagManager.getPlotFlagRaw(plot, "price");
|
||||
if (price != null) {
|
||||
Optional<Double> price = plot.getFlag(Flags.PRICE);
|
||||
if (price.isPresent()) {
|
||||
plots.add(plot);
|
||||
}
|
||||
*/
|
||||
}
|
||||
break;
|
||||
case "unowned":
|
||||
|
@ -14,7 +14,6 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandDeclaration(command = "merge",
|
||||
@ -74,7 +73,7 @@ public class Merge extends SubCommand {
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
final double price = plotworld.PRICES.containsKey("merge") ? plotworld.PRICES.get("merge") : 0;
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d && EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return false;
|
||||
}
|
||||
final int size = plot.getConnectedPlots().size();
|
||||
@ -108,7 +107,7 @@ public class Merge extends SubCommand {
|
||||
if (plot.autoMerge(-1, maxSize, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
@ -138,7 +137,7 @@ public class Merge extends SubCommand {
|
||||
if (plot.autoMerge(direction, maxSize - size, uuid, terrain)) {
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
return true;
|
||||
@ -152,7 +151,7 @@ public class Merge extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, C.PERMISSION_MERGE_OTHER);
|
||||
return false;
|
||||
}
|
||||
HashSet<UUID> uuids = adjacent.getOwners();
|
||||
java.util.Set<UUID> uuids = adjacent.getOwners();
|
||||
boolean isOnline = false;
|
||||
for (final UUID owner : uuids) {
|
||||
final PlotPlayer accepter = UUIDHandler.getPlayer(owner);
|
||||
@ -173,11 +172,11 @@ public class Merge extends SubCommand {
|
||||
}
|
||||
if (EconHandler.manager != null && plotworld.USE_ECONOMY && price > 0d) {
|
||||
if (EconHandler.manager.getMoney(plr) < price) {
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, price + "");
|
||||
sendMessage(plr, C.CANNOT_AFFORD_MERGE, String.valueOf(price));
|
||||
return;
|
||||
}
|
||||
EconHandler.manager.withdrawMoney(plr, price);
|
||||
sendMessage(plr, C.REMOVED_BALANCE, price + "");
|
||||
sendMessage(plr, C.REMOVED_BALANCE, String.valueOf(price));
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.SUCCESS_MERGE);
|
||||
}
|
||||
|
@ -47,7 +47,7 @@ public class RegenAllRoads extends SubCommand {
|
||||
}
|
||||
String name = args[0];
|
||||
PlotManager manager = area.getPlotManager();
|
||||
if ((manager == null) || !(manager instanceof HybridPlotManager)) {
|
||||
if (!(manager instanceof HybridPlotManager)) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_WORLD);
|
||||
return false;
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ public class Setup extends SubCommand {
|
||||
if (object.setup_index > 0) {
|
||||
object.setup_index--;
|
||||
ConfigurationNode node = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", node.getDescription(), node.getType().getType(),
|
||||
node.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, node.getDescription(), node.getType().getType(),
|
||||
String.valueOf(node.getDefaultValue()));
|
||||
return false;
|
||||
} else if (object.current > 0) {
|
||||
object.current--;
|
||||
@ -127,8 +127,8 @@ public class Setup extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
} else {
|
||||
if (gen.isFull()) {
|
||||
object.plotManager = object.setupGenerator;
|
||||
@ -216,8 +216,8 @@ public class Setup extends SubCommand {
|
||||
.getNewPlotArea("CheckingPlotSquaredGenerator", null, null, null).getSettingNodes();
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
break;
|
||||
}
|
||||
case 6: // world setup
|
||||
@ -229,8 +229,8 @@ public class Setup extends SubCommand {
|
||||
}
|
||||
ConfigurationNode step = object.step[object.setup_index];
|
||||
if (args.length < 1) {
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
}
|
||||
boolean valid = step.isValid(args[0]);
|
||||
@ -243,13 +243,13 @@ public class Setup extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
step = object.step[object.setup_index];
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
} else {
|
||||
sendMessage(plr, C.SETUP_INVALID_ARG, args[0], step.getConstant());
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1 + "", step.getDescription(), step.getType().getType(),
|
||||
step.getDefaultValue() + "");
|
||||
sendMessage(plr, C.SETUP_STEP, object.setup_index + 1, step.getDescription(), step.getType().getType(),
|
||||
String.valueOf(step.getDefaultValue()));
|
||||
return false;
|
||||
}
|
||||
case 7:
|
||||
|
@ -41,7 +41,7 @@ public class Update extends SubCommand {
|
||||
MainUtil.sendMessage(plr, "&cTo manually specify an update URL: /plot update <url>");
|
||||
return false;
|
||||
}
|
||||
if (PS.get().update(null, url) && (url == PS.get().update)) {
|
||||
if (PS.get().update(plr, url) && (url == PS.get().update)) {
|
||||
PS.get().update = null;
|
||||
}
|
||||
return true;
|
||||
|
@ -7,6 +7,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.plotsquared.general.commands.CommandCaller;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.EnumSet;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
@ -730,7 +731,7 @@ public enum C {
|
||||
if (!split[0].equalsIgnoreCase(caption.category)) {
|
||||
changed = true;
|
||||
yml.set(key, null);
|
||||
yml.set(caption.category + "." + caption.name().toLowerCase(), value);
|
||||
yml.set(caption.category + '.' + caption.name().toLowerCase(), value);
|
||||
}
|
||||
captions.add(caption);
|
||||
caption.s = value;
|
||||
@ -747,7 +748,7 @@ public enum C {
|
||||
// HashMap<String, String> replacements = new HashMap<>();
|
||||
replacements.clear();
|
||||
for (String style : styles) {
|
||||
replacements.put("$" + style, "\u00a7" + config.getString(style));
|
||||
replacements.put('$' + style, '§' + config.getString(style));
|
||||
}
|
||||
for (char letter : "1234567890abcdefklmnor".toCharArray()) {
|
||||
replacements.put("&" + letter, "\u00a7" + letter);
|
||||
@ -761,14 +762,14 @@ public enum C {
|
||||
continue;
|
||||
}
|
||||
changed = true;
|
||||
yml.set(caption.category + "." + caption.name().toLowerCase(), caption.def);
|
||||
yml.set(caption.category + '.' + caption.name().toLowerCase(), caption.def);
|
||||
}
|
||||
caption.s = StringMan.replaceFromMap(caption.s, replacements);
|
||||
}
|
||||
if (changed) {
|
||||
yml.save(file);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (IOException | IllegalArgumentException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
@ -41,7 +41,7 @@ public class Configuration {
|
||||
try {
|
||||
Integer.parseInt(string);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -54,12 +54,8 @@ public class Configuration {
|
||||
public static final SettingValue<Boolean> BOOLEAN = new SettingValue<Boolean>("BOOLEAN") {
|
||||
@Override
|
||||
public boolean validateValue(String string) {
|
||||
try {
|
||||
Boolean.parseBoolean(string);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
return false;
|
||||
}
|
||||
Boolean.parseBoolean(string);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -73,7 +69,7 @@ public class Configuration {
|
||||
try {
|
||||
Double.parseDouble(string);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -89,7 +85,7 @@ public class Configuration {
|
||||
try {
|
||||
int biome = WorldUtil.IMP.getBiomeFromString(string.toUpperCase());
|
||||
return biome != -1;
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -134,7 +130,7 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
return true;
|
||||
} catch (NumberFormatException e) {
|
||||
} catch (NumberFormatException ignored) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -39,7 +39,7 @@ public class SQLite extends Database {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
file.createNewFile();
|
||||
} catch (IOException e) {
|
||||
} catch (IOException ignored) {
|
||||
PS.debug("&cUnable to create database!");
|
||||
}
|
||||
}
|
||||
|
@ -12,9 +12,9 @@ public abstract class StmtMod<T> {
|
||||
public String getCreateMySQL(int size, String query, int params) {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append("),");
|
||||
statement.append('(').append(StringMan.repeat(",?", params).substring(1)).append("),");
|
||||
}
|
||||
statement.append("(").append(StringMan.repeat(",?", params).substring(1)).append(")");
|
||||
statement.append('(').append(StringMan.repeat(",?", params).substring(1)).append(')');
|
||||
return statement.toString();
|
||||
}
|
||||
|
||||
@ -22,7 +22,7 @@ public abstract class StmtMod<T> {
|
||||
StringBuilder statement = new StringBuilder(query);
|
||||
String modParams = StringMan.repeat(",?", params).substring(1);
|
||||
for (int i = 0; i < size - 1; i++) {
|
||||
statement.append("UNION SELECT ").append(modParams).append(" ");
|
||||
statement.append("UNION SELECT ").append(modParams).append(' ');
|
||||
}
|
||||
return statement.toString();
|
||||
}
|
||||
|
@ -2,7 +2,7 @@ package com.intellectualcrafters.plot.flag;
|
||||
|
||||
public class Flag<V> {
|
||||
|
||||
private String name;
|
||||
private final String name;
|
||||
|
||||
/**
|
||||
* Flag object used to store basic information for a Plot. Flags are a
|
||||
|
@ -127,9 +127,8 @@ public class AugmentedUtils {
|
||||
}
|
||||
if (!has) {
|
||||
continue;
|
||||
} else {
|
||||
toReturn = true;
|
||||
}
|
||||
toReturn = true;
|
||||
secondaryMask = new PlotChunk<Object>(wrap) {
|
||||
@Override
|
||||
public Object getChunkAbs() {
|
||||
|
@ -2,6 +2,7 @@ package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.google.common.collect.BiMap;
|
||||
import com.google.common.collect.ImmutableSet;
|
||||
import com.intellectualcrafters.jnbt.CompoundTag;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
@ -212,19 +213,19 @@ public class Plot {
|
||||
String[] split = string.split(";|,");
|
||||
if (split.length == 2) {
|
||||
if (defaultArea != null) {
|
||||
PlotId id = PlotId.fromString(split[0] + ";" + split[1]);
|
||||
PlotId id = PlotId.fromString(split[0] + ';' + split[1]);
|
||||
return id != null ? defaultArea.getPlotAbs(id) : null;
|
||||
}
|
||||
} else if (split.length == 3) {
|
||||
PlotArea pa = PS.get().getPlotArea(split[0], null);
|
||||
if (pa != null) {
|
||||
PlotId id = PlotId.fromString(split[1] + ";" + split[2]);
|
||||
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
|
||||
return pa.getPlotAbs(id);
|
||||
}
|
||||
} else if (split.length == 4) {
|
||||
PlotArea pa = PS.get().getPlotArea(split[0], split[1]);
|
||||
if (pa != null) {
|
||||
PlotId id = PlotId.fromString(split[1] + ";" + split[2]);
|
||||
PlotId id = PlotId.fromString(split[1] + ';' + split[2]);
|
||||
return pa.getPlotAbs(id);
|
||||
}
|
||||
}
|
||||
@ -348,17 +349,17 @@ public class Plot {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get a list of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||
* Get a immutable set of owner UUIDs for a plot (supports multi-owner mega-plots).
|
||||
* @return
|
||||
*/
|
||||
public HashSet<UUID> getOwners() {
|
||||
public Set<UUID> getOwners() {
|
||||
if (this.owner == null) {
|
||||
return new HashSet<>();
|
||||
}
|
||||
if (isMerged()) {
|
||||
HashSet<Plot> plots = getConnectedPlots();
|
||||
Plot[] array = plots.toArray(new Plot[plots.size()]);
|
||||
HashSet<UUID> owners = new HashSet<UUID>(1);
|
||||
ImmutableSet.Builder<UUID> owners = ImmutableSet.builder();
|
||||
UUID last = this.owner;
|
||||
owners.add(this.owner);
|
||||
for (Plot current : array) {
|
||||
@ -367,9 +368,9 @@ public class Plot {
|
||||
last = current.owner;
|
||||
}
|
||||
}
|
||||
return owners;
|
||||
return owners.build();
|
||||
}
|
||||
return new HashSet<>(Collections.singletonList(this.owner));
|
||||
return ImmutableSet.of(this.owner);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -380,10 +381,7 @@ public class Plot {
|
||||
* @return true if the player is added/trusted or is the owner
|
||||
*/
|
||||
public boolean isAdded(UUID uuid) {
|
||||
if (this.owner == null) {
|
||||
return false;
|
||||
}
|
||||
if (getDenied().contains(uuid)) {
|
||||
if (this.owner == null || getDenied().contains(uuid)) {
|
||||
return false;
|
||||
}
|
||||
if (getTrusted().contains(uuid) || getTrusted().contains(DBFunc.everyone)) {
|
||||
@ -1742,7 +1740,7 @@ public class Plot {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String name = Plot.this.id + "," + Plot.this.area + "," + MainUtil.getName(Plot.this.owner);
|
||||
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil.getName(Plot.this.owner);
|
||||
boolean result =
|
||||
SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
||||
if (whenDone != null) {
|
||||
@ -2034,7 +2032,7 @@ public class Plot {
|
||||
this.create();
|
||||
}
|
||||
return this.owner;
|
||||
} catch (IllegalArgumentException e) {
|
||||
} catch (IllegalArgumentException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -2576,16 +2574,15 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
TaskManager.TELEPORT_QUEUE.remove(name);
|
||||
if (!player.isOnline()) {
|
||||
return;
|
||||
if (player.isOnline()) {
|
||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
}
|
||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
}
|
||||
}, Settings.TELEPORT_DELAY * 20);
|
||||
return true;
|
||||
}
|
||||
return result;
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isOnline() {
|
||||
@ -2876,6 +2873,7 @@ public class Plot {
|
||||
}
|
||||
|
||||
public boolean hasFlag(Flag<?> flag) {
|
||||
//todo
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -515,7 +515,7 @@ public class PlotAnalysis {
|
||||
int SIZE = 10;
|
||||
List<Integer>[] bucket = new ArrayList[SIZE];
|
||||
for (int i = 0; i < bucket.length; i++) {
|
||||
bucket[i] = new ArrayList<Integer>();
|
||||
bucket[i] = new ArrayList<>();
|
||||
}
|
||||
boolean maxLength = false;
|
||||
int placement = 1;
|
||||
|
@ -1,6 +1,6 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class PlotHandler {
|
||||
@ -8,7 +8,7 @@ public class PlotHandler {
|
||||
if ((plot1.owner == null) || (plot2.owner == null)) {
|
||||
return false;
|
||||
}
|
||||
final HashSet<UUID> owners = plot1.getOwners();
|
||||
final Set<UUID> owners = plot1.getOwners();
|
||||
owners.retainAll(plot2.getOwners());
|
||||
return !owners.isEmpty();
|
||||
}
|
||||
|
@ -245,19 +245,6 @@ public abstract class PlotPlayer implements CommandCaller {
|
||||
*/
|
||||
public abstract UUID getUUID();
|
||||
|
||||
/**
|
||||
* Check the player's permissions<br>
|
||||
* - Will be cached if permission caching is enabled
|
||||
*/
|
||||
@Override
|
||||
public abstract boolean hasPermission(String permission);
|
||||
|
||||
/**
|
||||
* Send the player a message
|
||||
*/
|
||||
@Override
|
||||
public abstract void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* Teleport the player to a location
|
||||
* @param location
|
||||
|
@ -254,7 +254,7 @@ public class BO3Handler {
|
||||
try (FileOutputStream fos = new FileOutputStream(bo3File)) {
|
||||
write(fos, plot, bo3);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.io.PrintWriter;
|
||||
@ -125,7 +126,7 @@ public class MainUtil {
|
||||
filename = "plot." + extension;
|
||||
} else {
|
||||
website = Settings.WEB_URL + "save.php?" + uuid;
|
||||
filename = file + "." + extension;
|
||||
filename = file + '.' + extension;
|
||||
}
|
||||
final URL url;
|
||||
try {
|
||||
@ -183,7 +184,7 @@ public class MainUtil {
|
||||
whenDone.value = url;
|
||||
}
|
||||
TaskManager.runTask(whenDone);
|
||||
} catch (Exception e) {
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
TaskManager.runTask(whenDone);
|
||||
}
|
||||
@ -298,7 +299,8 @@ public class MainUtil {
|
||||
public static String getName(UUID owner) {
|
||||
if (owner == null) {
|
||||
return C.NONE.s();
|
||||
} else if (owner.equals(DBFunc.everyone)) {
|
||||
}
|
||||
if (owner.equals(DBFunc.everyone)) {
|
||||
return C.EVERYONE.s();
|
||||
}
|
||||
String name = UUIDHandler.getName(owner);
|
||||
@ -365,7 +367,7 @@ public class MainUtil {
|
||||
uuid = UUID.fromString(term);
|
||||
}
|
||||
uuids.add(uuid);
|
||||
} catch (Exception e) {
|
||||
} catch (Exception ignored) {
|
||||
id = PlotId.fromString(term);
|
||||
if (id != null) {
|
||||
continue;
|
||||
@ -772,20 +774,20 @@ public class MainUtil {
|
||||
}
|
||||
String info;
|
||||
if (full && Settings.RATING_CATEGORIES != null && Settings.RATING_CATEGORIES.size() > 1) {
|
||||
String rating = "";
|
||||
String prefix = "";
|
||||
double[] ratings = MainUtil.getAverageRatings(plot);
|
||||
for (double v : ratings) {
|
||||
|
||||
}
|
||||
|
||||
String rating = "";
|
||||
String prefix = "";
|
||||
for (int i = 0; i < ratings.length; i++) {
|
||||
rating += prefix + Settings.RATING_CATEGORIES.get(i) + "=" + String.format("%.1f", ratings[i]);
|
||||
rating += prefix + Settings.RATING_CATEGORIES.get(i) + '=' + String.format("%.1f", ratings[i]);
|
||||
prefix = ",";
|
||||
}
|
||||
info = newInfo.replaceAll("%rating%", rating);
|
||||
} else {
|
||||
info = newInfo.replaceAll("%rating%", String.format("%.1f", plot.getAverageRating()) + "/" + max);
|
||||
info = newInfo.replaceAll("%rating%", String.format("%.1f", plot.getAverageRating()) + '/' + max);
|
||||
}
|
||||
whenDone.run(info);
|
||||
}
|
||||
|
@ -115,7 +115,7 @@ public class MathMan {
|
||||
}
|
||||
|
||||
public static double sqrtApprox(double d) {
|
||||
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1l << 52)) >> 1) + (1l << 61));
|
||||
return Double.longBitsToDouble(((Double.doubleToLongBits(d) - (1L << 52)) >> 1) + (1L << 61));
|
||||
}
|
||||
|
||||
public static float invSqrt(float x) {
|
||||
|
@ -27,8 +27,8 @@ public class ReflectionUtils {
|
||||
|
||||
public ReflectionUtils(String version) {
|
||||
if (version != null) {
|
||||
preClassB += "." + version;
|
||||
preClassM += "." + version;
|
||||
preClassB += '.' + version;
|
||||
preClassM += '.' + version;
|
||||
}
|
||||
}
|
||||
|
||||
@ -73,29 +73,29 @@ public class ReflectionUtils {
|
||||
} catch (ClassCastException ignored) {
|
||||
}
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | SecurityException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public static Class<?> getNmsClass(String name) {
|
||||
String className = preClassM + "." + name;
|
||||
String className = preClassM + '.' + name;
|
||||
return getClass(className);
|
||||
}
|
||||
|
||||
public static Class<?> getCbClass(String name) {
|
||||
String className = preClassB + "." + name;
|
||||
String className = preClassB + '.' + name;
|
||||
return getClass(className);
|
||||
}
|
||||
|
||||
public static Class<?> getUtilClass(String name) {
|
||||
try {
|
||||
return Class.forName(name); //Try before 1.8 first
|
||||
} catch (ClassNotFoundException ex) {
|
||||
} catch (ClassNotFoundException ignored) {
|
||||
try {
|
||||
return Class.forName("net.minecraft.util." + name); //Not 1.8
|
||||
} catch (ClassNotFoundException ex2) {
|
||||
} catch (ClassNotFoundException ignored2) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -110,9 +110,9 @@ public class ReflectionUtils {
|
||||
public static Method makeMethod(Class<?> clazz, String methodName, Class<?>... paramaters) {
|
||||
try {
|
||||
return clazz.getDeclaredMethod(methodName, paramaters);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
} catch (SecurityException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@ -127,7 +127,7 @@ public class ReflectionUtils {
|
||||
return (T) method.invoke(instance, paramaters);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@ -136,9 +136,9 @@ public class ReflectionUtils {
|
||||
public static <T> Constructor<T> makeConstructor(Class<?> clazz, Class<?>... paramaterTypes) {
|
||||
try {
|
||||
return (Constructor<T>) clazz.getConstructor(paramaterTypes);
|
||||
} catch (NoSuchMethodException ex) {
|
||||
} catch (NoSuchMethodException ignored) {
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
} catch (SecurityException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@ -152,7 +152,7 @@ public class ReflectionUtils {
|
||||
return constructor.newInstance(paramaters);
|
||||
} catch (InvocationTargetException ex) {
|
||||
throw new RuntimeException(ex.getCause());
|
||||
} catch (Exception ex) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException | InstantiationException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@ -160,9 +160,9 @@ public class ReflectionUtils {
|
||||
public static Field makeField(Class<?> clazz, String name) {
|
||||
try {
|
||||
return clazz.getDeclaredField(name);
|
||||
} catch (NoSuchFieldException ex) {
|
||||
} catch (NoSuchFieldException ignored) {
|
||||
return null;
|
||||
} catch (Exception ex) {
|
||||
} catch (SecurityException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
@ -175,7 +175,7 @@ public class ReflectionUtils {
|
||||
field.setAccessible(true);
|
||||
try {
|
||||
return (T) field.get(instance);
|
||||
} catch (Exception ex) {
|
||||
} catch (IllegalAccessException | IllegalArgumentException ex) {
|
||||
throw new RuntimeException(ex);
|
||||
}
|
||||
}
|
||||
|
@ -577,6 +577,8 @@ public abstract class SchematicHandler {
|
||||
try (OutputStream stream = new FileOutputStream(tmp); NBTOutputStream output = new NBTOutputStream(new GZIPOutputStream(stream))) {
|
||||
output.writeTag(tag);
|
||||
}
|
||||
} catch (FileNotFoundException e) {
|
||||
e.printStackTrace();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
@ -253,7 +253,7 @@ public abstract class Command {
|
||||
return;
|
||||
}
|
||||
if (page == 0 && totalPages != 0) { // Next
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (page + 2))
|
||||
new PlotMessage().text("<-").color("$3").text(" | ").color("$3").text("->").color("$1").command(baseCommand + " " + (0 + 2))
|
||||
.text(C.CLICKABLE.s()).color("$2").send(player);
|
||||
return;
|
||||
}
|
||||
|
@ -4,8 +4,14 @@ import com.intellectualcrafters.plot.commands.RequiredType;
|
||||
|
||||
public interface CommandCaller {
|
||||
|
||||
/**
|
||||
* Send the player a message.
|
||||
*/
|
||||
void sendMessage(String message);
|
||||
|
||||
/**
|
||||
* Check the player's permissions. Will be cached if permission caching is enabled.
|
||||
*/
|
||||
boolean hasPermission(String perm);
|
||||
|
||||
RequiredType getSuperCaller();
|
||||
|
@ -123,11 +123,10 @@ public class WESubscriber {
|
||||
if (maskextent != null) {
|
||||
wrapper = new ExtentWrapper(maskextent);
|
||||
field.set(maskextent, history);
|
||||
event.setExtent(wrapper);
|
||||
} else {
|
||||
wrapper = new ExtentWrapper(history);
|
||||
event.setExtent(wrapper);
|
||||
}
|
||||
event.setExtent(wrapper);
|
||||
field.set(history, reorder);
|
||||
field.set(reorder, new ProcessedWEExtent(world, mask, max, new FastModeExtent(worldObj, true), wrapper));
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package com.intellectualcrafters.plot;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
import com.intellectualcrafters.plot.database.AbstractDBTEst;
|
||||
import com.intellectualcrafters.plot.database.AbstractDBTest;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.Flags;
|
||||
@ -27,7 +27,7 @@ public class FlagTest {
|
||||
@Before
|
||||
public void setUp() throws Exception {
|
||||
EventUtil.manager = new EventUtilTest();
|
||||
DBFunc.dbManager = new AbstractDBTEst();
|
||||
DBFunc.dbManager = new AbstractDBTest();
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -15,70 +15,54 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
public class AbstractDBTEst implements AbstractDB {
|
||||
public class AbstractDBTest implements AbstractDB {
|
||||
|
||||
@Override public void setOwner(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createPlotsAndData(ArrayList<Plot> plots, Runnable whenDone) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createPlot(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createTables() throws Exception {
|
||||
|
||||
@Override public void createTables() {
|
||||
}
|
||||
|
||||
@Override public void delete(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteSettings(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteHelpers(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteTrusted(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteDenied(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteComments(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void deleteRatings(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void delete(PlotCluster cluster) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void addPersistentMeta(UUID uuid, String key, byte[] meta, boolean delete) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removePersistentMeta(UUID uuid, String key) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void getPersistentMeta(UUID uuid, RunnableVal<Map<String, byte[]>> result) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createPlotSettings(int id, Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public int getId(Plot plot) {
|
||||
@ -94,7 +78,6 @@ public class AbstractDBTEst implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override public void validateAllPlots(Set<Plot> toValidate) {
|
||||
|
||||
}
|
||||
|
||||
@Override public HashMap<String, Set<PlotCluster>> getClusters() {
|
||||
@ -102,83 +85,63 @@ public class AbstractDBTEst implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override public void setMerged(Plot plot, boolean[] merged) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void swapPlots(Plot plot1, Plot plot2) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setFlags(Plot plot, HashMap<Flag<?>, Object> flags) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setFlags(PlotCluster cluster, HashMap<Flag<?>, Object> flags) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setClusterName(PlotCluster cluster, String name) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setAlias(Plot plot, String alias) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void purgeIds(Set<Integer> uniqueIds) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void purge(PlotArea area, Set<PlotId> plotIds) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setPosition(Plot plot, String position) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setPosition(PlotCluster cluster, String position) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeTrusted(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeHelper(PlotCluster cluster, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeMember(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeInvited(PlotCluster cluster, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setTrusted(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setHelper(PlotCluster cluster, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setMember(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setInvited(PlotCluster cluster, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeDenied(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setDenied(Plot plot, UUID uuid) {
|
||||
|
||||
}
|
||||
|
||||
@Override public HashMap<UUID, Integer> getRatings(Plot plot) {
|
||||
@ -186,43 +149,33 @@ public class AbstractDBTEst implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override public void setRating(Plot plot, UUID rater, int value) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void removeComment(Plot plot, PlotComment comment) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void clearInbox(Plot plot, String inbox) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void setComment(Plot plot, PlotComment comment) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void getComments(Plot plot, String inbox, RunnableVal<List<PlotComment>> whenDone) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createPlotAndSettings(Plot plot, Runnable whenDone) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void createCluster(PlotCluster cluster) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void resizeCluster(PlotCluster current, PlotId min, PlotId max) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void movePlot(Plot originalPlot, Plot newPlot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void replaceUUID(UUID old, UUID now) {
|
||||
|
||||
}
|
||||
|
||||
@Override public boolean deleteTables() {
|
||||
@ -230,14 +183,11 @@ public class AbstractDBTEst implements AbstractDB {
|
||||
}
|
||||
|
||||
@Override public void close() {
|
||||
|
||||
}
|
||||
|
||||
@Override public void replaceWorld(String oldWorld, String newWorld, PlotId min, PlotId max) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void updateTables(int[] oldVersion) {
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -31,7 +31,6 @@ public class EventUtilTest extends EventUtil {
|
||||
}
|
||||
|
||||
@Override public void callDelete(Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public boolean callFlagAdd(Flag flag, Plot plot) {
|
||||
@ -55,22 +54,17 @@ public class EventUtilTest extends EventUtil {
|
||||
}
|
||||
|
||||
@Override public void callEntry(PlotPlayer player, Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void callLeave(PlotPlayer player, Plot plot) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void callDenied(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void callTrusted(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
}
|
||||
|
||||
@Override public void callMember(PlotPlayer initiator, Plot plot, UUID player, boolean added) {
|
||||
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user