From 34f971c72916729fcccc2f2f12f9de68fe93408e Mon Sep 17 00:00:00 2001 From: dordsor21 Date: Wed, 22 Dec 2021 12:19:20 +0000 Subject: [PATCH] Add classes with the correct minor version to the start of the adapter candidates list --- .../bukkit/adapter/BukkitImplLoader.java | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java index 3224aec12..11cee4f14 100644 --- a/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java +++ b/worldedit-bukkit/src/main/java/com/sk89q/worldedit/bukkit/adapter/BukkitImplLoader.java @@ -19,6 +19,7 @@ package com.sk89q.worldedit.bukkit.adapter; +import com.fastasyncworldedit.bukkit.util.MinecraftVersion; import com.sk89q.worldedit.internal.util.LogManagerCompat; import com.sk89q.worldedit.util.io.Closer; import org.apache.logging.log4j.Logger; @@ -39,6 +40,8 @@ public class BukkitImplLoader { private static final Logger LOGGER = LogManagerCompat.getLogger(); private final List adapterCandidates = new ArrayList<>(); + private final String minorMCVersion = String.valueOf(new MinecraftVersion().getMinor()); + private int zeroth = 0; private String customCandidate; private static final String SEARCH_PACKAGE = "com.sk89q.worldedit.bukkit.adapter.impl.fawe"; @@ -73,6 +76,7 @@ public class BukkitImplLoader { String className = System.getProperty("worldedit.bukkit.adapter"); if (className != null) { customCandidate = className; + zeroth = 1; adapterCandidates.add(className); LOGGER.info("-Dworldedit.bukkit.adapter used to add " + className + " to the list of available Bukkit adapters"); } @@ -101,7 +105,11 @@ public class BukkitImplLoader { int beginIndex = 0; int endIndex = className.length() - CLASS_SUFFIX.length(); className = className.substring(beginIndex, endIndex); - adapterCandidates.add(className); + if (className.contains(minorMCVersion)) { + adapterCandidates.add(zeroth, className); + } else { + adapterCandidates.add(className); + } } } finally { closer.close(); @@ -142,7 +150,11 @@ public class BukkitImplLoader { int beginIndex = 0; int endIndex = resource.length() - CLASS_SUFFIX.length(); String className = resource.substring(beginIndex, endIndex); - adapterCandidates.add(className); + if (className.contains(minorMCVersion)) { + adapterCandidates.add(zeroth, className); + } else { + adapterCandidates.add(className); + } } }