diff --git a/README.md b/README.md index 810fe4c..c15c284 100644 --- a/README.md +++ b/README.md @@ -1,3 +1,3 @@ # DE-ArenaRegen -Read more about this resource here: [coming soon] +Read more about this resource here: https://www.spigotmc.org/resources/duels-extension-arenaregen.59686/ diff --git a/build.gradle b/build.gradle index dfb3412..55d2a5b 100644 --- a/build.gradle +++ b/build.gradle @@ -30,19 +30,12 @@ repositories { name 'jitpack-repo' url 'https://jitpack.io' } - - flatDir { - dirs 'libs' - } } dependencies { compile 'org.projectlombok:lombok:1.16.20' compile 'org.spigotmc:spigot-api:1.13-R0.1-SNAPSHOT' compile 'com.github.RealizedMC.Duels:duels-api:v3.1.2' - compile name: 'spigot-1.7.10' - compile name: 'spigot-1.12.2' - compile name: 'spigot-1.13' } jar { diff --git a/libs/spigot-1.12.2.jar b/libs/spigot-1.12.2.jar deleted file mode 100644 index 2b40f63..0000000 Binary files a/libs/spigot-1.12.2.jar and /dev/null differ diff --git a/libs/spigot-1.13.jar b/libs/spigot-1.13.jar deleted file mode 100644 index 435b221..0000000 Binary files a/libs/spigot-1.13.jar and /dev/null differ diff --git a/libs/spigot-1.7.10.jar b/libs/spigot-1.7.10.jar deleted file mode 100644 index ca1ea23..0000000 Binary files a/libs/spigot-1.7.10.jar and /dev/null differ diff --git a/src/main/java/me/realized/de/arenaregen/util/compat/CompatUtil.java b/src/main/java/me/realized/de/arenaregen/util/compat/CompatUtil.java index 0c88213..b057b97 100644 --- a/src/main/java/me/realized/de/arenaregen/util/compat/CompatUtil.java +++ b/src/main/java/me/realized/de/arenaregen/util/compat/CompatUtil.java @@ -3,7 +3,7 @@ import me.realized.de.arenaregen.util.NumberUtil; import org.bukkit.Bukkit; -public final class CompatUtil { +final class CompatUtil { private static final int SUB_VERSION; @@ -14,11 +14,11 @@ public final class CompatUtil { private CompatUtil() {} - public static boolean isPre1_8() { + static boolean isPre1_8() { return SUB_VERSION < 8; } - public static boolean isPre1_13() { + static boolean isPre1_13() { return SUB_VERSION < 13; } } diff --git a/src/main/java/me/realized/de/arenaregen/util/compat/NMSUtil.java b/src/main/java/me/realized/de/arenaregen/util/compat/NMSUtil.java index ba6078f..399ecc8 100644 --- a/src/main/java/me/realized/de/arenaregen/util/compat/NMSUtil.java +++ b/src/main/java/me/realized/de/arenaregen/util/compat/NMSUtil.java @@ -12,38 +12,38 @@ public final class NMSUtil { private static Constructor BLOCK_POS_CONSTRUCTOR; - private static Object SKY_BLOCK_ENUM; - private static Method GET_HANDLE_WORLD; - private static Method C_17; - private static Method C; - private static Method GET_HANDLE; - private static Method FROM_LEGACY_DATA; - private static Method GET_BLOCK_DATA; - private static Method GET_BLOCK; - private static Method SET_BLOCK_7; - private static Method SET_BLOCK_12; - private static Method SET_BLOCK; + private static Object BLOCK_ENUM; + private static Method WORLD_GET_HANDLE; + private static Method WORLD_C_17; + private static Method WORLD_C; + private static Method CHUNK_GET_HANDLE; + private static Method BLOCK_FROM_LEGACY_DATA; + private static Method BLOCK_GET_DATA; + private static Method MAGIC_GET_BLOCK; + private static Method CHUNK_SET_BLOCK_7; + private static Method CHUNK_SET_BLOCK_12; + private static Method CHUNK_SET_BLOCK; static { try { final Class BLOCK_POS = ReflectionUtil.getNMSClass("BlockPosition"); BLOCK_POS_CONSTRUCTOR = ReflectionUtil.getConstructor(BLOCK_POS, Double.TYPE, Double.TYPE, Double.TYPE); - GET_HANDLE_WORLD = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("CraftWorld"), "getHandle"); + WORLD_GET_HANDLE = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("CraftWorld"), "getHandle"); final Class WORLD = ReflectionUtil.getNMSClass("World"); final Class ENUM_SKY_BLOCK = ReflectionUtil.getNMSClass("EnumSkyBlock"); - C = ReflectionUtil.getMethod(WORLD, "c", ENUM_SKY_BLOCK, BLOCK_POS); - C_17 = ReflectionUtil.getMethod(WORLD, "c", ENUM_SKY_BLOCK, Integer.TYPE, Integer.TYPE, Integer.TYPE); - SKY_BLOCK_ENUM = ReflectionUtil.getEnumConstant(ENUM_SKY_BLOCK, 1); - GET_HANDLE = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("CraftChunk"), "getHandle"); + WORLD_C = ReflectionUtil.getMethod(WORLD, "c", ENUM_SKY_BLOCK, BLOCK_POS); + WORLD_C_17 = ReflectionUtil.getMethod(WORLD, "c", ENUM_SKY_BLOCK, Integer.TYPE, Integer.TYPE, Integer.TYPE); + BLOCK_ENUM = ReflectionUtil.getEnumConstant(ENUM_SKY_BLOCK, 1); + CHUNK_GET_HANDLE = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("CraftChunk"), "getHandle"); final Class BLOCK = ReflectionUtil.getNMSClass("Block"); - FROM_LEGACY_DATA = ReflectionUtil.getMethod(BLOCK, "fromLegacyData", Integer.TYPE); - GET_BLOCK_DATA = ReflectionUtil.getMethod(BLOCK, "getBlockData"); - GET_BLOCK = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("util.CraftMagicNumbers"), "getBlock", Material.class); + BLOCK_FROM_LEGACY_DATA = ReflectionUtil.getMethod(BLOCK, "fromLegacyData", Integer.TYPE); + BLOCK_GET_DATA = ReflectionUtil.getMethod(BLOCK, "getBlockData"); + MAGIC_GET_BLOCK = ReflectionUtil.getMethod(ReflectionUtil.getCBClass("util.CraftMagicNumbers"), "getBlock", Material.class); final Class CHUNK = ReflectionUtil.getNMSClass("Chunk"); - SET_BLOCK_7 = ReflectionUtil.getMethod(CHUNK, "a", Integer.TYPE, Integer.TYPE, Integer.TYPE, BLOCK, Integer.TYPE); + CHUNK_SET_BLOCK_7 = ReflectionUtil.getMethod(CHUNK, "a", Integer.TYPE, Integer.TYPE, Integer.TYPE, BLOCK, Integer.TYPE); final Class BLOCK_DATA = ReflectionUtil.getNMSClass("IBlockData"); - SET_BLOCK_12 = ReflectionUtil.getMethod(CHUNK, "a", BLOCK_POS, BLOCK_DATA); - SET_BLOCK = ReflectionUtil.getMethod(CHUNK, "a", BLOCK_POS, BLOCK_DATA, Boolean.TYPE); + CHUNK_SET_BLOCK_12 = ReflectionUtil.getMethod(CHUNK, "a", BLOCK_POS, BLOCK_DATA); + CHUNK_SET_BLOCK = ReflectionUtil.getMethod(CHUNK, "a", BLOCK_POS, BLOCK_DATA, Boolean.TYPE); } catch (Throwable ex) { ex.printStackTrace(); } @@ -56,32 +56,32 @@ public static void setBlockFast(final Block block, final Material material, fina final int z = block.getZ(); try { - final Object chunkHandle = GET_HANDLE.invoke(chunk); - Object nmsBlock = GET_BLOCK.invoke(null, material); + final Object chunkHandle = CHUNK_GET_HANDLE.invoke(chunk); + Object nmsBlock = MAGIC_GET_BLOCK.invoke(null, material); if (CompatUtil.isPre1_8()) { - SET_BLOCK_7.invoke(chunkHandle, x & 0x0F, y, z & 0x0F, nmsBlock, data); + CHUNK_SET_BLOCK_7.invoke(chunkHandle, x & 0x0F, y, z & 0x0F, nmsBlock, data); - if (block.getType().name().contains("AIR") || isSurrounded(block.getWorld(), x, y, z)) { + if (block.getType() == Material.AIR || isSurrounded(block.getWorld(), x, y, z)) { return; } - C_17.invoke(GET_HANDLE_WORLD.invoke(block.getWorld()), SKY_BLOCK_ENUM, x, y, z); + WORLD_C_17.invoke(WORLD_GET_HANDLE.invoke(block.getWorld()), BLOCK_ENUM, x, y, z); } else { final Object blockPos = BLOCK_POS_CONSTRUCTOR.newInstance(x, y, z); if (CompatUtil.isPre1_13()) { - nmsBlock = FROM_LEGACY_DATA.invoke(nmsBlock, data); - SET_BLOCK_12.invoke(chunkHandle, blockPos, nmsBlock); + nmsBlock = BLOCK_FROM_LEGACY_DATA.invoke(nmsBlock, data); + CHUNK_SET_BLOCK_12.invoke(chunkHandle, blockPos, nmsBlock); } else { - SET_BLOCK.invoke(chunkHandle, blockPos, GET_BLOCK_DATA.invoke(nmsBlock), true); + CHUNK_SET_BLOCK.invoke(chunkHandle, blockPos, BLOCK_GET_DATA.invoke(nmsBlock), true); } - if (block.getType().name().contains("AIR") || isSurrounded(block.getWorld(), x, y, z)) { + if (block.getType() == Material.AIR || isSurrounded(block.getWorld(), x, y, z)) { return; } - C.invoke(GET_HANDLE_WORLD.invoke(block.getWorld()), SKY_BLOCK_ENUM, BLOCK_POS_CONSTRUCTOR.newInstance(x, y, z)); + WORLD_C.invoke(WORLD_GET_HANDLE.invoke(block.getWorld()), BLOCK_ENUM, BLOCK_POS_CONSTRUCTOR.newInstance(x, y, z)); } } catch (Throwable ex) { ex.printStackTrace(); diff --git a/src/main/resources/extension.yml b/src/main/resources/extension.yml index ac70064..a9ffa73 100644 --- a/src/main/resources/extension.yml +++ b/src/main/resources/extension.yml @@ -3,5 +3,5 @@ version: @VERSION@ main: me.realized.de.arenaregen.ArenaRegen authors: [Realized] description: Create automatically resetting arenas! -website: not released +website: https://www.spigotmc.org/resources/duels-extension-arenaregen.59686/ api-version: 3.1.2 \ No newline at end of file