diff --git a/build.gradle b/build.gradle index 3dce8a2..bff9e66 100644 --- a/build.gradle +++ b/build.gradle @@ -65,6 +65,12 @@ dependencies { repositories { //mavenLocal() + + // temporary for custom bStats fork + maven { + url 'https://jitpack.io' + } + maven { url = 'https://oss.sonatype.org/content/repositories/snapshots' } @@ -112,6 +118,7 @@ shadowJar { configurations = [project.configurations.shadow] // TODO this is temporary until Floodgate's dev branch is merged relocate("com.google.inject", "org.geysermc.floodgate.shadow.guice") + relocate("org.bstats", "org.geysermc.floodgate.shadow.bstats") relocate("org.yaml.snakeyaml", "org.geysermc.floodgate.shadow.snakeyaml") //relocate snakeyaml to avoid conflicts with other mods exclude([ 'cloud/**', diff --git a/gradle.properties b/gradle.properties index 6f7b3a3..df5bd4e 100644 --- a/gradle.properties +++ b/gradle.properties @@ -5,7 +5,7 @@ org.gradle.jvmargs=-Xmx2G minecraft_version=1.19.3 loader_version=0.14.11 # Mod Properties -mod_version=2.2.0-SNAPSHOT +mod_version=2.2.2-SNAPSHOT maven_group=org.geysermc.floodgate archives_base_name=floodgate-fabric # Dependencies diff --git a/src/main/java/org/geysermc/floodgate/FabricMod.java b/src/main/java/org/geysermc/floodgate/FabricMod.java index 1eaab88..a2da132 100644 --- a/src/main/java/org/geysermc/floodgate/FabricMod.java +++ b/src/main/java/org/geysermc/floodgate/FabricMod.java @@ -19,7 +19,7 @@ public void onInitialize() { new FabricPlatformModule() ); - FabricPlatform platform = injector.getInstance(FabricPlatform.class); + FloodgatePlatform platform = injector.getInstance(FloodgatePlatform.class); platform.enable(new FabricCommandModule()); diff --git a/src/main/java/org/geysermc/floodgate/FabricPlatform.java b/src/main/java/org/geysermc/floodgate/FabricPlatform.java deleted file mode 100644 index af1a0a2..0000000 --- a/src/main/java/org/geysermc/floodgate/FabricPlatform.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.geysermc.floodgate; - -import com.google.inject.Inject; -import com.google.inject.Injector; -import org.geysermc.floodgate.api.FloodgateApi; -import org.geysermc.floodgate.api.inject.PlatformInjector; -import org.geysermc.floodgate.api.logger.FloodgateLogger; - -public final class FabricPlatform extends FloodgatePlatform { - @Inject - public FabricPlatform(FloodgateApi api, PlatformInjector platformInjector, FloodgateLogger logger, Injector guice) { - super(api, platformInjector, logger, guice); - } -} diff --git a/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java b/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java index 7eaf986..1dca449 100644 --- a/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java +++ b/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java @@ -12,8 +12,8 @@ public final class FabricInjector extends CommonPlatformInjector { @Getter private final boolean injected = true; @Override - public boolean inject() throws Exception { - return true; + public void inject() throws Exception { + //no-op } public void injectClient(ChannelFuture future) { @@ -39,8 +39,8 @@ protected void initChannel(Channel channel) { } @Override - public boolean removeInjection() throws Exception { - return true; + public void removeInjection() throws Exception { + //no-op } public static FabricInjector getInstance() { diff --git a/src/main/java/org/geysermc/floodgate/logger/Log4jFloodgateLogger.java b/src/main/java/org/geysermc/floodgate/logger/Log4jFloodgateLogger.java index a4cb38f..d24223f 100644 --- a/src/main/java/org/geysermc/floodgate/logger/Log4jFloodgateLogger.java +++ b/src/main/java/org/geysermc/floodgate/logger/Log4jFloodgateLogger.java @@ -1,18 +1,31 @@ package org.geysermc.floodgate.logger; -import lombok.RequiredArgsConstructor; +import com.google.inject.Inject; +import com.google.inject.Singleton; +import com.google.inject.name.Named; import org.apache.logging.log4j.Level; import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.core.config.Configurator; import org.geysermc.floodgate.api.logger.FloodgateLogger; +import org.geysermc.floodgate.config.FloodgateConfig; import org.geysermc.floodgate.util.LanguageManager; import static org.geysermc.floodgate.util.MessageFormatter.format; -@RequiredArgsConstructor +@Singleton public final class Log4jFloodgateLogger implements FloodgateLogger { - private final Logger logger; - private final LanguageManager languageManager; + @Inject + @Named("logger") + private Logger logger; + private LanguageManager languageManager; + + @Inject + private void init(LanguageManager languageManager, FloodgateConfig config) { + this.languageManager = languageManager; + if (config.isDebug() && !logger.isDebugEnabled()) { + Configurator.setLevel(logger.getName(), Level.DEBUG); + } + } @Override public void error(String message, Object... args) { @@ -49,20 +62,6 @@ public void trace(String message, Object... args) { logger.trace(message, args); } - @Override - public void enableDebug() { - if (!logger.isDebugEnabled()) { - Configurator.setLevel(logger.getName(), Level.DEBUG); - } - } - - @Override - public void disableDebug() { - if (logger.isDebugEnabled()) { - Configurator.setLevel(logger.getName(), Level.INFO); - } - } - @Override public boolean isDebug() { return logger.isDebugEnabled(); diff --git a/src/main/java/org/geysermc/floodgate/module/FabricPlatformModule.java b/src/main/java/org/geysermc/floodgate/module/FabricPlatformModule.java index 3071107..9a59283 100644 --- a/src/main/java/org/geysermc/floodgate/module/FabricPlatformModule.java +++ b/src/main/java/org/geysermc/floodgate/module/FabricPlatformModule.java @@ -1,5 +1,7 @@ package org.geysermc.floodgate.module; +import com.google.inject.name.Names; +import org.apache.logging.log4j.Logger; import org.geysermc.floodgate.inject.fabric.FabricInjector; import org.geysermc.floodgate.listener.FabricEventListener; import org.geysermc.floodgate.listener.FabricEventRegistration; @@ -32,12 +34,8 @@ public final class FabricPlatformModule extends AbstractModule { @Override protected void configure() { bind(PlatformUtils.class).to(FabricPlatformUtils.class); - } - - @Provides - @Singleton - public FloodgateLogger floodgateLogger(LanguageManager languageManager) { - return new Log4jFloodgateLogger(LogManager.getLogger("floodgate"), languageManager); + bind(Logger.class).annotatedWith(Names.named("logger")).toInstance(LogManager.getLogger("floodgate")); + bind(FloodgateLogger.class).to(Log4jFloodgateLogger.class); } @Provides diff --git a/src/main/java/org/geysermc/floodgate/pluginmessage/FabricSkinApplier.java b/src/main/java/org/geysermc/floodgate/pluginmessage/FabricSkinApplier.java index 7d5107e..374c2d8 100644 --- a/src/main/java/org/geysermc/floodgate/pluginmessage/FabricSkinApplier.java +++ b/src/main/java/org/geysermc/floodgate/pluginmessage/FabricSkinApplier.java @@ -7,18 +7,20 @@ import net.minecraft.server.level.ChunkMap; import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerPlayer; +import org.checkerframework.checker.nullness.qual.NonNull; import org.geysermc.floodgate.MinecraftServerHolder; import org.geysermc.floodgate.api.player.FloodgatePlayer; import org.geysermc.floodgate.mixin.ChunkMapMixin; import org.geysermc.floodgate.skin.SkinApplier; -import org.geysermc.floodgate.skin.SkinData; + +import static org.geysermc.floodgate.api.event.skin.SkinApplyEvent.SkinData; import java.util.Collections; public final class FabricSkinApplier implements SkinApplier { @Override - public void applySkin(FloodgatePlayer floodgatePlayer, SkinData skinData) { + public void applySkin(@NonNull FloodgatePlayer floodgatePlayer, @NonNull SkinData skinData) { MinecraftServerHolder.get().execute(() -> { ServerPlayer bedrockPlayer = MinecraftServerHolder.get().getPlayerList() .getPlayer(floodgatePlayer.getCorrectUniqueId()); @@ -31,7 +33,7 @@ public void applySkin(FloodgatePlayer floodgatePlayer, SkinData skinData) { PropertyMap properties = bedrockPlayer.getGameProfile().getProperties(); properties.removeAll("textures"); - properties.put("textures", new Property("textures", skinData.getValue(), skinData.getSignature())); + properties.put("textures", new Property("textures", skinData.value(), skinData.signature())); ChunkMap tracker = ((ServerLevel) bedrockPlayer.level).getChunkSource().chunkMap; ChunkMap.TrackedEntity entry = ((ChunkMapMixin) tracker).getEntityMap().get(bedrockPlayer.getId());