diff --git a/SpigotCore_20/build.gradle b/SpigotCore_20/build.gradle new file mode 100644 index 0000000..d25c3e2 --- /dev/null +++ b/SpigotCore_20/build.gradle @@ -0,0 +1,50 @@ +/* + * This file is a part of the SteamWar software. + * + * Copyright (C) 2023 SteamWar.de-Serverteam + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero 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 Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +plugins { + id 'base' + id 'java' +} + +group 'steamwar' +version '1.0' + +compileJava.options.encoding = 'UTF-8' + +sourceCompatibility = 1.8 +targetCompatibility = 1.8 + +sourceSets { + main { + java { + srcDirs = ['src/'] + } + resources { + srcDirs = ['src/'] + exclude '**/*.java', '**/*.kt' + } + } +} + +dependencies { + compileOnly project(":SpigotCore_Main") + + compileOnly 'org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT' + compileOnly swdep("Spigot-1.20") +} diff --git a/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java b/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java new file mode 100644 index 0000000..f223879 --- /dev/null +++ b/SpigotCore_20/src/de/steamwar/core/CraftbukkitWrapper20.java @@ -0,0 +1,42 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2023 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero 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 Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.core; + +import com.comphenix.tinyprotocol.Reflection; +import com.comphenix.tinyprotocol.TinyProtocol; +import net.minecraft.network.protocol.game.ClientboundLevelChunkWithLightPacket; +import net.minecraft.world.level.World; +import net.minecraft.world.level.chunk.Chunk; +import net.minecraft.world.level.chunk.ChunkStatus; +import net.minecraft.world.level.lighting.LevelLightEngine; +import net.minecraft.world.level.lighting.LightEngine; +import org.bukkit.entity.Player; + +public class CraftbukkitWrapper20 implements CraftbukkitWrapper.ICraftbukkitWrapper { + + private static final Reflection.MethodInvoker getHandle = Reflection.getMethod("{obc}.CraftChunk", "getHandle", ChunkStatus.class); + private static final Reflection.MethodInvoker getLightEngine = Reflection.getTypedMethod(World.class, null, LightEngine.class); + + @Override + public void sendChunk(Player p, int chunkX, int chunkZ) { + Chunk chunk = (Chunk) getHandle.invoke(p.getWorld().getChunkAt(chunkX, chunkZ), ChunkStatus.n); + TinyProtocol.instance.sendPacket(p, new ClientboundLevelChunkWithLightPacket(chunk, (LevelLightEngine) getLightEngine.invoke(chunk.r), null, null, true)); + } +} diff --git a/build.gradle b/build.gradle index 473ecf0..0a88ab2 100755 --- a/build.gradle +++ b/build.gradle @@ -75,6 +75,7 @@ dependencies { implementation project(":SpigotCore_15") implementation project(":SpigotCore_18") implementation project(":SpigotCore_19") + implementation project(":SpigotCore_20") implementation project(":CommonCore") } diff --git a/settings.gradle b/settings.gradle index 0479c2c..ff43518 100644 --- a/settings.gradle +++ b/settings.gradle @@ -29,6 +29,7 @@ pluginManagement { rootProject.name = 'SpigotCore' include 'SpigotCore_Main' +include 'SpigotCore_20' include 'SpigotCore_19' include 'SpigotCore_18' include 'SpigotCore_15'