Fixed utility classes having constructors.

This commit is contained in:
sk89q 2014-04-04 14:35:12 -07:00
parent 2b0ee84952
commit 478ce3f627
14 changed files with 67 additions and 41 deletions

View File

@ -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

View File

@ -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)];

View File

@ -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> 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;
}
}

View File

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

View File

@ -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() {
}
}
/**

View File

@ -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);
*

View File

@ -203,4 +203,6 @@ public final class BlockID {
public static final int PACKED_ICE = 174;
public static final int DOUBLE_PLANT = 175;
private BlockID() {
}
}

View File

@ -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() {
}
}

View File

@ -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<Identifiable> input) throws ParserException {
return processBinaryOpsRA(input, binaryOpMapsRA.length - 1);
}

View File

@ -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<Integer, double[]> gmegabuf = new HashMap<Integer, double[]>();
private final Map<Integer, double[]> megabuf = new HashMap<Integer, double[]>();
public Map<Integer, double[]> getMegabuf() {
return megabuf;
}
private static double[] getSubBuffer(Map<Integer, double[]> megabuf, Integer key) {
double[] ret = megabuf.get(key);
if (ret == null) {

View File

@ -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 {

View File

@ -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]);

View File

@ -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();

View File

@ -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);
*