Merge pull request #50 from FrankHeijden/feature/1.19

Initial update for 1.19
This commit is contained in:
Frank van der Heijden 2022-06-15 17:07:40 +02:00 committed by GitHub
commit 32f4bd1572
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 22 additions and 8 deletions

View file

@ -58,12 +58,12 @@ public class BukkitPlugin extends ServerUtilsPlugin<Plugin, BukkitTask, BukkitAu
throw new RuntimeException(ex);
}
if (commandManager.queryCapability(CloudBukkitCapabilities.BRIGADIER)) {
if (commandManager.hasCapability(CloudBukkitCapabilities.BRIGADIER)) {
commandManager.registerBrigadier();
handleBrigadier(commandManager.brigadierManager());
}
if (commandManager.queryCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
if (commandManager.hasCapability(CloudBukkitCapabilities.ASYNCHRONOUS_COMPLETION)) {
commandManager.registerAsynchronousCompletions();
}

View file

@ -1,7 +1,10 @@
package net.frankheijden.serverutils.bukkit.reflection;
import dev.frankheijden.minecraftreflection.exceptions.MinecraftReflectionException;
import dev.frankheijden.minecraftreflection.MinecraftReflection;
import dev.frankheijden.minecraftreflection.MinecraftReflectionVersion;
import java.lang.reflect.Method;
import java.util.Arrays;
import java.util.Collection;
import java.util.Map;
import java.util.concurrent.atomic.AtomicBoolean;
@ -12,6 +15,7 @@ import org.bukkit.plugin.Plugin;
public class RCraftingManager {
private static final MinecraftReflection reflection;
private static final Method getCraftingManagerMethod;
static {
if (MinecraftReflectionVersion.MINOR >= 17) {
@ -19,6 +23,11 @@ public class RCraftingManager {
} else {
reflection = MinecraftReflection.of("net.minecraft.server.%s.CraftingManager");
}
getCraftingManagerMethod = Arrays.stream(RMinecraftServer.getReflection().getClazz().getDeclaredMethods())
.filter(m -> m.getReturnType().equals(reflection.getClazz()))
.findAny()
.get();
}
private RCraftingManager() {}
@ -35,8 +44,12 @@ public class RCraftingManager {
RRegistryMaterials.removeKeysFor(reflection.get(null, "recipes"), plugin);
} else if (MinecraftReflectionVersion.MINOR > 12) {
Object server = RMinecraftServer.getReflection().invoke(null, "getServer");
String getCraftingManagerMethod = MinecraftReflectionVersion.MINOR >= 18 ? "aC" : "getCraftingManager";
Object craftingManager = RMinecraftServer.getReflection().invoke(server, getCraftingManagerMethod);
Object craftingManager;
try {
craftingManager = getCraftingManagerMethod.invoke(server);
} catch (ReflectiveOperationException ex) {
throw new MinecraftReflectionException(ex);
}
Map recipes;
if (MinecraftReflectionVersion.MINOR >= 17) {

View file

@ -8,7 +8,7 @@ plugins {
group = "net.frankheijden.serverutils"
val dependencyDir = "${group}.dependencies"
version = "3.4.5-SNAPSHOT"
version = "3.5.0-SNAPSHOT"
java {
sourceCompatibility = JavaVersion.VERSION_1_8
@ -39,7 +39,7 @@ subprojects {
implementation("cloud.commandframework:cloud-brigadier:${VersionConstants.cloudVersion}")
implementation("com.github.FrankHeijden:MinecraftReflection:1.0.0")
implementation("com.google.code.gson:gson:2.8.6")
implementation("me.lucko:commodore:1.13")
implementation("me.lucko:commodore:2.0")
compileOnly("com.mojang:brigadier:1.0.18")
testImplementation("org.assertj:assertj-core:3.18.1")
@ -55,6 +55,7 @@ subprojects {
compileJava {
options.encoding = Charsets.UTF_8.name()
options.isDeprecation = true
}
javadoc {

View file

@ -1,7 +1,7 @@
object VersionConstants {
const val cloudVersion = "1.6.2"
const val cloudVersion = "1.7.0-SNAPSHOT"
const val adventureVersion = "4.9.3"
const val adventurePlatformVersion = "4.0.1"
const val adventureMinimessageVersion = "4.2.0-SNAPSHOT"
const val bstatsVersion = "2.2.1"
const val bstatsVersion = "3.0.0"
}