From fff7cd53cc9f7af30295f96308d3c7d44be6d26c Mon Sep 17 00:00:00 2001 From: Daniel Mills Date: Thu, 5 Aug 2021 18:42:17 -0400 Subject: [PATCH] INMS Drop 1.16 --- build.gradle | 4 - .../java/com/volmit/iris/core/nms/INMS.java | 8 +- .../iris/core/nms/v16_1/NMSBinding16_1.java | 162 ----------- .../iris/core/nms/v16_2/NMSBinding16_2.java | 267 ------------------ .../iris/core/nms/v16_3/NMSBinding16_3.java | 267 ------------------ 5 files changed, 1 insertion(+), 707 deletions(-) delete mode 100644 src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java delete mode 100644 src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java delete mode 100644 src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java diff --git a/build.gradle b/build.gradle index 883a280e9..7364e48e0 100644 --- a/build.gradle +++ b/build.gradle @@ -125,11 +125,7 @@ dependencies { compileOnly 'org.projectlombok:lombok:1.18.20' annotationProcessor 'org.projectlombok:lombok:1.18.20' implementation 'org.spigotmc:spigot-api:1.17-R0.1-SNAPSHOT' - implementation 'org.bukkit.craftbukkit:1.17:1.17' implementation 'org.bukkit.craftbukkit:1.17.1:1.17.1' - implementation 'org.bukkit.craftbukkit:1.16.5:1.16.5' - implementation 'org.bukkit.craftbukkit:1.16.3:1.16.3' - implementation 'org.bukkit.craftbukkit:1.16.1:1.16.1' implementation 'com.sk89q.worldedit:worldedit-bukkit:7.2.0-SNAPSHOT' implementation 'me.clip:placeholderapi:2.10.10' diff --git a/src/main/java/com/volmit/iris/core/nms/INMS.java b/src/main/java/com/volmit/iris/core/nms/INMS.java index 9843c4ab1..f624fa418 100644 --- a/src/main/java/com/volmit/iris/core/nms/INMS.java +++ b/src/main/java/com/volmit/iris/core/nms/INMS.java @@ -20,9 +20,6 @@ package com.volmit.iris.core.nms; import com.volmit.iris.Iris; import com.volmit.iris.core.IrisSettings; -import com.volmit.iris.core.nms.v16_1.NMSBinding16_1; -import com.volmit.iris.core.nms.v16_2.NMSBinding16_2; -import com.volmit.iris.core.nms.v16_3.NMSBinding16_3; import com.volmit.iris.core.nms.v17_1.NMSBinding17_1; import com.volmit.iris.core.nms.v1X.NMSBinding1X; import com.volmit.iris.util.collection.KMap; @@ -31,10 +28,7 @@ import org.bukkit.Bukkit; public class INMS { //@builder private static final KMap> bindings = new KMap>() - .qput("v1_17_R1", NMSBinding17_1.class) - .qput("v1_16_R3", NMSBinding16_3.class) - .qput("v1_16_R2", NMSBinding16_2.class) - .qput("v1_16_R1", NMSBinding16_1.class); + .qput("v1_17_R1", NMSBinding17_1.class); //@done private static final INMSBinding binding = bind(); diff --git a/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java b/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java deleted file mode 100644 index 2c05fe5c1..000000000 --- a/src/main/java/com/volmit/iris/core/nms/v16_1/NMSBinding16_1.java +++ /dev/null @@ -1,162 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.volmit.iris.core.nms.v16_1; - -import com.volmit.iris.Iris; -import com.volmit.iris.core.nms.INMSBinding; -import com.volmit.iris.util.collection.KMap; -import net.minecraft.server.v1_16_R1.BiomeBase; -import net.minecraft.server.v1_16_R1.IRegistryWritable; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.craftbukkit.v1_16_R1.CraftWorld; -import org.bukkit.generator.ChunkGenerator; - -import java.lang.reflect.Field; - -public class NMSBinding16_1 implements INMSBinding { - private final KMap baseBiomeCache = new KMap<>(); - private Field biomeStorageCache = null; - - public boolean supportsDataPacks() { - return true; - } - - private Field getFieldForBiomeStorage(Object storage) { - Field f = biomeStorageCache; - - if (f != null) { - return f; - } - try { - - f = storage.getClass().getDeclaredField("biome"); - f.setAccessible(true); - return f; - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - Iris.error(storage.getClass().getCanonicalName()); - } - - biomeStorageCache = f; - return null; - } - - private IRegistryWritable getCustomBiomeRegistry() { - return null; - } - - @Override - public Object getBiomeBaseFromId(int id) { - return null; - } - - @Override - public int getMinHeight(World world) { - return 0; - } - - @Override - public boolean supportsCustomHeight() { - return false; - } - - @Override - public boolean supportsCustomBiomes() { - return false; - } - - @Override - public int getTrueBiomeBaseId(Object biomeBase) { - return -1; - } - - @Override - public Object getTrueBiomeBase(Location location) { - return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - @Override - public String getTrueBiomeBaseKey(Location location) { - return getKeyForBiomeBase(getTrueBiomeBase(location)); - } - - @Override - public Object getCustomBiomeBaseFor(String mckey) { - try { - return null; - } catch (Throwable e) { - Iris.reportError(e); - } - - return null; - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - @Override - public String getKeyForBiomeBase(Object biomeBase) { - return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); - } - - @Override - public Object getBiomeBase(World world, Biome biome) { - return null; // Can't find IRegistryCustom in 16_R1 - } - - @Override - public Object getBiomeBase(Object registry, Biome biome) { - Object v = baseBiomeCache.get(biome); - - if (v != null) { - return v; - } - //noinspection unchecked - v = org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock.biomeToBiomeBase(biome); - if (v == null) { - // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. - // But, this does NOT exist within CraftBukkit which makes it return an error. - // So, we will just return the ID that the plains biome returns instead. - return org.bukkit.craftbukkit.v1_16_R1.block.CraftBlock.biomeToBiomeBase(Biome.PLAINS); - } - baseBiomeCache.put(biome, v); - return v; - } - - @Override - public int getBiomeId(Biome biome) { - return -1; - } - - @Override - public int countCustomBiomes() { - return 0; - } - - @Override - public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { - - } - - @Override - public boolean isBukkit() { - return false; - } -} diff --git a/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java b/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java deleted file mode 100644 index 68e89f37e..000000000 --- a/src/main/java/com/volmit/iris/core/nms/v16_2/NMSBinding16_2.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.volmit.iris.core.nms.v16_2; - -import com.volmit.iris.Iris; -import com.volmit.iris.core.nms.INMSBinding; -import com.volmit.iris.util.collection.KMap; -import net.minecraft.server.v1_16_R2.*; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.craftbukkit.v1_16_R2.CraftServer; -import org.bukkit.craftbukkit.v1_16_R2.CraftWorld; -import org.bukkit.generator.ChunkGenerator; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicInteger; - -public class NMSBinding16_2 implements INMSBinding { - private final KMap baseBiomeCache = new KMap<>(); - private Field biomeStorageCache = null; - - public boolean supportsDataPacks() { - return true; - } - - private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) { - try { - return getFieldForBiomeStorage(g).get(g); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private Field getFieldForBiomeStorage(Object storage) { - Field f = biomeStorageCache; - - if (f != null) { - return f; - } - try { - - f = storage.getClass().getDeclaredField("biome"); - f.setAccessible(true); - return f; - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - Iris.error(storage.getClass().getCanonicalName()); - } - - biomeStorageCache = f; - return null; - } - - private IRegistryWritable getCustomBiomeRegistry() { - return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.ay); - } - - @Override - public Object getBiomeBaseFromId(int id) { - return getCustomBiomeRegistry().fromId(id); - } - - @Override - public int getTrueBiomeBaseId(Object biomeBase) { - return getCustomBiomeRegistry().a((BiomeBase) biomeBase); - } - - @Override - public Object getTrueBiomeBase(Location location) { - return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - @Override - public String getTrueBiomeBaseKey(Location location) { - return getKeyForBiomeBase(getTrueBiomeBase(location)); - } - - @Override - public Object getCustomBiomeBaseFor(String mckey) { - try { - return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.ay, new MinecraftKey(mckey))); - } catch (Throwable e) { - Iris.reportError(e); - } - - return null; - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - @Override - public String getKeyForBiomeBase(Object biomeBase) { - return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); - } - - @Override - public Object getBiomeBase(World world, Biome biome) { - return getBiomeBase(((CraftWorld) world).getHandle().r().b(IRegistry.ay), biome); - } - - @Override - public boolean supportsCustomBiomes() { - return false; - } - - @Override - public int getMinHeight(World world) { - return 0; - } - - @Override - public boolean supportsCustomHeight() { - return false; - } - - private Class[] classify(Object... par) { - Class[] g = new Class[par.length]; - for (int i = 0; i < g.length; i++) { - g[i] = par[i].getClass(); - } - - return g; - } - - private T invoke(Object from, String name, Object... par) { - try { - Method f = from.getClass().getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(from, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T invokeStatic(Class from, String name, Object... par) { - try { - Method f = from.getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(null, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getField(Object from, String name) { - try { - Field f = from.getClass().getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(from); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getStaticField(Class t, String name) { - try { - Field f = t.getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(null); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - @Override - public Object getBiomeBase(Object registry, Biome biome) { - Object v = baseBiomeCache.get(biome); - - if (v != null) { - return v; - } - //noinspection unchecked - v = org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); - if (v == null) { - // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. - // But, this does NOT exist within CraftBukkit which makes it return an error. - // So, we will just return the ID that the plains biome returns instead. - //noinspection unchecked - return org.bukkit.craftbukkit.v1_16_R2.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); - } - baseBiomeCache.put(biome, v); - return v; - } - - @Override - public int getBiomeId(Biome biome) { - for (World i : Bukkit.getWorlds()) { - if (i.getEnvironment().equals(World.Environment.NORMAL)) { - IRegistry registry = ((CraftWorld) i).getHandle().r().b(IRegistry.ay); - return registry.a((BiomeBase) getBiomeBase(registry, biome)); - } - } - - return biome.ordinal(); - } - - @Override - public int countCustomBiomes() { - AtomicInteger a = new AtomicInteger(0); - getCustomBiomeRegistry().d().forEach((i) -> { - MinecraftKey k = i.getKey().a(); - - if (k.getNamespace().equals("minecraft")) { - return; - } - - a.incrementAndGet(); - Iris.debug("Custom Biome: " + k); - }); - - return a.get(); - } - - @Override - public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { - try { - BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); - s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - } - - @Override - public boolean isBukkit() { - return false; - } -} diff --git a/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java b/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java deleted file mode 100644 index c65f5fa31..000000000 --- a/src/main/java/com/volmit/iris/core/nms/v16_3/NMSBinding16_3.java +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Iris is a World Generator for Minecraft Bukkit Servers - * Copyright (c) 2021 Arcane Arts (Volmit Software) - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ - -package com.volmit.iris.core.nms.v16_3; - -import com.volmit.iris.Iris; -import com.volmit.iris.core.nms.INMSBinding; -import com.volmit.iris.util.collection.KMap; -import net.minecraft.server.v1_16_R3.*; -import org.bukkit.Bukkit; -import org.bukkit.Location; -import org.bukkit.World; -import org.bukkit.block.Biome; -import org.bukkit.craftbukkit.v1_16_R3.CraftServer; -import org.bukkit.craftbukkit.v1_16_R3.CraftWorld; -import org.bukkit.generator.ChunkGenerator; - -import java.lang.reflect.Field; -import java.lang.reflect.Method; -import java.util.concurrent.atomic.AtomicInteger; - -public class NMSBinding16_3 implements INMSBinding { - private final KMap baseBiomeCache = new KMap<>(); - private Field biomeStorageCache = null; - - public boolean supportsDataPacks() { - return true; - } - - private Object getBiomeStorage(ChunkGenerator.BiomeGrid g) { - try { - return getFieldForBiomeStorage(g).get(g); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - @Override - public boolean supportsCustomHeight() { - return false; - } - - @Override - public int getMinHeight(World world) { - return 0; - } - - @Override - public boolean supportsCustomBiomes() { - return false; - } - - private Field getFieldForBiomeStorage(Object storage) { - Field f = biomeStorageCache; - - if (f != null) { - return f; - } - try { - - f = storage.getClass().getDeclaredField("biome"); - f.setAccessible(true); - return f; - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - Iris.error(storage.getClass().getCanonicalName()); - } - - biomeStorageCache = f; - return null; - } - - private IRegistryWritable getCustomBiomeRegistry() { - return ((CraftServer) Bukkit.getServer()).getHandle().getServer().getCustomRegistry().b(IRegistry.ay); - } - - @Override - public Object getBiomeBaseFromId(int id) { - return getCustomBiomeRegistry().fromId(id); - } - - @Override - public int getTrueBiomeBaseId(Object biomeBase) { - return getCustomBiomeRegistry().a((BiomeBase) biomeBase); - } - - @Override - public Object getTrueBiomeBase(Location location) { - return ((CraftWorld) location.getWorld()).getHandle().getBiome(location.getBlockX(), location.getBlockY(), location.getBlockZ()); - } - - @Override - public String getTrueBiomeBaseKey(Location location) { - return getKeyForBiomeBase(getTrueBiomeBase(location)); - } - - @Override - public Object getCustomBiomeBaseFor(String mckey) { - try { - return getCustomBiomeRegistry().d(ResourceKey.a(IRegistry.ay, new MinecraftKey(mckey))); - } catch (Throwable e) { - Iris.reportError(e); - } - - return null; - } - - @SuppressWarnings("OptionalGetWithoutIsPresent") - @Override - public String getKeyForBiomeBase(Object biomeBase) { - return getCustomBiomeRegistry().c((BiomeBase) biomeBase).get().a().toString(); - } - - @Override - public Object getBiomeBase(World world, Biome biome) { - return getBiomeBase(((CraftWorld) world).getHandle().r().b(IRegistry.ay), biome); - } - - private Class[] classify(Object... par) { - Class[] g = new Class[par.length]; - for (int i = 0; i < g.length; i++) { - g[i] = par[i].getClass(); - } - - return g; - } - - private T invoke(Object from, String name, Object... par) { - try { - Method f = from.getClass().getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(from, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T invokeStatic(Class from, String name, Object... par) { - try { - Method f = from.getDeclaredMethod(name, classify(par)); - f.setAccessible(true); - //noinspection unchecked - return (T) f.invoke(null, par); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getField(Object from, String name) { - try { - Field f = from.getClass().getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(from); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - private T getStaticField(Class t, String name) { - try { - Field f = t.getDeclaredField(name); - f.setAccessible(true); - //noinspection unchecked - return (T) f.get(null); - } catch (Throwable e) { - Iris.reportError(e); - e.printStackTrace(); - } - - return null; - } - - @Override - public Object getBiomeBase(Object registry, Biome biome) { - Object v = baseBiomeCache.get(biome); - - if (v != null) { - return v; - } - //noinspection unchecked - v = org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, biome); - if (v == null) { - // Ok so there is this new biome name called "CUSTOM" in Paper's new releases. - // But, this does NOT exist within CraftBukkit which makes it return an error. - // So, we will just return the ID that the plains biome returns instead. - //noinspection unchecked - return org.bukkit.craftbukkit.v1_16_R3.block.CraftBlock.biomeToBiomeBase((IRegistry) registry, Biome.PLAINS); - } - baseBiomeCache.put(biome, v); - return v; - } - - @Override - public int getBiomeId(Biome biome) { - for (World i : Bukkit.getWorlds()) { - if (i.getEnvironment().equals(World.Environment.NORMAL)) { - IRegistry registry = ((CraftWorld) i).getHandle().r().b(IRegistry.ay); - return registry.a((BiomeBase) getBiomeBase(registry, biome)); - } - } - - return biome.ordinal(); - } - - @Override - public int countCustomBiomes() { - AtomicInteger a = new AtomicInteger(0); - getCustomBiomeRegistry().d().forEach((i) -> { - MinecraftKey k = i.getKey().a(); - - if (k.getNamespace().equals("minecraft")) { - return; - } - - a.incrementAndGet(); - Iris.debug("Custom Biome: " + k); - }); - - return a.get(); - } - - @Override - public void forceBiomeInto(int x, int y, int z, Object somethingVeryDirty, ChunkGenerator.BiomeGrid chunk) { - try { - BiomeStorage s = (BiomeStorage) getFieldForBiomeStorage(chunk).get(chunk); - s.setBiome(x, y, z, (BiomeBase) somethingVeryDirty); - } catch (IllegalAccessException e) { - Iris.reportError(e); - e.printStackTrace(); - } - } - - @Override - public boolean isBukkit() { - return false; - } -}