diff --git a/config/checkstyle/checkstyle.xml b/config/checkstyle/checkstyle.xml index 89177a84c..bef46365f 100644 --- a/config/checkstyle/checkstyle.xml +++ b/config/checkstyle/checkstyle.xml @@ -1,7 +1,7 @@ + "https://checkstyle.org/dtds/configuration_1_3.dtd"> @@ -16,9 +16,11 @@ Control package usage, so people don't insert Bukkit into WE where it shouldn't belong, etc. It is a bit draconian, so update as necessary! --> + @@ -63,6 +65,10 @@ + + + + diff --git a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java index b29975775..83c6b29ff 100644 --- a/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java +++ b/favs/src/main/java/com/thevoxelbox/voxelsniper/jsap/HelpJSAP.java @@ -30,7 +30,7 @@ public class HelpJSAP extends JSAP { * @param explanation * @param screenWidth */ - public HelpJSAP(final String name, final String explanation, final int screenWidth) { + public HelpJSAP(String name, String explanation, int screenWidth) { super(); this.name = name; @@ -39,7 +39,7 @@ public class HelpJSAP extends JSAP { try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (final JSAPException e) { + } catch (JSAPException ignored) { } } @@ -48,10 +48,10 @@ public class HelpJSAP extends JSAP { * @param explanation * @param screenWidth * @param resourceName - * @throws java.io.IOException if an I/O error occurs - * @throws com.martiansoftware.jsap.JSAPException if the configuration is not valid + * @throws IOException if an I/O error occurs + * @throws JSAPException if the configuration is not valid */ - public HelpJSAP(final String name, final String explanation, final int screenWidth, final String resourceName) throws IOException, JSAPException { + public HelpJSAP(String name, String explanation, int screenWidth, String resourceName) throws IOException, JSAPException { super(resourceName); this.name = name; @@ -60,7 +60,7 @@ public class HelpJSAP extends JSAP { try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (final JSAPException e) { + } catch (JSAPException ignored) { } } @@ -69,10 +69,10 @@ public class HelpJSAP extends JSAP { * @param explanation * @param screenWidth * @param jsapXML - * @throws java.io.IOException if an I/O error occurs - * @throws com.martiansoftware.jsap.JSAPException if the configuration is not valid + * @throws IOException if an I/O error occurs + * @throws JSAPException if the configuration is not valid */ - public HelpJSAP(final String name, final String explanation, final int screenWidth, final URL jsapXML) throws IOException, JSAPException { + public HelpJSAP(String name, String explanation, int screenWidth, URL jsapXML) throws IOException, JSAPException { super(jsapXML); this.name = name; @@ -81,7 +81,7 @@ public class HelpJSAP extends JSAP { try { this.registerParameter(new Switch("help", JSAP.NO_SHORTFLAG, "help", "Displays this help page.")); - } catch (final JSAPException e) { + } catch (JSAPException ignored) { } } @@ -95,7 +95,7 @@ public class HelpJSAP extends JSAP { /** * @param explanation the explanation to set */ - public final void setExplanation(final String explanation) { + public final void setExplanation(String explanation) { this.explanation = explanation; } @@ -109,7 +109,7 @@ public class HelpJSAP extends JSAP { /** * @param name the name to set */ - public final void setName(final String name) { + public final void setName(String name) { this.name = name; } @@ -123,7 +123,7 @@ public class HelpJSAP extends JSAP { /** * @param screenWidth the screenWidth to set */ - public final void setScreenWidth(final int screenWidth) { + public final void setScreenWidth(int screenWidth) { this.screenWidth = screenWidth; } @@ -131,8 +131,8 @@ public class HelpJSAP extends JSAP { * @param jsapResult * @return if something has been written on writer. */ - public final List writeHelpOrErrorMessageIfRequired(final JSAPResult jsapResult) { - if (!(jsapResult.success()) || jsapResult.getBoolean("help")) { + public final List writeHelpOrErrorMessageIfRequired(JSAPResult jsapResult) { + if (!jsapResult.success() || jsapResult.getBoolean("help")) { List returnValue = new LinkedList<>(); // To avoid spurious missing argument errors we never print errors if help is required. if (!jsapResult.getBoolean("help")) { @@ -145,14 +145,14 @@ public class HelpJSAP extends JSAP { returnValue.add(ChatColor.GOLD + "Usage:"); List l = StringUtils.wrapToList(this.name + " " + this.getUsage(), this.screenWidth); - for (final Object aL : l) { + for (Object aL : l) { returnValue.add(" " + aL.toString()); } if (this.explanation != null) { returnValue.add(""); l = StringUtils.wrapToList(this.explanation, this.screenWidth); - for (final Object aL : l) { + for (Object aL : l) { final String next = (String) aL; returnValue.add(ChatColor.AQUA + next); } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java index 02ff18c46..7fe7f7a9e 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/BukkitPlayer.java @@ -45,15 +45,15 @@ public class BukkitPlayer extends FawePlayer { * Permissions are used to managing WorldEdit region restrictions * - The `/wea` command will give/remove the required bypass permission */ - if (Fawe.imp().getVault() == null || Fawe. imp().getVault().permission == null) { - this.parent.addAttachment(Fawe. imp().getPlugin()).setPermission(perm, flag); + if (Fawe.imp().getVault() == null || Fawe.imp().getVault().permission == null) { + this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); } else if (flag) { - if (!Fawe. imp().getVault().permission.playerAdd(this.parent, perm)) { - this.parent.addAttachment(Fawe. imp().getPlugin()).setPermission(perm, flag); + if (!Fawe.imp().getVault().permission.playerAdd(this.parent, perm)) { + this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); } } else { - if (!Fawe. imp().getVault().permission.playerRemove(this.parent, perm)) { - this.parent.addAttachment(Fawe. imp().getPlugin()).setPermission(perm, flag); + if (!Fawe.imp().getVault().permission.playerRemove(this.parent, perm)) { + this.parent.addAttachment(Fawe.imp().getPlugin()).setPermission(perm, flag); } } } diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java index 22983d20a..2151f1408 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/chat/FancyMessage.java @@ -1,5 +1,7 @@ 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; @@ -12,10 +14,16 @@ import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.*; +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; @@ -24,20 +32,22 @@ import org.bukkit.configuration.serialization.ConfigurationSerialization; import org.bukkit.entity.Player; import org.jetbrains.annotations.NotNull; - -import static com.boydti.fawe.bukkit.chat.TextualComponent.rawText; - /** - * 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 JSON message formatter. - * This class allows plugins to emulate the functionality of the vanilla Minecraft tellraw command. + * 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 JSON message formatter. This + * class allows plugins to emulate the functionality of the vanilla Minecraft tellraw command. *

- * 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. + * 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. *

*/ -public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable, ConfigurationSerializable { +public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable, + ConfigurationSerializable { static { ConfigurationSerialization.registerClass(FancyMessage.class); @@ -80,10 +90,12 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< dirty = false; if (nmsPacketPlayOutChatConstructor == null) { try { - nmsPacketPlayOutChatConstructor = Reflection.getNMSClass("PacketPlayOutChat").getDeclaredConstructor(Reflection.getNMSClass("IChatBaseComponent")); + 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); + 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); } @@ -124,10 +136,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * * @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). + * @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(); @@ -148,7 +160,7 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< last = i + 1; } } - if (c == '\u00A7') { + if (c == '\u00A7') { color = true; } } @@ -161,12 +173,13 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Sets the color of the current editing component to a value.
- * Setting the color will clear current styles + * Sets the color of the current editing component to a value.
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). + * @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()) { @@ -189,7 +202,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< * * @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. + * @throws IllegalArgumentException If any of the enumeration values in the array do not + * represent formatters. */ public FancyMessage style(ChatColor... styles) { for (final ChatColor style : styles) { @@ -203,7 +217,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. @@ -214,7 +230,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. @@ -225,8 +243,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. @@ -237,8 +258,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. @@ -250,8 +274,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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 will immediately send the command to the server to be executed when the editing component is clicked. + * 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 will 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. @@ -262,10 +288,13 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Set the behavior of the current editing component to display raw text when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display raw text when the client hovers + * over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* - * @param text The text, which supports newlines, which will be displayed to the client upon hovering. + * @param text The text, which supports newlines, which will be displayed to the client upon + * hovering. * @return This builder instance. */ public FancyMessage tooltip(final String text) { @@ -274,10 +303,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Set the behavior of the current editing component to display raw text when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display raw text when the client hovers + * over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* - * @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. + * @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(final Iterable lines) { @@ -286,8 +319,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Set the behavior of the current editing component to display raw text when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display raw text when the client hovers + * over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* * @param lines The lines of text which will be displayed to the client upon hovering. * @return This builder instance. @@ -305,8 +340,10 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Set the behavior of the current editing component to display formatted text when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display formatted text when the client + * hovers over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* * @param text The formatted text which will be displayed to the client upon hovering. * @return This builder instance. @@ -324,10 +361,13 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Set the behavior of the current editing component to display the specified lines of formatted text when the client hovers over the text. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display the specified lines of formatted + * text when the client hovers over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* - * @param lines The lines of formatted text which will be displayed to the client upon hovering. + * @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) { @@ -337,15 +377,19 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } FancyMessage result = new FancyMessage(); - result.messageParts.clear(); // Remove the one existing text component that exists by default, which destabilizes the object + result.messageParts + .clear(); // Remove the one existing text component that exists by default, which destabilizes the object for (int i = 0; i < lines.length; i++) { 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."); + 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()); @@ -361,24 +405,32 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< return this; } } - return formattedTooltip(result.messageParts.isEmpty() ? null : result); // Throws NPE if size is 0, intended + 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. - *

Tooltips do not inherit display characteristics, such as color and styles, from the message component on which they are applied.

+ * Set the behavior of the current editing component to display the specified lines of formatted + * text when the client hovers over the text. + *

Tooltips do not inherit display characteristics, such as color and styles, from the + * message component on which they are applied.

* - * @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. + * @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(final Iterable lines) { - return formattedTooltip(com.boydti.fawe.bukkit.chat.ArrayWrapper.toArray(lines, FancyMessage.class)); + return formattedTooltip( + com.boydti.fawe.bukkit.chat.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. + * If the text is a translatable key, and it has replaceable values, this function can be used + * to set the replacements that will be used in the message. * - * @param replacements The replacements, in order, that will be used in the language-specific message. + * @param replacements The replacements, in order, that will be used in the language-specific + * message. * @return This builder instance. */ public FancyMessage translationReplacements(final String... replacements) { @@ -407,9 +459,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< */ /** - * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message. + * If the text is a translatable key, and it has replaceable values, this function can be used + * to set the replacements that will be used in the message. * - * @param replacements The replacements, in order, that will be used in the language-specific message. + * @param replacements The replacements, in order, that will be used in the language-specific + * message. * @return This builder instance. */ public FancyMessage translationReplacements(final FancyMessage... replacements) { @@ -421,18 +475,22 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * If the text is a translatable key, and it has replaceable values, this function can be used to set the replacements that will be used in the message. + * If the text is a translatable key, and it has replaceable values, this function can be used + * to set the replacements that will be used in the message. * - * @param replacements The replacements, in order, that will be used in the language-specific message. + * @param replacements The replacements, in order, that will be used in the language-specific + * message. * @return This builder instance. */ public FancyMessage translationReplacements(final Iterable replacements) { - return translationReplacements(com.boydti.fawe.bukkit.chat.ArrayWrapper.toArray(replacements, FancyMessage.class)); + return translationReplacements( + com.boydti.fawe.bukkit.chat.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. + * 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. @@ -454,8 +512,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. @@ -471,8 +530,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. */ @@ -500,8 +560,9 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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}. + * 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. */ @@ -523,7 +584,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * Sends this message to a player. The player will receive the fully-fledged formatted display of this message. + * 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. */ @@ -539,8 +601,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< 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)); + 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) { @@ -548,7 +613,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } 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); + 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) { @@ -560,7 +626,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< private static Object nmsChatSerializerGsonInstance; private static Method fromJsonMethod; - private Object createChatPacket(String json) throws IllegalArgumentException, IllegalAccessException, InstantiationException, InvocationTargetException, NoSuchMethodException, ClassNotFoundException { + 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; @@ -571,7 +638,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< // Y = minor // Z = revision final String version = Reflection.getVersion(); - String[] split = version.substring(1, version.length() - 1).split("_"); // Remove trailing dot + 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 @@ -587,11 +655,14 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } for (Field declaredField : chatSerializerClazz.getDeclaredFields()) { - if (Modifier.isFinal(declaredField.getModifiers()) && Modifier.isStatic(declaredField.getModifiers()) && declaredField.getType().getName().endsWith("Gson")) { + if (Modifier.isFinal(declaredField.getModifiers()) && Modifier + .isStatic(declaredField.getModifiers()) && declaredField.getType().getName() + .endsWith("Gson")) { // We've found our field declaredField.setAccessible(true); nmsChatSerializerGsonInstance = declaredField.get(null); - fromJsonMethod = nmsChatSerializerGsonInstance.getClass().getMethod("fromJson", String.class, Class.class); + fromJsonMethod = nmsChatSerializerGsonInstance.getClass() + .getMethod("fromJson", String.class, Class.class); break; } } @@ -599,15 +670,16 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< // Since the method is so simple, and all the obfuscated methods have the same name, it's easier to reimplement 'IChatBaseComponent a(String)' 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")); + 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. + * 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() @@ -630,10 +702,11 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. *

- * Serialization of this message by using this message will include (in this order for each message part): + * Serialization of this message by using this message will include (in this order for each + * message part): *

    *
  1. The color of each message part.
  2. *
  3. The applicable stylizations for each message part.
  4. @@ -644,7 +717,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< *

    * Color and formatting can be removed from the returned string by using {@link ChatColor#stripColor(String)}.

    * - * @return A human-readable string representing limited formatting in addition to the core text of this message. + * @return A human-readable string representing limited formatting in addition to the core text + * of this message. */ public String toOldMessageFormat() { StringBuilder result = new StringBuilder(); @@ -669,12 +743,18 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } private void onClick(final String name, final String data) { - onCurrent(m -> { m.clickActionName = name; m.clickActionData = data; }); + onCurrent(m -> { + m.clickActionName = name; + m.clickActionData = data; + }); dirty = true; } private void onHover(final String name, final JsonRepresentedObject data) { - onCurrent(m -> { m.hoverActionName = name; m.hoverActionData = data; }); + onCurrent(m -> { + m.hoverActionName = name; + m.hoverActionData = data; + }); dirty = true; } @@ -687,9 +767,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< } /** - * 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. + * 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. */ @@ -713,8 +792,8 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< 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. + * 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. @@ -738,17 +817,21 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< serializedMapForm.put("value", entry.getValue().getAsString()); } else { // Composite object, but we assume each element is a string - for (Map.Entry compositeNestedElement : entry.getValue().getAsJsonObject().entrySet()) { - serializedMapForm.put("value." + compositeNestedElement.getKey(), compositeNestedElement.getValue().getAsString()); + for (Map.Entry 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())); + component.styles + .add(MessagePart.stylesToNames.inverse().get(entry.getKey())); } } else if (entry.getKey().equals("color")) { - component.color = ChatColor.valueOf(entry.getValue().getAsString().toUpperCase()); + 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(); @@ -758,19 +841,22 @@ public class FancyMessage implements JsonRepresentedObject, Cloneable, Iterable< component.hoverActionName = object.get("action").getAsString(); if (object.get("value").isJsonPrimitive()) { // Assume string - component.hoverActionData = new JsonString(object.get("value").getAsString()); + 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 */); + 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())); + 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 diff --git a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java index e7bef8045..56af3100c 100644 --- a/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java +++ b/worldedit-bukkit/src/main/java/com/boydti/fawe/bukkit/v0/ChunkListener.java @@ -15,7 +15,6 @@ import org.bukkit.World; import org.bukkit.block.Block; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; -import org.bukkit.event.Event; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.Listener; @@ -39,30 +38,31 @@ import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.inventory.FurnaceBurnEvent; import org.bukkit.event.inventory.FurnaceSmeltEvent; import org.bukkit.event.world.ChunkLoadEvent; -import org.bukkit.plugin.EventExecutor; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.PluginManager; import org.bukkit.util.Vector; -import java.lang.reflect.Method; -import java.util.List; - public abstract class ChunkListener implements Listener { protected int rateLimit = 0; protected Location lastCancelPos; - private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS}; + private int[] badLimit = new int[]{Settings.IMP.TICK_LIMITER.PHYSICS_MS, + Settings.IMP.TICK_LIMITER.FALLING, Settings.IMP.TICK_LIMITER.ITEMS}; public ChunkListener() { if (Settings.IMP.TICK_LIMITER.ENABLED) { PluginManager plm = Bukkit.getPluginManager(); Plugin plugin = Fawe.imp().getPlugin(); plm.registerEvents(this, plugin); - try { plm.registerEvents(new ChunkListener_8Plus(this), plugin); } catch (Throwable ignore) {} + try { + plm.registerEvents(new ChunkListener_8Plus(this), plugin); + } catch (Throwable ignore) { + } TaskManager.IMP.repeat(() -> { Location tmpLoc = lastCancelPos; if (tmpLoc != null) { - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + tmpLoc); + Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled physics lag source at " + + tmpLoc); } rateLimit--; physicsFreeze = false; @@ -86,6 +86,7 @@ public abstract class ChunkListener implements Listener { } protected abstract int getDepth(Exception ex); + protected abstract StackTraceElement getElement(Exception ex, int index); public static boolean physicsFreeze = false; @@ -105,7 +106,7 @@ public abstract class ChunkListener implements Listener { long pair = MathMan.pairInt(cx, cz); int[] tmp = lastCount = counter.get(pair); if (tmp == null) { - lastCount = tmp = new int[3]; + lastCount = tmp = new int[3]; counter.put(pair, tmp); } return tmp; @@ -134,34 +135,54 @@ public abstract class ChunkListener implements Listener { } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockBurnEvent event) { reset(); } + public void event(BlockBurnEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockCanBuildEvent event) { reset(); } + public void event(BlockCanBuildEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockDamageEvent event) { reset(); } + public void event(BlockDamageEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockDispenseEvent event) { reset(); } + public void event(BlockDispenseEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockExpEvent event) { reset(); } + public void event(BlockExpEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockFadeEvent event) { reset(); } + public void event(BlockFadeEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockFromToEvent event) { reset(); } + public void event(BlockFromToEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockGrowEvent event) { reset(); } + public void event(BlockGrowEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockIgniteEvent event) { reset(); } + public void event(BlockIgniteEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockPlaceEvent event) { reset(); } + public void event(BlockPlaceEvent event) { + reset(); + } // @EventHandler(priority = EventPriority.LOWEST) // public void event(BrewEvent event) { reset(); } @@ -173,22 +194,34 @@ public abstract class ChunkListener implements Listener { // public void event(CauldronLevelChangeEvent event ) { reset(); } @EventHandler(priority = EventPriority.LOWEST) - public void event(FurnaceBurnEvent event) { reset(); } + public void event(FurnaceBurnEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(FurnaceSmeltEvent event) { reset(); } + public void event(FurnaceSmeltEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(LeavesDecayEvent event) { reset(); } + public void event(LeavesDecayEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(NotePlayEvent event) { reset(); } + public void event(NotePlayEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(SignChangeEvent event) { reset(); } + public void event(SignChangeEvent event) { + reset(); + } @EventHandler(priority = EventPriority.LOWEST) - public void event(BlockRedstoneEvent event) { reset(); } + public void event(BlockRedstoneEvent event) { + reset(); + } @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPhysics(BlockPhysicsEvent event) { @@ -209,13 +242,16 @@ public abstract class ChunkListener implements Listener { return; } } else { - if ((++physSkip & 1023) != 0) return; + if ((++physSkip & 1023) != 0) { + return; + } FaweTimer timer = Fawe.get().getTimer(); if (timer.getTick() != physTick) { physTick = timer.getTick(); physStart = System.currentTimeMillis(); return; - } else if (System.currentTimeMillis() - physStart < Settings.IMP.TICK_LIMITER.PHYSICS_MS) { + } else if (System.currentTimeMillis() - physStart + < Settings.IMP.TICK_LIMITER.PHYSICS_MS) { return; } } @@ -255,7 +291,8 @@ public abstract class ChunkListener implements Listener { if (elem != null) { String methodName = elem.getMethodName(); // setAir | setTypeAndData (hacky, but this needs to be efficient) - if (methodName.charAt(0) == 's' && methodName.length() == 6 || methodName.length() == 14) { + if (methodName.charAt(0) == 's' && methodName.length() == 6 + || methodName.length() == 14) { return true; } } @@ -324,6 +361,7 @@ public abstract class ChunkListener implements Listener { /** * Prevent FireWorks from loading chunks + * * @param event */ @EventHandler(priority = EventPriority.LOWEST) @@ -340,16 +378,22 @@ public abstract class ChunkListener implements Listener { for (int frame = start; frame < depth; frame++) { StackTraceElement elem = getElement(e, frame); - if (elem == null) return; + if (elem == null) { + return; + } String className = elem.getClassName(); int len = className.length(); - if (len > 15 && className.charAt(len - 15) == 'E' && className.endsWith("EntityFireworks")) { + if (len > 15 && className.charAt(len - 15) == 'E' && className + .endsWith("EntityFireworks")) { for (Entity ent : world.getEntities()) { if (ent.getType() == EntityType.FIREWORK) { Vector velocity = ent.getVelocity(); double vertical = Math.abs(velocity.getY()); - if (Math.abs(velocity.getX()) > vertical || Math.abs(velocity.getZ()) > vertical) { - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + ent.getLocation()); + if (Math.abs(velocity.getX()) > vertical + || Math.abs(velocity.getZ()) > vertical) { + Fawe.debug( + "[FAWE `tick-limiter`] Detected and cancelled rogue FireWork at " + + ent.getLocation()); ent.remove(); } } @@ -378,7 +422,8 @@ public abstract class ChunkListener implements Listener { cancelNearby(cx, cz); if (rateLimit <= 0) { rateLimit = 20; - Fawe.debug("[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc); + Fawe.debug( + "[FAWE `tick-limiter`] Detected and cancelled item lag source at " + loc); } event.setCancelled(true); return; diff --git a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java index c74c8f382..eb0c2e382 100644 --- a/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java +++ b/worldedit-core/src/legacy/java/com/sk89q/worldedit/blocks/MobSpawnerBlock.java @@ -90,7 +90,7 @@ public class MobSpawnerBlock extends BaseBlock { /** * Get the spawn delay. - * + * * @return the delay */ public short getDelay() { @@ -99,13 +99,13 @@ public class MobSpawnerBlock extends BaseBlock { /** * Set the spawn delay. - * + * * @param delay the delay to set */ public void setDelay(short delay) { this.delay = delay; } - + @Override public boolean hasNbtData() { return true; @@ -208,7 +208,7 @@ public class MobSpawnerBlock extends BaseBlock { this.spawnCount = spawnCountTag.getValue(); } if (spawnRangeTag != null) { - this.spawnRange =spawnRangeTag.getValue(); + this.spawnRange = spawnRangeTag.getValue(); } if (minSpawnDelayTag != null) { this.minSpawnDelay = minSpawnDelayTag.getValue(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java index 51e0f6e9b..40f40592f 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/IFawe.java @@ -13,6 +13,7 @@ import java.util.Collection; import java.util.UUID; public interface IFawe { + void debug(final String s); File getDirectory(); @@ -31,7 +32,9 @@ public interface IFawe { void startMetrics(); - default ImageViewer getImageViewer(FawePlayer player) { return null; } + default ImageViewer getImageViewer(FawePlayer player) { + return null; + } default int getPlayerCount() { return Fawe.get().getCachedPlayers().size(); diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java index 0c24cc27b..273efc414 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/CFICommands.java @@ -4,7 +4,6 @@ import static com.boydti.fawe.util.image.ImageUtil.load; import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; -import com.boydti.fawe.beta.IQueueExtent; import com.boydti.fawe.beta.SingleFilterBlock; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Commands; @@ -21,17 +20,6 @@ import com.boydti.fawe.util.TaskManager; import com.boydti.fawe.util.TextureUtil; import com.boydti.fawe.util.chat.Message; import com.boydti.fawe.util.image.ImageUtil; -import com.sk89q.worldedit.command.util.CommandPermissionsConditionGenerator; - -import java.nio.file.Path; -import java.util.function.Consumer; -import java.util.stream.IntStream; - -import com.sk89q.worldedit.extension.platform.binding.ProvideBindings; -import com.sk89q.worldedit.util.formatting.text.TextComponent; -import org.enginehub.piston.annotation.Command; -import org.enginehub.piston.exception.StopExecutionException; -import org.enginehub.piston.inject.InjectedValueAccess; import com.sk89q.minecraft.util.commands.CommandException; import com.sk89q.worldedit.EmptyClipboardException; import com.sk89q.worldedit.LocalSession; @@ -45,6 +33,7 @@ import com.sk89q.worldedit.extension.input.InputParseException; import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.extension.platform.Capability; import com.sk89q.worldedit.extension.platform.Platform; +import com.sk89q.worldedit.extension.platform.binding.ProvideBindings; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.io.ClipboardFormats; import com.sk89q.worldedit.function.mask.Mask; @@ -55,6 +44,7 @@ import com.sk89q.worldedit.registry.state.PropertyKey; import com.sk89q.worldedit.session.ClipboardHolder; import com.sk89q.worldedit.session.request.Request; import com.sk89q.worldedit.util.Location; +import com.sk89q.worldedit.util.formatting.text.TextComponent; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.biome.BiomeType; import com.sk89q.worldedit.world.block.BlockStateHolder; @@ -67,6 +57,7 @@ import java.io.File; import java.io.FileNotFoundException; import java.io.IOException; import java.net.URL; +import java.nio.file.Path; import java.text.DateFormat; import java.text.SimpleDateFormat; import java.util.ArrayDeque; @@ -74,6 +65,7 @@ import java.util.Date; import java.util.HashSet; import java.util.List; import java.util.Set; +import java.util.function.Consumer; import java.util.function.Function; import java.util.stream.IntStream; import javax.imageio.ImageIO; @@ -81,6 +73,7 @@ import org.enginehub.piston.annotation.Command; import org.enginehub.piston.annotation.CommandContainer; import org.enginehub.piston.annotation.param.Arg; import org.enginehub.piston.annotation.param.Switch; +import org.enginehub.piston.exception.StopExecutionException; import org.enginehub.piston.inject.InjectedValueAccess; @CommandContainer(superTypes = CommandPermissionsConditionGenerator.Registration.class) @@ -254,7 +247,7 @@ public class CFICommands extends MethodCommands { desc = "Set the floor and main block" ) @CommandPermissions("worldedit.anvil.cfi") - public void column(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void column(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setColumn(load(image), pattern, !disableWhiteOnly); @@ -273,14 +266,14 @@ public class CFICommands extends MethodCommands { desc = "Set the floor (default: grass)" ) @CommandPermissions("worldedit.anvil.cfi") - public void floorCmd(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void floorCmd(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ floor(fp, pattern, image, mask, disableWhiteOnly); fp.sendMessage("Set floor!"); assertSettings(fp).resetComponent(); component(fp); } - private void floor(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly) { + private void floor(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly) { HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setFloor(load(image), pattern, !disableWhiteOnly); @@ -296,14 +289,14 @@ public class CFICommands extends MethodCommands { desc = "Set the main block (default: stone)" ) @CommandPermissions("worldedit.anvil.cfi") - public void mainCmd(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void mainCmd(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ main(fp, pattern, image, mask, disableWhiteOnly); fp.sendMessage("Set main!"); assertSettings(fp).resetComponent(); component(fp); } - public void main(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void main(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setMain(load(image), pattern, !disableWhiteOnly); @@ -322,7 +315,7 @@ public class CFICommands extends MethodCommands { "e.g. Tallgrass" ) @CommandPermissions("worldedit.anvil.cfi") - public void overlay(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void overlay(FawePlayer fp, Pattern pattern, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setOverlay(load(image), pattern, !disableWhiteOnly); @@ -344,13 +337,13 @@ public class CFICommands extends MethodCommands { " - A good value for radius and iterations would be 1 8." ) @CommandPermissions("worldedit.anvil.cfi") - public void smoothCmd(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void smoothCmd(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ smooth(fp, radius, iterations, image, mask, disableWhiteOnly); assertSettings(fp).resetComponent(); component(fp); } - private void smooth(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + private void smooth(FawePlayer fp, int radius, int iterations, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.smooth(load(image), !disableWhiteOnly, radius, iterations); @@ -364,7 +357,7 @@ public class CFICommands extends MethodCommands { desc = "Create some snow" ) @CommandPermissions("worldedit.anvil.cfi") - public void snow(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void snow(FawePlayer fp, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); floor(fp, BlockTypes.SNOW.getDefaultState().with(PropertyKey.LAYERS, 7), image, mask, disableWhiteOnly); main(fp, BlockTypes.SNOW_BLOCK, image, mask, disableWhiteOnly); @@ -533,7 +526,7 @@ public class CFICommands extends MethodCommands { " - If a mask is used, the biome will be set anywhere the mask applies" ) @CommandPermissions("worldedit.anvil.cfi") - public void biome(FawePlayer fp, BiomeType biome, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name='w', desc = "TODO") boolean disableWhiteOnly){ + public void biome(FawePlayer fp, BiomeType biome, @Arg(def = "", desc = "image url or filename") ProvideBindings.ImageUri image, @Arg(name = "mask", desc = "Mask", def = "") Mask mask, @Switch(name = 'w', desc = "TODO") boolean disableWhiteOnly){ HeightMapMCAGenerator gen = assertSettings(fp).getGenerator(); if (image != null) { gen.setBiome(load(image), biome, !disableWhiteOnly); @@ -700,7 +693,7 @@ public class CFICommands extends MethodCommands { ) // ![79,174,212,5:3,5:4,18,161,20] @CommandPermissions("worldedit.anvil.cfi") - 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); settings.getGenerator().setColorWithGlass(load(image)); msg("Set color with glass!").send(fp); @@ -717,7 +710,7 @@ public class CFICommands extends MethodCommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - public void color(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 color(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); HeightMapMCAGenerator gen = settings.getGenerator(); if (imageMask != null) { @@ -741,7 +734,7 @@ public class CFICommands extends MethodCommands { "The -w (disableWhiteOnly) will randomly apply depending on the pixel luminance" ) @CommandPermissions("worldedit.anvil.cfi") - 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); settings.getGenerator().setBlockAndBiomeColor(load(image), mask, load(imageMask), !disableWhiteOnly); msg("Set color with blocks and biomes!").send(fp); @@ -757,7 +750,7 @@ public class CFICommands extends MethodCommands { " - If you changed the block to something other than grass you will not see anything." ) @CommandPermissions("worldedit.anvil.cfi") - 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); settings.getGenerator().setBiomeColor(load(image)); msg("Set color with biomes!").send(fp); @@ -856,7 +849,7 @@ public class CFICommands extends MethodCommands { desc = "Select a mask" ) @CommandPermissions("worldedit.anvil.cfi") - public void mask(FawePlayer fp, @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, InjectedValueAccess context){ + public void mask(FawePlayer fp, @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, InjectedValueAccess context){ CFISettings settings = assertSettings(fp); String[] split = getArguments(context).split(" "); int index = 2; diff --git a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java index 0645a9dba..1043018c6 100644 --- a/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java +++ b/worldedit-core/src/main/java/com/boydti/fawe/command/Rollback.java @@ -4,22 +4,21 @@ import com.boydti.fawe.Fawe; import com.boydti.fawe.FaweAPI; import com.boydti.fawe.config.BBC; import com.boydti.fawe.config.Settings; -import com.boydti.fawe.object.*; +import com.boydti.fawe.object.FaweCommand; +import com.boydti.fawe.object.FawePlayer; +import com.boydti.fawe.object.RegionWrapper; +import com.boydti.fawe.object.RunnableVal; import com.boydti.fawe.object.changeset.DiskStorageHistory; import com.boydti.fawe.util.MainUtil; import com.boydti.fawe.util.MathMan; -import com.boydti.fawe.util.TaskManager; import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.util.Location; import com.sk89q.worldedit.world.World; import com.sk89q.worldedit.world.block.BlockState; - import java.util.Arrays; import java.util.List; import java.util.Map; import java.util.UUID; -import java.util.concurrent.Callable; -import java.util.concurrent.Future; public class Rollback extends FaweCommand { @@ -53,9 +52,6 @@ public class Rollback extends FaweCommand { } World world = player.getWorld(); switch (args[0]) { - default: - BBC.COMMAND_SYNTAX.send(player, "/frb info u: r: t: