Skip to content

Commit

Permalink
update website
Browse files Browse the repository at this point in the history
  • Loading branch information
Realizedd committed Aug 11, 2018
1 parent 1a96865 commit 761cd89
Show file tree
Hide file tree
Showing 8 changed files with 37 additions and 44 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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/
7 changes: 0 additions & 7 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Binary file removed libs/spigot-1.12.2.jar
Binary file not shown.
Binary file removed libs/spigot-1.13.jar
Binary file not shown.
Binary file removed libs/spigot-1.7.10.jar
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand All @@ -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;
}
}
64 changes: 32 additions & 32 deletions src/main/java/me/realized/de/arenaregen/util/compat/NMSUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand All @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/extension.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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

0 comments on commit 761cd89

Please sign in to comment.