mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-11-23 23:38:41 +01:00
Add Fabric as a platform type (#1376)
* PlatformType: Add Fabric as a platform * Don't use XML reflections on Fabric
This commit is contained in:
parent
90656a9846
commit
172a5a6db8
7 changed files with 14 additions and 12 deletions
|
@ -312,15 +312,16 @@ public class GeyserConnector {
|
|||
}
|
||||
|
||||
/**
|
||||
* Get the production status of the current runtime.
|
||||
* Will return true if the version number is not 'DEV'.
|
||||
* Should only happen in compiled jars.
|
||||
* Whether to use XML reflections in the jar or manually find the reflections.
|
||||
* Will return true if the version number is not 'DEV' and the platform is not Fabric.
|
||||
* On Fabric - it complains about being unable to create a default XMLReader.
|
||||
* On other platforms this should only be true in compiled jars.
|
||||
*
|
||||
* @return If we are in a production build/environment
|
||||
* @return whether to use XML reflections
|
||||
*/
|
||||
public boolean isProduction() {
|
||||
public boolean useXmlReflections() {
|
||||
//noinspection ConstantConditions
|
||||
return !"DEV".equals(GeyserConnector.VERSION);
|
||||
return !this.getPlatformType().equals(PlatformType.FABRIC) && !"DEV".equals(GeyserConnector.VERSION);
|
||||
}
|
||||
|
||||
public static GeyserConnector getInstance() {
|
||||
|
|
|
@ -34,10 +34,11 @@ public enum PlatformType {
|
|||
|
||||
ANDROID("Android"),
|
||||
BUNGEECORD("BungeeCord"),
|
||||
FABRIC("Fabric"),
|
||||
SPIGOT("Spigot"),
|
||||
SPONGE("Sponge"),
|
||||
STANDALONE("Standalone"),
|
||||
VELOCITY("Velocity");
|
||||
|
||||
private String platformName;
|
||||
private final String platformName;
|
||||
}
|
||||
|
|
|
@ -48,7 +48,7 @@ public class PacketTranslatorRegistry<T> {
|
|||
private static final ObjectArrayList<Class<?>> IGNORED_PACKETS = new ObjectArrayList<>();
|
||||
|
||||
static {
|
||||
Reflections ref = GeyserConnector.getInstance().isProduction() ? FileUtils.getReflections("org.geysermc.connector.network.translators") : new Reflections("org.geysermc.connector.network.translators");
|
||||
Reflections ref = GeyserConnector.getInstance().useXmlReflections() ? FileUtils.getReflections("org.geysermc.connector.network.translators") : new Reflections("org.geysermc.connector.network.translators");
|
||||
|
||||
for (Class<?> clazz : ref.getTypesAnnotatedWith(Translator.class)) {
|
||||
Class<?> packet = clazz.getAnnotation(Translator.class).packet();
|
||||
|
|
|
@ -64,7 +64,7 @@ public abstract class ItemTranslator {
|
|||
|
||||
static {
|
||||
/* Load item translators */
|
||||
Reflections ref = GeyserConnector.getInstance().isProduction() ? FileUtils.getReflections("org.geysermc.connector.network.translators.item") : new Reflections("org.geysermc.connector.network.translators.item");
|
||||
Reflections ref = GeyserConnector.getInstance().useXmlReflections() ? FileUtils.getReflections("org.geysermc.connector.network.translators.item") : new Reflections("org.geysermc.connector.network.translators.item");
|
||||
|
||||
Map<NbtItemStackTranslator, Integer> loadedNbtItemTranslators = new HashMap<>();
|
||||
for (Class<?> clazz : ref.getTypesAnnotatedWith(ItemRemapper.class)) {
|
||||
|
|
|
@ -40,7 +40,7 @@ public class SoundHandlerRegistry {
|
|||
static final Map<SoundHandler, SoundInteractionHandler<?>> INTERACTION_HANDLERS = new HashMap<>();
|
||||
|
||||
static {
|
||||
Reflections ref = GeyserConnector.getInstance().isProduction() ? FileUtils.getReflections("org.geysermc.connector.network.translators.sound") : new Reflections("org.geysermc.connector.network.translators.sound");
|
||||
Reflections ref = GeyserConnector.getInstance().useXmlReflections() ? FileUtils.getReflections("org.geysermc.connector.network.translators.sound") : new Reflections("org.geysermc.connector.network.translators.sound");
|
||||
for (Class<?> clazz : ref.getTypesAnnotatedWith(SoundHandler.class)) {
|
||||
try {
|
||||
SoundInteractionHandler<?> interactionHandler = (SoundInteractionHandler<?>) clazz.newInstance();
|
||||
|
|
|
@ -113,7 +113,7 @@ public class BlockTranslator {
|
|||
addedStatesMap.defaultReturnValue(-1);
|
||||
List<NbtMap> paletteList = new ArrayList<>();
|
||||
|
||||
Reflections ref = GeyserConnector.getInstance().isProduction() ? FileUtils.getReflections("org.geysermc.connector.network.translators.world.block.entity") : new Reflections("org.geysermc.connector.network.translators.world.block.entity");
|
||||
Reflections ref = GeyserConnector.getInstance().useXmlReflections() ? FileUtils.getReflections("org.geysermc.connector.network.translators.world.block.entity") : new Reflections("org.geysermc.connector.network.translators.world.block.entity");
|
||||
ref.getTypesAnnotatedWith(BlockEntity.class);
|
||||
|
||||
int waterRuntimeId = -1;
|
||||
|
|
|
@ -68,7 +68,7 @@ public abstract class BlockEntityTranslator {
|
|||
}
|
||||
|
||||
static {
|
||||
Reflections ref = GeyserConnector.getInstance().isProduction() ? FileUtils.getReflections("org.geysermc.connector.network.translators.world.block.entity") : new Reflections("org.geysermc.connector.network.translators.world.block.entity");
|
||||
Reflections ref = GeyserConnector.getInstance().useXmlReflections() ? FileUtils.getReflections("org.geysermc.connector.network.translators.world.block.entity") : new Reflections("org.geysermc.connector.network.translators.world.block.entity");
|
||||
for (Class<?> clazz : ref.getTypesAnnotatedWith(BlockEntity.class)) {
|
||||
GeyserConnector.getInstance().getLogger().debug("Found annotated block entity: " + clazz.getCanonicalName());
|
||||
|
||||
|
|
Loading…
Reference in a new issue