mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16: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
|
@Override
|
||||||
public void log(String message) {
|
public void log(String message) {
|
||||||
if ((THIS != null) && (Bukkit.getServer().getConsoleSender() != null)) {
|
if (THIS != null && Bukkit.getServer().getConsoleSender() != null) {
|
||||||
try {
|
try {
|
||||||
message = C.color(message);
|
message = C.color(message);
|
||||||
if (!Settings.CONSOLE_COLOR) {
|
if (!Settings.CONSOLE_COLOR) {
|
||||||
@ -377,7 +377,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
final String version = BukkitMain.worldEdit.getDescription().getVersion();
|
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("&cThis version of WorldEdit does not support PlotSquared.");
|
||||||
log("&cPlease use WorldEdit 6+ for masking support");
|
log("&cPlease use WorldEdit 6+ for masking support");
|
||||||
log("&c - http://builds.enginehub.org/job/worldedit");
|
log("&c - http://builds.enginehub.org/job/worldedit");
|
||||||
@ -461,7 +461,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 20);
|
}, 20);
|
||||||
return (Bukkit.getPluginManager().getPlugin("PlotMe") != null) || (Bukkit.getPluginManager().getPlugin("AthionPlots") != null);
|
return Bukkit.getPluginManager().getPlugin("PlotMe") != null || Bukkit.getPluginManager().getPlugin("AthionPlots") != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -470,7 +470,7 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
final Plugin gen_plugin = Bukkit.getPluginManager().getPlugin(name);
|
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, "");
|
ChunkGenerator gen = gen_plugin.getDefaultWorldGenerator(world, "");
|
||||||
if (gen instanceof GeneratorWrapper<?>) {
|
if (gen instanceof GeneratorWrapper<?>) {
|
||||||
return (GeneratorWrapper<?>) gen;
|
return (GeneratorWrapper<?>) gen;
|
||||||
@ -497,19 +497,19 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
UUIDWrapper wrapper;
|
UUIDWrapper wrapper;
|
||||||
if (Settings.OFFLINE_MODE) {
|
if (Settings.OFFLINE_MODE) {
|
||||||
if (Settings.UUID_LOWERCASE) {
|
if (Settings.UUID_LOWERCASE) {
|
||||||
wrapper = (new LowerOfflineUUIDWrapper());
|
wrapper = new LowerOfflineUUIDWrapper();
|
||||||
} else {
|
} else {
|
||||||
wrapper = (new OfflineUUIDWrapper());
|
wrapper = new OfflineUUIDWrapper();
|
||||||
}
|
}
|
||||||
Settings.OFFLINE_MODE = true;
|
Settings.OFFLINE_MODE = true;
|
||||||
} else if (checkVersion) {
|
} else if (checkVersion) {
|
||||||
wrapper = (new DefaultUUIDWrapper());
|
wrapper = new DefaultUUIDWrapper();
|
||||||
Settings.OFFLINE_MODE = false;
|
Settings.OFFLINE_MODE = false;
|
||||||
} else {
|
} else {
|
||||||
if (Settings.UUID_LOWERCASE) {
|
if (Settings.UUID_LOWERCASE) {
|
||||||
wrapper = (new LowerOfflineUUIDWrapper());
|
wrapper = new LowerOfflineUUIDWrapper();
|
||||||
} else {
|
} else {
|
||||||
wrapper = (new OfflineUUIDWrapper());
|
wrapper = new OfflineUUIDWrapper();
|
||||||
}
|
}
|
||||||
Settings.OFFLINE_MODE = true;
|
Settings.OFFLINE_MODE = true;
|
||||||
}
|
}
|
||||||
|
@ -47,6 +47,12 @@ import java.util.logging.Level;
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<MessagePart>, ConfigurationSerializable {
|
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 {
|
static {
|
||||||
ConfigurationSerialization.registerClass(FancyMessage.class);
|
ConfigurationSerialization.registerClass(FancyMessage.class);
|
||||||
@ -56,20 +62,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
private String jsonString;
|
private String jsonString;
|
||||||
private boolean dirty;
|
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.
|
* Creates a JSON message with text.
|
||||||
* @param firstPartText The existing text in the message.
|
* @param firstPartText The existing text in the message.
|
||||||
@ -83,7 +75,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
messageParts.add(new MessagePart(firstPartText));
|
messageParts.add(new MessagePart(firstPartText));
|
||||||
jsonString = null;
|
jsonString = null;
|
||||||
dirty = false;
|
dirty = false;
|
||||||
|
|
||||||
if (nmsPacketPlayOutChatConstructor == null) {
|
if (nmsPacketPlayOutChatConstructor == null) {
|
||||||
try {
|
try {
|
||||||
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
|
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
|
||||||
@ -103,6 +95,105 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
this((TextualComponent) null);
|
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.
|
* Sets the text of the current editing component to a value.
|
||||||
* @param text The new text of the current editing component.
|
* @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) {
|
if (type == Type.UNTYPED) {
|
||||||
throw new IllegalArgumentException("That statistic needs no additional parameter!");
|
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 + "!");
|
throw new IllegalArgumentException("Wrong parameter type for that statistic - needs " + type + "!");
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@ -382,6 +473,24 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
return this;
|
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.
|
* 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>
|
* <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();
|
final StringBuilder builder = new StringBuilder();
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
builder.append(lines[i]);
|
builder.append(lines[i]);
|
||||||
if (i != (lines.length - 1)) {
|
if (i != lines.length - 1) {
|
||||||
builder.append('\n');
|
builder.append('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -408,9 +517,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
*/
|
*/
|
||||||
public FancyMessage formattedTooltip(final FancyMessage text) {
|
public FancyMessage formattedTooltip(final FancyMessage text) {
|
||||||
for (final MessagePart component : text.messageParts) {
|
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.");
|
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.");
|
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -429,23 +538,23 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
onHover(null, null); // Clear tooltip
|
onHover(null, null); // Clear tooltip
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
final FancyMessage result = new FancyMessage();
|
final FancyMessage result = new FancyMessage();
|
||||||
result.messageParts.clear(); // Remove the one existing text component that exists by default, which destabilizes the object
|
result.messageParts.clear(); // Remove the one existing text component that exists by default, which destabilizes the object
|
||||||
|
|
||||||
for (int i = 0; i < lines.length; i++) {
|
for (int i = 0; i < lines.length; i++) {
|
||||||
try {
|
try {
|
||||||
for (final MessagePart component : lines[i]) {
|
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.");
|
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.");
|
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
|
||||||
}
|
}
|
||||||
if (component.hasText()) {
|
if (component.hasText()) {
|
||||||
result.messageParts.add(component.clone());
|
result.messageParts.add(component.clone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (i != (lines.length - 1)) {
|
if (i != lines.length - 1) {
|
||||||
result.messageParts.add(new MessagePart(rawText("\n")));
|
result.messageParts.add(new MessagePart(rawText("\n")));
|
||||||
}
|
}
|
||||||
} catch (final CloneNotSupportedException e) {
|
} catch (final CloneNotSupportedException e) {
|
||||||
@ -476,27 +585,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
latest().translationReplacements.add(new JsonString(str));
|
latest().translationReplacements.add(new JsonString(str));
|
||||||
}
|
}
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
|
||||||
return this;
|
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.
|
* 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.
|
* @param replacements The replacements, in order, that will be used in the language-specific message.
|
||||||
@ -504,9 +596,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
*/
|
*/
|
||||||
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
public FancyMessage translationReplacements(final FancyMessage... replacements) {
|
||||||
Collections.addAll(latest().translationReplacements, replacements);
|
Collections.addAll(latest().translationReplacements, replacements);
|
||||||
|
|
||||||
dirty = true;
|
dirty = true;
|
||||||
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -557,7 +649,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
dirty = true;
|
dirty = true;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void writeJson(final JsonWriter writer) throws IOException {
|
public void writeJson(final JsonWriter writer) throws IOException {
|
||||||
if (messageParts.size() == 1) {
|
if (messageParts.size() == 1) {
|
||||||
@ -577,7 +669,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
* @return The JSON string representing this object.
|
* @return The JSON string representing this object.
|
||||||
*/
|
*/
|
||||||
public String toJSONString() {
|
public String toJSONString() {
|
||||||
if (!dirty && (jsonString != null)) {
|
if (!dirty && jsonString != null) {
|
||||||
return jsonString;
|
return jsonString;
|
||||||
}
|
}
|
||||||
final StringWriter string = new StringWriter();
|
final StringWriter string = new StringWriter();
|
||||||
@ -626,30 +718,26 @@ 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,
|
private Object createChatPacket(final String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException,
|
||||||
ClassNotFoundException {
|
ClassNotFoundException {
|
||||||
if (nmsChatSerializerGsonInstance == null) {
|
if (nmsChatSerializerGsonInstance == null) {
|
||||||
// Find the field and its value, completely bypassing obfuscation
|
// Find the field and its value, completely bypassing obfuscation
|
||||||
Class<?> chatSerializerClazz;
|
Class<?> chatSerializerClazz;
|
||||||
|
|
||||||
final String version = Reflection.getVersion();
|
final String version = Reflection.getVersion();
|
||||||
final double majorVersion = Double.parseDouble(version.replace('_', '.').substring(1, 4));
|
final double majorVersion = Double.parseDouble(version.replace('_', '.').substring(1, 4));
|
||||||
final int lesserVersion = Integer.parseInt(version.substring(6, 7));
|
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");
|
chatSerializerClazz = Reflection.getNMSClass("ChatSerializer");
|
||||||
} else {
|
} else {
|
||||||
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (chatSerializerClazz == null) {
|
if (chatSerializerClazz == null) {
|
||||||
throw new ClassNotFoundException("Can't find the ChatSerializer class");
|
throw new ClassNotFoundException("Can't find the ChatSerializer class");
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final Field declaredField : chatSerializerClazz.getDeclaredFields()) {
|
for (final Field declaredField : chatSerializerClazz.getDeclaredFields()) {
|
||||||
if (Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType().getName().endsWith("Gson")) {
|
if (Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType().getName().endsWith("Gson")) {
|
||||||
// We've found our field
|
// We've found our field
|
||||||
@ -660,14 +748,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)'
|
Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)'
|
||||||
than to reflectively call it
|
than to reflectively call it
|
||||||
Of course, the implementation may change, but fuzzy matches might break with signature changes
|
Of course, the implementation may change, but fuzzy matches might break with signature changes
|
||||||
*/
|
*/
|
||||||
final Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent"));
|
final Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json, Reflection.getNMSClass("IChatBaseComponent"));
|
||||||
|
|
||||||
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -749,21 +837,6 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
return map;
|
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>
|
* <b>Internally called method. Not for API consumption.</b>
|
||||||
*/
|
*/
|
||||||
@ -771,77 +844,4 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<
|
|||||||
public Iterator<MessagePart> iterator() {
|
public Iterator<MessagePart> iterator() {
|
||||||
return messageParts.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;
|
loaded = true;
|
||||||
}
|
}
|
||||||
// Set random seed
|
// Set random seed
|
||||||
this.random.state = (cx << 16) | (cz & 0xFFFF);
|
this.random.state = cx << 16 | cz & 0xFFFF;
|
||||||
// Process the chunk
|
// Process the chunk
|
||||||
if (ChunkManager.preProcessChunk(result)) {
|
if (ChunkManager.preProcessChunk(result)) {
|
||||||
return;
|
return;
|
||||||
@ -267,7 +267,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
PlotArea area = PS.get().getPlotArea(world.getName(), null);
|
||||||
plotGenerator.generateChunk(chunkSetter, area, this.random);
|
plotGenerator.generateChunk(chunkSetter, area, this.random);
|
||||||
ChunkManager.postProcessChunk(result);
|
ChunkManager.postProcessChunk(result);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -316,6 +315,6 @@ public class BukkitPlotGenerator extends ChunkGenerator implements GeneratorWrap
|
|||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
return false;
|
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();
|
iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,7 +73,7 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
}
|
}
|
||||||
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
final PlotPlayer player = BukkitUtil.getPlayer((Player) commandSender);
|
||||||
if (strings.length < 1) {
|
if (strings.length < 1) {
|
||||||
if ((strings.length == 0) || "plots".startsWith(s)) {
|
if (strings.length == 0 || "plots".startsWith(s)) {
|
||||||
return Collections.singletonList("plots");
|
return Collections.singletonList("plots");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,5 @@
|
|||||||
package com.plotsquared.bukkit.util;
|
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.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotAnalysis;
|
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.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.MathMan;
|
import com.intellectualcrafters.plot.util.MathMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
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 {
|
public class BukkitHybridUtils extends HybridUtils {
|
||||||
|
|
||||||
@ -72,8 +71,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final int ctz = tz >> 4;
|
final int ctz = tz >> 4;
|
||||||
final Random r = new Random();
|
final Random r = new Random();
|
||||||
MainUtil.initCache();
|
MainUtil.initCache();
|
||||||
final int width = (tx - bx) + 1;
|
final int width = tx - bx + 1;
|
||||||
final int length = (tz - bz) + 1;
|
final int length = tz - bz + 1;
|
||||||
|
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
@ -90,17 +89,17 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final int X = value[0];
|
final int X = value[0];
|
||||||
final int Z = value[1];
|
final int Z = value[1];
|
||||||
final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
|
final short[][] result = gen.generateExtBlockSections(worldObj, r, X, Z, nullBiomeGrid);
|
||||||
final int xb = ((X) << 4) - bx;
|
final int xb = (X << 4) - bx;
|
||||||
final int zb = ((Z) << 4) - bz;
|
final int zb = (Z << 4) - bz;
|
||||||
for (int i = 0; i < result.length; i++) {
|
for (int i = 0; i < result.length; i++) {
|
||||||
if (result[i] == null) {
|
if (result[i] == null) {
|
||||||
for (int j = 0; j < 4096; j++) {
|
for (int j = 0; j < 4096; j++) {
|
||||||
final int x = MainUtil.x_loc[i][j] + xb;
|
final int x = MainUtil.x_loc[i][j] + xb;
|
||||||
if ((x < 0) || (x >= width)) {
|
if (x < 0 || x >= width) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int z = MainUtil.z_loc[i][j] + zb;
|
final int z = MainUtil.z_loc[i][j] + zb;
|
||||||
if ((z < 0) || (z >= length)) {
|
if (z < 0 || z >= length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int y = MainUtil.y_loc[i][j];
|
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++) {
|
for (int j = 0; j < result[i].length; j++) {
|
||||||
final int x = MainUtil.x_loc[i][j] + xb;
|
final int x = MainUtil.x_loc[i][j] + xb;
|
||||||
if ((x < 0) || (x >= width)) {
|
if (x < 0 || x >= width) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int z = MainUtil.z_loc[i][j] + zb;
|
final int z = MainUtil.z_loc[i][j] + zb;
|
||||||
if ((z < 0) || (z >= length)) {
|
if (z < 0 || z >= length) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
final int y = MainUtil.y_loc[i][j];
|
final int y = MainUtil.y_loc[i][j];
|
||||||
@ -150,7 +149,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
} else {
|
} else {
|
||||||
// check vertices
|
// check vertices
|
||||||
// modifications_adjacent
|
// 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) {
|
if (newblocks[y - 1][x][z] == 0) {
|
||||||
faces[i]++;
|
faces[i]++;
|
||||||
}
|
}
|
||||||
@ -196,11 +195,11 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
analysis.air = (int) (MathMan.getMean(air) * 100);
|
analysis.air = (int) (MathMan.getMean(air) * 100);
|
||||||
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
analysis.variety = (int) (MathMan.getMean(variety) * 100);
|
||||||
|
|
||||||
analysis.changes_sd = (int) (MathMan.getSD(changes, analysis.changes));
|
analysis.changes_sd = (int) MathMan.getSD(changes, analysis.changes);
|
||||||
analysis.faces_sd = (int) (MathMan.getSD(faces, analysis.faces));
|
analysis.faces_sd = (int) MathMan.getSD(faces, analysis.faces);
|
||||||
analysis.data_sd = (int) (MathMan.getSD(data, analysis.data));
|
analysis.data_sd = (int) MathMan.getSD(data, analysis.data);
|
||||||
analysis.air_sd = (int) (MathMan.getSD(air, analysis.air));
|
analysis.air_sd = (int) MathMan.getSD(air, analysis.air);
|
||||||
analysis.variety_sd = (int) (MathMan.getSD(variety, analysis.variety));
|
analysis.variety_sd = (int) MathMan.getSD(variety, analysis.variety);
|
||||||
System.gc();
|
System.gc();
|
||||||
System.gc();
|
System.gc();
|
||||||
whenDone.value = analysis;
|
whenDone.value = analysis;
|
||||||
@ -222,24 +221,24 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final int Z = value[1];
|
final int Z = value[1];
|
||||||
worldObj.loadChunk(X, Z);
|
worldObj.loadChunk(X, Z);
|
||||||
int minX;
|
int minX;
|
||||||
int minZ;
|
|
||||||
int maxX;
|
|
||||||
int maxZ;
|
|
||||||
if (X == cbx) {
|
if (X == cbx) {
|
||||||
minX = bx & 15;
|
minX = bx & 15;
|
||||||
} else {
|
} else {
|
||||||
minX = 0;
|
minX = 0;
|
||||||
}
|
}
|
||||||
|
int minZ;
|
||||||
if (Z == cbz) {
|
if (Z == cbz) {
|
||||||
minZ = bz & 15;
|
minZ = bz & 15;
|
||||||
} else {
|
} else {
|
||||||
minZ = 0;
|
minZ = 0;
|
||||||
}
|
}
|
||||||
|
int maxX;
|
||||||
if (X == ctx) {
|
if (X == ctx) {
|
||||||
maxX = tx & 15;
|
maxX = tx & 15;
|
||||||
} else {
|
} else {
|
||||||
maxX = 16;
|
maxX = 16;
|
||||||
}
|
}
|
||||||
|
int maxZ;
|
||||||
if (Z == ctz) {
|
if (Z == ctz) {
|
||||||
maxZ = tz & 15;
|
maxZ = tz & 15;
|
||||||
} else {
|
} else {
|
||||||
@ -249,8 +248,8 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
final int cbx = X << 4;
|
final int cbx = X << 4;
|
||||||
final int cbz = Z << 4;
|
final int cbz = Z << 4;
|
||||||
|
|
||||||
final int xb = (cbx) - bx;
|
final int xb = cbx - bx;
|
||||||
final int zb = (cbz) - bz;
|
final int zb = cbz - bz;
|
||||||
for (int x = minX; x <= maxX; x++) {
|
for (int x = minX; x <= maxX; x++) {
|
||||||
final int xx = cbx + x;
|
final int xx = cbx + x;
|
||||||
for (int z = minZ; z <= maxZ; z++) {
|
for (int z = minZ; z <= maxZ; z++) {
|
||||||
@ -311,7 +310,7 @@ public class BukkitHybridUtils extends HybridUtils {
|
|||||||
for (int y = sy; y < maxY; y++) {
|
for (int y = sy; y < maxY; y++) {
|
||||||
if (y > ey) {
|
if (y > ey) {
|
||||||
final Block block = world.getBlockAt(x, y, z);
|
final Block block = world.getBlockAt(x, y, z);
|
||||||
if (block.getTypeId() != 0) {
|
if (!block.getType().equals(Material.AIR)) {
|
||||||
ey = y;
|
ey = y;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
int count = 0;
|
int count = 0;
|
||||||
final ArrayList<Chunk> chunks = new ArrayList<>();
|
final ArrayList<Chunk> chunks = new ArrayList<>();
|
||||||
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
final Iterator<Entry<ChunkWrapper, Chunk>> i = toUpdate.entrySet().iterator();
|
||||||
while (i.hasNext() && (count < 128)) {
|
while (i.hasNext() && count < 128) {
|
||||||
chunks.add(i.next().getValue());
|
chunks.add(i.next().getValue());
|
||||||
i.remove();
|
i.remove();
|
||||||
count++;
|
count++;
|
||||||
@ -180,7 +180,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
|
|
||||||
// Trim entities
|
// Trim entities
|
||||||
for (int i = 0; i < 16; i++) {
|
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();
|
entities[i].clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
Object section = sections[j];
|
Object section = sections[j];
|
||||||
if ((section == null) || (fs.getCount(j) >= 4096)) {
|
if (section == null || fs.getCount(j) >= 4096) {
|
||||||
char[] array = new char[4096];
|
char[] array = new char[4096];
|
||||||
for (int i = 0; i < newArray.length; i++) {
|
for (int i = 0; i < newArray.length; i++) {
|
||||||
int combined = newArray[i];
|
int combined = newArray[i];
|
||||||
@ -317,7 +317,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
|
|
||||||
methodInitLighting.of(c).call();
|
methodInitLighting.of(c).call();
|
||||||
|
|
||||||
if ((bc.getTotalRelight() == 0 && !fixAll)) {
|
if (bc.getTotalRelight() == 0 && !fixAll) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -333,7 +333,7 @@ public class FastQueue_1_9 extends SlowQueue {
|
|||||||
if (section == null) {
|
if (section == null) {
|
||||||
continue;
|
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;
|
continue;
|
||||||
}
|
}
|
||||||
final int[] array = bc.getIdArray(j);
|
final int[] array = bc.getIdArray(j);
|
||||||
|
@ -208,7 +208,7 @@ public class PS {
|
|||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
for (final Plot plot : getPlots()) {
|
for (final Plot plot : getPlots()) {
|
||||||
if (plot.hasOwner() && (plot.temp != -1)) {
|
if (plot.hasOwner() && plot.temp != -1) {
|
||||||
if (UUIDHandler.getName(plot.owner) == null) {
|
if (UUIDHandler.getName(plot.owner) == null) {
|
||||||
UUIDHandler.implementation.unknown.add(plot.owner);
|
UUIDHandler.implementation.unknown.add(plot.owner);
|
||||||
}
|
}
|
||||||
@ -376,8 +376,8 @@ public class PS {
|
|||||||
* @return true if `version` is >= `version2`
|
* @return true if `version` is >= `version2`
|
||||||
*/
|
*/
|
||||||
public boolean checkVersion(final int[] version, int... 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]) && (
|
return version[0] > version2[0] || version[0] == version2[0] && version[1] > version2[1] || version[0] == version2[0]
|
||||||
version[2] >= version2[2]));
|
&& version[1] == version2[1] && version[2] >= version2[2];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -518,7 +518,7 @@ public class PS {
|
|||||||
if (areas == null) {
|
if (areas == null) {
|
||||||
for (PlotArea area : plotareas) {
|
for (PlotArea area : plotareas) {
|
||||||
if (area.worldname.equalsIgnoreCase(split[0])) {
|
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;
|
return area;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -902,7 +902,7 @@ public class PS {
|
|||||||
} else {
|
} else {
|
||||||
extra.add(plot);
|
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);
|
extra.add(plot);
|
||||||
} else {
|
} else {
|
||||||
overflow.add(plot);
|
overflow.add(plot);
|
||||||
@ -950,7 +950,7 @@ public class PS {
|
|||||||
} else {
|
} else {
|
||||||
extra.add(plot);
|
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);
|
extra.add(plot);
|
||||||
} else {
|
} else {
|
||||||
overflow.add(plot);
|
overflow.add(plot);
|
||||||
@ -1011,7 +1011,7 @@ public class PS {
|
|||||||
for (final Plot i : input) {
|
for (final Plot i : input) {
|
||||||
int tmp = MathMan.getPositiveId(i.hashCode()) / placement;
|
int tmp = MathMan.getPositiveId(i.hashCode()) / placement;
|
||||||
bucket[tmp & 31].add(i);
|
bucket[tmp & 31].add(i);
|
||||||
if (maxLength && (tmp > 0)) {
|
if (maxLength && tmp > 0) {
|
||||||
maxLength = false;
|
maxLength = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -1062,7 +1062,7 @@ public class PS {
|
|||||||
Collections.sort(areas, new Comparator<PlotArea>() {
|
Collections.sort(areas, new Comparator<PlotArea>() {
|
||||||
@Override
|
@Override
|
||||||
public int compare(final PlotArea a, final PlotArea b) {
|
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 -1;
|
||||||
}
|
}
|
||||||
return a.hashCode() - b.hashCode();
|
return a.hashCode() - b.hashCode();
|
||||||
@ -1229,7 +1229,7 @@ public class PS {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Plot getPlot(PlotArea area, final PlotId id) {
|
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())) {
|
if (!plotareaHasCollision && !plotareaHashCheck.add(world.hashCode())) {
|
||||||
plotareaHasCollision = true;
|
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;
|
final String path = "worlds." + world;
|
||||||
ConfigurationSection worldSection = config.getConfigurationSection(path);
|
ConfigurationSection worldSection = config.getConfigurationSection(path);
|
||||||
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
int type = worldSection != null ? worldSection.getInt("generator.type") : 0;
|
||||||
@ -1543,7 +1543,7 @@ public class PS {
|
|||||||
* @return boolean | if valid arguments were provided
|
* @return boolean | if valid arguments were provided
|
||||||
*/
|
*/
|
||||||
public boolean setupPlotWorld(final String world, final String args, IndependentPlotGenerator generator) {
|
public boolean setupPlotWorld(final String world, final String args, IndependentPlotGenerator generator) {
|
||||||
if ((args != null) && (!args.isEmpty())) {
|
if (args != null && !args.isEmpty()) {
|
||||||
// save configuration
|
// save configuration
|
||||||
final String[] split = args.split(",");
|
final String[] split = args.split(",");
|
||||||
final HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
|
final HybridPlotWorld plotworld = new HybridPlotWorld(world, null, generator, null, null);
|
||||||
@ -1869,7 +1869,7 @@ public class PS {
|
|||||||
case "false":
|
case "false":
|
||||||
return false;
|
return false;
|
||||||
default:
|
default:
|
||||||
return (MainUtil.timeToSec(value) * 1000) + System.currentTimeMillis();
|
return MainUtil.timeToSec(value) * 1000 + System.currentTimeMillis();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
@ -1999,7 +1999,7 @@ public class PS {
|
|||||||
|
|
||||||
final int keep = config.getInt("clear.keep-if-modified");
|
final int keep = config.getInt("clear.keep-if-modified");
|
||||||
final int ignore = config.getInt("clear.ignore-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.threshold", 1);
|
||||||
options.put("clear.auto.enabled", false);
|
options.put("clear.auto.enabled", false);
|
||||||
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
log("&cIMPORTANT MESSAGE ABOUT THIS UPDATE!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
|
||||||
|
@ -80,8 +80,8 @@ public class Area extends SubCommand {
|
|||||||
Location pos2 = plr.getMeta("area_pos1");
|
Location pos2 = plr.getMeta("area_pos1");
|
||||||
int dx = Math.abs(pos1.getX() - pos2.getX());
|
int dx = Math.abs(pos1.getX() - pos2.getX());
|
||||||
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
int dz = Math.abs(pos1.getZ() - pos2.getZ());
|
||||||
int numx = Math.max(1, (dx + 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);
|
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 ddx = dx - (numx * area.SIZE - area.ROAD_WIDTH);
|
||||||
final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
final int ddz = dz - (numz * area.SIZE - area.ROAD_WIDTH);
|
||||||
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
int bx = Math.min(pos1.getX(), pos2.getX()) + ddx;
|
||||||
@ -318,7 +318,7 @@ public class Area extends SubCommand {
|
|||||||
region = area.getRegion().toString();
|
region = area.getRegion().toString();
|
||||||
} else {
|
} else {
|
||||||
name = area.worldname;
|
name = area.worldname;
|
||||||
percent = claimed == 0 ? 0 : (100d * claimed) / (Integer.MAX_VALUE);
|
percent = claimed == 0 ? 0 : 100d * claimed / Integer.MAX_VALUE;
|
||||||
region = "N/A";
|
region = "N/A";
|
||||||
}
|
}
|
||||||
String value = "&r$1NAME: " + name
|
String value = "&r$1NAME: " + name
|
||||||
|
@ -52,7 +52,7 @@ public class Auto extends SubCommand {
|
|||||||
return new PlotId(id.x + 1, id.y);
|
return new PlotId(id.x + 1, id.y);
|
||||||
}
|
}
|
||||||
} else {
|
} 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);
|
return new PlotId(id.x, id.y + step);
|
||||||
}
|
}
|
||||||
if (id.x == absX) {
|
if (id.x == absX) {
|
||||||
@ -81,7 +81,7 @@ public class Auto extends SubCommand {
|
|||||||
final String[] split = args[0].split(",|;");
|
final String[] split = args[0].split(",|;");
|
||||||
size_x = Integer.parseInt(split[0]);
|
size_x = Integer.parseInt(split[0]);
|
||||||
size_z = Integer.parseInt(split[1]);
|
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");
|
MainUtil.sendMessage(plr, "&cError: size<=0");
|
||||||
}
|
}
|
||||||
if (args.length > 1) {
|
if (args.length > 1) {
|
||||||
@ -101,15 +101,15 @@ public class Auto extends SubCommand {
|
|||||||
// return false;
|
// 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 + "");
|
MainUtil.sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS_NUM, Settings.MAX_AUTO_SIZE + "");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
final int currentPlots = Settings.GLOBAL_LIMIT ? plr.getPlotCount() : plr.getPlotCount(plotarea.worldname);
|
||||||
final int diff = currentPlots - plr.getAllowedPlots();
|
final int diff = currentPlots - plr.getAllowedPlots();
|
||||||
if ((diff + (size_x * size_z)) > 0) {
|
if (diff + size_x * size_z > 0) {
|
||||||
if (diff < 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;
|
return false;
|
||||||
} else if (plr.hasPersistentMeta("grantedPlots")) {
|
} else if (plr.hasPersistentMeta("grantedPlots")) {
|
||||||
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
int grantedPlots = ByteArrayUtilities.bytesToInteger(plr.getPersistentMeta("grantedPlots"));
|
||||||
@ -117,11 +117,10 @@ public class Auto extends SubCommand {
|
|||||||
plr.removePersistentMeta("grantedPlots");
|
plr.removePersistentMeta("grantedPlots");
|
||||||
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
return sendMessage(plr, C.CANT_CLAIM_MORE_PLOTS);
|
||||||
} else {
|
} else {
|
||||||
int left = grantedPlots - diff - (size_x * size_z);
|
int left = grantedPlots - diff - size_x * size_z;
|
||||||
if (left == 0) {
|
if (left == 0) {
|
||||||
plr.removePersistentMeta("grantedPlots");
|
plr.removePersistentMeta("grantedPlots");
|
||||||
}
|
} else {
|
||||||
else {
|
|
||||||
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left));
|
plr.setPersistentMeta("grantedPlots", ByteArrayUtilities.integerToBytes(left));
|
||||||
}
|
}
|
||||||
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left));
|
sendMessage(plr, C.REMOVED_GRANTED_PLOT, "" + left, "" + (grantedPlots - left));
|
||||||
@ -131,7 +130,7 @@ public class Auto extends SubCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((EconHandler.manager != null) && plotarea.USE_ECONOMY) {
|
if (EconHandler.manager != null && plotarea.USE_ECONOMY) {
|
||||||
double cost = plotarea.PRICES.get("claim");
|
double cost = plotarea.PRICES.get("claim");
|
||||||
cost = (size_x * size_z) * cost;
|
cost = (size_x * size_z) * cost;
|
||||||
if (cost > 0d) {
|
if (cost > 0d) {
|
||||||
@ -159,7 +158,7 @@ public class Auto extends SubCommand {
|
|||||||
final PlotId top = plotarea.getMax();
|
final PlotId top = plotarea.getMax();
|
||||||
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
final PlotId origin = new PlotId((bot.x + top.x) / 2, (bot.y + top.y) / 2);
|
||||||
PlotId id = new PlotId(0, 0);
|
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;
|
final int max = width * width;
|
||||||
//
|
//
|
||||||
for (int i = 0; i <= max; i++) {
|
for (int i = 0; i <= max; i++) {
|
||||||
@ -179,17 +178,17 @@ public class Auto extends SubCommand {
|
|||||||
boolean br = false;
|
boolean br = false;
|
||||||
while (true) {
|
while (true) {
|
||||||
final PlotId start = getNextPlotId(getLastPlotId(plotarea), 1);
|
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);
|
plotarea.setMeta("lastPlot", start);
|
||||||
if (plotarea.canClaim(plr, start, end)) {
|
if (plotarea.canClaim(plr, start, end)) {
|
||||||
for (int i = start.x; i <= end.x; i++) {
|
for (int i = start.x; i <= end.x; i++) {
|
||||||
for (int j = start.y; j <= end.y; j++) {
|
for (int j = start.y; j <= end.y; j++) {
|
||||||
Plot plot = plotarea.getPlotAbs(new PlotId(i, 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);
|
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)) {
|
if (!plotarea.mergePlots(MainUtil.getPlotSelectionIds(start, end), Settings.MERGE_REMOVES_ROADS, true)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -102,7 +102,7 @@ public class Cluster extends SubCommand {
|
|||||||
// check pos1 / pos2
|
// check pos1 / pos2
|
||||||
PlotId pos1 = PlotId.fromString(args[2]);
|
PlotId pos1 = PlotId.fromString(args[2]);
|
||||||
PlotId pos2 = PlotId.fromString(args[3]);
|
PlotId pos2 = PlotId.fromString(args[3]);
|
||||||
if ((pos1 == null) || (pos2 == null)) {
|
if (pos1 == null || pos2 == null) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -112,7 +112,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
MainUtil.sendMessage(plr, C.ALIAS_IS_TAKEN);
|
||||||
return false;
|
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));
|
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));
|
pos2 = new PlotId(Math.max(pos1.x, pos2.x), Math.max(pos1.y, pos2.y));
|
||||||
pos1 = tmp;
|
pos1 = tmp;
|
||||||
@ -145,7 +145,7 @@ public class Cluster extends SubCommand {
|
|||||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
||||||
}
|
}
|
||||||
final int allowed = Permissions.hasPermissionRange(plr, "plots.cluster", Settings.MAX_PLOTS);
|
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()));
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -172,7 +172,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.delete");
|
||||||
return false;
|
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]");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster delete [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -218,11 +218,11 @@ public class Cluster extends SubCommand {
|
|||||||
// check pos1 / pos2
|
// check pos1 / pos2
|
||||||
PlotId pos1 = PlotId.fromString(args[1]);
|
PlotId pos1 = PlotId.fromString(args[1]);
|
||||||
PlotId pos2 = PlotId.fromString(args[2]);
|
PlotId pos2 = PlotId.fromString(args[2]);
|
||||||
if ((pos1 == null) || (pos2 == null)) {
|
if (pos1 == null || pos2 == null) {
|
||||||
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
MainUtil.sendMessage(plr, C.NOT_VALID_PLOT_ID);
|
||||||
return false;
|
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));
|
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));
|
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> existing = area.getPlotSelectionOwned(cluster.getP1(), cluster.getP2());
|
||||||
final HashSet<Plot> newplots = area.getPlotSelectionOwned(pos1, pos2);
|
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);
|
removed.removeAll(newplots);
|
||||||
// Check expand / shrink
|
// Check expand / shrink
|
||||||
if (!removed.isEmpty()) {
|
if (!removed.isEmpty()) {
|
||||||
@ -274,9 +274,9 @@ public class Cluster extends SubCommand {
|
|||||||
} else {
|
} else {
|
||||||
current = plr.getPlayerClusterCount(plr.getLocation().getWorld());
|
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);
|
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()));
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster." + (current + cluster.getArea()));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -379,7 +379,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||||
final PlotCluster current = plot.getCluster();
|
final PlotCluster current = plot.getCluster();
|
||||||
if ((current != null) && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -392,7 +392,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.leave");
|
||||||
return false;
|
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]");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster leave [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -432,7 +432,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
MainUtil.sendMessage(plr, C.CLUSTER_REMOVED, cluster.getName());
|
||||||
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
for (final Plot plot : new ArrayList<>(PS.get().getPlots(plr.getLocation().getWorld(), uuid))) {
|
||||||
final PlotCluster current = plot.getCluster();
|
final PlotCluster current = plot.getCluster();
|
||||||
if ((current != null) && current.equals(cluster)) {
|
if (current != null && current.equals(cluster)) {
|
||||||
plr.getLocation().getWorld();
|
plr.getLocation().getWorld();
|
||||||
plot.unclaim();
|
plot.unclaim();
|
||||||
}
|
}
|
||||||
@ -515,7 +515,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.info");
|
||||||
return false;
|
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]");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster info [name]");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -543,7 +543,7 @@ public class Cluster extends SubCommand {
|
|||||||
owner = "unknown";
|
owner = "unknown";
|
||||||
}
|
}
|
||||||
final String name = cluster.getName();
|
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()) + "";
|
final String rights = cluster.isAdded(plr.getUUID()) + "";
|
||||||
String message = C.CLUSTER_INFO.s();
|
String message = C.CLUSTER_INFO.s();
|
||||||
message = message.replaceAll("%id%", id);
|
message = message.replaceAll("%id%", id);
|
||||||
@ -561,7 +561,7 @@ public class Cluster extends SubCommand {
|
|||||||
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
MainUtil.sendMessage(plr, C.NO_PERMISSION, "plots.cluster.sethome");
|
||||||
return false;
|
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");
|
MainUtil.sendMessage(plr, C.COMMAND_SYNTAX, "/plot cluster sethome");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -126,13 +126,13 @@ public class Configuration {
|
|||||||
@Override
|
@Override
|
||||||
public boolean validateValue(final String string) {
|
public boolean validateValue(final String string) {
|
||||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
|
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(string);
|
||||||
return !((value == null) || (value.match > 1));
|
return !(value == null || value.match > 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PlotBlock parseString(final String string) {
|
public PlotBlock parseString(final String string) {
|
||||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(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 null;
|
||||||
}
|
}
|
||||||
return value.best;
|
return value.best;
|
||||||
@ -149,7 +149,7 @@ public class Configuration {
|
|||||||
block = split[1];
|
block = split[1];
|
||||||
}
|
}
|
||||||
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(block);
|
final StringComparison<PlotBlock>.ComparisonResult value = WorldUtil.IMP.getClosestBlock(block);
|
||||||
if ((value == null) || (value.match > 1)) {
|
if (value == null || value.match > 1) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -183,7 +183,7 @@ public class Configuration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
final StringComparison<PlotBlock>.ComparisonResult result = WorldUtil.IMP.getClosestBlock(blocks[i]);
|
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;
|
values[i] = result.best;
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException e) {
|
} catch (NumberFormatException e) {
|
||||||
@ -192,7 +192,7 @@ public class Configuration {
|
|||||||
final int gcd = gcd(counts);
|
final int gcd = gcd(counts);
|
||||||
for (int i = 0; i < counts.length; i++) {
|
for (int i = 0; i < counts.length; i++) {
|
||||||
final int num = counts[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]);
|
parsedvalues.add(values[i]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -136,7 +136,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// schedule reconnect
|
// schedule reconnect
|
||||||
if (MYSQL && ((System.currentTimeMillis() - last) > 550000)) {
|
if (MYSQL && System.currentTimeMillis() - last > 550000) {
|
||||||
last = System.currentTimeMillis();
|
last = System.currentTimeMillis();
|
||||||
try {
|
try {
|
||||||
close();
|
close();
|
||||||
@ -573,14 +573,14 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMySQL(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
public void setMySQL(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
||||||
stmt.setInt((i * 2) + 1, pair.id);
|
stmt.setInt(i * 2 + 1, pair.id);
|
||||||
stmt.setString((i * 2) + 2, pair.uuid.toString());
|
stmt.setString(i * 2 + 2, pair.uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSQLite(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
public void setSQLite(final PreparedStatement stmt, final int i, final UUIDPair pair) throws SQLException {
|
||||||
stmt.setInt((i * 2) + 1, pair.id);
|
stmt.setInt(i * 2 + 1, pair.id);
|
||||||
stmt.setString((i * 2) + 2, pair.uuid.toString());
|
stmt.setString(i * 2 + 2, pair.uuid.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -617,29 +617,29 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMySQL(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
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 + 1, plot.getId().x);
|
||||||
stmt.setInt((i * 5) + 2, plot.getId().y);
|
stmt.setInt(i * 5 + 2, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString((i * 5) + 3, plot.owner.toString());
|
stmt.setString(i * 5 + 3, plot.owner.toString());
|
||||||
} catch (SQLException e) {
|
} 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.setString(i * 5 + 4, plot.getArea().toString());
|
||||||
stmt.setTimestamp((i * 5) + 5, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(i * 5 + 5, new Timestamp(plot.getTimestamp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
public void setSQLite(final PreparedStatement stmt, final int i, final Plot plot) throws SQLException {
|
||||||
stmt.setNull((i * 6) + 1, 4);
|
stmt.setNull(i * 6 + 1, 4);
|
||||||
stmt.setInt((i * 6) + 2, plot.getId().x);
|
stmt.setInt(i * 6 + 2, plot.getId().x);
|
||||||
stmt.setInt((i * 6) + 3, plot.getId().y);
|
stmt.setInt(i * 6 + 3, plot.getId().y);
|
||||||
try {
|
try {
|
||||||
stmt.setString((i * 6) + 4, plot.owner.toString());
|
stmt.setString(i * 6 + 4, plot.owner.toString());
|
||||||
} catch (SQLException e1) {
|
} 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.setString(i * 6 + 5, plot.getArea().toString());
|
||||||
stmt.setTimestamp((i * 6) + 6, new Timestamp(plot.getTimestamp()));
|
stmt.setTimestamp(i * 6 + 6, new Timestamp(plot.getTimestamp()));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -685,7 +685,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
statement = mod.getCreateMySQL(subList.size());
|
statement = mod.getCreateMySQL(subList.size());
|
||||||
preparedStmt = connection.prepareStatement(statement);
|
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.executeBatch();
|
||||||
preparedStmt.close();
|
preparedStmt.close();
|
||||||
statement = mod.getCreateMySQL(subList.size());
|
statement = mod.getCreateMySQL(subList.size());
|
||||||
@ -728,7 +728,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
statement = mod.getCreateSQLite(subList.size());
|
statement = mod.getCreateSQLite(subList.size());
|
||||||
preparedStmt = connection.prepareStatement(statement);
|
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.executeBatch();
|
||||||
preparedStmt.clearParameters();
|
preparedStmt.clearParameters();
|
||||||
statement = mod.getCreateSQLite(subList.size());
|
statement = mod.getCreateSQLite(subList.size());
|
||||||
@ -799,16 +799,16 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
public void setMySQL(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
stmt.setInt(i * 10 + 1, pair.id); // id
|
||||||
stmt.setNull((i * 10) + 2, 4); // biome
|
stmt.setNull(i * 10 + 2, 4); // biome
|
||||||
stmt.setNull((i * 10) + 3, 4); // rain
|
stmt.setNull(i * 10 + 3, 4); // rain
|
||||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
stmt.setNull(i * 10 + 4, 4); // custom_time
|
||||||
stmt.setNull((i * 10) + 5, 4); // time
|
stmt.setNull(i * 10 + 5, 4); // time
|
||||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
stmt.setNull(i * 10 + 6, 4); // deny_entry
|
||||||
if (pair.settings.getAlias().isEmpty()) {
|
if (pair.settings.getAlias().isEmpty()) {
|
||||||
stmt.setNull((i * 10) + 7, 4);
|
stmt.setNull(i * 10 + 7, 4);
|
||||||
} else {
|
} else {
|
||||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
stmt.setString(i * 10 + 7, pair.settings.getAlias());
|
||||||
}
|
}
|
||||||
final StringBuilder flag_string = new StringBuilder();
|
final StringBuilder flag_string = new StringBuilder();
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@ -819,10 +819,10 @@ public class SQLManager implements AbstractDB {
|
|||||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
stmt.setString((i * 10) + 8, flag_string.toString());
|
stmt.setString(i * 10 + 8, flag_string.toString());
|
||||||
final boolean[] merged = pair.settings.getMerged();
|
final boolean[] merged = pair.settings.getMerged();
|
||||||
int hash = MainUtil.hash(merged);
|
int hash = MainUtil.hash(merged);
|
||||||
stmt.setInt((i * 10) + 9, hash);
|
stmt.setInt(i * 10 + 9, hash);
|
||||||
final BlockLoc loc = pair.settings.getPosition();
|
final BlockLoc loc = pair.settings.getPosition();
|
||||||
String position;
|
String position;
|
||||||
if (loc.y == 0) {
|
if (loc.y == 0) {
|
||||||
@ -830,21 +830,21 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else {
|
} else {
|
||||||
position = loc.x + "," + loc.y + "," + loc.z;
|
position = loc.x + "," + loc.y + "," + loc.z;
|
||||||
}
|
}
|
||||||
stmt.setString((i * 10) + 10, position);
|
stmt.setString(i * 10 + 10, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
public void setSQLite(final PreparedStatement stmt, final int i, final SettingsPair pair) throws SQLException {
|
||||||
stmt.setInt((i * 10) + 1, pair.id); // id
|
stmt.setInt(i * 10 + 1, pair.id); // id
|
||||||
stmt.setNull((i * 10) + 2, 4); // biome
|
stmt.setNull(i * 10 + 2, 4); // biome
|
||||||
stmt.setNull((i * 10) + 3, 4); // rain
|
stmt.setNull(i * 10 + 3, 4); // rain
|
||||||
stmt.setNull((i * 10) + 4, 4); // custom_time
|
stmt.setNull(i * 10 + 4, 4); // custom_time
|
||||||
stmt.setNull((i * 10) + 5, 4); // time
|
stmt.setNull(i * 10 + 5, 4); // time
|
||||||
stmt.setNull((i * 10) + 6, 4); // deny_entry
|
stmt.setNull(i * 10 + 6, 4); // deny_entry
|
||||||
if (pair.settings.getAlias().equals("")) {
|
if (pair.settings.getAlias().isEmpty()) {
|
||||||
stmt.setNull((i * 10) + 7, 4);
|
stmt.setNull(i * 10 + 7, 4);
|
||||||
} else {
|
} else {
|
||||||
stmt.setString((i * 10) + 7, pair.settings.getAlias());
|
stmt.setString(i * 10 + 7, pair.settings.getAlias());
|
||||||
}
|
}
|
||||||
final StringBuilder flag_string = new StringBuilder();
|
final StringBuilder flag_string = new StringBuilder();
|
||||||
int k = 0;
|
int k = 0;
|
||||||
@ -855,13 +855,13 @@ public class SQLManager implements AbstractDB {
|
|||||||
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
flag_string.append(flag.getKey() + ":" + flag.getValueString().replaceAll(":", "\u00AF").replaceAll(",", "\u00B4"));
|
||||||
k++;
|
k++;
|
||||||
}
|
}
|
||||||
stmt.setString((i * 10) + 8, flag_string.toString());
|
stmt.setString(i * 10 + 8, flag_string.toString());
|
||||||
final boolean[] merged = pair.settings.getMerged();
|
final boolean[] merged = pair.settings.getMerged();
|
||||||
int n = 0;
|
int n = 0;
|
||||||
for (int j = 0; j < 4; ++j) {
|
for (int j = 0; j < 4; ++j) {
|
||||||
n = (n << 1) + (merged[j] ? 1 : 0);
|
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();
|
final BlockLoc loc = pair.settings.getPosition();
|
||||||
String position;
|
String position;
|
||||||
if (loc.y == 0) {
|
if (loc.y == 0) {
|
||||||
@ -869,7 +869,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
} else {
|
} else {
|
||||||
position = loc.x + "," + loc.y + "," + loc.z;
|
position = loc.x + "," + loc.y + "," + loc.z;
|
||||||
}
|
}
|
||||||
stmt.setString((i * 10) + 10, position);
|
stmt.setString(i * 10 + 10, position);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -909,21 +909,21 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMySQL(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
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
|
@Override
|
||||||
public void setSQLite(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
public void setSQLite(final PreparedStatement stmt, final int i, final Integer id) throws SQLException {
|
||||||
stmt.setInt((i * 10) + 1, id);
|
stmt.setInt(i * 10 + 1, id);
|
||||||
stmt.setNull((i * 10) + 2, 4);
|
stmt.setNull(i * 10 + 2, 4);
|
||||||
stmt.setNull((i * 10) + 3, 4);
|
stmt.setNull(i * 10 + 3, 4);
|
||||||
stmt.setNull((i * 10) + 4, 4);
|
stmt.setNull(i * 10 + 4, 4);
|
||||||
stmt.setNull((i * 10) + 5, 4);
|
stmt.setNull(i * 10 + 5, 4);
|
||||||
stmt.setNull((i * 10) + 6, 4);
|
stmt.setNull(i * 10 + 6, 4);
|
||||||
stmt.setNull((i * 10) + 7, 4);
|
stmt.setNull(i * 10 + 7, 4);
|
||||||
stmt.setNull((i * 10) + 8, 4);
|
stmt.setNull(i * 10 + 8, 4);
|
||||||
stmt.setNull((i * 10) + 9, 4);
|
stmt.setNull(i * 10 + 9, 4);
|
||||||
stmt.setString((i * 10) + 10, "DEFAULT");
|
stmt.setString(i * 10 + 10, "DEFAULT");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1417,7 +1417,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
stmt.close();
|
stmt.close();
|
||||||
r.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) {
|
if (cluster.temp > 0) {
|
||||||
return cluster.temp;
|
return cluster.temp;
|
||||||
}
|
}
|
||||||
@ -1453,7 +1453,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
r.close();
|
r.close();
|
||||||
stmt.close();
|
stmt.close();
|
||||||
if ((id == Integer.MAX_VALUE) || (id == 0)) {
|
if (id == Integer.MAX_VALUE || id == 0) {
|
||||||
if (plot.temp > 0) {
|
if (plot.temp > 0) {
|
||||||
return plot.temp;
|
return plot.temp;
|
||||||
}
|
}
|
||||||
@ -1575,12 +1575,12 @@ public class SQLManager implements AbstractDB {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
public void setMySQL(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||||
stmt.setInt((i) + 1, obj);
|
stmt.setInt(i + 1, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
public void setSQLite(PreparedStatement stmt, int i, Integer obj) throws SQLException {
|
||||||
stmt.setInt((i) + 1, obj);
|
stmt.setInt(i + 1, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1801,7 +1801,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
final Integer m = r.getInt("merged");
|
final Integer m = r.getInt("merged");
|
||||||
final boolean[] merged = new boolean[4];
|
final boolean[] merged = new boolean[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
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);
|
plot.getSettings().setMerged(merged);
|
||||||
String[] flags_string;
|
String[] flags_string;
|
||||||
@ -2584,7 +2584,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
final Integer m = r.getInt("merged");
|
final Integer m = r.getInt("merged");
|
||||||
final boolean[] merged = new boolean[4];
|
final boolean[] merged = new boolean[4];
|
||||||
for (int i = 0; i < 4; i++) {
|
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);
|
cluster.settings.setMerged(merged);
|
||||||
String[] flags_string;
|
String[] flags_string;
|
||||||
|
@ -1,7 +1,5 @@
|
|||||||
package com.intellectualcrafters.plot.generator;
|
package com.intellectualcrafters.plot.generator;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
import com.intellectualcrafters.plot.object.Plot;
|
||||||
import com.intellectualcrafters.plot.object.PlotArea;
|
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.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.SetQueue;
|
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)
|
* 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
|
@Override
|
||||||
public boolean unclaimPlot(final PlotArea plotworld, final Plot plot, final Runnable whenDone) {
|
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 });
|
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 });
|
setWall(dpw, plot.getId(), new PlotBlock[] { dpw.WALL_BLOCK });
|
||||||
}
|
}
|
||||||
SetQueue.IMP.addTask(whenDone);
|
SetQueue.IMP.addTask(whenDone);
|
||||||
@ -142,7 +142,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
final PseudoRandom random = new PseudoRandom();
|
final PseudoRandom random = new PseudoRandom();
|
||||||
if (!plot.getMerged(0)) {
|
if (!plot.getMerged(0)) {
|
||||||
int z = bottom.getZ();
|
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++) {
|
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(3)) {
|
||||||
int x = bottom.getX();
|
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++) {
|
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(2)) {
|
||||||
int z = top.getZ();
|
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++) {
|
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(1)) {
|
||||||
int x = top.getX();
|
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++) {
|
for (int y = dpw.PLOT_HEIGHT; y <= 255; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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();
|
final PseudoRandom random = new PseudoRandom();
|
||||||
if (!plot.getMerged(0)) {
|
if (!plot.getMerged(0)) {
|
||||||
int z = bot.getZ();
|
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++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(3)) {
|
||||||
int x = bot.getX();
|
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++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(2)) {
|
||||||
int z = top.getZ();
|
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++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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)) {
|
if (!plot.getMerged(1)) {
|
||||||
int x = top.getX();
|
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++) {
|
for (int y = 1; y <= dpw.WALL_HEIGHT; y++) {
|
||||||
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
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;
|
final int y = dpw.WALL_HEIGHT + 1;
|
||||||
if (!plot.getMerged(0)) {
|
if (!plot.getMerged(0)) {
|
||||||
int z = bot.getZ();
|
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)]);
|
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(3)) {
|
if (!plot.getMerged(3)) {
|
||||||
int x = bot.getX();
|
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)]);
|
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(2)) {
|
if (!plot.getMerged(2)) {
|
||||||
int z = top.getZ();
|
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)]);
|
SetQueue.IMP.setBlock(plotworld.worldname, x, y, z, blocks[random.random(blocks.length)]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!plot.getMerged(1)) {
|
if (!plot.getMerged(1)) {
|
||||||
int x = top.getX();
|
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)]);
|
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 pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||||
final int sx = pos2.getX() + 1;
|
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 sz = pos1.getZ() - 2;
|
||||||
final int ez = pos2.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));
|
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 pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||||
final int sz = pos2.getZ() + 1;
|
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 sx = pos1.getX() - 2;
|
||||||
final int ex = pos2.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));
|
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 ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||||
final int sx = pos2.getX() + 1;
|
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 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(
|
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));
|
(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));
|
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 pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||||
final int sx = pos2.getX() + 1;
|
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 sz = pos1.getZ() - 1;
|
||||||
final int ez = pos2.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));
|
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 pos1 = getPlotBottomLocAbs(plotworld, plot.getId());
|
||||||
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
final Location pos2 = getPlotTopLocAbs(plotworld, plot.getId());
|
||||||
final int sz = pos2.getZ() + 1;
|
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 sx = pos1.getX() - 1;
|
||||||
final int ex = pos2.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));
|
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 ClassicPlotWorld dpw = (ClassicPlotWorld) plotworld;
|
||||||
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
final Location loc = getPlotTopLocAbs(dpw, plot.getId());
|
||||||
final int sx = loc.getX() + 1;
|
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 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.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, 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);
|
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) {
|
public boolean finishPlotMerge(final PlotArea plotworld, final ArrayList<PlotId> plotIds) {
|
||||||
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
final PlotBlock block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).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) {
|
for (final PlotId id : plotIds) {
|
||||||
setWall(plotworld, id, new PlotBlock[] { block });
|
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 block = ((ClassicPlotWorld) plotworld).CLAIMED_WALL_BLOCK;
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
for (final PlotId id : plotIds) {
|
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 });
|
setWall(plotworld, id, new PlotBlock[] { block });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ public class ClassicPlotManager extends SquarePlotManager {
|
|||||||
public boolean claimPlot(final PlotArea plotworld, final Plot plot) {
|
public boolean claimPlot(final PlotArea plotworld, final Plot plot) {
|
||||||
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
final PlotBlock unclaim = ((ClassicPlotWorld) plotworld).WALL_BLOCK;
|
||||||
final PlotBlock claim = ((ClassicPlotWorld) plotworld).CLAIMED_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 });
|
setWall(plotworld, plot.getId(), new PlotBlock[] { claim });
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -5,12 +5,32 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.flag.Flag;
|
import com.intellectualcrafters.plot.flag.Flag;
|
||||||
import com.intellectualcrafters.plot.flag.FlagManager;
|
import com.intellectualcrafters.plot.flag.FlagManager;
|
||||||
import com.intellectualcrafters.plot.object.*;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.util.*;
|
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.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.Map.Entry;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public abstract class HybridUtils {
|
public abstract class HybridUtils {
|
||||||
@ -95,8 +115,8 @@ public abstract class HybridUtils {
|
|||||||
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
final ArrayList<ChunkLoc> chunks = new ArrayList<>();
|
||||||
final int sx = region.x << 5;
|
final int sx = region.x << 5;
|
||||||
final int sz = region.z << 5;
|
final int sz = region.z << 5;
|
||||||
for (int x = sx; x < (sx + 32); x++) {
|
for (int x = sx; x < sx + 32; x++) {
|
||||||
for (int z = sz; z < (sz + 32); z++) {
|
for (int z = sz; z < sz + 32; z++) {
|
||||||
chunks.add(new ChunkLoc(x, z));
|
chunks.add(new ChunkLoc(x, z));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -185,10 +205,10 @@ public abstract class HybridUtils {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
count.incrementAndGet();
|
count.incrementAndGet();
|
||||||
if ((count.intValue() % 20) == 0) {
|
if (count.intValue() % 20 == 0) {
|
||||||
PS.debug("PROGRESS: " + ((100 * (2048 - chunks.size())) / 2048) + "%");
|
PS.debug("PROGRESS: " + 100 * (2048 - chunks.size()) / 2048 + "%");
|
||||||
}
|
}
|
||||||
if ((regions.isEmpty()) && (chunks.isEmpty())) {
|
if (regions.isEmpty() && chunks.isEmpty()) {
|
||||||
HybridUtils.UPDATE = false;
|
HybridUtils.UPDATE = false;
|
||||||
PS.debug(C.PREFIX.s() + "Finished road conversion");
|
PS.debug(C.PREFIX.s() + "Finished road conversion");
|
||||||
// CANCEL TASK
|
// CANCEL TASK
|
||||||
@ -214,7 +234,7 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
final long diff = System.currentTimeMillis() + 1;
|
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);
|
last.set(0);
|
||||||
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
PS.debug(C.PREFIX.s() + "Detected low TPS. Rescheduling in 30s");
|
||||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||||
@ -230,8 +250,8 @@ public abstract class HybridUtils {
|
|||||||
TaskManager.runTaskLater(task, 600);
|
TaskManager.runTaskLater(task, 600);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((((System.currentTimeMillis() - baseTime) - last.get()) < 1500) && (last.get() != 0)) {
|
if (System.currentTimeMillis() - baseTime - last.get() < 1500 && last.get() != 0) {
|
||||||
while ((System.currentTimeMillis() < diff) && (!chunks.isEmpty())) {
|
while (System.currentTimeMillis() < diff && !chunks.isEmpty()) {
|
||||||
Iterator<ChunkLoc> iter = chunks.iterator();
|
Iterator<ChunkLoc> iter = chunks.iterator();
|
||||||
final ChunkLoc chunk = iter.next();
|
final ChunkLoc chunk = iter.next();
|
||||||
iter.remove();
|
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?)");
|
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 sx = loc.x << 5;
|
||||||
final int sz = loc.z << 5;
|
final int sz = loc.z << 5;
|
||||||
for (int x = sx; x < (sx + 32); x++) {
|
for (int x = sx; x < sx + 32; x++) {
|
||||||
for (int z = sz; z < (sz + 32); z++) {
|
for (int z = sz; z < sz + 32; z++) {
|
||||||
ChunkManager.manager.unloadChunk(area.worldname, new ChunkLoc(x, z), true, true);
|
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 bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||||
final Location top = plot.getTopAbs();
|
final Location top = plot.getTopAbs();
|
||||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
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 sz = bot.getZ() + 1;
|
||||||
final int sy = plotworld.ROAD_HEIGHT;
|
final int sy = plotworld.ROAD_HEIGHT;
|
||||||
final int ex = bot.getX();
|
final int ex = bot.getX();
|
||||||
@ -339,18 +359,18 @@ public abstract class HybridUtils {
|
|||||||
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
final PlotId id2 = manager.getPlotId(plotworld, ex, 0, ez);
|
||||||
x -= plotworld.ROAD_OFFSET_X;
|
x -= plotworld.ROAD_OFFSET_X;
|
||||||
z -= plotworld.ROAD_OFFSET_Z;
|
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);
|
final boolean result = ChunkManager.manager.loadChunk(area.worldname, chunk, false);
|
||||||
if (result) {
|
if (result) {
|
||||||
if (id1 != null) {
|
if (id1 != null) {
|
||||||
final Plot p1 = area.getPlotAbs(id1);
|
final Plot p1 = area.getPlotAbs(id1);
|
||||||
if ((p1 != null) && p1.hasOwner() && p1.isMerged()) {
|
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
|
||||||
toCheck = true;
|
toCheck = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if ((id2 != null) && !toCheck) {
|
if (id2 != null && !toCheck) {
|
||||||
final Plot p2 = area.getPlotAbs(id2);
|
final Plot p2 = area.getPlotAbs(id2);
|
||||||
if ((p2 != null) && p2.hasOwner() && p2.isMerged()) {
|
if (p2 != null && p2.hasOwner() && p2.isMerged()) {
|
||||||
toCheck = true;
|
toCheck = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -374,12 +394,11 @@ public abstract class HybridUtils {
|
|||||||
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
final boolean gz = absZ > plotworld.PATH_WIDTH_LOWER;
|
||||||
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
final boolean lx = absX < plotworld.PATH_WIDTH_UPPER;
|
||||||
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
final boolean lz = absZ < plotworld.PATH_WIDTH_UPPER;
|
||||||
condition = (!gx || !gz || !lx || !lz);
|
condition = !gx || !gz || !lx || !lz;
|
||||||
}
|
}
|
||||||
if (condition) {
|
if (condition) {
|
||||||
final int sy = plotworld.ROAD_HEIGHT;
|
|
||||||
final HashMap<Integer, PlotBlock> blocks = plotworld.G_SCH.get(MathMan.pair(absX, absZ));
|
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);
|
SetQueue.IMP.setBlock(area.worldname, x + X + plotworld.ROAD_OFFSET_X, y, z + Z + plotworld.ROAD_OFFSET_Z, 0);
|
||||||
}
|
}
|
||||||
if (blocks != null) {
|
if (blocks != null) {
|
||||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.object;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.Settings;
|
import com.intellectualcrafters.plot.config.Settings;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
public class BO3 {
|
public class BO3 {
|
||||||
@ -59,6 +60,6 @@ public class BO3 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFilename() {
|
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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -19,14 +19,35 @@ public class BlockLoc {
|
|||||||
public BlockLoc(final int x, final int y, final int z) {
|
public BlockLoc(final int x, final int y, final int z) {
|
||||||
this(x, y, z, 0f, 0f);
|
this(x, y, z, 0f, 0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static BlockLoc fromString(final String string) {
|
||||||
|
final String[] parts = string.split(",");
|
||||||
|
|
||||||
|
float yaw, pitch;
|
||||||
|
if (parts.length == 3) {
|
||||||
|
yaw = 0f;
|
||||||
|
pitch = 0f;
|
||||||
|
}
|
||||||
|
if (parts.length == 5) {
|
||||||
|
yaw = Float.parseFloat(parts[3]);
|
||||||
|
pitch = Float.parseFloat(parts[4]);
|
||||||
|
} else {
|
||||||
|
return new BlockLoc(0, 0, 0);
|
||||||
|
}
|
||||||
|
final int x = Integer.parseInt(parts[0]);
|
||||||
|
final int y = Integer.parseInt(parts[1]);
|
||||||
|
final int z = Integer.parseInt(parts[2]);
|
||||||
|
|
||||||
|
return new BlockLoc(x, y, z, yaw, pitch);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
final int prime = 31;
|
final int prime = 31;
|
||||||
int result = 1;
|
int result = 1;
|
||||||
result = (prime * result) + x;
|
result = prime * result + x;
|
||||||
result = (prime * result) + y;
|
result = prime * result + y;
|
||||||
result = (prime * result) + z;
|
result = prime * result + z;
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -42,7 +63,7 @@ public class BlockLoc {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
final BlockLoc other = (BlockLoc) obj;
|
final BlockLoc other = (BlockLoc) obj;
|
||||||
return ((x == other.x) && (y == other.y) && (z == other.z));
|
return x == other.x && y == other.y && z == other.z;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -53,25 +74,4 @@ public class BlockLoc {
|
|||||||
return x + "," + y + "," + z + "," + yaw + "," + pitch;
|
return x + "," + y + "," + z + "," + yaw + "," + pitch;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static BlockLoc fromString(final String string) {
|
|
||||||
final String[] parts = string.split(",");
|
|
||||||
|
|
||||||
float yaw, pitch;
|
|
||||||
if (parts.length == 3) {
|
|
||||||
yaw = 0f;
|
|
||||||
pitch = 0f;
|
|
||||||
}
|
|
||||||
if (parts.length == 5) {
|
|
||||||
yaw = Float.parseFloat(parts[3]);
|
|
||||||
pitch = Float.parseFloat(parts[4]);
|
|
||||||
} else {
|
|
||||||
return new BlockLoc(0, 0, 0);
|
|
||||||
}
|
|
||||||
final int x = Integer.parseInt(parts[0]);
|
|
||||||
final int y = Integer.parseInt(parts[1]);
|
|
||||||
final int z = Integer.parseInt(parts[2]);
|
|
||||||
|
|
||||||
return new BlockLoc(x, y, z, yaw, pitch);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -70,7 +70,7 @@ public class PlotAnalysis {
|
|||||||
PS.debug("Calibration task already in progress!");
|
PS.debug("Calibration task already in progress!");
|
||||||
return;
|
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)");
|
PS.debug("Invalid threshold provided! (Cannot be 0 or 100 as then there's no point calibrating)");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -84,7 +84,7 @@ public class PlotAnalysis {
|
|||||||
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
PS.debug(" - $1Reducing " + plots.size() + " plots to those with sufficient data");
|
||||||
while (iter.hasNext()) {
|
while (iter.hasNext()) {
|
||||||
final Plot plot = iter.next();
|
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();
|
iter.remove();
|
||||||
} else {
|
} else {
|
||||||
plot.addRunning();
|
plot.addRunning();
|
||||||
@ -126,7 +126,7 @@ public class PlotAnalysis {
|
|||||||
final int i = mi.intValue();
|
final int i = mi.intValue();
|
||||||
final Plot plot = plots.get(i);
|
final Plot plot = plots.get(i);
|
||||||
ratings[i] = (int) ((plot.getAverageRating() + plot.getSettings().getRatings().size()) * 100);
|
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 {
|
try {
|
||||||
ratingAnalysis.join();
|
ratingAnalysis.join();
|
||||||
} catch (final InterruptedException e) {
|
} catch (final InterruptedException e) {
|
||||||
@ -212,7 +212,7 @@ public class PlotAnalysis {
|
|||||||
final int[] variance_changes = square(sd_changes);
|
final int[] variance_changes = square(sd_changes);
|
||||||
final int sum_changes = sum(variance_changes);
|
final int sum_changes = sum(variance_changes);
|
||||||
final double factor_changes = getCC(n, sum_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);
|
PS.debug(" - | changes " + factor_changes);
|
||||||
|
|
||||||
final int[] rank_faces = rank(faces);
|
final int[] rank_faces = rank(faces);
|
||||||
@ -220,7 +220,7 @@ public class PlotAnalysis {
|
|||||||
final int[] variance_faces = square(sd_faces);
|
final int[] variance_faces = square(sd_faces);
|
||||||
final int sum_faces = sum(variance_faces);
|
final int sum_faces = sum(variance_faces);
|
||||||
final double factor_faces = getCC(n, sum_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);
|
PS.debug(" - | faces " + factor_faces);
|
||||||
|
|
||||||
final int[] rank_data = rank(data);
|
final int[] rank_data = rank(data);
|
||||||
@ -228,7 +228,7 @@ public class PlotAnalysis {
|
|||||||
final int[] variance_data = square(sd_data);
|
final int[] variance_data = square(sd_data);
|
||||||
final int sum_data = sum(variance_data);
|
final int sum_data = sum(variance_data);
|
||||||
final double factor_data = getCC(n, sum_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);
|
PS.debug(" - | data " + factor_data);
|
||||||
|
|
||||||
final int[] rank_air = rank(air);
|
final int[] rank_air = rank(air);
|
||||||
@ -236,7 +236,7 @@ public class PlotAnalysis {
|
|||||||
final int[] variance_air = square(sd_air);
|
final int[] variance_air = square(sd_air);
|
||||||
final int sum_air = sum(variance_air);
|
final int sum_air = sum(variance_air);
|
||||||
final double factor_air = getCC(n, sum_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);
|
PS.debug(" - | air " + factor_air);
|
||||||
|
|
||||||
final int[] rank_variety = rank(variety);
|
final int[] rank_variety = rank(variety);
|
||||||
@ -244,7 +244,7 @@ public class PlotAnalysis {
|
|||||||
final int[] variance_variety = square(sd_variety);
|
final int[] variance_variety = square(sd_variety);
|
||||||
final int sum_variety = sum(variance_variety);
|
final int sum_variety = sum(variance_variety);
|
||||||
final double factor_variety = getCC(n, sum_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);
|
PS.debug(" - | variety " + factor_variety);
|
||||||
|
|
||||||
final int[] rank_changes_sd = rank(changes_sd);
|
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[] variance_changes_sd = square(sd_changes_sd);
|
||||||
final int sum_changes_sd = sum(variance_changes_sd);
|
final int sum_changes_sd = sum(variance_changes_sd);
|
||||||
final double factor_changes_sd = getCC(n, sum_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);
|
PS.debug(" - | changes_sd " + factor_changes_sd);
|
||||||
|
|
||||||
final int[] rank_faces_sd = rank(faces_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[] variance_faces_sd = square(sd_faces_sd);
|
||||||
final int sum_faces_sd = sum(variance_faces_sd);
|
final int sum_faces_sd = sum(variance_faces_sd);
|
||||||
final double factor_faces_sd = getCC(n, sum_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);
|
PS.debug(" - | faces_sd " + factor_faces_sd);
|
||||||
|
|
||||||
final int[] rank_data_sd = rank(data_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[] variance_data_sd = square(sd_data_sd);
|
||||||
final int sum_data_sd = sum(variance_data_sd);
|
final int sum_data_sd = sum(variance_data_sd);
|
||||||
final double factor_data_sd = getCC(n, sum_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);
|
PS.debug(" - | data_sd " + factor_data_sd);
|
||||||
|
|
||||||
final int[] rank_air_sd = rank(air_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[] variance_air_sd = square(sd_air_sd);
|
||||||
final int sum_air_sd = sum(variance_air_sd);
|
final int sum_air_sd = sum(variance_air_sd);
|
||||||
final double factor_air_sd = getCC(n, sum_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);
|
PS.debug(" - | air_sd " + factor_air_sd);
|
||||||
|
|
||||||
final int[] rank_variety_sd = rank(variety_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[] variance_variety_sd = square(sd_variety_sd);
|
||||||
final int sum_variety_sd = sum(variance_variety_sd);
|
final int sum_variety_sd = sum(variance_variety_sd);
|
||||||
final double factor_variety_sd = getCC(n, sum_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);
|
PS.debug(" - | variety_sd " + factor_variety_sd);
|
||||||
|
|
||||||
final int[] complexity = new int[n];
|
final int[] complexity = new int[n];
|
||||||
@ -303,7 +303,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
int optimal_complexity = Integer.MAX_VALUE;
|
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);
|
final int[] rank_complexity = rank(complexity, max + 1);
|
||||||
for (int i = 0; i < n; i++) {
|
for (int i = 0; i < n; i++) {
|
||||||
if (rank_complexity[i] == optimal_index) {
|
if (rank_complexity[i] == optimal_index) {
|
||||||
@ -396,7 +396,7 @@ public class PlotAnalysis {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public static double getCC(final int n, final int sum) {
|
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) {
|
for (final Integer i : input) {
|
||||||
tmp = i / placement;
|
tmp = i / placement;
|
||||||
bucket[tmp % SIZE].add(i);
|
bucket[tmp % SIZE].add(i);
|
||||||
if (maxLength && (tmp > 0)) {
|
if (maxLength && tmp > 0) {
|
||||||
maxLength = false;
|
maxLength = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -542,16 +542,16 @@ public class PlotAnalysis {
|
|||||||
if (complexity != 0) {
|
if (complexity != 0) {
|
||||||
return complexity;
|
return complexity;
|
||||||
}
|
}
|
||||||
complexity = ((changes) * MODIFIERS.changes)
|
complexity = changes * MODIFIERS.changes
|
||||||
+ ((faces) * MODIFIERS.faces)
|
+ faces * MODIFIERS.faces
|
||||||
+ ((data) * MODIFIERS.data)
|
+ data * MODIFIERS.data
|
||||||
+ ((air) * MODIFIERS.air)
|
+ air * MODIFIERS.air
|
||||||
+ ((variety) * MODIFIERS.variety)
|
+ variety * MODIFIERS.variety
|
||||||
+ ((changes_sd) * MODIFIERS.changes_sd)
|
+ changes_sd * MODIFIERS.changes_sd
|
||||||
+ ((faces_sd) * MODIFIERS.faces_sd)
|
+ faces_sd * MODIFIERS.faces_sd
|
||||||
+ ((data_sd) * MODIFIERS.data_sd)
|
+ data_sd * MODIFIERS.data_sd
|
||||||
+ ((air_sd) * MODIFIERS.air_sd)
|
+ air_sd * MODIFIERS.air_sd
|
||||||
+ ((variety_sd) * MODIFIERS.variety_sd);
|
+ variety_sd * MODIFIERS.variety_sd;
|
||||||
return complexity;
|
return complexity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -64,11 +64,12 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdded(final UUID uuid) {
|
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) {
|
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() {
|
public String getName() {
|
||||||
@ -80,7 +81,7 @@ public class PlotCluster {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getArea() {
|
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) {
|
public void setArea(PlotArea plotarea) {
|
||||||
@ -159,10 +160,10 @@ public class PlotCluster {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean intersects(PlotId pos1, PlotId pos2) {
|
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) {
|
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) {
|
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) {
|
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) {
|
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
|
@Override
|
||||||
|
@ -10,7 +10,7 @@ public abstract class AbstractTitle {
|
|||||||
if (ConsolePlayer.isConsole(player)) {
|
if (ConsolePlayer.isConsole(player)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if ((TITLE_CLASS != null) && !player.getAttribute("disabletitles")) {
|
if (TITLE_CLASS != null && !player.getAttribute("disabletitles")) {
|
||||||
TITLE_CLASS.sendTitle(player, head, sub, 1, 2, 1);
|
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.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||||
|
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
@ -72,7 +73,7 @@ public class BO3Handler {
|
|||||||
throw new IllegalArgumentException("Save task cannot be null!");
|
throw new IllegalArgumentException("Save task cannot be null!");
|
||||||
}
|
}
|
||||||
final PlotArea plotworld = plot.getArea();
|
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.");
|
MainUtil.sendMessage(plr, "BO3 exporting only supports type 0 classic generation.");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -106,10 +107,10 @@ public class BO3Handler {
|
|||||||
Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
|
Location pos1 = new Location(plotworld.worldname, region.minX, region.minY, region.minZ);
|
||||||
Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
|
Location pos2 = new Location(plotworld.worldname, region.maxX, region.maxY, region.maxZ);
|
||||||
for (int x = pos1.getX(); x <= pos2.getX(); x++) {
|
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;
|
final int xx = (x - cx) % 16;
|
||||||
for (int z = pos1.getZ(); z <= pos2.getZ(); z++) {
|
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 int zz = (z - cz) % 16;
|
||||||
final ChunkLoc loc = new ChunkLoc(X, Z);
|
final ChunkLoc loc = new ChunkLoc(X, Z);
|
||||||
BO3 bo3 = map.get(loc);
|
BO3 bo3 = map.get(loc);
|
||||||
@ -156,7 +157,7 @@ public class BO3Handler {
|
|||||||
for (final Entry<ChunkLoc, BO3> entry : map.entrySet()) {
|
for (final Entry<ChunkLoc, BO3> entry : map.entrySet()) {
|
||||||
final ChunkLoc chunk = entry.getKey();
|
final ChunkLoc chunk = entry.getKey();
|
||||||
final BO3 bo3 = entry.getValue();
|
final BO3 bo3 = entry.getValue();
|
||||||
if ((chunk.x == 0) && (chunk.z == 0)) {
|
if (chunk.x == 0 && chunk.z == 0) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int x = chunk.x;
|
int x = chunk.x;
|
||||||
@ -171,7 +172,7 @@ public class BO3Handler {
|
|||||||
parentLoc = null;
|
parentLoc = null;
|
||||||
for (final Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
|
for (final Entry<ChunkLoc, BO3> entry2 : map.entrySet()) {
|
||||||
final ChunkLoc other = entry2.getKey();
|
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;
|
parentLoc = other;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -268,7 +269,7 @@ public class BO3Handler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
File bo3File;
|
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");
|
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + ".bo3");
|
||||||
} else {
|
} else {
|
||||||
bo3File = MainUtil.getFile(base.getParentFile(), bo3.getName() + "_" + bo3.getLoc().x + "_" + bo3.getLoc().z + ".bo3");
|
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) {
|
if (!Settings.CONSOLE_COLOR) {
|
||||||
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
|
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
|
||||||
}
|
}
|
||||||
if ((server == null) || (server.getConsole() == null)) {
|
if (server == null || server.getConsole() == null) {
|
||||||
logger.info(message);
|
logger.info(message);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -168,7 +168,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
|
PluginContainer plugin = game.getPluginManager().fromInstance(this).get();
|
||||||
String version = plugin.getVersion().get();
|
String version = plugin.getVersion().get();
|
||||||
final String[] split = version.split("\\.");
|
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
|
@Override
|
||||||
@ -176,7 +176,7 @@ public class SpongeMain implements IPlotMain {
|
|||||||
log("Checking minecraft version: Sponge: ");
|
log("Checking minecraft version: Sponge: ");
|
||||||
final String version = game.getPlatform().getMinecraftVersion().getName();
|
final String version = game.getPlatform().getMinecraftVersion().getName();
|
||||||
final String[] split = version.split("\\.");
|
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
|
@Override
|
||||||
@ -337,12 +337,8 @@ public class SpongeMain implements IPlotMain {
|
|||||||
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
||||||
if (gen instanceof SpongePlotGenerator) {
|
if (gen instanceof SpongePlotGenerator) {
|
||||||
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
|
PS.get().loadWorld(worldname, (SpongePlotGenerator) gen);
|
||||||
} else if (gen != null) {
|
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
|
||||||
} else {
|
} else {
|
||||||
if (PS.get().config.contains("worlds." + worldname)) {
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
||||||
PS.get().loadWorld(worldname, null);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user