Skip to content

Commit

Permalink
Disable recipes and players in ping
Browse files Browse the repository at this point in the history
  • Loading branch information
rtm516 committed Jan 11, 2025
1 parent dadcf6b commit a990a70
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 2 deletions.
15 changes: 15 additions & 0 deletions src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ public record Util(
boolean disableChat,
boolean voidTeleport,
boolean preventHunger,
boolean respawnOnJoin
boolean respawnOnJoin,
boolean hidePlayerCount,
boolean disableRecipeDiscover
) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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")
));
}
}
2 changes: 2 additions & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,5 @@ util:
void-teleport: true
prevent-hunger: true
respawn-on-join: true
hide-player-count: true
disable-recipe-discover: true

0 comments on commit a990a70

Please sign in to comment.