diff --git a/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java b/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java index 94d7d08..1af1006 100644 --- a/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java +++ b/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java @@ -10,6 +10,7 @@ import java.util.List; import java.util.logging.Logger; +import com.destroystokyo.paper.event.server.PaperServerListPingEvent; import io.papermc.paper.command.brigadier.Commands; import io.papermc.paper.command.brigadier.argument.ArgumentTypes; import io.papermc.paper.event.player.AsyncChatEvent; @@ -27,6 +28,7 @@ import org.bukkit.event.player.PlayerCommandSendEvent; import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerQuitEvent; +import org.bukkit.event.player.PlayerRecipeDiscoverEvent; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.checkerframework.checker.nullness.qual.NonNull; @@ -181,4 +183,17 @@ public void onDeath(PlayerDeathEvent event) { public void onPlayerChat(AsyncChatEvent event) { if (config.util().disableChat()) event.setCancelled(true); } + + @EventHandler + public void onServerListPing(PaperServerListPingEvent event) { + if (!config.util().hidePlayerCount()) return; + event.getListedPlayers().clear(); + event.setNumPlayers(0); + event.setMaxPlayers(1); + } + + @EventHandler + public void onPlayerRecipeDiscover(PlayerRecipeDiscoverEvent event) { + if (config.util().disableRecipeDiscover()) event.setCancelled(true); + } } diff --git a/src/main/java/org/geysermc/globallinkserver/config/Config.java b/src/main/java/org/geysermc/globallinkserver/config/Config.java index f8c9575..e09039a 100644 --- a/src/main/java/org/geysermc/globallinkserver/config/Config.java +++ b/src/main/java/org/geysermc/globallinkserver/config/Config.java @@ -23,6 +23,8 @@ public record Util( boolean disableChat, boolean voidTeleport, boolean preventHunger, - boolean respawnOnJoin + boolean respawnOnJoin, + boolean hidePlayerCount, + boolean disableRecipeDiscover ) {} } diff --git a/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java b/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java index 7e2fe56..dcd2de8 100644 --- a/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java +++ b/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java @@ -29,7 +29,9 @@ public static Config readConfig(JavaPlugin plugin) { util.getBoolean("disable-chat"), util.getBoolean("void-teleport"), util.getBoolean("prevent-hunger"), - util.getBoolean("respawn-on-join") + util.getBoolean("respawn-on-join"), + util.getBoolean("hide-player-count"), + util.getBoolean("disable-recipe-discover") )); } } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e94ccd0..e04d7fa 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -12,3 +12,5 @@ util: void-teleport: true prevent-hunger: true respawn-on-join: true + hide-player-count: true + disable-recipe-discover: true