mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 22:56:45 +01:00
Code Style Cleanup
This commit is contained in:
parent
19b6df8268
commit
029241912b
@ -139,7 +139,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
|
||||
@Override
|
||||
public void log(String message) {
|
||||
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
|
||||
if (THIS != null && Bukkit.getServer().getConsoleSender() != null) {
|
||||
try {
|
||||
message = C.color(message);
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
@ -377,7 +377,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||
final String version = BukkitMain.worldEdit.getDescription().getVersion();
|
||||
if ((version != null) && version.startsWith("5.")) {
|
||||
if (version != null && version.startsWith("5.")) {
|
||||
log("&cThis version of WorldEdit does not support PlotSquared.");
|
||||
log("&cPlease use WorldEdit 6+ for masking support");
|
||||
log("&c - http://builds.enginehub.org/job/worldedit");
|
||||
@ -461,7 +461,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
}
|
||||
}
|
||||
}, 20);
|
||||
return (Bukkit.getPluginManager().getPlugin("PlotMe") != null) || (Bukkit.getPluginManager().getPlugin("AthionPlots") != null);
|
||||
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -470,7 +470,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
return null;
|
||||
}
|
||||
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
||||
if ((gen_plugin != null) && gen_plugin.isEnabled()) {
|
||||
if (gen_plugin != null && gen_plugin.isEnabled()) {
|
||||
ChunkGenerator gen = gen_plugin.getDefaultWorldGenerator(world, "");
|
||||
if (gen instanceof GeneratorWrapper<?>) {
|
||||
return (GeneratorWrapper<?>) gen;
|
||||
@ -497,19 +497,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||
UUIDWrapper wrapper;
|
||||
if (Settings.OFFLINE_MODE) {
|
||||
if (Settings.UUID_LOWERCASE) {
|
||||
wrapper = (new LowerOfflineUUIDWrapper());
|
||||
wrapper = new LowerOfflineUUIDWrapper();
|
||||
} else {
|
||||
wrapper = (new OfflineUUIDWrapper());
|
||||
wrapper = new OfflineUUIDWrapper();
|
||||
}
|
||||
Settings.OFFLINE_MODE = true;
|
||||
} else if (checkVersion) {
|
||||
wrapper = (new DefaultUUIDWrapper());
|
||||
wrapper = new DefaultUUIDWrapper();
|
||||
Settings.OFFLINE_MODE = false;
|
||||
} else {
|
||||
if (Settings.UUID_LOWERCASE) {
|
||||
wrapper = (new LowerOfflineUUIDWrapper());
|
||||
wrapper = new LowerOfflineUUIDWrapper();
|
||||
} else {
|
||||
wrapper = (new OfflineUUIDWrapper());
|
||||
wrapper = new OfflineUUIDWrapper();
|
||||
}
|
||||
Settings.OFFLINE_MODE = true;
|
||||
}
|
||||
|
@ -48,6 +48,12 @@ import java.util.logging.Level;
|
||||
*/
|
||||
public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<MessagePart>, ConfigurationSerializable {
|
||||
|
||||
private static final JsonParser _stringParser = new JsonParser();
|
||||
private static Constructor<?> nmsPacketPlayOutChatConstructor;
|
||||
// The ChatSerializer's instance of Gson
|
||||
private static Object nmsChatSerializerGsonInstance;
|
||||
private static Method fromJsonMethod;
|
||||
|
||||
static {
|
||||
ConfigurationSerialization.registerClass(FancyMessage.class);
|
||||
}
|
||||
@ -56,20 +62,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
private String jsonString;
|
||||
private boolean dirty;
|
||||
|
||||
private static Constructor<?> nmsPacketPlayOutChatConstructor;
|
||||
|
||||
@Override
|
||||
public FancyMessage clone() throws CloneNotSupportedException {
|
||||
final FancyMessage instance = (FancyMessage) super.clone();
|
||||
instance.messageParts = new ArrayList<>(messageParts.size());
|
||||
for (int i = 0; i < messageParts.size(); i++) {
|
||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||
}
|
||||
instance.dirty = false;
|
||||
instance.jsonString = null;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a JSON message with text.
|
||||
* @param firstPartText The existing text in the message.
|
||||
@ -103,6 +95,105 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
this((TextualComponent) null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON-represented message from a mapping of key-value pairs.
|
||||
* This is called by the Bukkit serialization API.
|
||||
* It is not intended for direct public API consumption.
|
||||
* @param serialized The key-value mapping which represents a fancy message.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static FancyMessage deserialize(final Map<String, Object> serialized) {
|
||||
final FancyMessage msg = new FancyMessage();
|
||||
msg.messageParts = (List<MessagePart>) serialized.get("messageParts");
|
||||
msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
|
||||
msg.dirty = !serialized.containsKey("JSON");
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a fancy message from its JSON representation. This JSON representation is of the format of
|
||||
* that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
|
||||
* @param json The JSON string which represents a fancy message.
|
||||
* @return A {@code FancyMessage} representing the parametrized JSON message.
|
||||
*/
|
||||
public static FancyMessage deserialize(final String json) {
|
||||
final JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
|
||||
final JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
|
||||
final FancyMessage returnVal = new FancyMessage();
|
||||
returnVal.messageParts.clear();
|
||||
for (final JsonElement mPrt : extra) {
|
||||
final MessagePart component = new MessagePart();
|
||||
final JsonObject messagePart = mPrt.getAsJsonObject();
|
||||
for (final Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
|
||||
// Deserialize text
|
||||
if (TextualComponent.isTextKey(entry.getKey())) {
|
||||
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
|
||||
final Map<String, Object> serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
|
||||
serializedMapForm.put("key", entry.getKey());
|
||||
if (entry.getValue().isJsonPrimitive()) {
|
||||
// Assume string
|
||||
serializedMapForm.put("value", entry.getValue().getAsString());
|
||||
} else {
|
||||
// Composite object, but we assume each element is a string
|
||||
for (final Map.Entry<String, JsonElement> compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
component.text = TextualComponent.deserialize(serializedMapForm);
|
||||
} else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
|
||||
if (entry.getValue().getAsBoolean()) {
|
||||
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
|
||||
}
|
||||
} else if (entry.getKey().equals("color")) {
|
||||
component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
|
||||
} else if (entry.getKey().equals("clickEvent")) {
|
||||
final JsonObject object = entry.getValue().getAsJsonObject();
|
||||
component.clickActionName = object.get("action").getAsString();
|
||||
component.clickActionData = object.get("value").getAsString();
|
||||
} else if (entry.getKey().equals("hoverEvent")) {
|
||||
final JsonObject object = entry.getValue().getAsJsonObject();
|
||||
component.hoverActionName = object.get("action").getAsString();
|
||||
if (object.get("value").isJsonPrimitive()) {
|
||||
// Assume string
|
||||
component.hoverActionData = new JsonString(object.get("value").getAsString());
|
||||
} else {
|
||||
// Assume composite type
|
||||
// The only composite type we currently store is another FancyMessage
|
||||
// Therefore, recursion time!
|
||||
component.hoverActionData =
|
||||
deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */);
|
||||
}
|
||||
} else if (entry.getKey().equals("insertion")) {
|
||||
component.insertionData = entry.getValue().getAsString();
|
||||
} else if (entry.getKey().equals("with")) {
|
||||
for (final JsonElement object : entry.getValue().getAsJsonArray()) {
|
||||
if (object.isJsonPrimitive()) {
|
||||
component.translationReplacements.add(new JsonString(object.getAsString()));
|
||||
} else {
|
||||
// Only composite type stored in this array is - again - FancyMessages
|
||||
// Recurse within this function to parse this as a translation replacement
|
||||
component.translationReplacements.add(deserialize(object.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
returnVal.messageParts.add(component);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
|
||||
@Override
|
||||
public FancyMessage clone() throws CloneNotSupportedException {
|
||||
final FancyMessage instance = (FancyMessage) super.clone();
|
||||
instance.messageParts = new ArrayList<>(messageParts.size());
|
||||
for (int i = 0; i < messageParts.size(); i++) {
|
||||
instance.messageParts.add(i, messageParts.get(i).clone());
|
||||
}
|
||||
instance.dirty = false;
|
||||
instance.jsonString = null;
|
||||
return instance;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the text of the current editing component to a value.
|
||||
* @param text The new text of the current editing component.
|
||||
@ -283,7 +374,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
if (type == Type.UNTYPED) {
|
||||
throw new IllegalArgumentException("That statistic needs no additional parameter!");
|
||||
}
|
||||
if (((type == Type.BLOCK) && item.isBlock()) || (type == Type.ENTITY)) {
|
||||
if (type == Type.BLOCK && item.isBlock() || type == Type.ENTITY) {
|
||||
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||
}
|
||||
try {
|
||||
@ -382,6 +473,24 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the
|
||||
* message.
|
||||
* @param replacements The replacements, in order, that will be used in the language-specific message.
|
||||
* @return This builder instance.
|
||||
*//* ------------
|
||||
public FancyMessage translationReplacements(final Iterable<? extends CharSequence> replacements){
|
||||
for(CharSequence str : replacements){
|
||||
latest().translationReplacements.add(new JsonString(str));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* Set the behavior of the current editing component to display raw text when the client hovers over the text.
|
||||
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.</p>
|
||||
@ -392,7 +501,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
builder.append(lines[i]);
|
||||
if (i != (lines.length - 1)) {
|
||||
if (i != lines.length - 1) {
|
||||
builder.append('\n');
|
||||
}
|
||||
}
|
||||
@ -408,9 +517,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
*/
|
||||
public FancyMessage formattedTooltip(final FancyMessage text) {
|
||||
for (final MessagePart component : text.messageParts) {
|
||||
if ((component.clickActionData != null) && (component.clickActionName != null)) {
|
||||
if (component.clickActionData != null && component.clickActionName != null) {
|
||||
throw new IllegalArgumentException("The tooltip text cannot have click data.");
|
||||
} else if ((component.hoverActionData != null) && (component.hoverActionName != null)) {
|
||||
} else if (component.hoverActionData != null && component.hoverActionName != null) {
|
||||
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
|
||||
}
|
||||
}
|
||||
@ -436,16 +545,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
for (int i = 0; i < lines.length; i++) {
|
||||
try {
|
||||
for (final MessagePart component : lines[i]) {
|
||||
if ((component.clickActionData != null) && (component.clickActionName != null)) {
|
||||
if (component.clickActionData != null && component.clickActionName != null) {
|
||||
throw new IllegalArgumentException("The tooltip text cannot have click data.");
|
||||
} else if ((component.hoverActionData != null) && (component.hoverActionName != null)) {
|
||||
} else if (component.hoverActionData != null && component.hoverActionName != null) {
|
||||
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
|
||||
}
|
||||
if (component.hasText()) {
|
||||
result.messageParts.add(component.clone());
|
||||
}
|
||||
}
|
||||
if (i != (lines.length - 1)) {
|
||||
if (i != lines.length - 1) {
|
||||
result.messageParts.add(new MessagePart(rawText("\n")));
|
||||
}
|
||||
} catch (final CloneNotSupportedException e) {
|
||||
@ -480,23 +589,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
return this;
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
/**
|
||||
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
|
||||
* @param replacements The replacements, in order, that will be used in the language-specific message.
|
||||
* @return This builder instance.
|
||||
*//* ------------
|
||||
public FancyMessage translationReplacements(final Iterable<? extends CharSequence> replacements){
|
||||
for(CharSequence str : replacements){
|
||||
latest().translationReplacements.add(new JsonString(str));
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
*/
|
||||
|
||||
/**
|
||||
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
|
||||
* @param replacements The replacements, in order, that will be used in the language-specific message.
|
||||
@ -577,7 +669,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
* @return The JSON string representing this object.
|
||||
*/
|
||||
public String toJSONString() {
|
||||
if (!dirty && (jsonString != null)) {
|
||||
if (!dirty && jsonString != null) {
|
||||
return jsonString;
|
||||
}
|
||||
final StringWriter string = new StringWriter();
|
||||
@ -626,10 +718,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
}
|
||||
}
|
||||
|
||||
// The ChatSerializer's instance of Gson
|
||||
private static Object nmsChatSerializerGsonInstance;
|
||||
private static Method fromJsonMethod;
|
||||
|
||||
private Object createChatPacket(final String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||
ClassNotFoundException {
|
||||
if (nmsChatSerializerGsonInstance == null) {
|
||||
@ -640,7 +728,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
final double majorVersion = Double.parseDouble(version.replace('_', '.').substring(1, 4));
|
||||
final int lesserVersion = Integer.parseInt(version.substring(6, 7));
|
||||
|
||||
if ((majorVersion < 1.8) || ((majorVersion == 1.8) && (lesserVersion == 1))) {
|
||||
if (majorVersion < 1.8 || majorVersion == 1.8 && lesserVersion == 1) {
|
||||
chatSerializerClazz = Reflection.getNMSClass("ChatSerializer");
|
||||
} else {
|
||||
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||
@ -749,21 +837,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
return map;
|
||||
}
|
||||
|
||||
/**
|
||||
* Deserialize a JSON-represented message from a mapping of key-value pairs.
|
||||
* This is called by the Bukkit serialization API.
|
||||
* It is not intended for direct public API consumption.
|
||||
* @param serialized The key-value mapping which represents a fancy message.
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static FancyMessage deserialize(final Map<String, Object> serialized) {
|
||||
final FancyMessage msg = new FancyMessage();
|
||||
msg.messageParts = (List<MessagePart>) serialized.get("messageParts");
|
||||
msg.jsonString = serialized.containsKey("JSON") ? serialized.get("JSON").toString() : null;
|
||||
msg.dirty = !serialized.containsKey("JSON");
|
||||
return msg;
|
||||
}
|
||||
|
||||
/**
|
||||
* <b>Internally called method. Not for API consumption.</b>
|
||||
*/
|
||||
@ -771,77 +844,4 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
||||
public Iterator<MessagePart> iterator() {
|
||||
return messageParts.iterator();
|
||||
}
|
||||
|
||||
private static JsonParser _stringParser = new JsonParser();
|
||||
|
||||
/**
|
||||
* Deserialize a fancy message from its JSON representation. This JSON representation is of the format of
|
||||
* that returned by {@link #toJSONString()}, and is compatible with vanilla inputs.
|
||||
* @param json The JSON string which represents a fancy message.
|
||||
* @return A {@code FancyMessage} representing the parametrized JSON message.
|
||||
*/
|
||||
public static FancyMessage deserialize(final String json) {
|
||||
final JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
|
||||
final JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
|
||||
final FancyMessage returnVal = new FancyMessage();
|
||||
returnVal.messageParts.clear();
|
||||
for (final JsonElement mPrt : extra) {
|
||||
final MessagePart component = new MessagePart();
|
||||
final JsonObject messagePart = mPrt.getAsJsonObject();
|
||||
for (final Map.Entry<String, JsonElement> entry : messagePart.entrySet()) {
|
||||
// Deserialize text
|
||||
if (TextualComponent.isTextKey(entry.getKey())) {
|
||||
// The map mimics the YAML serialization, which has a "key" field and one or more "value" fields
|
||||
final Map<String, Object> serializedMapForm = new HashMap<>(); // Must be object due to Bukkit serializer API compliance
|
||||
serializedMapForm.put("key", entry.getKey());
|
||||
if (entry.getValue().isJsonPrimitive()) {
|
||||
// Assume string
|
||||
serializedMapForm.put("value", entry.getValue().getAsString());
|
||||
} else {
|
||||
// Composite object, but we assume each element is a string
|
||||
for (final Map.Entry<String, JsonElement> compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) {
|
||||
serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString());
|
||||
}
|
||||
}
|
||||
component.text = TextualComponent.deserialize(serializedMapForm);
|
||||
} else if (MessagePart.stylesToNames.inverse().containsKey(entry.getKey())) {
|
||||
if (entry.getValue().getAsBoolean()) {
|
||||
component.styles.add(MessagePart.stylesToNames.inverse().get(entry.getKey()));
|
||||
}
|
||||
} else if (entry.getKey().equals("color")) {
|
||||
component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase());
|
||||
} else if (entry.getKey().equals("clickEvent")) {
|
||||
final JsonObject object = entry.getValue().getAsJsonObject();
|
||||
component.clickActionName = object.get("action").getAsString();
|
||||
component.clickActionData = object.get("value").getAsString();
|
||||
} else if (entry.getKey().equals("hoverEvent")) {
|
||||
final JsonObject object = entry.getValue().getAsJsonObject();
|
||||
component.hoverActionName = object.get("action").getAsString();
|
||||
if (object.get("value").isJsonPrimitive()) {
|
||||
// Assume string
|
||||
component.hoverActionData = new JsonString(object.get("value").getAsString());
|
||||
} else {
|
||||
// Assume composite type
|
||||
// The only composite type we currently store is another FancyMessage
|
||||
// Therefore, recursion time!
|
||||
component.hoverActionData = deserialize(object.get("value").toString() /* This should properly serialize the JSON object as a JSON string */);
|
||||
}
|
||||
} else if (entry.getKey().equals("insertion")) {
|
||||
component.insertionData = entry.getValue().getAsString();
|
||||
} else if (entry.getKey().equals("with")) {
|
||||
for (final JsonElement object : entry.getValue().getAsJsonArray()) {
|
||||
if (object.isJsonPrimitive()) {
|
||||
component.translationReplacements.add(new JsonString(object.getAsString()));
|
||||
} else {
|
||||
// Only composite type stored in this array is - again - FancyMessages
|
||||
// Recurse within this function to parse this as a translation replacement
|
||||
component.translationReplacements.add(deserialize(object.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
returnVal.messageParts.add(component);
|
||||
}
|
||||
return returnVal;
|
||||
}
|
||||
}
|
||||
|
@ -259,7 +259,7 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
loaded = true;
|
||||
}
|
||||
// Set random seed
|
||||
this.random.state = (cx << 16) | (cz & 0xFFFF);
|
||||
this.random.state = cx << 16 | cz & 0xFFFF;
|
||||
// Process the chunk
|
||||
if (ChunkManager.preProcessChunk(result)) {
|
||||
return;
|
||||
@ -267,7 +267,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||
plotGenerator.generateChunk(chunkSetter, area, this.random);
|
||||
ChunkManager.postProcessChunk(result);
|
||||
return;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -316,6 +315,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
||||
if (obj == null) {
|
||||
return false;
|
||||
}
|
||||
return (toString().equals(obj.toString()) || toString().equals(obj.getClass().getName()));
|
||||
return toString().equals(obj.toString()) || toString().equals(obj.getClass().getName());
|
||||
}
|
||||
}
|
||||
|
@ -45,6 +45,5 @@ public class PlayerEvents_1_8_3 implements Listener {
|
||||
iter.remove();
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -73,7 +73,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
||||
}
|
||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||
if (strings.length < 1) {
|
||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
||||
if (strings.length == 0 || "plots".startsWith(s)) {
|
||||
return Collections.singletonList("plots");
|
||||
}
|
||||
}
|
||||
|
@ -1,18 +1,5 @@
|
||||
package com.plotsquared.bukkit.util;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
@ -23,6 +10,18 @@ import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
|
||||
import org.bukkit.material.Directional;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
|
||||
public class BukkitHybridUtils extends HybridUtils {
|
||||
|
||||
@ -72,8 +71,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
final int ctz = tz >> 4;
|
||||
final Random r = new Random();
|
||||
MainUtil.initCache();
|
||||
final int width = (tx - bx) + 1;
|
||||
final int length = (tz - bz) + 1;
|
||||
final int width = tx - bx + 1;
|
||||
final int length = tz - bz + 1;
|
||||
|
||||
System.gc();
|
||||
System.gc();
|
||||
@ -90,17 +89,17 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
final int X = value[0];
|
||||
final int Z = value[1];
|
||||
final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
|
||||
final int xb = ((X) << 4) - bx;
|
||||
final int zb = ((Z) << 4) - bz;
|
||||
final int xb = (X << 4) - bx;
|
||||
final int zb = (Z << 4) - bz;
|
||||
for (int i = 0; i < result.length; i++) {
|
||||
if (result[i] == null) {
|
||||
for (int j = 0; j < 4096; j++) {
|
||||
final int x = MainUtil.x_loc[i][j] + xb;
|
||||
if ((x < 0) || (x >= width)) {
|
||||
if (x < 0 || x >= width) {
|
||||
continue;
|
||||
}
|
||||
final int z = MainUtil.z_loc[i][j] + zb;
|
||||
if ((z < 0) || (z >= length)) {
|
||||
if (z < 0 || z >= length) {
|
||||
continue;
|
||||
}
|
||||
final int y = MainUtil.y_loc[i][j];
|
||||
@ -110,11 +109,11 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
}
|
||||
for (int j = 0; j < result[i].length; j++) {
|
||||
final int x = MainUtil.x_loc[i][j] + xb;
|
||||
if ((x < 0) || (x >= width)) {
|
||||
if (x < 0 || x >= width) {
|
||||
continue;
|
||||
}
|
||||
final int z = MainUtil.z_loc[i][j] + zb;
|
||||
if ((z < 0) || (z >= length)) {
|
||||
if (z < 0 || z >= length) {
|
||||
continue;
|
||||
}
|
||||
final int y = MainUtil.y_loc[i][j];
|
||||
@ -150,7 +149,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
} else {
|
||||
// check vertices
|
||||
// modifications_adjacent
|
||||
if ((x > 0) && (z > 0) && (y > 0) && (x < (width - 1)) && (z < (length - 1)) && (y < 255)) {
|
||||
if (x > 0 && z > 0 && y > 0 && x < width - 1 && z < length - 1 && y < 255) {
|
||||
if (newblocks[y - 1][x][z] == 0) {
|
||||
faces[i]++;
|
||||
}
|
||||
@ -196,11 +195,11 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
analysis.air = (int) (MathMan.getMean(air) * 100);
|
||||
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
||||
|
||||
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
|
||||
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
|
||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
|
||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
|
||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
|
||||
analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes);
|
||||
analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces);
|
||||
analysis.data_sd = (int) MathMan.getSD(data, analysis.data);
|
||||
analysis.air_sd = (int) MathMan.getSD(air, analysis.air);
|
||||
analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety);
|
||||
System.gc();
|
||||
System.gc();
|
||||
whenDone.value = analysis;
|
||||
@ -222,24 +221,24 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
final int Z = value[1];
|
||||
worldObj.loadChunk(X, Z);
|
||||
int minX;
|
||||
int minZ;
|
||||
int maxX;
|
||||
int maxZ;
|
||||
if (X == cbx) {
|
||||
minX = bx & 15;
|
||||
} else {
|
||||
minX = 0;
|
||||
}
|
||||
int minZ;
|
||||
if (Z == cbz) {
|
||||
minZ = bz & 15;
|
||||
} else {
|
||||
minZ = 0;
|
||||
}
|
||||
int maxX;
|
||||
if (X == ctx) {
|
||||
maxX = tx & 15;
|
||||
} else {
|
||||
maxX = 16;
|
||||
}
|
||||
int maxZ;
|
||||
if (Z == ctz) {
|
||||
maxZ = tz & 15;
|
||||
} else {
|
||||
@ -249,8 +248,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
final int cbx = X << 4;
|
||||
final int cbz = Z << 4;
|
||||
|
||||
final int xb = (cbx) - bx;
|
||||
final int zb = (cbz) - bz;
|
||||
final int xb = cbx - bx;
|
||||
final int zb = cbz - bz;
|
||||
for (int x = minX; x <= maxX; x++) {
|
||||
final int xx = cbx + x;
|
||||
for (int z = minZ; z <= maxZ; z++) {
|
||||
@ -311,7 +310,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
||||
for (int y = sy; y < maxY; y++) {
|
||||
if (y > ey) {
|
||||
final Block block = world.getBlockAt(x, y, z);
|
||||
if (block.getTypeId() != 0) {
|
||||
if (!block.getType().equals(Material.AIR)) {
|
||||
ey = y;
|
||||
}
|
||||
}
|
||||
|
@ -85,7 +85,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
int count = 0;
|
||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||
while (i.hasNext() && (count < 128)) {
|
||||
while (i.hasNext() && count < 128) {
|
||||
chunks.add(i.next().getValue());
|
||||
i.remove();
|
||||
count++;
|
||||
@ -180,7 +180,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
// Trim entities
|
||||
for (int i = 0; i < 16; i++) {
|
||||
if ((entities[i] != null) && (fs.getCount(i) >= 4096)) {
|
||||
if (entities[i] != null && fs.getCount(i) >= 4096) {
|
||||
entities[i].clear();
|
||||
}
|
||||
}
|
||||
@ -195,7 +195,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
continue;
|
||||
}
|
||||
Object section = sections[j];
|
||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
||||
if (section == null || fs.getCount(j) >= 4096) {
|
||||
char[] array = new char[4096];
|
||||
for (int i = 0; i < newArray.length; i++) {
|
||||
int combined = newArray[i];
|
||||
@ -317,7 +317,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
|
||||
methodInitLighting.of(c).call();
|
||||
|
||||
if ((bc.getTotalRelight() == 0 && !fixAll)) {
|
||||
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
||||
if (section == null) {
|
||||
continue;
|
||||
}
|
||||
if ((bc.getRelight(j) == 0 && !fixAll) || bc.getCount(j) == 0 || (bc.getCount(j) >= 4096 && bc.getAir(j) == 0)) {
|
||||
if (bc.getRelight(j) == 0 && !fixAll || bc.getCount(j) == 0 || bc.getCount(j) >= 4096 && bc.getAir(j) == 0) {
|
||||
continue;
|
||||
}
|
||||
final int[] array = bc.getIdArray(j);
|
||||
|
@ -208,7 +208,7 @@ public class PS {
|
||||
@Override
|
||||
public void run() {
|
||||
for (final Plot plot : getPlots()) {
|
||||
if (plot.hasOwner() && (plot.temp != -1)) {
|
||||
if (plot.hasOwner() && plot.temp != -1) {
|
||||
if (UUIDHandler.getName(plot.owner) == null) {
|
||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||
}
|
||||
@ -376,8 +376,8 @@ public class PS {
|
||||
* @return true if `version` is >= `version2`
|
||||
*/
|
||||
public boolean checkVersion(final int[] version, int... version2) {
|
||||
return (version[0] > version2[0]) || ((version[0] == version2[0]) && (version[1] > version2[1])) || ((version[0] == version2[0]) && (version[1] == version2[1]) && (
|
||||
version[2] >= version2[2]));
|
||||
return version[0] > version2[0] || version[0] == version2[0] && version[1] > version2[1] || version[0] == version2[0]
|
||||
&& version[1] == version2[1] && version[2] >= version2[2];
|
||||
}
|
||||
|
||||
/**
|
||||
@ -518,7 +518,7 @@ public class PS {
|
||||
if (areas == null) {
|
||||
for (PlotArea area : plotareas) {
|
||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
||||
if (area.id == null || (split.length == 2 && area.id.equalsIgnoreCase(split[1]))) {
|
||||
if (area.id == null || split.length == 2 && area.id.equalsIgnoreCase(split[1])) {
|
||||
return area;
|
||||
}
|
||||
}
|
||||
@ -902,7 +902,7 @@ public class PS {
|
||||
} else {
|
||||
extra.add(plot);
|
||||
}
|
||||
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
|
||||
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
|
||||
extra.add(plot);
|
||||
} else {
|
||||
overflow.add(plot);
|
||||
@ -950,7 +950,7 @@ public class PS {
|
||||
} else {
|
||||
extra.add(plot);
|
||||
}
|
||||
} else if ((Math.abs(plot.getId().x) > 15446) || (Math.abs(plot.getId().y) > 15446)) {
|
||||
} else if (Math.abs(plot.getId().x) > 15446 || Math.abs(plot.getId().y) > 15446) {
|
||||
extra.add(plot);
|
||||
} else {
|
||||
overflow.add(plot);
|
||||
@ -1011,7 +1011,7 @@ public class PS {
|
||||
for (final Plot i : input) {
|
||||
int tmp = MathMan.getPositiveId(i.hashCode()) / placement;
|
||||
bucket[tmp & 31].add(i);
|
||||
if (maxLength && (tmp > 0)) {
|
||||
if (maxLength && tmp > 0) {
|
||||
maxLength = false;
|
||||
}
|
||||
}
|
||||
@ -1062,7 +1062,7 @@ public class PS {
|
||||
Collections.sort(areas, new Comparator<PlotArea>() {
|
||||
@Override
|
||||
public int compare(final PlotArea a, final PlotArea b) {
|
||||
if ((priorityArea != null) && StringMan.isEqual(a.toString(), b.toString())) {
|
||||
if (priorityArea != null && StringMan.isEqual(a.toString(), b.toString())) {
|
||||
return -1;
|
||||
}
|
||||
return a.hashCode() - b.hashCode();
|
||||
@ -1229,7 +1229,7 @@ public class PS {
|
||||
}
|
||||
|
||||
public Plot getPlot(PlotArea area, final PlotId id) {
|
||||
return area == null ? null : (id == null ? null : area.getPlot(id));
|
||||
return area == null ? null : id == null ? null : area.getPlot(id);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1338,7 +1338,7 @@ public class PS {
|
||||
if (!plotareaHasCollision && !plotareaHashCheck.add(world.hashCode())) {
|
||||
plotareaHasCollision = true;
|
||||
}
|
||||
final Set<String> worlds = (config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>());
|
||||
final Set<String> worlds = config.contains("worlds") ? config.getConfigurationSection("worlds").getKeys(false) : new HashSet<String>();
|
||||
final String path = "worlds." + world;
|
||||
ConfigurationSection worldSection = config.getConfigurationSection(path);
|
||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||
@ -1543,7 +1543,7 @@ public class PS {
|
||||
* @return boolean | if valid arguments were provided
|
||||
*/
|
||||
public boolean setupPlotWorld(final String world, final String args, IndependentPlotGenerator generator) {
|
||||
if ((args != null) && (!args.isEmpty())) {
|
||||
if (args != null && !args.isEmpty()) {
|
||||
// save configuration
|
||||
final String[] split = args.split(",");
|
||||
final HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
|
||||
@ -1869,7 +1869,7 @@ public class PS {
|
||||
case "false":
|
||||
return false;
|
||||
default:
|
||||
return (MainUtil.timeToSec(value) * 1000) + System.currentTimeMillis();
|
||||
return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis();
|
||||
}
|
||||
}
|
||||
@Override
|
||||
@ -1999,7 +1999,7 @@ public class PS {
|
||||
|
||||
final int keep = config.getInt("clear.keep-if-modified");
|
||||
final int ignore = config.getInt("clear.ignore-if-modified");
|
||||
if ((keep > 0) || (ignore > 0)) {
|
||||
if (keep > 0 || ignore > 0) {
|
||||
options.put("clear.auto.threshold", 1);
|
||||
options.put("clear.auto.enabled", false);
|
||||
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||
|
@ -80,8 +80,8 @@ public class Area extends SubCommand {
|
||||
Location pos2 = plr.getMeta("area_pos1");
|
||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);
|
||||
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + (area.SIZE / 2)) / area.SIZE);
|
||||
int numx = Math.max(1, (dx + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
int numz = Math.max(1, (dz + 1 + area.ROAD_WIDTH + area.SIZE / 2) / area.SIZE);
|
||||
final int ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
||||
final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
||||
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
||||
@ -318,7 +318,7 @@ public class Area extends SubCommand {
|
||||
region = area.getRegion().toString();
|
||||
} else {
|
||||
name = area.worldname;
|
||||
percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE);
|
||||
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
|
||||
region = "N/A";
|
||||
}
|
||||
String value = "&r$1NAME: " + name
|
||||
|
@ -52,7 +52,7 @@ public class Auto extends SubCommand {
|
||||
return new PlotId(id.x + 1, id.y);
|
||||
}
|
||||
} else {
|
||||
if (id.x == id.y && (id.x > 0)) {
|
||||
if (id.x == id.y && id.x > 0) {
|
||||
return new PlotId(id.x, id.y + step);
|
||||
}
|
||||
if (id.x == absX) {
|
||||
@ -81,7 +81,7 @@ public class Auto extends SubCommand {
|
||||
final String[] split = args[0].split(",|;");
|
||||
size_x = Integer.parseInt(split[0]);
|
||||
size_z = Integer.parseInt(split[1]);
|
||||
if ((size_x < 1) || (size_z < 1)) {
|
||||
if (size_x < 1 || size_z < 1) {
|
||||
MainUtil.sendMessage(plr, "&cError: size<=0");
|
||||
}
|
||||
if (args.length > 1) {
|
||||
@ -101,15 +101,15 @@ public class Auto extends SubCommand {
|
||||
// return false;
|
||||
}
|
||||
}
|
||||
if ((size_x * size_z) > Settings.MAX_AUTO_SIZE) {
|
||||
if (size_x * size_z > Settings.MAX_AUTO_SIZE) {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||
return false;
|
||||
}
|
||||
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
||||
final int diff = currentPlots - plr.getAllowedPlots();
|
||||
if ((diff + (size_x * size_z)) > 0) {
|
||||
if (diff + size_x * size_z > 0) {
|
||||
if (diff < 0) {
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, (-diff) + "");
|
||||
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, -diff + "");
|
||||
return false;
|
||||
} else if (plr.hasPersistentMeta("grantedPlots")) {
|
||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||
@ -117,11 +117,10 @@ public class Auto extends SubCommand {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||
} else {
|
||||
int left = grantedPlots - diff - (size_x * size_z);
|
||||
int left = grantedPlots - diff - size_x * size_z;
|
||||
if (left == 0) {
|
||||
plr.removePersistentMeta("grantedPlots");
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left));
|
||||
}
|
||||
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left));
|
||||
@ -131,7 +130,7 @@ public class Auto extends SubCommand {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ((EconHandler.manager != null) && plotarea.USE_ECONOMY) {
|
||||
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
||||
double cost = plotarea.PRICES.get("claim");
|
||||
cost = (size_x * size_z) * cost;
|
||||
if (cost > 0d) {
|
||||
@ -159,7 +158,7 @@ public class Auto extends SubCommand {
|
||||
final PlotId top = plotarea.getMax();
|
||||
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||
PlotId id = new PlotId(0, 0);
|
||||
final int width = Math.max((top.x - bot.x) + 1, (top.y - bot.y) + 1);
|
||||
final int width = Math.max(top.x - bot.x + 1, top.y - bot.y + 1);
|
||||
final int max = width * width;
|
||||
//
|
||||
for (int i = 0; i <= max; i++) {
|
||||
@ -179,17 +178,17 @@ public class Auto extends SubCommand {
|
||||
boolean br = false;
|
||||
while (true) {
|
||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
||||
final PlotId end = new PlotId((start.x + size_x) - 1, (start.y + size_z) - 1);
|
||||
final PlotId end = new PlotId(start.x + size_x - 1, start.y + size_z - 1);
|
||||
plotarea.setMeta("lastPlot", start);
|
||||
if (plotarea.canClaim(plr, start, end)) {
|
||||
for (int i = start.x; i <= end.x; i++) {
|
||||
for (int j = start.y; j <= end.y; j++) {
|
||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, j));
|
||||
final boolean teleport = ((i == end.x) && (j == end.y));
|
||||
final boolean teleport = i == end.x && j == end.y;
|
||||
plot.claim(plr, teleport, null);
|
||||
}
|
||||
}
|
||||
if ((size_x != 1) || (size_z != 1)) {
|
||||
if (size_x != 1 || size_z != 1) {
|
||||
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
||||
return false;
|
||||
}
|
||||
|
@ -102,7 +102,7 @@ public class Cluster extends SubCommand {
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[2]);
|
||||
PlotId pos2 = PlotId.fromString(args[3]);
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
@ -112,7 +112,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||
return false;
|
||||
}
|
||||
if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) {
|
||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
||||
PlotId tmp = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
|
||||
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
|
||||
pos1 = tmp;
|
||||
@ -145,7 +145,7 @@ public class Cluster extends SubCommand {
|
||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
||||
}
|
||||
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
if ((current + cluster.getArea()) > allowed) {
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
@ -172,7 +172,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
||||
return false;
|
||||
}
|
||||
if ((args.length != 1) && (args.length != 2)) {
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
||||
return false;
|
||||
}
|
||||
@ -218,11 +218,11 @@ public class Cluster extends SubCommand {
|
||||
// check pos1 / pos2
|
||||
PlotId pos1 = PlotId.fromString(args[1]);
|
||||
PlotId pos2 = PlotId.fromString(args[2]);
|
||||
if ((pos1 == null) || (pos2 == null)) {
|
||||
if (pos1 == null || pos2 == null) {
|
||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||
return false;
|
||||
}
|
||||
if ((pos2.x < pos1.x) || (pos2.y < pos1.y)) {
|
||||
if (pos2.x < pos1.x || pos2.y < pos1.y) {
|
||||
pos1 = new PlotId(Math.min(pos1.x, pos2.x), Math.min(pos1.y, pos2.y));
|
||||
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
|
||||
}
|
||||
@ -251,7 +251,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
final HashSet<Plot> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||
final HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
||||
final HashSet<Plot> removed = ((HashSet<Plot>) existing.clone());
|
||||
final HashSet<Plot> removed = (HashSet<Plot>) existing.clone();
|
||||
removed.removeAll(newplots);
|
||||
// Check expand / shrink
|
||||
if (!removed.isEmpty()) {
|
||||
@ -274,9 +274,9 @@ public class Cluster extends SubCommand {
|
||||
} else {
|
||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
||||
}
|
||||
current -= cluster.getArea() + (((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y));
|
||||
current -= cluster.getArea() + (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
||||
if ((current + cluster.getArea()) > allowed) {
|
||||
if (current + cluster.getArea() > allowed) {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||
return false;
|
||||
}
|
||||
@ -379,7 +379,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
final PlotCluster current = plot.getCluster();
|
||||
if ((current != null) && current.equals(cluster)) {
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plot.unclaim();
|
||||
}
|
||||
}
|
||||
@ -392,7 +392,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
||||
return false;
|
||||
}
|
||||
if ((args.length != 1) && (args.length != 2)) {
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
||||
return false;
|
||||
}
|
||||
@ -432,7 +432,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||
final PlotCluster current = plot.getCluster();
|
||||
if ((current != null) && current.equals(cluster)) {
|
||||
if (current != null && current.equals(cluster)) {
|
||||
plr.getLocation().getWorld();
|
||||
plot.unclaim();
|
||||
}
|
||||
@ -515,7 +515,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
||||
return false;
|
||||
}
|
||||
if ((args.length != 1) && (args.length != 2)) {
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
|
||||
return false;
|
||||
}
|
||||
@ -543,7 +543,7 @@ public class Cluster extends SubCommand {
|
||||
owner = "unknown";
|
||||
}
|
||||
final String name = cluster.getName();
|
||||
final String size = ((cluster.getP2().x - cluster.getP1().x) + 1) + "x" + ((cluster.getP2().y - cluster.getP1().y) + 1);
|
||||
final String size = (cluster.getP2().x - cluster.getP1().x + 1) + "x" + (cluster.getP2().y - cluster.getP1().y + 1);
|
||||
final String rights = cluster.isAdded(plr.getUUID()) + "";
|
||||
String message = C.CLUSTER_INFO.s();
|
||||
message = message.replaceAll("%id%", id);
|
||||
@ -561,7 +561,7 @@ public class Cluster extends SubCommand {
|
||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||
return false;
|
||||
}
|
||||
if ((args.length != 1) && (args.length != 2)) {
|
||||
if (args.length != 1 && args.length != 2) {
|
||||
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
|
||||
return false;
|
||||
}
|
||||
|
@ -126,13 +126,13 @@ public class Configuration {
|
||||
@Override
|
||||
public boolean validateValue(final String string) {
|
||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
|
||||
return !((value == null) || (value.match > 1));
|
||||
return !(value == null || value.match > 1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlotBlock parseString(final String string) {
|
||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
|
||||
if ((value == null) || (value.match > 1)) {
|
||||
if (value == null || value.match > 1) {
|
||||
return null;
|
||||
}
|
||||
return value.best;
|
||||
@ -149,7 +149,7 @@ public class Configuration {
|
||||
block = split[1];
|
||||
}
|
||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(block);
|
||||
if ((value == null) || (value.match > 1)) {
|
||||
if (value == null || value.match > 1) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -183,7 +183,7 @@ public class Configuration {
|
||||
}
|
||||
}
|
||||
final StringComparison<PlotBlock>.ComparisonResult result = WorldUtil.IMP.getClosestBlock(blocks[i]);
|
||||
if ((result != null) && (result.match < 2)) {
|
||||
if (result != null && result.match < 2) {
|
||||
values[i] = result.best;
|
||||
}
|
||||
} catch (NumberFormatException e) {
|
||||
@ -192,7 +192,7 @@ public class Configuration {
|
||||
final int gcd = gcd(counts);
|
||||
for (int i = 0; i < counts.length; i++) {
|
||||
final int num = counts[i];
|
||||
for (int j = 0; j < (num / gcd); j++) {
|
||||
for (int j = 0; j < num / gcd; j++) {
|
||||
parsedvalues.add(values[i]);
|
||||
}
|
||||
}
|
||||
|
@ -136,7 +136,7 @@ public class SQLManager implements AbstractDB {
|
||||
break;
|
||||
}
|
||||
// schedule reconnect
|
||||
if (MYSQL && ((System.currentTimeMillis() - last) > 550000)) {
|
||||
if (MYSQL && System.currentTimeMillis() - last > 550000) {
|
||||
last = System.currentTimeMillis();
|
||||
try {
|
||||
close();
|
||||
@ -573,14 +573,14 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
||||
stmt.setInt((i * 2) + 1, pair.id);
|
||||
stmt.setString((i * 2) + 2, pair.uuid.toString());
|
||||
stmt.setInt(i * 2 + 1, pair.id);
|
||||
stmt.setString(i * 2 + 2, pair.uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
||||
stmt.setInt((i * 2) + 1, pair.id);
|
||||
stmt.setString((i * 2) + 2, pair.uuid.toString());
|
||||
stmt.setInt(i * 2 + 1, pair.id);
|
||||
stmt.setString(i * 2 + 2, pair.uuid.toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -617,29 +617,29 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||
stmt.setInt((i * 5) + 1, plot.getId().x);
|
||||
stmt.setInt((i * 5) + 2, plot.getId().y);
|
||||
stmt.setInt(i * 5 + 1, plot.getId().x);
|
||||
stmt.setInt(i * 5 + 2, plot.getId().y);
|
||||
try {
|
||||
stmt.setString((i * 5) + 3, plot.owner.toString());
|
||||
stmt.setString(i * 5 + 3, plot.owner.toString());
|
||||
} catch (SQLException e) {
|
||||
stmt.setString((i * 5) + 3, everyone.toString());
|
||||
stmt.setString(i * 5 + 3, everyone.toString());
|
||||
}
|
||||
stmt.setString((i * 5) + 4, plot.getArea().toString());
|
||||
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
|
||||
stmt.setString(i * 5 + 4, plot.getArea().toString());
|
||||
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||
stmt.setNull((i * 6) + 1, 4);
|
||||
stmt.setInt((i * 6) + 2, plot.getId().x);
|
||||
stmt.setInt((i * 6) + 3, plot.getId().y);
|
||||
stmt.setNull(i * 6 + 1, 4);
|
||||
stmt.setInt(i * 6 + 2, plot.getId().x);
|
||||
stmt.setInt(i * 6 + 3, plot.getId().y);
|
||||
try {
|
||||
stmt.setString((i * 6) + 4, plot.owner.toString());
|
||||
stmt.setString(i * 6 + 4, plot.owner.toString());
|
||||
} catch (SQLException e1) {
|
||||
stmt.setString((i * 6) + 4, everyone.toString());
|
||||
stmt.setString(i * 6 + 4, everyone.toString());
|
||||
}
|
||||
stmt.setString((i * 6) + 5, plot.getArea().toString());
|
||||
stmt.setTimestamp((i * 6) + 6, new Timestamp(plot.getTimestamp()));
|
||||
stmt.setString(i * 6 + 5, plot.getArea().toString());
|
||||
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -685,7 +685,7 @@ public class SQLManager implements AbstractDB {
|
||||
statement = mod.getCreateMySQL(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
|
||||
if (subList.size() != last || count % 5000 == 0 && count > 0) {
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.close();
|
||||
statement = mod.getCreateMySQL(subList.size());
|
||||
@ -728,7 +728,7 @@ public class SQLManager implements AbstractDB {
|
||||
statement = mod.getCreateSQLite(subList.size());
|
||||
preparedStmt = connection.prepareStatement(statement);
|
||||
}
|
||||
if ((subList.size() != last) || (((count % 5000) == 0) && (count > 0))) {
|
||||
if (subList.size() != last || count % 5000 == 0 && count > 0) {
|
||||
preparedStmt.executeBatch();
|
||||
preparedStmt.clearParameters();
|
||||
statement = mod.getCreateSQLite(subList.size());
|
||||
@ -799,16 +799,16 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
stmt.setNull((i * 10) + 5, 4); // time
|
||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
||||
stmt.setInt(i * 10 + 1, pair.id); // id
|
||||
stmt.setNull(i * 10 + 2, 4); // biome
|
||||
stmt.setNull(i * 10 + 3, 4); // rain
|
||||
stmt.setNull(i * 10 + 4, 4); // custom_time
|
||||
stmt.setNull(i * 10 + 5, 4); // time
|
||||
stmt.setNull(i * 10 + 6, 4); // deny_entry
|
||||
if (pair.settings.getAlias().isEmpty()) {
|
||||
stmt.setNull((i * 10) + 7, 4);
|
||||
stmt.setNull(i * 10 + 7, 4);
|
||||
} else {
|
||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
||||
stmt.setString(i * 10 + 7, pair.settings.getAlias());
|
||||
}
|
||||
final StringBuilder flag_string = new StringBuilder();
|
||||
int k = 0;
|
||||
@ -819,10 +819,10 @@ public class SQLManager implements AbstractDB {
|
||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||
k++;
|
||||
}
|
||||
stmt.setString((i * 10) + 8, flag_string.toString());
|
||||
stmt.setString(i * 10 + 8, flag_string.toString());
|
||||
final boolean[] merged = pair.settings.getMerged();
|
||||
int hash = MainUtil.hash(merged);
|
||||
stmt.setInt((i * 10) + 9, hash);
|
||||
stmt.setInt(i * 10 + 9, hash);
|
||||
final BlockLoc loc = pair.settings.getPosition();
|
||||
String position;
|
||||
if (loc.y == 0) {
|
||||
@ -830,21 +830,21 @@ public class SQLManager implements AbstractDB {
|
||||
} else {
|
||||
position = loc.x + "," + loc.y + "," + loc.z;
|
||||
}
|
||||
stmt.setString((i * 10) + 10, position);
|
||||
stmt.setString(i * 10 + 10, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
||||
stmt.setNull((i * 10) + 2, 4); // biome
|
||||
stmt.setNull((i * 10) + 3, 4); // rain
|
||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
||||
stmt.setNull((i * 10) + 5, 4); // time
|
||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
||||
if (pair.settings.getAlias().equals("")) {
|
||||
stmt.setNull((i * 10) + 7, 4);
|
||||
stmt.setInt(i * 10 + 1, pair.id); // id
|
||||
stmt.setNull(i * 10 + 2, 4); // biome
|
||||
stmt.setNull(i * 10 + 3, 4); // rain
|
||||
stmt.setNull(i * 10 + 4, 4); // custom_time
|
||||
stmt.setNull(i * 10 + 5, 4); // time
|
||||
stmt.setNull(i * 10 + 6, 4); // deny_entry
|
||||
if (pair.settings.getAlias().isEmpty()) {
|
||||
stmt.setNull(i * 10 + 7, 4);
|
||||
} else {
|
||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
||||
stmt.setString(i * 10 + 7, pair.settings.getAlias());
|
||||
}
|
||||
final StringBuilder flag_string = new StringBuilder();
|
||||
int k = 0;
|
||||
@ -855,13 +855,13 @@ public class SQLManager implements AbstractDB {
|
||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||
k++;
|
||||
}
|
||||
stmt.setString((i * 10) + 8, flag_string.toString());
|
||||
stmt.setString(i * 10 + 8, flag_string.toString());
|
||||
final boolean[] merged = pair.settings.getMerged();
|
||||
int n = 0;
|
||||
for (int j = 0; j < 4; ++j) {
|
||||
n = (n << 1) + (merged[j] ? 1 : 0);
|
||||
}
|
||||
stmt.setInt((i * 10) + 9, n);
|
||||
stmt.setInt(i * 10 + 9, n);
|
||||
final BlockLoc loc = pair.settings.getPosition();
|
||||
String position;
|
||||
if (loc.y == 0) {
|
||||
@ -869,7 +869,7 @@ public class SQLManager implements AbstractDB {
|
||||
} else {
|
||||
position = loc.x + "," + loc.y + "," + loc.z;
|
||||
}
|
||||
stmt.setString((i * 10) + 10, position);
|
||||
stmt.setString(i * 10 + 10, position);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -909,21 +909,21 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
||||
stmt.setInt((i) + 1, id);
|
||||
stmt.setInt(i + 1, id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
||||
stmt.setInt((i * 10) + 1, id);
|
||||
stmt.setNull((i * 10) + 2, 4);
|
||||
stmt.setNull((i * 10) + 3, 4);
|
||||
stmt.setNull((i * 10) + 4, 4);
|
||||
stmt.setNull((i * 10) + 5, 4);
|
||||
stmt.setNull((i * 10) + 6, 4);
|
||||
stmt.setNull((i * 10) + 7, 4);
|
||||
stmt.setNull((i * 10) + 8, 4);
|
||||
stmt.setNull((i * 10) + 9, 4);
|
||||
stmt.setString((i * 10) + 10, "DEFAULT");
|
||||
stmt.setInt(i * 10 + 1, id);
|
||||
stmt.setNull(i * 10 + 2, 4);
|
||||
stmt.setNull(i * 10 + 3, 4);
|
||||
stmt.setNull(i * 10 + 4, 4);
|
||||
stmt.setNull(i * 10 + 5, 4);
|
||||
stmt.setNull(i * 10 + 6, 4);
|
||||
stmt.setNull(i * 10 + 7, 4);
|
||||
stmt.setNull(i * 10 + 8, 4);
|
||||
stmt.setNull(i * 10 + 9, 4);
|
||||
stmt.setString(i * 10 + 10, "DEFAULT");
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1417,7 +1417,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
stmt.close();
|
||||
r.close();
|
||||
if ((c_id == Integer.MAX_VALUE) || (c_id == 0)) {
|
||||
if (c_id == Integer.MAX_VALUE || c_id == 0) {
|
||||
if (cluster.temp > 0) {
|
||||
return cluster.temp;
|
||||
}
|
||||
@ -1453,7 +1453,7 @@ public class SQLManager implements AbstractDB {
|
||||
}
|
||||
r.close();
|
||||
stmt.close();
|
||||
if ((id == Integer.MAX_VALUE) || (id == 0)) {
|
||||
if (id == Integer.MAX_VALUE || id == 0) {
|
||||
if (plot.temp > 0) {
|
||||
return plot.temp;
|
||||
}
|
||||
@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB {
|
||||
|
||||
@Override
|
||||
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||
stmt.setInt((i) + 1, obj);
|
||||
stmt.setInt(i + 1, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||
stmt.setInt((i) + 1, obj);
|
||||
stmt.setInt(i + 1, obj);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -1801,7 +1801,7 @@ public class SQLManager implements AbstractDB {
|
||||
final Integer m = r.getInt("merged");
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = (m & (1 << i)) != 0;
|
||||
merged[3 - i] = (m & 1 << i) != 0;
|
||||
}
|
||||
plot.getSettings().setMerged(merged);
|
||||
String[] flags_string;
|
||||
@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB {
|
||||
final Integer m = r.getInt("merged");
|
||||
final boolean[] merged = new boolean[4];
|
||||
for (int i = 0; i < 4; i++) {
|
||||
merged[3 - i] = ((m) & (1 << i)) != 0;
|
||||
merged[3 - i] = (m & 1 << i) != 0;
|
||||
}
|
||||
cluster.settings.setMerged(merged);
|
||||
String[] flags_string;
|
||||
|
@ -1,7 +1,5 @@
|
||||
package com.intellectualcrafters.plot.generator;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
@ -12,6 +10,8 @@ import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* A plot manager with square plots which tessellate on a square grid with the following sections: ROAD, WALL, BORDER (wall), PLOT, FLOOR (plot)
|
||||
*/
|
||||
@ -57,9 +57,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
@Override
|
||||
public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
||||
final ClassicPlotWorld dpw = ((ClassicPlotWorld) plotworld);
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
setWallFilling(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_FILLING });
|
||||
if ((dpw.WALL_BLOCK.id != 0) || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
|
||||
if (dpw.WALL_BLOCK.id != 0 || !dpw.WALL_BLOCK.equals(dpw.CLAIMED_WALL_BLOCK)) {
|
||||
setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
|
||||
}
|
||||
SetQueue.IMP.addTask(whenDone);
|
||||
@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bottom.getZ();
|
||||
for (int x = bottom.getX(); x <= (top.getX()); x++) {
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -150,7 +150,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
int x = bottom.getX();
|
||||
for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -159,7 +159,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
|
||||
if (!plot.getMerged(2)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bottom.getX(); x <= (top.getX()); x++) {
|
||||
for (int x = bottom.getX(); x <= top.getX(); x++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -167,7 +167,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
int x = top.getX();
|
||||
for (int z = bottom.getZ(); z <= (top.getZ()); z++) {
|
||||
for (int z = bottom.getZ(); z <= top.getZ(); z++) {
|
||||
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -194,7 +194,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final PseudoRandom random = new PseudoRandom();
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < (top.getX()); x++) {
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -202,7 +202,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
int x = bot.getX();
|
||||
for (int z = bot.getZ(); z < (top.getZ()); z++) {
|
||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -210,7 +210,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (!plot.getMerged(2)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
|
||||
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -218,7 +218,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
int x = top.getX();
|
||||
for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
|
||||
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
|
||||
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
@ -239,25 +239,25 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final int y = dpw.WALL_HEIGHT + 1;
|
||||
if (!plot.getMerged(0)) {
|
||||
int z = bot.getZ();
|
||||
for (int x = bot.getX(); x < (top.getX()); x++) {
|
||||
for (int x = bot.getX(); x < top.getX(); x++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(3)) {
|
||||
int x = bot.getX();
|
||||
for (int z = bot.getZ(); z < (top.getZ()); z++) {
|
||||
for (int z = bot.getZ(); z < top.getZ(); z++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(2)) {
|
||||
int z = top.getZ();
|
||||
for (int x = bot.getX(); x < (top.getX() + (plot.getMerged(1) ? 0 : 1)); x++) {
|
||||
for (int x = bot.getX(); x < top.getX() + (plot.getMerged(1) ? 0 : 1); x++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
if (!plot.getMerged(1)) {
|
||||
int x = top.getX();
|
||||
for (int z = bot.getZ(); z < (top.getZ() + (plot.getMerged(2) ? 0 : 1)); z++) {
|
||||
for (int z = bot.getZ(); z < top.getZ() + (plot.getMerged(2) ? 0 : 1); z++) {
|
||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||
}
|
||||
}
|
||||
@ -273,7 +273,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos1.getZ() - 2;
|
||||
final int ez = pos2.getZ() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz + 1), new Location(plotworld.worldname, ex, 255, ez - 1), new PlotBlock((short) 0, (byte) 0));
|
||||
@ -295,7 +295,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
final int sx = pos1.getX() - 2;
|
||||
final int ex = pos2.getX() + 2;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, Math.min(dpw.WALL_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex - 1, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
@ -315,9 +315,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, dpw.ROAD_HEIGHT + 1, sz + 1), new Location(plotworld.worldname, ex - 1, 255, ez - 1), new PlotBlock(
|
||||
(short) 0, (byte) 0));
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx + 1, 0, sz + 1), new Location(plotworld.worldname, ex - 1, 0, ez - 1), new PlotBlock((short) 7, (byte) 0));
|
||||
@ -331,7 +331,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sx = pos2.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = pos1.getZ() - 1;
|
||||
final int ez = pos2.getZ() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
@ -346,7 +346,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final Location pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||
final int sz = pos2.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
final int sx = pos1.getX() - 1;
|
||||
final int ex = pos2.getX() + 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, Math.min(dpw.PLOT_HEIGHT, dpw.ROAD_HEIGHT) + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
@ -360,9 +360,9 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||
final int sx = loc.getX() + 1;
|
||||
final int ex = (sx + dpw.ROAD_WIDTH) - 1;
|
||||
final int ex = sx + dpw.ROAD_WIDTH - 1;
|
||||
final int sz = loc.getZ() + 1;
|
||||
final int ez = (sz + dpw.ROAD_WIDTH) - 1;
|
||||
final int ez = sz + dpw.ROAD_WIDTH - 1;
|
||||
MainUtil.setSimpleCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT + 1, sz), new Location(plotworld.worldname, ex, 255, ez), new PlotBlock((short) 0, (byte) 0));
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, 1, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT - 1, ez), dpw.MAIN_BLOCK);
|
||||
MainUtil.setCuboidAsync(plotworld.worldname, new Location(plotworld.worldname, sx, dpw.ROAD_HEIGHT, sz), new Location(plotworld.worldname, ex, dpw.ROAD_HEIGHT, ez), dpw.TOP_BLOCK);
|
||||
@ -376,7 +376,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
public boolean finishPlotMerge(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
if ((block.id != 0) || !block.equals(unclaim)) {
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
for (final PlotId id : plotIds) {
|
||||
setWall(plotworld, id, new PlotBlock[] { block });
|
||||
}
|
||||
@ -389,7 +389,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
for (final PlotId id : plotIds) {
|
||||
if ((block.id != 0) || !block.equals(unclaim)) {
|
||||
if (block.id != 0 || !block.equals(unclaim)) {
|
||||
setWall(plotworld, id, new PlotBlock[] { block });
|
||||
}
|
||||
}
|
||||
@ -410,7 +410,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
||||
public boolean claimPlot(final PlotArea plotworld, final Plot plot) {
|
||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||
if ((claim.id != 0) || !claim.equals(unclaim)) {
|
||||
if (claim.id != 0 || !claim.equals(unclaim)) {
|
||||
setWall(plotworld, plot.getId(), new PlotBlock[] { claim });
|
||||
}
|
||||
return true;
|
||||
|
@ -5,12 +5,32 @@ import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.flag.Flag;
|
||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||
import com.intellectualcrafters.plot.object.*;
|
||||
import com.intellectualcrafters.plot.util.*;
|
||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.PlotManager;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
import com.intellectualcrafters.plot.util.MathMan;
|
||||
import com.intellectualcrafters.plot.util.SchematicHandler;
|
||||
import com.intellectualcrafters.plot.util.SetQueue;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.ArrayDeque;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
public abstract class HybridUtils {
|
||||
@ -95,8 +115,8 @@ public abstract class HybridUtils {
|
||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||
final int sx = region.x << 5;
|
||||
final int sz = region.z << 5;
|
||||
for (int x = sx; x < (sx + 32); x++) {
|
||||
for (int z = sz; z < (sz + 32); z++) {
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
@ -185,10 +205,10 @@ public abstract class HybridUtils {
|
||||
return;
|
||||
}
|
||||
count.incrementAndGet();
|
||||
if ((count.intValue() % 20) == 0) {
|
||||
PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
|
||||
if (count.intValue() % 20 == 0) {
|
||||
PS.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%");
|
||||
}
|
||||
if ((regions.isEmpty()) && (chunks.isEmpty())) {
|
||||
if (regions.isEmpty() && chunks.isEmpty()) {
|
||||
HybridUtils.UPDATE = false;
|
||||
PS.debug(C.PREFIX.s() + "Finished road conversion");
|
||||
// CANCEL TASK
|
||||
@ -214,7 +234,7 @@ public abstract class HybridUtils {
|
||||
}
|
||||
if (!chunks.isEmpty()) {
|
||||
final long diff = System.currentTimeMillis() + 1;
|
||||
if (((System.currentTimeMillis() - baseTime - last.get()) > 2000) && (last.get() != 0)) {
|
||||
if (System.currentTimeMillis() - baseTime - last.get() > 2000 && last.get() != 0) {
|
||||
last.set(0);
|
||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
@ -230,8 +250,8 @@ public abstract class HybridUtils {
|
||||
TaskManager.runTaskLater(task, 600);
|
||||
return;
|
||||
}
|
||||
if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) {
|
||||
while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) {
|
||||
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
||||
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||
final ChunkLoc chunk = iter.next();
|
||||
iter.remove();
|
||||
@ -253,8 +273,8 @@ public abstract class HybridUtils {
|
||||
PS.debug("&c[ERROR]&7 Could not update '" + area.worldname + "/region/r." + loc.x + "." + loc.z + ".mca' (Corrupt chunk?)");
|
||||
final int sx = loc.x << 5;
|
||||
final int sz = loc.z << 5;
|
||||
for (int x = sx; x < (sx + 32); x++) {
|
||||
for (int z = sz; z < (sz + 32); z++) {
|
||||
for (int x = sx; x < sx + 32; x++) {
|
||||
for (int z = sz; z < sz + 32; z++) {
|
||||
ChunkManager.manager.unloadChunk(area.worldname, new ChunkLoc(x, z), true, true);
|
||||
}
|
||||
}
|
||||
@ -280,7 +300,7 @@ public abstract class HybridUtils {
|
||||
final Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||
final Location top = plot.getTopAbs();
|
||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
||||
final int sx = (bot.getX() - plotworld.ROAD_WIDTH) + 1;
|
||||
final int sx = bot.getX() - plotworld.ROAD_WIDTH + 1;
|
||||
final int sz = bot.getZ() + 1;
|
||||
final int sy = plotworld.ROAD_HEIGHT;
|
||||
final int ex = bot.getX();
|
||||
@ -339,18 +359,18 @@ public abstract class HybridUtils {
|
||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||
x -= plotworld.ROAD_OFFSET_X;
|
||||
z -= plotworld.ROAD_OFFSET_Z;
|
||||
if ((id1 == null) || (id2 == null) || (id1 != id2)) {
|
||||
if (id1 == null || id2 == null || id1 != id2) {
|
||||
final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||
if (result) {
|
||||
if (id1 != null) {
|
||||
final Plot p1 = area.getPlotAbs(id1);
|
||||
if ((p1 != null) && p1.hasOwner() && p1.isMerged()) {
|
||||
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
if ((id2 != null) && !toCheck) {
|
||||
if (id2 != null && !toCheck) {
|
||||
final Plot p2 = area.getPlotAbs(id2);
|
||||
if ((p2 != null) && p2.hasOwner() && p2.isMerged()) {
|
||||
if (p2 != null && p2.hasOwner() && p2.isMerged()) {
|
||||
toCheck = true;
|
||||
}
|
||||
}
|
||||
@ -374,12 +394,11 @@ public abstract class HybridUtils {
|
||||
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
||||
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
||||
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
||||
condition = (!gx || !gz || !lx || !lz);
|
||||
condition = !gx || !gz || !lx || !lz;
|
||||
}
|
||||
if (condition) {
|
||||
final int sy = plotworld.ROAD_HEIGHT;
|
||||
final HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ));
|
||||
for (short y = (short) (plotworld.ROAD_HEIGHT); y <= (plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend); y++) {
|
||||
for (short y = (short) plotworld.ROAD_HEIGHT; y <= plotworld.ROAD_HEIGHT + plotworld.SCHEMATIC_HEIGHT + extend; y++) {
|
||||
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
|
||||
}
|
||||
if (blocks != null) {
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.object;
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.Settings;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class BO3 {
|
||||
@ -59,6 +60,6 @@ public class BO3 {
|
||||
}
|
||||
|
||||
public String getFilename() {
|
||||
return name + (((chunk.x == 0) && (chunk.z == 0)) ? "" : ("_" + chunk.x + "_" + chunk.z)) + ".bo3";
|
||||
return name + (chunk.x == 0 && chunk.z == 0 ? "" : "_" + chunk.x + "_" + chunk.z) + ".bo3";
|
||||
}
|
||||
}
|
||||
|
@ -20,40 +20,6 @@ public class BlockLoc {
|
||||
this(x, y, z, 0f, 0f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = (prime * result) + x;
|
||||
result = (prime * result) + y;
|
||||
result = (prime * result) + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final BlockLoc other = (BlockLoc) obj;
|
||||
return ((x == other.x) && (y == other.y) && (z == other.z));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return "";
|
||||
}
|
||||
return x + "," + y + "," + z + "," + yaw + "," + pitch;
|
||||
|
||||
}
|
||||
|
||||
public static BlockLoc fromString(final String string) {
|
||||
final String[] parts = string.split(",");
|
||||
|
||||
@ -74,4 +40,38 @@ public class BlockLoc {
|
||||
|
||||
return new BlockLoc(x, y, z, yaw, pitch);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
final int prime = 31;
|
||||
int result = 1;
|
||||
result = prime * result + x;
|
||||
result = prime * result + y;
|
||||
result = prime * result + z;
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(final Object obj) {
|
||||
if (this == obj) {
|
||||
return true;
|
||||
}
|
||||
if (obj == null) {
|
||||
return x == 0 && y == 0 && z == 0;
|
||||
}
|
||||
if (getClass() != obj.getClass()) {
|
||||
return false;
|
||||
}
|
||||
final BlockLoc other = (BlockLoc) obj;
|
||||
return x == other.x && y == other.y && z == other.z;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
if (x == 0 && y == 0 && z == 0) {
|
||||
return "";
|
||||
}
|
||||
return x + "," + y + "," + z + "," + yaw + "," + pitch;
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -70,6 +70,7 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
*/
|
||||
@SuppressWarnings("javadoc")
|
||||
public class Plot {
|
||||
|
||||
/**
|
||||
* @deprecated raw access is deprecated
|
||||
*/
|
||||
@ -199,8 +200,9 @@ public class Plot {
|
||||
* @param denied
|
||||
* @param merged
|
||||
*/
|
||||
public Plot(final PlotId id, final UUID owner, final HashSet<UUID> trusted, final HashSet<UUID> members, final HashSet<UUID> denied, final String alias, final BlockLoc position,
|
||||
final Collection<Flag> flags, final PlotArea area, final boolean[] merged, final long timestamp, final int temp) {
|
||||
public Plot(final PlotId id, final UUID owner, final HashSet<UUID> trusted, final HashSet<UUID> members, final HashSet<UUID> denied,
|
||||
final String alias, final BlockLoc position,
|
||||
final Collection<Flag> flags, final PlotArea area, final boolean[] merged, final long timestamp, final int temp) {
|
||||
this.id = id;
|
||||
this.area = area;
|
||||
this.owner = owner;
|
||||
@ -426,7 +428,8 @@ public class Plot {
|
||||
* @return boolean false if the player is allowed to enter
|
||||
*/
|
||||
public boolean isDenied(final UUID uuid) {
|
||||
return (this.denied != null) && ((this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid)) || (!this.isAdded(uuid) && this.denied.contains(uuid)));
|
||||
return this.denied != null && (this.denied.contains(DBFunc.everyone) && !this.isAdded(uuid) ||
|
||||
!this.isAdded(uuid) && this.denied.contains(uuid));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -501,7 +504,7 @@ public class Plot {
|
||||
* @return base Plot
|
||||
*/
|
||||
public Plot getBasePlot(final boolean recalculate) {
|
||||
if ((this.origin != null) && !recalculate) {
|
||||
if (this.origin != null && !recalculate) {
|
||||
if (this.equals(this.origin)) {
|
||||
return this;
|
||||
}
|
||||
@ -514,7 +517,7 @@ public class Plot {
|
||||
this.origin = this;
|
||||
PlotId min = this.id;
|
||||
for (final Plot plot : this.getConnectedPlots()) {
|
||||
if ((plot.id.y < min.y) || (plot.id.y == min.y && plot.id.x < min.x)) {
|
||||
if (plot.id.y < min.y || plot.id.y == min.y && plot.id.x < min.x) {
|
||||
this.origin = plot;
|
||||
min = plot.id;
|
||||
}
|
||||
@ -765,7 +768,7 @@ public class Plot {
|
||||
}
|
||||
|
||||
public boolean clear(final boolean checkRunning, final boolean isDelete, final Runnable whenDone) {
|
||||
if (checkRunning && (this.getRunning() != 0)) {
|
||||
if (checkRunning && this.getRunning() != 0) {
|
||||
return false;
|
||||
}
|
||||
if (!EventUtil.manager.callClear(this)) {
|
||||
@ -814,7 +817,7 @@ public class Plot {
|
||||
return;
|
||||
}
|
||||
final Plot current = queue.poll();
|
||||
if ((Plot.this.area.TERRAIN != 0) || Settings.FAST_CLEAR) {
|
||||
if (Plot.this.area.TERRAIN != 0 || Settings.FAST_CLEAR) {
|
||||
ChunkManager.manager.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false, this);
|
||||
return;
|
||||
}
|
||||
@ -886,7 +889,7 @@ public class Plot {
|
||||
if (createRoad) {
|
||||
manager.startPlotUnlink(this.area, ids);
|
||||
}
|
||||
if ((this.area.TERRAIN != 3) && createRoad) {
|
||||
if (this.area.TERRAIN != 3 && createRoad) {
|
||||
for (final Plot current : plots) {
|
||||
if (current.getMerged(1)) {
|
||||
manager.createRoadEast(current.area, current);
|
||||
@ -902,7 +905,7 @@ public class Plot {
|
||||
}
|
||||
}
|
||||
for (final Plot current : plots) {
|
||||
final boolean[] merged = new boolean[] { false, false, false, false };
|
||||
final boolean[] merged = new boolean[]{false, false, false, false};
|
||||
current.setMerged(merged);
|
||||
if (createSign) {
|
||||
current.setSign(MainUtil.getName(current.owner));
|
||||
@ -932,11 +935,11 @@ public class Plot {
|
||||
if (this.area.ALLOW_SIGNS) {
|
||||
final Location loc = manager.getSignLoc(this.area, this);
|
||||
final String id = this.id.x + ";" + this.id.y;
|
||||
final String[] lines = new String[] {
|
||||
C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
|
||||
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name) };
|
||||
final String[] lines = new String[]{
|
||||
C.OWNER_SIGN_LINE_1.formatted().replaceAll("%id%", id),
|
||||
C.OWNER_SIGN_LINE_2.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_3.formatted().replaceAll("%id%", id).replaceAll("%plr%", name),
|
||||
C.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll("%plr%", name)};
|
||||
WorldUtil.IMP.setSign(this.area.worldname, loc.getX(), loc.getY(), loc.getZ(), lines);
|
||||
}
|
||||
}
|
||||
@ -1111,7 +1114,7 @@ public class Plot {
|
||||
*/
|
||||
public Location getHome() {
|
||||
final BlockLoc home = this.getPosition();
|
||||
if ((home == null) || ((home.x == 0) && (home.z == 0))) {
|
||||
if (home == null || home.x == 0 && home.z == 0) {
|
||||
return this.getDefaultHome();
|
||||
} else {
|
||||
final Location bot = this.getBottomAbs();
|
||||
@ -1147,11 +1150,11 @@ public class Plot {
|
||||
if (this.area.DEFAULT_HOME != null) {
|
||||
final int x;
|
||||
final int z;
|
||||
if ((this.area.DEFAULT_HOME.x == Integer.MAX_VALUE) && (this.area.DEFAULT_HOME.z == Integer.MAX_VALUE)) {
|
||||
if (this.area.DEFAULT_HOME.x == Integer.MAX_VALUE && this.area.DEFAULT_HOME.z == Integer.MAX_VALUE) {
|
||||
// center
|
||||
final RegionWrapper largest = plot.getLargestRegion();
|
||||
x = ((largest.maxX - largest.minX) / 2) + largest.minX;
|
||||
z = ((largest.maxZ - largest.minZ) / 2) + largest.minZ;
|
||||
x = (largest.maxX - largest.minX) / 2 + largest.minX;
|
||||
z = (largest.maxZ - largest.minZ) / 2 + largest.minZ;
|
||||
} else {
|
||||
// specific
|
||||
final Location bot = plot.getBottomAbs();
|
||||
@ -1163,7 +1166,7 @@ public class Plot {
|
||||
}
|
||||
// Side
|
||||
final RegionWrapper largest = plot.getLargestRegion();
|
||||
final int x = ((largest.maxX - largest.minX) / 2) + largest.minX;
|
||||
final int x = (largest.maxX - largest.minX) / 2 + largest.minX;
|
||||
final int z = largest.minZ - 1;
|
||||
final PlotManager manager = plot.getManager();
|
||||
final int y = Math.max(WorldUtil.IMP.getHighestBlock(plot.area.worldname, x, z), manager.getSignLoc(plot.area, plot).getY());
|
||||
@ -1208,7 +1211,7 @@ public class Plot {
|
||||
public void clearRatings() {
|
||||
final Plot base = this.getBasePlot(false);
|
||||
final PlotSettings baseSettings = base.getSettings();
|
||||
if ((baseSettings.ratings != null) && !baseSettings.getRatings().isEmpty()) {
|
||||
if (baseSettings.ratings != null && !baseSettings.getRatings().isEmpty()) {
|
||||
DBFunc.deleteRatings(base);
|
||||
baseSettings.ratings = null;
|
||||
}
|
||||
@ -1246,8 +1249,8 @@ public class Plot {
|
||||
public void run() {
|
||||
final HashSet<ChunkLoc> chunks = new HashSet<>();
|
||||
for (final RegionWrapper region : Plot.this.getRegions()) {
|
||||
for (int x = region.minX >> 4; x <= (region.maxX >> 4); x++) {
|
||||
for (int z = region.minZ >> 4; z <= (region.maxZ >> 4); z++) {
|
||||
for (int x = region.minX >> 4; x <= region.maxX >> 4; x++) {
|
||||
for (int z = region.minZ >> 4; z <= region.maxZ >> 4; z++) {
|
||||
chunks.add(new ChunkLoc(x, z));
|
||||
}
|
||||
}
|
||||
@ -1283,7 +1286,8 @@ public class Plot {
|
||||
/**
|
||||
* Register a plot and create it in the database<br>
|
||||
* - The plot will not be created if the owner is null<br>
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation.
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot
|
||||
* creation.
|
||||
* @return true if plot was created successfully
|
||||
*/
|
||||
public boolean create() {
|
||||
@ -1332,7 +1336,8 @@ public class Plot {
|
||||
/**
|
||||
* Register a plot and create it in the database<br>
|
||||
* - The plot will not be created if the owner is null<br>
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot creation.
|
||||
* - Any setting from before plot creation will not be saved until the server is stopped properly. i.e. Set any values/options after plot
|
||||
* creation.
|
||||
* @return true if plot was created successfully
|
||||
*/
|
||||
public boolean create(final UUID uuid, final boolean notify) {
|
||||
@ -1377,10 +1382,7 @@ public class Plot {
|
||||
*/
|
||||
public boolean setComponent(final String component, final String blocks) {
|
||||
final PlotBlock[] parsed = Configuration.BLOCKLIST.parseString(blocks);
|
||||
if ((parsed == null) || (parsed.length == 0)) {
|
||||
return false;
|
||||
}
|
||||
return this.setComponent(component, parsed);
|
||||
return !(parsed == null || parsed.length == 0) && this.setComponent(component, parsed);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1415,13 +1417,13 @@ public class Plot {
|
||||
*/
|
||||
public boolean swapData(final Plot p2, final Runnable whenDone) {
|
||||
if (this.owner == null) {
|
||||
if ((p2 != null) && p2.hasOwner()) {
|
||||
if (p2 != null && p2.hasOwner()) {
|
||||
p2.moveData(this, whenDone);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
if ((p2 == null) || (p2.owner == null)) {
|
||||
if (p2 == null || p2.owner == null) {
|
||||
this.moveData(p2, whenDone);
|
||||
return true;
|
||||
}
|
||||
@ -1521,7 +1523,7 @@ public class Plot {
|
||||
@Deprecated
|
||||
public Location[] getCorners() {
|
||||
if (!this.isMerged()) {
|
||||
return new Location[] { this.getBottomAbs(), this.getTopAbs() };
|
||||
return new Location[]{this.getBottomAbs(), this.getTopAbs()};
|
||||
}
|
||||
return MainUtil.getCorners(this.area.worldname, this.getRegions());
|
||||
}
|
||||
@ -1531,7 +1533,7 @@ public class Plot {
|
||||
* - Used when a plot is merged<br>
|
||||
*/
|
||||
public void removeRoadEast() {
|
||||
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
||||
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
|
||||
if (this.area.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
@ -1556,7 +1558,7 @@ public class Plot {
|
||||
@Deprecated
|
||||
public PlotId[] getCornerIds() {
|
||||
if (!this.isMerged()) {
|
||||
return new PlotId[] { this.getId(), this.getId() };
|
||||
return new PlotId[]{this.getId(), this.getId()};
|
||||
}
|
||||
final PlotId min = new PlotId(this.getId().x, this.getId().y);
|
||||
final PlotId max = new PlotId(this.getId().x, this.getId().y);
|
||||
@ -1572,7 +1574,7 @@ public class Plot {
|
||||
max.y = current.getId().y;
|
||||
}
|
||||
}
|
||||
return new PlotId[] { min, max };
|
||||
return new PlotId[]{min, max};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1625,7 +1627,7 @@ public class Plot {
|
||||
*/
|
||||
@Override
|
||||
public String toString() {
|
||||
if ((this.settings != null) && (this.settings.getAlias().length() > 1)) {
|
||||
if (this.settings != null && this.settings.getAlias().length() > 1) {
|
||||
return this.settings.getAlias();
|
||||
}
|
||||
return this.area + ";" + this.id.x + ";" + this.id.y;
|
||||
@ -1657,6 +1659,7 @@ public class Plot {
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove a helper (use DBFunc as well)<br>
|
||||
* Using the * uuid will remove all users
|
||||
@ -1732,7 +1735,8 @@ public class Plot {
|
||||
@Override
|
||||
public void run() {
|
||||
final String name = Plot.this.id + "," + Plot.this.area + "," + MainUtil.getName(Plot.this.owner);
|
||||
final boolean result = SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
||||
final boolean result =
|
||||
SchematicHandler.manager.save(value, Settings.SCHEMATIC_SAVE_PATH + File.separator + name + ".schematic");
|
||||
if (whenDone != null) {
|
||||
whenDone.value = result;
|
||||
TaskManager.runTask(whenDone);
|
||||
@ -1806,7 +1810,7 @@ public class Plot {
|
||||
return false;
|
||||
}
|
||||
final Plot other = (Plot) obj;
|
||||
return (this.hashCode() == other.hashCode()) && this.id.equals(other.id) && (this.area == other.area);
|
||||
return this.hashCode() == other.hashCode() && this.id.equals(other.id) && this.area == other.area;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1889,7 +1893,7 @@ public class Plot {
|
||||
if (value) {
|
||||
final Plot other = this.getRelative(direction).getBasePlot(false);
|
||||
if (!other.equals(this.getBasePlot(false))) {
|
||||
final Plot base = (other.id.y < this.id.y) || (other.id.y == this.id.y && (other.id.x < this.id.x)) ? other : this.origin;
|
||||
final Plot base = other.id.y < this.id.y || other.id.y == this.id.y && other.id.x < this.id.x ? other : this.origin;
|
||||
this.origin.origin = base;
|
||||
other.origin = base;
|
||||
this.origin = base;
|
||||
@ -1986,7 +1990,8 @@ public class Plot {
|
||||
if (lines == null) {
|
||||
return null;
|
||||
}
|
||||
loop: for (int i = 4; i > 0; i--) {
|
||||
loop:
|
||||
for (int i = 4; i > 0; i--) {
|
||||
final String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s();
|
||||
final int index = caption.indexOf("%plr%");
|
||||
if (index == -1) {
|
||||
@ -1994,7 +1999,7 @@ public class Plot {
|
||||
} else if (index < -1) {
|
||||
PS.debug("This should NEVER happen. Seriously, it's impossible.");
|
||||
}
|
||||
String line = lines[i-1];
|
||||
String line = lines[i - 1];
|
||||
if (line.length() <= index) {
|
||||
return null;
|
||||
}
|
||||
@ -2011,7 +2016,7 @@ public class Plot {
|
||||
final BiMap<StringWrapper, UUID> map = UUIDHandler.getUuidMap();
|
||||
for (final Entry<StringWrapper, UUID> entry : map.entrySet()) {
|
||||
final String key = entry.getKey().value;
|
||||
if ((key.length() > name.length()) && key.startsWith(name)) {
|
||||
if (key.length() > name.length() && key.startsWith(name)) {
|
||||
this.owner = entry.getValue();
|
||||
break loop;
|
||||
}
|
||||
@ -2034,7 +2039,7 @@ public class Plot {
|
||||
* - Used when a plot is merged<br>
|
||||
*/
|
||||
public void removeRoadSouth() {
|
||||
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
||||
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
|
||||
if (this.area.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
@ -2075,50 +2080,54 @@ public class Plot {
|
||||
final ArrayDeque<Plot> frontier = new ArrayDeque<>(connected);
|
||||
Plot current;
|
||||
boolean toReturn = false;
|
||||
while (((current = frontier.poll()) != null) && (max >= 0)) {
|
||||
while ((current = frontier.poll()) != null && max >= 0) {
|
||||
if (visited.contains(current)) {
|
||||
continue;
|
||||
}
|
||||
visited.add(current);
|
||||
Set<Plot> plots;
|
||||
if ((dir == -1 || (dir == 0)) && !current.getMerged(0)) {
|
||||
if ((dir == -1 || dir == 0) && !current.getMerged(0)) {
|
||||
final Plot other = current.getRelative(0);
|
||||
if ((other != null)
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false)) || (((plots = other.getConnectedPlots()).size() <= max) && frontier.addAll(plots) && ((max -= plots.size()) != -1)))) {
|
||||
if (other != null
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
if ((max >= 0) && ((dir == -1) || (dir == 1)) && !current.getMerged(1)) {
|
||||
if (max >= 0 && (dir == -1 || dir == 1) && !current.getMerged(1)) {
|
||||
final Plot other = current.getRelative(1);
|
||||
if ((other != null)
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false)) || (((plots = other.getConnectedPlots()).size() <= max) && frontier.addAll(plots) && ((max -= plots.size()) != -1)))) {
|
||||
if (other != null
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) &&
|
||||
|
||||
(max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
if ((max >= 0) && ((dir == -1) || (dir == 2)) && !current.getMerged(2)) {
|
||||
if (max >= 0 && (dir == -1 || dir == 2) && !current.getMerged(2)) {
|
||||
final Plot other = current.getRelative(2);
|
||||
if ((other != null)
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false)) || (((plots = other.getConnectedPlots()).size() <= max) && frontier.addAll(plots) && ((max -= plots.size()) != -1)))) {
|
||||
if (other != null && other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
toReturn = true;
|
||||
}
|
||||
}
|
||||
if ((max >= 0) && ((dir == -1) || (dir == 3)) && !current.getMerged(3)) {
|
||||
if (max >= 0 && (dir == -1 || dir == 3) && !current.getMerged(3)) {
|
||||
final Plot other = current.getRelative(3);
|
||||
if ((other != null)
|
||||
&& other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false)) || (((plots = other.getConnectedPlots()).size() <= max) && frontier.addAll(plots) && ((max -= plots.size()) != -1)))) {
|
||||
if (other != null && other.isOwner(uuid)
|
||||
&& (other.getBasePlot(false).equals(current.getBasePlot(false))
|
||||
|| (plots = other.getConnectedPlots()).size() <= max && frontier.addAll(plots) && (max -= plots.size()) != -1)) {
|
||||
current.mergePlot(other, removeRoads);
|
||||
merged.add(current.getId());
|
||||
merged.add(other.getId());
|
||||
@ -2182,7 +2191,7 @@ public class Plot {
|
||||
* Remove the SE road (only effects terrain)
|
||||
*/
|
||||
public void removeRoadSouthEast() {
|
||||
if ((this.area.TYPE != 0) && (this.area.TERRAIN > 1)) {
|
||||
if (this.area.TYPE != 0 && this.area.TERRAIN > 1) {
|
||||
if (this.area.TERRAIN == 3) {
|
||||
return;
|
||||
}
|
||||
@ -2236,7 +2245,7 @@ public class Plot {
|
||||
if (hash == 0) {
|
||||
return new HashSet<>(Collections.singletonList(this));
|
||||
}
|
||||
if ((connected_cache != null) && connected_cache.contains(this)) {
|
||||
if (connected_cache != null && connected_cache.contains(this)) {
|
||||
return connected_cache;
|
||||
}
|
||||
regions_cache = null;
|
||||
@ -2311,7 +2320,7 @@ public class Plot {
|
||||
}
|
||||
Plot current;
|
||||
while ((current = frontier.poll()) != null) {
|
||||
if ((current.owner == null) || (current.settings == null)) {
|
||||
if (current.owner == null || current.settings == null) {
|
||||
// Invalid plot
|
||||
// merged onto unclaimed plot
|
||||
PS.debug("Ignoring invalid merged plot: " + current + " | " + current.owner);
|
||||
@ -2322,28 +2331,28 @@ public class Plot {
|
||||
merged = current.getMerged();
|
||||
if (merged[0]) {
|
||||
tmp = current.area.getPlotAbs(current.id.getRelative(0));
|
||||
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[1]) {
|
||||
tmp = current.area.getPlotAbs(current.id.getRelative(1));
|
||||
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[2]) {
|
||||
tmp = current.area.getPlotAbs(current.id.getRelative(2));
|
||||
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
}
|
||||
if (merged[3]) {
|
||||
tmp = current.area.getPlotAbs(current.id.getRelative(3));
|
||||
if ((tmp != null) && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
if (tmp != null && !queuecache.contains(tmp) && !connected_cache.contains(tmp)) {
|
||||
queuecache.add(tmp);
|
||||
frontier.add(tmp);
|
||||
}
|
||||
@ -2359,7 +2368,7 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public HashSet<RegionWrapper> getRegions() {
|
||||
if ((regions_cache != null) && (connected_cache != null) && connected_cache.contains(this)) {
|
||||
if (regions_cache != null && connected_cache != null && connected_cache.contains(this)) {
|
||||
return regions_cache;
|
||||
}
|
||||
if (!this.isMerged()) {
|
||||
@ -2386,7 +2395,7 @@ public class Plot {
|
||||
boolean tmp = true;
|
||||
for (final PlotId id : ids) {
|
||||
final Plot plot = this.area.getPlotAbs(id);
|
||||
if ((plot == null) || !plot.getMerged(2) || visited.contains(plot.getId())) {
|
||||
if (plot == null || !plot.getMerged(2) || visited.contains(plot.getId())) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -2398,7 +2407,7 @@ public class Plot {
|
||||
tmp = true;
|
||||
for (final PlotId id : ids) {
|
||||
final Plot plot = this.area.getPlotAbs(id);
|
||||
if ((plot == null) || !plot.getMerged(3) || visited.contains(plot.getId())) {
|
||||
if (plot == null || !plot.getMerged(3) || visited.contains(plot.getId())) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -2410,7 +2419,7 @@ public class Plot {
|
||||
tmp = true;
|
||||
for (final PlotId id : ids) {
|
||||
final Plot plot = this.area.getPlotAbs(id);
|
||||
if ((plot == null) || !plot.getMerged(0) || visited.contains(plot.getId())) {
|
||||
if (plot == null || !plot.getMerged(0) || visited.contains(plot.getId())) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -2422,7 +2431,7 @@ public class Plot {
|
||||
tmp = true;
|
||||
for (final PlotId id : ids) {
|
||||
final Plot plot = this.area.getPlotAbs(id);
|
||||
if ((plot == null) || !plot.getMerged(1) || visited.contains(plot.getId())) {
|
||||
if (plot == null || !plot.getMerged(1) || visited.contains(plot.getId())) {
|
||||
tmp = false;
|
||||
}
|
||||
}
|
||||
@ -2479,7 +2488,7 @@ public class Plot {
|
||||
RegionWrapper max = null;
|
||||
int area = 0;
|
||||
for (final RegionWrapper region : regions) {
|
||||
final int current = ((region.maxX - region.minX) + 1) * ((region.maxZ - region.minZ) + 1);
|
||||
final int current = (region.maxX - region.minX + 1) * (region.maxZ - region.minZ + 1);
|
||||
if (current > area) {
|
||||
max = region;
|
||||
area = current;
|
||||
@ -2542,7 +2551,7 @@ public class Plot {
|
||||
} else {
|
||||
location = this.getDefaultHome();
|
||||
}
|
||||
if ((Settings.TELEPORT_DELAY == 0) || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
if (Settings.TELEPORT_DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
player.teleport(location);
|
||||
return true;
|
||||
@ -2797,19 +2806,19 @@ public class Plot {
|
||||
if (plot.isMerged()) {
|
||||
other.setMerged(plot.getMerged());
|
||||
}
|
||||
if ((plot.members != null) && !plot.members.isEmpty()) {
|
||||
if (plot.members != null && !plot.members.isEmpty()) {
|
||||
other.members = plot.members;
|
||||
for (final UUID member : plot.members) {
|
||||
DBFunc.setMember(other, member);
|
||||
}
|
||||
}
|
||||
if ((plot.trusted != null) && !plot.trusted.isEmpty()) {
|
||||
if (plot.trusted != null && !plot.trusted.isEmpty()) {
|
||||
other.trusted = plot.trusted;
|
||||
for (final UUID trusted : plot.trusted) {
|
||||
DBFunc.setTrusted(other, trusted);
|
||||
}
|
||||
}
|
||||
if ((plot.denied != null) && !plot.denied.isEmpty()) {
|
||||
if (plot.denied != null && !plot.denied.isEmpty()) {
|
||||
other.denied = plot.denied;
|
||||
for (final UUID denied : plot.denied) {
|
||||
DBFunc.setDenied(other, denied);
|
||||
|
@ -70,7 +70,7 @@ public class PlotAnalysis {
|
||||
PS.debug("Calibration task already in progress!");
|
||||
return;
|
||||
}
|
||||
if ((threshold <= 0) || (threshold >= 1)) {
|
||||
if (threshold <= 0 || threshold >= 1) {
|
||||
PS.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
|
||||
return;
|
||||
}
|
||||
@ -84,7 +84,7 @@ public class PlotAnalysis {
|
||||
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||
while (iter.hasNext()) {
|
||||
final Plot plot = iter.next();
|
||||
if ((plot.getSettings().ratings == null) || (plot.getSettings().getRatings().isEmpty())) {
|
||||
if (plot.getSettings().ratings == null || plot.getSettings().getRatings().isEmpty()) {
|
||||
iter.remove();
|
||||
} else {
|
||||
plot.addRunning();
|
||||
@ -126,7 +126,7 @@ public class PlotAnalysis {
|
||||
final int i = mi.intValue();
|
||||
final Plot plot = plots.get(i);
|
||||
ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100);
|
||||
PS.debug(" | " + plot + " (rating) " + (ratings[i]));
|
||||
PS.debug(" | " + plot + " (rating) " + ratings[i]);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -170,7 +170,7 @@ public class PlotAnalysis {
|
||||
}
|
||||
}
|
||||
|
||||
PS.debug(" - $1Waiting on plot rating thread: " + ((mi.intValue() * 100) / plots.size()) + "%");
|
||||
PS.debug(" - $1Waiting on plot rating thread: " + mi.intValue() * 100 / plots.size() + "%");
|
||||
try {
|
||||
ratingAnalysis.join();
|
||||
} catch (final InterruptedException e) {
|
||||
@ -212,7 +212,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_changes = square(sd_changes);
|
||||
final int sum_changes = sum(variance_changes);
|
||||
final double factor_changes = getCC(n, sum_changes);
|
||||
PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) ((factor_changes * 1000) / MathMan.getMean(changes));
|
||||
PlotAnalysis.MODIFIERS.changes = factor_changes == 1 ? 0 : (int) (factor_changes * 1000 / MathMan.getMean(changes));
|
||||
PS.debug(" - | changes " + factor_changes);
|
||||
|
||||
final int[] rank_faces = rank(faces);
|
||||
@ -220,7 +220,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_faces = square(sd_faces);
|
||||
final int sum_faces = sum(variance_faces);
|
||||
final double factor_faces = getCC(n, sum_faces);
|
||||
PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) ((factor_faces * 1000) / MathMan.getMean(faces));
|
||||
PlotAnalysis.MODIFIERS.faces = factor_faces == 1 ? 0 : (int) (factor_faces * 1000 / MathMan.getMean(faces));
|
||||
PS.debug(" - | faces " + factor_faces);
|
||||
|
||||
final int[] rank_data = rank(data);
|
||||
@ -228,7 +228,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_data = square(sd_data);
|
||||
final int sum_data = sum(variance_data);
|
||||
final double factor_data = getCC(n, sum_data);
|
||||
PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) ((factor_data * 1000) / MathMan.getMean(data));
|
||||
PlotAnalysis.MODIFIERS.data = factor_data == 1 ? 0 : (int) (factor_data * 1000 / MathMan.getMean(data));
|
||||
PS.debug(" - | data " + factor_data);
|
||||
|
||||
final int[] rank_air = rank(air);
|
||||
@ -236,7 +236,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_air = square(sd_air);
|
||||
final int sum_air = sum(variance_air);
|
||||
final double factor_air = getCC(n, sum_air);
|
||||
PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) ((factor_air * 1000) / MathMan.getMean(air));
|
||||
PlotAnalysis.MODIFIERS.air = factor_air == 1 ? 0 : (int) (factor_air * 1000 / MathMan.getMean(air));
|
||||
PS.debug(" - | air " + factor_air);
|
||||
|
||||
final int[] rank_variety = rank(variety);
|
||||
@ -244,7 +244,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_variety = square(sd_variety);
|
||||
final int sum_variety = sum(variance_variety);
|
||||
final double factor_variety = getCC(n, sum_variety);
|
||||
PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) ((factor_variety * 1000) / MathMan.getMean(variety));
|
||||
PlotAnalysis.MODIFIERS.variety = factor_variety == 1 ? 0 : (int) (factor_variety * 1000 / MathMan.getMean(variety));
|
||||
PS.debug(" - | variety " + factor_variety);
|
||||
|
||||
final int[] rank_changes_sd = rank(changes_sd);
|
||||
@ -252,7 +252,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_changes_sd = square(sd_changes_sd);
|
||||
final int sum_changes_sd = sum(variance_changes_sd);
|
||||
final double factor_changes_sd = getCC(n, sum_changes_sd);
|
||||
PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) ((factor_changes_sd * 1000) / MathMan.getMean(changes_sd));
|
||||
PlotAnalysis.MODIFIERS.changes_sd = factor_changes_sd == 1 ? 0 : (int) (factor_changes_sd * 1000 / MathMan.getMean(changes_sd));
|
||||
PS.debug(" - | changes_sd " + factor_changes_sd);
|
||||
|
||||
final int[] rank_faces_sd = rank(faces_sd);
|
||||
@ -260,7 +260,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_faces_sd = square(sd_faces_sd);
|
||||
final int sum_faces_sd = sum(variance_faces_sd);
|
||||
final double factor_faces_sd = getCC(n, sum_faces_sd);
|
||||
PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) ((factor_faces_sd * 1000) / MathMan.getMean(faces_sd));
|
||||
PlotAnalysis.MODIFIERS.faces_sd = factor_faces_sd == 1 ? 0 : (int) (factor_faces_sd * 1000 / MathMan.getMean(faces_sd));
|
||||
PS.debug(" - | faces_sd " + factor_faces_sd);
|
||||
|
||||
final int[] rank_data_sd = rank(data_sd);
|
||||
@ -268,7 +268,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_data_sd = square(sd_data_sd);
|
||||
final int sum_data_sd = sum(variance_data_sd);
|
||||
final double factor_data_sd = getCC(n, sum_data_sd);
|
||||
PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) ((factor_data_sd * 1000) / MathMan.getMean(data_sd));
|
||||
PlotAnalysis.MODIFIERS.data_sd = factor_data_sd == 1 ? 0 : (int) (factor_data_sd * 1000 / MathMan.getMean(data_sd));
|
||||
PS.debug(" - | data_sd " + factor_data_sd);
|
||||
|
||||
final int[] rank_air_sd = rank(air_sd);
|
||||
@ -276,7 +276,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_air_sd = square(sd_air_sd);
|
||||
final int sum_air_sd = sum(variance_air_sd);
|
||||
final double factor_air_sd = getCC(n, sum_air_sd);
|
||||
PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) ((factor_air_sd * 1000) / MathMan.getMean(air_sd));
|
||||
PlotAnalysis.MODIFIERS.air_sd = factor_air_sd == 1 ? 0 : (int) (factor_air_sd * 1000 / MathMan.getMean(air_sd));
|
||||
PS.debug(" - | air_sd " + factor_air_sd);
|
||||
|
||||
final int[] rank_variety_sd = rank(variety_sd);
|
||||
@ -284,7 +284,7 @@ public class PlotAnalysis {
|
||||
final int[] variance_variety_sd = square(sd_variety_sd);
|
||||
final int sum_variety_sd = sum(variance_variety_sd);
|
||||
final double factor_variety_sd = getCC(n, sum_variety_sd);
|
||||
PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) ((factor_variety_sd * 1000) / MathMan.getMean(variety_sd));
|
||||
PlotAnalysis.MODIFIERS.variety_sd = factor_variety_sd == 1 ? 0 : (int) (factor_variety_sd * 1000 / MathMan.getMean(variety_sd));
|
||||
PS.debug(" - | variety_sd " + factor_variety_sd);
|
||||
|
||||
final int[] complexity = new int[n];
|
||||
@ -303,7 +303,7 @@ public class PlotAnalysis {
|
||||
}
|
||||
}
|
||||
int optimal_complexity = Integer.MAX_VALUE;
|
||||
if ((min > 0) && (max < 102400)) { // If low size, use my fast ranking algorithm
|
||||
if (min > 0 && max < 102400) { // If low size, use my fast ranking algorithm
|
||||
final int[] rank_complexity = rank(complexity, max + 1);
|
||||
for (int i = 0; i < n; i++) {
|
||||
if (rank_complexity[i] == optimal_index) {
|
||||
@ -396,7 +396,7 @@ public class PlotAnalysis {
|
||||
* @return
|
||||
*/
|
||||
public static double getCC(final int n, final int sum) {
|
||||
return 1 - ((6 * (double) sum) / (n * ((n * n) - 1)));
|
||||
return 1 - 6 * (double) sum / (n * (n * n - 1));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -519,7 +519,7 @@ public class PlotAnalysis {
|
||||
for (final Integer i : input) {
|
||||
tmp = i / placement;
|
||||
bucket[tmp % SIZE].add(i);
|
||||
if (maxLength && (tmp > 0)) {
|
||||
if (maxLength && tmp > 0) {
|
||||
maxLength = false;
|
||||
}
|
||||
}
|
||||
@ -542,16 +542,16 @@ public class PlotAnalysis {
|
||||
if (complexity != 0) {
|
||||
return complexity;
|
||||
}
|
||||
complexity = ((changes) * MODIFIERS.changes)
|
||||
+ ((faces) * MODIFIERS.faces)
|
||||
+ ((data) * MODIFIERS.data)
|
||||
+ ((air) * MODIFIERS.air)
|
||||
+ ((variety) * MODIFIERS.variety)
|
||||
+ ((changes_sd) * MODIFIERS.changes_sd)
|
||||
+ ((faces_sd) * MODIFIERS.faces_sd)
|
||||
+ ((data_sd) * MODIFIERS.data_sd)
|
||||
+ ((air_sd) * MODIFIERS.air_sd)
|
||||
+ ((variety_sd) * MODIFIERS.variety_sd);
|
||||
complexity = changes * MODIFIERS.changes
|
||||
+ faces * MODIFIERS.faces
|
||||
+ data * MODIFIERS.data
|
||||
+ air * MODIFIERS.air
|
||||
+ variety * MODIFIERS.variety
|
||||
+ changes_sd * MODIFIERS.changes_sd
|
||||
+ faces_sd * MODIFIERS.faces_sd
|
||||
+ data_sd * MODIFIERS.data_sd
|
||||
+ air_sd * MODIFIERS.air_sd
|
||||
+ variety_sd * MODIFIERS.variety_sd;
|
||||
return complexity;
|
||||
}
|
||||
}
|
||||
|
@ -64,11 +64,12 @@ public class PlotCluster {
|
||||
}
|
||||
|
||||
public boolean isAdded(final UUID uuid) {
|
||||
return (owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone));
|
||||
return owner.equals(uuid) || invited.contains(uuid) || invited.contains(DBFunc.everyone) || helpers.contains(uuid) || helpers
|
||||
.contains(DBFunc.everyone);
|
||||
}
|
||||
|
||||
public boolean hasHelperRights(final UUID uuid) {
|
||||
return (owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone));
|
||||
return owner.equals(uuid) || helpers.contains(uuid) || helpers.contains(DBFunc.everyone);
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
@ -80,7 +81,7 @@ public class PlotCluster {
|
||||
* @return
|
||||
*/
|
||||
public int getArea() {
|
||||
return ((1 + pos2.x) - pos1.x) * ((1 + pos2.y) - pos1.y);
|
||||
return (1 + pos2.x - pos1.x) * (1 + pos2.y - pos1.y);
|
||||
}
|
||||
|
||||
public void setArea(PlotArea plotarea) {
|
||||
@ -159,10 +160,10 @@ public class PlotCluster {
|
||||
}
|
||||
|
||||
public boolean intersects(PlotId pos1, PlotId pos2) {
|
||||
return (pos1.x <= this.pos2.x) && (pos2.x >= this.pos1.x) && (pos1.y <= this.pos2.y) && (pos2.y >= this.pos1.y);
|
||||
return pos1.x <= this.pos2.x && pos2.x >= this.pos1.x && pos1.y <= this.pos2.y && pos2.y >= this.pos1.y;
|
||||
}
|
||||
|
||||
public boolean contains(final PlotId id) {
|
||||
return (pos1.x <= id.x) && (pos1.y <= id.y) && (pos2.x >= id.x) && (pos2.y >= id.y);
|
||||
return pos1.x <= id.x && pos1.y <= id.y && pos2.x >= id.x && pos2.y >= id.y;
|
||||
}
|
||||
}
|
||||
|
@ -27,15 +27,15 @@ public class RegionWrapper {
|
||||
}
|
||||
|
||||
public boolean isIn(final int x, final int y, final int z) {
|
||||
return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ) && (y >= minY) && (y <= maxY));
|
||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ && y >= minY && y <= maxY;
|
||||
}
|
||||
|
||||
public boolean isIn(final int x, final int z) {
|
||||
return ((x >= minX) && (x <= maxX) && (z >= minZ) && (z <= maxZ));
|
||||
return x >= minX && x <= maxX && z >= minZ && z <= maxZ;
|
||||
}
|
||||
|
||||
public boolean intersects(RegionWrapper other) {
|
||||
return (other.minX <= this.maxX) && (other.maxX >= this.minX) && (other.minY <= this.maxY) && (other.maxY >= this.minY);
|
||||
return other.minX <= this.maxX && other.maxX >= this.minX && other.minY <= this.maxY && other.maxY >= this.minY;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -10,7 +10,7 @@ public abstract class AbstractTitle {
|
||||
if (ConsolePlayer.isConsole(player)) {
|
||||
return;
|
||||
}
|
||||
if ((TITLE_CLASS != null) && !player.getAttribute("disabletitles")) {
|
||||
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
|
||||
}
|
||||
}
|
||||
|
@ -13,6 +13,7 @@ import com.intellectualcrafters.plot.object.PlotBlock;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileOutputStream;
|
||||
@ -72,7 +73,7 @@ public class BO3Handler {
|
||||
throw new IllegalArgumentException("Save task cannot be null!");
|
||||
}
|
||||
final PlotArea plotworld = plot.getArea();
|
||||
if (!(plotworld instanceof ClassicPlotWorld) || (plotworld.TYPE != 0)) {
|
||||
if (!(plotworld instanceof ClassicPlotWorld) || plotworld.TYPE != 0) {
|
||||
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
|
||||
return false;
|
||||
}
|
||||
@ -106,10 +107,10 @@ public class BO3Handler {
|
||||
Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
|
||||
Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
|
||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
||||
final int X = ((x + 7) - cx) >> 4;
|
||||
final int X = x + 7 - cx >> 4;
|
||||
final int xx = (x - cx) % 16;
|
||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
||||
final int Z = ((z + 7) - cz) >> 4;
|
||||
final int Z = z + 7 - cz >> 4;
|
||||
final int zz = (z - cz) % 16;
|
||||
final ChunkLoc loc = new ChunkLoc(X, Z);
|
||||
BO3 bo3 = map.get(loc);
|
||||
@ -156,7 +157,7 @@ public class BO3Handler {
|
||||
for (final Entry<ChunkLoc, BO3> entry : map.entrySet()) {
|
||||
final ChunkLoc chunk = entry.getKey();
|
||||
final BO3 bo3 = entry.getValue();
|
||||
if ((chunk.x == 0) && (chunk.z == 0)) {
|
||||
if (chunk.x == 0 && chunk.z == 0) {
|
||||
continue;
|
||||
}
|
||||
int x = chunk.x;
|
||||
@ -171,7 +172,7 @@ public class BO3Handler {
|
||||
parentLoc = null;
|
||||
for (final Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
|
||||
final ChunkLoc other = entry2.getKey();
|
||||
if (((other.x == (chunk.x - 1)) && (other.z == chunk.z)) || ((other.z == (chunk.z - 1)) && (other.x == chunk.x))) {
|
||||
if (other.x == chunk.x - 1 && other.z == chunk.z || other.z == chunk.z - 1 && other.x == chunk.x) {
|
||||
parentLoc = other;
|
||||
}
|
||||
}
|
||||
@ -268,7 +269,7 @@ public class BO3Handler {
|
||||
}
|
||||
}
|
||||
File bo3File;
|
||||
if ((bo3.getLoc().x == 0) && (bo3.getLoc().z == 0)) {
|
||||
if (bo3.getLoc().x == 0 && bo3.getLoc().z == 0) {
|
||||
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3");
|
||||
} else {
|
||||
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3");
|
||||
|
@ -140,7 +140,7 @@ public class SpongeMain implements IPlotMain {
|
||||
if (!Settings.CONSOLE_COLOR) {
|
||||
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
|
||||
}
|
||||
if ((server == null) || (server.getConsole() == null)) {
|
||||
if (server == null || server.getConsole() == null) {
|
||||
logger.info(message);
|
||||
return;
|
||||
}
|
||||
@ -168,7 +168,7 @@ public class SpongeMain implements IPlotMain {
|
||||
PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
|
||||
String version = plugin.getVersion().get();
|
||||
final String[] split = version.split("\\.");
|
||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -176,7 +176,7 @@ public class SpongeMain implements IPlotMain {
|
||||
log("Checking minecraft version: Sponge: ");
|
||||
final String version = game.getPlatform().getMinecraftVersion().getName();
|
||||
final String[] split = version.split("\\.");
|
||||
return new int[] { Integer.parseInt(split[0]), Integer.parseInt(split[1]), (split.length == 3) ? Integer.parseInt(split[2]) : 0 };
|
||||
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -337,12 +337,8 @@ public class SpongeMain implements IPlotMain {
|
||||
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
||||
if (gen instanceof SpongePlotGenerator) {
|
||||
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
|
||||
} else if (gen != null) {
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
||||
} else {
|
||||
if (PS.get().config.contains("worlds." + worldname)) {
|
||||
PS.get().loadWorld(worldname, null);
|
||||
}
|
||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user