From 27e7729a3d23191bbda89731a7ca2a5bceaccfeb Mon Sep 17 00:00:00 2001 From: UserNugget Date: Thu, 13 Jun 2024 01:23:24 +0300 Subject: [PATCH] Remove DummyPlayer (improves build stability alot) --- build.gradle | 2 +- .../java/net/elytrium/fastmotd/FastMOTD.java | 3 +- .../elytrium/fastmotd/dummy/DummyPlayer.java | 259 ------------------ 3 files changed, 2 insertions(+), 262 deletions(-) delete mode 100644 src/main/java/net/elytrium/fastmotd/dummy/DummyPlayer.java diff --git a/build.gradle b/build.gradle index c0f703b..58538ee 100644 --- a/build.gradle +++ b/build.gradle @@ -41,7 +41,7 @@ dependencies { implementation("net.elytrium.commons:kyori:1.3.0") implementation("net.elytrium.commons:velocity:1.3.0") implementation("net.elytrium.commons:utils:1.3.0") - implementation("net.elytrium:fastprepare:1.0.8") + implementation("net.elytrium:fastprepare:1.0.10") implementation("net.elytrium:serializer:1.1.1") implementation('it.unimi.dsi:fastutil-core:8.5.11') compileOnly("com.velocitypowered:velocity-api:3.3.0-SNAPSHOT") diff --git a/src/main/java/net/elytrium/fastmotd/FastMOTD.java b/src/main/java/net/elytrium/fastmotd/FastMOTD.java index a74cf11..c58d085 100644 --- a/src/main/java/net/elytrium/fastmotd/FastMOTD.java +++ b/src/main/java/net/elytrium/fastmotd/FastMOTD.java @@ -61,7 +61,6 @@ import net.elytrium.commons.utils.updates.UpdatesChecker; import net.elytrium.fastmotd.command.MaintenanceCommand; import net.elytrium.fastmotd.command.ReloadCommand; -import net.elytrium.fastmotd.dummy.DummyPlayer; import net.elytrium.fastmotd.injection.ServerChannelInitializerHook; import net.elytrium.fastmotd.listener.CompatPingListener; import net.elytrium.fastmotd.listener.DisconnectOnZeroPlayersListener; @@ -375,7 +374,7 @@ public ServerPing getNextCompat(ProtocolVersion version, String serverAddress) { } public void inject(MinecraftConnection connection, ChannelPipeline pipeline) { - this.preparedPacketFactory.inject(DummyPlayer.INSTANCE, connection, pipeline); + this.preparedPacketFactory.inject(false, connection, pipeline); } public boolean checkKickWhitelist(InetAddress inetAddress) { diff --git a/src/main/java/net/elytrium/fastmotd/dummy/DummyPlayer.java b/src/main/java/net/elytrium/fastmotd/dummy/DummyPlayer.java deleted file mode 100644 index 9fd25f5..0000000 --- a/src/main/java/net/elytrium/fastmotd/dummy/DummyPlayer.java +++ /dev/null @@ -1,259 +0,0 @@ -/* - * Copyright (C) 2022 - 2023 Elytrium - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU Affero 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 Affero General Public License for more details. - * - * You should have received a copy of the GNU Affero General Public License - * along with this program. If not, see . - */ - -package net.elytrium.fastmotd.dummy; - -import com.velocitypowered.api.network.ProtocolState; -import com.velocitypowered.api.network.ProtocolVersion; -import com.velocitypowered.api.permission.Tristate; -import com.velocitypowered.api.proxy.ConnectionRequestBuilder; -import com.velocitypowered.api.proxy.Player; -import com.velocitypowered.api.proxy.ServerConnection; -import com.velocitypowered.api.proxy.crypto.IdentifiedKey; -import com.velocitypowered.api.proxy.messages.ChannelIdentifier; -import com.velocitypowered.api.proxy.messages.PluginMessageEncoder; -import com.velocitypowered.api.proxy.player.PlayerSettings; -import com.velocitypowered.api.proxy.player.ResourcePackInfo; -import com.velocitypowered.api.proxy.player.TabList; -import com.velocitypowered.api.proxy.server.RegisteredServer; -import com.velocitypowered.api.util.GameProfile; -import com.velocitypowered.api.util.ModInfo; -import java.net.InetSocketAddress; -import java.util.Collection; -import java.util.List; -import java.util.Locale; -import java.util.Optional; -import java.util.UUID; -import net.kyori.adventure.identity.Identity; -import net.kyori.adventure.text.Component; -import org.checkerframework.checker.nullness.qual.Nullable; -import org.jetbrains.annotations.NotNull; - -public class DummyPlayer implements Player { - - public static final DummyPlayer INSTANCE = new DummyPlayer(); - - @Override - public String getUsername() { - return null; - } - - @Override - public @Nullable Locale getEffectiveLocale() { - return null; - } - - @Override - public void setEffectiveLocale(Locale locale) { - - } - - @Override - public UUID getUniqueId() { - return null; - } - - @Override - public Optional getCurrentServer() { - return Optional.empty(); - } - - @Override - public PlayerSettings getPlayerSettings() { - return null; - } - - @Override - public boolean hasSentPlayerSettings() { - return false; - } - - @Override - public Optional getModInfo() { - return Optional.empty(); - } - - @Override - public long getPing() { - return 0; - } - - @Override - public boolean isOnlineMode() { - return false; - } - - @Override - public ConnectionRequestBuilder createConnectionRequest(RegisteredServer server) { - return null; - } - - @Override - public List getGameProfileProperties() { - return null; - } - - @Override - public void setGameProfileProperties(List properties) { - - } - - @Override - public GameProfile getGameProfile() { - return null; - } - - @Override - public void clearPlayerListHeaderAndFooter() { - - } - - @Override - public Component getPlayerListHeader() { - return null; - } - - @Override - public Component getPlayerListFooter() { - return null; - } - - @Override - public TabList getTabList() { - return null; - } - - @Override - public void disconnect(Component reason) { - - } - - @Override - public void spoofChatInput(String input) { - - } - - @Override - public void sendResourcePack(String url) { - - } - - @Override - public void sendResourcePack(String url, byte[] hash) { - - } - - @Override - public void sendResourcePackOffer(ResourcePackInfo packInfo) { - - } - - @Override - public @Nullable ResourcePackInfo getAppliedResourcePack() { - return null; - } - - @Override - public @Nullable ResourcePackInfo getPendingResourcePack() { - return null; - } - - @Override - public Collection getAppliedResourcePacks() { - throw new IllegalStateException(); - } - - @Override - public Collection getPendingResourcePacks() { - throw new IllegalStateException(); - } - - @Override - public boolean sendPluginMessage(ChannelIdentifier identifier, byte[] data) { - return false; - } - - @Override - public boolean sendPluginMessage(ChannelIdentifier identifier, PluginMessageEncoder dataEncoder) { - return false; - } - - @Override - public @Nullable String getClientBrand() { - return null; - } - - @Override - public void addCustomChatCompletions(@NotNull Collection collection) { - - } - - @Override - public void removeCustomChatCompletions(@NotNull Collection collection) { - - } - - @Override - public void setCustomChatCompletions(@NotNull Collection collection) { - - } - - @Override - public void transferToHost(@NotNull InetSocketAddress inetSocketAddress) { - - } - - @Override - public Tristate getPermissionValue(String permission) { - return null; - } - - @Override - public InetSocketAddress getRemoteAddress() { - return null; - } - - @Override - public Optional getVirtualHost() { - return Optional.empty(); - } - - @Override - public boolean isActive() { - return false; - } - - @Override - public ProtocolVersion getProtocolVersion() { - return null; - } - - @Override - public ProtocolState getProtocolState() { - return null; - } - - @Override - public IdentifiedKey getIdentifiedKey() { - return null; - } - - @Override - public @NotNull Identity identity() { - throw new IllegalStateException(); - } -}