It started on work with commands then I got carried away.

Dieser Commit ist enthalten in:
MattBDev 2019-07-25 14:44:10 -04:00
Ursprung 01c371df9c
Commit ff5860113d
184 geänderte Dateien mit 1694 neuen und 2580 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.IFawe;
import com.boydti.fawe.beta.implementation.QueueHandler; import com.boydti.fawe.beta.implementation.QueueHandler;
import com.boydti.fawe.bukkit.beta.BukkitQueue; import com.boydti.fawe.bukkit.beta.BukkitQueue;
import com.boydti.fawe.bukkit.beta.BukkitQueueHandler; import com.boydti.fawe.bukkit.beta.BukkitQueueHandler;
import com.boydti.fawe.bukkit.chat.BukkitChatManager;
import com.boydti.fawe.bukkit.listener.BrushListener; import com.boydti.fawe.bukkit.listener.BrushListener;
import com.boydti.fawe.bukkit.listener.BukkitImageListener; import com.boydti.fawe.bukkit.listener.BukkitImageListener;
import com.boydti.fawe.bukkit.listener.CFIPacketListener; import com.boydti.fawe.bukkit.listener.CFIPacketListener;
@ -97,11 +96,6 @@ public class FaweBukkit implements IFawe, Listener {
if (Bukkit.getVersion().contains("git-Paper") && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) { if (Bukkit.getVersion().contains("git-Paper") && Settings.IMP.EXPERIMENTAL.DYNAMIC_CHUNK_RENDERING > 1) {
new RenderListener(plugin); new RenderListener(plugin);
} }
try {
Fawe.get().setChatManager(new BukkitChatManager());
} catch (Throwable throwable) {
throwable.printStackTrace();
}
} catch (final Throwable e) { } catch (final Throwable e) {
e.printStackTrace(); e.printStackTrace();
Bukkit.getServer().shutdown(); Bukkit.getServer().shutdown();

Datei anzeigen

@ -1,64 +0,0 @@
package com.boydti.fawe.bukkit.chat;
import com.boydti.fawe.bukkit.BukkitPlayer;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.util.chat.ChatManager;
import com.boydti.fawe.util.chat.Message;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.ChatColor;
public class BukkitChatManager implements ChatManager<FancyMessage> {
@Override
public FancyMessage builder() {
return new FancyMessage("");
}
@Override
public void color(Message message, String color) {
message.$(this).color(ChatColor.getByChar(BBC.color(color).substring(1)));
}
@Override
public void tooltip(Message message, Message... tooltips) {
List<FancyMessage> lines = new ArrayList<>();
for (Message tooltip : tooltips) {
lines.add(tooltip.$(this));
}
message.$(this).formattedTooltip(lines);
}
@Override
public void command(Message message, String command) {
message.$(this).command(command);
}
@Override
public void text(Message message, String text) {
message.$(this).color(BBC.color(text));
}
@Override
public void send(Message Message, FawePlayer player) {
if (!(player instanceof BukkitPlayer)) {
player.sendMessage(Message.$(this).toOldMessageFormat());
} else {
Message.$(this).send(((BukkitPlayer) player).parent);
}
}
@Override
public void suggest(Message Message, String command) {
Message.$(this).suggest(command);
}
@Override
public void link(Message Message, String url) {
Message.$(this).link(url);
}
}

Datei anzeigen

@ -1,874 +0,0 @@
package com.boydti.fawe.bukkit.chat;
import static com.boydti.fawe.bukkit.chat.TextualComponent.rawText;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.io.StringWriter;
import java.lang.reflect.Constructor;
import java.lang.reflect.Field;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import java.lang.reflect.Modifier;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.function.Consumer;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
import org.bukkit.entity.Player;
import org.jetbrains.annotations.NotNull;
/**
* Represents a formattable message. Such messages can use elements such as colors, formatting
* codes, hover and click data, and other features provided by the vanilla Minecraft <a
* href="http://minecraft.gamepedia.com/Tellraw#Raw_JSON_Text">JSON message formatter</a>. This
* class allows plugins to emulate the functionality of the vanilla Minecraft <a
* href="http://minecraft.gamepedia.com/Commands#tellraw">tellraw command</a>.
* <p>
* This class follows the builder pattern, allowing for method chaining. It is set up such that
* invocations of property-setting methods will affect the current editing component, and a call to
* {@link #then()} or {@link #then(String)} will append a new editing component to the end of the
* message, optionally initializing it with text. Further property-setting method calls will affect
* that editing component.
* </p>
*/
public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable<MessagePart>,
ConfigurationSerializable {
static {
ConfigurationSerialization.registerClass(FancyMessage.class);
}
private List<MessagePart> messageParts;
private int index;
private String jsonString;
private boolean dirty;
private static Constructor<?> nmsPacketPlayOutChatConstructor;
@Override
public FancyMessage clone() throws CloneNotSupportedException {
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.index = index;
instance.dirty = false;
instance.jsonString = null;
return instance;
}
/**
* Creates a JSON message with text.
*
* @param firstPartText The existing text in the message.
*/
public FancyMessage(String firstPartText) {
this(rawText(firstPartText));
}
private FancyMessage(TextualComponent firstPartText) {
messageParts = new ArrayList<>();
messageParts.add(new MessagePart(firstPartText));
index = messageParts.size();
jsonString = null;
dirty = false;
if (nmsPacketPlayOutChatConstructor == null) {
try {
nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat")
.getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent"));
nmsPacketPlayOutChatConstructor.setAccessible(true);
} catch (NoSuchMethodException e) {
Bukkit.getLogger()
.log(Level.SEVERE, "Could not find Minecraft method or constructor.", e);
} catch (SecurityException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access constructor.", e);
}
}
}
/**
* Creates a JSON message without text.
*/
public FancyMessage() {
this((TextualComponent) null);
}
/**
* Sets the text of the current editing component to a value.
*
* @param text The new text of the current editing component.
* @return This builder instance.
*/
public FancyMessage text(String text) {
MessagePart latest = latest();
latest.text = rawText(text);
dirty = true;
return this;
}
/**
* Sets the text of the current editing component to a value.
*
* @param text The new text of the current editing component.
* @return This builder instance.
*/
public FancyMessage text(TextualComponent text) {
MessagePart latest = latest();
latest.text = text;
dirty = true;
return this;
}
/**
* @param text Text with coloring
* @return This builder instance.
* @throws IllegalArgumentException If the specified {@code ChatColor} enumeration value is not
* a color (but a format value).
*/
public FancyMessage color(String text) {
index = messageParts.size();
boolean color = false;
ArrayDeque<ChatColor> colors = new ArrayDeque<>();
int last = 0;
for (int i = 0; i < text.length(); i++) {
char c = text.charAt(i);
if (color != (color = false)) {
ChatColor chatColor = ChatColor.getByChar(c);
if (chatColor != null) {
if (i - last > 1) {
append(text.substring(last, i - 1));
colors.forEach(this::color);
colors.clear();
}
colors.add(chatColor);
last = i + 1;
}
}
if (c == '\u00A7') {
color = true;
}
}
if (text.length() - last > 0) {
append(text.substring(last));
colors.forEach(this::color);
}
index++;
return this;
}
/**
* Sets the color of the current editing component to a value.<br /> Setting the color will
* clear current styles
*
* @param color The new color of the current editing component.
* @return This builder instance.
* @throws IllegalArgumentException If the specified {@code ChatColor} enumeration value is not
* a color (but a format value).
*/
public FancyMessage color(ChatColor color) {
if (!color.isColor()) {
if (color.isFormat()) {
return style(color);
}
if (color == ChatColor.RESET) {
color = ChatColor.WHITE;
}
} else {
latest().styles.clear();
}
latest().color = color;
dirty = true;
return this;
}
/**
* Sets the stylization of the current editing component.
*
* @param styles The array of styles to apply to the editing component.
* @return This builder instance.
* @throws IllegalArgumentException If any of the enumeration values in the array do not
* represent formatters.
*/
public FancyMessage style(ChatColor... styles) {
for (ChatColor style : styles) {
if (!style.isFormat()) {
color(style);
}
}
latest().styles.addAll(Arrays.asList(styles));
dirty = true;
return this;
}
/**
* Set the behavior of the current editing component to instruct the client to open a file on
* the client side filesystem when the currently edited part of the {@code FancyMessage} is
* clicked.
*
* @param path The path of the file on the client filesystem.
* @return This builder instance.
*/
public FancyMessage file(String path) {
onClick("open_file", path);
return this;
}
/**
* Set the behavior of the current editing component to instruct the client to open a webpage in
* the client's web browser when the currently edited part of the {@code FancyMessage} is
* clicked.
*
* @param url The URL of the page to open when the link is clicked.
* @return This builder instance.
*/
public FancyMessage link(String url) {
onClick("open_url", url);
return this;
}
/**
* Set the behavior of the current editing component to instruct the client to replace the chat
* input box content with the specified string when the currently edited part of the {@code
* FancyMessage} is clicked. The client will not immediately send the command to the server to
* be executed unless the client player submits the command/chat message, usually with the enter
* key.
*
* @param command The text to display in the chat bar of the client.
* @return This builder instance.
*/
public FancyMessage suggest(String command) {
onClick("suggest_command", command);
return this;
}
/**
* Set the behavior of the current editing component to instruct the client to append the chat
* input box content with the specified string when the currently edited part of the {@code
* FancyMessage} is SHIFT-CLICKED. The client will not immediately send the command to the
* server to be executed unless the client player submits the command/chat message, usually with
* the enter key.
*
* @param command The text to append to the chat bar of the client.
* @return This builder instance.
*/
public FancyMessage insert(String command) {
onCurrent(m -> m.insertionData = command);
dirty = true;
return this;
}
/**
* Set the behavior of the current editing component to instruct the client to send the
* specified string to the server as a chat message when the currently edited part of the {@code
* FancyMessage} is clicked. The client <b>will</b> immediately send the command to the server
* to be executed when the editing component is clicked.
*
* @param command The text to display in the chat bar of the client.
* @return This builder instance.
*/
public FancyMessage command(String command) {
onClick("run_command", command);
return this;
}
/**
* Set the behavior of the current editing component to display raw text when the client hovers
* over the text.
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the
* message component on which they are applied.</p>
*
* @param text The text, which supports newlines, which will be displayed to the client upon
* hovering.
* @return This builder instance.
*/
public FancyMessage tooltip(String text) {
onHover("show_text", new JsonString(text));
return this;
}
/**
* Set the behavior of the current editing component to display raw text when the client hovers
* over the text.
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the
* message component on which they are applied.</p>
*
* @param lines The lines of text which will be displayed to the client upon hovering. The
* iteration order of this object will be the order in which the lines of the
* tooltip are created.
* @return This builder instance.
*/
public FancyMessage tooltip(Iterable<String> lines) {
tooltip(ArrayWrapper.toArray(lines, String.class));
return this;
}
/**
* Set the behavior of the current editing component to display raw text when the client hovers
* over the text.
* <p>Tooltips do not inherit display characteristics, such as color and styles, from the
* message component on which they are applied.</p>
*
* @param lines The lines of text which will be displayed to the client upon hovering.
* @return This builder instance.
*/
public FancyMessage tooltip(String... lines) {
StringBuilder builder = new StringBuilder();
for (int i = 0; i < lines.length; i++) {
builder.append(lines[i]);
if (i != lines.length - 1) {
builder.append('\n');
}
}
tooltip(builder.toString());
return this;
}
/**
* Set the behavior of the current editing component to display formatted 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>
*
* @param text The formatted text which will be displayed to the client upon hovering.
* @return This builder instance.
*/
public FancyMessage formattedTooltip(FancyMessage text) {
for (MessagePart component : text.messageParts) {
if (component.clickActionData != null && component.clickActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have click data.");
} else if (component.hoverActionData != null && component.hoverActionName != null) {
throw new IllegalArgumentException("The tooltip text cannot have a tooltip.");
}
}
onHover("show_text", text);
return this;
}
/**
* Set the behavior of the current editing component to display the specified lines of formatted
* 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>
*
* @param lines The lines of formatted text which will be displayed to the client upon
* hovering.
* @return This builder instance.
*/
public FancyMessage formattedTooltip(FancyMessage... lines) {
if (lines.length < 1) {
onHover(null, null); // Clear tooltip
return this;
}
FancyMessage result = new FancyMessage();
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++) {
try {
for (MessagePart component : lines[i]) {
if (component.clickActionData != null && component.clickActionName != null) {
throw new IllegalArgumentException(
"The tooltip text cannot have click data.");
} else if (component.hoverActionData != null
&& component.hoverActionName != null) {
throw new IllegalArgumentException(
"The tooltip text cannot have a tooltip.");
}
if (component.hasText()) {
result.messageParts.add(component.clone());
result.index = result.messageParts.size();
}
}
if (i != lines.length - 1) {
result.messageParts.add(new MessagePart(rawText("\n")));
result.index = result.messageParts.size();
}
} catch (CloneNotSupportedException e) {
Bukkit.getLogger().log(Level.WARNING, "Failed to clone object", e);
return this;
}
}
return formattedTooltip(
result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended
}
/**
* Set the behavior of the current editing component to display the specified lines of formatted
* 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>
*
* @param lines The lines of text which will be displayed to the client upon hovering. The
* iteration order of this object will be the order in which the lines of the
* tooltip are created.
* @return This builder instance.
*/
public FancyMessage formattedTooltip(Iterable<FancyMessage> lines) {
return formattedTooltip(ArrayWrapper.toArray(lines, FancyMessage.class));
}
/**
* 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(String... replacements) {
for (String str : replacements) {
latest().translationReplacements.add(new JsonString(str));
}
dirty = true;
return this;
}
/*
/**
* If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message.
* @param replacements The replacements, in order, that will be used in the language-specific message.
* @return This builder instance.
*/ /* ------------
public FancyMessage translationReplacements(final Iterable<? extends CharSequence> replacements){
for(CharSequence str : replacements){
latest().translationReplacements.add(new JsonString(str));
}
return this;
}
*/
/**
* If the text is a translatable key, and it has replaceable values, this function can be used
* to set the replacements that will be used in the message.
*
* @param replacements The replacements, in order, that will be used in the language-specific
* message.
* @return This builder instance.
*/
public FancyMessage translationReplacements(FancyMessage... replacements) {
Collections.addAll(latest().translationReplacements, replacements);
dirty = true;
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(Iterable<FancyMessage> replacements) {
return translationReplacements(
ArrayWrapper.toArray(replacements, FancyMessage.class));
}
/**
* Terminate construction of the current editing component, and begin construction of a new
* message component. After a successful call to this method, all setter methods will refer to a
* new message component, created as a result of the call to this method.
*
* @param text The text which will populate the new message component.
* @return This builder instance.
*/
public FancyMessage then(String text) {
return then(rawText(text));
}
private FancyMessage append(String text) {
if (!latest().hasText()) {
throw new IllegalStateException("previous message part has no text");
}
MessagePart latest = latest();
messageParts.add(new MessagePart(rawText(text)));
latest().color = latest.color;
latest().styles.addAll(latest.styles);
dirty = true;
return this;
}
/**
* Terminate construction of the current editing component, and begin construction of a new
* message component. After a successful call to this method, all setter methods will refer to a
* new message component, created as a result of the call to this method.
*
* @param text The text which will populate the new message component.
* @return This builder instance.
*/
public FancyMessage then(TextualComponent text) {
if (!latest().hasText()) {
throw new IllegalStateException("previous message part has no text");
}
messageParts.add(new MessagePart(text));
index = messageParts.size();
dirty = true;
return this;
}
/**
* Terminate construction of the current editing component, and begin construction of a new
* message component. After a successful call to this method, all setter methods will refer to a
* new message component, created as a result of the call to this method.
*
* @return This builder instance.
*/
public FancyMessage then() {
if (!latest().hasText()) {
throw new IllegalStateException("previous message part has no text");
}
messageParts.add(new MessagePart());
index = messageParts.size();
dirty = true;
return this;
}
@Override
public void writeJson(JsonWriter writer) throws IOException {
if (messageParts.size() == 1) {
latest().writeJson(writer);
} else {
writer.beginObject().name("text").value("").name("extra").beginArray();
for (MessagePart part : this) {
part.writeJson(writer);
}
writer.endArray().endObject();
}
}
/**
* Serialize this fancy message, converting it into syntactically-valid JSON using a {@link
* JsonWriter}. This JSON should be compatible with vanilla formatter commands such as {@code
* /tellraw}.
*
* @return The JSON string representing this object.
*/
public String toJSONString() {
if (!dirty && jsonString != null) {
return jsonString;
}
StringWriter string = new StringWriter();
JsonWriter json = new JsonWriter(string);
try {
writeJson(json);
json.close();
} catch (IOException e) {
throw new RuntimeException("invalid message");
}
jsonString = string.toString();
dirty = false;
return jsonString;
}
/**
* Sends this message to a player. The player will receive the fully-fledged formatted display
* of this message.
*
* @param player The player who will receive the message.
*/
public void send(Player player) {
send(player, toJSONString());
}
private void send(CommandSender sender, String jsonString) {
if (!(sender instanceof Player)) {
sender.sendMessage(toOldMessageFormat());
return;
}
Player player = (Player) sender;
try {
Object handle = Reflection.getHandle(player);
Object connection = Reflection.getField(handle.getClass(), "playerConnection")
.get(handle);
Reflection
.getMethod(connection.getClass(), "sendPacket", Reflection.getNMSClass("Packet"))
.invoke(connection, createChatPacket(jsonString));
} catch (IllegalArgumentException e) {
Bukkit.getLogger().log(Level.WARNING, "Argument could not be passed.", e);
} catch (IllegalAccessException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not access method.", e);
} catch (InstantiationException e) {
Bukkit.getLogger().log(Level.WARNING, "Underlying class is abstract.", e);
} catch (InvocationTargetException e) {
Bukkit.getLogger()
.log(Level.WARNING, "A error has occurred during invoking of method.", e);
} catch (NoSuchMethodException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not find method.", e);
} catch (ClassNotFoundException e) {
Bukkit.getLogger().log(Level.WARNING, "Could not find class.", e);
}
}
// The ChatSerializer's instance of Gson
private static Object nmsChatSerializerGsonInstance;
private static Method fromJsonMethod;
private Object createChatPacket(String json)
throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException {
if (nmsChatSerializerGsonInstance == null) {
// Find the field and its value, completely bypassing obfuscation
Class<?> chatSerializerClazz;
// Get the three parts of the version string (major version is currently unused)
// vX_Y_RZ
// X = major
// Y = minor
// Z = revision
final String version = Reflection.getVersion();
String[] split = version.substring(1, version.length() - 1)
.split("_"); // Remove trailing dot
//int majorVersion = Integer.parseInt(split[0]);
int minorVersion = Integer.parseInt(split[1]);
int revisionVersion = Integer.parseInt(split[2].substring(1)); // Substring to ignore R
if (minorVersion < 8 || minorVersion == 8 && revisionVersion == 1) {
chatSerializerClazz = Reflection.getNMSClass("ChatSerializer");
} else {
chatSerializerClazz = Reflection.getNMSClass("IChatBaseComponent$ChatSerializer");
}
if (chatSerializerClazz == null) {
throw new ClassNotFoundException("Can't find the ChatSerializer class");
}
for (Field declaredField : chatSerializerClazz.getDeclaredFields()) {
if (Modifier.isFinal(declaredField.getModifiers()) && Modifier
.isStatic(declaredField.getModifiers()) && declaredField.getType().getName()
.endsWith("Gson")) {
// We've found our field
declaredField.setAccessible(true);
nmsChatSerializerGsonInstance = declaredField.get(null);
fromJsonMethod = nmsChatSerializerGsonInstance.getClass()
.getMethod("fromJson", String.class, Class.class);
break;
}
}
}
// 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
// Of course, the implementation may change, but fuzzy matches might break with signature changes
Object serializedChatComponent = fromJsonMethod.invoke(nmsChatSerializerGsonInstance, json,
Reflection.getNMSClass("IChatBaseComponent"));
return nmsPacketPlayOutChatConstructor.newInstance(serializedChatComponent);
}
/**
* Sends this message to a command sender. If the sender is a player, they will receive the
* fully-fledged formatted display of this message. Otherwise, they will receive a version of
* this message with less formatting.
*
* @param sender The command sender who will receive the message.
* @see #toOldMessageFormat()
*/
public void send(CommandSender sender) {
send(sender, toJSONString());
}
/**
* Sends this message to multiple command senders.
*
* @param senders The command senders who will receive the message.
* @see #send(CommandSender)
*/
public void send(Iterable<? extends CommandSender> senders) {
String string = toJSONString();
for (CommandSender sender : senders) {
send(sender, string);
}
}
/**
* Convert this message to a human-readable string with limited formatting. This method is used
* to send this message to clients without JSON formatting support.
* <p>
* Serialization of this message by using this message will include (in this order for each
* message part):
* <ol>
* <li>The color of each message part.</li>
* <li>The applicable stylizations for each message part.</li>
* <li>The core text of the message part.</li>
* </ol>
* The primary omissions are tooltips and clickable actions. Consequently, this method should be used only as a last resort.
* </p>
* <p>
* Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.</p>
*
* @return A human-readable string representing limited formatting in addition to the core text
* of this message.
*/
public String toOldMessageFormat() {
StringBuilder result = new StringBuilder();
for (MessagePart part : this) {
result.append(part.color == null ? "" : part.color);
for (ChatColor formatSpecifier : part.styles) {
result.append(formatSpecifier);
}
result.append(part.text);
}
return result.toString();
}
private void onCurrent(Consumer<MessagePart> call) {
for (int i = index - 1; i < messageParts.size(); i++) {
call.accept(messageParts.get(i));
}
}
private MessagePart latest() {
return messageParts.get(messageParts.size() - 1);
}
private void onClick(String name, String data) {
onCurrent(m -> {
m.clickActionName = name;
m.clickActionData = data;
});
dirty = true;
}
private void onHover(String name, JsonRepresentedObject data) {
onCurrent(m -> {
m.hoverActionName = name;
m.hoverActionData = data;
});
dirty = true;
}
// Doc copied from interface
@Override
public Map<String, Object> serialize() {
HashMap<String, Object> map = new HashMap<>();
map.put("messageParts", messageParts);
// map.put("JSON", toJSONString());
return map;
}
/**
* Deserializes 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(Map<String, Object> serialized) {
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>
*/
@Override
@NotNull
public Iterator<MessagePart> iterator() {
return messageParts.iterator();
}
private static JsonParser _stringParser = new JsonParser();
/**
* Deserializes 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 parameterized JSON message.
*/
public static FancyMessage deserialize(String json) {
JsonObject serialized = _stringParser.parse(json).getAsJsonObject();
JsonArray extra = serialized.getAsJsonArray("extra"); // Get the extra component
FancyMessage returnVal = new FancyMessage();
returnVal.messageParts.clear();
for (JsonElement mPrt : extra) {
MessagePart component = new MessagePart();
JsonObject messagePart = mPrt.getAsJsonObject();
for (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
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 (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")) {
JsonObject object = entry.getValue().getAsJsonObject();
component.clickActionName = object.get("action").getAsString();
component.clickActionData = object.get("value").getAsString();
} else if (entry.getKey().equals("hoverEvent")) {
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 (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);
returnVal.index = returnVal.messageParts.size();
}
return returnVal;
}
}

Datei anzeigen

@ -1,156 +0,0 @@
package com.boydti.fawe.bukkit.chat;
import com.google.common.collect.BiMap;
import com.google.common.collect.ImmutableBiMap;
import com.google.gson.stream.JsonWriter;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.logging.Level;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.configuration.serialization.ConfigurationSerialization;
/**
* Internal class: Represents a component of a JSON-serializable {@link FancyMessage}.
*/
final class MessagePart implements JsonRepresentedObject, ConfigurationSerializable, Cloneable {
ChatColor color = ChatColor.WHITE;
ArrayList<ChatColor> styles = new ArrayList<>();
String clickActionName = null;
String clickActionData = null;
String hoverActionName = null;
JsonRepresentedObject hoverActionData = null;
TextualComponent text = null;
String insertionData = null;
ArrayList<JsonRepresentedObject> translationReplacements = new ArrayList<>();
MessagePart(final TextualComponent text) {
this.text = text;
}
MessagePart() {
this.text = null;
}
boolean hasText() {
return text != null;
}
@Override
@SuppressWarnings("unchecked")
public MessagePart clone() throws CloneNotSupportedException {
MessagePart obj = (MessagePart) super.clone();
obj.styles = (ArrayList<ChatColor>) styles.clone();
if (hoverActionData instanceof JsonString) {
obj.hoverActionData = new JsonString(((JsonString) hoverActionData).getValue());
} else if (hoverActionData instanceof FancyMessage) {
obj.hoverActionData = ((FancyMessage) hoverActionData).clone();
}
obj.translationReplacements = (ArrayList<JsonRepresentedObject>) translationReplacements.clone();
return obj;
}
static final BiMap<ChatColor, String> stylesToNames;
static {
ImmutableBiMap.Builder<ChatColor, String> builder = ImmutableBiMap.builder();
for (final ChatColor style : ChatColor.values()) {
if (!style.isFormat()) {
continue;
}
String styleName;
switch (style) {
case MAGIC:
styleName = "obfuscated";
break;
case UNDERLINE:
styleName = "underlined";
break;
default:
styleName = style.name().toLowerCase();
break;
}
builder.put(style, styleName);
}
stylesToNames = builder.build();
}
public void writeJson(JsonWriter json) {
try {
json.beginObject();
text.writeJson(json);
json.name("color").value(color.name().toLowerCase());
for (final ChatColor style : styles) {
json.name(stylesToNames.get(style)).value(true);
}
if (clickActionName != null && clickActionData != null) {
json.name("clickEvent")
.beginObject()
.name("action").value(clickActionName)
.name("value").value(clickActionData)
.endObject();
}
if (hoverActionName != null && hoverActionData != null) {
json.name("hoverEvent")
.beginObject()
.name("action").value(hoverActionName)
.name("value");
hoverActionData.writeJson(json);
json.endObject();
}
if (insertionData != null) {
json.name("insertion").value(insertionData);
}
if (translationReplacements.size() > 0 && text != null && TextualComponent.isTranslatableText(text)) {
json.name("with").beginArray();
for (JsonRepresentedObject obj : translationReplacements) {
obj.writeJson(json);
}
json.endArray();
}
json.endObject();
} catch (IOException e) {
Bukkit.getLogger().log(Level.WARNING, "A problem occured during writing of JSON string", e);
}
}
public Map<String, Object> serialize() {
HashMap<String, Object> map = new HashMap<>();
map.put("text", text);
map.put("styles", styles);
map.put("color", color.getChar());
map.put("hoverActionName", hoverActionName);
map.put("hoverActionData", hoverActionData);
map.put("clickActionName", clickActionName);
map.put("clickActionData", clickActionData);
map.put("insertion", insertionData);
map.put("translationReplacements", translationReplacements);
return map;
}
@SuppressWarnings("unchecked")
public static MessagePart deserialize(Map<String, Object> serialized) {
MessagePart part = new MessagePart((TextualComponent) serialized.get("text"));
part.styles = (ArrayList<ChatColor>) serialized.get("styles");
part.color = ChatColor.getByChar(serialized.get("color").toString());
part.hoverActionName = (String) serialized.get("hoverActionName");
part.hoverActionData = (JsonRepresentedObject) serialized.get("hoverActionData");
part.clickActionName = (String) serialized.get("clickActionName");
part.clickActionData = (String) serialized.get("clickActionData");
part.insertionData = (String) serialized.get("insertion");
part.translationReplacements = (ArrayList<JsonRepresentedObject>) serialized.get("translationReplacements");
return part;
}
static {
ConfigurationSerialization.registerClass(MessagePart.class);
}
}

Datei anzeigen

@ -26,7 +26,9 @@ import com.sk89q.worldedit.event.platform.Interaction;
import com.sk89q.worldedit.extension.platform.PlatformManager; import com.sk89q.worldedit.extension.platform.PlatformManager;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.util.formatting.text.TextComponent.Builder;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.net.URI;
import java.util.List; import java.util.List;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -59,7 +61,7 @@ public class CFIPacketListener implements Listener {
// Direct digging to the virtual world // Direct digging to the virtual world
registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() { registerBlockEvent(PacketType.Play.Client.BLOCK_DIG, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
@Override @Override
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) { public void run(Builder event, URI gen, String pt) {
try { try {
Player plr = event.getPlayer(); Player plr = event.getPlayer();
BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint()); BlockVector3 realPos = pt.add(gen.getOrigin().toBlockPoint());
@ -75,7 +77,7 @@ public class CFIPacketListener implements Listener {
// Direct placing to the virtual world // Direct placing to the virtual world
RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() { RunnableVal3<PacketEvent, VirtualWorld, BlockVector3> placeTask = new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
@Override @Override
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) { public void run(Builder event, URI gen, String pt) {
try { try {
Player plr = event.getPlayer(); Player plr = event.getPlayer();
List<EnumWrappers.Hand> hands = event.getPacket().getHands().getValues(); List<EnumWrappers.Hand> hands = event.getPacket().getHands().getValues();
@ -112,7 +114,7 @@ public class CFIPacketListener implements Listener {
// Cancel block change packets where the real world overlaps with the virtual one // Cancel block change packets where the real world overlaps with the virtual one
registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() { registerBlockEvent(PacketType.Play.Server.BLOCK_CHANGE, false, new RunnableVal3<PacketEvent, VirtualWorld, BlockVector3>() {
@Override @Override
public void run(PacketEvent event, VirtualWorld gen, BlockVector3 pt) { public void run(Builder event, URI gen, String pt) {
// Do nothing // Do nothing
} }
}); });

Datei anzeigen

@ -3,7 +3,7 @@ package com.boydti.fawe.bukkit.regions;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Perm; import com.boydti.fawe.util.Permission;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.bukkit.BukkitAdapter;
import org.bukkit.Chunk; import org.bukkit.Chunk;
@ -30,7 +30,8 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = fp.parent;
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
final World world = player.getWorld(); final World world = player.getWorld();
RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
@ -40,7 +41,7 @@ public class FactionsOneFeature extends BukkitMaskManager implements Listener {
if (this.isAdded(locs, world, player, perm, type)) { if (this.isAdded(locs, world, player, perm, type)) {
boolean hasPerm = true; boolean hasPerm = true;
while (hasPerm && (count > 0)) { while (hasPerm && count > 0) {
count--; count--;
hasPerm = false; hasPerm = false;

Datei anzeigen

@ -4,7 +4,7 @@ import com.boydti.fawe.bukkit.FaweBukkit;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.RegionWrapper; import com.boydti.fawe.object.RegionWrapper;
import com.boydti.fawe.regions.FaweMask; import com.boydti.fawe.regions.FaweMask;
import com.boydti.fawe.util.Perm; import com.boydti.fawe.util.Permission;
import com.massivecraft.factions.Board; import com.massivecraft.factions.Board;
import com.massivecraft.factions.FLocation; import com.massivecraft.factions.FLocation;
import com.massivecraft.factions.Faction; import com.massivecraft.factions.Faction;
@ -28,7 +28,8 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) { public FaweMask getMask(final FawePlayer<Player> fp, MaskType type) {
final Player player = fp.parent; final Player player = fp.parent;
final Chunk chunk = player.getLocation().getChunk(); final Chunk chunk = player.getLocation().getChunk();
final boolean perm = Perm.hasPermission(FawePlayer.wrap(player), "fawe.factions.wilderness"); final boolean perm = Permission
.hasPermission(fp.toWorldEditPlayer(), "fawe.factions.wilderness");
final World world = player.getWorld(); final World world = player.getWorld();
RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ()); RegionWrapper locs = new RegionWrapper(chunk.getX(), chunk.getX(), chunk.getZ(), chunk.getZ());
@ -38,7 +39,7 @@ public class FactionsUUIDFeature extends BukkitMaskManager implements Listener {
if (this.isAdded(locs, world, player, perm, type)) { if (this.isAdded(locs, world, player, perm, type)) {
boolean hasPerm = true; boolean hasPerm = true;
while (hasPerm && (count > 0)) { while (hasPerm && count > 0) {
count--; count--;
hasPerm = false; hasPerm = false;

Datei anzeigen

@ -1,15 +1,15 @@
package com.boydti.fawe.bukkit.wrapper.state; package com.boydti.fawe.bukkit.wrapper.state;
import com.boydti.fawe.bukkit.chat.FancyMessage;
import com.boydti.fawe.bukkit.wrapper.AsyncBlock; import com.boydti.fawe.bukkit.wrapper.AsyncBlock;
import com.boydti.fawe.bukkit.wrapper.AsyncBlockState; import com.boydti.fawe.bukkit.wrapper.AsyncBlockState;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.StringTag; import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.serializer.gson.GsonComponentSerializer;
import com.sk89q.worldedit.util.formatting.text.serializer.legacy.LegacyComponentSerializer;
import java.util.Map; import java.util.Map;
import net.minecraft.server.v1_14_R1.TileEntitySign;
import org.bukkit.DyeColor; import org.bukkit.DyeColor;
import org.bukkit.block.Sign; import org.bukkit.block.Sign;
import org.bukkit.persistence.PersistentDataContainer; import org.bukkit.persistence.PersistentDataContainer;
@ -37,18 +37,18 @@ public class AsyncSign extends AsyncBlockState implements Sign {
private String fromJson(String jsonInput) { private String fromJson(String jsonInput) {
if (jsonInput == null || jsonInput.isEmpty()) return ""; if (jsonInput == null || jsonInput.isEmpty()) return "";
return FancyMessage.deserialize(jsonInput).toOldMessageFormat(); return GsonComponentSerializer.INSTANCE.deserialize(jsonInput).toString();
} }
private String toJson(String oldInput) { private String toJson(String oldInput) {
if (oldInput == null || oldInput.isEmpty()) return ""; if (oldInput == null || oldInput.isEmpty()) return "";
return new FancyMessage("").color(oldInput).toJSONString(); return LegacyComponentSerializer.INSTANCE.serialize(TextComponent.of(oldInput));
} }
@Override @Override
public String getLine(int index) throws IndexOutOfBoundsException { public String getLine(int index) throws IndexOutOfBoundsException {
CompoundTag nbt = getNbtData(); CompoundTag nbt = getNbtData();
return nbt == null ? null : fromJson(nbt.getString("Text" + (index + 1))); return nbt == null ? "" : fromJson(nbt.getString("Text" + (index + 1)));
} }
@Override @Override
@ -80,7 +80,7 @@ public class AsyncSign extends AsyncBlockState implements Sign {
CompoundTag nbt = getNbtData(); CompoundTag nbt = getNbtData();
if (nbt != null) { if (nbt != null) {
String color = nbt.getString("Color").toUpperCase(); String color = nbt.getString("Color").toUpperCase();
if (color != null) return DyeColor.valueOf(color); return DyeColor.valueOf(color);
} }
return DyeColor.BLACK; return DyeColor.BLACK;
} }

Datei anzeigen

@ -7,27 +7,39 @@ import com.boydti.fawe.config.Settings;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.brush.visualization.VisualQueue; import com.boydti.fawe.object.brush.visualization.VisualQueue;
import com.boydti.fawe.regions.general.plot.PlotSquaredFeature; import com.boydti.fawe.regions.general.plot.PlotSquaredFeature;
import com.boydti.fawe.util.*; import com.boydti.fawe.util.CachedTextureUtil;
import com.boydti.fawe.util.chat.ChatManager; import com.boydti.fawe.util.CleanTextureUtil;
import com.boydti.fawe.util.chat.PlainChatManager; import com.boydti.fawe.util.FaweTimer;
import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.RandomTextureUtil;
import com.boydti.fawe.util.TaskManager;
import com.boydti.fawe.util.TextureUtil;
import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.extension.factory.DefaultTransformParser; import com.sk89q.worldedit.extension.factory.DefaultTransformParser;
import com.sk89q.worldedit.extension.platform.Actor; import com.sk89q.worldedit.extension.platform.Actor;
import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.session.request.Request;
import java.io.BufferedReader;
import javax.annotation.Nullable; import java.io.File;
import javax.management.InstanceAlreadyExistsException; import java.io.FileNotFoundException;
import javax.management.NotificationEmitter; import java.io.IOException;
import java.io.*; import java.io.InputStream;
import java.io.InputStreamReader;
import java.lang.management.ManagementFactory; import java.lang.management.ManagementFactory;
import java.lang.management.MemoryMXBean; import java.lang.management.MemoryMXBean;
import java.lang.management.MemoryPoolMXBean; import java.lang.management.MemoryPoolMXBean;
import java.lang.management.MemoryUsage; import java.lang.management.MemoryUsage;
import java.util.*; import java.util.Collection;
import java.util.Date;
import java.util.List;
import java.util.Objects;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull; import javax.management.InstanceAlreadyExistsException;
import javax.management.NotificationEmitter;
/** /**
* [ WorldEdit action] * [ WorldEdit action]
@ -80,7 +92,6 @@ public class Fawe {
private VisualQueue visualQueue; private VisualQueue visualQueue;
private TextureUtil textures; private TextureUtil textures;
private DefaultTransformParser transformParser; private DefaultTransformParser transformParser;
private ChatManager chatManager = new PlainChatManager();
private QueueHandler queueHandler; private QueueHandler queueHandler;
@ -202,15 +213,6 @@ public class Fawe {
return queueHandler; return queueHandler;
} }
public ChatManager getChatManager() {
return chatManager;
}
public void setChatManager(ChatManager chatManager) {
checkNotNull(chatManager);
this.chatManager = chatManager;
}
public DefaultTransformParser getTransformParser() { public DefaultTransformParser getTransformParser() {
return transformParser; return transformParser;
} }

Datei anzeigen

@ -16,8 +16,10 @@ import java.util.UUID;
* Interface for setting blocks * Interface for setting blocks
*/ */
public interface IChunkSet extends IBlocks, OutputExtent { public interface IChunkSet extends IBlocks, OutputExtent {
@Override
boolean setBiome(int x, int y, int z, BiomeType biome); boolean setBiome(int x, int y, int z, BiomeType biome);
@Override
boolean setBlock(int x, int y, int z, BlockStateHolder holder); boolean setBlock(int x, int y, int z, BlockStateHolder holder);
boolean isEmpty(); boolean isEmpty();

Datei anzeigen

@ -59,11 +59,13 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
*/ */
<T extends Future<T>> T submit(IChunk<T> chunk); <T extends Future<T>> T submit(IChunk<T> chunk);
@Override
default boolean setBlock(final int x, final int y, final int z, final BlockStateHolder state) { default boolean setBlock(final int x, final int y, final int z, final BlockStateHolder state) {
final IChunk chunk = getCachedChunk(x >> 4, z >> 4); final IChunk chunk = getCachedChunk(x >> 4, z >> 4);
return chunk.setBlock(x & 15, y, z & 15, state); return chunk.setBlock(x & 15, y, z & 15, state);
} }
@Override
default boolean setBiome(final int x, final int y, final int z, final BiomeType biome) { default boolean setBiome(final int x, final int y, final int z, final BiomeType biome) {
final IChunk chunk = getCachedChunk(x >> 4, z >> 4); final IChunk chunk = getCachedChunk(x >> 4, z >> 4);
return chunk.setBiome(x & 15, y, z & 15, biome); return chunk.setBiome(x & 15, y, z & 15, biome);
@ -127,4 +129,4 @@ public interface IQueueExtent extends Flushable, Trimable, Extent {
boolean isEmpty(); boolean isEmpty();
void sendChunk(int chunkX, int chunkZ, int bitMask); void sendChunk(int chunkX, int chunkZ, int bitMask);
} }

Datei anzeigen

@ -47,6 +47,7 @@ import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.util.formatting.text.TextComponent;
import com.sk89q.worldedit.util.formatting.text.TextComponent.Builder; import com.sk89q.worldedit.util.formatting.text.TextComponent.Builder;
import com.sk89q.worldedit.util.formatting.text.event.ClickEvent; import com.sk89q.worldedit.util.formatting.text.event.ClickEvent;
import com.sk89q.worldedit.util.formatting.text.event.HoverEvent;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
@ -354,7 +355,7 @@ public class CFICommands {
floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly);
main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly);
smooth(fp, 1, 8, image, mask, disableWhiteOnly); smooth(fp, 1, 8, image, mask, disableWhiteOnly);
TextComponent.of("Added snow!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Added snow!"));
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); component(fp);
} }
@ -383,17 +384,28 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws EmptyClipboardException, InputParseException, FileNotFoundException { public void paletteblocks(FawePlayer fp, Player player, LocalSession session, @Arg(name = "arg", desc = "String", def = "") String arg) throws EmptyClipboardException, InputParseException, FileNotFoundException {
if (arg == null) { if (arg == null) {
TextComponent.of("What blocks do you want to color with?").append(newline()) TextComponent build = TextComponent.builder("What blocks do you want to color with?")
.text("[All]").cmdTip(alias() + " PaletteBlocks *").text(" - All available blocks") .append(newline())
.append(newline()) .append(TextComponent.of("[All]")
.text("[Clipboard]").cmdTip(alias() + " PaletteBlocks #clipboard").text(" - The blocks in your clipboard") .clickEvent(ClickEvent.runCommand("/cfi PaletteBlocks *")))
.append(newline()) .append(" - All available blocks")
.text("[List]").suggestTip(alias() + " PaletteBlocks stone,gravel").text(" - A comma separated list of blocks") .append(newline())
.append(newline()) .append(TextComponent.of("[Clipboard]")
.text("[Complexity]").cmdTip(alias() + " Complexity").text(" - Block textures within a complexity range") .clickEvent(ClickEvent.runCommand("/cfi PaletteBlocks #clipboard")))
.append(newline()) .append(" - The blocks in your clipboard")
.text("< [Back]").cmdTip(alias() + " " + Commands.getAlias(CFICommands.class, "coloring")) .append(newline())
.send(fp); .append(TextComponent.of("[List]")
.clickEvent(ClickEvent.runCommand("/cfi PaletteBlocks stone,gravel")))
.append(" - A comma separated list of blocks")
.append(newline())
.append(TextComponent.of("[Complexity]")
.clickEvent(ClickEvent.runCommand("/cfi Complexity")))
.append(" - Block textures within a complexity range")
.append(newline())
.append(TextComponent.of("< [Back]").clickEvent(ClickEvent
.runCommand("/cfi " + Commands.getAlias(CFICommands.class, "coloring"))))
.build();
fp.toWorldEditPlayer().print(build);
return; return;
} }
HeightMapMCAGenerator generator = assertSettings(fp).getGenerator(); HeightMapMCAGenerator generator = assertSettings(fp).getGenerator();
@ -505,7 +517,7 @@ public class CFICommands {
} else { } else {
gen.addSchems(load(imageMask), mask, multi.getHolders(), rarity, distance, rotate); gen.addSchems(load(imageMask), mask, multi.getHolders(), rarity, distance, rotate);
} }
TextComponent.of("Added schematics!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Added schematics!"));
populate(fp); populate(fp);
} }
@ -527,7 +539,7 @@ public class CFICommands {
} else { } else {
gen.setBiome(biome); gen.setBiome(biome);
} }
TextComponent.of("Set biome!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set biome!"));
assertSettings(fp).resetComponent(); assertSettings(fp).resetComponent();
component(fp); component(fp);
} }
@ -539,7 +551,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void caves(FawePlayer fp) throws WorldEditException { public void caves(FawePlayer fp) throws WorldEditException {
assertSettings(fp).getGenerator().addCaves(); assertSettings(fp).getGenerator().addCaves();
TextComponent.of("Added caves!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Added caves!"));
populate(fp); populate(fp);
} }
@ -580,7 +592,6 @@ public class CFICommands {
gen.setHeights(Integer.parseInt(arg)); gen.setHeights(Integer.parseInt(arg));
} }
fp.toWorldEditPlayer().print("Set Height!"); fp.toWorldEditPlayer().print("Set Height!");
TextComponent.of("Set height!").send(fp);
component(fp); component(fp);
} }
@ -592,7 +603,8 @@ public class CFICommands {
public void waterId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { public void waterId(FawePlayer fp, BlockStateHolder block) throws WorldEditException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.getGenerator().setWaterId(block.getBlockType().getInternalId()); settings.getGenerator().setWaterId(block.getBlockType().getInternalId());
TextComponent.of("Set water id!").send(fp);
fp.toWorldEditPlayer().print("Set water id!");
settings.resetComponent(); settings.resetComponent();
component(fp); component(fp);
} }
@ -606,7 +618,7 @@ public class CFICommands {
public void baseId(FawePlayer fp, BlockStateHolder block) throws WorldEditException { public void baseId(FawePlayer fp, BlockStateHolder block) throws WorldEditException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBedrockId(block.getBlockType().getInternalId()); settings.getGenerator().setBedrockId(block.getBlockType().getInternalId());
TextComponent.of("Set base id!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set base id!"));
settings.resetComponent(); settings.resetComponent();
component(fp); component(fp);
} }
@ -620,7 +632,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void worldthickness(FawePlayer fp, int height) throws WorldEditException { public void worldthickness(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setWorldThickness(height); assertSettings(fp).getGenerator().setWorldThickness(height);
TextComponent.of("Set world thickness!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set world thickness!"));
component(fp); component(fp);
} }
@ -633,7 +645,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void floorthickness(FawePlayer fp, int height) throws WorldEditException { public void floorthickness(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setFloorThickness(height); assertSettings(fp).getGenerator().setFloorThickness(height);
TextComponent.of("Set floor thickness!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set floor thickness!"));
component(fp); component(fp);
} }
@ -645,7 +657,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void update(FawePlayer fp) throws WorldEditException { public void update(FawePlayer fp) throws WorldEditException {
assertSettings(fp).getGenerator().update(); assertSettings(fp).getGenerator().update();
TextComponent.of("Chunks refreshed!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Chunks refreshed!"));
mainMenu(fp); mainMenu(fp);
} }
@ -657,7 +669,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void tp(FawePlayer fp) throws WorldEditException { public void tp(FawePlayer fp) throws WorldEditException {
HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); HeightMapMCAGenerator gen = assertSettings(fp).getGenerator();
TextComponent.of("Teleporting...").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Teleporting..."));
Vector3 origin = gen.getOrigin(); Vector3 origin = gen.getOrigin();
Player player = fp.getPlayer(); Player player = fp.getPlayer();
player.setPosition(origin.subtract(16, 0, 16)); player.setPosition(origin.subtract(16, 0, 16));
@ -675,7 +687,7 @@ public class CFICommands {
@CommandPermissions("worldedit.anvil.cfi") @CommandPermissions("worldedit.anvil.cfi")
public void waterheight(FawePlayer fp, int height) throws WorldEditException { public void waterheight(FawePlayer fp, int height) throws WorldEditException {
assertSettings(fp).getGenerator().setWaterHeight(height); assertSettings(fp).getGenerator().setWaterHeight(height);
TextComponent.of("Set water height!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set water height!"));
component(fp); component(fp);
} }
@ -689,7 +701,7 @@ public class CFICommands {
public void glass(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { public void glass(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.getGenerator().setColorWithGlass(load(image)); settings.getGenerator().setColorWithGlass(load(image));
TextComponent.of("Set color with glass!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set color with glass!"));
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -714,7 +726,7 @@ public class CFICommands {
gen.setColor(load(image)); gen.setColor(load(image));
} }
settings.resetColoring(); settings.resetColoring();
TextComponent.of("Set color with blocks!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks!"));
mainMenu(fp); mainMenu(fp);
} }
@ -730,7 +742,7 @@ public class CFICommands {
public void blockbiome(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { public void blockbiome(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly); settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly);
TextComponent.of("Set color with blocks and biomes!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set color with blocks and biomes!"));
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -746,7 +758,7 @@ public class CFICommands {
public void biomecolor(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException { public void biomecolor(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri imageMask, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) throws WorldEditException {
CFISettings settings = assertSettings(fp); CFISettings settings = assertSettings(fp);
settings.getGenerator().setBiomeColor(load(image)); settings.getGenerator().setBiomeColor(load(image));
TextComponent.of("Set color with biomes!").send(fp); fp.toWorldEditPlayer().print(TextComponent.of("Set color with biomes!"));
settings.resetColoring(); settings.resetColoring();
mainMenu(fp); mainMenu(fp);
} }
@ -811,13 +823,12 @@ public class CFICommands {
.append(newline()); .append(newline());
if (settings.image != null) { if (settings.image != null) {
StringBuilder colorArgs = new StringBuilder(); StringBuilder colorArgs = new StringBuilder(" " + settings.imageArg);
colorArgs.append(" " + settings.imageArg);
if (settings.imageMask != null) { if (settings.imageMask != null) {
colorArgs.append(" " + settings.imageMaskArg); colorArgs.append(" ").append(settings.imageMaskArg);
} }
if (settings.mask != null) { if (settings.mask != null) {
colorArgs.append(" " + settings.maskArg); colorArgs.append(" ").append(settings.maskArg);
} }
if (!settings.whiteOnly) { if (!settings.whiteOnly) {
colorArgs.append(" -w"); colorArgs.append(" -w");
@ -854,14 +865,26 @@ public class CFICommands {
settings.maskArg = mask != null ? split[index++] : null; settings.maskArg = mask != null ? split[index++] : null;
settings.whiteOnly = !disableWhiteOnly; settings.whiteOnly = !disableWhiteOnly;
StringBuilder cmd = new StringBuilder(alias() + " mask "); StringBuilder cmd = new StringBuilder("/cfi mask ");
TextComponent.of(">> Current Settings <<").append(newline()) String s = "/cfi mask http://";
.text("Image Mask ").text("[" + settings.imageMaskArg + "]").suggestTip(cmd + "http://") String s1 = "/cfi mask <mask>";
String s2 = alias() + " " + settings.getCategory();
TextComponent build = TextComponent.builder(">> Current Settings <<")
.append(newline()) .append(newline())
.text("WorldEdit Mask ").text("[" + settings.maskArg + "]").suggestTip(cmd + "<mask>") .append("Image Mask ").append(
TextComponent.of("[" + settings.imageMaskArg + "]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s)))
.clickEvent(ClickEvent.suggestCommand("/cfi mask http://")))
.append(newline()) .append(newline())
.text("< [Back]").cmdTip(alias() + " " + settings.getCategory()).send(fp); .append("WorldEdit Mask ").append(TextComponent.of("[" + settings.maskArg + "]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s1)))
.clickEvent(ClickEvent.suggestCommand(s1)))
.append(newline())
.append(
TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(s2)))
.clickEvent(ClickEvent.runCommand(s2))).build();
fp.toWorldEditPlayer().print(build);
} }
@Command( @Command(
@ -881,10 +904,17 @@ public class CFICommands {
if (pattern != null) { if (pattern != null) {
settings.getCategory().accept(fp); settings.getCategory().accept(fp);
} else { } else {
TextComponent.of(">> Current Settings <<").append(newline()) String s = cmd + " stone";
.text("Pattern ").text("[Click Here]").suggestTip(cmd + " stone") String s1 = alias() + " " + settings.getCategory();
.append(newline()) TextComponent build = TextComponent.builder(">> Current Settings <<").append(newline())
.text("< [Back]").cmdTip(alias() + " " + settings.getCategory()).send(fp); .append("Pattern ").append(TextComponent.of("[Click Here]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s)))
.clickEvent(ClickEvent.suggestCommand(s)))
.append(newline())
.append(TextComponent.of("< [Back]")
.hoverEvent(HoverEvent.showText(TextComponent.of(s1)))
.clickEvent(ClickEvent.runCommand(s1))).build();
fp.toWorldEditPlayer().print(build);
} }
} }
@ -917,13 +947,12 @@ public class CFICommands {
settings.image = image; settings.image = image;
settings.imageArg = image != null ? split[index++] : null; settings.imageArg = image != null ? split[index++] : null;
StringBuilder cmd = new StringBuilder(alias() + " image ");
if (image == null) { if (image == null) {
TextComponent build = TextComponent.builder("Please provide an image:") TextComponent build = TextComponent.builder("Please provide an image:")
.append(newline()) .append(newline())
.append("From a URL: ").append("[Click Here]")//TODO .suggestTip(cmd + "http://") .append("From a URL: ").append(TextComponent.of("[Click Here]").clickEvent(ClickEvent.suggestCommand("/cfi image http://")))
.append(newline()) .append(newline())
.append("From a file: ").append("[Click Here]")//TODO .suggestTip(cmd + "file://") .append("From a file: ").append(TextComponent.of("[Click Here]").clickEvent(ClickEvent.suggestCommand("/cfi image file://")))
.build(); .build();
fp.toWorldEditPlayer().print(build); fp.toWorldEditPlayer().print(build);
} else { } else {
@ -994,50 +1023,76 @@ public class CFICommands {
String snow = Commands.getAlias(CFICommands.class, "snow"); String snow = Commands.getAlias(CFICommands.class, "snow");
//TODO //TODO
// Message msg = TextComponent.builder(">> Current Settings <<").append(newline()) @NonNull Builder msg = TextComponent.builder(">> Current Settings <<").append(newline())
// .append("Mask ").append("[" + mask + "]").cmdTip(alias() + " mask") .append("Mask ").append(TextComponent.of("[" + mask + "]")
// .append(newline()) .hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " mask")))
// .append("Pattern ").append("[" + pattern + "]").cmdTip(alias() + " pattern") .clickEvent(ClickEvent.runCommand(alias() + " mask")))
// .append(newline()) .append(newline())
// .append(newline()) .append("Pattern ").append(TextComponent.of("[" + pattern + "]")
// .append(">> Components <<") .hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " pattern")))
// .append(newline()) .clickEvent(ClickEvent.runCommand(alias() + " pattern")))
// .append("[Height]").suggestTip(alias() + " " + alias("height") + " 120").text(" - Terrain height for whole map") .append(newline())
// .append(newline()) .append(newline())
// .text("[WaterHeight]").suggestTip(alias() + " " + alias("waterheight") + " 60").text(" - Sea level for whole map") .append(">> Components <<")
// .append(newline()) .append(newline())
// .text("[FloorThickness]").suggestTip(alias() + " " + alias("floorthickness") + " 60").text(" - Floor thickness of entire map") .append(TextComponent.of("[Height]")
// .append(newline()) .hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("height") + " 120")))
// .text("[WorldThickness]").suggestTip(alias() + " " + alias("worldthickness") + " 60").text(" - World thickness of entire map") .clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("height") + " 120"))).append(" - Terrain height for whole map")
// .append(newline()) .append(newline())
// .text("[Snow]").suggestTip(alias() + " " + alias("snow") + maskArgs).text(" - Set snow in the masked areas") .append(TextComponent.of("[WaterHeight]")
// .append(newline()); .hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("waterheight") + " 60")))
// .clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("waterheight") + " 60"))).append(" - Sea level for whole map")
// if (pattern != null) { .append(newline())
// String disabled = "You must specify a pattern"; .append(TextComponent.of("[FloorThickness]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("floorthickness") + " 60")))
// msg .clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("floorthickness") + " 60"))).append(" - Floor thickness of entire map")
// .text("[&cWaterId]").tooltip(disabled).append(newline()) .append(newline())
// .text("[&cBedrockId]").tooltip(disabled).append(newline()) .append(TextComponent.of("[WorldThickness]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("worldthickness") + " 60")))
// .text("[&cFloor]").tooltip(disabled).append(newline()) .clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("worldthickness") + " 60"))).append(" - World thickness of entire map")
// .text("[&cMain]").tooltip(disabled).append(newline()) .append(newline())
// .text("[&cColumn]").tooltip(disabled).append(newline()) .append(TextComponent.of("[Snow]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " " + alias("snow") + maskArgs)))
// .text("[&cOverlay]").tooltip(disabled).append(newline()); .clickEvent(ClickEvent.suggestCommand(alias() + " " + alias("snow") + maskArgs))).append(" - Set snow in the masked areas")
// } else { .append(newline());
// StringBuilder compArgs = new StringBuilder();
// compArgs.append(" " + settings.patternArg + maskArgs); if (pattern != null) {
// String disabled = "You must specify a pattern";
// msg msg.append(TextComponent.of("[&cWaterId]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline())
// .text("[WaterId]").cmdTip(alias() + " waterId " + pattern).text(" - Water id for whole map").append(newline()) .append(TextComponent.of("[&cBedrockId]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline()).append(newline())
// .text("[BedrockId]").cmdTip(alias() + " baseId " + pattern).text(" - Bedrock id for whole map").append(newline()) .append(TextComponent.of("[&cFloor]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline()).append(newline())
// .text("[Floor]").cmdTip(alias() + " floor" + compArgs).text(" - Set the floor in the masked areas").append(newline()) .append(TextComponent.of("[&cMain]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline()).append(newline())
// .text("[Main]").cmdTip(alias() + " main" + compArgs).text(" - Set the main block in the masked areas").append(newline()) .append(TextComponent.of("[&cColumn]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline()).append(newline())
// .text("[Column]").cmdTip(alias() + " column" + compArgs).text(" - Set the columns in the masked areas").append(newline()) .append(TextComponent.of("[&cOverlay]").hoverEvent(HoverEvent.showText(TextComponent.of(disabled)))).append(newline()).append(newline());
// .text("[Overlay]").cmdTip(alias() + " overlay" + compArgs).text(" - Set the overlay in the masked areas").append(newline()); } else {
// } StringBuilder compArgs = new StringBuilder();
// compArgs.append(" " + settings.patternArg + maskArgs);
// msg.append(newline())
// .text("< [Back]").cmdTip(alias()) msg
// .send(fp); .append(TextComponent.of("[WaterId]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " waterId " + pattern)))
.clickEvent(ClickEvent.runCommand(alias() + " waterId " + pattern)))
.append(" - Water id for whole map")
.append(newline())
.append(TextComponent.of("[BedrockId]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " baseId " + pattern)))
.clickEvent(ClickEvent.runCommand(alias() + " baseId " + pattern)))
.append(TextComponent.of(" - Bedrock id for whole map"))
.append(newline())
.append(TextComponent.of("[Floor]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " floor " + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " floor " + compArgs)))
.append(TextComponent.of(" - Set the floor in the masked areas")).append(newline())
.append(TextComponent.of("[Main]")
.hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " main " + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " main " + compArgs)))
.append(TextComponent.of(" - Set the main block in the masked areas")).append(newline())
.append(TextComponent.of("[Column]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " column" + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " column" + compArgs))).append(" - Set the columns in the masked areas").append(newline())
.append(TextComponent.of("[Overlay]").hoverEvent(HoverEvent.showText(TextComponent.of(alias() + " overlay" + compArgs)))
.clickEvent(ClickEvent.runCommand(alias() + " overlay" + compArgs))).append(" - Set the overlay in the masked areas").append(newline());
}
msg.append(newline())
.append(TextComponent.of("< [Back]").hoverEvent(HoverEvent.showText(TextComponent.of(alias()))).clickEvent(ClickEvent.runCommand(alias())));
fp.toWorldEditPlayer().print(msg.build());
} }
private static CFISettings assertSettings(FawePlayer fp) { private static CFISettings assertSettings(FawePlayer fp) {

Datei anzeigen

@ -10,7 +10,6 @@ import com.boydti.fawe.object.task.AsyncNotifyQueue;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TaskManager;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -50,7 +49,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
this(FaweAPI.getWorld(world)); this(FaweAPI.getWorld(world));
} }
public RollbackDatabase(final World world) throws SQLException, ClassNotFoundException { public RollbackDatabase(World world) throws SQLException, ClassNotFoundException {
this.prefix = ""; this.prefix = "";
this.worldName = world.getName(); this.worldName = world.getName();
this.world = world; this.world = world;
@ -96,7 +95,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
} }
} }
public void delete(final UUID uuid, final int id) { public void delete(UUID uuid, int id) {
addTask(new Runnable() { addTask(new Runnable() {
@Override @Override
public void run() { public void run() {
@ -127,12 +126,13 @@ public class RollbackDatabase extends AsyncNotifyQueue {
}); });
} }
public void getPotentialEdits(final UUID uuid, final long minTime, final BlockVector3 pos1, final BlockVector3 pos2, final RunnableVal<DiskStorageHistory> onEach, final Runnable whenDone, final boolean delete, final boolean ascending) { public void getPotentialEdits(UUID uuid, long minTime, BlockVector3 pos1, BlockVector3 pos2, RunnableVal<DiskStorageHistory> onEach, Runnable whenDone, boolean delete, boolean ascending) {
final World world = FaweAPI.getWorld(this.worldName); final World world = FaweAPI.getWorld(this.worldName);
addTask(new Runnable() { addTask(new Runnable() {
@Override @Override
public void run() { public void run() {
String stmtStr = ascending ? (uuid == null ? GET_EDITS_ASC : GET_EDITS_USER_ASC) : (uuid == null ? GET_EDITS : GET_EDITS_USER); String stmtStr = ascending ? uuid == null ? GET_EDITS_ASC : GET_EDITS_USER_ASC :
uuid == null ? GET_EDITS : GET_EDITS_USER;
try (PreparedStatement stmt = connection.prepareStatement(stmtStr)) { try (PreparedStatement stmt = connection.prepareStatement(stmtStr)) {
stmt.setInt(1, pos1.getBlockX()); stmt.setInt(1, pos1.getBlockX());
stmt.setInt(2, pos2.getBlockX()); stmt.setInt(2, pos2.getBlockX());
@ -243,7 +243,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
} }
commit(); commit();
return true; return true;
} catch (final Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return false; return false;
@ -258,7 +258,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
connection.commit(); connection.commit();
connection.setAutoCommit(true); connection.setAutoCommit(true);
} }
} catch (final SQLException e) { } catch (SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -270,11 +270,11 @@ public class RollbackDatabase extends AsyncNotifyQueue {
if (!Fawe.imp().getDirectory().exists()) { if (!Fawe.imp().getDirectory().exists()) {
Fawe.imp().getDirectory().mkdirs(); Fawe.imp().getDirectory().mkdirs();
} }
if (!(dbLocation.exists())) { if (!dbLocation.exists()) {
try { try {
dbLocation.getParentFile().mkdirs(); dbLocation.getParentFile().mkdirs();
dbLocation.createNewFile(); dbLocation.createNewFile();
} catch (final IOException e) { } catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
Fawe.debug("&cUnable to create database!"); Fawe.debug("&cUnable to create database!");
} }
@ -299,9 +299,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
if (connection == null) { if (connection == null) {
try { try {
forceConnection(); forceConnection();
} catch (final ClassNotFoundException e) { } catch (ClassNotFoundException | SQLException e) {
e.printStackTrace();
} catch (final SQLException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -312,7 +310,7 @@ public class RollbackDatabase extends AsyncNotifyQueue {
* Closes the connection with the database * Closes the connection with the database
* *
* @return true if successful * @return true if successful
* @throws java.sql.SQLException if the connection cannot be closed * @throws SQLException if the connection cannot be closed
*/ */
public boolean closeConnection() throws SQLException { public boolean closeConnection() throws SQLException {
if (connection == null) { if (connection == null) {
@ -332,12 +330,12 @@ public class RollbackDatabase extends AsyncNotifyQueue {
* Checks if a connection is open with the database * Checks if a connection is open with the database
* *
* @return true if the connection is open * @return true if the connection is open
* @throws java.sql.SQLException if the connection cannot be checked * @throws SQLException if the connection cannot be checked
*/ */
public boolean checkConnection() { public boolean checkConnection() {
try { try {
return (connection != null) && !connection.isClosed(); return connection != null && !connection.isClosed();
} catch (final SQLException e) { } catch (SQLException e) {
return false; return false;
} }
} }

Datei anzeigen

@ -108,7 +108,7 @@ public abstract class FawePlayer<T> extends Metadatable {
} }
@Deprecated @Deprecated
public FawePlayer(final T parent) { public FawePlayer(T parent) {
this.parent = parent; this.parent = parent;
Fawe.get().register(this); Fawe.get().register(this);
if (Settings.IMP.CLIPBOARD.USE_DISK) { if (Settings.IMP.CLIPBOARD.USE_DISK) {
@ -247,7 +247,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* Queue an action to run async * Queue an action to run async
* @param run * @param run
*/ */
public void queueAction(final Runnable run) { public void queueAction(Runnable run) {
runAction(run, false, true); runAction(run, false, true);
} }
@ -288,7 +288,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* @param async * @param async
* @return false if the task was ran or queued * @return false if the task was ran or queued
*/ */
public boolean runAction(final Runnable ifFree, boolean checkFree, boolean async) { public boolean runAction(Runnable ifFree, boolean checkFree, boolean async) {
if (checkFree) { if (checkFree) {
if (runningCount.get() != 0) return false; if (runningCount.get() != 0) return false;
} }
@ -363,7 +363,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* *
* @param world * @param world
*/ */
public void loadSessionsFromDisk(final World world) { public void loadSessionsFromDisk(World world) {
if (world == null) { if (world == null) {
return; return;
} }
@ -417,14 +417,14 @@ public abstract class FawePlayer<T> extends Metadatable {
* @param perm * @param perm
* @return * @return
*/ */
public abstract boolean hasPermission(final String perm); public abstract boolean hasPermission(String perm);
/** /**
* Send a message to the player * Send a message to the player
* *
* @param message * @param message
*/ */
public abstract void sendMessage(final String message); public abstract void sendMessage(String message);
/** /**
* Print a WorldEdit error. * Print a WorldEdit error.
@ -438,7 +438,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* *
* @param substring * @param substring
*/ */
public abstract void executeCommand(final String substring); public abstract void executeCommand(String substring);
/** /**
* Get the player's location * Get the player's location
@ -473,7 +473,7 @@ public abstract class FawePlayer<T> extends Metadatable {
public Region getSelection() { public Region getSelection() {
try { try {
return this.getSession().getSelection(this.getPlayer().getWorld()); return this.getSession().getSelection(this.getPlayer().getWorld());
} catch (final IncompleteRegionException e) { } catch (IncompleteRegionException e) {
return null; return null;
} }
} }
@ -509,7 +509,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* @param region * @param region
*/ */
@Deprecated @Deprecated
public void setSelection(final RegionWrapper region) { public void setSelection(RegionWrapper region) {
final Player player = this.getPlayer(); final Player player = this.getPlayer();
BlockVector3 top = region.getMaximumPoint(); BlockVector3 top = region.getMaximumPoint();
top.withY(getWorld().getMaxY()); top.withY(getWorld().getMaxY());
@ -539,7 +539,7 @@ public abstract class FawePlayer<T> extends Metadatable {
* *
* @param selector * @param selector
*/ */
public void setSelection(final RegionSelector selector) { public void setSelection(RegionSelector selector) {
this.getSession().setRegionSelector(toWorldEditPlayer().getWorld(), selector); this.getSession().setRegionSelector(toWorldEditPlayer().getWorld(), selector);
} }
@ -551,7 +551,7 @@ public abstract class FawePlayer<T> extends Metadatable {
public Region getLargestRegion() { public Region getLargestRegion() {
int area = 0; int area = 0;
Region max = null; Region max = null;
for (final Region region : this.getCurrentRegions()) { for (Region region : this.getCurrentRegions()) {
final int tmp = region.getArea(); final int tmp = region.getArea();
if (tmp > area) { if (tmp > area) {
area = tmp; area = tmp;

Datei anzeigen

@ -5,7 +5,6 @@ import com.boydti.fawe.object.mask.SurfaceMask;
import com.boydti.fawe.object.pattern.BiomePattern; import com.boydti.fawe.object.pattern.BiomePattern;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
@ -52,7 +51,6 @@ public class SplatterBrush extends ScatterBrush {
} }
return false; return false;
}, vector -> editSession.setBlock(vector, finalPattern), recursion); }, vector -> editSession.setBlock(vector, finalPattern), recursion);
visitor.setMaxBranch(2);
visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS)); visitor.setDirections(Arrays.asList(BreadthFirstSearch.DIAGONAL_DIRECTIONS));
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);

Datei anzeigen

@ -10,7 +10,6 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.command.tool.brush.Brush; import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.mask.MaskIntersection; import com.sk89q.worldedit.function.mask.MaskIntersection;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
@ -21,7 +20,6 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.interpolation.Node; import com.sk89q.worldedit.math.interpolation.Node;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.List; import java.util.List;
public class SplineBrush implements Brush, ResettableTool { public class SplineBrush implements Brush, ResettableTool {
@ -50,7 +48,7 @@ public class SplineBrush implements Brush, ResettableTool {
} }
@Override @Override
public void build(EditSession editSession, final BlockVector3 position, Pattern pattern, double size) throws WorldEditException { public void build(EditSession editSession, BlockVector3 position, Pattern pattern, double size) throws WorldEditException {
Mask mask = editSession.getMask(); Mask mask = editSession.getMask();
if (mask == null) { if (mask == null) {
mask = new IdMask(editSession); mask = new IdMask(editSession);
@ -70,12 +68,9 @@ public class SplineBrush implements Brush, ResettableTool {
} }
final ArrayList<BlockVector3> points = new ArrayList<>(); final ArrayList<BlockVector3> points = new ArrayList<>();
if (size > 0) { if (size > 0) {
DFSRecursiveVisitor visitor = new DFSRecursiveVisitor(mask, new RegionFunction() { DFSRecursiveVisitor visitor = new DFSRecursiveVisitor(mask, p -> {
@Override points.add(p);
public boolean apply(BlockVector3 p) { return true;
points.add(p);
return true;
}
}, (int) size, 1); }, (int) size, 1);
List<BlockVector3> directions = visitor.getDirections(); List<BlockVector3> directions = visitor.getDirections();
for (int x = -1; x <= 1; x++) { for (int x = -1; x <= 1; x++) {
@ -90,7 +85,7 @@ public class SplineBrush implements Brush, ResettableTool {
} }
} }
} }
Collections.sort(directions, (o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq())); directions.sort((o1, o2) -> (int) Math.signum(o1.lengthSq() - o2.lengthSq()));
visitor.visit(position); visitor.visit(position);
Operations.completeBlindly(visitor); Operations.completeBlindly(visitor);
if (points.size() > numSplines) { if (points.size() > numSplines) {
@ -121,7 +116,7 @@ public class SplineBrush implements Brush, ResettableTool {
final List<Node> nodes = new ArrayList<>(centroids.size()); final List<Node> nodes = new ArrayList<>(centroids.size());
for (final Vector3 nodevector : centroids) { for (Vector3 nodevector : centroids) {
final Node n = new Node(nodevector); final Node n = new Node(nodevector);
n.setTension(tension); n.setTension(tension);
n.setBias(bias); n.setBias(bias);
@ -133,7 +128,7 @@ public class SplineBrush implements Brush, ResettableTool {
List<BlockVector3> currentSpline = new ArrayList<>(); List<BlockVector3> currentSpline = new ArrayList<>();
for (ArrayList<BlockVector3> points : positionSets) { for (ArrayList<BlockVector3> points : positionSets) {
int listSize = points.size(); int listSize = points.size();
int index = (int) (i * listSize / (double) (numSplines)); int index = (int) (i * listSize / (double) numSplines);
currentSpline.add(points.get(index)); currentSpline.add(points.get(index));
} }
editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true); editSession.drawSpline(pattern, currentSpline, 0, 0, 0, 10, 0, true);
@ -161,12 +156,10 @@ public class SplineBrush implements Brush, ResettableTool {
private BlockVector3 normal(Collection<BlockVector3> points, BlockVector3 centroid) { private BlockVector3 normal(Collection<BlockVector3> points, BlockVector3 centroid) {
int n = points.size(); int n = points.size();
switch (n) { switch (n) {
case 1: { case 1:
return null; return null;
} case 2:
case 2: {
return null; return null;
}
} }
// Calc full 3x3 covariance matrix, excluding symmetries: // Calc full 3x3 covariance matrix, excluding symmetries:
@ -179,9 +172,9 @@ public class SplineBrush implements Brush, ResettableTool {
MutableVector3 r = new MutableVector3(); MutableVector3 r = new MutableVector3();
for (BlockVector3 p : points) { for (BlockVector3 p : points) {
r.mutX((p.getX() - centroid.getX())); r.mutX(p.getX() - centroid.getX());
r.mutY((p.getY() - centroid.getY())); r.mutY(p.getY() - centroid.getY());
r.mutZ((p.getZ() - centroid.getZ())); r.mutZ(p.getZ() - centroid.getZ());
xx += r.getX() * r.getX(); xx += r.getX() * r.getX();
xy += r.getX() * r.getY(); xy += r.getX() * r.getY();
xz += r.getX() * r.getZ(); xz += r.getX() * r.getZ();
@ -214,7 +207,6 @@ public class SplineBrush implements Brush, ResettableTool {
double b = (xz * xy - yz * xx) / det_z; double b = (xz * xy - yz * xx) / det_z;
dir = BlockVector3.at(a, b, 1.0); dir = BlockVector3.at(a, b, 1.0);
} }
;
return dir.normalize(); return dir.normalize();
} }
} }

Datei anzeigen

@ -4,7 +4,6 @@ import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.MaxChangedBlocksException; import com.sk89q.worldedit.MaxChangedBlocksException;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.blocks.BaseItemStack; import com.sk89q.worldedit.blocks.BaseItemStack;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.Vector3; import com.sk89q.worldedit.math.Vector3;
@ -14,8 +13,6 @@ import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes; import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.weather.WeatherType; import com.sk89q.worldedit.world.weather.WeatherType;
import com.sk89q.worldedit.world.weather.WeatherTypes;
import javax.annotation.Nullable; import javax.annotation.Nullable;
public abstract class ImmutableVirtualWorld implements VirtualWorld { public abstract class ImmutableVirtualWorld implements VirtualWorld {
@ -34,12 +31,6 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
return BiomeTypes.FOREST; return BiomeTypes.FOREST;
} }
@Nullable
@Override
public Operation commit() {
return null;
}
@Override @Override
public String getName() { public String getName() {
return Integer.toString(hashCode()); return Integer.toString(hashCode());
@ -90,16 +81,6 @@ public abstract class ImmutableVirtualWorld implements VirtualWorld {
unsupported(); unsupported();
} }
@Override
public WeatherType getWeather() {
return WeatherTypes.CLEAR;
}
@Override
public long getRemainingWeatherDuration() {
return 0;
}
@Override @Override
public void setWeather(WeatherType weatherType) { public void setWeather(WeatherType weatherType) {
unsupported(); unsupported();

Datei anzeigen

@ -17,11 +17,6 @@ import java.io.IOException;
public interface VirtualWorld extends SimpleWorld, Closeable { public interface VirtualWorld extends SimpleWorld, Closeable {
Vector3 getOrigin(); Vector3 getOrigin();
@Override
default BaseBlock getFullBlock(BlockVector3 position) {
return getBlock(position).toBaseBlock();
}
@Override @Override
default BaseBlock getFullBlock(int x, int y, int z) { default BaseBlock getFullBlock(int x, int y, int z) {
return getBlock(x, y, z).toBaseBlock(); return getBlock(x, y, z).toBaseBlock();

Datei anzeigen

@ -6,7 +6,6 @@ import com.sk89q.worldedit.LocalSession;
import com.sk89q.worldedit.WorldEdit; import com.sk89q.worldedit.WorldEdit;
import com.sk89q.worldedit.command.tool.BrushTool; import com.sk89q.worldedit.command.tool.BrushTool;
import com.sk89q.worldedit.command.tool.Tool; import com.sk89q.worldedit.command.tool.Tool;
import com.sk89q.worldedit.command.tool.brush.Brush;
import com.sk89q.worldedit.entity.Player; import com.sk89q.worldedit.entity.Player;
public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> { public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> {
@ -17,7 +16,8 @@ public class VisualQueue extends SingleThreadIntervalQueue<FawePlayer> {
@Override @Override
public void operate(FawePlayer fp) { public void operate(FawePlayer fp) {
LocalSession session = fp.getSession(); LocalSession session = WorldEdit.getInstance().getSessionManager()
.get(fp.toWorldEditPlayer());
Player player = fp.getPlayer(); Player player = fp.getPlayer();
Tool tool = session.getTool(player); Tool tool = session.getTool(player);
if (tool instanceof BrushTool) { if (tool instanceof BrushTool) {

Datei anzeigen

@ -1942,11 +1942,6 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
return false; return false;
} }
@Override
public boolean generateTree(TreeGenerator.TreeType type, EditSession editSession, BlockVector3 position) throws MaxChangedBlocksException {
return false;
}
@Override @Override
public void dropItem(Vector3 position, BaseItemStack item) { public void dropItem(Vector3 position, BaseItemStack item) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
@ -1970,4 +1965,4 @@ public class HeightMapMCAGenerator extends MCAWriter implements StreamChange, Dr
// TODO Auto-generated method stub // TODO Auto-generated method stub
return null; return null;
} }
} }

Datei anzeigen

@ -33,11 +33,6 @@ public class AbstractDelegateChangeSet extends FaweChangeSet {
super.addChangeTask(queue); super.addChangeTask(queue);
} }
@Override
public boolean closeAsync() {
return super.closeAsync();
}
@Override @Override
public boolean flush() { public boolean flush() {
return parent.flush(); return parent.flush();

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.jnbt.NBTStreamer; import com.boydti.fawe.jnbt.NBTStreamer;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -10,7 +9,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
public class AbstractDelegateFaweClipboard extends FaweClipboard { public class AbstractDelegateFaweClipboard extends FaweClipboard {

Datei anzeigen

@ -3,7 +3,6 @@ package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.jnbt.NBTStreamer; import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
@ -16,7 +15,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
@ -127,13 +125,14 @@ public class CPUOptimizedClipboard extends FaweClipboard {
return BlockVector3.at(width, height, length); return BlockVector3.at(width, height, length);
} }
private int ylast; private int yLast;
private int ylasti; private int yLastI;
private int zlast; private int zLast;
private int zlasti; private int zLastI;
public int getIndex(int x, int y, int z) { public int getIndex(int x, int y, int z) {
return x + ((ylast == y) ? ylasti : (ylasti = (ylast = y) * area)) + ((zlast == z) ? zlasti : (zlasti = (zlast = z) * width)); return x + ((yLast == y) ? yLastI : (yLastI = (yLast = y) * area)) + ((zLast == z) ? zLastI
: (zLastI = (zLast = z) * width));
} }
@Override @Override

Datei anzeigen

@ -9,9 +9,6 @@ import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
@ -19,10 +16,12 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.Closeable; import java.io.Closeable;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
@ -82,7 +81,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
area = width * length; area = width * length;
this.volume = length * width * height; this.volume = length * width * height;
if ((braf.length() - HEADER_SIZE) == (volume << 2) + area) { if (braf.length() - HEADER_SIZE == (volume << 2) + area) {
hasBiomes = true; hasBiomes = true;
} }
autoCloseTask(); autoCloseTask();
@ -357,7 +356,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} }
@Override @Override
public void forEach(final BlockReader task, boolean air) { public void forEach(BlockReader task, boolean air) {
byteBuffer.force(); byteBuffer.force();
int pos = HEADER_SIZE; int pos = HEADER_SIZE;
IntegerTrio trio = new IntegerTrio(); IntegerTrio trio = new IntegerTrio();
@ -418,7 +417,8 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} }
public int getIndex(int x, int y, int z) { public int getIndex(int x, int y, int z) {
return x + ((ylast == y) ? ylasti : (ylasti = (ylast = y) * area)) + ((zlast == z) ? zlasti : (zlasti = (zlast = z) * width)); return x + (ylast == y ? ylasti : (ylasti = (ylast = y) * area)) + (zlast == z
? zlasti : (zlasti = (zlast = z) * width));
} }
@Override @Override
@ -445,7 +445,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override @Override
public BaseBlock getBlock(int i) { public BaseBlock getBlock(int i) {
try { try {
int diskIndex = (HEADER_SIZE) + (i << 2); int diskIndex = HEADER_SIZE + (i << 2);
int combinedId = byteBuffer.getInt(diskIndex); int combinedId = byteBuffer.getInt(diskIndex);
BlockType type = BlockTypes.getFromStateId(combinedId); BlockType type = BlockTypes.getFromStateId(combinedId);
BaseBlock base = type.withStateId(combinedId).toBaseBlock(); BaseBlock base = type.withStateId(combinedId).toBaseBlock();
@ -464,7 +464,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
} else { } else {
// x + z * width + y * area; // x + z * width + y * area;
int y = i / area; int y = i / area;
int newI = (i - (y * area)); int newI = i - y * area;
int z = newI / width; int z = newI / width;
int x = newI - z * width; int x = newI - z * width;
nbt = nbtMap.get(new IntegerTrio(x, y, z)); nbt = nbtMap.get(new IntegerTrio(x, y, z));
@ -494,7 +494,7 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
@Override @Override
public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) { public <B extends BlockStateHolder<B>> boolean setBlock(int x, int y, int z, B block) {
try { try {
int index = (HEADER_SIZE) + ((getIndex(x, y, z) << 2)); int index = HEADER_SIZE + (getIndex(x, y, z) << 2);
int combined = block.getInternalId(); int combined = block.getInternalId();
byteBuffer.putInt(index, combined); byteBuffer.putInt(index, combined);
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
@ -512,12 +512,12 @@ public class DiskOptimizedClipboard extends FaweClipboard implements Closeable {
public <B extends BlockStateHolder<B>> boolean setBlock(int i, B block) { public <B extends BlockStateHolder<B>> boolean setBlock(int i, B block) {
try { try {
int combined = block.getInternalId(); int combined = block.getInternalId();
int index = (HEADER_SIZE) + (i << 2); int index = HEADER_SIZE + (i << 2);
byteBuffer.putInt(index, combined); byteBuffer.putInt(index, combined);
boolean hasNbt = block instanceof BaseBlock && block.hasNbtData(); boolean hasNbt = block instanceof BaseBlock && block.hasNbtData();
if (hasNbt) { if (hasNbt) {
int y = i / area; int y = i / area;
int newI = (i - (y * area)); int newI = i - y * area;
int z = newI / width; int z = newI / width;
int x = newI - z * width; int x = newI - z * width;
setTile(x, y, z, block.getNbtData()); setTile(x, y, z, block.getNbtData());

Datei anzeigen

@ -1,25 +1,17 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import javax.annotation.Nullable;
import java.util.Collections;
import java.util.List;
public class EmptyClipboard implements Clipboard { public class EmptyClipboard implements Clipboard {
public static final EmptyClipboard INSTANCE = new EmptyClipboard(); public static final EmptyClipboard INSTANCE = new EmptyClipboard();
@ -56,22 +48,6 @@ public class EmptyClipboard implements Clipboard {
return BlockVector3.ZERO; return BlockVector3.ZERO;
} }
@Override
public List<? extends Entity> getEntities(Region region) {
return Collections.emptyList();
}
@Override
public List<? extends Entity> getEntities() {
return Collections.emptyList();
}
@Nullable
@Override
public Entity createEntity(Location location, BaseEntity entity) {
return null;
}
@Override @Override
public BaseBlock getFullBlock(BlockVector3 position) { public BaseBlock getFullBlock(BlockVector3 position) {
return BlockTypes.AIR.getDefaultState().toBaseBlock(); return BlockTypes.AIR.getDefaultState().toBaseBlock();
@ -97,9 +73,4 @@ public class EmptyClipboard implements Clipboard {
return false; return false;
} }
@Nullable
@Override
public Operation commit() {
return null;
}
} }

Datei anzeigen

@ -66,11 +66,11 @@ public abstract class FaweClipboard {
<B extends BlockStateHolder<B>> void run(int x, int y, int z, B block); <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block);
} }
public abstract void streamBiomes(final NBTStreamer.ByteReader task); public abstract void streamBiomes(NBTStreamer.ByteReader task);
public void streamCombinedIds(final NBTStreamer.ByteReader task) { public void streamCombinedIds(NBTStreamer.ByteReader task) {
forEach(new BlockReader() { forEach(new BlockReader() {
private int index = 0; private int index;
@Override @Override
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) { public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {

Datei anzeigen

@ -5,7 +5,6 @@ import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormat;
import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader; import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
import java.io.InputStream; import java.io.InputStream;
import java.net.URI; import java.net.URI;
import java.util.UUID; import java.util.UUID;

Datei anzeigen

@ -5,27 +5,25 @@ import com.boydti.fawe.jnbt.NBTStreamer;
import com.boydti.fawe.object.IntegerTrio; import com.boydti.fawe.object.IntegerTrio;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.IntTag; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.Tag; import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.biome.BiomeTypes;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import net.jpountz.util.SafeUtils;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import net.jpountz.util.SafeUtils;
public class MemoryOptimizedClipboard extends FaweClipboard { public class MemoryOptimizedClipboard extends FaweClipboard {

Datei anzeigen

@ -1,15 +1,18 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import java.net.URI; import java.net.URI;
import java.util.*; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import java.util.UUID;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import static com.google.common.base.Preconditions.checkNotNull;
public class MultiClipboardHolder extends URIClipboardHolder { public class MultiClipboardHolder extends URIClipboardHolder {
private final List<URIClipboardHolder> holders; private final List<URIClipboardHolder> holders;
private Clipboard[] cached; private Clipboard[] cached;

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import com.boydti.fawe.jnbt.NBTStreamer; import com.boydti.fawe.jnbt.NBTStreamer;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -11,7 +10,6 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.List; import java.util.List;
public abstract class ReadOnlyClipboard extends FaweClipboard { public abstract class ReadOnlyClipboard extends FaweClipboard {

Datei anzeigen

@ -4,15 +4,14 @@ import com.boydti.fawe.object.change.MutableBlockChange;
import com.boydti.fawe.object.change.MutableTileChange; import com.boydti.fawe.object.change.MutableTileChange;
import com.boydti.fawe.object.changeset.MemoryOptimizedHistory; import com.boydti.fawe.object.changeset.MemoryOptimizedHistory;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.history.change.Change; import com.sk89q.worldedit.history.change.Change;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.CuboidRegion; import com.sk89q.worldedit.regions.CuboidRegion;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.util.Iterator; import java.util.Iterator;
public class ResizableClipboardBuilder extends MemoryOptimizedHistory { public class ResizableClipboardBuilder extends MemoryOptimizedHistory {

Datei anzeigen

@ -1,14 +1,13 @@
package com.boydti.fawe.object.clipboard; package com.boydti.fawe.object.clipboard;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import java.net.URI; import java.net.URI;
import java.util.Collections; import java.util.Collections;
import java.util.Set; import java.util.Set;
import static com.google.common.base.Preconditions.checkNotNull;
public class URIClipboardHolder extends ClipboardHolder { public class URIClipboardHolder extends ClipboardHolder {
private final URI uri; private final URI uri;

Datei anzeigen

@ -2,8 +2,8 @@ package com.boydti.fawe.object.clipboard;
import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.EditSession;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
public class WorldCutClipboard extends WorldCopyClipboard { public class WorldCutClipboard extends WorldCopyClipboard {

Datei anzeigen

@ -5,9 +5,9 @@ import com.google.gson.JsonObject;
import com.google.gson.JsonParser; import com.google.gson.JsonParser;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.blocks.BaseItem; import com.sk89q.worldedit.blocks.BaseItem;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.item.ItemTypes; import com.sk89q.worldedit.world.item.ItemTypes;
import java.io.File; import java.io.File;

Datei anzeigen

@ -2,12 +2,10 @@ package com.boydti.fawe.object.clipboard.remap;
import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MainUtil;
import com.google.common.io.Resources; import com.google.common.io.Resources;
import com.google.common.reflect.TypeToken; import com.google.common.reflect.TypeToken;
import com.google.gson.Gson; import com.google.gson.Gson;
import com.google.gson.JsonSyntaxException; import com.google.gson.JsonSyntaxException;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.nio.charset.Charset; import java.nio.charset.Charset;

Datei anzeigen

@ -2,9 +2,6 @@ package com.boydti.fawe.object.collection;
import com.google.common.base.Function; import com.google.common.base.Function;
import com.google.common.collect.Collections2; import com.google.common.collect.Collections2;
import org.jetbrains.annotations.NotNull;
import javax.annotation.Nullable;
import java.util.Collection; import java.util.Collection;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@ -12,6 +9,7 @@ import java.util.Spliterator;
import java.util.function.Consumer; import java.util.function.Consumer;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Stream; import java.util.stream.Stream;
import org.jetbrains.annotations.NotNull;
/** /**
* Adapt a collection to a set * Adapt a collection to a set
@ -67,6 +65,7 @@ public class AdaptedSetCollection<T, V> implements Set<V> {
return adapted.toArray(a); return adapted.toArray(a);
} }
@Override
public boolean add(V v) { public boolean add(V v) {
return adapted.add(v); return adapted.add(v);
} }
@ -81,6 +80,7 @@ public class AdaptedSetCollection<T, V> implements Set<V> {
return adapted.containsAll(c); return adapted.containsAll(c);
} }
@Override
public boolean addAll(@NotNull Collection<? extends V> c) { public boolean addAll(@NotNull Collection<? extends V> c) {
return adapted.addAll(c); return adapted.addAll(c);
} }
@ -90,6 +90,7 @@ public class AdaptedSetCollection<T, V> implements Set<V> {
return adapted.removeAll(c); return adapted.removeAll(c);
} }
@Override
public boolean removeIf(Predicate<? super V> filter) { public boolean removeIf(Predicate<? super V> filter) {
return adapted.removeIf(filter); return adapted.removeIf(filter);
} }
@ -129,6 +130,7 @@ public class AdaptedSetCollection<T, V> implements Set<V> {
return adapted.parallelStream(); return adapted.parallelStream();
} }
@Override
public void forEach(Consumer<? super V> action) { public void forEach(Consumer<? super V> action) {
adapted.forEach(action); adapted.forEach(action);
} }

Datei anzeigen

@ -4,9 +4,6 @@ import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.AbstractRegion; import com.sk89q.worldedit.regions.AbstractRegion;
import com.sk89q.worldedit.regions.RegionOperationException; import com.sk89q.worldedit.regions.RegionOperationException;
import com.sk89q.worldedit.world.World;
import java.util.AbstractSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.Set; import java.util.Set;
@ -34,6 +31,7 @@ public abstract class BlockSet extends AbstractRegion {
} }
} }
@Override
public boolean contains(BlockVector3 obj) { public boolean contains(BlockVector3 obj) {
return contains(obj.getX(), obj.getY(), obj.getZ()); return contains(obj.getX(), obj.getY(), obj.getZ());
} }
@ -94,10 +92,15 @@ public abstract class BlockSet extends AbstractRegion {
public abstract void set(int x, int y, int z); public abstract void set(int x, int y, int z);
public abstract void clear(int x, int y, int z); public abstract void clear(int x, int y, int z);
public abstract boolean remove(int x, int y, int z); public abstract boolean remove(int x, int y, int z);
@Override
public abstract Iterator<BlockVector3> iterator(); public abstract Iterator<BlockVector3> iterator();
@Override
public abstract Set<BlockVector2> getChunks(); public abstract Set<BlockVector2> getChunks();
@Override
public abstract Set<BlockVector3> getChunkCubes(); public abstract Set<BlockVector3> getChunkCubes();
@Override
public abstract BlockVector3 getMaximumPoint(); public abstract BlockVector3 getMaximumPoint();
@Override
public abstract BlockVector3 getMinimumPoint(); public abstract BlockVector3 getMinimumPoint();
@Override @Override

Datei anzeigen

@ -19,7 +19,6 @@ import java.util.*;
*/ */
public class BlockVectorSet extends AbstractCollection<BlockVector3> implements Set<BlockVector3> { public class BlockVectorSet extends AbstractCollection<BlockVector3> implements Set<BlockVector3> {
private Int2ObjectMap<LocalBlockVectorSet> localSets = new Int2ObjectOpenHashMap<>(); private Int2ObjectMap<LocalBlockVectorSet> localSets = new Int2ObjectOpenHashMap<>();
private MutableBlockVector3 mutable = new MutableBlockVector3();
@Override @Override
public int size() { public int size() {

Datei anzeigen

@ -4,10 +4,9 @@ import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.MemUtil; import com.boydti.fawe.util.MemUtil;
import com.boydti.fawe.util.Perm; import com.boydti.fawe.util.Permission;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.AbstractDelegateExtent; import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
@ -27,7 +26,7 @@ public class MemoryCheckingExtent extends AbstractDelegateExtent {
if (MemUtil.isMemoryLimited()) { if (MemUtil.isMemoryLimited()) {
if (this.player != null) { if (this.player != null) {
player.sendMessage(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s())); player.sendMessage(BBC.WORLDEDIT_CANCEL_REASON.format(BBC.WORLDEDIT_CANCEL_REASON_LOW_MEMORY.s()));
if (Perm.hasPermission(this.player, "worldedit.fast")) { if (Permission.hasPermission(this.player.toWorldEditPlayer(), "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(this.player); BBC.WORLDEDIT_OOM_ADMIN.send(this.player);
} }
} }

Datei anzeigen

@ -1,10 +1,8 @@
package com.boydti.fawe.object.extent; package com.boydti.fawe.object.extent;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FaweLimit; import com.boydti.fawe.object.FaweLimit;
import com.boydti.fawe.object.exception.FaweException; import com.boydti.fawe.object.exception.FaweException;
import com.boydti.fawe.util.WEManager; import com.boydti.fawe.util.WEManager;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
@ -12,7 +10,6 @@ import com.sk89q.worldedit.extent.AbstractDelegateExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
@ -20,8 +17,6 @@ import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.List;
public class ProcessedWEExtent extends AbstractDelegateExtent { public class ProcessedWEExtent extends AbstractDelegateExtent {
private final FaweLimit limit; private final FaweLimit limit;
private final AbstractDelegateExtent extent; private final AbstractDelegateExtent extent;
@ -48,21 +43,6 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
return super.createEntity(location, entity); return super.createEntity(location, entity);
} }
@Override
public BiomeType getBiome(final BlockVector2 position) {
return super.getBiome(position);
}
@Override
public List<? extends Entity> getEntities() {
return super.getEntities();
}
@Override
public List<? extends Entity> getEntities(final Region region) {
return super.getEntities(region);
}
@Override @Override
public BlockState getBlock(int x, int y, int z) { public BlockState getBlock(int x, int y, int z) {
if (!limit.MAX_CHECKS()) { if (!limit.MAX_CHECKS()) {

Datei anzeigen

@ -36,7 +36,7 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
} }
/** /**
* Creates an asynchronous buffered output stream with defined buffersize and * Creates an asynchronous buffered output stream with defined bufferSize and
* 5 maximal buffers. * 5 maximal buffers.
*/ */
public AsyncBufferedOutputStream(OutputStream out, int bufSize) { public AsyncBufferedOutputStream(OutputStream out, int bufSize) {
@ -46,7 +46,7 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
/** /**
* Creates an asynchronous buffered output stream. * Creates an asynchronous buffered output stream.
* *
* @param out the outputstream to layer on. * @param out the outputStream to layer on.
* @param bufSize the buffer size. * @param bufSize the buffer size.
* @param maxBuffers the number of buffers to keep in parallel. * @param maxBuffers the number of buffers to keep in parallel.
*/ */
@ -179,4 +179,4 @@ public final class AsyncBufferedOutputStream extends FilterOutputStream {
} }
} }
} }

Datei anzeigen

@ -1,12 +1,9 @@
package com.github.luben.zstd; package com.github.luben.zstd;
import java.io.InputStream; import com.github.luben.zstd.util.Native;
import java.io.FilterInputStream; import java.io.FilterInputStream;
import java.io.IOException; import java.io.IOException;
import java.lang.IndexOutOfBoundsException; import java.io.InputStream;
import com.github.luben.zstd.util.Native;
import com.github.luben.zstd.Zstd;
/** /**
* InputStream filter that decompresses the data provided * InputStream filter that decompresses the data provided
@ -42,16 +39,13 @@ public class ZstdInputStream extends FilterInputStream {
private native int initDStream(long stream); private native int initDStream(long stream);
private native int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size); private native int decompressStream(long stream, byte[] dst, int dst_size, byte[] src, int src_size);
// The main constuctor / legacy version dispatcher // The main constructor / legacy version dispatcher
public ZstdInputStream(InputStream inStream) throws IOException { public ZstdInputStream(InputStream inStream) throws IOException {
// FilterInputStream constructor // FilterInputStream constructor
super(inStream); super(inStream);
// allocate input buffer with max frame header size // allocate input buffer with max frame header size
src = new byte[srcBuffSize]; src = new byte[srcBuffSize];
if (src == null) {
throw new IOException("Error allocating the input buffer of size " + srcBuffSize);
}
stream = createDStream(); stream = createDStream();
int size = initDStream(stream); int size = initDStream(stream);
if (Zstd.isError(size)) { if (Zstd.isError(size)) {
@ -80,9 +74,9 @@ public class ZstdInputStream extends FilterInputStream {
throw new IOException("Stream closed"); throw new IOException("Stream closed");
} }
// guard agains buffer overflows // guard against buffer overflows
if (offset < 0 || len > dst.length - offset) { if (offset < 0 || len > dst.length - offset) {
throw new IndexOutOfBoundsException("Requested lenght " + len throw new IndexOutOfBoundsException("Requested length " + len
+ " from offset " + offset + " in buffer of size " + dst.length); + " from offset " + offset + " in buffer of size " + dst.length);
} }
int dstSize = offset + len; int dstSize = offset + len;

Datei anzeigen

@ -4,7 +4,6 @@ import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import java.util.Arrays; import java.util.Arrays;
public class AngleMask extends SolidBlockMask implements ResettableMask { public class AngleMask extends SolidBlockMask implements ResettableMask {

Datei anzeigen

@ -3,11 +3,8 @@ package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class BlockLightMask extends AbstractExtentMask { public class BlockLightMask extends AbstractExtentMask {
private final int min, max; private final int min, max;

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;

Datei anzeigen

@ -1,7 +1,6 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.Set; import java.util.Set;
// TODO FIXME // TODO FIXME

Datei anzeigen

@ -2,11 +2,8 @@ package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class IdMask extends AbstractExtentMask implements ResettableMask { public class IdMask extends AbstractExtentMask implements ResettableMask {
private transient int id = -1; private transient int id = -1;

Datei anzeigen

@ -3,11 +3,8 @@ package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class LightMask extends AbstractExtentMask { public class LightMask extends AbstractExtentMask {
private final int min, max; private final int min, max;

Datei anzeigen

@ -33,6 +33,6 @@ public class MaskedTargetBlock extends TargetBlock {
} }
} }
Location currentBlock = getCurrentBlock(); Location currentBlock = getCurrentBlock();
return (currentBlock != null || !useLastBlock ? currentBlock : lastBlock); return currentBlock != null || !useLastBlock ? currentBlock : lastBlock;
} }
} }

Datei anzeigen

@ -3,11 +3,8 @@ package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class OpacityMask extends AbstractExtentMask { public class OpacityMask extends AbstractExtentMask {
private final int min, max; private final int min, max;

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
/** /**
* Restricts the * Restricts the
*/ */

Datei anzeigen

@ -10,22 +10,25 @@ public class ROCAngleMask extends AngleMask {
@Override @Override
protected boolean testSlope(int x, int y, int z) { protected boolean testSlope(int x, int y, int z) {
double slope, tmp; double tmp;
boolean aboveMin;
lastY = y; lastY = y;
int base = getHeight(x, y, z); int base = getHeight(x, y, z);
slope = ((getHeight(x + distance, y, z) - base) - (base - getHeight(x - distance, y, z))) * ADJACENT_MOD; double slope =
(getHeight(x + distance, y, z) - base - (base - getHeight(x - distance, y, z)))
* ADJACENT_MOD;
tmp = ((getHeight(x, y, z + distance) - base) - (base - getHeight(x, y, z - distance))) * ADJACENT_MOD; tmp = (getHeight(x, y, z + distance) - base - (base - getHeight(x, y, z - distance))) * ADJACENT_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = ((getHeight(x + distance, y, z + distance) - base) - (base - getHeight(x - distance, y, z - distance))) * DIAGONAL_MOD; tmp = (getHeight(x + distance, y, z + distance) - base - (base - getHeight(x - distance, y,
z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
tmp = ((getHeight(x - distance, y, z + distance) - base) - (base - getHeight(x + distance, y, z - distance))) * DIAGONAL_MOD; tmp = (getHeight(x - distance, y, z + distance) - base - (base - getHeight(x + distance, y,
z - distance))) * DIAGONAL_MOD;
if (Math.abs(tmp) > Math.abs(slope)) slope = tmp; if (Math.abs(tmp) > Math.abs(slope)) slope = tmp;
return lastValue = (slope >= min && slope <= max); return lastValue = slope >= min && slope <= max;
} }
} }

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class RadiusMask extends AbstractMask implements ResettableMask { public class RadiusMask extends AbstractMask implements ResettableMask {
private transient BlockVector3 pos; private transient BlockVector3 pos;

Datei anzeigen

@ -2,7 +2,6 @@ package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import java.util.SplittableRandom; import java.util.SplittableRandom;
public class RandomMask extends AbstractMask implements ResettableMask { public class RandomMask extends AbstractMask implements ResettableMask {
@ -23,4 +22,4 @@ public class RandomMask extends AbstractMask implements ResettableMask {
public void reset() { public void reset() {
random = new SplittableRandom(); random = new SplittableRandom();
} }
} }

Datei anzeigen

@ -3,11 +3,8 @@ package com.boydti.fawe.object.mask;
import com.boydti.fawe.object.extent.LightingExtent; import com.boydti.fawe.object.extent.LightingExtent;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.AbstractExtentMask; import com.sk89q.worldedit.function.mask.AbstractExtentMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
public class SkyLightMask extends AbstractExtentMask { public class SkyLightMask extends AbstractExtentMask {
private final int min, max; private final int min, max;

Datei anzeigen

@ -1,13 +1,10 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.function.mask.SolidBlockMask; import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import javax.annotation.Nullable;
/** /**
* Restricts the * Restricts the
*/ */

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
/** /**
* Restricts the * Restricts the
*/ */

Datei anzeigen

@ -1,11 +1,8 @@
package com.boydti.fawe.object.mask; package com.boydti.fawe.object.mask;
import com.sk89q.worldedit.function.mask.AbstractMask; import com.sk89q.worldedit.function.mask.AbstractMask;
import com.sk89q.worldedit.function.mask.Mask2D;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import javax.annotation.Nullable;
/** /**
* Restricts the * Restricts the
*/ */

Datei anzeigen

@ -1,11 +1,10 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import static com.google.common.base.Preconditions.checkNotNull;
public abstract class AbstractExtentPattern extends AbstractPattern { public abstract class AbstractExtentPattern extends AbstractPattern {
private transient final Extent extent; private transient final Extent extent;

Datei anzeigen

@ -1,13 +1,11 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.DataAnglePattern; import com.boydti.fawe.object.DataAnglePattern;
import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureHolder;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
@ -69,4 +67,4 @@ public class AngleColorPattern extends DataAnglePattern {
if (newBlock == null) return false; if (newBlock == null) return false;
return set.setBlock(extent, newBlock.getDefaultState()); return set.setBlock(extent, newBlock.getDefaultState());
} }
} }

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -9,8 +8,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.awt.Color; import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
public class AverageColorPattern extends AbstractExtentPattern { public class AverageColorPattern extends AbstractExtentPattern {
private transient TextureHolder holder; private transient TextureHolder holder;

Datei anzeigen

@ -1,14 +1,10 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector2;
import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.biome.BiomeType;
import java.io.IOException; import com.sk89q.worldedit.world.block.BaseBlock;
public class BiomePattern extends ExistingPattern { public class BiomePattern extends ExistingPattern {
private final BiomeType biome; private final BiomeType biome;

Datei anzeigen

@ -1,20 +1,15 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.FawePlayer; import com.boydti.fawe.object.FawePlayer;
import com.boydti.fawe.object.collection.LocalBlockVectorSet; import com.boydti.fawe.object.collection.LocalBlockVectorSet;
import com.boydti.fawe.util.FaweTimer; import com.boydti.fawe.util.FaweTimer;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
import java.util.UUID; import java.util.UUID;
public class BufferedPattern extends AbstractPattern implements ResettablePattern { public class BufferedPattern extends AbstractPattern implements ResettablePattern {

Datei anzeigen

@ -1,16 +1,13 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.DelegateFilterBlock; import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockStateHolder;
import static com.google.common.base.Preconditions.checkNotNull;
public class DataPattern extends AbstractExtentPattern { public class DataPattern extends AbstractExtentPattern {
private final Pattern pattern; private final Pattern pattern;

Datei anzeigen

@ -1,6 +1,5 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -9,8 +8,6 @@ import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.io.IOException;
import java.io.ObjectInputStream;
public class DesaturatePattern extends AbstractPattern { public class DesaturatePattern extends AbstractPattern {
private final TextureHolder holder; private final TextureHolder holder;
@ -40,8 +37,7 @@ public class DesaturatePattern extends AbstractPattern {
int red = (int) (r + value * (l - r)); int red = (int) (r + value * (l - r));
int green = (int) (g + value * (l - g)); int green = (int) (g + value * (l - g));
int blue = (int) (b + value * (l - b)); int blue = (int) (b + value * (l - b));
int newColor = (alpha << 24) + (red << 16) + (green << 8) + (blue << 0); return (alpha << 24) + (red << 16) + (green << 8) + (blue << 0);
return newColor;
} }
@Override @Override

Datei anzeigen

@ -1,10 +1,9 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
public class ExistingPattern extends AbstractExtentPattern { public class ExistingPattern extends AbstractExtentPattern {
public ExistingPattern(Extent extent) { public ExistingPattern(Extent extent) {

Datei anzeigen

@ -1,20 +1,17 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.world.block.BaseBlock; import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.Expression;
import com.sk89q.worldedit.internal.expression.ExpressionException; import com.sk89q.worldedit.internal.expression.ExpressionException;
import com.sk89q.worldedit.internal.expression.runtime.EvaluationException; import com.sk89q.worldedit.internal.expression.runtime.EvaluationException;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment; import com.sk89q.worldedit.regions.shape.WorldEditExpressionEnvironment;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.IOException;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* A mask that evaluates an expression. * A mask that evaluates an expression.
* <p> * <p>

Datei anzeigen

@ -1,8 +1,8 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import static com.google.common.base.Preconditions.checkNotNull;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
@ -10,13 +10,10 @@ import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException; import java.io.IOException;
import java.io.NotSerializableException; import java.io.NotSerializableException;
import static com.google.common.base.Preconditions.checkNotNull;
/** /**
* A pattern that reads from {@link Clipboard}. * A pattern that reads from {@link Clipboard}.
*/ */
@ -51,4 +48,4 @@ public class FullClipboardPattern extends AbstractExtentPattern {
private void writeObject(java.io.ObjectOutputStream stream) throws IOException { private void writeObject(java.io.ObjectOutputStream stream) throws IOException {
throw new NotSerializableException("Clipboard cannot be serialized!"); throw new NotSerializableException("Clipboard cannot be serialized!");
} }
} }

Datei anzeigen

@ -1,13 +1,9 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.FaweCache;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockTypes;
public class IdDataMaskPattern extends AbstractExtentPattern { public class IdDataMaskPattern extends AbstractExtentPattern {
private final Pattern pattern; private final Pattern pattern;
@ -27,4 +23,4 @@ public class IdDataMaskPattern extends AbstractExtentPattern {
int newData = newBlock.getInternalPropertiesId() + oldData - (oldData & bitMask); int newData = newBlock.getInternalPropertiesId() + oldData - (oldData & bitMask);
return newBlock.withPropertyId(newData).toBaseBlock(); return newBlock.withPropertyId(newData).toBaseBlock();
} }
} }

Datei anzeigen

@ -1,14 +1,11 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
public class Linear2DBlockPattern extends AbstractPattern { public class Linear2DBlockPattern extends AbstractPattern {
@ -35,4 +32,4 @@ public class Linear2DBlockPattern extends AbstractPattern {
} }
return patternsArray[index].apply(extent, get, set); return patternsArray[index].apply(extent, get, set);
} }
} }

Datei anzeigen

@ -1,14 +1,11 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
public class Linear3DBlockPattern extends AbstractPattern { public class Linear3DBlockPattern extends AbstractPattern {

Datei anzeigen

@ -1,13 +1,11 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
public class LinearBlockPattern extends AbstractPattern implements ResettablePattern { public class LinearBlockPattern extends AbstractPattern implements ResettablePattern {

Datei anzeigen

@ -1,16 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.beta.SingleFilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
public class MaskedPattern extends AbstractPattern { public class MaskedPattern extends AbstractPattern {

Datei anzeigen

@ -1,18 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.DelegateFilterBlock;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
public class NoXPattern extends AbstractPattern { public class NoXPattern extends AbstractPattern {
@ -25,15 +19,15 @@ public class NoXPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(BlockVector3 pos) { public BaseBlock apply(BlockVector3 pos) {
mutable.mutY((pos.getY())); mutable.mutY(pos.getY());
mutable.mutZ((pos.getZ())); mutable.mutZ(pos.getZ());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
@Override @Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
mutable.mutY((get.getY())); mutable.mutY(get.getY());
mutable.mutZ((get.getZ())); mutable.mutZ(get.getZ());
return pattern.apply(extent, mutable, set); return pattern.apply(extent, mutable, set);
} }
} }

Datei anzeigen

@ -19,15 +19,15 @@ public class NoYPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(BlockVector3 pos) { public BaseBlock apply(BlockVector3 pos) {
mutable.mutX((pos.getX())); mutable.mutX(pos.getX());
mutable.mutZ((pos.getZ())); mutable.mutZ(pos.getZ());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
@Override @Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
mutable.mutX((get.getX())); mutable.mutX(get.getX());
mutable.mutZ((get.getZ())); mutable.mutZ(get.getZ());
return pattern.apply(extent, mutable, set); return pattern.apply(extent, mutable, set);
} }
} }

Datei anzeigen

@ -1,18 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.DelegateFilterBlock;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
public class NoZPattern extends AbstractPattern { public class NoZPattern extends AbstractPattern {
@ -26,15 +20,15 @@ public class NoZPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(BlockVector3 pos) { public BaseBlock apply(BlockVector3 pos) {
mutable.mutX((pos.getX())); mutable.mutX(pos.getX());
mutable.mutY((pos.getY())); mutable.mutY(pos.getY());
return pattern.apply(mutable); return pattern.apply(mutable);
} }
@Override @Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
mutable.mutX((get.getX())); mutable.mutX(get.getX());
mutable.mutY((get.getY())); mutable.mutY(get.getY());
return pattern.apply(extent, mutable, set); return pattern.apply(extent, mutable, set);
} }
} }

Datei anzeigen

@ -1,17 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
public class OffsetPattern extends AbstractPattern { public class OffsetPattern extends AbstractPattern {
@ -28,17 +23,17 @@ public class OffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(BlockVector3 position) { public BaseBlock apply(BlockVector3 position) {
mutable.mutX((position.getX() + dx)); mutable.mutX(position.getX() + dx);
mutable.mutY((position.getY() + dy)); mutable.mutY(position.getY() + dy);
mutable.mutZ((position.getZ() + dz)); mutable.mutZ(position.getZ() + dz);
return pattern.apply(mutable); return pattern.apply(mutable);
} }
@Override @Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
mutable.mutX((get.getX() + dx)); mutable.mutX(get.getX() + dx);
mutable.mutY((get.getY() + dy)); mutable.mutY(get.getY() + dy);
mutable.mutZ((get.getZ() + dz)); mutable.mutZ(get.getZ() + dz);
return pattern.apply(extent, get, mutable); return pattern.apply(extent, get, mutable);
} }
} }

Datei anzeigen

@ -1,12 +1,10 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.object.string.MutableCharSequence; import com.boydti.fawe.object.string.MutableCharSequence;
import com.boydti.fawe.util.MathMan; import com.boydti.fawe.util.MathMan;
import com.boydti.fawe.util.StringMan; import com.boydti.fawe.util.StringMan;
import com.sk89q.jnbt.CompoundTag; import com.sk89q.jnbt.CompoundTag;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.registry.state.AbstractProperty; import com.sk89q.worldedit.registry.state.AbstractProperty;
@ -17,7 +15,6 @@ import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockState;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -173,7 +170,7 @@ public class PropertyPattern extends AbstractExtentPattern {
last = i + 1; last = i + 1;
break; break;
} }
default: { default:
Operator tmp = getOp(c); Operator tmp = getOp(c);
if (tmp != null) { if (tmp != null) {
operator = tmp; operator = tmp;
@ -186,7 +183,6 @@ public class PropertyPattern extends AbstractExtentPattern {
last = i + 1; last = i + 1;
} }
break; break;
}
} }
} }
} }

Datei anzeigen

@ -1,8 +1,9 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.schematic.Schematic; import com.boydti.fawe.object.schematic.Schematic;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
@ -12,12 +13,10 @@ import com.sk89q.worldedit.math.Vector3;
import com.sk89q.worldedit.math.transform.AffineTransform; import com.sk89q.worldedit.math.transform.AffineTransform;
import com.sk89q.worldedit.math.transform.Transform; import com.sk89q.worldedit.math.transform.Transform;
import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.ClipboardHolder;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.util.List; import java.util.List;
import java.util.concurrent.ThreadLocalRandom; import java.util.concurrent.ThreadLocalRandom;
import static com.google.common.base.Preconditions.checkNotNull;
public class RandomFullClipboardPattern extends AbstractPattern { public class RandomFullClipboardPattern extends AbstractPattern {
private final Extent extent; private final Extent extent;
private final MutableBlockVector3 mutable = new MutableBlockVector3(); private final MutableBlockVector3 mutable = new MutableBlockVector3();

Datei anzeigen

@ -1,15 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
import java.util.SplittableRandom; import java.util.SplittableRandom;
public class RandomOffsetPattern extends AbstractPattern { public class RandomOffsetPattern extends AbstractPattern {
@ -47,4 +44,4 @@ public class RandomOffsetPattern extends AbstractPattern {
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz)); mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz));
return pattern.apply(extent, get, mutable); return pattern.apply(extent, get, mutable);
} }
} }

Datei anzeigen

@ -1,15 +1,12 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import java.io.IOException;
public class RelativePattern extends AbstractPattern implements ResettablePattern { public class RelativePattern extends AbstractPattern implements ResettablePattern {

Datei anzeigen

@ -1,7 +1,5 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.beta.FilterBlock;
import com.boydti.fawe.util.TextureHolder; import com.boydti.fawe.util.TextureHolder;
import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.TextureUtil;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
@ -11,8 +9,6 @@ import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import java.awt.Color; import java.awt.Color;
import java.io.IOException;
import java.io.ObjectInputStream;
public class SaturatePattern extends AbstractPattern { public class SaturatePattern extends AbstractPattern {
private final TextureHolder holder; private final TextureHolder holder;

Datei anzeigen

@ -1,19 +1,15 @@
package com.boydti.fawe.object.pattern; package com.boydti.fawe.object.pattern;
import com.boydti.fawe.beta.FilterBlock;
import com.sk89q.worldedit.WorldEditException; import com.sk89q.worldedit.WorldEditException;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.extent.Extent; import com.sk89q.worldedit.extent.Extent;
import com.sk89q.worldedit.function.mask.SolidBlockMask;
import com.sk89q.worldedit.function.pattern.AbstractPattern; import com.sk89q.worldedit.function.pattern.AbstractPattern;
import com.sk89q.worldedit.function.pattern.Pattern; import com.sk89q.worldedit.function.pattern.Pattern;
import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.math.BlockVector3;
import com.sk89q.worldedit.math.MutableBlockVector3; import com.sk89q.worldedit.math.MutableBlockVector3;
import com.sk89q.worldedit.world.block.BaseBlock;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import com.sk89q.worldedit.world.block.BlockType; import com.sk89q.worldedit.world.block.BlockType;
import com.sk89q.worldedit.world.block.BlockTypes; import com.sk89q.worldedit.world.block.BlockTypes;
import java.io.IOException;
import java.util.SplittableRandom; import java.util.SplittableRandom;
public class SolidRandomOffsetPattern extends AbstractPattern { public class SolidRandomOffsetPattern extends AbstractPattern {
@ -47,27 +43,25 @@ public class SolidRandomOffsetPattern extends AbstractPattern {
@Override @Override
public BaseBlock apply(BlockVector3 position) { public BaseBlock apply(BlockVector3 position) {
mutable.mutX((position.getX() + r.nextInt(dx2) - dx)); mutable.mutX(position.getX() + r.nextInt(dx2) - dx);
mutable.mutY((position.getY() + r.nextInt(dy2) - dy)); mutable.mutY(position.getY() + r.nextInt(dy2) - dy);
mutable.mutZ((position.getZ() + r.nextInt(dz2) - dz)); mutable.mutZ(position.getZ() + r.nextInt(dz2) - dz);
BaseBlock block = pattern.apply(mutable); BaseBlock block = pattern.apply(mutable);
if (block.getMaterial().isSolid()) { if (block.getMaterial().isSolid()) {
return block; return block;
} else {
return pattern.apply(position);
} }
return pattern.apply(position);
} }
@Override @Override
public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException { public boolean apply(Extent extent, BlockVector3 get, BlockVector3 set) throws WorldEditException {
mutable.mutX((set.getX() + r.nextInt(dx2) - dx)); mutable.mutX(set.getX() + r.nextInt(dx2) - dx);
mutable.mutY((set.getY() + r.nextInt(dy2) - dy)); mutable.mutY(set.getY() + r.nextInt(dy2) - dy);
mutable.mutZ((set.getZ() + r.nextInt(dz2) - dz)); mutable.mutZ(set.getZ() + r.nextInt(dz2) - dz);
BlockStateHolder block = pattern.apply(mutable); BlockStateHolder block = pattern.apply(mutable);
if (block.getMaterial().isSolid()) { if (block.getMaterial().isSolid()) {
return pattern.apply(extent, get, mutable); return pattern.apply(extent, get, mutable);
} else {
return pattern.apply(extent, get, set);
} }
return pattern.apply(extent, get, set);
} }
} }

Datei anzeigen

@ -16,7 +16,6 @@ public class SurfaceRandomOffsetPattern extends AbstractPattern {
private final MutableBlockVector3 cur; private final MutableBlockVector3 cur;
private final MutableBlockVector3[] buffer; private final MutableBlockVector3[] buffer;
private final MutableBlockVector3[] allowed; private final MutableBlockVector3[] allowed;
private MutableBlockVector3 next;
public SurfaceRandomOffsetPattern(Pattern pattern, int distance) { public SurfaceRandomOffsetPattern(Pattern pattern, int distance) {
this.pattern = pattern; this.pattern = pattern;

Datei anzeigen

@ -155,7 +155,7 @@ public class FuzzyRegionSelector extends AbstractDelegateExtent implements Regio
} }
@Override @Override
public List<BlockVector3> getVerticies() { public List<BlockVector3> getVertices() {
return positions; return positions;
} }

Datei anzeigen

@ -230,7 +230,7 @@ public class PolyhedralRegionSelector implements RegionSelector, CUIRegion {
} }
@Override @Override
public List<BlockVector3> getVerticies() { public List<BlockVector3> getVertices() {
return new ArrayList<>(region.getVertices()); return new ArrayList<>(region.getVertices());
} }
} }

Datei anzeigen

@ -3,8 +3,14 @@ package com.boydti.fawe.object.schematic;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweCache; import com.boydti.fawe.FaweCache;
import com.boydti.fawe.util.ReflectionUtils; import com.boydti.fawe.util.ReflectionUtils;
import com.sk89q.jnbt.CompoundTag;
import com.sk89q.jnbt.*; import com.sk89q.jnbt.IntTag;
import com.sk89q.jnbt.ListTag;
import com.sk89q.jnbt.NBTInputStream;
import com.sk89q.jnbt.NBTOutputStream;
import com.sk89q.jnbt.NamedTag;
import com.sk89q.jnbt.StringTag;
import com.sk89q.jnbt.Tag;
import com.sk89q.worldedit.entity.BaseEntity; import com.sk89q.worldedit.entity.BaseEntity;
import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.entity.Entity;
import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard; import com.sk89q.worldedit.extent.clipboard.BlockArrayClipboard;
@ -26,8 +32,6 @@ import com.sk89q.worldedit.world.block.BlockTypes;
import com.sk89q.worldedit.world.entity.EntityTypes; import com.sk89q.worldedit.world.entity.EntityTypes;
import com.sk89q.worldedit.world.storage.NBTConversions; import com.sk89q.worldedit.world.storage.NBTConversions;
import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap; import it.unimi.dsi.fastutil.ints.Int2ObjectArrayMap;
import org.jetbrains.annotations.NotNull;
import java.io.IOException; import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Arrays; import java.util.Arrays;
@ -35,6 +39,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
import org.jetbrains.annotations.NotNull;
public class MinecraftStructure implements ClipboardReader, ClipboardWriter { public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
private static final int WARN_SIZE = 32; private static final int WARN_SIZE = 32;
@ -73,7 +78,7 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
// Init clipboard // Init clipboard
BlockVector3 origin = BlockVector3.at(0, 0, 0); BlockVector3 origin = BlockVector3.at(0, 0, 0);
CuboidRegion region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE)); CuboidRegion region = new CuboidRegion(origin, origin.add(width, height, length).subtract(BlockVector3.ONE));
BlockArrayClipboard clipboard = new BlockArrayClipboard(region, clipboardId); Clipboard clipboard = new BlockArrayClipboard(region, clipboardId);
// Blocks // Blocks
ListTag blocks = (ListTag) tags.get("blocks"); ListTag blocks = (ListTag) tags.get("blocks");
if (blocks != null) { if (blocks != null) {
@ -86,10 +91,6 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
String name = ((StringTag) map.get("Name")).getValue(); String name = ((StringTag) map.get("Name")).getValue();
BlockType type = BlockTypes.get(name); BlockType type = BlockTypes.get(name);
BlockState state = type.getDefaultState(); BlockState state = type.getDefaultState();
if (type == null) {
Fawe.debug("Unknown block: " + name);
continue;
}
CompoundTag properties = (CompoundTag) map.get("Properties"); CompoundTag properties = (CompoundTag) map.get("Properties");
if (properties != null) { if (properties != null) {
for (Map.Entry<String, Tag> entry : properties.getValue().entrySet()) { for (Map.Entry<String, Tag> entry : properties.getValue().entrySet()) {
@ -167,85 +168,79 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
// Size // Size
structure.put("size", Arrays.asList(width, height, length)); structure.put("size", Arrays.asList(width, height, length));
// Palette // Palette
{ ArrayList<HashMap<String, Object>> palette = new ArrayList<>();
ArrayList<HashMap<String, Object>> palette = new ArrayList<>(); for (BlockVector3 point : region) {
for (BlockVector3 point : region) { BlockStateHolder block = clipboard.getBlock(point);
BlockStateHolder block = clipboard.getBlock(point); int combined = block.getInternalId();
int combined = block.getInternalId(); BlockType type = block.getBlockType();
BlockType type = block.getBlockType();
if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(combined)) { if (type == BlockTypes.STRUCTURE_VOID || indexes.containsKey(combined)) {
continue; continue;
} }
indexes.put(combined, (Integer) palette.size()); indexes.put(combined, (Integer) palette.size());
HashMap<String, Object> paletteEntry = new HashMap<>(); HashMap<String, Object> paletteEntry = new HashMap<>();
paletteEntry.put("Name", type.getId()); paletteEntry.put("Name", type.getId());
if (block.getInternalId() != type.getInternalId()) { if (block.getInternalId() != type.getInternalId()) {
Map<String, Object> properties = null; Map<String, Object> properties = null;
for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) { for (AbstractProperty property : (List<AbstractProperty<?>>) type.getProperties()) {
int propIndex = property.getIndex(block.getInternalId()); int propIndex = property.getIndex(block.getInternalId());
if (propIndex != 0) { if (propIndex != 0) {
if (properties == null) properties = new HashMap<>(); if (properties == null) properties = new HashMap<>();
Object value = property.getValues().get(propIndex); Object value = property.getValues().get(propIndex);
properties.put(property.getName(), value.toString()); properties.put(property.getName(), value.toString());
}
}
if (properties != null) {
paletteEntry.put("Properties", properties);
} }
} }
palette.add(paletteEntry); if (properties != null) {
} paletteEntry.put("Properties", properties);
if (!palette.isEmpty()) { }
structure.put("palette", palette);
} }
palette.add(paletteEntry);
}
if (!palette.isEmpty()) {
structure.put("palette", palette);
} }
// Blocks // Blocks
{ ArrayList<Map<String, Object>> blocks = new ArrayList<>();
ArrayList<Map<String, Object>> blocks = new ArrayList<>(); BlockVector3 min = region.getMinimumPoint();
BlockVector3 min = region.getMinimumPoint(); for (BlockVector3 point : region) {
for (BlockVector3 point : region) { BaseBlock block = clipboard.getFullBlock(point);
BaseBlock block = clipboard.getFullBlock(point); if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) {
if (block.getBlockType() != BlockTypes.STRUCTURE_VOID) { int combined = block.getInternalId();
int combined = block.getInternalId(); int index = indexes.get(combined);
int index = indexes.get(combined); List<Integer> pos = Arrays.asList(point.getX() - min.getX(),
List<Integer> pos = Arrays.asList(point.getX() - min.getX(), point.getY() - min.getY(), point.getZ() - min.getZ());
point.getY() - min.getY(), point.getZ() - min.getZ()); if (!block.hasNbtData()) {
if (!block.hasNbtData()) { blocks.add(FaweCache.asMap("state", index, "pos", pos));
blocks.add(FaweCache.asMap("state", index, "pos", pos)); } else {
} else { blocks.add(
blocks.add( FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
FaweCache.asMap("state", index, "pos", pos, "nbt", block.getNbtData()));
}
} }
} }
if (!blocks.isEmpty()) { }
structure.put("blocks", blocks); if (!blocks.isEmpty()) {
} structure.put("blocks", blocks);
} }
// Entities // Entities
{ ArrayList<Map<String, Object>> entities = new ArrayList<>();
ArrayList<Map<String, Object>> entities = new ArrayList<>(); for (Entity entity : clipboard.getEntities()) {
for (Entity entity : clipboard.getEntities()) { Location loc = entity.getLocation();
Location loc = entity.getLocation(); List<Double> pos = Arrays.asList(loc.getX(), loc.getY(), loc.getZ());
List<Double> pos = Arrays.asList(loc.getX(), loc.getY(), loc.getZ()); List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
List<Integer> blockPos = Arrays.asList(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()); BaseEntity state = entity.getState();
BaseEntity state = entity.getState(); if (state != null) {
if (state != null) { CompoundTag nbt = state.getNbtData();
CompoundTag nbt = state.getNbtData(); Map<String, Tag> nbtMap = ReflectionUtils.getMap(nbt.getValue());
Map<String, Tag> nbtMap = ReflectionUtils.getMap(nbt.getValue()); // Replace rotation data
// Replace rotation data nbtMap.put("Rotation", writeRotation(entity.getLocation()));
nbtMap.put("Rotation", writeRotation(entity.getLocation(), "Rotation")); nbtMap.put("id", new StringTag(state.getType().getId()));
nbtMap.put("id", new StringTag(state.getType().getId())); Map<String, Object> entityMap = FaweCache.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt);
Map<String, Object> entityMap = FaweCache.asMap("pos", pos, "blockPos", blockPos, "nbt", nbt); entities.add(entityMap);
entities.add(entityMap);
}
}
if (!entities.isEmpty()) {
structure.put("entities", entities);
} }
} }
if (!entities.isEmpty()) {
structure.put("entities", entities);
}
out.writeNamedTag("", FaweCache.asTag(structure)); out.writeNamedTag("", FaweCache.asTag(structure));
close(); close();
} }
@ -260,18 +255,4 @@ public class MinecraftStructure implements ClipboardReader, ClipboardWriter {
} }
} }
private Tag writeVector(BlockVector3 vector, String name) {
List<DoubleTag> list = new ArrayList<>();
list.add(new DoubleTag(vector.getX()));
list.add(new DoubleTag(vector.getY()));
list.add(new DoubleTag(vector.getZ()));
return new ListTag(DoubleTag.class, list);
}
private Tag writeRotation(Location location, String name) {
List<FloatTag> list = new ArrayList<>();
list.add(new FloatTag(location.getYaw()));
list.add(new FloatTag(location.getPitch()));
return new ListTag(FloatTag.class, list);
}
} }

Datei anzeigen

@ -51,9 +51,6 @@ public class PNGWriter implements ClipboardWriter {
double[] dpxi = new double[Math.max(256, width)]; double[] dpxi = new double[Math.max(256, width)];
double[] dpyj = new double[length]; double[] dpyj = new double[length];
double[] dpyi = new double[Math.max(256, width)]; double[] dpyi = new double[Math.max(256, width)];
double[] hd = new double[256];
for (int i = 0; i < hd.length; i++) {
}
for (int j = 0; j < dpxj.length; j++) { for (int j = 0; j < dpxj.length; j++) {
dpxj[j] = cx + j * d; dpxj[j] = cx + j * d;
dpyj[j] = imageSize / 2 + d + j * d_2; dpyj[j] = imageSize / 2 + d + j * d_2;
@ -165,4 +162,4 @@ public class PNGWriter implements ClipboardWriter {
public void close() throws IOException { public void close() throws IOException {
out.close(); out.close();
} }
} }

Datei anzeigen

@ -1,5 +1,7 @@
package com.boydti.fawe.object.schematic; package com.boydti.fawe.object.schematic;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.object.clipboard.FaweClipboard; import com.boydti.fawe.object.clipboard.FaweClipboard;
import com.boydti.fawe.object.clipboard.ReadOnlyClipboard; import com.boydti.fawe.object.clipboard.ReadOnlyClipboard;
import com.boydti.fawe.util.EditSessionBuilder; import com.boydti.fawe.util.EditSessionBuilder;
@ -18,6 +20,7 @@ import com.sk89q.worldedit.function.RegionFunction;
import com.sk89q.worldedit.function.mask.ExistingBlockMask; import com.sk89q.worldedit.function.mask.ExistingBlockMask;
import com.sk89q.worldedit.function.mask.Mask; import com.sk89q.worldedit.function.mask.Mask;
import com.sk89q.worldedit.function.operation.ForwardExtentCopy; import com.sk89q.worldedit.function.operation.ForwardExtentCopy;
import com.sk89q.worldedit.function.operation.Operation;
import com.sk89q.worldedit.function.operation.Operations; import com.sk89q.worldedit.function.operation.Operations;
import com.sk89q.worldedit.function.visitor.RegionVisitor; import com.sk89q.worldedit.function.visitor.RegionVisitor;
import com.sk89q.worldedit.math.BlockVector2; import com.sk89q.worldedit.math.BlockVector2;
@ -29,17 +32,14 @@ import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.util.Location;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import com.sk89q.worldedit.world.block.BlockStateHolder; import com.sk89q.worldedit.world.block.BlockStateHolder;
import java.io.File; import java.io.File;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import static com.google.common.base.Preconditions.checkNotNull;
public class Schematic { public class Schematic {
private final Clipboard clipboard; private final Clipboard clipboard;
public Schematic(Clipboard clipboard) { public Schematic(Clipboard clipboard) {
@ -54,14 +54,15 @@ public class Schematic {
*/ */
public Schematic(Region region) { public Schematic(Region region) {
checkNotNull(region); checkNotNull(region);
checkNotNull(region.getWorld(), "World cannot be null (use the other constructor for the region)"); checkNotNull(region.getWorld(),
EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere().autoQueue(false).build(); "World cannot be null (use the other constructor for the region)");
EditSession session = new EditSessionBuilder(region.getWorld()).allowedRegionsEverywhere()
.autoQueue(false).build();
this.clipboard = new BlockArrayClipboard(region, ReadOnlyClipboard.of(session, region)); this.clipboard = new BlockArrayClipboard(region, ReadOnlyClipboard.of(session, region));
} }
public
@Nullable @Nullable
Clipboard getClipboard() { public Clipboard getClipboard() {
return clipboard; return clipboard;
} }
@ -104,7 +105,8 @@ public class Schematic {
} }
} }
public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, @Nullable Transform transform) { public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
@Nullable Transform transform) {
return paste(world, to, allowUndo, pasteAir, true, transform); return paste(world, to, allowUndo, pasteAir, true, transform);
} }
@ -118,14 +120,16 @@ public class Schematic {
* @param transform * @param transform
* @return * @return
*/ */
public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir, boolean copyEntities, @Nullable Transform transform) { public EditSession paste(World world, BlockVector3 to, boolean allowUndo, boolean pasteAir,
boolean copyEntities, @Nullable Transform transform) {
checkNotNull(world); checkNotNull(world);
checkNotNull(to); checkNotNull(to);
EditSession editSession; EditSession editSession;
if (world instanceof EditSession) { if (world instanceof EditSession) {
editSession = (EditSession) world; editSession = (EditSession) world;
} else { } else {
EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true).checkMemory(false).allowedRegionsEverywhere().limitUnlimited(); EditSessionBuilder builder = new EditSessionBuilder(world).autoQueue(true)
.checkMemory(false).allowedRegionsEverywhere().limitUnlimited();
if (allowUndo) { if (allowUndo) {
editSession = builder.build(); editSession = builder.build();
} else { } else {
@ -141,7 +145,8 @@ public class Schematic {
editSession.flushQueue(); editSession.flushQueue();
return editSession; return editSession;
} }
ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(), clipboard.getOrigin(), editSession, to); ForwardExtentCopy copy = new ForwardExtentCopy(extent, clipboard.getRegion(),
clipboard.getOrigin(), editSession, to);
if (transform != null && !transform.isIdentity()) { if (transform != null && !transform.isIdentity()) {
copy.setTransform(transform); copy.setTransform(transform);
} }
@ -165,16 +170,13 @@ public class Schematic {
public void paste(Extent extent, BlockVector3 to, boolean pasteAir, Transform transform) { public void paste(Extent extent, BlockVector3 to, boolean pasteAir, Transform transform) {
checkNotNull(transform); checkNotNull(transform);
Region region = clipboard.getRegion(); Extent source = new BlockTransformExtent(clipboard, transform);
Extent source = clipboard; ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(),
if (transform != null) { clipboard.getOrigin(), extent, to);
source = new BlockTransformExtent(clipboard, transform); copy.setTransform(transform);
} copy.setCopyingBiomes(
ForwardExtentCopy copy = new ForwardExtentCopy(source, clipboard.getRegion(), clipboard.getOrigin(), extent, to); !(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP
if (transform != null) { .hasBiomes());
copy.setTransform(transform);
}
copy.setCopyingBiomes(!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes());
if (extent instanceof EditSession) { if (extent instanceof EditSession) {
EditSession editSession = (EditSession) extent; EditSession editSession = (EditSession) extent;
Mask sourceMask = editSession.getSourceMask(); Mask sourceMask = editSession.getSourceMask();
@ -190,13 +192,14 @@ public class Schematic {
Operations.completeBlindly(copy); Operations.completeBlindly(copy);
} }
public void paste(Extent extent, BlockVector3 to, final boolean pasteAir) { public void paste(Extent extent, BlockVector3 to, boolean pasteAir) {
Region region = clipboard.getRegion().clone(); Region region = clipboard.getRegion().clone();
final int maxY = extent.getMaximumPoint().getBlockY();
final BlockVector3 bot = clipboard.getMinimumPoint(); final BlockVector3 bot = clipboard.getMinimumPoint();
final BlockVector3 origin = clipboard.getOrigin(); final BlockVector3 origin = clipboard.getOrigin();
final boolean copyBiomes = !(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP.hasBiomes(); final boolean copyBiomes =
!(clipboard instanceof BlockArrayClipboard) || ((BlockArrayClipboard) clipboard).IMP
.hasBiomes();
// Optimize for BlockArrayClipboard // Optimize for BlockArrayClipboard
if (clipboard instanceof BlockArrayClipboard && region instanceof CuboidRegion) { if (clipboard instanceof BlockArrayClipboard && region instanceof CuboidRegion) {
@ -209,9 +212,11 @@ public class Schematic {
if (copyBiomes) { if (copyBiomes) {
bac.IMP.forEach(new FaweClipboard.BlockReader() { bac.IMP.forEach(new FaweClipboard.BlockReader() {
MutableBlockVector2 mpos2d = new MutableBlockVector2(); MutableBlockVector2 mpos2d = new MutableBlockVector2();
{ {
mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE);
} }
@Override @Override
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) { public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
try { try {
@ -225,7 +230,9 @@ public class Schematic {
return; return;
} }
extent.setBlock(xx, y + rely, zz, block); extent.setBlock(xx, y + rely, zz, block);
} catch (WorldEditException e) { throw new RuntimeException(e);} } catch (WorldEditException e) {
throw new RuntimeException(e);
}
} }
}, true); }, true);
} else { } else {
@ -234,7 +241,9 @@ public class Schematic {
public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) { public <B extends BlockStateHolder<B>> void run(int x, int y, int z, B block) {
try { try {
extent.setBlock(x + relx, y + rely, z + relz, block); extent.setBlock(x + relx, y + rely, z + relz, block);
} catch (WorldEditException e) { throw new RuntimeException(e);} } catch (WorldEditException e) {
throw new RuntimeException(e);
}
} }
}, pasteAir); }, pasteAir);
} }
@ -243,12 +252,14 @@ public class Schematic {
final int relx = to.getBlockX() - origin.getBlockX(); final int relx = to.getBlockX() - origin.getBlockX();
final int rely = to.getBlockY() - origin.getBlockY(); final int rely = to.getBlockY() - origin.getBlockY();
final int relz = to.getBlockZ() - origin.getBlockZ(); final int relz = to.getBlockZ() - origin.getBlockZ();
RegionVisitor visitor = new RegionVisitor(region, new RegionFunction() { Operation visitor = new RegionVisitor(region, new RegionFunction() {
// MutableBlockVector2 mpos2d_2 = new MutableBlockVector2(); // MutableBlockVector2 mpos2d_2 = new MutableBlockVector2();
MutableBlockVector2 mpos2d = new MutableBlockVector2(); MutableBlockVector2 mpos2d = new MutableBlockVector2();
{ {
mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE); mpos2d.setComponents(Integer.MIN_VALUE, Integer.MIN_VALUE);
} }
@Override @Override
public boolean apply(BlockVector3 mutable) throws WorldEditException { public boolean apply(BlockVector3 mutable) throws WorldEditException {
BlockStateHolder block = clipboard.getBlock(mutable); BlockStateHolder block = clipboard.getBlock(mutable);
@ -257,7 +268,8 @@ public class Schematic {
if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) { if (copyBiomes && xx != mpos2d.getBlockX() && zz != mpos2d.getBlockZ()) {
mpos2d.setComponents(xx, zz); mpos2d.setComponents(xx, zz);
// extent.setBiome(mpos2d, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ()))); // extent.setBiome(mpos2d, clipboard.getBiome(mpos2d_2.setComponents(mutable.getBlockX(), mutable.getBlockZ())));
extent.setBiome(mpos2d, clipboard.getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ()))); extent.setBiome(mpos2d, clipboard
.getBiome(BlockVector2.at(mutable.getBlockX(), mutable.getBlockZ())));
} }
if (!pasteAir && block.getBlockType().getMaterial().isAir()) { if (!pasteAir && block.getBlockType().getMaterial().isAir()) {
return false; return false;
@ -275,11 +287,14 @@ public class Schematic {
// entities // entities
for (Entity entity : clipboard.getEntities()) { for (Entity entity : clipboard.getEntities()) {
// skip players on pasting schematic // skip players on pasting schematic
if (entity.getState() != null && entity.getState().getType().getId().equals("minecraft:player")) { if (entity.getState() != null && entity.getState().getType().getId()
.equals("minecraft:player")) {
continue; continue;
} }
Location pos = entity.getLocation(); Location pos = entity.getLocation();
Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX, pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(), pos.getPitch()); Location newPos = new Location(pos.getExtent(), pos.getX() + entityOffsetX,
pos.getY() + entityOffsetY, pos.getZ() + entityOffsetZ, pos.getYaw(),
pos.getPitch());
extent.createEntity(newPos, entity.getState()); extent.createEntity(newPos, entity.getState());
} }
} }

Datei anzeigen

@ -10,8 +10,8 @@ public class CleanTextureUtil extends TextureUtil {
super(parent.getFolder()); super(parent.getFolder());
this.min = minPercent; this.min = minPercent;
this.max = maxPercent; this.max = maxPercent;
int minIndex = ((parent.distances.length - 1) * minPercent) / 100; int minIndex = (parent.distances.length - 1) * minPercent / 100;
int maxIndex = ((parent.distances.length - 1) * maxPercent) / 100; int maxIndex = (parent.distances.length - 1) * maxPercent / 100;
long min = parent.distances[minIndex]; long min = parent.distances[minIndex];
long max = parent.distances[maxIndex]; long max = parent.distances[maxIndex];
for (; minIndex > 0 && parent.distances[minIndex - 1] == min; minIndex--) ; for (; minIndex > 0 && parent.distances[minIndex - 1] == min; minIndex--) ;
@ -44,4 +44,4 @@ public class CleanTextureUtil extends TextureUtil {
public int getMax() { public int getMax() {
return max; return max;
} }
} }

Datei anzeigen

@ -1,5 +1,7 @@
package com.boydti.fawe.util; package com.boydti.fawe.util;
import static com.google.common.base.Preconditions.checkNotNull;
import com.boydti.fawe.Fawe; import com.boydti.fawe.Fawe;
import com.boydti.fawe.FaweAPI; import com.boydti.fawe.FaweAPI;
import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.BBC;
@ -24,12 +26,9 @@ import com.sk89q.worldedit.extent.inventory.BlockBag;
import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.regions.Region;
import com.sk89q.worldedit.util.eventbus.EventBus; import com.sk89q.worldedit.util.eventbus.EventBus;
import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.World;
import java.util.UUID;
import javax.annotation.Nonnull; import javax.annotation.Nonnull;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import java.util.UUID;
import static com.google.common.base.Preconditions.checkNotNull;
public class EditSessionBuilder { public class EditSessionBuilder {
private World world; private World world;
@ -294,7 +293,7 @@ public class EditSessionBuilder {
} }
if (checkMemory) { if (checkMemory) {
if (MemUtil.isMemoryLimitedSlow()) { if (MemUtil.isMemoryLimitedSlow()) {
if (Perm.hasPermission(player, "worldedit.fast")) { if (Permission.hasPermission(player.toWorldEditPlayer(), "worldedit.fast")) {
BBC.WORLDEDIT_OOM_ADMIN.send(player); BBC.WORLDEDIT_OOM_ADMIN.send(player);
} }
throw FaweException.LOW_MEMORY; throw FaweException.LOW_MEMORY;

Datei anzeigen

@ -15,14 +15,14 @@ public final class IOUtil {
int ch4 = in.read(); int ch4 = in.read();
if ((ch1 | ch2 | ch3 | ch4) < 0) if ((ch1 | ch2 | ch3 | ch4) < 0)
throw new EOFException(); throw new EOFException();
return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); return (ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0);
} }
public static void writeInt(OutputStream out, int v) throws IOException { public static void writeInt(OutputStream out, int v) throws IOException {
out.write((v >>> 24) & 0xFF); out.write(v >>> 24 & 0xFF);
out.write((v >>> 16) & 0xFF); out.write(v >>> 16 & 0xFF);
out.write((v >>> 8) & 0xFF); out.write(v >>> 8 & 0xFF);
out.write((v >>> 0) & 0xFF); out.write(v >>> 0 & 0xFF);
} }
public static int readVarInt(InputStream in) throws IOException { public static int readVarInt(InputStream in) throws IOException {
@ -30,7 +30,7 @@ public final class IOUtil {
int offset = 0; int offset = 0;
int b; int b;
while ((b = in.read()) > 127) { while ((b = in.read()) > 127) {
i |= (b - 128) << offset; i |= b - 128 << offset;
offset += 7; offset += 7;
} }
i |= b << offset; i |= b << offset;

Datei anzeigen

@ -17,12 +17,12 @@ public class ImgurUtility {
return uploadImage(new FileInputStream(file)); return uploadImage(new FileInputStream(file));
} }
public static URL uploadImage(InputStream is) throws IOException { public static URL uploadImage(InputStream inputStream) throws IOException {
is = new BufferedInputStream(is); inputStream = new BufferedInputStream(inputStream);
FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE); FastByteArrayOutputStream baos = new FastByteArrayOutputStream(Short.MAX_VALUE);
int d; int i;
while ((d = is.read()) != -1) { while ((i = inputStream.read()) != -1) {
baos.write(d); baos.write(i);
} }
baos.flush(); baos.flush();
return uploadImage(baos.toByteArray()); return uploadImage(baos.toByteArray());

Datei anzeigen

@ -1,44 +0,0 @@
package com.boydti.fawe.util;
import com.boydti.fawe.object.FawePlayer;
public enum Perm {
/*
* Permission related functions
*/
ADMIN("fawe.admin", "admin");
public String s;
public String cat;
Perm(String perm, String cat) {
this.s = perm;
this.cat = cat;
}
public boolean has(FawePlayer<?> player) {
return this.hasPermission(player, this);
}
public boolean hasPermission(FawePlayer<?> player, Perm perm) {
return hasPermission(player, perm.s);
}
public static boolean hasPermission(FawePlayer<?> player, String perm) {
if (player == null || player.hasPermission(ADMIN.s)) {
return true;
}
if (player.hasPermission(perm)) {
return true;
}
final String[] nodes = perm.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i < nodes.length - 1; i++) {
n.append(nodes[i]).append(".");
if (player.hasPermission(n + "*")) {
return true;
}
}
return false;
}
}

Datei anzeigen

@ -0,0 +1,37 @@
package com.boydti.fawe.util;
import com.sk89q.worldedit.util.auth.Subject;
public enum Permission {
/*
* Permission related functions
*/
ADMIN("fawe.admin", "admin");
public String permission;
public String cat;
Permission(String permission, String category) {
this.permission = permission;
this.cat = category;
}
public static boolean hasPermission(Subject player, String permission) {
if (player == null || player.hasPermission(ADMIN.permission)) {
return true;
}
if (player.hasPermission(permission)) {
return true;
}
final String[] nodes = permission.split("\\.");
final StringBuilder n = new StringBuilder();
for (int i = 0; i < nodes.length - 1; i++) {
n.append(nodes[i]).append(".");
if (player.hasPermission(n + "*")) {
return true;
}
}
return false;
}
}

Datei anzeigen

@ -21,9 +21,9 @@ public class RandomTextureUtil extends CachedTextureUtil {
int red1 = (c1 >> 16) & 0xFF; int red1 = (c1 >> 16) & 0xFF;
int green1 = (c1 >> 8) & 0xFF; int green1 = (c1 >> 8) & 0xFF;
int blue1 = (c1 >> 0) & 0xFF; int blue1 = (c1 >> 0) & 0xFF;
byte red2 = (byte) ((c2 >> 16)); byte red2 = (byte) (c2 >> 16);
byte green2 = (byte) ((c2 >> 8)); byte green2 = (byte) (c2 >> 8);
byte blue2 = (byte) ((c2 >> 0)); byte blue2 = (byte) (c2 >> 0);
int red = MathMan.clamp(red1 + random(red2), 0, 255); int red = MathMan.clamp(red1 + random(red2), 0, 255);
int green = MathMan.clamp(green1 + random(green2), 0, 255); int green = MathMan.clamp(green1 + random(green2), 0, 255);
int blue = MathMan.clamp(blue1 + random(blue2), 0, 255); int blue = MathMan.clamp(blue1 + random(blue2), 0, 255);

Datei anzeigen

@ -8,10 +8,8 @@ import java.util.Comparator;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Objects;
import java.util.Set; import java.util.Set;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.IntStream; import java.util.stream.IntStream;
public class StringMan { public class StringMan {
@ -37,10 +35,8 @@ public class StringMan {
} }
public static boolean containsAny(CharSequence sequence, String any) { public static boolean containsAny(CharSequence sequence, String any) {
for (int i = 0; i < sequence.length(); i++) { return IntStream.range(0, sequence.length())
if (any.indexOf(sequence.charAt(i)) != -1) return true; .anyMatch(i -> any.indexOf(sequence.charAt(i)) != -1);
}
return false;
} }
public static boolean containsIgnoreCase(String haystack, String needle) { public static boolean containsIgnoreCase(String haystack, String needle) {
@ -122,14 +118,11 @@ public class StringMan {
int len = string.length(); int len = string.length();
for (int i = len - 1; i >= 0; i--) { for (int i = len - 1; i >= 0; i--) {
char c = string.charAt(i); char c = string.charAt(i);
switch (c) { if (c == '-') {
case '-': val = -val;
val = -val; } else {
break; val = val + (c - 48) * numIndex;
default: numIndex *= 10;
val = val + (c - 48) * numIndex;
numIndex *= 10;
break;
} }
} }
return val; return val;
@ -518,7 +511,8 @@ public class StringMan {
} }
public static boolean isEqualIgnoreCase(String a, String b) { public static boolean isEqualIgnoreCase(String a, String b) {
return ((a == b) || ((a != null) && (b != null) && (a.length() == b.length()) && a.equalsIgnoreCase(b))); return a == b ||
a != null && b != null && a.length() == b.length() && a.equalsIgnoreCase(b);
} }
public static String repeat(String s, int n) { public static String repeat(String s, int n) {

Datei anzeigen

@ -32,7 +32,7 @@ public class WEManager {
if (!(currentExtent instanceof NullExtent)) { if (!(currentExtent instanceof NullExtent)) {
field.set(parent, new NullExtent((Extent) field.get(parent), reason)); field.set(parent, new NullExtent((Extent) field.get(parent), reason));
} }
} catch (final Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
throw reason; throw reason;
@ -42,41 +42,33 @@ public class WEManager {
cancelEditSafe(parent, reason); cancelEditSafe(parent, reason);
} }
public boolean maskContains(final HashSet<RegionWrapper> mask, final int x, final int z) { public boolean maskContains(HashSet<RegionWrapper> mask, int x, int z) {
for (final RegionWrapper region : mask) { for (RegionWrapper region : mask) {
if ((x >= region.minX) && (x <= region.maxX) && (z >= region.minZ) && (z <= region.maxZ)) { if (x >= region.minX && x <= region.maxX && z >= region.minZ && z <= region.maxZ) {
return true; return true;
} }
} }
return false; return false;
} }
public boolean maskContains(RegionWrapper[] mask, final int x, final int z) { public boolean maskContains(RegionWrapper[] mask, int x, int z) {
switch (mask.length) { switch (mask.length) {
case 0: case 0:
return false; return false;
case 1: case 1:
return mask[0].isIn(x, z); return mask[0].isIn(x, z);
default: default:
for (final RegionWrapper region : mask) { return Arrays.stream(mask).anyMatch(region -> region.isIn(x, z));
if (region.isIn(x, z)) {
return true;
}
}
return false;
} }
} }
@Deprecated @Deprecated
public Region[] getMask(final FawePlayer<?> player) { public Region[] getMask(FawePlayer<?> player) {
return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType()); return getMask(player, FaweMaskManager.MaskType.getDefaultMaskType());
} }
public boolean isIn(int x, int y, int z, Region region) { public boolean isIn(int x, int y, int z, Region region) {
if (region.contains(x, y, z)) { return region.contains(x, y, z);
return true;
}
return false;
} }
/** /**
@ -85,7 +77,7 @@ public class WEManager {
* @param player * @param player
* @return * @return
*/ */
public Region[] getMask(final FawePlayer<?> player, FaweMaskManager.MaskType type) { public Region[] getMask(FawePlayer<?> player, FaweMaskManager.MaskType type) {
if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) { if (!Settings.IMP.REGION_RESTRICTIONS || player.hasPermission("fawe.bypass") || player.hasPermission("fawe.bypass.regions")) {
return new Region[]{RegionWrapper.GLOBAL()}; return new Region[]{RegionWrapper.GLOBAL()};
} }
@ -129,7 +121,7 @@ public class WEManager {
} }
} }
Set<FaweMask> tmpMasks = new HashSet<>(); Set<FaweMask> tmpMasks = new HashSet<>();
for (final FaweMaskManager manager : managers) { for (FaweMaskManager manager : managers) {
if (player.hasPermission("fawe." + manager.getKey())) { if (player.hasPermission("fawe." + manager.getKey())) {
try { try {
if (manager.isExclusive() && !masks.isEmpty()) continue; if (manager.isExclusive() && !masks.isEmpty()) continue;
@ -154,17 +146,19 @@ public class WEManager {
} }
public boolean intersects(final Region region1, final Region region2) { public boolean intersects(Region region1, Region region2) {
BlockVector3 rg1P1 = region1.getMinimumPoint(); BlockVector3 rg1P1 = region1.getMinimumPoint();
BlockVector3 rg1P2 = region1.getMaximumPoint(); BlockVector3 rg1P2 = region1.getMaximumPoint();
BlockVector3 rg2P1 = region2.getMinimumPoint(); BlockVector3 rg2P1 = region2.getMinimumPoint();
BlockVector3 rg2P2 = region2.getMaximumPoint(); BlockVector3 rg2P2 = region2.getMaximumPoint();
return (rg1P1.getBlockX() <= rg2P2.getBlockX()) && (rg1P2.getBlockX() >= rg2P1.getBlockX()) && (rg1P1.getBlockZ() <= rg2P2.getBlockZ()) && (rg1P2.getBlockZ() >= rg2P1.getBlockZ()); return rg1P1.getBlockX() <= rg2P2.getBlockX() && rg1P2.getBlockX() >= rg2P1.getBlockX() &&
rg1P1.getBlockZ() <= rg2P2.getBlockZ() &&
rg1P2.getBlockZ() >= rg2P1.getBlockZ();
} }
public boolean regionContains(final Region selection, final HashSet<Region> mask) { public boolean regionContains(Region selection, HashSet<Region> mask) {
for (final Region region : mask) { for (Region region : mask) {
if (this.intersects(region, selection)) { if (this.intersects(region, selection)) {
return true; return true;
} }
@ -172,29 +166,29 @@ public class WEManager {
return false; return false;
} }
public boolean delay(final FawePlayer<?> player, final String command) { public boolean delay(FawePlayer<?> player, String command) {
final long start = System.currentTimeMillis(); final long start = System.currentTimeMillis();
return this.delay(player, () -> { return this.delay(player, () -> {
try { try {
if ((System.currentTimeMillis() - start) > 1000) { if (System.currentTimeMillis() - start > 1000) {
BBC.WORLDEDIT_RUN.send(FawePlayer.wrap(player)); BBC.WORLDEDIT_RUN.send(FawePlayer.wrap(player));
} }
TaskManager.IMP.task(() -> { TaskManager.IMP.task(() -> {
final long start1 = System.currentTimeMillis(); final long start1 = System.currentTimeMillis();
player.executeCommand(command.substring(1)); player.executeCommand(command.substring(1));
TaskManager.IMP.later(() -> SetQueue.IMP.addEmptyTask(() -> { TaskManager.IMP.later(() -> SetQueue.IMP.addEmptyTask(() -> {
if ((System.currentTimeMillis() - start1) > 1000) { if (System.currentTimeMillis() - start1 > 1000) {
BBC.WORLDEDIT_COMPLETE.send(FawePlayer.wrap(player)); BBC.WORLDEDIT_COMPLETE.send(FawePlayer.wrap(player));
} }
}), 2); }), 2);
}); });
} catch (final Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
}, false, false); }, false, false);
} }
public boolean delay(final FawePlayer<?> player, final Runnable whenDone, final boolean delayed, final boolean onlyDelayedExecution) { public boolean delay(FawePlayer<?> player, Runnable whenDone, boolean delayed, boolean onlyDelayedExecution) {
final boolean free = SetQueue.IMP.addEmptyTask(null); final boolean free = SetQueue.IMP.addEmptyTask(null);
if (free) { if (free) {
if (delayed) { if (delayed) {
@ -202,14 +196,14 @@ public class WEManager {
whenDone.run(); whenDone.run();
} }
} else { } else {
if ((whenDone != null) && !onlyDelayedExecution) { if (whenDone != null && !onlyDelayedExecution) {
whenDone.run(); whenDone.run();
} else { } else {
return false; return false;
} }
} }
} else { } else {
if (!delayed && (player != null)) { if (!delayed && player != null) {
BBC.WORLDEDIT_DELAYED.send(player); BBC.WORLDEDIT_DELAYED.send(player);
} }
SetQueue.IMP.addEmptyTask(whenDone); SetQueue.IMP.addEmptyTask(whenDone);

Datei anzeigen

@ -1,21 +0,0 @@
package com.boydti.fawe.util.chat;
import com.boydti.fawe.object.FawePlayer;
public interface ChatManager<T> {
T builder();
void color(Message message, String color);
void tooltip(Message message, Message... tooltip);
void command(Message message, String command);
void text(Message message, String text);
void send(Message message, FawePlayer player);
void suggest(Message message, String command);
void link(Message message, String url);
}

Datei anzeigen

@ -1,127 +0,0 @@
package com.boydti.fawe.util.chat;
import com.boydti.fawe.Fawe;
import com.boydti.fawe.config.BBC;
import com.boydti.fawe.object.FawePlayer;
import com.sk89q.worldedit.extension.platform.Actor;
import java.io.Serializable;
import java.util.Objects;
public class Message {
private Object builder;
private boolean active;
public Message() {
try {
reset(Fawe.get().getChatManager());
} catch (Throwable e) {
Fawe.debug("Doesn't support fancy chat for " + Fawe.imp().getPlatform());
Fawe.get().setChatManager(new PlainChatManager());
reset(Fawe.get().getChatManager());
}
active = !(Fawe.get().getChatManager() instanceof PlainChatManager);
}
public Message(String text) {
this();
text(text);
}
public <T> T $(ChatManager<T> manager) {
return (T) this.builder;
}
public <T> T reset(ChatManager<T> manager) {
return (T) (this.builder = manager.builder());
}
public boolean supportsInteraction() {
return active;
}
public Message text(BBC caption, Object... args) {
return text(caption.format(args));
}
public Message text(Serializable text) {
Fawe.get().getChatManager().text(this, BBC.color(Objects.toString(text)));
return this;
}
public Message link(String text) {
Fawe.get().getChatManager().link(this, text);
return this;
}
public Message tooltip(Message... tooltip) {
Fawe.get().getChatManager().tooltip(this, tooltip);
return this;
}
public Message tooltip(String tooltip) {
return tooltip(new Message(tooltip));
}
public Message command(String command) {
Fawe.get().getChatManager().command(this, "/" + command);
return this;
}
public Message newline() {
return text("\n");
}
public Message cmdTip(String commandAndTooltip) {
return tooltip(commandAndTooltip).command(commandAndTooltip);
}
public Message linkTip(String linkAndTooltip) {
return tooltip(linkAndTooltip).link(linkAndTooltip);
}
public Message cmdOptions(String prefix, String suffix, String... options) {
for (int i = 0; i < options.length; i++) {
if (i != 0) text(" | ");
text("[" + options[i] + "]")
.cmdTip(prefix + options[i] + suffix);
}
return this;
}
public Message suggestTip(String commandAndTooltip) {
return tooltip(commandAndTooltip).suggest(commandAndTooltip);
}
public Message suggest(String command) {
Fawe.get().getChatManager().suggest(this, command);
return this;
}
public void send(Actor player) {
send(FawePlayer.wrap(player));
}
public void send(FawePlayer player) {
Fawe.get().getChatManager().send(this, player);
}
public Message paginate(String baseCommand, int page, int totalPages) {
if (!active) {
return text(BBC.PAGE_FOOTER.format(baseCommand, page + 1));
}
if (page < totalPages && page > 1) { // Back | Next
this.text("<<").command(baseCommand + " " + (page - 1)).text(" | ").text(">>")
.command(baseCommand + " " + (page + 1));
} else if (page <= 1 && totalPages > page) { // Next
this.text(" -").text(" | ").text(">>")
.command(baseCommand + " " + (page + 1));
} else if (page == totalPages && totalPages > 1) { // Back
this.text("<<").command(baseCommand + " " + (page - 1)).text(" | ").text("- ");
} else {
this.text(" - | - ");
}
return this;
}
}

Einige Dateien werden nicht angezeigt, da zu viele Dateien in diesem Diff geändert wurden Mehr anzeigen