From 478ce3f627d93609d871a127ad8439d5d2c6a710 Mon Sep 17 00:00:00 2001 From: sk89q Date: Fri, 4 Apr 2014 14:35:12 -0700 Subject: [PATCH] Fixed utility classes having constructors. --- .../com/sk89q/worldedit/forge/ForgeUtil.java | 5 +++- src/main/java/com/sk89q/util/ArrayUtil.java | 5 +++- .../java/com/sk89q/util/ReflectionUtil.java | 7 ++++- src/main/java/com/sk89q/util/StringUtil.java | 6 ++++- .../java/com/sk89q/worldedit/LocalWorld.java | 5 +++- .../com/sk89q/worldedit/blocks/BlockData.java | 4 +++ .../com/sk89q/worldedit/blocks/BlockID.java | 2 ++ .../com/sk89q/worldedit/blocks/ItemID.java | 3 +++ .../expression/parser/ParserProcessors.java | 13 +++++----- .../expression/runtime/Functions.java | 14 +++++----- .../expression/runtime/Operators.java | 3 +++ .../internal/util/DocumentationPrinter.java | 26 ++++++------------- .../sk89q/worldedit/util/FileDialogUtil.java | 12 ++++++--- .../worldedit/world/storage/BlockData.java | 3 +++ 14 files changed, 67 insertions(+), 41 deletions(-) diff --git a/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java b/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java index fad28d223..ba610529e 100644 --- a/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java +++ b/src/forge/java/com/sk89q/worldedit/forge/ForgeUtil.java @@ -9,7 +9,10 @@ import com.sk89q.worldedit.blocks.BaseItemStack; import cpw.mods.fml.common.FMLCommonHandler; -public class ForgeUtil { +public final class ForgeUtil { + + private ForgeUtil() { + } public static boolean hasPermission(EntityPlayerMP player, String perm) { // TODO fix WEPIF diff --git a/src/main/java/com/sk89q/util/ArrayUtil.java b/src/main/java/com/sk89q/util/ArrayUtil.java index 13f572c38..88f8a5a21 100644 --- a/src/main/java/com/sk89q/util/ArrayUtil.java +++ b/src/main/java/com/sk89q/util/ArrayUtil.java @@ -18,7 +18,10 @@ package com.sk89q.util; -public class ArrayUtil { +public final class ArrayUtil { + + private ArrayUtil() { + } public static String[] removePortionOfArray(String[] array, int from, int to, String replace) { String[] newArray = new String[from + array.length - to - (replace == null ? 1 : 0)]; diff --git a/src/main/java/com/sk89q/util/ReflectionUtil.java b/src/main/java/com/sk89q/util/ReflectionUtil.java index fd41b0433..456c8f6a8 100644 --- a/src/main/java/com/sk89q/util/ReflectionUtil.java +++ b/src/main/java/com/sk89q/util/ReflectionUtil.java @@ -24,7 +24,11 @@ import java.lang.reflect.Field; /** * @author zml2008 */ -public class ReflectionUtil { +public final class ReflectionUtil { + + private ReflectionUtil() { + } + @SuppressWarnings("unchecked") public static T getField(Object from, String name) { Class checkClass = from.getClass(); @@ -39,4 +43,5 @@ public class ReflectionUtil { } while (checkClass.getSuperclass() != Object.class && ((checkClass = checkClass.getSuperclass()) != null)); return null; } + } diff --git a/src/main/java/com/sk89q/util/StringUtil.java b/src/main/java/com/sk89q/util/StringUtil.java index 5911d9176..30bc5d178 100644 --- a/src/main/java/com/sk89q/util/StringUtil.java +++ b/src/main/java/com/sk89q/util/StringUtil.java @@ -26,7 +26,11 @@ import java.util.Map; * * @author sk89q */ -public class StringUtil { +public final class StringUtil { + + private StringUtil() { + } + /** * Trim a string if it is longer than a certain length. * diff --git a/src/main/java/com/sk89q/worldedit/LocalWorld.java b/src/main/java/com/sk89q/worldedit/LocalWorld.java index 9ce353181..3e4a0e0cc 100644 --- a/src/main/java/com/sk89q/worldedit/LocalWorld.java +++ b/src/main/java/com/sk89q/worldedit/LocalWorld.java @@ -42,7 +42,7 @@ public abstract class LocalWorld implements World, Extent { /** * Named flags to use as parameters to {@link LocalWorld#killMobs(Vector, double, int)} */ - public class KillFlags { + public final class KillFlags { public static final int PETS = 1 << 0; public static final int NPCS = 1 << 1; public static final int ANIMALS = 1 << 2; @@ -50,6 +50,9 @@ public abstract class LocalWorld implements World, Extent { public static final int AMBIENT = 1 << 4; public static final int FRIENDLY = PETS | NPCS | ANIMALS | GOLEMS | AMBIENT; public static final int WITH_LIGHTNING = 1 << 20; + + private KillFlags() { + } } /** diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java index 7c0839d4f..7ee6bcf17 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockData.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockData.java @@ -27,6 +27,10 @@ import com.sk89q.worldedit.CuboidClipboard.FlipDirection; * @author sk89q */ public final class BlockData { + + private BlockData() { + } + /** * Rotate a block's data value 90 degrees (north->east->south->west->north); * diff --git a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java index 7ec0f92f7..bdc8c14e7 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/BlockID.java +++ b/src/main/java/com/sk89q/worldedit/blocks/BlockID.java @@ -203,4 +203,6 @@ public final class BlockID { public static final int PACKED_ICE = 174; public static final int DOUBLE_PLANT = 175; + private BlockID() { + } } diff --git a/src/main/java/com/sk89q/worldedit/blocks/ItemID.java b/src/main/java/com/sk89q/worldedit/blocks/ItemID.java index 30bee5680..69d37385c 100644 --- a/src/main/java/com/sk89q/worldedit/blocks/ItemID.java +++ b/src/main/java/com/sk89q/worldedit/blocks/ItemID.java @@ -199,4 +199,7 @@ public final class ItemID { public static final int DISC_WARD = 2265; public static final int DISC_11 = 2266; public static final int DISC_WAIT = 2267; + + private ItemID() { + } } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java index 7dfee6a38..484d13468 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/parser/ParserProcessors.java @@ -19,18 +19,14 @@ package com.sk89q.worldedit.internal.expression.parser; -import java.util.Collections; -import java.util.HashMap; -import java.util.Iterator; -import java.util.LinkedList; -import java.util.Map; - import com.sk89q.worldedit.internal.expression.Identifiable; import com.sk89q.worldedit.internal.expression.lexer.tokens.OperatorToken; import com.sk89q.worldedit.internal.expression.lexer.tokens.Token; import com.sk89q.worldedit.internal.expression.runtime.Conditional; -import com.sk89q.worldedit.internal.expression.runtime.RValue; import com.sk89q.worldedit.internal.expression.runtime.Operators; +import com.sk89q.worldedit.internal.expression.runtime.RValue; + +import java.util.*; /** * Helper classfor Parser. Contains processors for statements and operators. @@ -148,6 +144,9 @@ public final class ParserProcessors { } } + private ParserProcessors() { + } + static RValue processExpression(LinkedList input) throws ParserException { return processBinaryOpsRA(input, binaryOpMapsRA.length - 1); } diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java index 637d2a2d5..c049d5709 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Functions.java @@ -19,16 +19,12 @@ package com.sk89q.worldedit.internal.expression.runtime; -import java.lang.reflect.Method; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.Random; - import com.sk89q.worldedit.internal.expression.Expression; import com.sk89q.worldedit.internal.expression.runtime.Function.Dynamic; +import java.lang.reflect.Method; +import java.util.*; + /** * Contains all functions that can be used in expressions. * @@ -279,6 +275,10 @@ public final class Functions { private static final Map gmegabuf = new HashMap(); private final Map megabuf = new HashMap(); + public Map getMegabuf() { + return megabuf; + } + private static double[] getSubBuffer(Map megabuf, Integer key) { double[] ret = megabuf.get(key); if (ret == null) { diff --git a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java index e8739043b..b6f724d2e 100644 --- a/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java +++ b/src/main/java/com/sk89q/worldedit/internal/expression/runtime/Operators.java @@ -26,6 +26,9 @@ package com.sk89q.worldedit.internal.expression.runtime; */ @SuppressWarnings("UnusedDeclaration") public final class Operators { + private Operators() { + } + public static Function getOperator(int position, String name, RValue lhs, RValue rhs) throws NoSuchMethodException { if (lhs instanceof LValue) { try { diff --git a/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java b/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java index cfacec6a6..137f85157 100644 --- a/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java +++ b/src/main/java/com/sk89q/worldedit/internal/util/DocumentationPrinter.java @@ -19,6 +19,11 @@ package com.sk89q.worldedit.internal.util; +import com.sk89q.minecraft.util.commands.Command; +import com.sk89q.minecraft.util.commands.CommandPermissions; +import com.sk89q.minecraft.util.commands.NestedCommand; +import com.sk89q.worldedit.command.*; + import java.io.File; import java.io.FileOutputStream; import java.io.IOException; @@ -28,25 +33,10 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.List; -import com.sk89q.minecraft.util.commands.Command; -import com.sk89q.minecraft.util.commands.CommandPermissions; -import com.sk89q.minecraft.util.commands.NestedCommand; -import com.sk89q.worldedit.command.BiomeCommands; -import com.sk89q.worldedit.command.ChunkCommands; -import com.sk89q.worldedit.command.ClipboardCommands; -import com.sk89q.worldedit.command.GeneralCommands; -import com.sk89q.worldedit.command.GenerationCommands; -import com.sk89q.worldedit.command.HistoryCommands; -import com.sk89q.worldedit.command.NavigationCommands; -import com.sk89q.worldedit.command.RegionCommands; -import com.sk89q.worldedit.command.ScriptingCommands; -import com.sk89q.worldedit.command.SelectionCommands; -import com.sk89q.worldedit.command.SnapshotUtilCommands; -import com.sk89q.worldedit.command.ToolCommands; -import com.sk89q.worldedit.command.ToolUtilCommands; -import com.sk89q.worldedit.command.UtilityCommands; +public final class DocumentationPrinter { + private DocumentationPrinter() { + } -public class DocumentationPrinter { public static void main(String[] args) throws IOException { File commandsDir = new File(args[0]); diff --git a/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java b/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java index d53f8a9e6..51a382faf 100644 --- a/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java +++ b/src/main/java/com/sk89q/worldedit/util/FileDialogUtil.java @@ -19,15 +19,19 @@ package com.sk89q.worldedit.util; +import com.sk89q.util.StringUtil; + +import javax.swing.*; +import javax.swing.filechooser.FileFilter; import java.io.File; import java.util.Arrays; import java.util.HashSet; import java.util.Set; -import javax.swing.JFileChooser; -import javax.swing.filechooser.FileFilter; -import com.sk89q.util.StringUtil; -public class FileDialogUtil { +public final class FileDialogUtil { + private FileDialogUtil() { + } + public static File showSaveDialog(String[] exts) { JFileChooser dialog = new JFileChooser(); diff --git a/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java b/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java index ea0fc7718..364dccb3a 100644 --- a/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java +++ b/src/main/java/com/sk89q/worldedit/world/storage/BlockData.java @@ -29,6 +29,9 @@ import com.sk89q.worldedit.CuboidClipboard.FlipDirection; */ @Deprecated public final class BlockData { + private BlockData() { + } + /** * Rotate a block's data value 90 degrees (north->east->south->west->north); *