From bb61dc4aec8faaffe2965bbea875ee2590743db4 Mon Sep 17 00:00:00 2001 From: Draycia Date: Sat, 16 Jul 2022 20:46:42 -0700 Subject: [PATCH] Cleanup and checkstyle --- build-logic/src/main/kotlin/extensions.kt | 3 ++- .../channels/CarbonChannelRegistry.java | 1 - .../carbon/fabric/CarbonChatFabric.java | 4 ---- .../carbon/fabric/CarbonChatFabricModule.java | 2 -- .../fabric/command/DeleteMessageCommand.java | 1 - .../listeners/FabricChatPreviewListener.java | 21 ++++++++++++++++++- .../listeners/FabricPlayerJoinListener.java | 3 +-- .../fabric/mixin/ChatListenerMixin.java | 21 ++++++++++++++++++- .../fabric/mixin/ServerPlayerMixin.java | 2 -- 9 files changed, 43 insertions(+), 15 deletions(-) diff --git a/build-logic/src/main/kotlin/extensions.kt b/build-logic/src/main/kotlin/extensions.kt index 9d6bf5a1..9eb5831c 100644 --- a/build-logic/src/main/kotlin/extensions.kt +++ b/build-logic/src/main/kotlin/extensions.kt @@ -39,7 +39,7 @@ fun ShadowJar.standardRelocations() { relocateDependency("ninja.egg82.messenger") relocateDependency("org.antlr") relocateDependency("com.github.luben") - relocateDependency("io.netty") + //relocateDependency("io.netty") } fun ShadowJar.relocateCloud() { @@ -61,6 +61,7 @@ fun ShadowJar.configureShadowJar() { exclude(dependency("org.checkerframework:checker-qual")) exclude(dependency("com.google.errorprone:error_prone_annotations")) exclude(dependency("com.google.j2objc:j2objc-annotations")) + exclude(dependency("io.netty:netty-all")) } } diff --git a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java index 48461372..69edaef3 100644 --- a/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java +++ b/common/src/main/java/net/draycia/carbon/common/channels/CarbonChannelRegistry.java @@ -60,7 +60,6 @@ import net.draycia.carbon.common.messaging.packets.ChatMessagePacket; import net.kyori.adventure.audience.MessageType; import net.kyori.adventure.identity.Identity; import net.kyori.adventure.key.Key; -import net.kyori.adventure.permission.PermissionChecker; import net.kyori.adventure.text.Component; import net.kyori.registry.DefaultedRegistryGetter; import ninja.egg82.messenger.services.PacketService; diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabric.java b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabric.java index d8626223..a15faf57 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabric.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabric.java @@ -21,16 +21,12 @@ package net.draycia.carbon.fabric; import com.google.common.cache.Cache; import com.google.common.cache.CacheBuilder; -import com.google.common.collect.MapMaker; -import com.google.common.collect.Ordering; import com.google.inject.Guice; import com.google.inject.Injector; import com.google.inject.TypeLiteral; import java.nio.file.Path; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.Set; import java.util.UUID; import java.util.concurrent.CompletableFuture; diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java index 85dc1189..497c566f 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/CarbonChatFabricModule.java @@ -38,11 +38,9 @@ import net.draycia.carbon.common.command.Commander; import net.draycia.carbon.common.command.argument.PlayerSuggestions; import net.draycia.carbon.common.util.CloudUtils; import net.draycia.carbon.fabric.command.FabricCommander; -import net.draycia.carbon.fabric.command.FabricPlayerCommander; import net.kyori.adventure.audience.Audience; import net.kyori.adventure.text.Component; import net.kyori.moonshine.message.IMessageRenderer; -import net.minecraft.server.level.ServerPlayer; import org.apache.logging.log4j.Logger; import org.checkerframework.checker.nullness.qual.NonNull; import org.checkerframework.framework.qual.DefaultQualifier; diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/command/DeleteMessageCommand.java b/fabric/src/main/java/net/draycia/carbon/fabric/command/DeleteMessageCommand.java index 350e0798..681035d7 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/command/DeleteMessageCommand.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/command/DeleteMessageCommand.java @@ -25,7 +25,6 @@ import cloud.commandframework.minecraft.extras.MinecraftExtrasMetaKeys; import com.google.inject.Inject; import java.util.LinkedList; import java.util.List; -import java.util.UUID; import net.draycia.carbon.common.command.CarbonCommand; import net.draycia.carbon.common.command.CommandSettings; import net.draycia.carbon.common.command.Commander; diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatPreviewListener.java b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatPreviewListener.java index cf53871d..ac6b6f64 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatPreviewListener.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricChatPreviewListener.java @@ -1,3 +1,22 @@ +/* + * CarbonChat + * + * Copyright (c) 2021 Josua Parks (Vicarious) + * Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.draycia.carbon.fabric.listeners; import com.google.inject.Inject; @@ -21,7 +40,7 @@ public class FabricChatPreviewListener implements ChatDecorator { } @Override - public CompletableFuture decorate(@Nullable ServerPlayer serverPlayer, Component component) { + public CompletableFuture decorate(final @Nullable ServerPlayer serverPlayer, final Component component) { String content = component.getString(); for (final Map.Entry placeholder : this.configFactory.primaryConfig().chatPlaceholders().entrySet()) { diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricPlayerJoinListener.java b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricPlayerJoinListener.java index 5351945b..8e1410b0 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricPlayerJoinListener.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/listeners/FabricPlayerJoinListener.java @@ -22,7 +22,6 @@ package net.draycia.carbon.fabric.listeners; import com.google.inject.Inject; import java.util.List; import net.draycia.carbon.common.config.ConfigFactory; -import net.draycia.carbon.common.config.PrimaryConfig; import net.fabricmc.fabric.api.networking.v1.PacketSender; import net.fabricmc.fabric.api.networking.v1.ServerPlayConnectionEvents; import net.minecraft.network.protocol.game.ClientboundCustomChatCompletionsPacket; @@ -43,7 +42,7 @@ public class FabricPlayerJoinListener implements ServerPlayConnectionEvents.Join } @Override - public void onPlayReady(final ServerGamePacketListenerImpl handler, PacketSender sender, final MinecraftServer server) { + public void onPlayReady(final ServerGamePacketListenerImpl handler, final PacketSender sender, final MinecraftServer server) { final @Nullable List suggestions = this.configFactory.primaryConfig().customChatSuggestions(); if (suggestions == null || suggestions.isEmpty()) { diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ChatListenerMixin.java b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ChatListenerMixin.java index 26e9c7fb..7f985b69 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ChatListenerMixin.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ChatListenerMixin.java @@ -1,3 +1,22 @@ +/* + * CarbonChat + * + * Copyright (c) 2021 Josua Parks (Vicarious) + * Contributors + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ package net.draycia.carbon.fabric.mixin; import java.util.UUID; @@ -13,7 +32,7 @@ import org.spongepowered.asm.mixin.injection.ModifyVariable; abstract class ChatListenerMixin { @ModifyVariable(at = @At("HEAD"), index = 1, method = "send(Lnet/minecraft/network/protocol/Packet;Lio/netty/util/concurrent/GenericFutureListener;)V", argsOnly = true) - private Packet sendPacket(Packet packet) { + private Packet sendPacket(final Packet packet) { if (packet instanceof ClientboundPlayerChatPacket chatPacket) { final UUID uuid = UUID.nameUUIDFromBytes(chatPacket.message().headerSignature().bytes()); CarbonChatFabric.addMessageSignature(uuid, chatPacket.message().headerSignature()); diff --git a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ServerPlayerMixin.java b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ServerPlayerMixin.java index 8f236bd9..c309e1aa 100644 --- a/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ServerPlayerMixin.java +++ b/fabric/src/main/java/net/draycia/carbon/fabric/mixin/ServerPlayerMixin.java @@ -21,9 +21,7 @@ package net.draycia.carbon.fabric.mixin; import net.draycia.carbon.fabric.callback.PlayerStatusMessageEvents; import net.kyori.adventure.platform.fabric.FabricServerAudiences; -import net.minecraft.network.chat.ChatType; import net.minecraft.network.chat.Component; -import net.minecraft.resources.ResourceKey; import net.minecraft.server.MinecraftServer; import net.minecraft.server.level.ServerPlayer; import net.minecraft.server.players.PlayerList;