9
0
mirror of https://github.com/VolmitSoftware/Iris.git synced 2025-12-27 19:19:07 +00:00

Totally stable optimizations that wont cause any problems at all.

This commit is contained in:
Daniel Mills
2021-07-14 16:40:20 -04:00
parent 886553a923
commit 7d423fa49d
260 changed files with 2329 additions and 3058 deletions

View File

@@ -28,7 +28,7 @@ import com.google.common.util.concurrent.AtomicDoubleArray;
* @author cyberpwn
*/
public class AtomicAverage {
protected AtomicDoubleArray values;
protected final AtomicDoubleArray values;
private double average;
private double lastSum;
private boolean dirty;
@@ -71,7 +71,7 @@ public class AtomicAverage {
lastSum = (lastSum - current) + i;
values.set(cursor, i);
cursor = cursor + 1 < size() ? cursor + 1 : 0;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}

View File

@@ -26,7 +26,7 @@ package com.volmit.iris.util;
* @author cyberpwn
*/
public class Average {
protected double[] values;
protected final double[] values;
private double average;
private double lastSum;
private boolean dirty;

View File

@@ -140,7 +140,7 @@ public class B {
BlockData bx = Bukkit.createBlockData(ix);
blockDataCache.put(ix, bx);
return bx;
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@@ -151,7 +151,7 @@ public class B {
try {
BlockData bd = Material.valueOf(i).createBlockData();
blockDataCache.put(ix, bd);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@@ -485,7 +485,7 @@ public class B {
public static String[] getBlockTypes() {
KList<String> bt = new KList<String>();
KList<String> bt = new KList<>();
for (Material i : Material.values()) {
if (i.isBlock()) {
@@ -503,17 +503,17 @@ public class B {
}
}
return bt.toArray(new String[bt.size()]);
return bt.toArray(new String[0]);
}
public static String[] getItemTypes() {
KList<String> bt = new KList<String>();
KList<String> bt = new KList<>();
for (Material i : Material.values()) {
String v = i.name().toLowerCase().trim();
bt.add(v);
}
return bt.toArray(new String[bt.size()]);
return bt.toArray(new String[0]);
}
}

View File

@@ -53,8 +53,7 @@ public class BlockPosition {
return false;
}
if (o instanceof BlockPosition) {
BlockPosition ot = (BlockPosition) o;
if (o instanceof BlockPosition ot) {
return ot.x == x && ot.y == y && ot.z == z;
}
@@ -85,7 +84,7 @@ public class BlockPosition {
public static long toLong(int x, int y, int z) {
long var3 = 0L;
var3 |= (x & m4) << m3;
var3 |= (y & m5) << 0L;
var3 |= (y & m5);
var3 |= (z & m6) << m2;
return var3;
}

View File

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

View File

@@ -25,6 +25,7 @@ import org.apache.commons.lang.StringUtils;
* @author Missionary (missionarymc@gmail.com)
* @since 3/29/2018
*/
@SuppressWarnings("ClassCanBeRecord")
public class BoardEntry {
@Getter

View File

@@ -22,6 +22,7 @@ import lombok.Builder;
import lombok.Getter;
@SuppressWarnings("ClassCanBeRecord")
@Getter
@Builder
public class BoardSettings {

View File

@@ -245,11 +245,12 @@ public enum C {
private final char code;
private final boolean isFormat;
private final String toString;
private final static Map<Integer, C> BY_ID = new HashMap<Integer, C>();
private final static Map<Character, C> BY_CHAR = new HashMap<Character, C>();
private final static Map<DyeColor, C> dyeChatMap = new HashMap<DyeColor, C>();
private final static Map<C, String> chatHexMap = new HashMap<C, String>();
private final static Map<DyeColor, String> dyeHexMap = new HashMap<DyeColor, String>();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection")
private final static Map<Integer, C> BY_ID = new HashMap<>();
private final static Map<Character, C> BY_CHAR = new HashMap<>();
private final static Map<DyeColor, C> dyeChatMap = new HashMap<>();
private final static Map<C, String> chatHexMap = new HashMap<>();
private final static Map<DyeColor, String> dyeHexMap = new HashMap<>();
static {
chatHexMap.put(C.BLACK, "#000");
@@ -334,7 +335,6 @@ public enum C {
/**
* get the dye color for the chatcolor
*
* @return
*/
public DyeColor dye() {
return chatToDye(chatColor());
@@ -424,9 +424,9 @@ public enum C {
}
public static DyeColor chatToDye(ChatColor color) {
for (DyeColor i : dyeChatMap.keySet()) {
if (dyeChatMap.get(i).toString().equals(color.toString())) {
return i;
for (Map.Entry<DyeColor, C> entry : dyeChatMap.entrySet()) {
if (entry.getValue().toString().equals(color.toString())) {
return entry.getKey();
}
}
@@ -455,7 +455,7 @@ public enum C {
hex = hex.substring(1);
}
if (hex.indexOf("x") != -1) {
if (hex.contains("x")) {
hex = hex.substring(hex.indexOf("x"));
}
@@ -509,7 +509,6 @@ public enum C {
/**
* Get the ChatColor enum instance instead of C
*
* @return
*/
public ChatColor chatColor() {
return ChatColor.getByChar(code);
@@ -551,105 +550,43 @@ public enum C {
}
public byte getMeta() {
switch (this) {
case AQUA:
return 11;
case BLACK:
return 0;
case BLUE:
return 9;
case BOLD:
return -1;
case DARK_AQUA:
return 9;
case DARK_BLUE:
return 1;
case DARK_GRAY:
return 8;
case DARK_GREEN:
return 2;
case DARK_PURPLE:
return 5;
case DARK_RED:
return 4;
case GOLD:
return 6;
case GRAY:
return 7;
case GREEN:
return 10;
case ITALIC:
return -1;
case LIGHT_PURPLE:
return 13;
case MAGIC:
return -1;
case RED:
return 12;
case RESET:
return -1;
case STRIKETHROUGH:
return -1;
case UNDERLINE:
return -1;
case WHITE:
return 15;
case YELLOW:
return 14;
default:
return -1;
}
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;
};
}
public byte getItemMeta() {
switch (this) {
case AQUA:
return 9;
case BLACK:
return 15;
case BLUE:
return 3;
case BOLD:
return -1;
case DARK_AQUA:
return 9;
case DARK_BLUE:
return 11;
case DARK_GRAY:
return 7;
case DARK_GREEN:
return 13;
case DARK_PURPLE:
return 10;
case DARK_RED:
return 14;
case GOLD:
return 4;
case GRAY:
return 8;
case GREEN:
return 5;
case ITALIC:
return -1;
case LIGHT_PURPLE:
return 2;
case MAGIC:
return -1;
case RED:
return 14;
case RESET:
return -1;
case STRIKETHROUGH:
return -1;
case UNDERLINE:
return -1;
case WHITE:
return 0;
case YELLOW:
return 4;
default:
return -1;
}
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;
};
}
public static C randomColor() {
@@ -663,7 +600,7 @@ public enum C {
* @return Any remaining ChatColors to pass onto the next line.
*/
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
@@ -674,7 +611,7 @@ public enum C {
C color = getByChar(c);
if (color != null) {
result = color + result;
result.insert(0, color);
// Once we find a color or reset we can stop searching
if (color.isColor() || color.equals(RESET)) {
@@ -684,7 +621,7 @@ public enum C {
}
}
return result;
return result.toString();
}
static {

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util;
@SuppressWarnings("ALL")
public class CDou {
private double number;
private final double max;

View File

@@ -20,9 +20,12 @@ package com.volmit.iris.util;
import lombok.Value;
@SuppressWarnings("ClassCanBeRecord")
@Value
public class CarveResult {
@SuppressWarnings("RedundantModifiersValueLombok")
private final int surface;
@SuppressWarnings("RedundantModifiersValueLombok")
private final int ceiling;
public int getHeight() {

View File

@@ -57,10 +57,9 @@ public class ChunkPosition {
if (this == obj) {
return true;
}
if (!(obj instanceof ChunkPosition)) {
if (!(obj instanceof ChunkPosition other)) {
return false;
}
ChunkPosition other = (ChunkPosition) obj;
return x == other.x && z == other.z;
}

View File

@@ -45,14 +45,14 @@ public class Chunker<T> {
public void execute(Consumer<T> consumer, Callback<Double> progress, int progressInterval) {
ChronoLatch cl = new ChronoLatch(progressInterval);
Contained<Integer> consumed = new Contained<Integer>(0);
Contained<Integer> consumed = new Contained<>(0);
executor = Executors.newFixedThreadPool(threads);
int length = q.size();
int remaining = length;
while (remaining > 0) {
int at = remaining;
remaining -= (remaining > workload ? workload : remaining);
remaining -= (Math.min(remaining, workload));
int to = remaining;
executor.submit(() ->

View File

@@ -56,9 +56,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();

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@SuppressWarnings({"hiding", "RedundantSuppression"})
@FunctionalInterface
public interface Consumer2<A, B> {
void accept(A a, B b);

View File

@@ -18,7 +18,7 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@SuppressWarnings("ALL")
@FunctionalInterface
public interface Consumer3<A, B, C> {
void accept(A a, B b, C c);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Consumer4<A, B, C, D> {
void accept(A a, B b, C c, D d);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Consumer5<A, B, C, D, E> {
void accept(A a, B b, C c, D d, E e);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Consumer6<A, B, C, D, E, F> {
void accept(A a, B b, C c, D d, E e, F f);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@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,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Consumer8<A, B, C, D, E, F, G, H> {
void accept(A a, B b, C c, D d, E e, F f, G g, H h);

View File

@@ -29,7 +29,7 @@ public abstract class Controller implements IController {
tickRate = -1;
}
protected void setTickRate(int rate) {
protected void setTickRate(@SuppressWarnings("SameParameterValue") int rate) {
this.tickRate = rate;
}

View File

@@ -23,6 +23,7 @@ import java.io.File;
public interface Converter {
String getInExtension();
@SuppressWarnings("SameReturnValue")
String getOutExtension();
void convert(File in, File out);

View File

@@ -22,6 +22,7 @@ import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.configuration.serialization.ConfigurationSerializable;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import java.util.*;
@@ -57,7 +58,7 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
}
public KList<Entity> getEntities() {
KList<Entity> en = new KList<Entity>();
KList<Entity> en = new KList<>();
for (Chunk i : getChunks()) {
for (Entity j : i.getEntities()) {
@@ -155,9 +156,10 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
z2 = (Integer) map.get("z2");
}
@NotNull
@Override
public Map<String, Object> serialize() {
Map<String, Object> map = new HashMap<String, Object>();
Map<String, Object> map = new HashMap<>();
map.put("worldName", worldName);
map.put("x1", x1);
map.put("y1", y1);
@@ -337,22 +339,15 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* @return a new Cuboid expanded by the given direction and amount
*/
public Cuboid expand(CuboidDirection dir, int amount) {
switch (dir) {
case North:
return new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2);
case South:
return new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2);
case East:
return new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2);
case West:
return new Cuboid(worldName, x1, y1, z1, x2, y2, z2 + amount);
case Down:
return new Cuboid(worldName, x1, y1 - amount, z1, x2, y2, z2);
case Up:
return new Cuboid(worldName, x1, y1, z1, x2, y2 + amount, z2);
default:
throw new IllegalArgumentException("invalid direction " + dir);
}
return switch (dir) {
case North -> new Cuboid(worldName, x1 - amount, y1, z1, x2, y2, z2);
case South -> new Cuboid(worldName, x1, y1, z1, x2 + amount, y2, z2);
case East -> new Cuboid(worldName, x1, y1, z1 - amount, x2, y2, z2);
case West -> new Cuboid(worldName, x1, y1, z1, x2, y2, z2 + amount);
case Down -> new Cuboid(worldName, x1, y1 - amount, z1, x2, y2, z2);
case Up -> new Cuboid(worldName, x1, y1, z1, x2, y2 + amount, z2);
default -> throw new IllegalArgumentException("invalid direction " + dir);
};
}
public Cuboid expand(Direction dir, int amount) {
@@ -385,20 +380,12 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* @return a new Cuboid outset by the given direction and amount
*/
public Cuboid outset(CuboidDirection dir, int amount) {
Cuboid c;
switch (dir) {
case Horizontal:
c = expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
break;
case Vertical:
c = expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
break;
case Both:
c = outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
break;
default:
throw new IllegalArgumentException("invalid direction " + dir);
}
Cuboid c = switch (dir) {
case Horizontal -> expand(CuboidDirection.North, amount).expand(CuboidDirection.South, amount).expand(CuboidDirection.East, amount).expand(CuboidDirection.West, amount);
case Vertical -> expand(CuboidDirection.Down, amount).expand(CuboidDirection.Up, amount);
case Both -> outset(CuboidDirection.Horizontal, amount).outset(CuboidDirection.Vertical, amount);
default -> throw new IllegalArgumentException("invalid direction " + dir);
};
return c;
}
@@ -495,38 +482,43 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
public Cuboid contract(CuboidDirection dir) {
Cuboid face = getFace(dir.opposite());
switch (dir) {
case Down:
case Down -> {
while (face.containsOnly(Material.AIR) && face.getLowerY() > this.getLowerY()) {
face = face.shift(CuboidDirection.Down, 1);
}
return new Cuboid(worldName, x1, y1, z1, x2, face.getUpperY(), z2);
case Up:
}
case Up -> {
while (face.containsOnly(Material.AIR) && face.getUpperY() < this.getUpperY()) {
face = face.shift(CuboidDirection.Up, 1);
}
return new Cuboid(worldName, x1, face.getLowerY(), z1, x2, y2, z2);
case North:
}
case North -> {
while (face.containsOnly(Material.AIR) && face.getLowerX() > this.getLowerX()) {
face = face.shift(CuboidDirection.North, 1);
}
return new Cuboid(worldName, x1, y1, z1, face.getUpperX(), y2, z2);
case South:
}
case South -> {
while (face.containsOnly(Material.AIR) && face.getUpperX() < this.getUpperX()) {
face = face.shift(CuboidDirection.South, 1);
}
return new Cuboid(worldName, face.getLowerX(), y1, z1, x2, y2, z2);
case East:
}
case East -> {
while (face.containsOnly(Material.AIR) && face.getLowerZ() > this.getLowerZ()) {
face = face.shift(CuboidDirection.East, 1);
}
return new Cuboid(worldName, x1, y1, z1, x2, y2, face.getUpperZ());
case West:
}
case West -> {
while (face.containsOnly(Material.AIR) && face.getUpperZ() < this.getUpperZ()) {
face = face.shift(CuboidDirection.West, 1);
}
return new Cuboid(worldName, x1, y1, face.getLowerZ(), x2, y2, z2);
default:
throw new IllegalArgumentException("Invalid direction " + dir);
}
default -> throw new IllegalArgumentException("Invalid direction " + dir);
}
}
@@ -538,22 +530,15 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* @return the Cuboid representing this Cuboid's requested face
*/
public Cuboid getFace(CuboidDirection dir) {
switch (dir) {
case Down:
return new Cuboid(worldName, x1, y1, z1, x2, y1, z2);
case Up:
return new Cuboid(worldName, x1, y2, z1, x2, y2, z2);
case North:
return new Cuboid(worldName, x1, y1, z1, x1, y2, z2);
case South:
return new Cuboid(worldName, x2, y1, z1, x2, y2, z2);
case East:
return new Cuboid(worldName, x1, y1, z1, x2, y2, z1);
case West:
return new Cuboid(worldName, x1, y1, z2, x2, y2, z2);
default:
throw new IllegalArgumentException("Invalid direction " + dir);
}
return switch (dir) {
case Down -> new Cuboid(worldName, x1, y1, z1, x2, y1, z2);
case Up -> new Cuboid(worldName, x1, y2, z1, x2, y2, z2);
case North -> new Cuboid(worldName, x1, y1, z1, x1, y2, z2);
case South -> new Cuboid(worldName, x2, y1, z1, x2, y2, z2);
case East -> new Cuboid(worldName, x1, y1, z1, x2, y2, z1);
case West -> new Cuboid(worldName, x1, y1, z2, x2, y2, z2);
default -> throw new IllegalArgumentException("Invalid direction " + dir);
};
}
/**
@@ -626,7 +611,7 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
* @return a list of Chunk objects
*/
public List<Chunk> getChunks() {
List<Chunk> res = new ArrayList<Chunk>();
List<Chunk> res = new ArrayList<>();
World w = getWorld();
int x1 = getLowerX() & ~0xf;
@@ -641,11 +626,11 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
return res;
}
/**
* Set all the blocks within the Cuboid to the given MaterialData, using a
* MassBlockUpdate object for fast updates.
*
* @param mat
/*
Set all the blocks within the Cuboid to the given MaterialData, using a
MassBlockUpdate object for fast updates.
@param mat
* the MaterialData to set
* @param mbu
* the MassBlockUpdate object
@@ -670,8 +655,9 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
*
* @see java.lang.Object#clone()
*/
@SuppressWarnings("MethodDoesntCallSuperMethod")
@Override
public Cuboid clone() throws CloneNotSupportedException {
public Cuboid clone() {
return new Cuboid(this);
}
@@ -685,7 +671,7 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
return "Cuboid: " + worldName + "," + x1 + "," + y1 + "," + z1 + "=>" + x2 + "," + y2 + "," + z2;
}
public class CuboidIterator implements Iterator<Block> {
public static class CuboidIterator implements Iterator<Block> {
private final World w;
private final int baseX;
private final int baseY;
@@ -744,28 +730,18 @@ public class Cuboid implements Iterable<Block>, Cloneable, ConfigurationSerializ
Unknown;
public CuboidDirection opposite() {
switch (this) {
case North:
return South;
case East:
return West;
case South:
return North;
case West:
return East;
case Horizontal:
return Vertical;
case Vertical:
return Horizontal;
case Up:
return Down;
case Down:
return Up;
case Both:
return Both;
default:
return Unknown;
}
return switch (this) {
case North -> South;
case East -> West;
case South -> North;
case West -> East;
case Horizontal -> Vertical;
case Vertical -> Horizontal;
case Up -> Down;
case Down -> Up;
case Both -> Both;
default -> Unknown;
};
}
}

View File

@@ -37,9 +37,9 @@ public abstract class DataPalette<T> implements Writable {
getPaletteId(defaultValue);
}
public abstract T readType(DataInputStream i) throws IOException;
public abstract T readType(DataInputStream i);
public abstract void writeType(T t, DataOutputStream o) throws IOException;
public abstract void writeType(T t, DataOutputStream o);
@Override
public void write(DataOutputStream o) throws IOException {

View File

@@ -23,6 +23,8 @@ import org.bukkit.Axis;
import org.bukkit.block.BlockFace;
import org.bukkit.util.Vector;
import java.util.Map;
/**
* Directions
*
@@ -44,68 +46,28 @@ public enum Direction {
private final CuboidDirection f;
public static Direction getDirection(BlockFace f) {
switch (f) {
case DOWN:
return D;
case EAST:
return E;
case EAST_NORTH_EAST:
return E;
case EAST_SOUTH_EAST:
return E;
case NORTH:
return N;
case NORTH_EAST:
return N;
case NORTH_NORTH_EAST:
return N;
case NORTH_NORTH_WEST:
return N;
case NORTH_WEST:
return N;
case SELF:
return U;
case SOUTH:
return S;
case SOUTH_EAST:
return S;
case SOUTH_SOUTH_EAST:
return S;
case SOUTH_SOUTH_WEST:
return S;
case SOUTH_WEST:
return S;
case UP:
return U;
case WEST:
return W;
case WEST_NORTH_WEST:
return W;
case WEST_SOUTH_WEST:
return W;
}
return switch (f) {
case DOWN -> D;
case EAST, EAST_SOUTH_EAST, EAST_NORTH_EAST -> E;
case NORTH, NORTH_WEST, NORTH_NORTH_WEST, NORTH_NORTH_EAST, NORTH_EAST -> N;
case SELF, UP -> U;
case SOUTH, SOUTH_WEST, SOUTH_SOUTH_WEST, SOUTH_SOUTH_EAST, SOUTH_EAST -> S;
case WEST, WEST_SOUTH_WEST, WEST_NORTH_WEST -> W;
};
return D;
}
@Override
public String toString() {
switch (this) {
case D:
return "Down";
case E:
return "East";
case N:
return "North";
case S:
return "South";
case U:
return "Up";
case W:
return "West";
}
return switch (this) {
case D -> "Down";
case E -> "East";
case N -> "North";
case S -> "South";
case U -> "Up";
case W -> "West";
};
return "?";
}
public boolean isVertical() {
@@ -185,9 +147,10 @@ public enum Direction {
public Vector angle(Vector initial, Direction d) {
calculatePermutations();
for (GBiset<Direction, Direction> i : permute.keySet()) {
for (Map.Entry<GBiset<Direction, Direction>, DOP> entry : permute.entrySet()) {
GBiset<Direction, Direction> i = entry.getKey();
if (i.getA().equals(this) && i.getB().equals(d)) {
return permute.get(i).op(initial);
return entry.getValue().op(initial);
}
}
@@ -310,11 +273,11 @@ public enum Direction {
return;
}
permute = new KMap<GBiset<Direction, Direction>, DOP>();
permute = new KMap<>();
for (Direction i : udnews()) {
for (Direction j : udnews()) {
GBiset<Direction, Direction> b = new GBiset<Direction, Direction>(i, j);
GBiset<Direction, Direction> b = new GBiset<>(i, j);
if (i.equals(j)) {
permute.put(b, new DOP("DIRECT") {
@@ -394,40 +357,23 @@ public enum Direction {
}
public BlockFace getFace() {
switch (this) {
case D:
return BlockFace.DOWN;
case E:
return BlockFace.EAST;
case N:
return BlockFace.NORTH;
case S:
return BlockFace.SOUTH;
case U:
return BlockFace.UP;
case W:
return BlockFace.WEST;
}
return switch (this) {
case D -> BlockFace.DOWN;
case E -> BlockFace.EAST;
case N -> BlockFace.NORTH;
case S -> BlockFace.SOUTH;
case U -> BlockFace.UP;
case W -> BlockFace.WEST;
};
return null;
}
public Axis getAxis() {
switch (this) {
case D:
return Axis.Y;
case E:
return Axis.X;
case N:
return Axis.Z;
case S:
return Axis.Z;
case U:
return Axis.Y;
case W:
return Axis.X;
}
return switch (this) {
case D, U -> Axis.Y;
case E, W -> Axis.X;
case N, S -> Axis.Z;
};
return null;
}
}

View File

@@ -25,9 +25,7 @@ import java.util.Arrays;
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;
}

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.util;
import org.bukkit.inventory.ItemStack;
@SuppressWarnings("ALL")
public interface Element {
MaterialBlock getMaterial();

View File

@@ -64,10 +64,11 @@ public class FakeWorld implements World {
}
@Override
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) {
}
@NotNull
@Override
public Set<String> getListeningPluginChannels() {
@@ -75,35 +76,38 @@ public class FakeWorld implements World {
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
}
@NotNull
@Override
public List<MetadataValue> getMetadata(String metadataKey) {
public List<MetadataValue> getMetadata(@NotNull String metadataKey) {
return null;
}
@Override
public boolean hasMetadata(String metadataKey) {
public boolean hasMetadata(@NotNull String metadataKey) {
return false;
}
@Override
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) {
}
@NotNull
@Override
public Block getBlockAt(int x, int y, int z) {
return null;
}
@NotNull
@Override
public Block getBlockAt(Location location) {
public Block getBlockAt(@NotNull Location location) {
return null;
}
@@ -115,71 +119,79 @@ public class FakeWorld implements World {
}
@Override
public int getHighestBlockYAt(Location location) {
public int getHighestBlockYAt(@NotNull Location location) {
return 0;
}
@NotNull
@Override
public Block getHighestBlockAt(int x, int z) {
return null;
}
@NotNull
@Override
public Block getHighestBlockAt(Location location) {
public Block getHighestBlockAt(@NotNull Location location) {
return null;
}
@Override
public int getHighestBlockYAt(int x, int z, HeightMap heightMap) {
public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap) {
return 0;
}
@Override
public int getHighestBlockYAt(Location location, HeightMap heightMap) {
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap) {
return 0;
}
@NotNull
@Override
public Block getHighestBlockAt(int x, int z, HeightMap heightMap) {
public Block getHighestBlockAt(int x, int z, @NotNull HeightMap heightMap) {
return null;
}
@NotNull
@Override
public Block getHighestBlockAt(Location location, HeightMap heightMap) {
public Block getHighestBlockAt(@NotNull Location location, @NotNull HeightMap heightMap) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(int x, int z) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(Location location) {
public Chunk getChunkAt(@NotNull Location location) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(@NotNull Block block) {
return null;
}
@Override
public Chunk getChunkAt(Block block) {
return null;
}
@Override
public boolean isChunkLoaded(Chunk chunk) {
public boolean isChunkLoaded(@NotNull Chunk chunk) {
return false;
}
@NotNull
@Override
public Chunk[] getLoadedChunks() {
@@ -187,7 +199,7 @@ public class FakeWorld implements World {
}
@Override
public void loadChunk(Chunk chunk) {
public void loadChunk(@NotNull Chunk chunk) {
}
@@ -221,7 +233,7 @@ public class FakeWorld implements World {
}
@Override
public boolean unloadChunk(Chunk chunk) {
public boolean unloadChunk(@NotNull Chunk chunk) {
return false;
}
@@ -267,6 +279,7 @@ public class FakeWorld implements World {
}
@NotNull
@Override
public Collection<Chunk> getForceLoadedChunks() {
@@ -274,36 +287,39 @@ public class FakeWorld implements World {
}
@Override
public boolean addPluginChunkTicket(int x, int z, Plugin plugin) {
public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return false;
}
@Override
public boolean removePluginChunkTicket(int x, int z, Plugin plugin) {
public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return false;
}
@Override
public void removePluginChunkTickets(Plugin plugin) {
public void removePluginChunkTickets(@NotNull Plugin plugin) {
}
@NotNull
@Override
public Collection<Plugin> getPluginChunkTickets(int x, int z) {
return null;
}
@NotNull
@Override
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
return null;
}
@NotNull
@Override
public Item dropItem(Location location, ItemStack item) {
public Item dropItem(@NotNull Location location, @NotNull ItemStack item) {
return null;
}
@@ -314,8 +330,9 @@ public class FakeWorld implements World {
return null;
}
@NotNull
@Override
public Item dropItemNaturally(Location location, ItemStack item) {
public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item) {
return null;
}
@@ -326,168 +343,187 @@ public class FakeWorld implements World {
return null;
}
@NotNull
@Override
public Arrow spawnArrow(Location location, Vector direction, float speed, float spread) {
public Arrow spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread) {
return null;
}
@NotNull
@Override
public <T extends AbstractArrow> T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
return null;
}
@Override
public <T extends AbstractArrow> T spawnArrow(Location location, Vector direction, float speed, float spread, Class<T> clazz) {
return null;
}
@Override
public boolean generateTree(Location location, TreeType type) {
public boolean generateTree(@NotNull Location location, @NotNull TreeType type) {
return false;
}
@Override
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate) {
return false;
}
@NotNull
@Override
public Entity spawnEntity(Location loc, EntityType type) {
public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type) {
return null;
}
@NotNull
@Override
public LightningStrike strikeLightning(Location loc) {
public LightningStrike strikeLightning(@NotNull Location loc) {
return null;
}
@NotNull
@Override
public LightningStrike strikeLightningEffect(Location loc) {
public LightningStrike strikeLightningEffect(@NotNull Location loc) {
return null;
}
@NotNull
@Override
public List<Entity> getEntities() {
return null;
}
@NotNull
@Override
public List<LivingEntity> getLivingEntities() {
return null;
}
@NotNull
@SuppressWarnings({"RedundantSuppression", "unchecked"})
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(@SuppressWarnings("unchecked") Class<T>... classes) {
public <T extends Entity> Collection<T> getEntitiesByClass(@NotNull @SuppressWarnings("unchecked") Class<T>... classes) {
return null;
}
@NotNull
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> cls) {
public <T extends Entity> Collection<T> getEntitiesByClass(@NotNull Class<T> cls) {
return null;
}
@NotNull
@Override
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
public Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes) {
return null;
}
@NotNull
@Override
public List<Player> getPlayers() {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z) {
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, Predicate<Entity> filter) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox, Predicate<Entity> filter) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z, Predicate<Entity> filter) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, Predicate<Entity> filter) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate<Entity> filter) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
return null;
}
@Override
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<Entity> filter) {
public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<Entity> filter) {
return null;
}
@NotNull
@Override
public String getName() {
return worldName;
}
@NotNull
@Override
public UUID getUID() {
return null;
}
@NotNull
@Override
public Location getSpawnLocation() {
@@ -495,7 +531,7 @@ public class FakeWorld implements World {
}
@Override
public boolean setSpawnLocation(Location location) {
public boolean setSpawnLocation(@NotNull Location location) {
return false;
}
@@ -622,29 +658,30 @@ public class FakeWorld implements World {
}
@Override
public boolean createExplosion(Location loc, float power) {
public boolean createExplosion(@NotNull Location loc, float power) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) {
return false;
}
@NotNull
@Override
public Environment getEnvironment() {
@@ -679,62 +716,69 @@ public class FakeWorld implements World {
}
@NotNull
@Override
public List<BlockPopulator> getPopulators() {
return null;
}
@NotNull
@Override
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException {
return null;
}
@Override
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException {
return null;
}
@Override
public void playEffect(Location location, Effect effect, int data) {
public void playEffect(@NotNull Location location, @NotNull Effect effect, int data) {
}
@Override
public void playEffect(Location location, Effect effect, int data, int radius) {
public void playEffect(@NotNull Location location, @NotNull Effect effect, int data, int radius) {
}
@Override
public <T> void playEffect(Location location, Effect effect, T data) {
public <T> void playEffect(@NotNull Location location, @NotNull Effect effect, T data) {
}
@Override
public <T> void playEffect(Location location, Effect effect, T data, int radius) {
public <T> void playEffect(@NotNull Location location, @NotNull Effect effect, T data, int radius) {
}
@NotNull
@Override
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp) {
@@ -758,12 +802,14 @@ public class FakeWorld implements World {
return false;
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
return null;
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
@@ -771,12 +817,12 @@ public class FakeWorld implements World {
}
@Override
public void setBiome(int x, int z, Biome bio) {
public void setBiome(int x, int z, @NotNull Biome bio) {
}
@Override
public void setBiome(int x, int y, int z, Biome bio) {
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
}
@@ -844,16 +890,18 @@ public class FakeWorld implements World {
}
@Override
public void setDifficulty(Difficulty difficulty) {
public void setDifficulty(@NotNull Difficulty difficulty) {
}
@NotNull
@Override
public Difficulty getDifficulty() {
return null;
}
@NotNull
@Override
public File getWorldFolder() {
@@ -994,25 +1042,26 @@ public class FakeWorld implements World {
}
@Override
public void playSound(Location location, Sound sound, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch) {
}
@Override
public void playSound(Location location, String sound, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch) {
}
@Override
public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
}
@Override
public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) {
}
@NotNull
@Override
public String[] getGameRules() {
@@ -1026,35 +1075,36 @@ public class FakeWorld implements World {
}
@Override
public boolean setGameRuleValue(String rule, String value) {
public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) {
return false;
}
@Override
public boolean isGameRule(String rule) {
public boolean isGameRule(@NotNull String rule) {
return false;
}
@Override
public <T> T getGameRuleValue(GameRule<T> rule) {
public <T> T getGameRuleValue(@NotNull GameRule<T> rule) {
return null;
}
@Override
public <T> T getGameRuleDefault(GameRule<T> rule) {
public <T> T getGameRuleDefault(@NotNull GameRule<T> rule) {
return null;
}
@Override
public <T> boolean setGameRule(GameRule<T> rule, T newValue) {
public <T> boolean setGameRule(@NotNull GameRule<T> rule, @NotNull T newValue) {
return false;
}
@NotNull
@Override
public WorldBorder getWorldBorder() {
@@ -1062,77 +1112,77 @@ public class FakeWorld implements World {
}
@Override
public void spawnParticle(Particle particle, Location location, int count) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) {
}
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
}
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
}
@Override
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) {
public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
return null;
}
@@ -1141,16 +1191,18 @@ public class FakeWorld implements World {
return 0;
}
@NotNull
@Override
public Spigot spigot() {
return null;
}
@Override
public Raid locateNearestRaid(Location location, int radius) {
public Raid locateNearestRaid(@NotNull Location location, int radius) {
return null;
}
@NotNull
@Override
public List<Raid> getRaids() {
return null;

View File

@@ -36,7 +36,7 @@ public class Form {
private static final NavigableMap<BigInteger, String> MAP;
static {
MAP = new TreeMap<BigInteger, String>();
MAP = new TreeMap<>();
for (int i = 0; i < NAMES.length; i++) {
MAP.put(THOUSAND.pow(i + 1), NAMES[i]);
}
@@ -54,7 +54,6 @@ public class Form {
* @param smx the text
* @param viewport the viewport length
* @param time the timeline value
* @return
*/
public static String scroll(String smx, int viewport, long time) {
String src = Form.repeat(" ", viewport) + smx + Form.repeat(" ", viewport);
@@ -73,19 +72,19 @@ public class Form {
* @return the capitalized string
*/
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();
}
/**
@@ -95,10 +94,10 @@ public class Form {
* @return the capitalized string
*/
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);
@@ -223,7 +222,6 @@ public class Form {
/**
* Returns a fancy duration up to Years
*
* @param rollingSequence
* @param duration the duration in ms
* @return the fancy duration
*/
@@ -341,72 +339,33 @@ public class Form {
} else {
int h = c.get(Calendar.HOUR);
h = h == 0 ? 12 : h;
String dow = "Error Day";
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY:
dow = "Sunday";
break;
case Calendar.MONDAY:
dow = "Monday";
break;
case Calendar.TUESDAY:
dow = "Tuesday";
break;
case Calendar.WEDNESDAY:
dow = "Wednesday";
break;
case Calendar.THURSDAY:
dow = "Thursday";
break;
case Calendar.FRIDAY:
dow = "Friday";
break;
case Calendar.SATURDAY:
dow = "Saturday";
break;
}
String dow = switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY -> "Sunday";
case Calendar.MONDAY -> "Monday";
case Calendar.TUESDAY -> "Tuesday";
case Calendar.WEDNESDAY -> "Wednesday";
case Calendar.THURSDAY -> "Thursday";
case Calendar.FRIDAY -> "Friday";
case Calendar.SATURDAY -> "Saturday";
default -> "Error Day";
};
String monthName = "Error Month";
int month = c.get(Calendar.MONTH);
switch (month) {
case Calendar.JANUARY:
monthName = "Jan";
break;
case Calendar.FEBRUARY:
monthName = "Feb";
break;
case Calendar.MARCH:
monthName = "Mar";
break;
case Calendar.APRIL:
monthName = "Apr";
break;
case Calendar.MAY:
monthName = "May";
break;
case Calendar.JUNE:
monthName = "Jun";
break;
case Calendar.JULY:
monthName = "Jul";
break;
case Calendar.AUGUST:
monthName = "Aug";
break;
case Calendar.SEPTEMBER:
monthName = "Sep";
break;
case Calendar.OCTOBER:
monthName = "Oct";
break;
case Calendar.NOVEMBER:
monthName = "Nov";
break;
case Calendar.DECEMBER:
monthName = "Dec";
break;
case Calendar.JANUARY -> monthName = "Jan";
case Calendar.FEBRUARY -> monthName = "Feb";
case Calendar.MARCH -> monthName = "Mar";
case Calendar.APRIL -> monthName = "Apr";
case Calendar.MAY -> monthName = "May";
case Calendar.JUNE -> monthName = "Jun";
case Calendar.JULY -> monthName = "Jul";
case Calendar.AUGUST -> monthName = "Aug";
case Calendar.SEPTEMBER -> monthName = "Sep";
case Calendar.OCTOBER -> monthName = "Oct";
case Calendar.NOVEMBER -> monthName = "Nov";
case Calendar.DECEMBER -> monthName = "Dec";
}
int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
@@ -417,72 +376,33 @@ public class Form {
} else {
int h = c.get(Calendar.HOUR);
h = h == 0 ? 12 : h;
String dow = "Error Day";
switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY:
dow = "Sunday";
break;
case Calendar.MONDAY:
dow = "Monday";
break;
case Calendar.TUESDAY:
dow = "Tuesday";
break;
case Calendar.WEDNESDAY:
dow = "Wednesday";
break;
case Calendar.THURSDAY:
dow = "Thursday";
break;
case Calendar.FRIDAY:
dow = "Friday";
break;
case Calendar.SATURDAY:
dow = "Saturday";
break;
}
String dow = switch (c.get(Calendar.DAY_OF_WEEK)) {
case Calendar.SUNDAY -> "Sunday";
case Calendar.MONDAY -> "Monday";
case Calendar.TUESDAY -> "Tuesday";
case Calendar.WEDNESDAY -> "Wednesday";
case Calendar.THURSDAY -> "Thursday";
case Calendar.FRIDAY -> "Friday";
case Calendar.SATURDAY -> "Saturday";
default -> "Error Day";
};
String monthName = "Error Month";
int month = c.get(Calendar.MONTH);
switch (month) {
case Calendar.JANUARY:
monthName = "Jan";
break;
case Calendar.FEBRUARY:
monthName = "Feb";
break;
case Calendar.MARCH:
monthName = "Mar";
break;
case Calendar.APRIL:
monthName = "Apr";
break;
case Calendar.MAY:
monthName = "May";
break;
case Calendar.JUNE:
monthName = "Jun";
break;
case Calendar.JULY:
monthName = "Jul";
break;
case Calendar.AUGUST:
monthName = "Aug";
break;
case Calendar.SEPTEMBER:
monthName = "Sep";
break;
case Calendar.OCTOBER:
monthName = "Oct";
break;
case Calendar.NOVEMBER:
monthName = "Nov";
break;
case Calendar.DECEMBER:
monthName = "Dec";
break;
case Calendar.JANUARY -> monthName = "Jan";
case Calendar.FEBRUARY -> monthName = "Feb";
case Calendar.MARCH -> monthName = "Mar";
case Calendar.APRIL -> monthName = "Apr";
case Calendar.MAY -> monthName = "May";
case Calendar.JUNE -> monthName = "Jun";
case Calendar.JULY -> monthName = "Jul";
case Calendar.AUGUST -> monthName = "Aug";
case Calendar.SEPTEMBER -> monthName = "Sep";
case Calendar.OCTOBER -> monthName = "Oct";
case Calendar.NOVEMBER -> monthName = "Nov";
case Calendar.DECEMBER -> monthName = "Dec";
}
int dayOfMonth = c.get(Calendar.DAY_OF_MONTH);
@@ -502,15 +422,10 @@ public class Form {
*/
public static String numberSuffix(int i) {
String[] sufixes = new String[]{"th", "st", "nd", "rd", "th", "th", "th", "th", "th", "th"};
switch (i % 100) {
case 11:
case 12:
case 13:
return i + "th";
default:
return i + sufixes[i % 10];
}
return switch (i % 100) {
case 11, 12, 13 -> i + "th";
default -> i + sufixes[i % 10];
};
}
/**
@@ -722,7 +637,7 @@ public class Form {
* @return the string
*/
public static String ofSize(long s, int div) {
Double d = (double) s;
double d = (double) s;
String sub = "Bytes";
if (d > div - 1) {
@@ -763,7 +678,7 @@ public class Form {
* @return the string
*/
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) {
@@ -804,7 +719,7 @@ public class Form {
if (neg) {
s = -s;
}
Double d = (double) s;
double d = (double) s;
String sub = "Grams";
if (d > div - 1) {
@@ -853,21 +768,21 @@ public class Form {
* @return the string representation
*/
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("-")) {
codeName = codeName.substring(1);
if (codeName.toString().startsWith("-")) {
codeName = new StringBuilder(codeName.substring(1));
}
return codeName;
return codeName.toString();
}
/**
@@ -887,7 +802,6 @@ public class Form {
/**
* Get a formatted representation of the memory given in kilobytes
*
* @param mb the kilobytes
* @return the string representation with suffixes
*/
public static String memx(long kb) {
@@ -1121,7 +1035,6 @@ public class Form {
/**
* nanoseconds to seconds (double)
*
* @param ms the nanoseconds
* @return a formatted string to nanoseconds
*/
public static String nsMs(long ns) {
@@ -1131,7 +1044,6 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param ms the nanoseconds
* @param p number of decimal points
* @return a formatted string to nanoseconds
*/
@@ -1142,7 +1054,6 @@ public class Form {
/**
* nanoseconds to seconds (double) custom decimals
*
* @param ms the nanoseconds
* @param p number of decimal points
* @return a formatted string to nanoseconds
*/
@@ -1157,7 +1068,7 @@ public class Form {
* @return the numerals
*/
public static String toRoman(int num) {
LinkedHashMap<String, Integer> roman_numerals = new LinkedHashMap<String, Integer>();
LinkedHashMap<String, Integer> roman_numerals = new LinkedHashMap<>();
roman_numerals.put("M", 1000);
roman_numerals.put("CM", 900);
@@ -1173,16 +1084,16 @@ 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();
}
/**
@@ -1260,6 +1171,7 @@ public class Form {
* @param n the amount of times to repeat
* @return the repeated string
*/
@SuppressWarnings("StringRepeatCanBeUsed")
public static String repeat(String s, int n) {
if (s == null) {
return null;

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Function2<A, B, R> {
R apply(A a, B b);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Function3<A, B, C, R> {
R apply(A a, B b, C c);

View File

@@ -18,7 +18,6 @@
package com.volmit.iris.util;
@SuppressWarnings("hiding")
@FunctionalInterface
public interface Function4<A, B, C, D, R> {
R apply(A a, B b, C c, D d);

View File

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

View File

@@ -36,7 +36,7 @@ public abstract class GListAdapter<FROM, TO> {
* @return the to list
*/
public List<TO> adapt(List<FROM> from) {
List<TO> adapted = new KList<TO>();
List<TO> adapted = new KList<>();
for (FROM i : from) {
TO t = onAdapt(i);

View File

@@ -31,7 +31,7 @@ public class GroupedExecutor {
public GroupedExecutor(int threadLimit, int priority, String name) {
xc = 1;
mirror = new KMap<String, Integer>();
mirror = new KMap<>();
if (threadLimit == 1) {
service = Executors.newSingleThreadExecutor((r) ->
@@ -43,14 +43,11 @@ public class GroupedExecutor {
return t;
});
} else if (threadLimit > 1) {
final ForkJoinWorkerThreadFactory factory = new ForkJoinWorkerThreadFactory() {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName(name + " " + xc++);
worker.setPriority(priority);
return worker;
}
final ForkJoinWorkerThreadFactory factory = pool -> {
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName(name + " " + xc++);
worker.setPriority(priority);
return worker;
};
service = new ForkJoinPool(threadLimit, factory, null, false);

View File

@@ -81,7 +81,6 @@ public class HTTP {
* @param string An HTTP header string.
* @return A JSONObject containing the elements and attributes of the XML
* string.
* @throws JSONException
*/
public static JSONObject toJSONObject(String string) throws JSONException {
JSONObject jo = new JSONObject();

View File

@@ -41,7 +41,6 @@ public class HTTPTokener extends JSONTokener {
* Get the next token or string. This is used in parsing HTTP headers.
*
* @return A String.
* @throws JSONException
*/
public String nextToken() throws JSONException {
char c;

View File

@@ -42,7 +42,7 @@ import java.io.File;
import java.util.*;
import java.util.function.Predicate;
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "ClassCanBeRecord", "unchecked"})
public class HeightedFakeWorld implements World {
private final int height;
@@ -51,10 +51,11 @@ public class HeightedFakeWorld implements World {
}
@Override
public void sendPluginMessage(Plugin source, String channel, byte[] message) {
public void sendPluginMessage(@NotNull Plugin source, @NotNull String channel, @NotNull byte[] message) {
}
@NotNull
@Override
public Set<String> getListeningPluginChannels() {
@@ -62,35 +63,38 @@ public class HeightedFakeWorld implements World {
}
@Override
public void setMetadata(String metadataKey, MetadataValue newMetadataValue) {
public void setMetadata(@NotNull String metadataKey, @NotNull MetadataValue newMetadataValue) {
}
@NotNull
@Override
public List<MetadataValue> getMetadata(String metadataKey) {
public List<MetadataValue> getMetadata(@NotNull String metadataKey) {
return null;
}
@Override
public boolean hasMetadata(String metadataKey) {
public boolean hasMetadata(@NotNull String metadataKey) {
return false;
}
@Override
public void removeMetadata(String metadataKey, Plugin owningPlugin) {
public void removeMetadata(@NotNull String metadataKey, @NotNull Plugin owningPlugin) {
}
@NotNull
@Override
public Block getBlockAt(int x, int y, int z) {
return null;
}
@NotNull
@Override
public Block getBlockAt(Location location) {
public Block getBlockAt(@NotNull Location location) {
return null;
}
@@ -102,71 +106,79 @@ public class HeightedFakeWorld implements World {
}
@Override
public int getHighestBlockYAt(Location location) {
public int getHighestBlockYAt(@NotNull Location location) {
return 0;
}
@NotNull
@Override
public Block getHighestBlockAt(int x, int z) {
return null;
}
@NotNull
@Override
public Block getHighestBlockAt(Location location) {
public Block getHighestBlockAt(@NotNull Location location) {
return null;
}
@Override
public int getHighestBlockYAt(int x, int z, HeightMap heightMap) {
public int getHighestBlockYAt(int x, int z, @NotNull HeightMap heightMap) {
return 0;
}
@Override
public int getHighestBlockYAt(Location location, HeightMap heightMap) {
public int getHighestBlockYAt(@NotNull Location location, @NotNull HeightMap heightMap) {
return 0;
}
@NotNull
@Override
public Block getHighestBlockAt(int x, int z, HeightMap heightMap) {
public Block getHighestBlockAt(int x, int z, @NotNull HeightMap heightMap) {
return null;
}
@NotNull
@Override
public Block getHighestBlockAt(Location location, HeightMap heightMap) {
public Block getHighestBlockAt(@NotNull Location location, @NotNull HeightMap heightMap) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(int x, int z) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(Location location) {
public Chunk getChunkAt(@NotNull Location location) {
return null;
}
@NotNull
@Override
public Chunk getChunkAt(@NotNull Block block) {
return null;
}
@Override
public Chunk getChunkAt(Block block) {
return null;
}
@Override
public boolean isChunkLoaded(Chunk chunk) {
public boolean isChunkLoaded(@NotNull Chunk chunk) {
return false;
}
@NotNull
@Override
public Chunk[] getLoadedChunks() {
@@ -174,7 +186,7 @@ public class HeightedFakeWorld implements World {
}
@Override
public void loadChunk(Chunk chunk) {
public void loadChunk(@NotNull Chunk chunk) {
}
@@ -208,7 +220,7 @@ public class HeightedFakeWorld implements World {
}
@Override
public boolean unloadChunk(Chunk chunk) {
public boolean unloadChunk(@NotNull Chunk chunk) {
return false;
}
@@ -254,6 +266,7 @@ public class HeightedFakeWorld implements World {
}
@NotNull
@Override
public Collection<Chunk> getForceLoadedChunks() {
@@ -261,36 +274,39 @@ public class HeightedFakeWorld implements World {
}
@Override
public boolean addPluginChunkTicket(int x, int z, Plugin plugin) {
public boolean addPluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return false;
}
@Override
public boolean removePluginChunkTicket(int x, int z, Plugin plugin) {
public boolean removePluginChunkTicket(int x, int z, @NotNull Plugin plugin) {
return false;
}
@Override
public void removePluginChunkTickets(Plugin plugin) {
public void removePluginChunkTickets(@NotNull Plugin plugin) {
}
@NotNull
@Override
public Collection<Plugin> getPluginChunkTickets(int x, int z) {
return null;
}
@NotNull
@Override
public Map<Plugin, Collection<Chunk>> getPluginChunkTickets() {
return null;
}
@NotNull
@Override
public Item dropItem(Location location, ItemStack item) {
public Item dropItem(@NotNull Location location, @NotNull ItemStack item) {
return null;
}
@@ -301,8 +317,9 @@ public class HeightedFakeWorld implements World {
return null;
}
@NotNull
@Override
public Item dropItemNaturally(Location location, ItemStack item) {
public Item dropItemNaturally(@NotNull Location location, @NotNull ItemStack item) {
return null;
}
@@ -313,168 +330,186 @@ public class HeightedFakeWorld implements World {
return null;
}
@NotNull
@Override
public Arrow spawnArrow(Location location, Vector direction, float speed, float spread) {
public Arrow spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread) {
return null;
}
@NotNull
@Override
public <T extends AbstractArrow> T spawnArrow(@NotNull Location location, @NotNull Vector direction, float speed, float spread, @NotNull Class<T> clazz) {
return null;
}
@Override
public <T extends AbstractArrow> T spawnArrow(Location location, Vector direction, float speed, float spread, Class<T> clazz) {
return null;
}
@Override
public boolean generateTree(Location location, TreeType type) {
public boolean generateTree(@NotNull Location location, @NotNull TreeType type) {
return false;
}
@Override
public boolean generateTree(Location loc, TreeType type, BlockChangeDelegate delegate) {
public boolean generateTree(@NotNull Location loc, @NotNull TreeType type, @NotNull BlockChangeDelegate delegate) {
return false;
}
@NotNull
@Override
public Entity spawnEntity(Location loc, EntityType type) {
public Entity spawnEntity(@NotNull Location loc, @NotNull EntityType type) {
return null;
}
@NotNull
@Override
public LightningStrike strikeLightning(Location loc) {
public LightningStrike strikeLightning(@NotNull Location loc) {
return null;
}
@NotNull
@Override
public LightningStrike strikeLightningEffect(Location loc) {
public LightningStrike strikeLightningEffect(@NotNull Location loc) {
return null;
}
@NotNull
@Override
public List<Entity> getEntities() {
return null;
}
@NotNull
@Override
public List<LivingEntity> getLivingEntities() {
return null;
}
@NotNull
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(@SuppressWarnings("unchecked") Class<T>... classes) {
public <T extends Entity> Collection<T> getEntitiesByClass(@NotNull Class<T>... classes) {
return null;
}
@NotNull
@Override
public <T extends Entity> Collection<T> getEntitiesByClass(Class<T> cls) {
public <T extends Entity> Collection<T> getEntitiesByClass(@NotNull Class<T> cls) {
return null;
}
@NotNull
@Override
public Collection<Entity> getEntitiesByClasses(Class<?>... classes) {
public Collection<Entity> getEntitiesByClasses(@NotNull Class<?>... classes) {
return null;
}
@NotNull
@Override
public List<Player> getPlayers() {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z) {
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull Location location, double x, double y, double z, Predicate<Entity> filter) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox) {
return null;
}
@NotNull
@Override
public Collection<Entity> getNearbyEntities(@NotNull BoundingBox boundingBox, Predicate<Entity> filter) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(Location location, double x, double y, double z, Predicate<Entity> filter) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize) {
return null;
}
@Override
public Collection<Entity> getNearbyEntities(BoundingBox boundingBox, Predicate<Entity> filter) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, Predicate<Entity> filter) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance) {
public RayTraceResult rayTraceEntities(@NotNull Location start, @NotNull Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, Predicate<Entity> filter) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode) {
return null;
}
@Override
public RayTraceResult rayTraceEntities(Location start, Vector direction, double maxDistance, double raySize, Predicate<Entity> filter) {
public RayTraceResult rayTraceBlocks(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode) {
return null;
}
@Override
public RayTraceResult rayTraceBlocks(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks) {
return null;
}
@Override
public RayTraceResult rayTrace(Location start, Vector direction, double maxDistance, FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<Entity> filter) {
public RayTraceResult rayTrace(@NotNull Location start, @NotNull Vector direction, double maxDistance, @NotNull FluidCollisionMode fluidCollisionMode, boolean ignorePassableBlocks, double raySize, Predicate<Entity> filter) {
return null;
}
@NotNull
@Override
public String getName() {
return null;
}
@NotNull
@Override
public UUID getUID() {
return null;
}
@NotNull
@Override
public Location getSpawnLocation() {
@@ -482,7 +517,7 @@ public class HeightedFakeWorld implements World {
}
@Override
public boolean setSpawnLocation(Location location) {
public boolean setSpawnLocation(@NotNull Location location) {
return false;
}
@@ -609,29 +644,30 @@ public class HeightedFakeWorld implements World {
}
@Override
public boolean createExplosion(Location loc, float power) {
public boolean createExplosion(@NotNull Location loc, float power) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks) {
return false;
}
@Override
public boolean createExplosion(Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) {
public boolean createExplosion(@NotNull Location loc, float power, boolean setFire, boolean breakBlocks, Entity source) {
return false;
}
@NotNull
@Override
public Environment getEnvironment() {
@@ -666,62 +702,69 @@ public class HeightedFakeWorld implements World {
}
@NotNull
@Override
public List<BlockPopulator> getPopulators() {
return null;
}
@NotNull
@Override
public <T extends Entity> T spawn(Location location, Class<T> clazz) throws IllegalArgumentException {
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public <T extends Entity> T spawn(@NotNull Location location, @NotNull Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull MaterialData data) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull BlockData data) throws IllegalArgumentException {
return null;
}
@NotNull
@Override
public FallingBlock spawnFallingBlock(@NotNull Location location, @NotNull Material material, byte data) throws IllegalArgumentException {
return null;
}
@Override
public <T extends Entity> T spawn(Location location, Class<T> clazz, Consumer<T> function) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, MaterialData data) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, BlockData data) throws IllegalArgumentException {
return null;
}
@Override
public FallingBlock spawnFallingBlock(Location location, Material material, byte data) throws IllegalArgumentException {
return null;
}
@Override
public void playEffect(Location location, Effect effect, int data) {
public void playEffect(@NotNull Location location, @NotNull Effect effect, int data) {
}
@Override
public void playEffect(Location location, Effect effect, int data, int radius) {
public void playEffect(@NotNull Location location, @NotNull Effect effect, int data, int radius) {
}
@Override
public <T> void playEffect(Location location, Effect effect, T data) {
public <T> void playEffect(@NotNull Location location, @NotNull Effect effect, T data) {
}
@Override
public <T> void playEffect(Location location, Effect effect, T data, int radius) {
public <T> void playEffect(@NotNull Location location, @NotNull Effect effect, T data, int radius) {
}
@NotNull
@Override
public ChunkSnapshot getEmptyChunkSnapshot(int x, int z, boolean includeBiome, boolean includeBiomeTemp) {
@@ -745,12 +788,14 @@ public class HeightedFakeWorld implements World {
return false;
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
return null;
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
@@ -758,12 +803,12 @@ public class HeightedFakeWorld implements World {
}
@Override
public void setBiome(int x, int z, Biome bio) {
public void setBiome(int x, int z, @NotNull Biome bio) {
}
@Override
public void setBiome(int x, int y, int z, Biome bio) {
public void setBiome(int x, int y, int z, @NotNull Biome bio) {
}
@@ -831,16 +876,18 @@ public class HeightedFakeWorld implements World {
}
@Override
public void setDifficulty(Difficulty difficulty) {
public void setDifficulty(@NotNull Difficulty difficulty) {
}
@NotNull
@Override
public Difficulty getDifficulty() {
return null;
}
@NotNull
@Override
public File getWorldFolder() {
@@ -981,25 +1028,26 @@ public class HeightedFakeWorld implements World {
}
@Override
public void playSound(Location location, Sound sound, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull Sound sound, float volume, float pitch) {
}
@Override
public void playSound(Location location, String sound, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull String sound, float volume, float pitch) {
}
@Override
public void playSound(Location location, Sound sound, SoundCategory category, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull Sound sound, @NotNull SoundCategory category, float volume, float pitch) {
}
@Override
public void playSound(Location location, String sound, SoundCategory category, float volume, float pitch) {
public void playSound(@NotNull Location location, @NotNull String sound, @NotNull SoundCategory category, float volume, float pitch) {
}
@NotNull
@Override
public String[] getGameRules() {
@@ -1013,35 +1061,36 @@ public class HeightedFakeWorld implements World {
}
@Override
public boolean setGameRuleValue(String rule, String value) {
public boolean setGameRuleValue(@NotNull String rule, @NotNull String value) {
return false;
}
@Override
public boolean isGameRule(String rule) {
public boolean isGameRule(@NotNull String rule) {
return false;
}
@Override
public <T> T getGameRuleValue(GameRule<T> rule) {
public <T> T getGameRuleValue(@NotNull GameRule<T> rule) {
return null;
}
@Override
public <T> T getGameRuleDefault(GameRule<T> rule) {
public <T> T getGameRuleDefault(@NotNull GameRule<T> rule) {
return null;
}
@Override
public <T> boolean setGameRule(GameRule<T> rule, T newValue) {
public <T> boolean setGameRule(@NotNull GameRule<T> rule, @NotNull T newValue) {
return false;
}
@NotNull
@Override
public WorldBorder getWorldBorder() {
@@ -1049,77 +1098,77 @@ public class HeightedFakeWorld implements World {
}
@Override
public void spawnParticle(Particle particle, Location location, int count) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, T data) {
}
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, T data) {
}
@Override
public void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
public void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra) {
}
@Override
public void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
public void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data) {
}
@Override
public <T> void spawnParticle(Particle particle, Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
public <T> void spawnParticle(@NotNull Particle particle, @NotNull Location location, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
}
@Override
public <T> void spawnParticle(Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
public <T> void spawnParticle(@NotNull Particle particle, double x, double y, double z, int count, double offsetX, double offsetY, double offsetZ, double extra, T data, boolean force) {
}
@Override
public Location locateNearestStructure(Location origin, StructureType structureType, int radius, boolean findUnexplored) {
public Location locateNearestStructure(@NotNull Location origin, @NotNull StructureType structureType, int radius, boolean findUnexplored) {
return null;
}
@@ -1128,16 +1177,18 @@ public class HeightedFakeWorld implements World {
return 0;
}
@NotNull
@Override
public Spigot spigot() {
return null;
}
@Override
public Raid locateNearestRaid(Location location, int radius) {
public Raid locateNearestRaid(@NotNull Location location, int radius) {
return null;
}
@NotNull
@Override
public List<Raid> getRaids() {
return null;

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.util;
import org.bukkit.event.Listener;
@SuppressWarnings("EmptyMethod")
public interface IController extends Listener {
String getName();

View File

@@ -29,6 +29,7 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@SuppressWarnings("ALL")
public class IO {
/**
* The Unix directory separator character.
@@ -68,7 +69,7 @@ public class IO {
IO.fullTransfer(gzi, boas, 256);
gzi.close();
return boas.toString(StandardCharsets.UTF_8);
return boas.toString();
}
public static byte[] sdecompress(String compressed) throws IOException {
@@ -131,7 +132,6 @@ public class IO {
*
* @param in the input
* @param out the output
* @param amount the buffer and size to use
* @return the actual transfered amount
* @throws IOException shit happens
*/
@@ -330,30 +330,30 @@ public class IO {
throw e;
}
BufferedReader bu = new BufferedReader(fr);
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();
}
/**
@@ -385,7 +385,6 @@ public class IO {
* @throws NullPointerException if source or destination is null
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @see #copyFileToDirectory
*/
public static void copyFile(File srcFile, File destFile) throws IOException {
copyFile(srcFile, destFile, true);
@@ -406,7 +405,6 @@ public class IO {
* @throws NullPointerException if source or destination is null
* @throws IOException if source or destination is invalid
* @throws IOException if an IO error occurs during copying
* @see #copyFileToDirectory
*/
public static void copyFile(File srcFile, File destFile, boolean preserveFileDate) throws IOException {
if (srcFile == null) {
@@ -415,7 +413,7 @@ public class IO {
if (destFile == null) {
throw new NullPointerException("Destination must not be null");
}
if (srcFile.exists() == false) {
if (!srcFile.exists()) {
throw new FileNotFoundException("Source '" + srcFile + "' does not exist");
}
if (srcFile.isDirectory()) {
@@ -424,12 +422,12 @@ public class IO {
if (srcFile.getCanonicalPath().equals(destFile.getCanonicalPath())) {
throw new IOException("Source '" + srcFile + "' and destination '" + destFile + "' are the same");
}
if (destFile.getParentFile() != null && destFile.getParentFile().exists() == false) {
if (destFile.getParentFile().mkdirs() == false) {
if (destFile.getParentFile() != null && !destFile.getParentFile().exists()) {
if (!destFile.getParentFile().mkdirs()) {
throw new IOException("Destination '" + destFile + "' directory cannot be created");
}
}
if (destFile.exists() && destFile.canWrite() == false) {
if (destFile.exists() && !destFile.canWrite()) {
throw new IOException("Destination '" + destFile + "' exists but is read-only");
}
doCopyFile(srcFile, destFile, preserveFileDate);
@@ -611,11 +609,9 @@ public class IO {
*
* @param input the <code>String</code> to convert
* @return the requested byte array
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs (never occurs)
* @deprecated Use {@link String#getBytes()}
*/
public static byte[] toByteArray(String input) throws IOException {
public static byte[] toByteArray(String input) {
return input.getBytes();
}
@@ -748,11 +744,9 @@ public class IO {
*
* @param input the byte array to read from
* @return the requested String
* @throws NullPointerException if the input is null
* @throws IOException if an I/O error occurs (never occurs)
* @deprecated Use {@link String#String(byte[])}
*/
public static String toString(byte[] input) throws IOException {
public static String toString(byte[] input) {
return new String(input);
}

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.util;
import com.volmit.iris.Iris;
import org.bukkit.block.Biome;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.jetbrains.annotations.NotNull;
public class InvertedBiomeGrid implements BiomeGrid {
private final BiomeGrid grid;
@@ -29,12 +30,14 @@ public class InvertedBiomeGrid implements BiomeGrid {
this.grid = real;
}
@NotNull
@SuppressWarnings("deprecation")
@Override
public Biome getBiome(int arg0, int arg1) {
return grid.getBiome(arg0, arg1);
}
@NotNull
@Override
public Biome getBiome(int arg0, int arg1, int arg2) {
if (!Iris.biome3d) {
@@ -46,12 +49,12 @@ public class InvertedBiomeGrid implements BiomeGrid {
@SuppressWarnings("deprecation")
@Override
public void setBiome(int arg0, int arg1, Biome arg2) {
public void setBiome(int arg0, int arg1, @NotNull Biome arg2) {
grid.setBiome(arg0, arg1, arg2);
}
@Override
public void setBiome(int arg0, int arg1, int arg2, Biome arg3) {
public void setBiome(int arg0, int arg1, int arg2, @NotNull Biome arg3) {
if (!Iris.biome3d) {
setBiome(arg0, arg2, arg3);
return;

View File

@@ -848,8 +848,6 @@ public class IrisInterpolation {
return getStarcast(x, z, h, 9D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.HERMITE_STARCAST_12)) {
return getStarcast(x, z, h, 12D, (xx, zz) -> getHermiteNoise((int) xx, (int) zz, h, n, 0D, 0D));
} else if (method.equals(InterpolationMethod.BICUBIC)) {
return getBicubicNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.BILINEAR_BEZIER)) {
return getBilinearBezierNoise(x, z, h, n);
} else if (method.equals(InterpolationMethod.BILINEAR_PARAMETRIC_2)) {

View File

@@ -47,7 +47,7 @@ public class IrisLock {
}
try {
lock.unlock();
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}

View File

@@ -75,30 +75,21 @@ public class IrisMathHelper {
if (var0 < var1) {
return var1;
}
if (var0 > var2) {
return var2;
}
return var0;
return Math.min(var0, var2);
}
public static float a(final float var0, final float var1, final float var2) {
if (var0 < var1) {
return var1;
}
if (var0 > var2) {
return var2;
}
return var0;
return Math.min(var0, var2);
}
public static double a(final double var0, final double var2, final double var4) {
if (var0 < var2) {
return var2;
}
if (var0 > var4) {
return var4;
}
return var0;
return Math.min(var0, var4);
}
public static double b(final double var0, final double var2, final double var4) {
@@ -118,7 +109,7 @@ public class IrisMathHelper {
if (var2 < 0.0) {
var2 = -var2;
}
return (var0 > var2) ? var0 : var2;
return Math.max(var0, var2);
}
public static int a(final int var0, final int var1) {
@@ -260,7 +251,7 @@ public class IrisMathHelper {
}
public static long c(final int var0, final int var1, final int var2) {
long var3 = (long) (var0 * 3129871) ^ var2 * 116129781L ^ (long) var1;
long var3 = (long) (var0 * 3129871L) ^ var2 * 116129781L ^ (long) var1;
var3 = var3 * var3 * 42317861L + var3 * 11L;
return var3 >> 16;
}
@@ -340,43 +331,37 @@ public class IrisMathHelper {
float var9 = 0.0f;
float var10 = 0.0f;
switch (var3) {
case 0: {
case 0 -> {
var8 = var2;
var9 = var7;
var10 = var5;
break;
}
case 1: {
case 1 -> {
var8 = var6;
var9 = var2;
var10 = var5;
break;
}
case 2: {
case 2 -> {
var8 = var5;
var9 = var2;
var10 = var7;
break;
}
case 3: {
case 3 -> {
var8 = var5;
var9 = var6;
var10 = var2;
break;
}
case 4: {
case 4 -> {
var8 = var7;
var9 = var5;
var10 = var2;
break;
}
case 5: {
case 5 -> {
var8 = var2;
var9 = var5;
var10 = var6;
break;
}
default: {
default -> {
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
}
}

View File

@@ -26,6 +26,7 @@ import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.Supplier;
@SuppressWarnings("ALL")
public class J {
private static int tid = 0;
private static final ExecutorService e = Executors.newCachedThreadPool(new ThreadFactory() {

View File

@@ -74,6 +74,7 @@ import java.util.Map;
* @author JSON.org
* @version 2015-07-22
*/
@SuppressWarnings("ALL")
public class JSONArray implements Iterable<Object> {
/**
@@ -870,6 +871,7 @@ public class JSONArray implements Iterable<Object> {
* @param other The other JSONArray
* @return true if they are equal
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean similar(Object other) {
if (!(other instanceof JSONArray)) {
return false;

View File

@@ -39,7 +39,6 @@ public class JSONML {
* @param ja The JSONArray that is containing the current tag or null if we
* are at the outermost level.
* @return A JSONArray if the value is the outermost tag, otherwise null.
* @throws JSONException
*/
private static Object parse(XMLTokener x, boolean arrayForm, JSONArray ja) throws JSONException {
String attribute;
@@ -231,7 +230,6 @@ public class JSONML {
*
* @param string The source string.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException
*/
public static JSONArray toJSONArray(String string) throws JSONException {
return toJSONArray(new XMLTokener(string));
@@ -248,7 +246,6 @@ public class JSONML {
*
* @param x An XMLTokener.
* @return A JSONArray containing the structured data from the XML string.
* @throws JSONException
*/
public static JSONArray toJSONArray(XMLTokener x) throws JSONException {
return (JSONArray) parse(x, true, null);
@@ -266,7 +263,6 @@ public class JSONML {
*
* @param x An XMLTokener of the XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
*/
public static JSONObject toJSONObject(XMLTokener x) throws JSONException {
return (JSONObject) parse(x, false, null);
@@ -284,7 +280,6 @@ public class JSONML {
*
* @param string The XML source text.
* @return A JSONObject containing the structured data from the XML string.
* @throws JSONException
*/
public static JSONObject toJSONObject(String string) throws JSONException {
return toJSONObject(new XMLTokener(string));
@@ -295,7 +290,6 @@ public class JSONML {
*
* @param ja A JSONArray.
* @return An XML string.
* @throws JSONException
*/
public static String toString(JSONArray ja) throws JSONException {
int i;
@@ -346,7 +340,6 @@ public class JSONML {
length = ja.length();
if (i >= length) {
sb.append('/');
sb.append('>');
} else {
sb.append('>');
do {
@@ -367,8 +360,8 @@ public class JSONML {
sb.append('<');
sb.append('/');
sb.append(tagName);
sb.append('>');
}
sb.append('>');
return sb.toString();
}
@@ -380,7 +373,6 @@ public class JSONML {
*
* @param jo A JSONObject.
* @return An XML string.
* @throws JSONException
*/
public static String toString(JSONObject jo) throws JSONException {
StringBuilder sb = new StringBuilder();
@@ -428,7 +420,6 @@ public class JSONML {
ja = jo.optJSONArray("childNodes");
if (ja == null) {
sb.append('/');
sb.append('>');
} else {
sb.append('>');
length = ja.length();
@@ -449,8 +440,8 @@ public class JSONML {
sb.append('<');
sb.append('/');
sb.append(tagName);
sb.append('>');
}
sb.append('>');
return sb.toString();
}
}

View File

@@ -79,6 +79,7 @@ import java.util.Map.Entry;
* @author JSON.org
* @version 2015-07-22
*/
@SuppressWarnings("ALL")
public class JSONObject {
/**
* JSONObject.NULL is equivalent to the value that JavaScript calls null,
@@ -1299,6 +1300,7 @@ public class JSONObject {
* @param other The other JSONObject
* @return true if they are equal
*/
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
public boolean similar(Object other) {
try {
if (!(other instanceof JSONObject)) {

View File

@@ -29,6 +29,7 @@ import java.io.*;
* @author JSON.org
* @version 2014-05-03
*/
@SuppressWarnings("ALL")
public class JSONTokener {
private long character;

View File

@@ -83,7 +83,7 @@ public class JSONWriter {
/**
* The writer that will receive the output.
*/
protected Writer writer;
protected final Writer writer;
/**
* Make a fresh JSONWriter. It can be used to build one JSON text.
@@ -283,7 +283,6 @@ public class JSONWriter {
*
* @param b A boolean.
* @return this
* @throws JSONException
*/
public JSONWriter value(boolean b) throws JSONException {
return this.append(b ? "true" : "false");
@@ -305,7 +304,6 @@ public class JSONWriter {
*
* @param l A long.
* @return this
* @throws JSONException
*/
public JSONWriter value(long l) throws JSONException {
return this.append(Long.toString(l));

View File

@@ -36,7 +36,7 @@ public class JarScanner {
*/
public JarScanner(File jar, String superPackage) {
this.jar = jar;
this.classes = new KSet<Class<?>>();
this.classes = new KSet<>();
this.superPackage = superPackage;
}

View File

@@ -24,6 +24,7 @@ import java.util.*;
import java.util.function.Function;
import java.util.function.Predicate;
@SuppressWarnings("ALL")
public class KList<T> extends ArrayList<T> implements List<T> {
private static final long serialVersionUID = -2892550695744823337L;
@@ -108,7 +109,6 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* @param f the function
* @return the new map
*/
@SuppressWarnings("hiding")
public <V> KMap<T, V> asKeys(Function<T, V> f) {
KMap<T, V> m = new KMap<T, V>();
forEach((i) -> m.putNonNull(i, f.apply(i)));
@@ -249,7 +249,7 @@ public class KList<T> extends ArrayList<T> implements List<T> {
StringBuilder b = new StringBuilder();
for (String i : toStringList()) {
b.append(split + i);
b.append(split).append(i);
}
return b.substring(split.length());
@@ -272,7 +272,6 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* @param converter the converter that converts the forign type into this list type
* @return this list (builder)
*/
@SuppressWarnings("hiding")
public <V> KList<T> addFrom(List<V> v, Function<V, T> converter) {
v.forEach((g) -> add(converter.apply(g)));
return this;
@@ -286,7 +285,6 @@ public class KList<T> extends ArrayList<T> implements List<T> {
* @param converter
* @return
*/
@SuppressWarnings("hiding")
public <V> KList<V> convert(Function<T, V> converter) {
KList<V> v = new KList<V>();
forEach((t) -> v.addNonNull(converter.apply(t)));

View File

@@ -24,7 +24,7 @@ import java.util.Enumeration;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
@SuppressWarnings("hiding")
@SuppressWarnings("ALL")
public class KMap<K, V> extends ConcurrentHashMap<K, V> {
private static final long serialVersionUID = 7288942695300448163L;

View File

@@ -28,6 +28,7 @@ import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.bukkit.material.MaterialData;
import org.jetbrains.annotations.NotNull;
@SuppressWarnings("deprecation")
public class LinkedTerrainChunk implements TerrainChunk {
@@ -69,6 +70,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
return (x, y, z, bb) -> INMS.get().forceBiomeInto(x, y, z, bb, storage);
}
@NotNull
@Override
public Biome getBiome(int x, int z) {
if (storage != null) {
@@ -82,6 +84,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
return biome3D.getBiome(x, 0, z);
}
@NotNull
@Override
public Biome getBiome(int x, int y, int z) {
if (storage != null) {
@@ -144,6 +147,7 @@ public class LinkedTerrainChunk implements TerrainChunk {
rawChunkData.setBlock(x, y, z, blockData);
}
@NotNull
@Override
public BlockData getBlockData(int x, int y, int z) {
return rawChunkData.getBlockData(x, y, z);
@@ -151,39 +155,41 @@ public class LinkedTerrainChunk implements TerrainChunk {
@Deprecated
@Override
public void setBlock(int x, int y, int z, Material material) {
public void setBlock(int x, int y, int z, @NotNull Material material) {
rawChunkData.setBlock(x, y, z, material);
}
@Deprecated
@Override
public void setBlock(int x, int y, int z, MaterialData material) {
public void setBlock(int x, int y, int z, @NotNull MaterialData material) {
rawChunkData.setBlock(x, y, z, material);
}
@Deprecated
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, Material material) {
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull Material material) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material);
}
@Deprecated
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, MaterialData material) {
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull MaterialData material) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, material);
}
@Override
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, BlockData blockData) {
public void setRegion(int xMin, int yMin, int zMin, int xMax, int yMax, int zMax, @NotNull BlockData blockData) {
rawChunkData.setRegion(xMin, yMin, zMin, xMax, yMax, zMax, blockData);
}
@NotNull
@Deprecated
@Override
public Material getType(int x, int y, int z) {
return rawChunkData.getType(x, y, z);
}
@NotNull
@Deprecated
@Override
public MaterialData getTypeAndData(int x, int y, int z) {

View File

@@ -73,9 +73,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();

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.util;
import com.volmit.iris.Iris;
public abstract class Looper extends Thread {
@SuppressWarnings("BusyWait")
public void run() {
while (!interrupted()) {
try {
@@ -30,6 +31,7 @@ public abstract class Looper extends Thread {
break;
}
//noinspection BusyWait
Thread.sleep(m);
} catch (InterruptedException e) {
break;

View File

@@ -90,8 +90,6 @@ public class M {
* @param b the second point (1, 0)
* @param c the third point (0, 1)
* @param d the fourth point (1, 1)
* @param tx the x
* @param ty the y
* @return the bilerped value
*/
public static double bilerp(double a, double b, double c, double d, double x, double y) {
@@ -138,6 +136,7 @@ public class M {
* @return true if true
*/
public static boolean r(Double d) {
//noinspection ReplaceNullCheck
if (d == null) {
return Math.random() < 0.5;
}
@@ -252,7 +251,6 @@ public class M {
/**
* Biggest number
*
* @param numbers the numbers
* @return the biggest one
*/
@SuppressWarnings("unchecked")
@@ -323,7 +321,7 @@ public class M {
ScriptEngineManager mgr = new ScriptEngineManager();
ScriptEngine scriptEngine = mgr.getEngineByName("JavaScript");
return Double.valueOf(scriptEngine.eval(expression).toString());
return Double.parseDouble(scriptEngine.eval(expression).toString());
}
/**

View File

@@ -96,30 +96,21 @@ public class MathHelper {
if (var0 < var1) {
return var1;
}
if (var0 > var2) {
return var2;
}
return var0;
return Math.min(var0, var2);
}
public static float a(float var0, float var1, float var2) {
if (var0 < var1) {
return var1;
}
if (var0 > var2) {
return var2;
}
return var0;
return Math.min(var0, var2);
}
public static double a(double var0, double var2, double var4) {
if (var0 < var2) {
return var2;
}
if (var0 > var4) {
return var4;
}
return var0;
return Math.min(var0, var4);
}
public static double b(double var0, double var2, double var4) {
@@ -139,7 +130,7 @@ public class MathHelper {
if (var2 < 0.0) {
var2 = -var2;
}
return var0 > var2 ? var0 : var2;
return Math.max(var0, var2);
}
public static int a(int var0, int var1) {
@@ -285,7 +276,7 @@ public class MathHelper {
}
public static long c(int var0, int var1, int var2) {
long var3 = (long) (var0 * 3129871) ^ (long) var2 * 116129781L ^ (long) var1;
long var3 = (var0 * 3129871L) ^ (long) var2 * 116129781L ^ (long) var1;
var3 = var3 * var3 * 42317861L + var3 * 11L;
return var3 >> 16;
}
@@ -370,43 +361,37 @@ public class MathHelper {
float var6 = var2 * (1.0f - var4 * var1);
float var7 = var2 * (1.0f - (1.0f - var4) * var1);
switch (var3) {
case 0: {
case 0 -> {
var8 = var2;
var9 = var7;
var10 = var5;
break;
}
case 1: {
case 1 -> {
var8 = var6;
var9 = var2;
var10 = var5;
break;
}
case 2: {
case 2 -> {
var8 = var5;
var9 = var2;
var10 = var7;
break;
}
case 3: {
case 3 -> {
var8 = var5;
var9 = var6;
var10 = var2;
break;
}
case 4: {
case 4 -> {
var8 = var7;
var9 = var5;
var10 = var2;
break;
}
case 5: {
case 5 -> {
var8 = var2;
var9 = var5;
var10 = var6;
break;
}
default: {
default -> {
throw new RuntimeException("Something went wrong when converting from HSV to RGB. Input was " + var0 + ", " + var1 + ", " + var2);
}
}

View File

@@ -127,10 +127,11 @@ public class Metrics {
// Inform the server owners about bStats
config.options().header(
"bStats collects some data for plugin authors like how many servers are using their plugins.\n" +
"To honor their work, you should not disable it.\n" +
"This has nearly no effect on the server performance!\n" +
"Check out https://bStats.org/ to learn more :)"
"""
bStats collects some data for plugin authors like how many servers are using their plugins.
To honor their work, you should not disable it.
This has nearly no effect on the server performance!
Check out https://bStats.org/ to learn more :)"""
).copyDefaults(true);
try {
config.save(configFile);

View File

@@ -125,7 +125,11 @@ public class MetricsLite {
config.addDefault("logResponseStatusText", false);
// Inform the server owners about bStats
config.options().header("bStats collects some data for plugin authors like how many servers are using their plugins.\n" + "To honor their work, you should not disable it.\n" + "This has nearly no effect on the server performance!\n" + "Check out https://bStats.org/ to learn more :)").copyDefaults(true);
config.options().header("""
bStats collects some data for plugin authors like how many servers are using their plugins.
To honor their work, you should not disable it.
This has nearly no effect on the server performance!
Check out https://bStats.org/ to learn more :)""").copyDefaults(true);
try {
config.save(configFile);
} catch (IOException ignored) {

View File

@@ -47,7 +47,7 @@ public abstract class MortarCommand implements ICommand {
public MortarCommand(String node, String... nodes) {
category = "";
this.node = node;
this.nodes = new KList<String>(nodes);
this.nodes = new KList<>(nodes);
requiredPermissions = new KList<>();
children = buildChildren();
description = "No Description";
@@ -83,7 +83,6 @@ public abstract class MortarCommand implements ICommand {
for (MortarCommand i : getChildren()) {
for (String j : i.getRequiredPermissions()) {
if (!sender.hasPermission(j)) {
continue;
}
}
@@ -132,16 +131,16 @@ public abstract class MortarCommand implements ICommand {
if (a.length > past) {
int p = past;
String m = "";
StringBuilder m = new StringBuilder();
for (String i : a) {
p--;
if (p < 0) {
m += i + ", ";
m.append(i).append(", ");
}
}
if (!m.trim().isEmpty()) {
if (!m.toString().trim().isEmpty()) {
sender.sendMessage("Parameters Ignored: " + m);
}
}

View File

@@ -107,47 +107,49 @@ public class MortarSender implements CommandSender {
}
@Override
public boolean isPermissionSet(String name) {
public boolean isPermissionSet(@NotNull String name) {
return s.isPermissionSet(name);
}
@Override
public boolean isPermissionSet(Permission perm) {
public boolean isPermissionSet(@NotNull Permission perm) {
return s.isPermissionSet(perm);
}
@Override
public boolean hasPermission(String name) {
public boolean hasPermission(@NotNull String name) {
return s.hasPermission(name);
}
@Override
public boolean hasPermission(Permission perm) {
public boolean hasPermission(@NotNull Permission perm) {
return s.hasPermission(perm);
}
@NotNull
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value) {
public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value) {
return s.addAttachment(plugin, name, value);
}
@NotNull
@Override
public PermissionAttachment addAttachment(Plugin plugin) {
public PermissionAttachment addAttachment(@NotNull Plugin plugin) {
return s.addAttachment(plugin);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, String name, boolean value, int ticks) {
public PermissionAttachment addAttachment(@NotNull Plugin plugin, @NotNull String name, boolean value, int ticks) {
return s.addAttachment(plugin, name, value, ticks);
}
@Override
public PermissionAttachment addAttachment(Plugin plugin, int ticks) {
public PermissionAttachment addAttachment(@NotNull Plugin plugin, int ticks) {
return s.addAttachment(plugin, ticks);
}
@Override
public void removeAttachment(PermissionAttachment attachment) {
public void removeAttachment(@NotNull PermissionAttachment attachment) {
s.removeAttachment(attachment);
}
@@ -156,6 +158,7 @@ public class MortarSender implements CommandSender {
s.recalculatePermissions();
}
@NotNull
@Override
public Set<PermissionAttachmentInfo> getEffectivePermissions() {
return s.getEffectivePermissions();
@@ -176,7 +179,7 @@ public class MortarSender implements CommandSender {
}
@Override
public void sendMessage(String message) {
public void sendMessage(@NotNull String message) {
s.sendMessage(C.translateAlternateColorCodes('&', getTag()) + message);
}
@@ -196,16 +199,19 @@ public class MortarSender implements CommandSender {
sendMessage(messages);
}
@NotNull
@Override
public Server getServer() {
return s.getServer();
}
@NotNull
@Override
public String getName() {
return s.getName();
}
@NotNull
@Override
public Spigot spigot() {
return s.spigot();

View File

@@ -21,8 +21,8 @@ package com.volmit.iris.util;
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
/**
* Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**

View File

@@ -28,9 +28,9 @@ import java.util.List;
import java.util.Map;
import java.util.zip.GZIPInputStream;
/**
* Changes :
* Neil Wightman - Support 19133 Tag_Int_Array tag
/*
Changes :
Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
@@ -147,7 +147,7 @@ public final class NBTInputStream implements Closeable {
int childType = is.readByte();
length = is.readInt();
List<Tag> tagList = new ArrayList<Tag>();
List<Tag> tagList = new ArrayList<>();
for (int i = 0; i < length; i++) {
Tag tag = readTagPayload(childType, "", depth + 1);
if (tag instanceof EndTag) {
@@ -158,7 +158,7 @@ public final class NBTInputStream implements Closeable {
return new ListTag(name, NBTUtils.getTypeClass(childType), tagList);
case NBTConstants.TYPE_COMPOUND:
Map<String, Tag> tagMap = new HashMap<String, Tag>();
Map<String, Tag> tagMap = new HashMap<>();
while (true) {
Tag tag = readTag(depth + 1);
if (tag instanceof EndTag) {

View File

@@ -24,8 +24,8 @@ import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.zip.GZIPOutputStream;
/**
* Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
@@ -39,6 +39,7 @@ import java.util.zip.GZIPOutputStream;
*
* @author Graham Edgecombe
*/
@SuppressWarnings({"EmptyMethod", "JavaDoc"})
public final class NBTOutputStream implements Closeable {
/**
@@ -97,44 +98,19 @@ public final class NBTOutputStream implements Closeable {
private void writeTagPayload(Tag tag) throws IOException {
int type = NBTUtils.getTypeCode(tag.getClass());
switch (type) {
case NBTConstants.TYPE_END:
writeEndTagPayload((EndTag) tag);
break;
case NBTConstants.TYPE_BYTE:
writeByteTagPayload((ByteTag) tag);
break;
case NBTConstants.TYPE_SHORT:
writeShortTagPayload((ShortTag) tag);
break;
case NBTConstants.TYPE_INT:
writeIntTagPayload((IntTag) tag);
break;
case NBTConstants.TYPE_LONG:
writeLongTagPayload((LongTag) tag);
break;
case NBTConstants.TYPE_FLOAT:
writeFloatTagPayload((FloatTag) tag);
break;
case NBTConstants.TYPE_DOUBLE:
writeDoubleTagPayload((DoubleTag) tag);
break;
case NBTConstants.TYPE_BYTE_ARRAY:
writeByteArrayTagPayload((ByteArrayTag) tag);
break;
case NBTConstants.TYPE_STRING:
writeStringTagPayload((StringTag) tag);
break;
case NBTConstants.TYPE_LIST:
writeListTagPayload((ListTag) tag);
break;
case NBTConstants.TYPE_COMPOUND:
writeCompoundTagPayload((CompoundTag) tag);
break;
case NBTConstants.TYPE_INT_ARRAY:
writeIntArrayTagPayload((IntArrayTag) tag);
break;
default:
throw new IOException("Invalid tag type: " + type + ".");
case NBTConstants.TYPE_END -> writeEndTagPayload((EndTag) tag);
case NBTConstants.TYPE_BYTE -> writeByteTagPayload((ByteTag) tag);
case NBTConstants.TYPE_SHORT -> writeShortTagPayload((ShortTag) tag);
case NBTConstants.TYPE_INT -> writeIntTagPayload((IntTag) tag);
case NBTConstants.TYPE_LONG -> writeLongTagPayload((LongTag) tag);
case NBTConstants.TYPE_FLOAT -> writeFloatTagPayload((FloatTag) tag);
case NBTConstants.TYPE_DOUBLE -> writeDoubleTagPayload((DoubleTag) tag);
case NBTConstants.TYPE_BYTE_ARRAY -> writeByteArrayTagPayload((ByteArrayTag) tag);
case NBTConstants.TYPE_STRING -> writeStringTagPayload((StringTag) tag);
case NBTConstants.TYPE_LIST -> writeListTagPayload((ListTag) tag);
case NBTConstants.TYPE_COMPOUND -> writeCompoundTagPayload((CompoundTag) tag);
case NBTConstants.TYPE_INT_ARRAY -> writeIntArrayTagPayload((IntArrayTag) tag);
default -> throw new IOException("Invalid tag type: " + type + ".");
}
}
@@ -187,8 +163,8 @@ public final class NBTOutputStream implements Closeable {
os.writeByte(NBTUtils.getTypeCode(clazz));
os.writeInt(size);
for (int i = 0; i < size; i++) {
writeTagPayload(tags.get(i));
for (Tag value : tags) {
writeTagPayload(value);
}
}

View File

@@ -18,8 +18,8 @@
package com.volmit.iris.util;
/**
* Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
/*
Changes : Neil Wightman - Support 19133 Tag_Int_Array tag
*/
/**
@@ -110,34 +110,21 @@ public final class NBTUtils {
* @throws IllegalArgumentException if the tag type is invalid.
*/
public static Class<? extends Tag> getTypeClass(int type) {
switch (type) {
case NBTConstants.TYPE_END:
return EndTag.class;
case NBTConstants.TYPE_BYTE:
return ByteTag.class;
case NBTConstants.TYPE_SHORT:
return ShortTag.class;
case NBTConstants.TYPE_INT:
return IntTag.class;
case NBTConstants.TYPE_LONG:
return LongTag.class;
case NBTConstants.TYPE_FLOAT:
return FloatTag.class;
case NBTConstants.TYPE_DOUBLE:
return DoubleTag.class;
case NBTConstants.TYPE_BYTE_ARRAY:
return ByteArrayTag.class;
case NBTConstants.TYPE_STRING:
return StringTag.class;
case NBTConstants.TYPE_LIST:
return ListTag.class;
case NBTConstants.TYPE_COMPOUND:
return CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY:
return IntArrayTag.class;
default:
throw new IllegalArgumentException("Invalid tag type : " + type + ".");
}
return switch (type) {
case NBTConstants.TYPE_END -> EndTag.class;
case NBTConstants.TYPE_BYTE -> ByteTag.class;
case NBTConstants.TYPE_SHORT -> ShortTag.class;
case NBTConstants.TYPE_INT -> IntTag.class;
case NBTConstants.TYPE_LONG -> LongTag.class;
case NBTConstants.TYPE_FLOAT -> FloatTag.class;
case NBTConstants.TYPE_DOUBLE -> DoubleTag.class;
case NBTConstants.TYPE_BYTE_ARRAY -> ByteArrayTag.class;
case NBTConstants.TYPE_STRING -> StringTag.class;
case NBTConstants.TYPE_LIST -> ListTag.class;
case NBTConstants.TYPE_COMPOUND -> CompoundTag.class;
case NBTConstants.TYPE_INT_ARRAY -> IntArrayTag.class;
default -> throw new IllegalArgumentException("Invalid tag type : " + type + ".");
};
}
/**

View File

@@ -129,7 +129,7 @@ public enum NMSVersion {
try {
Class.forName("org.bukkit.craftbukkit.v" + v + ".CraftWorld");
return true;
} catch (Throwable e) {
} catch (Throwable ignored) {
}

View File

@@ -19,5 +19,5 @@
package com.volmit.iris.util;
public interface NastyFunction<T, R> {
R run(T t) throws Throwable;
R run(T t);
}

View File

@@ -19,5 +19,5 @@
package com.volmit.iris.util;
public interface NastyFuture<R> {
R run() throws Throwable;
R run();
}

View File

@@ -139,8 +139,8 @@ public class NibbleArray implements Writable {
public String toBitsString(ByteOrder byteOrder) {
StringJoiner joiner = new StringJoiner(" ");
for (int i = 0; i < data.length; i++) {
joiner.add(binaryString(data[i], byteOrder));
for (byte datum : data) {
joiner.add(binaryString(datum, byteOrder));
}
return joiner.toString();

View File

@@ -29,11 +29,10 @@ public class O<T> implements Observable<T> {
@Override
public O<T> set(T t) {
T x = t;
this.t = t;
if (observers != null && observers.hasElements()) {
observers.forEach((o) -> o.onChanged(x, t));
observers.forEach((o) -> o.onChanged(t, t));
}
return this;

View File

@@ -151,7 +151,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;
}

View File

@@ -33,7 +33,7 @@ import java.lang.reflect.Method;
*
* @author MrMicky
*/
@SuppressWarnings("deprecation")
@SuppressWarnings({"deprecation", "JavaReflectionInvocation"})
class ParticleSenderLegacy implements ParticleSender {
private static final boolean SERVER_IS_1_8;
@@ -158,20 +158,18 @@ class ParticleSenderLegacy implements ParticleSender {
private int[] toData(ParticleType particle, Object data) {
Class<?> dataType = particle.getDataType();
if (dataType == ItemStack.class) {
if (!(data instanceof ItemStack)) {
if (!(data instanceof ItemStack itemStack)) {
return SERVER_IS_1_8 ? new int[2] : new int[]{1, 0};
}
ItemStack itemStack = (ItemStack) data;
return new int[]{itemStack.getType().getId(), itemStack.getDurability()};
}
if (dataType == MaterialData.class) {
if (!(data instanceof MaterialData)) {
if (!(data instanceof MaterialData materialData)) {
return SERVER_IS_1_8 ? new int[1] : new int[]{1, 0};
}
MaterialData materialData = (MaterialData) data;
if (SERVER_IS_1_8) {
return new int[]{materialData.getItemType().getId() + (materialData.getData() << 12)};
} else {

View File

@@ -161,19 +161,14 @@ public enum ParticleType {
}
public Class<?> getDataType() {
switch (this) {
case ITEM_CRACK:
return ItemStack.class;
case BLOCK_CRACK:
case BLOCK_DUST:
case FALLING_DUST:
//noinspection deprecation
return MaterialData.class;
case REDSTONE:
return Color.class;
default:
return Void.class;
}
return switch (this) {
case ITEM_CRACK -> ItemStack.class;
case BLOCK_CRACK, BLOCK_DUST, FALLING_DUST ->
//noinspection deprecation
MaterialData.class;
case REDSTONE -> Color.class;
default -> Void.class;
};
}
public static ParticleType getParticle(String particleName) {

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util;
@SuppressWarnings("ALL")
public interface Queue<T> {
Queue<T> queue(T t);

View File

@@ -23,7 +23,7 @@ public class QueueExecutor extends Looper {
private boolean shutdown;
public QueueExecutor() {
queue = new ShurikenQueue<Runnable>();
queue = new ShurikenQueue<>();
shutdown = false;
}

View File

@@ -45,7 +45,7 @@ public class RNG extends Random {
* @param seed the seed (string)
*/
public RNG(String seed) {
this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564));
this(UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getLeastSignificantBits() + UUID.nameUUIDFromBytes(seed.getBytes(StandardCharsets.UTF_8)).getMostSignificantBits() + (seed.length() * 32564L));
}
public RNG nextParallelRNG(int signature) {

View File

@@ -99,7 +99,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;
}
@@ -140,8 +140,7 @@ public class ResourceLoader<T extends IrisRegistrant> {
String key = name + "-" + cname;
if (loadCache.containsKey(key)) {
T t = loadCache.get(key);
return t;
return loadCache.get(key);
}
lock.lock();

View File

@@ -21,6 +21,7 @@ package com.volmit.iris.util;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.jetbrains.annotations.NotNull;
/**
* Assistive command router
@@ -44,19 +45,21 @@ public class RouterCommand extends org.bukkit.command.Command {
this.ex = ex;
}
@NotNull
@Override
public Command setUsage(String u) {
public Command setUsage(@NotNull String u) {
this.usage = u;
return this;
}
@NotNull
@Override
public String getUsage() {
return usage;
}
@Override
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
public boolean execute(@NotNull CommandSender sender, @NotNull String commandLabel, @NotNull String[] args) {
return ex.onCommand(sender, this, commandLabel, args);
}
}

View File

@@ -28,7 +28,6 @@ import com.volmit.iris.object.IrisObject;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
public class SKConversion {
@@ -48,8 +47,6 @@ public class SKConversion {
}
o.write(out);
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}

View File

@@ -81,7 +81,7 @@ public class ShurikenQueue<T> implements Queue<T> {
@Override
public ShurikenQueue<T> clear() {
queue = new KList<T>();
queue = new KList<>();
return this;
}

View File

@@ -18,6 +18,7 @@
package com.volmit.iris.util;
@SuppressWarnings("EmptyMethod")
public class Spiraler {
int x, z, dx, dz, sizeX, sizeZ, t, maxI, i;
int ox, oz;

View File

@@ -45,14 +45,11 @@ public class TaskExecutor {
return t;
});
} else if (threadLimit > 1) {
final ForkJoinWorkerThreadFactory factory = new ForkJoinWorkerThreadFactory() {
@Override
public ForkJoinWorkerThread newThread(ForkJoinPool pool) {
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName(name + " " + xc++);
worker.setPriority(priority);
return worker;
}
final ForkJoinWorkerThreadFactory factory = pool -> {
final ForkJoinWorkerThread worker = ForkJoinPool.defaultForkJoinWorkerThreadFactory.newThread(pool);
worker.setName(name + " " + xc++);
worker.setPriority(priority);
return worker;
};
service = new ForkJoinPool(threadLimit, factory, null, false);
@@ -120,8 +117,9 @@ public class TaskExecutor {
waiting:
while (true) {
try {
//noinspection BusyWait
Thread.sleep(0);
} catch (InterruptedException e1) {
} catch (InterruptedException ignored) {
}
@@ -150,6 +148,7 @@ public class TaskExecutor {
}
}
@SuppressWarnings("ClassCanBeRecord")
@ToString
public static class TaskResult {
public TaskResult(double timeElapsed, int tasksExecuted, int tasksFailed, int tasksCompleted) {

View File

@@ -24,6 +24,7 @@ import org.bukkit.block.Biome;
import org.bukkit.block.data.BlockData;
import org.bukkit.generator.ChunkGenerator.BiomeGrid;
import org.bukkit.generator.ChunkGenerator.ChunkData;
import org.jetbrains.annotations.NotNull;
public interface TerrainChunk extends BiomeGrid, ChunkData {
static TerrainChunk create(World world) {
@@ -58,6 +59,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @return Biome value
* @deprecated biomes are now 3-dimensional
*/
@NotNull
@Deprecated
Biome getBiome(int x, int z);
@@ -69,6 +71,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @param z - 0-15
* @return Biome value
*/
@NotNull
Biome getBiome(int x, int y, int z);
/**
@@ -80,7 +83,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @deprecated biomes are now 3-dimensional
*/
@Deprecated
void setBiome(int x, int z, Biome bio);
void setBiome(int x, int z, @NotNull Biome bio);
/**
* Set biome at x, z within chunk being generated
@@ -90,7 +93,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @param z - 0-15
* @param bio - Biome value
*/
void setBiome(int x, int y, int z, Biome bio);
void setBiome(int x, int y, int z, @NotNull Biome bio);
/**
* Get the maximum height for the chunk.
@@ -112,7 +115,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @param z the z location in the chunk from 0-15 inclusive
* @param blockData the type to set the block to
*/
void setBlock(int x, int y, int z, BlockData blockData);
void setBlock(int x, int y, int z, @NotNull BlockData blockData);
/**
* Get the type and data of the block at x, y, z.
@@ -126,6 +129,7 @@ public interface TerrainChunk extends BiomeGrid, ChunkData {
* @return the data of the block or the BlockData for air if x, y or z are
* outside the chunk's bounds
*/
@NotNull
BlockData getBlockData(int x, int y, int z);
ChunkData getRaw();

View File

@@ -47,6 +47,7 @@ public class ThreadMonitor extends Thread {
public void run() {
while (running) {
try {
//noinspection BusyWait
Thread.sleep(0);
State s = monitor.getState();
if (lastState != s) {

View File

@@ -311,9 +311,7 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
try {
Tuple2d t2 = (Tuple2d) t1;
return (this.x == t2.x && this.y == t2.y);
} catch (NullPointerException e2) {
return false;
} catch (ClassCastException e1) {
} catch (NullPointerException | ClassCastException e2) {
return false;
}
@@ -363,19 +361,11 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
public final void clamp(double min, double max, Tuple2d t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
}
@@ -388,17 +378,9 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(double min, Tuple2d t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
}
@@ -411,17 +393,9 @@ public abstract class Tuple2d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(double max, Tuple2d t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
}

View File

@@ -313,9 +313,7 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
try {
Tuple2f t2 = (Tuple2f) t1;
return (this.x == t2.x && this.y == t2.y);
} catch (NullPointerException e2) {
return false;
} catch (ClassCastException e1) {
} catch (NullPointerException | ClassCastException e2) {
return false;
}
@@ -365,19 +363,11 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
public final void clamp(float min, float max, Tuple2f t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
}
@@ -390,17 +380,9 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(float min, Tuple2f t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
}
@@ -413,17 +395,9 @@ public abstract class Tuple2f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(float max, Tuple2f t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
}

View File

@@ -361,9 +361,7 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
try {
Tuple3d t2 = (Tuple3d) t1;
return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
} catch (ClassCastException e1) {
return false;
} catch (NullPointerException e2) {
} catch (ClassCastException | NullPointerException e1) {
return false;
}
@@ -416,27 +414,15 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
public final void clamp(double min, double max, Tuple3d t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
if (t.z > max) {
z = max;
} else if (t.z < min) {
z = min;
} else {
z = t.z;
}
} else z = Math.max(t.z, min);
}
@@ -457,23 +443,11 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(double min, Tuple3d t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
if (t.z < min) {
z = min;
} else {
z = t.z;
}
z = Math.max(t.z, min);
}
@@ -494,23 +468,11 @@ public abstract class Tuple3d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(double max, Tuple3d t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
if (t.z > max) {
z = max;
} else {
z = t.z;
}
z = Math.min(t.z, max);
}

View File

@@ -346,9 +346,7 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
try {
Tuple3f t2 = (Tuple3f) t1;
return (this.x == t2.x && this.y == t2.y && this.z == t2.z);
} catch (NullPointerException e2) {
return false;
} catch (ClassCastException e1) {
} catch (NullPointerException | ClassCastException e2) {
return false;
}
}
@@ -411,27 +409,15 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
public final void clamp(float min, float max, Tuple3f t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
if (t.z > max) {
z = max;
} else if (t.z < min) {
z = min;
} else {
z = t.z;
}
} else z = Math.max(t.z, min);
}
@@ -444,23 +430,11 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(float min, Tuple3f t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
if (t.z < min) {
z = min;
} else {
z = t.z;
}
z = Math.max(t.z, min);
}
@@ -473,23 +447,11 @@ public abstract class Tuple3f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(float max, Tuple3f t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
if (t.z > max) {
z = max;
} else {
z = t.z;
}
z = Math.min(t.z, max);
}

View File

@@ -387,9 +387,7 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
Tuple4d t2 = (Tuple4d) t1;
return (this.x == t2.x && this.y == t2.y &&
this.z == t2.z && this.w == t2.w);
} catch (NullPointerException e2) {
return false;
} catch (ClassCastException e1) {
} catch (NullPointerException | ClassCastException e2) {
return false;
}
}
@@ -466,35 +464,19 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
public final void clamp(double min, double max, Tuple4d t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
if (t.z > max) {
z = max;
} else if (t.z < min) {
z = min;
} else {
z = t.z;
}
} else z = Math.max(t.z, min);
if (t.w > max) {
w = max;
} else if (t.w < min) {
w = min;
} else {
w = t.w;
}
} else w = Math.max(t.w, min);
}
@@ -515,29 +497,13 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(double min, Tuple4d t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
if (t.z < min) {
z = min;
} else {
z = t.z;
}
z = Math.max(t.z, min);
if (t.w < min) {
w = min;
} else {
w = t.w;
}
w = Math.max(t.w, min);
}
@@ -558,23 +524,11 @@ public abstract class Tuple4d implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(double max, Tuple4d t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
if (t.z > max) {
z = max;
} else {
z = t.z;
}
z = Math.min(t.z, max);
if (t.w > max) {
w = max;

View File

@@ -374,9 +374,7 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
Tuple4f t2 = (Tuple4f) t1;
return (this.x == t2.x && this.y == t2.y &&
this.z == t2.z && this.w == t2.w);
} catch (NullPointerException e2) {
return false;
} catch (ClassCastException e1) {
} catch (NullPointerException | ClassCastException e2) {
return false;
}
}
@@ -444,35 +442,19 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
public final void clamp(float min, float max, Tuple4f t) {
if (t.x > max) {
x = max;
} else if (t.x < min) {
x = min;
} else {
x = t.x;
}
} else x = Math.max(t.x, min);
if (t.y > max) {
y = max;
} else if (t.y < min) {
y = min;
} else {
y = t.y;
}
} else y = Math.max(t.y, min);
if (t.z > max) {
z = max;
} else if (t.z < min) {
z = min;
} else {
z = t.z;
}
} else z = Math.max(t.z, min);
if (t.w > max) {
w = max;
} else if (t.w < min) {
w = min;
} else {
w = t.w;
}
} else w = Math.max(t.w, min);
}
@@ -485,29 +467,13 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMin(float min, Tuple4f t) {
if (t.x < min) {
x = min;
} else {
x = t.x;
}
x = Math.max(t.x, min);
if (t.y < min) {
y = min;
} else {
y = t.y;
}
y = Math.max(t.y, min);
if (t.z < min) {
z = min;
} else {
z = t.z;
}
z = Math.max(t.z, min);
if (t.w < min) {
w = min;
} else {
w = t.w;
}
w = Math.max(t.w, min);
}
@@ -521,23 +487,11 @@ public abstract class Tuple4f implements java.io.Serializable, Cloneable {
* @param t the source tuple, which will not be modified
*/
public final void clampMax(float max, Tuple4f t) {
if (t.x > max) {
x = max;
} else {
x = t.x;
}
x = Math.min(t.x, max);
if (t.y > max) {
y = max;
} else {
y = t.y;
}
y = Math.min(t.y, max);
if (t.z > max) {
z = max;
} else {
z = t.z;
}
z = Math.min(t.z, max);
if (t.w > max) {
w = max;

View File

@@ -53,7 +53,7 @@ public class UIElement implements Element {
}
public Double clip(double value, double min, double max) {
return Double.valueOf(Math.min(max, Math.max(min, value)));
return Math.min(max, Math.max(min, value));
}
@Override
@@ -134,26 +134,32 @@ public class UIElement implements Element {
public Element call(ElementEvent event, Element context) {
try {
switch (event) {
case DRAG_INTO:
case DRAG_INTO -> {
eDraggedInto.run(context);
return this;
case LEFT:
}
case LEFT -> {
eLeft.run(context);
return this;
case OTHER_DRAG_INTO:
}
case OTHER_DRAG_INTO -> {
eOtherDraggedInto.run(context);
return this;
case RIGHT:
}
case RIGHT -> {
eRight.run(context);
return this;
case SHIFT_LEFT:
}
case SHIFT_LEFT -> {
eShiftLeft.run(context);
return this;
case SHIFT_RIGHT:
}
case SHIFT_RIGHT -> {
eShiftRight.run(context);
return this;
}
}
} catch (NullPointerException e) {
} catch (NullPointerException ignored) {
} catch (Throwable e) {
e.printStackTrace();

View File

@@ -20,6 +20,7 @@ package com.volmit.iris.util;
import org.bukkit.Material;
@SuppressWarnings("ClassCanBeRecord")
public class UIStaticDecorator implements WindowDecorator {
private final Element element;

View File

@@ -85,55 +85,31 @@ public class UIWindow implements Window, Listener {
switch (e.getAction()) {
case CLONE_STACK:
break;
case COLLECT_TO_CURSOR:
break;
case DROP_ALL_CURSOR:
break;
case DROP_ALL_SLOT:
break;
case DROP_ONE_CURSOR:
break;
case DROP_ONE_SLOT:
break;
case HOTBAR_MOVE_AND_READD:
break;
case HOTBAR_SWAP:
break;
case MOVE_TO_OTHER_INVENTORY:
break;
case NOTHING:
break;
case PICKUP_ALL:
break;
case PICKUP_HALF:
break;
case PICKUP_ONE:
break;
case PICKUP_SOME:
break;
case PLACE_ALL:
break;
case PLACE_ONE:
break;
case PLACE_SOME:
break;
case SWAP_WITH_CURSOR:
break;
case UNKNOWN:
case SWAP_WITH_CURSOR:
case PLACE_SOME:
case PLACE_ONE:
case PLACE_ALL:
case PICKUP_SOME:
case PICKUP_ONE:
case PICKUP_HALF:
case PICKUP_ALL:
case NOTHING:
case MOVE_TO_OTHER_INVENTORY:
case HOTBAR_SWAP:
case HOTBAR_MOVE_AND_READD:
case DROP_ONE_SLOT:
case DROP_ONE_CURSOR:
case DROP_ALL_SLOT:
case DROP_ALL_CURSOR:
case COLLECT_TO_CURSOR:
break;
}
switch (e.getClick()) {
case CONTROL_DROP:
break;
case CREATIVE:
break;
case DOUBLE_CLICK:
doubleclicked = true;
break;
case DROP:
break;
case LEFT:
clickcheck++;
@@ -162,10 +138,6 @@ public class UIWindow implements Window, Listener {
});
}
break;
case MIDDLE:
break;
case NUMBER_KEY:
break;
case RIGHT:
if (element != null) {
@@ -184,14 +156,15 @@ public class UIWindow implements Window, Listener {
element.call(ElementEvent.SHIFT_RIGHT, element);
}
break;
case WINDOW_BORDER_LEFT:
break;
case WINDOW_BORDER_RIGHT:
break;
case UNKNOWN:
break;
case SWAP_OFFHAND:
break;
case UNKNOWN:
case WINDOW_BORDER_RIGHT:
case WINDOW_BORDER_LEFT:
case NUMBER_KEY:
case MIDDLE:
case DROP:
case CREATIVE:
case CONTROL_DROP:
default:
break;
}
@@ -414,7 +387,7 @@ public class UIWindow implements Window, Listener {
}
public Double clip(double value, double min, double max) {
return Double.valueOf(Math.min(max, Math.max(min, value)));
return Math.min(max, Math.max(min, value));
}
@Override
@@ -437,7 +410,7 @@ public class UIWindow implements Window, Listener {
public Window updateInventory() {
if (isVisible()) {
ItemStack[] is = inventory.getContents();
KSet<ItemStack> isf = new KSet<ItemStack>();
@SuppressWarnings("MismatchedQueryAndUpdateOfCollection") KSet<ItemStack> isf = new KSet<>();
for (int i = 0; i < is.length; i++) {
ItemStack isc = is[i];

View File

@@ -100,14 +100,14 @@ public class V {
}
public Object invoke(String method, Object... parameters) {
KList<Class<?>> par = new KList<Class<?>>();
KList<Class<?>> par = new KList<>();
for (Object i : parameters) {
par.add(i.getClass());
}
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) {
if (!suppress) {
e.printStackTrace();

View File

@@ -32,16 +32,12 @@ import org.bukkit.util.Vector;
*/
public class VectorMath {
public static Vector scaleStatic(Axis x, Vector v, double amt) {
switch (x) {
case X:
return scaleX(v, amt);
case Y:
return scaleY(v, amt);
case Z:
return scaleZ(v, amt);
}
return switch (x) {
case X -> scaleX(v, amt);
case Y -> scaleY(v, amt);
case Z -> scaleZ(v, amt);
};
return null;
}
public static Vector scaleX(Vector v, double amt) {
@@ -227,7 +223,7 @@ public class VectorMath {
}
private static double round(double value, int precision) {
return Double.valueOf(Form.f(value, precision));
return Double.parseDouble(Form.f(value, precision));
}
public static Vector clip(Vector v, int decimals) {
@@ -247,9 +243,10 @@ public class VectorMath {
u = axis.getX();
v = axis.getY();
w = axis.getZ();
double xPrime = u * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + x * Math.cos(theta) + (-w * y + v * z) * Math.sin(theta);
double yPrime = v * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + y * Math.cos(theta) + (w * x - u * z) * Math.sin(theta);
double zPrime = w * (u * x + v * y + w * z) * (1d - Math.cos(theta)) + z * Math.cos(theta) + (-v * x + u * y) * Math.sin(theta);
double f = u * x + v * y + w * z;
double xPrime = u * (f) * (1d - Math.cos(theta)) + x * Math.cos(theta) + (-w * y + v * z) * Math.sin(theta);
double yPrime = v * (f) * (1d - Math.cos(theta)) + y * Math.cos(theta) + (w * x - u * z) * Math.sin(theta);
double zPrime = w * (f) * (1d - Math.cos(theta)) + z * Math.cos(theta) + (-v * x + u * y) * Math.sin(theta);
return clip(new Vector(xPrime, yPrime, zPrime), 4);
}
@@ -262,7 +259,7 @@ public class VectorMath {
* @return multiple faces, or one if the face is already simple
*/
public static KList<BlockFace> split(BlockFace f) {
KList<BlockFace> faces = new KList<BlockFace>();
KList<BlockFace> faces = new KList<>();
switch (f) {
case DOWN:
@@ -441,7 +438,7 @@ public class VectorMath {
* @return the shifted vectors
*/
public static KList<Vector> shift(Vector vector, KList<Vector> vectors) {
return new KList<Vector>(new GListAdapter<Vector, Vector>() {
return new KList<>(new GListAdapter<Vector, Vector>() {
@Override
public Vector onAdapt(Vector from) {
return from.add(vector);

View File

@@ -25,7 +25,7 @@ import java.lang.reflect.Method;
import java.util.concurrent.ConcurrentSkipListMap;
public class Violator {
protected static ConcurrentSkipListMap<String, Object> nodes = new ConcurrentSkipListMap<String, Object>();
protected static final ConcurrentSkipListMap<String, Object> nodes = new ConcurrentSkipListMap<>();
private static String id(Object o, Object h) {
if (o instanceof Field) {
@@ -40,34 +40,32 @@ public class Violator {
return ((Class<?>) o).getCanonicalName();
}
if (o instanceof Constructor<?>) {
Constructor<?> co = (Constructor<?>) o;
if (o instanceof Constructor<?> co) {
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 + ")";
}
if (o instanceof Annotation) {
Annotation a = (Annotation) o;
if (o instanceof Annotation a) {
return "@" + a.annotationType().getCanonicalName() + "[" + id(h, null) + "]";
}
@@ -78,6 +76,7 @@ public class Violator {
nodes.put(n, o);
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private static boolean h(String n) {
return nodes.containsKey(n);
}
@@ -87,13 +86,13 @@ 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 + ")")) {
Constructor<?> co = c.getConstructor(params);
@@ -148,13 +147,13 @@ 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)) {
@@ -168,14 +167,14 @@ public class Violator {
@SuppressWarnings("unchecked")
public static <T> T construct(Class<?> c, Object... parameters) {
KList<Class<?>> cv = new KList<Class<?>>();
KList<Class<?>> cv = new KList<>();
for (Object i : parameters) {
cv.add(i.getClass());
}
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);
} catch (Exception e) {
e.printStackTrace();
@@ -186,13 +185,13 @@ 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)) {
@@ -205,7 +204,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getAnnotation(Class<?> c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getAnnotation(Class<?> c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) {
T f = c.getAnnotation(a);
p(id(f, c), f);
@@ -215,7 +214,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getDeclaredAnnotation(Class<?> c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getDeclaredAnnotation(Class<?> c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + c.getCanonicalName() + "]")) {
T f = c.getDeclaredAnnotation(a);
p(id(f, c), f);
@@ -225,7 +224,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getAnnotation(Field c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getAnnotation(Field c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) {
T f = c.getAnnotation(a);
p(id(f, c), f);
@@ -235,7 +234,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getDeclaredAnnotation(Field c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getDeclaredAnnotation(Field c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) {
T f = c.getDeclaredAnnotation(a);
p(id(f, c), f);
@@ -245,7 +244,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getAnnotation(Method c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getAnnotation(Method c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) {
T f = c.getAnnotation(a);
p(id(f, c), f);
@@ -255,7 +254,7 @@ public class Violator {
}
@SuppressWarnings("unchecked")
public static <T extends Annotation> T getDeclaredAnnotation(Method c, Class<? extends T> a) throws Throwable {
public static <T extends Annotation> T getDeclaredAnnotation(Method c, Class<? extends T> a) {
if (!h("@" + a.getCanonicalName() + "[" + id(c, null) + "]")) {
T f = c.getDeclaredAnnotation(a);
p(id(f, c), f);

View File

@@ -44,7 +44,7 @@ public class VirtualCommand {
public VirtualCommand(ICommand command, String tag) {
this.command = command;
children = new KMap<KList<String>, VirtualCommand>();
children = new KMap<>();
this.tag = tag;
for (Field i : command.getClass().getDeclaredFields()) {
@@ -117,7 +117,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]));
}
public KList<String> hitTab(CommandSender sender, KList<String> chain, String label) {
@@ -156,9 +156,10 @@ public class VirtualCommand {
return null;
}
return command.handleTab(vs, chain.toArray(new String[chain.size()]));
return command.handleTab(vs, chain.toArray(new String[0]));
}
@SuppressWarnings("BooleanMethodIsAlwaysInverted")
private boolean checkPermissions(CommandSender sender, ICommand command2) {
boolean failed = false;

View File

@@ -18,12 +18,11 @@
package com.volmit.iris.util;
import java.io.IOException;
import java.io.OutputStream;
public class VoidOutputStream extends OutputStream {
@Override
public void write(int b) throws IOException {
public void write(int b) {
// poof
}
}

View File

@@ -45,8 +45,9 @@ import java.util.List;
import java.util.Map;
import java.util.SortedSet;
@SuppressWarnings("EmptyMethod")
public abstract class VolmitPlugin extends JavaPlugin implements Listener {
public static boolean bad = false;
public static final boolean bad = false;
private KMap<KList<String>, VirtualCommand> commands;
private KList<MortarCommand> commandCache;
private KList<MortarPermission> permissionCache;
@@ -70,14 +71,17 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
Field pluginsField = Bukkit.getPluginManager().getClass().getDeclaredField("plugins");
pluginsField.setAccessible(true);
//noinspection unchecked
plugins = (List<Plugin>) pluginsField.get(getServer().getPluginManager());
Field lookupNamesField = Bukkit.getPluginManager().getClass().getDeclaredField("lookupNames");
lookupNamesField.setAccessible(true);
//noinspection unchecked
names = (Map<String, Plugin>) lookupNamesField.get(getServer().getPluginManager());
try {
Field listenersField = Bukkit.getPluginManager().getClass().getDeclaredField("listeners");
listenersField.setAccessible(true);
//noinspection unchecked
listeners = (Map<Event, SortedSet<RegisteredListener>>) listenersField.get(getServer().getPluginManager());
} catch (Throwable ignored) {
@@ -88,9 +92,10 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
commandMap = (SimpleCommandMap) commandMapField.get(getServer().getPluginManager());
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
knownCommandsField.setAccessible(true);
//noinspection unchecked
commands = (Map<String, Command>) knownCommandsField.get(commandMap);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
@@ -106,8 +111,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
for (Iterator<Map.Entry<String, Command>> it = commands.entrySet().iterator(); it.hasNext(); ) {
Map.Entry<String, Command> entry = it.next();
if (entry.getValue() instanceof PluginCommand) {
PluginCommand c = (PluginCommand) entry.getValue();
if (entry.getValue() instanceof PluginCommand c) {
if (c.getPlugin() == plugin) {
c.unregister(commandMap);
it.remove();
@@ -163,7 +167,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
registerCommands();
registerControllers();
Bukkit.getScheduler().scheduleSyncRepeatingTask(this, this::tickControllers, 0, 0);
J.a(() -> outputInfo());
J.a(this::outputInfo);
registerListener(this);
start();
}
@@ -183,7 +187,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
outputPluginInfo();
outputCommandInfo();
outputPermissionInfo();
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@@ -199,7 +203,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
}
private void chain(MortarPermission i, FileConfiguration fc) {
KList<String> ff = new KList<String>();
KList<String> ff = new KList<>();
for (MortarPermission j : i.getChildren()) {
ff.add(j.getFullNode());
@@ -264,7 +268,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
for (org.bukkit.permissions.Permission i : computePermissions()) {
try {
Bukkit.getPluginManager().addPermission(i);
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@@ -482,7 +486,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
@Override
public List<String> onTabComplete(@NotNull CommandSender sender, @NotNull Command command,
@NotNull String alias, @NotNull String[] args) {
KList<String> chain = new KList<String>();
KList<String> chain = new KList<>();
for (String i : args) {
if (i.trim().isEmpty()) {
@@ -509,12 +513,12 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
}
@Override
public boolean onCommand(CommandSender sender, org.bukkit.command.Command command, String label, String[] args) {
public boolean onCommand(@NotNull CommandSender sender, @NotNull org.bukkit.command.Command command, @NotNull String label, @NotNull String[] args) {
if (bad) {
return false;
}
KList<String> chain = new KList<String>();
KList<String> chain = new KList<>();
chain.add(args);
for (KList<String> i : commands.k()) {
@@ -619,7 +623,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
for (VirtualCommand i : commands.v()) {
try {
unregisterCommand(i.getCommand());
} catch (Throwable e) {
} catch (Throwable ignored) {
}
}
@@ -652,13 +656,13 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
}
public File getDataFile(String... strings) {
File f = new File(getDataFolder(), new KList<String>(strings).toString(File.separator));
File f = new File(getDataFolder(), new KList<>(strings).toString(File.separator));
f.getParentFile().mkdirs();
return f;
}
public File getDataFileList(String pre, String[] strings) {
KList<String> v = new KList<String>(strings);
KList<String> v = new KList<>(strings);
v.add(0, pre);
File f = new File(getDataFolder(), v.toString(File.separator));
f.getParentFile().mkdirs();
@@ -670,7 +674,7 @@ public abstract class VolmitPlugin extends JavaPlugin implements Listener {
return super.getDataFolder();
}
File f = new File(getDataFolder(), new KList<String>(strings).toString(File.separator));
File f = new File(getDataFolder(), new KList<>(strings).toString(File.separator));
f.mkdirs();
return f;

Some files were not shown because too many files have changed in this diff Show More