From 1ede0e048fd11f8bd7b3f3bd2fa0136f4dc7268b Mon Sep 17 00:00:00 2001 From: Konicai <71294714+Konicai@users.noreply.github.com> Date: Tue, 14 Feb 2023 01:32:59 -0500 Subject: [PATCH 1/3] Update for floodgate 2.2.2-SNAPSHOT --- build.gradle | 1 + gradle.properties | 2 +- .../org/geysermc/floodgate/FabricMod.java | 2 +- .../geysermc/floodgate/FabricPlatform.java | 14 -------- .../inject/fabric/FabricInjector.java | 8 ++--- .../logger/Log4jFloodgateLogger.java | 35 +++++++++---------- .../module/FabricPlatformModule.java | 10 +++--- .../pluginmessage/FabricSkinApplier.java | 8 +++-- 8 files changed, 33 insertions(+), 47 deletions(-) delete mode 100644 src/main/java/org/geysermc/floodgate/FabricPlatform.java diff --git a/build.gradle b/build.gradle index 99ac159..d98dca1 100644 --- a/build.gradle +++ b/build.gradle @@ -112,6 +112,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") exclude([ 'cloud/**', 'com/google/common/**', 'com/google/errorprone/**', 'com/google/gson/**', 'com/google/j2objc/**', 'com/google/thirdparty/**', diff --git a/gradle.properties b/gradle.properties index 6f7b3a3..78e2c7f 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=development-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 558f8ff..18f1fa7 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..43404b6 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 56ada8d..dbae027 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; @@ -30,12 +32,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()); From be0e09b16a703e76e2735074840733d6acf571c1 Mon Sep 17 00:00:00 2001 From: Konicai <71294714+Konicai@users.noreply.github.com> Date: Tue, 14 Feb 2023 01:36:11 -0500 Subject: [PATCH 2/3] Fix spacing on //no-op comment --- .../org/geysermc/floodgate/inject/fabric/FabricInjector.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 43404b6..1dca449 100644 --- a/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java +++ b/src/main/java/org/geysermc/floodgate/inject/fabric/FabricInjector.java @@ -13,7 +13,7 @@ public final class FabricInjector extends CommonPlatformInjector { @Override public void inject() throws Exception { - // no-op + //no-op } public void injectClient(ChannelFuture future) { From d535d1495fc81e014353d17745e57715d13b5b9e Mon Sep 17 00:00:00 2001 From: Konicai <71294714+konicai@users.noreply.github.com> Date: Wed, 1 Mar 2023 10:20:16 -0500 Subject: [PATCH 3/3] Add jitpack repo and target floodgat-master --- build.gradle | 6 ++++++ gradle.properties | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/build.gradle b/build.gradle index 3513ab5..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' } diff --git a/gradle.properties b/gradle.properties index 78e2c7f..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=development-2.2.2-SNAPSHOT +mod_version=2.2.2-SNAPSHOT maven_group=org.geysermc.floodgate archives_base_name=floodgate-fabric # Dependencies