mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-19 02:36:59 +00:00
Merge pull request #15 from cyberpwnn/performance-passes
Performance passes
This commit is contained in:
commit
e530e30878
@ -36,9 +36,9 @@ public class CommandIrisDownload extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("-t") || i.equals("--trim"))
|
||||
{
|
||||
if (i.equals("-t") || i.equals("--trim")) {
|
||||
trim = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -48,10 +48,10 @@ public class CommandIrisObjectPaste extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-edit"))
|
||||
{
|
||||
intoWand = true;
|
||||
}
|
||||
if (i.equalsIgnoreCase("-edit")) {
|
||||
intoWand = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(file == null || !file.exists())
|
||||
|
@ -51,10 +51,10 @@ public class CommandIrisObjectSave extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equals("-o"))
|
||||
{
|
||||
overwrite = true;
|
||||
}
|
||||
if (i.equals("-o")) {
|
||||
overwrite = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
Player p = sender.player();
|
||||
|
@ -39,10 +39,10 @@ public class CommandIrisStructureCreate extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-3d"))
|
||||
{
|
||||
d3 = true;
|
||||
}
|
||||
if (i.equalsIgnoreCase("-3d")) {
|
||||
d3 = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
sender.sendMessage("Creating new Structure");
|
||||
|
@ -74,10 +74,10 @@ public class CommandIrisStudioGoto extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-cave"))
|
||||
{
|
||||
cave = true;
|
||||
}
|
||||
if (i.equalsIgnoreCase("-cave")) {
|
||||
cave = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
IrisBiome biome = args[0].equals("this") ? g.sampleTrueBiome(p.getLocation().getBlockX(), p.getLocation().getBlockZ()) : g.loadBiome(args[0]);
|
||||
|
@ -38,10 +38,10 @@ public class CommandIrisStudioPackage extends MortarCommand
|
||||
|
||||
for(String i : args)
|
||||
{
|
||||
if(i.equalsIgnoreCase("-o"))
|
||||
{
|
||||
o = true;
|
||||
}
|
||||
if (i.equalsIgnoreCase("-o")) {
|
||||
o = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
String dim = args[0];
|
||||
|
@ -298,7 +298,7 @@ public class NoiseExplorer extends JPanel implements MouseWheelListener
|
||||
NoiseExplorer nv = new NoiseExplorer();
|
||||
frame.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
|
||||
KList<String> li = new KList<NoiseStyle>(NoiseStyle.values()).toStringList();
|
||||
combo = new JComboBox<String>(li.toArray(new String[li.size()]));
|
||||
combo = new JComboBox<String>(li.toArray(new String[0]));
|
||||
combo.setSelectedItem("STATIC");
|
||||
combo.setFocusable(false);
|
||||
combo.addActionListener(new ActionListener()
|
||||
|
@ -47,7 +47,7 @@ public class MythicMobsLink
|
||||
}
|
||||
}
|
||||
|
||||
return v.toArray(new String[v.size()]);
|
||||
return v.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public Plugin getMythicMobs()
|
||||
|
@ -99,17 +99,17 @@ public class IrisDataManager
|
||||
{
|
||||
File examples = new File(dataFolder, "example");
|
||||
examples.mkdirs();
|
||||
String biomes = "";
|
||||
String envs = "";
|
||||
StringBuilder biomes = new StringBuilder();
|
||||
StringBuilder envs = new StringBuilder();
|
||||
|
||||
for(Biome i : Biome.values())
|
||||
{
|
||||
biomes += i.name() + "\n";
|
||||
biomes.append(i.name()).append("\n");
|
||||
}
|
||||
|
||||
for(Environment i : Environment.values())
|
||||
{
|
||||
envs += i.name() + "\n";
|
||||
envs.append(i.name()).append("\n");
|
||||
}
|
||||
|
||||
try
|
||||
@ -118,8 +118,8 @@ public class IrisDataManager
|
||||
new File(examples, "example-pack/biomes").mkdirs();
|
||||
new File(examples, "example-pack/dimensions").mkdirs();
|
||||
new File(examples, "example-pack/generators").mkdirs();
|
||||
IO.writeAll(new File(examples, "biome-list.txt"), biomes);
|
||||
IO.writeAll(new File(examples, "environment-list.txt"), envs);
|
||||
IO.writeAll(new File(examples, "biome-list.txt"), biomes.toString());
|
||||
IO.writeAll(new File(examples, "environment-list.txt"), envs.toString());
|
||||
|
||||
IrisGenerator gen = new IrisGenerator();
|
||||
IrisNoiseGenerator n = new IrisNoiseGenerator();
|
||||
|
@ -133,7 +133,7 @@ public class B
|
||||
}
|
||||
}
|
||||
|
||||
return bt.toArray(new String[bt.size()]);
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static String[] getItemTypes()
|
||||
@ -146,7 +146,7 @@ public class B
|
||||
bt.add(v);
|
||||
}
|
||||
|
||||
return bt.toArray(new String[bt.size()]);
|
||||
return bt.toArray(new String[0]);
|
||||
}
|
||||
|
||||
public static BlockData getBlockData(String bdxf, IrisDimension resolver)
|
||||
|
@ -753,7 +753,7 @@ public enum C
|
||||
*/
|
||||
public static String getLastColors(String input)
|
||||
{
|
||||
String result = "";
|
||||
StringBuilder result = new StringBuilder();
|
||||
int length = input.length();
|
||||
|
||||
// Search backwards from the end as it is faster
|
||||
@ -767,7 +767,7 @@ public enum C
|
||||
|
||||
if(color != null)
|
||||
{
|
||||
result = color.toString() + result;
|
||||
result.insert(0, color.toString());
|
||||
|
||||
// Once we find a color or reset we can stop searching
|
||||
if(color.isColor() || color.equals(RESET))
|
||||
@ -778,7 +778,7 @@ public enum C
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
return result.toString();
|
||||
}
|
||||
|
||||
static
|
||||
|
@ -72,9 +72,9 @@ public final class CompoundTag extends Tag {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_Compound" + append + ": " + value.size() + " entries\r\n{\r\n");
|
||||
bldr.append("TAG_Compound").append(append).append(": ").append(value.size()).append(" entries\r\n{\r\n");
|
||||
for (Map.Entry<String, Tag> entry : value.entrySet()) {
|
||||
bldr.append(" " + entry.getValue().toString().replaceAll("\r\n", "\r\n ") + "\r\n");
|
||||
bldr.append(" ").append(entry.getValue().toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
|
@ -5,10 +5,7 @@ public class DoubleArrayUtils
|
||||
{
|
||||
public static void shiftRight(double[] values, double push)
|
||||
{
|
||||
for(int index = values.length - 2; index >= 0; index--)
|
||||
{
|
||||
values[index + 1] = values[index];
|
||||
}
|
||||
if (values.length - 2 + 1 >= 0) System.arraycopy(values, 0, values, 1, values.length - 2 + 1);
|
||||
|
||||
values[0] = push;
|
||||
}
|
||||
|
@ -72,24 +72,24 @@ public class Form
|
||||
*/
|
||||
public static String capitalize(String s)
|
||||
{
|
||||
String roll = "";
|
||||
StringBuilder roll = new StringBuilder();
|
||||
boolean f = true;
|
||||
|
||||
for(Character i : s.trim().toCharArray())
|
||||
{
|
||||
if(f)
|
||||
{
|
||||
roll += Character.toUpperCase(i);
|
||||
roll.append(Character.toUpperCase(i));
|
||||
f = false;
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
roll += i;
|
||||
roll.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
return roll;
|
||||
return roll.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -101,11 +101,11 @@ public class Form
|
||||
*/
|
||||
public static String capitalizeWords(String s)
|
||||
{
|
||||
String rollx = "";
|
||||
StringBuilder rollx = new StringBuilder();
|
||||
|
||||
for(String i : s.trim().split(" "))
|
||||
{
|
||||
rollx += " " + capitalize(i.trim());
|
||||
rollx.append(" ").append(capitalize(i.trim()));
|
||||
}
|
||||
|
||||
return rollx.substring(1);
|
||||
@ -876,7 +876,7 @@ public class Form
|
||||
*/
|
||||
public static String ofSize(long s, int div)
|
||||
{
|
||||
Double d = (double) s;
|
||||
double d = (double) s;
|
||||
String sub = "Bytes";
|
||||
|
||||
if(d > div - 1)
|
||||
@ -929,7 +929,7 @@ public class Form
|
||||
*/
|
||||
public static String ofSize(long s, int div, int dec)
|
||||
{
|
||||
Double d = (double) s;
|
||||
double d = (double) s;
|
||||
String sub = "Bytes";
|
||||
|
||||
if(d > div - 1)
|
||||
@ -979,7 +979,7 @@ public class Form
|
||||
{
|
||||
s = -s;
|
||||
}
|
||||
Double d = (double) s;
|
||||
double d = (double) s;
|
||||
String sub = "Grams";
|
||||
|
||||
if(d > div - 1)
|
||||
@ -1038,27 +1038,27 @@ public class Form
|
||||
*/
|
||||
public static String cname(String clazz)
|
||||
{
|
||||
String codeName = "";
|
||||
StringBuilder codeName = new StringBuilder();
|
||||
|
||||
for(Character i : clazz.toCharArray())
|
||||
{
|
||||
if(Character.isUpperCase(i))
|
||||
{
|
||||
codeName = codeName + "-" + Character.toLowerCase(i);
|
||||
codeName.append("-").append(Character.toLowerCase(i));
|
||||
}
|
||||
|
||||
else
|
||||
{
|
||||
codeName = codeName + i;
|
||||
codeName.append(i);
|
||||
}
|
||||
}
|
||||
|
||||
if(codeName.startsWith("-"))
|
||||
if(codeName.toString().startsWith("-"))
|
||||
{
|
||||
codeName = codeName.substring(1);
|
||||
codeName = new StringBuilder(codeName.substring(1));
|
||||
}
|
||||
|
||||
return codeName;
|
||||
return codeName.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -1439,17 +1439,17 @@ public class Form
|
||||
roman_numerals.put("IV", 4);
|
||||
roman_numerals.put("I", 1);
|
||||
|
||||
String res = "";
|
||||
StringBuilder res = new StringBuilder();
|
||||
|
||||
for(Map.Entry<String, Integer> entry : roman_numerals.entrySet())
|
||||
{
|
||||
int matches = num / entry.getValue();
|
||||
|
||||
res += repeat(entry.getKey(), matches);
|
||||
res.append(repeat(entry.getKey(), matches));
|
||||
num = num % entry.getValue();
|
||||
}
|
||||
|
||||
return res;
|
||||
return res.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -407,33 +407,33 @@ public class IO
|
||||
public static String readAll(File f) throws IOException
|
||||
{
|
||||
BufferedReader bu = new BufferedReader(new FileReader(f));
|
||||
String c = "";
|
||||
StringBuilder c = new StringBuilder();
|
||||
String l = "";
|
||||
|
||||
while((l = bu.readLine()) != null)
|
||||
{
|
||||
c += l + "\n";
|
||||
c.append(l).append("\n");
|
||||
}
|
||||
|
||||
bu.close();
|
||||
|
||||
return c;
|
||||
return c.toString();
|
||||
}
|
||||
|
||||
public static String readAll(InputStream in) throws IOException
|
||||
{
|
||||
BufferedReader bu = new BufferedReader(new InputStreamReader(in));
|
||||
String c = "";
|
||||
StringBuilder c = new StringBuilder();
|
||||
String l = "";
|
||||
|
||||
while((l = bu.readLine()) != null)
|
||||
{
|
||||
c += l + "\n";
|
||||
c.append(l).append("\n");
|
||||
}
|
||||
|
||||
bu.close();
|
||||
|
||||
return c;
|
||||
return c.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -1652,7 +1652,7 @@ public class JSONObject
|
||||
*/
|
||||
public static Object stringToValue(String string)
|
||||
{
|
||||
Double d;
|
||||
double d;
|
||||
if(string.equals(""))
|
||||
{
|
||||
return string;
|
||||
@ -1682,8 +1682,8 @@ public class JSONObject
|
||||
{
|
||||
if(string.indexOf('.') > -1 || string.indexOf('e') > -1 || string.indexOf('E') > -1)
|
||||
{
|
||||
d = Double.valueOf(string);
|
||||
if(!d.isInfinite() && !d.isNaN())
|
||||
d = Double.parseDouble(string);
|
||||
if(!Double.isInfinite(d) && !Double.isNaN(d))
|
||||
{
|
||||
return d;
|
||||
}
|
||||
|
@ -253,7 +253,7 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
|
||||
for(String i : toStringList())
|
||||
{
|
||||
b.append(split + i);
|
||||
b.append(split).append(i);
|
||||
}
|
||||
|
||||
return b.toString().substring(split.length());
|
||||
@ -382,10 +382,7 @@ public class KList<T> extends ArrayList<T> implements List<T>
|
||||
@SuppressWarnings("unchecked")
|
||||
public KList<T> add(T... t)
|
||||
{
|
||||
for(T i : t)
|
||||
{
|
||||
super.add(i);
|
||||
}
|
||||
Collections.addAll(super, t);
|
||||
|
||||
return this;
|
||||
}
|
||||
|
@ -88,9 +88,9 @@ public final class ListTag extends Tag {
|
||||
append = "(\"" + this.getName() + "\")";
|
||||
}
|
||||
StringBuilder bldr = new StringBuilder();
|
||||
bldr.append("TAG_List" + append + ": " + value.size() + " entries of type " + NBTUtils.getTypeName(type) + "\r\n{\r\n");
|
||||
bldr.append("TAG_List").append(append).append(": ").append(value.size()).append(" entries of type ").append(NBTUtils.getTypeName(type)).append("\r\n{\r\n");
|
||||
for (Tag t : value) {
|
||||
bldr.append(" " + t.toString().replaceAll("\r\n", "\r\n ") + "\r\n");
|
||||
bldr.append(" ").append(t.toString().replaceAll("\r\n", "\r\n ")).append("\r\n");
|
||||
}
|
||||
bldr.append("}");
|
||||
return bldr.toString();
|
||||
|
@ -153,7 +153,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[v.size()]);
|
||||
possibleKeys = v.toArray(new String[0]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
@ -201,7 +201,7 @@ public class ObjectResourceLoader extends ResourceLoader<IrisObject>
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[v.size()]);
|
||||
possibleKeys = v.toArray(new String[0]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
|
@ -79,7 +79,7 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
preferredKeys = v.toArray(new String[v.size()]);
|
||||
preferredKeys = v.toArray(new String[0]);
|
||||
return preferredKeys;
|
||||
}
|
||||
|
||||
@ -116,7 +116,7 @@ public class ResourceLoader<T extends IrisRegistrant>
|
||||
}
|
||||
|
||||
KList<String> v = new KList<>(m);
|
||||
possibleKeys = v.toArray(new String[v.size()]);
|
||||
possibleKeys = v.toArray(new String[0]);
|
||||
return possibleKeys;
|
||||
}
|
||||
|
||||
|
@ -117,7 +117,7 @@ public class V
|
||||
|
||||
try
|
||||
{
|
||||
return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class<?>[par.size()])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class<?>[par.size()]))).invoke(o, parameters);
|
||||
return (local ? Violator.getDeclaredMethod(o.getClass(), method, par.toArray(new Class<?>[0])) : Violator.getMethod(o.getClass(), method, par.toArray(new Class<?>[0]))).invoke(o, parameters);
|
||||
}
|
||||
|
||||
catch(Throwable e)
|
||||
|
@ -31,28 +31,28 @@ public class Violator
|
||||
{
|
||||
Constructor<?> co = (Constructor<?>) o;
|
||||
|
||||
String mx = "";
|
||||
StringBuilder mx = new StringBuilder();
|
||||
|
||||
for(Class<?> i : co.getParameterTypes())
|
||||
{
|
||||
mx += "," + i.getCanonicalName();
|
||||
mx.append(",").append(i.getCanonicalName());
|
||||
}
|
||||
|
||||
mx = mx.length() >= 1 ? mx.substring(1) : mx;
|
||||
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString());
|
||||
|
||||
return id(co.getDeclaringClass(), null) + "(" + mx + ")";
|
||||
}
|
||||
|
||||
if(o instanceof Method)
|
||||
{
|
||||
String mx = "";
|
||||
StringBuilder mx = new StringBuilder();
|
||||
|
||||
for(Class<?> i : ((Method) o).getParameterTypes())
|
||||
{
|
||||
mx += "," + i.getCanonicalName();
|
||||
mx.append(",").append(i.getCanonicalName());
|
||||
}
|
||||
|
||||
mx = mx.length() >= 1 ? mx.substring(1) : mx;
|
||||
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString());
|
||||
|
||||
return id(((Method) o).getDeclaringClass(), null) + "." + ((Method) o).getName() + "(" + mx + ")";
|
||||
}
|
||||
@ -83,14 +83,14 @@ public class Violator
|
||||
|
||||
public static Constructor<?> getConstructor(Class<?> c, Class<?>... params) throws NoSuchMethodException, SecurityException
|
||||
{
|
||||
String mx = "";
|
||||
StringBuilder mx = new StringBuilder();
|
||||
|
||||
for(Class<?> i : params)
|
||||
{
|
||||
mx += "," + i.getCanonicalName();
|
||||
mx.append(",").append(i.getCanonicalName());
|
||||
}
|
||||
|
||||
mx = mx.length() >= 1 ? mx.substring(1) : mx;
|
||||
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString());
|
||||
|
||||
if(!h(id(c, null) + "(" + mx + ")"))
|
||||
{
|
||||
@ -159,14 +159,14 @@ public class Violator
|
||||
public static Method getMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
|
||||
{
|
||||
String iv = "";
|
||||
String mx = "";
|
||||
StringBuilder mx = new StringBuilder();
|
||||
|
||||
for(Class<?> i : pars)
|
||||
{
|
||||
mx += "," + i.getCanonicalName();
|
||||
mx.append(",").append(i.getCanonicalName());
|
||||
}
|
||||
|
||||
mx = mx.length() >= 1 ? mx.substring(1) : mx;
|
||||
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString());
|
||||
iv = id(c, null) + "." + name + "(" + mx + ")";
|
||||
|
||||
if(!h(iv))
|
||||
@ -191,7 +191,7 @@ public class Violator
|
||||
|
||||
try
|
||||
{
|
||||
Constructor<?> co = getConstructor(c, cv.toArray(new Class<?>[cv.size()]));
|
||||
Constructor<?> co = getConstructor(c, cv.toArray(new Class<?>[0]));
|
||||
return (T) co.newInstance(parameters);
|
||||
}
|
||||
|
||||
@ -206,14 +206,14 @@ public class Violator
|
||||
public static Method getDeclaredMethod(Class<?> c, String name, Class<?>... pars) throws Throwable
|
||||
{
|
||||
String iv = "";
|
||||
String mx = "";
|
||||
StringBuilder mx = new StringBuilder();
|
||||
|
||||
for(Class<?> i : pars)
|
||||
{
|
||||
mx += "," + i.getCanonicalName();
|
||||
mx.append(",").append(i.getCanonicalName());
|
||||
}
|
||||
|
||||
mx = mx.length() >= 1 ? mx.substring(1) : mx;
|
||||
mx = new StringBuilder(mx.length() >= 1 ? mx.substring(1) : mx.toString());
|
||||
iv = id(c, null) + "." + name + "(" + mx + ")";
|
||||
|
||||
if(!h(iv))
|
||||
|
@ -115,7 +115,7 @@ public class VirtualCommand
|
||||
return true;
|
||||
}
|
||||
|
||||
return command.handle(vs, chain.toArray(new String[chain.size()]));
|
||||
return command.handle(vs, chain.toArray(new String[0]));
|
||||
}
|
||||
|
||||
private boolean checkPermissions(CommandSender sender, ICommand command2)
|
||||
|
Loading…
x
Reference in New Issue
Block a user