This commit is contained in:
Daniel Mills 2021-08-06 22:15:11 -04:00
parent a5ef5769b9
commit e9f4c3d0c7
35 changed files with 179 additions and 335 deletions

View File

@ -56,7 +56,6 @@ import com.volmit.iris.util.scheduling.J;
import com.volmit.iris.util.scheduling.Queue;
import com.volmit.iris.util.scheduling.ShurikenQueue;
import io.papermc.lib.PaperLib;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.serializer.ComponentSerializer;
import org.bukkit.Bukkit;
@ -73,7 +72,7 @@ import org.bukkit.plugin.Plugin;
import java.io.*;
import java.lang.annotation.Annotation;
import java.net.URL;
import java.util.*;
import java.util.Date;
@SuppressWarnings("CanBeFinal")
public class Iris extends VolmitPlugin implements Listener {
@ -443,13 +442,9 @@ public class Iris extends VolmitPlugin implements Listener {
try {
sender.sendMessage(string);
} catch (Throwable ignored) {
try
{
try {
System.out.println(string);
}
catch(Throwable ignored1)
{
} catch (Throwable ignored1) {
}
}

View File

@ -28,7 +28,6 @@ import com.volmit.iris.engine.object.objects.IrisDirection;
import com.volmit.iris.engine.object.objects.IrisObject;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import com.volmit.iris.util.format.Form;
import com.volmit.iris.util.function.Consumer2;
import com.volmit.iris.util.io.Converter;
@ -42,8 +41,6 @@ import com.volmit.iris.util.nbt.tag.IntTag;
import com.volmit.iris.util.nbt.tag.ListTag;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import net.kyori.adventure.text.minimessage.parser.Token;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.type.Jigsaw;

View File

@ -1,6 +1,5 @@
package com.volmit.iris.core;
import com.volmit.iris.Iris;
import com.volmit.iris.core.tools.IrisToolbelt;
import org.bukkit.Material;
import org.bukkit.entity.EntityType;

View File

@ -26,14 +26,12 @@ import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.format.C;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.matter.WorldMatter;
import com.volmit.iris.util.plugin.VolmitSender;
import com.volmit.iris.util.scheduling.J;
import org.bukkit.*;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -68,8 +66,7 @@ public class WandManager implements Listener {
}
public void tick(Player p) {
try
{
try {
try {
if (isWand(p.getInventory().getItemInMainHand())) {
Location[] d = getCuboid(p.getInventory().getItemInMainHand());
@ -78,10 +75,7 @@ public class WandManager implements Listener {
} catch (Throwable e) {
Iris.reportError(e);
}
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}
}

View File

@ -39,8 +39,7 @@ public class CommandIrisAura extends MortarCommand {
@Override
public boolean handle(VolmitSender sender, String[] args) {
try
{
try {
int h = Integer.parseInt(args[0]);
int s = Integer.parseInt(args[1]);
int b = Integer.parseInt(args[2]);
@ -49,10 +48,7 @@ public class CommandIrisAura extends MortarCommand {
IrisSettings.get().getGeneral().setSpinb(b);
IrisSettings.get().forceSave();
sender.sendMessage("<rainbow>Aura Spins updated to " + h + " " + s + " " + b);
}
catch(Throwable b)
{
} catch (Throwable b) {
sender.sendMessage(getArgsUsage());
}

View File

@ -19,7 +19,6 @@
package com.volmit.iris.core.command;
import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.tools.IrisToolbelt;
import com.volmit.iris.engine.IrisEngine;
import com.volmit.iris.util.collection.KList;

View File

@ -22,7 +22,6 @@ import com.volmit.iris.Iris;
import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.core.WandManager;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.matter.IrisMatter;
import com.volmit.iris.util.matter.Matter;
import com.volmit.iris.util.plugin.MortarCommand;
import com.volmit.iris.util.plugin.VolmitSender;

View File

@ -60,23 +60,19 @@ public class CommandIrisStudioUpdate extends MortarCommand {
return true;
}
for(String i : args)
{
if(i.equals("--rewrite-objects"))
{
for (String i : args) {
if (i.equals("--rewrite-objects")) {
IrisData data = new IrisData(Iris.proj.getWorkspaceFolder(args[0]));
int t = data.getObjectLoader().getPossibleKeys().length;
ChronoLatch cl = new ChronoLatch(250, false);
MultiBurst bx = new MultiBurst("Object Rewriter", Thread.MIN_PRIORITY, Runtime.getRuntime().availableProcessors());
BurstExecutor b = bx.burst();
int g = 0;
for(String f : data.getObjectLoader().getPossibleKeys())
{
for (String f : data.getObjectLoader().getPossibleKeys()) {
int finalG1 = g;
b.queue(() -> {
if(cl.flip())
{
if (cl.flip()) {
Iris.info("Rewriting: " + Form.f(t - finalG1) + " Objects Left");
}
File ff = data.getObjectLoader().findFile(f);
@ -88,8 +84,7 @@ public class CommandIrisStudioUpdate extends MortarCommand {
return;
}
if(oo == null)
{
if (oo == null) {
Iris.error("FAILER TO READ: " + f);
return;
}

View File

@ -31,11 +31,13 @@ public class MythicMobsLink {
/**
* Spawn a mythic mob at this location
*
* @param mob The mob
* @param location The location
* @return The mob, or null if it can't be spawned
*/
public @Nullable Entity spawnMob(String mob, Location location) {
public @Nullable
Entity spawnMob(String mob, Location location) {
if (!isEnabled()) return null;
if (spawnMobFunction != null) {

View File

@ -18,11 +18,7 @@
package com.volmit.iris.core.link;
import com.volmit.iris.Iris;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.B;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.OraxenItems;
import io.th0rgal.oraxen.mechanics.Mechanic;
import io.th0rgal.oraxen.mechanics.MechanicFactory;
@ -33,7 +29,6 @@ import io.th0rgal.oraxen.mechanics.provided.gameplay.noteblock.NoteBlockMechanic
import io.th0rgal.oraxen.utils.Utils;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.data.BlockData;
import org.bukkit.block.data.MultipleFacing;
import org.bukkit.plugin.Plugin;
@ -49,28 +44,22 @@ public class OraxenLink {
}
public BlockData getBlockDataFor(String id) {
if(!supported())
{
if (!supported()) {
return null;
}
MechanicFactory f = getFactory(id);
if(f == null)
{
if (f == null) {
return null;
}
Mechanic m = f.getMechanic(id);
// TODO: Why isnt there a simple getBlockData() function?
if(m.getFactory() instanceof NoteBlockMechanicFactory)
{
if (m.getFactory() instanceof NoteBlockMechanicFactory) {
return ((NoteBlockMechanicFactory) m.getFactory()).createNoteBlockData(id);
}
else if(m.getFactory() instanceof BlockMechanicFactory)
{
} else if (m.getFactory() instanceof BlockMechanicFactory) {
MultipleFacing newBlockData = (MultipleFacing) Bukkit.createBlockData(Material.MUSHROOM_STEM);
Utils.setBlockFacing(newBlockData, ((BlockMechanic) m).getCustomVariation());
return newBlockData;
@ -79,10 +68,8 @@ public class OraxenLink {
return null;
}
public MechanicFactory getFactory(String id)
{
if(!supported())
{
public MechanicFactory getFactory(String id) {
if (!supported()) {
return null;
}
@ -91,10 +78,8 @@ public class OraxenLink {
f.setAccessible(true);
Map<String, MechanicFactory> map = (Map<String, MechanicFactory>) f.get(null);
for(MechanicFactory i : map.values())
{
if(i.getItems().contains(id))
{
for (MechanicFactory i : map.values()) {
if (i.getItems().contains(id)) {
return i;
}
}
@ -106,17 +91,14 @@ public class OraxenLink {
}
public String[] getItemTypes() {
if(!supported())
{
if (!supported()) {
return EMPTY;
}
KList<String> v = new KList<>();
for(String i : OraxenItems.getItemNames())
{
if(getBlockDataFor(i) != null)
{
for (String i : OraxenItems.getItemNames()) {
if (getBlockDataFor(i) != null) {
v.add(i);
}
}

View File

@ -23,7 +23,6 @@ import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.block.Biome;
import org.bukkit.block.TileState;
import org.bukkit.entity.Entity;
import org.bukkit.generator.ChunkGenerator;

View File

@ -23,14 +23,17 @@ import com.volmit.iris.core.nms.INMSBinding;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import com.volmit.iris.util.nbt.tag.IntTag;
import net.minecraft.core.BlockPosition;
import net.minecraft.core.IRegistry;
import net.minecraft.core.IRegistryWritable;
import net.minecraft.nbt.*;
import net.minecraft.nbt.NBTCompressedStreamTools;
import net.minecraft.nbt.NBTTagCompound;
import net.minecraft.nbt.NBTTagDouble;
import net.minecraft.nbt.NBTTagList;
import net.minecraft.resources.MinecraftKey;
import net.minecraft.resources.ResourceKey;
import net.minecraft.server.level.WorldServer;
import net.minecraft.world.entity.Entity;
import net.minecraft.world.level.biome.BiomeBase;
import net.minecraft.world.level.block.entity.TileEntity;
import net.minecraft.world.level.block.state.IBlockData;
@ -44,7 +47,6 @@ import org.bukkit.block.Biome;
import org.bukkit.craftbukkit.v1_17_R1.CraftServer;
import org.bukkit.craftbukkit.v1_17_R1.CraftWorld;
import org.bukkit.craftbukkit.v1_17_R1.entity.CraftEntity;
import net.minecraft.world.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.generator.ChunkGenerator;
@ -81,8 +83,7 @@ public class NMSBinding17_1 implements INMSBinding {
public CompoundTag serializeTile(Location location) {
TileEntity e = ((CraftWorld) location.getWorld()).getHandle().getTileEntity(new BlockPosition(location.getBlockX(), location.getBlockY(), location.getBlockZ()), true);
if(e == null)
{
if (e == null) {
return null;
}
@ -95,8 +96,7 @@ public class NMSBinding17_1 implements INMSBinding {
public void deserializeTile(CompoundTag s, Location newPosition) {
NBTTagCompound c = convert(s);
if(c != null)
{
if (c != null) {
int x = newPosition.getBlockX();
int y = newPosition.getBlockY();
int z = newPosition.getBlockZ();
@ -109,8 +109,7 @@ public class NMSBinding17_1 implements INMSBinding {
}
}
private NBTTagCompound convert(CompoundTag tag)
{
private NBTTagCompound convert(CompoundTag tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
NBTUtil.write(tag, boas, false);
@ -118,18 +117,14 @@ public class NMSBinding17_1 implements INMSBinding {
NBTTagCompound c = NBTCompressedStreamTools.a((DataInput) din);
din.close();
return c;
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}
return null;
}
private CompoundTag convert(NBTTagCompound tag)
{
private CompoundTag convert(NBTTagCompound tag) {
try {
ByteArrayOutputStream boas = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(boas);

View File

@ -28,9 +28,6 @@ import com.volmit.iris.util.data.B;
import com.volmit.iris.util.json.JSONArray;
import com.volmit.iris.util.json.JSONObject;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import org.bukkit.material.MaterialData;
import org.bukkit.potion.PotionEffectType;
import java.awt.*;
@ -228,8 +225,7 @@ public class SchemaBuilder {
} else if (k.isAnnotationPresent(RegistryListSpecialEntity.class)) {
String key = "enum-reg-specialentity";
if(!definitions.containsKey(key))
{
if (!definitions.containsKey(key)) {
JSONObject j = new JSONObject();
KList<String> list = new KList<>();
list.addAll(Iris.linkMythicMobs.getMythicMobTypes().stream().map(s -> "MythicMobs:" + s).collect(Collectors.toList()));

View File

@ -18,7 +18,6 @@
package com.volmit.iris.core.wand;
import com.volmit.iris.Iris;
import com.volmit.iris.util.data.Cuboid;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
@ -33,23 +32,18 @@ public class WandSelection {
private final Cuboid c;
private final Player p;
public WandSelection(Cuboid c, Player p)
{
public WandSelection(Cuboid c, Player p) {
this.c = c;
this.p = p;
}
public void draw()
{
public void draw() {
double accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(c.getCenter()));
double dist = M.lerp(0.125, 3.5, accuracy);
for(double i = c.getLowerX()-1; i < c.getUpperX()+1; i+=0.25)
{
for(double j = c.getLowerY()-1; j < c.getUpperY()+1; j+=0.25)
{
for(double k = c.getLowerZ()-1; k < c.getUpperZ()+1; k+=0.25)
{
for (double i = c.getLowerX() - 1; i < c.getUpperX() + 1; i += 0.25) {
for (double j = c.getLowerY() - 1; j < c.getUpperY() + 1; j += 0.25) {
for (double k = c.getLowerZ() - 1; k < c.getUpperZ() + 1; k += 0.25) {
boolean ii = i == c.getLowerX() || i == c.getUpperX();
boolean jj = j == c.getLowerY() || j == c.getUpperY();
boolean kk = k == c.getLowerZ() || k == c.getUpperZ();
@ -85,28 +79,23 @@ public class WandSelection {
accuracy = M.lerpInverse(0, 64 * 64, p.getLocation().distanceSquared(a));
dist = M.lerp(0.125, 3.5, accuracy);
if(M.r(M.min(dist*5, 0.9D) * 0.995))
{
if (M.r(M.min(dist * 5, 0.9D) * 0.995)) {
continue;
}
if(ii && jj)
{
if (ii && jj) {
a.add(0, 0, RNG.r.d(-0.3, 0.3));
}
if(kk && jj)
{
if (kk && jj) {
a.add(RNG.r.d(-0.3, 0.3), 0, 0);
}
if(ii && kk)
{
if (ii && kk) {
a.add(0, RNG.r.d(-0.3, 0.3), 0);
}
if(p.getLocation().distanceSquared(a) < 256 * 256)
{
if (p.getLocation().distanceSquared(a) < 256 * 256) {
Color color = Color.getHSBColor((float) (0.5f + (Math.sin((i + j + k + (p.getTicksLived() / 2f)) / (20f)) / 2)), 1, 1);
int r = color.getRed();
int g = color.getGreen();

View File

@ -87,13 +87,11 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
looper = new Looper() {
@Override
protected long loop() {
if(M.ms() < charge)
{
if (M.ms() < charge) {
energy += 70;
}
if(cln.flip())
{
if (cln.flip()) {
engine.getEngineData().cleanup(getEngine());
}
@ -207,14 +205,12 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
.collect(Collectors.toList()))
.popRandom(RNG.r);
if(v != null && v.getReferenceSpawner() != null)
{
if (v != null && v.getReferenceSpawner() != null) {
int maxEntCount = v.getReferenceSpawner().getMaxEntitiesPerChunk();
for (Entity i : c.getEntities()) {
if (i instanceof LivingEntity) {
if(-maxEntCount <= 0)
{
if (-maxEntCount <= 0) {
return;
}
}
@ -228,36 +224,30 @@ public class IrisWorldManager extends EngineAssignedWorldManager {
private void spawn(Chunk c, IrisEntitySpawn i) {
boolean allow = true;
if(!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite())
{
if (!i.getReferenceSpawner().getMaximumRatePerChunk().isInfinite()) {
allow = false;
IrisEngineChunkData cd = getEngine().getEngineData().getChunk(c.getX(), c.getZ());
IrisEngineSpawnerCooldown sc = null;
for(IrisEngineSpawnerCooldown j : cd.getCooldowns())
{
if(j.getSpawner().equals(i.getReferenceSpawner().getLoadKey()))
{
for (IrisEngineSpawnerCooldown j : cd.getCooldowns()) {
if (j.getSpawner().equals(i.getReferenceSpawner().getLoadKey())) {
sc = j;
break;
}
}
if(sc == null)
{
if (sc == null) {
sc = new IrisEngineSpawnerCooldown();
sc.setSpawner(i.getReferenceSpawner().getLoadKey());
cd.getCooldowns().add(sc);
}
if(sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk()))
{
if (sc.canSpawn(i.getReferenceSpawner().getMaximumRatePerChunk())) {
sc.spawn(getEngine());
allow = true;
}
}
if(allow)
{
if (allow) {
int s = i.spawn(getEngine(), c, RNG.r);
actuallySpawned += s;
if (s > 0) {

View File

@ -21,9 +21,7 @@ package com.volmit.iris.engine.object.annotations;
import java.lang.annotation.Retention;
import java.lang.annotation.Target;
import static java.lang.annotation.ElementType.FIELD;
import static java.lang.annotation.ElementType.PARAMETER;
import static java.lang.annotation.ElementType.TYPE;
import static java.lang.annotation.ElementType.*;
import static java.lang.annotation.RetentionPolicy.RUNTIME;
@Retention(RUNTIME)

View File

@ -149,10 +149,8 @@ public class IrisBlockData extends IrisRegistrant {
});
}
private String keyify(String dat)
{
if(dat.contains(":"))
{
private String keyify(String dat) {
if (dat.contains(":")) {
return dat;
}

View File

@ -34,7 +34,6 @@ import com.volmit.iris.engine.object.carve.IrisCaveFluid;
import com.volmit.iris.engine.object.carve.IrisCaveLayer;
import com.volmit.iris.engine.object.carve.IrisCaverns;
import com.volmit.iris.engine.object.deposits.IrisDepositGenerator;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.engine.object.feature.IrisFeaturePositional;
import com.volmit.iris.engine.object.feature.IrisFeaturePotential;
import com.volmit.iris.engine.object.jigsaw.IrisJigsawStructure;
@ -47,6 +46,7 @@ import com.volmit.iris.engine.object.objects.IrisObjectPlacement;
import com.volmit.iris.engine.object.regional.IrisRegion;
import com.volmit.iris.engine.object.spawners.IrisSpawner;
import com.volmit.iris.engine.object.trees.IrisTreeSettings;
import com.volmit.iris.engine.object.villager.IrisVillagerOverride;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.data.DataProvider;
import com.volmit.iris.util.io.IO;

View File

@ -28,14 +28,11 @@ public class IrisEngineChunkData {
private long chunk;
private KList<IrisEngineSpawnerCooldown> cooldowns = new KList<>();
public void cleanup(Engine engine)
{
for(IrisEngineSpawnerCooldown i : getCooldowns().copy())
{
public void cleanup(Engine engine) {
for (IrisEngineSpawnerCooldown i : getCooldowns().copy()) {
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if(sp == null || i.canSpawn(sp.getMaximumRate()))
{
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
getCooldowns().remove(i);
}
}

View File

@ -20,7 +20,6 @@ package com.volmit.iris.engine.object.engine;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.engine.framework.Engine;
import com.volmit.iris.engine.object.meta.IrisEnchantment;
import com.volmit.iris.engine.object.spawners.IrisSpawner;
import com.volmit.iris.util.collection.KList;
import lombok.Data;
@ -31,20 +30,16 @@ public class IrisEngineData {
private KList<IrisEngineSpawnerCooldown> spawnerCooldowns = new KList<>();
private KList<IrisEngineChunkData> chunks = new KList<>();
public void removeChunk(int x, int z)
{
public void removeChunk(int x, int z) {
long k = Cache.key(x, z);
chunks.removeWhere((i) -> i.getChunk() == k);
}
public IrisEngineChunkData getChunk(int x, int z)
{
public IrisEngineChunkData getChunk(int x, int z) {
long k = Cache.key(x, z);
for(IrisEngineChunkData i : chunks)
{
if(i.getChunk() == k)
{
for (IrisEngineChunkData i : chunks) {
if (i.getChunk() == k) {
return i;
}
}
@ -56,22 +51,18 @@ public class IrisEngineData {
}
public void cleanup(Engine engine) {
for(IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy())
{
for (IrisEngineSpawnerCooldown i : getSpawnerCooldowns().copy()) {
IrisSpawner sp = engine.getData().getSpawnerLoader().load(i.getSpawner());
if(sp == null || i.canSpawn(sp.getMaximumRate()))
{
if (sp == null || i.canSpawn(sp.getMaximumRate())) {
getSpawnerCooldowns().remove(i);
}
}
for(IrisEngineChunkData i : chunks.copy())
{
for (IrisEngineChunkData i : chunks.copy()) {
i.cleanup(engine);
if(i.isEmpty())
{
if (i.isEmpty()) {
getChunks().remove(i);
}
}

View File

@ -348,8 +348,7 @@ public class IrisObject extends IrisRegistrant {
}
public void write(File file) throws IOException {
if(file == null)
{
if (file == null) {
return;
}

View File

@ -4,9 +4,7 @@ package com.volmit.iris.engine.object.villager;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.object.annotations.*;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.math.RNG;
import com.volmit.iris.util.scheduling.S;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.EqualsAndHashCode;
@ -103,6 +101,7 @@ public class IrisVillagerTrade {
/**
* Get the ingredients
*
* @return The list of 1 or 2 ingredients (depending on if ing2 is null)
*/
public List<ItemStack> getIngredients() {

View File

@ -572,15 +572,11 @@ public class B {
}
}
try
{
try {
for (String i : Iris.linkOraxen.getItemTypes()) {
bt.add("oraxen:" + i);
}
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
}

View File

@ -19,11 +19,6 @@
package com.volmit.iris.util.format;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.biome.IrisBiomeCustom;
import com.volmit.iris.util.math.M;
import com.volmit.iris.util.plugin.VolmitSender;
import net.kyori.adventure.text.minimessage.transformation.inbuild.FontTransformation;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.apache.commons.lang.Validate;
@ -31,8 +26,6 @@ import org.bukkit.ChatColor;
import org.bukkit.Color;
import org.bukkit.DyeColor;
import java.awt.color.ColorSpace;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
@ -337,6 +330,7 @@ public enum C {
C(char code, int intCode, boolean isFormat) {
this("^", code, intCode, false);
}
C(String token, char code, int intCode, boolean isFormat) {
this.code = code;
this.token = token.equalsIgnoreCase("^") ? "<" + name().toLowerCase(Locale.ROOT) + ">" : token;
@ -345,37 +339,31 @@ public enum C {
this.toString = new String(new char[]{COLOR_CHAR, code});
}
public static float[] spin(float[] c, int shift)
{
public static float[] spin(float[] c, int shift) {
return new float[]{spin(c[0], shift), spinc(c[1], shift), spinc(c[2], shift)};
}
public static float[] spin(float[] c, int a,int b, int d)
{
public static float[] spin(float[] c, int a, int b, int d) {
return new float[]{spin(c[0], a), spinc(c[1], b), spinc(c[2], d)};
}
public static float spin(float c, int shift)
{
public static float spin(float c, int shift) {
float g = ((((int) Math.floor(c * 360)) + shift) % 360) / 360F;
return g < 0 ? 1f - g : g;
}
public static float spinc(float c, int shift)
{
public static float spinc(float c, int shift) {
float g = ((((int) Math.floor(c * 255)) + shift)) / 255F;
return Math.max(0f, Math.min(g, 1f));
}
public static java.awt.Color spin(java.awt.Color c, int h, int s, int b)
{
public static java.awt.Color spin(java.awt.Color c, int h, int s, int b) {
float[] hsb = java.awt.Color.RGBtoHSB(c.getRed(), c.getGreen(), c.getBlue(), null);
hsb = spin(hsb, h, s, b);
return java.awt.Color.getHSBColor(hsb[0], hsb[1], hsb[2]);
}
public static String spinToHex(C color, int h, int s, int b)
{
public static String spinToHex(C color, int h, int s, int b) {
return "#" + Integer.toHexString(spin(color.awtColor(), h, s, b).getRGB()).substring(2);
}
@ -384,33 +372,26 @@ public enum C {
StringBuilder b = new StringBuilder();
boolean c = false;
for(char i : msg.toCharArray())
{
if(c)
{
for (char i : msg.toCharArray()) {
if (c) {
c = false;
C o = C.getByChar(i);
if(hrad != 0 || srad != 0 || vrad != 0)
{
if (hrad != 0 || srad != 0 || vrad != 0) {
b.append("<gradient:")
.append(spinToHex(o, hrad, srad, vrad))
.append(":")
.append(spinToHex(o, -hrad, -srad, -vrad))
.append(">");
}
else
{
} else {
b.append(C.getByChar(i).token);
}
continue;
}
if(i == C.COLOR_CHAR)
{
if (i == C.COLOR_CHAR) {
c = true;
continue;
}
@ -421,8 +402,7 @@ public enum C {
return b.toString();
}
public static String compress(String c)
{
public static String compress(String c) {
return BaseComponent.toLegacyText(TextComponent.fromLegacyText(c));
}
@ -455,8 +435,7 @@ public enum C {
return chatToHex(this);
}
public java.awt.Color awtColor()
{
public java.awt.Color awtColor() {
return java.awt.Color.decode(hex());
}

View File

@ -244,16 +244,12 @@ public interface Matter {
/**
* Remove any slices that are empty
*/
default void trimSlices()
{
default void trimSlices() {
Set<Class<?>> drop = null;
for(Class<?> i : getSliceTypes())
{
if(getSlice(i).getCount() == 0)
{
if(drop == null)
{
for (Class<?> i : getSliceTypes()) {
if (getSlice(i).getCount() == 0) {
if (drop == null) {
drop = new KSet<>();
}
@ -261,10 +257,8 @@ public interface Matter {
}
}
if(drop != null)
{
for(Class<?> i : drop)
{
if (drop != null) {
for (Class<?> i : drop) {
deleteSlice(i);
}
}
@ -325,16 +319,12 @@ public interface Matter {
while (sliceCount-- > 0) {
String cn = din.readUTF();
try
{
try {
Class<?> type = Class.forName(cn);
MatterSlice<?> slice = matter.createSlice(type, matter);
slice.read(din);
matter.putSlice(type, slice);
}
catch(Throwable e)
{
} catch (Throwable e) {
e.printStackTrace();
throw new IOException("Can't read class '" + cn + "' (slice count reverse at " + sliceCount + ")");
}

View File

@ -19,8 +19,6 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import lombok.AllArgsConstructor;
import lombok.Data;
@Data

View File

@ -18,7 +18,6 @@
package com.volmit.iris.util.matter;
import com.volmit.iris.Iris;
import com.volmit.iris.engine.data.cache.Cache;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.hunk.Hunk;
@ -89,8 +88,7 @@ public interface MatterSlice<T> extends Hunk<T> {
for (int k = z; k < z + getDepth(); k++) {
T v = ejector.readMatter(w, i, j, k);
if(v != null)
{
if (v != null) {
set(i - x, j - y, k - z, v);
}
}

View File

@ -24,26 +24,21 @@ import org.bukkit.Location;
import org.bukkit.block.data.BlockData;
public class WorldMatter {
public static void placeMatter(Matter matter, Location at)
{
if(matter.hasSlice(BlockData.class))
{
public static void placeMatter(Matter matter, Location at) {
if (matter.hasSlice(BlockData.class)) {
matter.slice(BlockData.class).writeInto(at);
}
if(matter.hasSlice(MatterEntityGroup.class))
{
if (matter.hasSlice(MatterEntityGroup.class)) {
matter.slice(MatterEntityGroup.class).writeInto(at);
}
if(matter.hasSlice(MatterTile.class))
{
if (matter.hasSlice(MatterTile.class)) {
matter.slice(MatterTile.class).writeInto(at);
}
}
public static Matter createMatter(String author, Location a, Location b)
{
public static Matter createMatter(String author, Location a, Location b) {
Cuboid c = new Cuboid(a, b);
Matter s = new IrisMatter(c.getSizeX(), c.getSizeY(), c.getSizeZ());
Iris.info(s.getWidth() + " " + s.getHeight() + " " + s.getDepth());

View File

@ -18,13 +18,15 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.Iris;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.object.basic.IrisPosition;
import com.volmit.iris.util.collection.KList;
import com.volmit.iris.util.collection.KMap;
import com.volmit.iris.util.data.Varint;
import com.volmit.iris.util.matter.*;
import com.volmit.iris.util.matter.MatterEntity;
import com.volmit.iris.util.matter.MatterEntityGroup;
import com.volmit.iris.util.matter.MatterReader;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
import com.volmit.iris.util.nbt.tag.CompoundTag;
import org.bukkit.Location;
@ -47,8 +49,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
public EntityMatter(int width, int height, int depth) {
super(width, height, depth, MatterEntityGroup.class);
registerWriter(World.class, ((w, d, x, y, z) -> {
for(MatterEntity i : d.getEntities())
{
for (MatterEntity i : d.getEntities()) {
Location realPosition = new Location(w, x + i.getXOff(), y + i.getYOff(), z + i.getZOff());
INMS.get().deserializeEntity(i.getEntityData(), realPosition);
}
@ -57,10 +58,8 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
IrisPosition pos = new IrisPosition(x, y, z);
KList<Entity> entities = entityCache.get(pos);
MatterEntityGroup g = new MatterEntityGroup();
if(entities != null)
{
for(Entity i : entities)
{
if (entities != null) {
for (Entity i : entities) {
g.getEntities().add(new MatterEntity(
Math.abs(i.getLocation().getX()) - Math.abs(i.getLocation().getBlockX()),
Math.abs(i.getLocation().getY()) - Math.abs(i.getLocation().getBlockY()),
@ -81,6 +80,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
* across every block position, we simply use getNearbyEntities and cache each
* block position with a list of entities within that block, and directly feed
* the reader with the entities we capture.
*
* @param w the world
* @param x the x offset
* @param y the y offset
@ -90,8 +90,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
*/
@Override
public synchronized <W> boolean readFrom(W w, int x, int y, int z) {
if(!(w instanceof World))
{
if (!(w instanceof World)) {
return super.readFrom(w, x, y, z);
}
@ -103,18 +102,15 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
entityCache = new KMap<>();
for(Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight())))
{
for (Entity i : ((World) w).getNearbyEntities(new BoundingBox(x, y, z, x + getWidth(), y + getHeight(), z + getHeight()))) {
entityCache.compute(new IrisPosition(i.getLocation()),
(k, v) -> v == null ? new KList<>() : v).add(i);
}
for(IrisPosition i : entityCache.keySet())
{
for (IrisPosition i : entityCache.keySet()) {
MatterEntityGroup g = reader.readMatter(w, i.getX(), i.getY(), i.getZ());
if(g != null)
{
if (g != null) {
set(i.getX() - x, i.getY() - y, i.getZ() - z, g);
}
}
@ -127,8 +123,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
@Override
public void writeNode(MatterEntityGroup b, DataOutputStream dos) throws IOException {
Varint.writeUnsignedVarInt(b.getEntities().size(), dos);
for(MatterEntity i : b.getEntities())
{
for (MatterEntity i : b.getEntities()) {
dos.writeByte((int) (i.getXOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int) (i.getYOff() * 255) + Byte.MIN_VALUE);
dos.writeByte((int) (i.getZOff() * 255) + Byte.MIN_VALUE);
@ -141,8 +136,7 @@ public class EntityMatter extends RawMatter<MatterEntityGroup> {
MatterEntityGroup g = new MatterEntityGroup();
int c = Varint.readUnsignedVarInt(din);
while(c-- > 0)
{
while (c-- > 0) {
g.getEntities().add(new MatterEntity(
((int) din.readByte() - Byte.MIN_VALUE) / 255F,
((int) din.readByte() - Byte.MIN_VALUE) / 255F,

View File

@ -19,8 +19,6 @@
package com.volmit.iris.util.matter.slices;
import com.volmit.iris.core.nms.INMS;
import com.volmit.iris.engine.parallax.ParallaxAccess;
import com.volmit.iris.engine.parallax.ParallaxWorld;
import com.volmit.iris.util.matter.MatterTile;
import com.volmit.iris.util.matter.Sliced;
import com.volmit.iris.util.nbt.io.NBTUtil;
@ -43,12 +41,10 @@ public class TileMatter extends RawMatter<MatterTile> {
registerWriter(World.class, ((w, d, x, y, z) -> INMS.get().deserializeTile(d.getTileData(), new Location(w, x, y, z))));
registerReader(World.class, (w, x, y, z) -> {
Location l = new Location(w, x, y, z);
if(INMS.get().hasTile(l))
{
if (INMS.get().hasTile(l)) {
CompoundTag tag = INMS.get().serializeTile(l);
if(tag != null)
{
if (tag != null) {
return new MatterTile(tag);
}
}

View File

@ -23,13 +23,8 @@ import com.volmit.iris.core.IrisSettings;
import com.volmit.iris.util.format.C;
import lombok.Getter;
import lombok.Setter;
import net.kyori.adventure.Adventure;
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.minimessage.transformation.inbuild.GradientTransformation;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -188,22 +183,17 @@ public class VolmitSender implements CommandSender {
@Override
public void sendMessage(String message) {
if(message.contains("<NOMINI>"))
{
if (message.contains("<NOMINI>")) {
s.sendMessage(message.replaceAll("\\Q<NOMINI>\\E", ""));
return;
}
try
{
try {
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());
Component c = MiniMessage.get().parse(a);
Iris.audiences.sender(s).sendMessage(c);
}
catch(Throwable e)
{
} catch (Throwable e) {
String t = C.translateAlternateColorCodes('&', getTag() + message);
String a = C.aura(t, IrisSettings.get().getGeneral().getSpinh(), IrisSettings.get().getGeneral().getSpins(), IrisSettings.get().getGeneral().getSpinb());

View File

@ -19,8 +19,7 @@
package com.volmit.iris.util.reflect;
public class ShadeFix {
public static void fix(Class<?> c)
{
public static void fix(Class<?> c) {
c.getCanonicalName();
}
}