Initial 1.17 update
This commit is contained in:
parent
64c37d567d
commit
89e7498ef2
4 changed files with 50 additions and 9 deletions
|
|
@ -1,6 +1,7 @@
|
|||
package net.frankheijden.serverutils.bukkit.commands;
|
||||
|
||||
import static net.frankheijden.serverutils.common.config.Messenger.sendMessage;
|
||||
import static net.frankheijden.serverutils.common.config.Messenger.sendRawMessage;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.RegisteredCommand;
|
||||
|
|
@ -121,12 +122,17 @@ public class CommandServerUtils extends BaseCommand {
|
|||
@CommandPermission("serverutils.reloadconfig")
|
||||
@Description("Reloads individual Server configurations.")
|
||||
public void onReloadCommands(CommandSender commandSender, String config) {
|
||||
ServerCommandSender sender = BukkitUtils.wrap(commandSender);
|
||||
if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
sendRawMessage(sender, "&cThis command is not supported on your Minecraft version.");
|
||||
return;
|
||||
}
|
||||
|
||||
ReloadHandler handler = supportedConfigs.get(config);
|
||||
if (handler == null) {
|
||||
this.doHelp(commandSender);
|
||||
return;
|
||||
}
|
||||
ServerCommandSender sender = BukkitUtils.wrap(commandSender);
|
||||
|
||||
String[] replacements = new String[]{ "%action%", "reload", "%what%", config };
|
||||
|
||||
|
|
@ -382,7 +388,6 @@ public class CommandServerUtils extends BaseCommand {
|
|||
.lastSeperator(lastSeperator)
|
||||
.toString())
|
||||
.add("Label", cmd.getLabel())
|
||||
.add("Timings Name", cmd.getTimingName())
|
||||
.add("Permission", cmd.getPermission())
|
||||
.add("Permission Message", cmd.getPermissionMessage());
|
||||
|
||||
|
|
|
|||
|
|
@ -11,8 +11,17 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class RCraftingManager {
|
||||
|
||||
private static final MinecraftReflection reflection = MinecraftReflection
|
||||
.of("net.minecraft.server.%s.CraftingManager");
|
||||
private static final MinecraftReflection reflection;
|
||||
|
||||
static {
|
||||
if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
reflection = MinecraftReflection.of("net.minecraft.world.item.crafting.CraftingManager");
|
||||
} else {
|
||||
reflection = MinecraftReflection.of("net.minecraft.server.%s.CraftingManager");
|
||||
}
|
||||
}
|
||||
|
||||
private RCraftingManager() {}
|
||||
|
||||
/**
|
||||
* Removes all associated recipes of a plugin.
|
||||
|
|
@ -27,7 +36,13 @@ public class RCraftingManager {
|
|||
} else if (MinecraftReflectionVersion.MINOR > 12) {
|
||||
Object server = RMinecraftServer.getReflection().invoke(null, "getServer");
|
||||
Object craftingManager = RMinecraftServer.getReflection().invoke(server, "getCraftingManager");
|
||||
Map recipes = reflection.get(craftingManager, "recipes");
|
||||
|
||||
Map recipes;
|
||||
if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
recipes = reflection.get(craftingManager, "c");
|
||||
} else {
|
||||
recipes = reflection.get(craftingManager, "recipes");
|
||||
}
|
||||
|
||||
Predicate<Object> predicate = RMinecraftKey.matchingPluginPredicate(new AtomicBoolean(false), plugin);
|
||||
if (MinecraftReflectionVersion.MINOR == 13) {
|
||||
|
|
|
|||
|
|
@ -9,8 +9,17 @@ import org.bukkit.plugin.Plugin;
|
|||
|
||||
public class RMinecraftKey {
|
||||
|
||||
private static final MinecraftReflection reflection = MinecraftReflection
|
||||
.of("net.minecraft.server.%s.MinecraftKey");
|
||||
private static final MinecraftReflection reflection;
|
||||
|
||||
static {
|
||||
if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
reflection = MinecraftReflection.of("net.minecraft.resources.MinecraftKey");
|
||||
} else {
|
||||
reflection = MinecraftReflection.of("net.minecraft.server.%s.MinecraftKey");
|
||||
}
|
||||
}
|
||||
|
||||
private RMinecraftKey() {}
|
||||
|
||||
public static MinecraftReflection getReflection() {
|
||||
return reflection;
|
||||
|
|
@ -24,6 +33,8 @@ public class RMinecraftKey {
|
|||
public static String getNameSpace(Object instance) {
|
||||
if (MinecraftReflectionVersion.MINOR <= 13) {
|
||||
return reflection.get(instance, "a");
|
||||
} else if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
return reflection.invoke(instance, "getNamespace");
|
||||
}
|
||||
return reflection.get(instance, "namespace");
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,11 +1,21 @@
|
|||
package net.frankheijden.serverutils.bukkit.reflection;
|
||||
|
||||
import dev.frankheijden.minecraftreflection.MinecraftReflection;
|
||||
import dev.frankheijden.minecraftreflection.MinecraftReflectionVersion;
|
||||
|
||||
public class RMinecraftServer {
|
||||
|
||||
private static final MinecraftReflection reflection = MinecraftReflection
|
||||
.of("net.minecraft.server.%s.MinecraftServer");
|
||||
private static final MinecraftReflection reflection;
|
||||
|
||||
static {
|
||||
if (MinecraftReflectionVersion.MINOR >= 17) {
|
||||
reflection = MinecraftReflection.of("net.minecraft.server.MinecraftServer");
|
||||
} else {
|
||||
reflection = MinecraftReflection.of("net.minecraft.server.%s.MinecraftServer");
|
||||
}
|
||||
}
|
||||
|
||||
private RMinecraftServer() {}
|
||||
|
||||
public static MinecraftReflection getReflection() {
|
||||
return reflection;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue