mirror of
https://github.com/plexusorg/Plex-FAWE.git
synced 2024-12-23 01:37:37 +00:00
Add classes with the correct minor version to the start of the adapter candidates list
This commit is contained in:
parent
1715f35341
commit
34f971c729
@ -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<String> 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,8 +105,12 @@ public class BukkitImplLoader {
|
||||
int beginIndex = 0;
|
||||
int endIndex = className.length() - CLASS_SUFFIX.length();
|
||||
className = className.substring(beginIndex, endIndex);
|
||||
if (className.contains(minorMCVersion)) {
|
||||
adapterCandidates.add(zeroth, className);
|
||||
} else {
|
||||
adapterCandidates.add(className);
|
||||
}
|
||||
}
|
||||
} finally {
|
||||
closer.close();
|
||||
}
|
||||
@ -142,9 +150,13 @@ public class BukkitImplLoader {
|
||||
int beginIndex = 0;
|
||||
int endIndex = resource.length() - CLASS_SUFFIX.length();
|
||||
String className = resource.substring(beginIndex, endIndex);
|
||||
if (className.contains(minorMCVersion)) {
|
||||
adapterCandidates.add(zeroth, className);
|
||||
} else {
|
||||
adapterCandidates.add(className);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterate through the list of candidates and load an adapter.
|
||||
|
Loading…
Reference in New Issue
Block a user