3
0
Mirror von https://github.com/GeyserMC/Geyser.git synchronisiert 2024-10-01 23:50:11 +02:00

Add Fabric as a platform type (#1376)

* PlatformType: Add Fabric as a platform

* Don't use XML reflections on Fabric
Dieser Commit ist enthalten in:
Camotoy 2020-10-07 18:51:36 -04:00 committet von GitHub
Ursprung 90656a9846
Commit 172a5a6db8
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 4AEE18F83AFDEB23
7 geänderte Dateien mit 14 neuen und 12 gelöschten Zeilen

Datei anzeigen

@ -312,15 +312,16 @@ public class GeyserConnector {
} }
/** /**
* Get the production status of the current runtime. * Whether to use XML reflections in the jar or manually find the reflections.
* Will return true if the version number is not 'DEV'. * Will return true if the version number is not 'DEV' and the platform is not Fabric.
* Should only happen in compiled jars. * 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 //noinspection ConstantConditions
return !"DEV".equals(GeyserConnector.VERSION); return !this.getPlatformType().equals(PlatformType.FABRIC) && !"DEV".equals(GeyserConnector.VERSION);
} }
public static GeyserConnector getInstance() { public static GeyserConnector getInstance() {

Datei anzeigen

@ -34,10 +34,11 @@ public enum PlatformType {
ANDROID("Android"), ANDROID("Android"),
BUNGEECORD("BungeeCord"), BUNGEECORD("BungeeCord"),
FABRIC("Fabric"),
SPIGOT("Spigot"), SPIGOT("Spigot"),
SPONGE("Sponge"), SPONGE("Sponge"),
STANDALONE("Standalone"), STANDALONE("Standalone"),
VELOCITY("Velocity"); VELOCITY("Velocity");
private String platformName; private final String platformName;
} }

Datei anzeigen

@ -48,7 +48,7 @@ public class PacketTranslatorRegistry<T> {
private static final ObjectArrayList<Class<?>> IGNORED_PACKETS = new ObjectArrayList<>(); private static final ObjectArrayList<Class<?>> IGNORED_PACKETS = new ObjectArrayList<>();
static { 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)) { for (Class<?> clazz : ref.getTypesAnnotatedWith(Translator.class)) {
Class<?> packet = clazz.getAnnotation(Translator.class).packet(); Class<?> packet = clazz.getAnnotation(Translator.class).packet();

Datei anzeigen

@ -64,7 +64,7 @@ public abstract class ItemTranslator {
static { static {
/* Load item translators */ /* 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<>(); Map<NbtItemStackTranslator, Integer> loadedNbtItemTranslators = new HashMap<>();
for (Class<?> clazz : ref.getTypesAnnotatedWith(ItemRemapper.class)) { for (Class<?> clazz : ref.getTypesAnnotatedWith(ItemRemapper.class)) {

Datei anzeigen

@ -40,7 +40,7 @@ public class SoundHandlerRegistry {
static final Map<SoundHandler, SoundInteractionHandler<?>> INTERACTION_HANDLERS = new HashMap<>(); static final Map<SoundHandler, SoundInteractionHandler<?>> INTERACTION_HANDLERS = new HashMap<>();
static { 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)) { for (Class<?> clazz : ref.getTypesAnnotatedWith(SoundHandler.class)) {
try { try {
SoundInteractionHandler<?> interactionHandler = (SoundInteractionHandler<?>) clazz.newInstance(); SoundInteractionHandler<?> interactionHandler = (SoundInteractionHandler<?>) clazz.newInstance();

Datei anzeigen

@ -113,7 +113,7 @@ public class BlockTranslator {
addedStatesMap.defaultReturnValue(-1); addedStatesMap.defaultReturnValue(-1);
List<NbtMap> paletteList = new ArrayList<>(); 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); ref.getTypesAnnotatedWith(BlockEntity.class);
int waterRuntimeId = -1; int waterRuntimeId = -1;

Datei anzeigen

@ -68,7 +68,7 @@ public abstract class BlockEntityTranslator {
} }
static { 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)) { for (Class<?> clazz : ref.getTypesAnnotatedWith(BlockEntity.class)) {
GeyserConnector.getInstance().getLogger().debug("Found annotated block entity: " + clazz.getCanonicalName()); GeyserConnector.getInstance().getLogger().debug("Found annotated block entity: " + clazz.getCanonicalName());