9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00
This commit is contained in:
Daniel Mills
2021-07-16 02:25:35 -04:00
parent 22387b2610
commit 71140381e0
198 changed files with 1033 additions and 1146 deletions

View File

@@ -128,8 +128,8 @@ public class Board {
team.setSuffix(entry.getSuffix());
switch (boardSettings.getScoreDirection()) {
case ScoreDirection.UP -> objective.getScore(team.getName()).setScore(1 + i);
case ScoreDirection.DOWN -> objective.getScore(team.getName()).setScore(15 - i);
case UP -> objective.getScore(team.getName()).setScore(1 + i);
case DOWN -> objective.getScore(team.getName()).setScore(15 - i);
}
}
}

View File

@@ -74,7 +74,6 @@ public class GBiset<A, B> implements Serializable {
/**
* Set the second object
*
*/
public void setB(B b) {
this.b = b;

View File

@@ -19,16 +19,18 @@
package com.volmit.iris.util.data;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.inventorygui.RandomColor.Color;
import com.volmit.iris.util.inventorygui.RandomColor.Luminosity;
import com.volmit.iris.util.inventorygui.RandomColor.SaturationType;
import org.bukkit.block.Biome;
import com.volmit.iris.util.inventorygui.RandomColor.*;
public class VanillaBiomeMap {
private static KMap<Biome, Integer> BIOME_HEX = new KMap<>();
private static KMap<Biome, Color> BIOME_COLOR = new KMap<>();
private static KMap<Biome, Luminosity> BIOME_LUMINOSITY = new KMap<>();
private static KMap<Biome, SaturationType> BIOME_SATURATION = new KMap<>();
private static KMap<Biome, Short> BIOME_IDs = new KMap<>();
private static final KMap<Biome, Integer> BIOME_HEX = new KMap<>();
private static final KMap<Biome, Color> BIOME_COLOR = new KMap<>();
private static final KMap<Biome, Luminosity> BIOME_LUMINOSITY = new KMap<>();
private static final KMap<Biome, SaturationType> BIOME_SATURATION = new KMap<>();
private static final KMap<Biome, Short> BIOME_IDs = new KMap<>();
private static void add(Biome biome, int color, short id, Color randomColor, Luminosity luminosity, SaturationType saturation) {
BIOME_HEX.put(biome, color);

View File

@@ -18,17 +18,11 @@
package com.volmit.iris.util.fakenews;
import com.volmit.iris.engine.IrisEngineFramework;
import com.volmit.iris.core.IrisDataManager;
import com.volmit.iris.engine.object.*;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.framework.EngineCompound;
import com.volmit.iris.engine.framework.EngineEffects;
import com.volmit.iris.engine.framework.EngineFramework;
import com.volmit.iris.engine.framework.EngineMetrics;
import com.volmit.iris.engine.framework.EngineTarget;
import com.volmit.iris.engine.framework.EngineWorldManager;
import com.volmit.iris.engine.IrisEngineFramework;
import com.volmit.iris.engine.framework.*;
import com.volmit.iris.engine.hunk.Hunk;
import com.volmit.iris.engine.object.*;
import lombok.Getter;
import org.bukkit.World;
import org.bukkit.block.Biome;
@@ -48,12 +42,12 @@ public class FakeEngine implements Engine {
private double maxBiomeDecoratorDensity;
@Getter
private IrisDimension dimension;
private final IrisDimension dimension;
private EngineFramework framework;
private final EngineFramework framework;
@Getter
private World world;
private final World world;
public FakeEngine(IrisDimension dimension, FakeWorld world) {
this.dimension = dimension;
@@ -63,28 +57,24 @@ public class FakeEngine implements Engine {
}
private void computeBiomeMaxes() {
for(IrisBiome i : getDimension().getAllBiomes(this))
{
for (IrisBiome i : getDimension().getAllBiomes(this)) {
double density = 0;
for(IrisObjectPlacement j : i.getObjects())
{
for (IrisObjectPlacement j : i.getObjects()) {
density += j.getDensity() * j.getChance();
}
maxBiomeObjectDensity = Math.max(maxBiomeObjectDensity, density);
density = 0;
for(IrisDecorator j : i.getDecorators())
{
for (IrisDecorator j : i.getDecorators()) {
density += Math.max(j.getStackMax(), 1) * j.getChance();
}
maxBiomeDecoratorDensity = Math.max(maxBiomeDecoratorDensity, density);
density = 0;
for(IrisBiomePaletteLayer j : i.getLayers())
{
for (IrisBiomePaletteLayer j : i.getLayers()) {
density++;
}
@@ -93,7 +83,8 @@ public class FakeEngine implements Engine {
}
@Override
public void close() { }
public void close() {
}
@Override
public boolean isClosed() {
@@ -111,7 +102,8 @@ public class FakeEngine implements Engine {
}
@Override
public void setParallelism(int parallelism) { }
public void setParallelism(int parallelism) {
}
@Override
public int getParallelism() {
@@ -129,10 +121,12 @@ public class FakeEngine implements Engine {
}
@Override
public void setMinHeight(int min) { }
public void setMinHeight(int min) {
}
@Override
public void recycle() { }
public void recycle() {
}
@Override
public int getIndex() {
@@ -160,7 +154,8 @@ public class FakeEngine implements Engine {
}
@Override
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) { }
public void generate(int x, int z, Hunk<BlockData> blocks, Hunk<Biome> biomes) {
}
@Override
public EngineMetrics getMetrics() {
@@ -183,7 +178,8 @@ public class FakeEngine implements Engine {
}
@Override
public void fail(String error, Throwable e) { }
public void fail(String error, Throwable e) {
}
@Override
public boolean hasFailed() {
@@ -196,5 +192,6 @@ public class FakeEngine implements Engine {
}
@Override
public void hotload() { }
public void hotload() {
}
}

View File

@@ -19,7 +19,6 @@
package com.volmit.iris.util.fakenews;
import lombok.Setter;
import org.bukkit.HeightMap;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util.fakenews;
import org.bukkit.HeightMap;
import org.bukkit.*;
import org.bukkit.block.Biome;
import org.bukkit.block.Block;

View File

@@ -335,7 +335,6 @@ public enum C {
/**
* get the dye color for the chatcolor
*
*/
public DyeColor dye() {
return chatToDye(chatColor());
@@ -392,7 +391,8 @@ public enum C {
Validate.isTrue(code.length() > 0, "Code must have at least one char");
return BY_CHAR.get(code.charAt(0));
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return C.WHITE;
}
}
@@ -510,7 +510,6 @@ public enum C {
/**
* Get the ChatColor enum instance instead of C
*
*/
public ChatColor chatColor() {
return ChatColor.getByChar(code);
@@ -553,41 +552,41 @@ public enum C {
public byte getMeta() {
return switch (this) {
case AQUA -> (byte)11;
case BLACK -> (byte)0;
case BLUE, DARK_AQUA -> (byte)9;
case BOLD, UNDERLINE, STRIKETHROUGH, RESET, MAGIC, ITALIC -> (byte)-1;
case DARK_BLUE -> (byte)1;
case DARK_GRAY -> (byte)8;
case DARK_GREEN -> (byte)2;
case DARK_PURPLE -> (byte)5;
case DARK_RED -> (byte)4;
case GOLD -> (byte)6;
case GRAY -> (byte)7;
case GREEN -> (byte)10;
case LIGHT_PURPLE -> (byte)13;
case RED -> (byte)12;
case WHITE -> (byte)15;
case YELLOW -> (byte)14;
case AQUA -> (byte) 11;
case BLACK -> (byte) 0;
case BLUE, DARK_AQUA -> (byte) 9;
case BOLD, UNDERLINE, STRIKETHROUGH, RESET, MAGIC, ITALIC -> (byte) -1;
case DARK_BLUE -> (byte) 1;
case DARK_GRAY -> (byte) 8;
case DARK_GREEN -> (byte) 2;
case DARK_PURPLE -> (byte) 5;
case DARK_RED -> (byte) 4;
case GOLD -> (byte) 6;
case GRAY -> (byte) 7;
case GREEN -> (byte) 10;
case LIGHT_PURPLE -> (byte) 13;
case RED -> (byte) 12;
case WHITE -> (byte) 15;
case YELLOW -> (byte) 14;
};
}
public byte getItemMeta() {
return switch (this) {
case AQUA, DARK_AQUA -> (byte)9;
case BLACK -> (byte)15;
case BLUE -> (byte)3;
case BOLD, UNDERLINE, RESET, STRIKETHROUGH, MAGIC, ITALIC -> (byte)-1;
case DARK_BLUE -> (byte)11;
case DARK_GRAY -> (byte)7;
case DARK_GREEN -> (byte)13;
case DARK_PURPLE -> (byte)10;
case DARK_RED, RED -> (byte)14;
case GOLD, YELLOW -> (byte)4;
case GRAY -> (byte)8;
case GREEN -> (byte)5;
case LIGHT_PURPLE -> (byte)2;
case WHITE -> (byte)0;
case AQUA, DARK_AQUA -> (byte) 9;
case BLACK -> (byte) 15;
case BLUE -> (byte) 3;
case BOLD, UNDERLINE, RESET, STRIKETHROUGH, MAGIC, ITALIC -> (byte) -1;
case DARK_BLUE -> (byte) 11;
case DARK_GRAY -> (byte) 7;
case DARK_GREEN -> (byte) 13;
case DARK_PURPLE -> (byte) 10;
case DARK_RED, RED -> (byte) 14;
case GOLD, YELLOW -> (byte) 4;
case GRAY -> (byte) 8;
case GREEN -> (byte) 5;
case LIGHT_PURPLE -> (byte) 2;
case WHITE -> (byte) 0;
};
}

View File

@@ -225,7 +225,7 @@ public class Form {
/**
* Returns a fancy duration up to Years
*
* @param duration the duration in ms
* @param duration the duration in ms
* @return the fancy duration
*/
public static String duration(RollingSequence rollingSequence, long duration) {
@@ -1047,7 +1047,7 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param p number of decimal points
* @param p number of decimal points
* @return a formatted string to nanoseconds
*/
public static String nsMs(long ns, int p) {
@@ -1057,7 +1057,7 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param p number of decimal points
* @param p number of decimal points
* @return a formatted string to nanoseconds
*/
public static String nsMsd(long ns, int p) {

View File

@@ -1,24 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.function;
@FunctionalInterface
public interface Consumer7<A, B, C, D, E, F, G> {
void accept(A a, B b, C c, D d, E e, F f, G g);
}

View File

@@ -18,9 +18,9 @@
package com.volmit.iris.util.inventorygui;
import com.volmit.iris.util.scheduling.Callback;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.MaterialBlock;
import com.volmit.iris.util.scheduling.Callback;
import org.bukkit.inventory.ItemStack;
@SuppressWarnings("ALL")

View File

@@ -95,13 +95,13 @@ public class RandomColor {
}
}
private Random random;
private final Random random;
public static enum SaturationType {
public enum SaturationType {
RANDOM, MONOCHROME, HIGH, LOW, MEDIUM
}
public static enum Luminosity {
public enum Luminosity {
BRIGHT, LIGHT, DARK, RANDOM
}
@@ -135,14 +135,14 @@ public class RandomColor {
}
}
private HashMap<String, ColorInfo> colors = new HashMap<>();
private final HashMap<String, ColorInfo> colors = new HashMap<>();
public RandomColor() {
loadColorBounds();
random = new Random();
}
public RandomColor(long seed){
public RandomColor(long seed) {
loadColorBounds();
random = new Random();
random.setSeed(seed);
@@ -154,7 +154,7 @@ public class RandomColor {
}
private int getColor(int hue, int saturation, int brightness) {
return java.awt.Color.getHSBColor((float)(hue + hueOffset % 360) / 360, (float)saturation / 100, (float)brightness / 100).getRGB();
return java.awt.Color.getHSBColor((float) (hue + hueOffset % 360) / 360, (float) saturation / 100, (float) brightness / 100).getRGB();
}
public int randomColor() {
@@ -280,7 +280,7 @@ public class RandomColor {
return 0;
}
Range saturationRange = colorInfo.getSaturationRange();
Range saturationRange = colorInfo.getSaturationRange();
int min = saturationRange.start;
int max = saturationRange.end;
@@ -358,10 +358,10 @@ public class RandomColor {
if (saturation >= s1 && saturation <= s2) {
float m = (v2 - v1)/(float) (s2 - s1),
b = v1 - m*s1;
float m = (v2 - v1) / (float) (s2 - s1),
b = v1 - m * s1;
return (int) (m*saturation + b);
return (int) (m * saturation + b);
}
}
@@ -372,10 +372,10 @@ public class RandomColor {
private ColorInfo getColorInfo(int hue) {
// Maps red colors to make picking hue easier
if (hue >= 334 && hue <= 360) {
hue-= 360;
hue -= 360;
}
for(String key : colors.keySet()) {
for (String key : colors.keySet()) {
ColorInfo colorInfo = colors.get(key);
if (colorInfo.getHueRange() != null && colorInfo.getHueRange().contain(hue)) {
return colorInfo;
@@ -385,8 +385,8 @@ public class RandomColor {
return null;
}
private int randomWithin (Range range) {
return (int) Math.floor(range.start + random.nextDouble()*(range.end + 1 - range.start));
private int randomWithin(Range range) {
return (int) Math.floor(range.start + random.nextDouble() * (range.end + 1 - range.start));
}
public void defineColor(String name, Range hueRange, List<Range> lowerBounds) {
@@ -466,7 +466,7 @@ public class RandomColor {
defineColor(
Color.GREEN.name(),
new Range(63,178),
new Range(63, 178),
lowerBounds5
);
@@ -520,7 +520,7 @@ public class RandomColor {
);
}
public static enum Color {
public enum Color {
MONOCHROME, RED, ORANGE, YELLOW, GREEN, BLUE, PURPLE, PINK
}

View File

@@ -19,9 +19,9 @@
package com.volmit.iris.util.inventorygui;
import com.volmit.iris.Iris;
import com.volmit.iris.util.scheduling.Callback;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.MaterialBlock;
import com.volmit.iris.util.scheduling.Callback;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
@@ -166,7 +166,8 @@ public class UIElement implements Element {
} catch (NullPointerException e) {
Iris.reportError(e);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -216,7 +217,8 @@ public class UIElement implements Element {
is.setItemMeta(im);
return is;
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}

View File

@@ -19,10 +19,10 @@
package com.volmit.iris.util.inventorygui;
import com.volmit.iris.Iris;
import com.volmit.iris.util.scheduling.Callback;
import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.collection.KSet;
import com.volmit.iris.util.scheduling.Callback;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;

View File

@@ -111,7 +111,8 @@ public class IO {
fullTransfer(din, new VoidOutputStream(), 8192);
din.close();
return bytesToHex(din.getMessageDigest().digest());
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
@@ -133,8 +134,8 @@ public class IO {
* Transfers the length of the buffer amount of data from the input stream to
* the output stream
*
* @param in the input
* @param out the output
* @param in the input
* @param out the output
* @return the actual transfered amount
* @throws IOException shit happens
*/
@@ -307,7 +308,8 @@ public class IO {
v.accept(in);
}
}
} catch (Exception ex) {Iris.reportError(ex);
} catch (Exception ex) {
Iris.reportError(ex);
x = ex.getCause();
} finally {
file.close();
@@ -329,7 +331,8 @@ public class IO {
FileReader fr;
try {
fr = new FileReader(f);
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw e;
}
BufferedReader bu = new BufferedReader(fr);
@@ -484,7 +487,8 @@ public class IO {
if (input != null) {
input.close();
}
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// ignore
}
}
@@ -502,7 +506,8 @@ public class IO {
if (output != null) {
output.close();
}
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// ignore
}
}
@@ -520,7 +525,8 @@ public class IO {
if (input != null) {
input.close();
}
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// ignore
}
}
@@ -538,7 +544,8 @@ public class IO {
if (output != null) {
output.close();
}
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// ignore
}
}

View File

@@ -19,9 +19,6 @@
package com.volmit.iris.util.json;
import com.volmit.iris.util.json.JSONException;
import com.volmit.iris.util.json.JSONTokener;
/**
* The HTTPTokener extends the JSONTokener to provide additional methods for the
* parsing of HTTP headers.

View File

@@ -261,7 +261,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return new BigDecimal(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] could not convert to BigDecimal.");
}
}
@@ -278,7 +279,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return new BigInteger(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] could not convert to BigInteger.");
}
}
@@ -294,7 +296,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@@ -343,7 +346,8 @@ public class JSONArray implements Iterable<Object> {
Object object = this.get(index);
try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONArray[" + index + "] is not a number.");
}
}
@@ -438,7 +442,8 @@ public class JSONArray implements Iterable<Object> {
public boolean optBoolean(int index, boolean defaultValue) {
try {
return this.getBoolean(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -467,7 +472,8 @@ public class JSONArray implements Iterable<Object> {
public double optDouble(int index, double defaultValue) {
try {
return this.getDouble(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -496,7 +502,8 @@ public class JSONArray implements Iterable<Object> {
public int optInt(int index, int defaultValue) {
try {
return this.getInt(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -534,9 +541,11 @@ public class JSONArray implements Iterable<Object> {
return myE;
}
return Enum.valueOf(clazz, val.toString());
} catch (IllegalArgumentException e) {Iris.reportError(e);
} catch (IllegalArgumentException e) {
Iris.reportError(e);
return defaultValue;
} catch (NullPointerException e) {Iris.reportError(e);
} catch (NullPointerException e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -553,7 +562,8 @@ public class JSONArray implements Iterable<Object> {
public BigInteger optBigInteger(int index, BigInteger defaultValue) {
try {
return this.getBigInteger(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -570,7 +580,8 @@ public class JSONArray implements Iterable<Object> {
public BigDecimal optBigDecimal(int index, BigDecimal defaultValue) {
try {
return this.getBigDecimal(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -624,7 +635,8 @@ public class JSONArray implements Iterable<Object> {
public long optLong(int index, long defaultValue) {
try {
return this.getLong(index);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -937,7 +949,8 @@ public class JSONArray implements Iterable<Object> {
public String toString() {
try {
return this.toString(0);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}

View File

@@ -283,7 +283,8 @@ public class JSONObject {
String name = names[i];
try {
this.putOpt(name, c.getField(name).get(object));
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
}
@@ -491,7 +492,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return new BigInteger(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigInteger.");
}
}
@@ -508,7 +510,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return new BigDecimal(object.toString());
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] could not be converted to BigDecimal.");
}
}
@@ -525,7 +528,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).doubleValue() : Double.parseDouble((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not a number.");
}
}
@@ -542,7 +546,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).intValue() : Integer.parseInt((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not an int.");
}
}
@@ -589,7 +594,8 @@ public class JSONObject {
Object object = this.get(key);
try {
return object instanceof Number ? ((Number) object).longValue() : Long.parseLong((String) object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException("JSONObject[" + quote(key) + "] is not a long.");
}
}
@@ -818,9 +824,11 @@ public class JSONObject {
return myE;
}
return Enum.valueOf(clazz, val.toString());
} catch (IllegalArgumentException e) {Iris.reportError(e);
} catch (IllegalArgumentException e) {
Iris.reportError(e);
return defaultValue;
} catch (NullPointerException e) {Iris.reportError(e);
} catch (NullPointerException e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -848,7 +856,8 @@ public class JSONObject {
public boolean optBoolean(String key, boolean defaultValue) {
try {
return this.getBoolean(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -877,7 +886,8 @@ public class JSONObject {
public BigInteger optBigInteger(String key, BigInteger defaultValue) {
try {
return this.getBigInteger(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -894,7 +904,8 @@ public class JSONObject {
public BigDecimal optBigDecimal(String key, BigDecimal defaultValue) {
try {
return this.getBigDecimal(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -911,7 +922,8 @@ public class JSONObject {
public double optDouble(String key, double defaultValue) {
try {
return this.getDouble(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -940,7 +952,8 @@ public class JSONObject {
public int optInt(String key, int defaultValue) {
try {
return this.getInt(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -993,7 +1006,8 @@ public class JSONObject {
public long optLong(String key, long defaultValue) {
try {
return this.getLong(key);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return defaultValue;
}
}
@@ -1059,7 +1073,8 @@ public class JSONObject {
}
}
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
}
@@ -1220,7 +1235,8 @@ public class JSONObject {
synchronized (sw.getBuffer()) {
try {
return quote(string, sw).toString();
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
// will never happen - we are writing to a string writer
return "";
}
@@ -1331,7 +1347,8 @@ public class JSONObject {
}
}
return true;
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
return false;
}
}
@@ -1381,7 +1398,8 @@ public class JSONObject {
}
}
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
return string;
@@ -1442,7 +1460,8 @@ public class JSONObject {
public String toString() {
try {
return this.toString(0);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}
@@ -1496,7 +1515,8 @@ public class JSONObject {
Object object;
try {
object = ((JSONString) value).toJSONString();
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException(e);
}
if (object instanceof String) {
@@ -1565,7 +1585,8 @@ public class JSONObject {
return object.toString();
}
return new JSONObject(object);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
return null;
}
}
@@ -1608,7 +1629,8 @@ public class JSONObject {
Object o;
try {
o = ((JSONString) value).toJSONString();
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
throw new JSONException(e);
}
writer.write(o != null ? o.toString() : quote(value.toString()));
@@ -1674,7 +1696,8 @@ public class JSONObject {
}
writer.write('}');
return writer;
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
}

View File

@@ -398,7 +398,8 @@ public class JSONTokener {
return c;
}
} while (c != to);
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
this.back();

View File

@@ -163,7 +163,8 @@ public class JSONWriter {
this.pop(mode);
try {
this.writer.write(c);
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
this.comma = true;
@@ -216,7 +217,8 @@ public class JSONWriter {
this.comma = false;
this.mode = 'o';
return this;
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
throw new JSONException(e);
}
}

View File

@@ -330,7 +330,8 @@ public class XML {
if (value.toString().equals(string)) {
return value;
}
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
}
}
return string;

View File

@@ -23,34 +23,16 @@ public class AlignedPoint {
private double y;
private double z;
public AlignedPoint(double x, double y, double z) {
this.x = x;
this.y = y;
this.z = z;
}
public double getX() {
return x;
}
public void setX(double x) {
this.x = x;
}
public double getY() {
return y;
}
public void setY(double y) {
this.y = y;
}
public double getZ() {
return z;
}
public void setZ(double z) {
this.z = z;
}
}

View File

@@ -18,10 +18,10 @@
package com.volmit.iris.util.math;
import com.volmit.iris.util.data.Cuboid.CuboidDirection;
import com.volmit.iris.util.collection.GBiset;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.Cuboid.CuboidDirection;
import org.bukkit.Axis;
import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector;

View File

@@ -251,7 +251,7 @@ public class IrisMathHelper {
}
public static long c(final int var0, final int var1, final int var2) {
long var3 = (long) (var0 * 3129871L) ^ var2 * 116129781L ^ (long) var1;
long var3 = (var0 * 3129871L) ^ var2 * 116129781L ^ (long) var1;
var3 = var3 * var3 * 42317861L + var3 * 11L;
return var3 >> 16;
}

View File

@@ -86,10 +86,10 @@ public class M {
/**
* Bilinear interpolation
*
* @param a the first point (0, 0)
* @param b the second point (1, 0)
* @param c the third point (0, 1)
* @param d the fourth point (1, 1)
* @param a the first point (0, 0)
* @param b the second point (1, 0)
* @param c the third point (0, 1)
* @param d the fourth point (1, 1)
* @return the bilerped value
*/
public static double bilerp(double a, double b, double c, double d, double x, double y) {

View File

@@ -508,7 +508,8 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
// Since there are no arrays we can just use Object.clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {Iris.reportError(e);
} catch (CloneNotSupportedException e) {
Iris.reportError(e);
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}

View File

@@ -512,7 +512,8 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
// Since there are no arrays we can just use Object.clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {Iris.reportError(e);
} catch (CloneNotSupportedException e) {
Iris.reportError(e);
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}

View File

@@ -582,7 +582,8 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
// Since there are no arrays we can just use Object.clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {Iris.reportError(e);
} catch (CloneNotSupportedException e) {
Iris.reportError(e);
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}

View File

@@ -713,7 +713,8 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
// Since there are no arrays we can just use Object.clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {Iris.reportError(e);
} catch (CloneNotSupportedException e) {
Iris.reportError(e);
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}

View File

@@ -637,7 +637,8 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
// Since there are no arrays we can just use Object.clone()
try {
return super.clone();
} catch (CloneNotSupportedException e) {Iris.reportError(e);
} catch (CloneNotSupportedException e) {
Iris.reportError(e);
// this shouldn't happen, since we are Cloneable
throw new InternalError();
}

View File

@@ -18,9 +18,9 @@
package com.volmit.iris.util.math;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.collection.GListAdapter;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.Form;
import org.bukkit.Axis;
import org.bukkit.Bukkit;
import org.bukkit.Location;

View File

@@ -148,7 +148,8 @@ class ParticleSenderLegacy implements ParticleSender {
try {
return getEnumParticle(particle);
} catch (IllegalArgumentException e) {Iris.reportError(e);
} catch (IllegalArgumentException e) {
Iris.reportError(e);
return null;
}
}

View File

@@ -1,23 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.plugin;
public interface IActivator {
}

View File

@@ -156,7 +156,8 @@ public class Metrics {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException e) {Iris.reportError(e);
} catch (NoSuchFieldException e) {
Iris.reportError(e);
}
}
// Register our service
@@ -255,7 +256,8 @@ public class Metrics {
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class)
? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size()
: ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
}
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
@@ -314,7 +316,8 @@ public class Metrics {
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
pluginData.add(object);
}
} catch (ClassNotFoundException e) {Iris.reportError(e);
} catch (ClassNotFoundException e) {
Iris.reportError(e);
// minecraft version 1.14+
if (logFailedRequests) {
@@ -326,7 +329,8 @@ public class Metrics {
Iris.reportError(ignored);
}
}
} catch (NoSuchFieldException e) {Iris.reportError(e);
} catch (NoSuchFieldException e) {
Iris.reportError(e);
}
}
@@ -337,7 +341,8 @@ public class Metrics {
try {
// Send the data
sendData(plugin, data);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);
@@ -444,7 +449,8 @@ public class Metrics {
return null;
}
chart.add("data", data);
} catch (Throwable t) {Iris.reportError(t);
} catch (Throwable t) {
Iris.reportError(t);
if (logFailedRequests) {
Bukkit.getLogger().log(Level.WARNING, "Failed to get data for custom chart with id " + chartId, t);
}

View File

@@ -152,7 +152,8 @@ public class MetricsLite {
service.getField("B_STATS_VERSION"); // Our identifier :)
found = true; // We aren't the first
break;
} catch (NoSuchFieldException e) {Iris.reportError(e);
} catch (NoSuchFieldException e) {
Iris.reportError(e);
}
}
// Register our service
@@ -232,7 +233,8 @@ public class MetricsLite {
// org.bukkit.Bukkit.getOnlinePlayers()Ljava/util/Collection;
Method onlinePlayersMethod = Class.forName("org.bukkit.Server").getMethod("getOnlinePlayers");
playerAmount = onlinePlayersMethod.getReturnType().equals(Collection.class) ? ((Collection<?>) onlinePlayersMethod.invoke(Bukkit.getServer())).size() : ((Player[]) onlinePlayersMethod.invoke(Bukkit.getServer())).length;
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
playerAmount = Bukkit.getOnlinePlayers().size(); // Just use the new method if the Reflection failed
}
int onlineMode = Bukkit.getOnlineMode() ? 1 : 0;
@@ -291,7 +293,8 @@ public class MetricsLite {
JsonObject object = new JsonParser().parse(jsonString).getAsJsonObject();
pluginData.add(object);
}
} catch (ClassNotFoundException e) {Iris.reportError(e);
} catch (ClassNotFoundException e) {
Iris.reportError(e);
// minecraft version 1.14+
if (logFailedRequests) {
this.plugin.getLogger().log(Level.SEVERE, "Encountered unexpected exception ", e);
@@ -302,7 +305,8 @@ public class MetricsLite {
Iris.reportError(ignored);
}
}
} catch (NoSuchFieldException e) {Iris.reportError(e);
} catch (NoSuchFieldException e) {
Iris.reportError(e);
}
}
@@ -314,7 +318,8 @@ public class MetricsLite {
try {
// Send the data
sendData(plugin, data);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
// Something went wrong! :(
if (logFailedRequests) {
plugin.getLogger().log(Level.WARNING, "Could not submit plugin stats of " + plugin.getName(), e);

View File

@@ -20,8 +20,8 @@ package com.volmit.iris.util.plugin;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.format.C;
import org.bukkit.Sound;
import java.lang.reflect.Field;

View File

@@ -20,9 +20,9 @@ package com.volmit.iris.util.plugin;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.reflect.V;
import org.bukkit.Bukkit;
import org.bukkit.Sound;
@@ -58,7 +58,8 @@ public class VirtualCommand {
ICommand cmd = (ICommand) i.getType().getConstructor().newInstance();
new V(command, true, true).set(i.getName(), cmd);
children.put(cmd.getAllNodes(), new VirtualCommand(cmd, cc.value().trim().isEmpty() ? tag : cc.value().trim()));
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
e.printStackTrace();
}
}

View File

@@ -89,7 +89,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
listenersField.setAccessible(true);
//noinspection unchecked
listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(getServer().getPluginManager());
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -101,7 +102,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
//noinspection unchecked
commands = (Map<String, Command>) knownCommandsField.get(commandMap);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -134,7 +136,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
if (cl instanceof URLClassLoader) {
try {
((URLClassLoader) cl).close();
} catch (IOException e) {Iris.reportError(e);
} catch (IOException e) {
Iris.reportError(e);
}
}
@@ -193,7 +196,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
outputPluginInfo();
outputCommandInfo();
outputPermissionInfo();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
}
@@ -275,7 +279,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
for (org.bukkit.permissions.Permission i : computePermissions()) {
try {
Bukkit.getPluginManager().addPermission(i);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
}
@@ -290,7 +295,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
g.add(toPermission(x));
g.addAll(computePermissions(x));
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
Iris.reportError(e);e.printStackTrace();
Iris.reportError(e);
e.printStackTrace();
}
}
}
@@ -370,7 +376,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
i.tick();
} catch (Throwable e) {
w("Failed to tick controller " + i.getName());
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
}
@@ -400,7 +407,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
v("Registered " + pc.getName() + " (" + i.getName() + ")");
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
w("Failed to register controller (field " + i.getName() + ")");
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
}
@@ -425,7 +433,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
v("Started " + pc.getName());
} catch (Throwable e) {
w("Failed to start controller " + pc.getName());
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
@@ -441,7 +450,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
v("Registered Instance " + i.getName());
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
w("Failed to register instance (field " + i.getName() + ")");
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
}
@@ -459,7 +469,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
v("Unregistered Instance " + i.getName());
} catch (IllegalArgumentException | IllegalAccessException | SecurityException e) {
w("Failed to unregister instance (field " + i.getName() + ")");
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
}
@@ -483,7 +494,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
v("Registered Commands /" + pc.getNode() + " (" + i.getName() + ")");
} catch (IllegalArgumentException | IllegalAccessException | InstantiationException | InvocationTargetException | NoSuchMethodException | SecurityException e) {
w("Failed to register command (field " + i.getName() + ")");
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
}
@@ -591,7 +603,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
}
}
} catch (Throwable e) {
e.printStackTrace();Iris.reportError(e);
e.printStackTrace();
Iris.reportError(e);
}
}
@@ -630,7 +643,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
for (VirtualCommand i : commands.v()) {
try {
unregisterCommand(i.getCommand());
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
}
@@ -655,7 +669,8 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
unregisterListener(i);
i.stop();
v("Stopped " + i.getName());
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
w("Failed to stop controller " + i.getName());
e.printStackTrace();
}

View File

@@ -65,7 +65,8 @@ public class V {
public <T extends Annotation> T get(Class<? extends T> t, String mn, Class<?>... pars) {
try {
return local ? Violator.getDeclaredAnnotation(Violator.getDeclaredMethod(o.getClass(), mn, pars), t) : Violator.getAnnotation(Violator.getMethod(o.getClass(), mn, pars), t);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
if (!suppress) {
e.printStackTrace();
}
@@ -77,7 +78,8 @@ public class V {
public <T extends Annotation> T get(Class<? extends T> t, String mn) {
try {
return local ? Violator.getDeclaredAnnotation(Violator.getDeclaredField(o.getClass(), mn), t) : Violator.getAnnotation(Violator.getField(o.getClass(), mn), t);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
if (!suppress) {
e.printStackTrace();
}
@@ -90,7 +92,8 @@ public class V {
public <T> T get(String field) {
try {
return (T) (local ? Violator.getDeclaredField(o.getClass(), field) : Violator.getField(o.getClass(), field)).get(o);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
if (!suppress) {
e.printStackTrace();
}
@@ -112,7 +115,8 @@ public class V {
try {
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) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
if (!suppress) {
e.printStackTrace();
}
@@ -125,7 +129,8 @@ public class V {
try {
// https://github.com/VolmitSoftware/Mortar/issues/5
(local ? Violator.getDeclaredField(o.getClass(), field) : Violator.getField(o.getClass(), field)).set(o, value);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
if (!suppress) {
e.printStackTrace();
}

View File

@@ -135,7 +135,8 @@ public class Violator {
Field f = c.getDeclaredField(name);
f.setAccessible(true);
p(id(c, null) + "." + name, f);
} catch (NoSuchFieldException e) {Iris.reportError(e);
} catch (NoSuchFieldException e) {
Iris.reportError(e);
Class s = c.getSuperclass();
if (null == s) {
throw e;
@@ -180,7 +181,8 @@ public class Violator {
try {
Constructor<?> co = getConstructor(c, cv.toArray(new Class<?>[0]));
return (T) co.newInstance(parameters);
} catch (Exception e) {Iris.reportError(e);
} catch (Exception e) {
Iris.reportError(e);
e.printStackTrace();
}

View File

@@ -1,23 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.scheduling;
public interface CallbackCV<T> {
void run(T t);
}

View File

@@ -1,71 +0,0 @@
/*
* Iris is a World Generator for Minecraft Bukkit Servers
* Copyright (c) 2021 Arcane Arts (Volmit Software)
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package com.volmit.iris.util.scheduling;
import com.volmit.iris.util.collection.KList;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;
import java.util.function.Consumer;
public class Chunker<T> {
private ExecutorService executor;
private int threads;
private int workload;
private final KList<T> q;
public Chunker(KList<T> q) {
this.q = q;
}
public Chunker<T> threads(int threads) {
this.threads = threads;
return this;
}
public Chunker<T> workload(int workload) {
this.workload = workload;
return this;
}
public void execute(Consumer<T> consumer, Callback<Double> progress, int progressInterval) {
ChronoLatch cl = new ChronoLatch(progressInterval);
Contained<Integer> consumed = new Contained<>(0);
executor = Executors.newFixedThreadPool(threads);
int length = q.size();
int remaining = length;
while (remaining > 0) {
int at = remaining;
remaining -= (Math.min(remaining, workload));
int to = remaining;
executor.submit(() ->
{
J.dofor(at, (i) -> i >= to, -1, (i) -> J.attempt(() -> consumer.accept(q.get(i))));
consumed.mod((c) -> c += workload);
J.doif(() -> progress != null && cl.flip(), () -> progress.run((double) consumed.get() / (double) length));
});
}
executor.shutdown();
J.attempt(() -> executor.awaitTermination(100, TimeUnit.HOURS));
}
}

View File

@@ -23,14 +23,6 @@ import java.util.function.Function;
public class Contained<T> {
private T t;
public Contained(T t) {
set(t);
}
public Contained() {
this(null);
}
public void mod(Function<T, T> x) {
set(x.apply(t));
}

View File

@@ -21,7 +21,6 @@ package com.volmit.iris.util.scheduling;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.function.NastyRunnable;
import com.volmit.iris.util.scheduling.J;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

View File

@@ -63,7 +63,8 @@ public class J {
g.run();
return true;
}
} catch (NullPointerException e) {Iris.reportError(e);
} catch (NullPointerException e) {
Iris.reportError(e);
// TODO: Fix this because this is just a suppression for an NPE on g
return false;
}
@@ -75,7 +76,8 @@ public class J {
e.submit(() -> {
try {
a.run();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
System.out.println("Failed to run async task");
e.printStackTrace();
}
@@ -86,7 +88,8 @@ public class J {
e.submit(() -> {
try {
a.run();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
System.out.println("Failed to run async task");
e.printStackTrace();
}
@@ -104,7 +107,8 @@ public class J {
public static <R> R attemptResult(NastyFuture<R> r, R onError) {
try {
return r.run();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -114,7 +118,8 @@ public class J {
public static <T, R> R attemptFunction(NastyFunction<T, R> r, T param, R onError) {
try {
return r.run(param);
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
}
@@ -132,7 +137,8 @@ public class J {
public static Throwable attemptCatch(NastyRunnable r) {
try {
r.run();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
return e;
}
@@ -142,7 +148,8 @@ public class J {
public static <T> T attempt(Supplier<T> t, T i) {
try {
return t.get();
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
return i;
}
}

View File

@@ -33,9 +33,11 @@ public abstract class Looper extends Thread {
//noinspection BusyWait
Thread.sleep(m);
} catch (InterruptedException e) {Iris.reportError(e);
} catch (InterruptedException e) {
Iris.reportError(e);
break;
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
e.printStackTrace();
}
}

View File

@@ -195,7 +195,8 @@ public class TaskExecutor {
try {
task.run();
state = TaskState.COMPLETED;
} catch (Throwable ex) {Iris.reportError(ex);
} catch (Throwable ex) {
Iris.reportError(ex);
ex.printStackTrace();
Iris.reportError(ex);
state = TaskState.FAILED;

View File

@@ -62,7 +62,8 @@ public class ThreadMonitor extends Thread {
if (cl.flip()) {
Iris.info("Cycles: " + Form.f(cycles) + " (" + Form.duration(sq.getAverage(), 2) + ")");
}
} catch (Throwable e) {Iris.reportError(e);
} catch (Throwable e) {
Iris.reportError(e);
running = false;
break;
}