diff --git a/README.md b/README.md new file mode 100644 index 0000000..4a2e3c3 --- /dev/null +++ b/README.md @@ -0,0 +1,18 @@ +# GlobalLinkServer Plugin + +### `server.properties` +```properties +allow-nether=false +generate-structures=false +generator-settings={"biome"\:"minecraft\:the_void","layers"\:[{"block"\:"minecraft\:air","height"\:1}]} +level-type=minecraft\:flat +motd=§aGeyserMC §bLinking §fServer +spawn-protection=200 +``` + +### `bukkit.yml` +```yaml +settings: + allow-end: false +``` + diff --git a/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java b/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java index 1af1006..ce2e820 100644 --- a/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java +++ b/src/main/java/org/geysermc/globallinkserver/GlobalLinkServer.java @@ -19,6 +19,9 @@ import net.kyori.adventure.text.Component; import net.kyori.adventure.text.format.NamedTextColor; import org.bukkit.Bukkit; +import org.bukkit.GameMode; +import org.bukkit.GameRule; +import org.bukkit.World; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -108,6 +111,22 @@ public void onEnable() { ); }); + // Set game rules + World world = getServer().getWorld("world"); + world.setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false); + world.setGameRule(GameRule.DO_MOB_SPAWNING, false); + world.setGameRule(GameRule.DO_WEATHER_CYCLE, false); + world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); + world.setGameRule(GameRule.FALL_DAMAGE, false); + world.setGameRule(GameRule.DO_IMMEDIATE_RESPAWN, true); + world.setGameRule(GameRule.RANDOM_TICK_SPEED, 0); + world.setGameRule(GameRule.SHOW_DEATH_MESSAGES, false); + + // Make nighttime + world.setTime(18000); + + getServer().setDefaultGameMode(GameMode.ADVENTURE); + LOGGER.info("Started Global Linking Server plugin!"); } @@ -135,30 +154,29 @@ public void onCommands(PlayerCommandSendEvent event) { @EventHandler public void onPlayerLoad(PlayerJoinEvent event) { - if (config.util().hideJoinLeaveMessages()) event.joinMessage(null); - Utils.processJoin(event.getPlayer()); + event.joinMessage(null); - if (config.util().hidePlayers()) { - Bukkit.getOnlinePlayers().forEach(player -> { - event.getPlayer().hidePlayer(this, player); - player.hidePlayer(this, event.getPlayer()); - }); - } + event.getPlayer().setPersistent(false); + event.getPlayer().setAllowFlight(true); + + // Hide all players from each other + Bukkit.getOnlinePlayers().forEach(player -> { + event.getPlayer().hidePlayer(this, player); + player.hidePlayer(this, event.getPlayer()); + }); - if (config.util().respawnOnJoin()) Utils.fakeRespawn(event.getPlayer()); + Utils.processJoin(event.getPlayer()); } @EventHandler public void onPlayerLeave(PlayerQuitEvent event) { - if (config.util().hideJoinLeaveMessages()) event.quitMessage(null); + event.quitMessage(null); Utils.processLeave(event.getPlayer()); } @EventHandler public void onEntityDamage(EntityDamageEvent event) { - if (config.util().voidTeleport() - && event.getEntity() instanceof Player player - && event.getCause() == EntityDamageEvent.DamageCause.VOID) { + if (event.getCause() == EntityDamageEvent.DamageCause.VOID && event.getEntity() instanceof Player player) { event.setCancelled(true); Utils.fakeRespawn(player); @@ -167,26 +185,23 @@ public void onEntityDamage(EntityDamageEvent event) { @EventHandler public void onFoodLevelChange(FoodLevelChangeEvent event) { - if (config.util().preventHunger()) { - if (event.getFoodLevel() < event.getEntity().getFoodLevel()) { - event.setCancelled(true); - } + if (event.getFoodLevel() < event.getEntity().getFoodLevel()) { + event.setCancelled(true); } } @EventHandler public void onDeath(PlayerDeathEvent event) { - if (config.util().hideDeathMessages()) event.deathMessage(null); + event.deathMessage(null); } @EventHandler public void onPlayerChat(AsyncChatEvent event) { - if (config.util().disableChat()) event.setCancelled(true); + event.setCancelled(true); } @EventHandler public void onServerListPing(PaperServerListPingEvent event) { - if (!config.util().hidePlayerCount()) return; event.getListedPlayers().clear(); event.setNumPlayers(0); event.setMaxPlayers(1); @@ -194,6 +209,6 @@ public void onServerListPing(PaperServerListPingEvent event) { @EventHandler public void onPlayerRecipeDiscover(PlayerRecipeDiscoverEvent event) { - if (config.util().disableRecipeDiscover()) event.setCancelled(true); + 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 e09039a..193620c 100644 --- a/src/main/java/org/geysermc/globallinkserver/config/Config.java +++ b/src/main/java/org/geysermc/globallinkserver/config/Config.java @@ -6,8 +6,7 @@ package org.geysermc.globallinkserver.config; public record Config( - Database database, - Util util + Database database ) { public record Database( String hostname, @@ -15,16 +14,4 @@ public record Database( String password, String database ) {} - - public record Util( - boolean hideJoinLeaveMessages, - boolean hideDeathMessages, - boolean hidePlayers, - boolean disableChat, - boolean voidTeleport, - boolean preventHunger, - 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 dcd2de8..19d4ee4 100644 --- a/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java +++ b/src/main/java/org/geysermc/globallinkserver/config/ConfigReader.java @@ -15,23 +15,12 @@ public static Config readConfig(JavaPlugin plugin) { plugin.saveConfig(); var database = config.getConfigurationSection("database"); - var util = config.getConfigurationSection("util"); return new Config(new Config.Database( database.getString("hostname"), database.getString("username"), database.getString("password"), database.getString("database") - ), new Config.Util( - util.getBoolean("hide-join-leave-messages"), - util.getBoolean("hide-death-messages"), - util.getBoolean("hide-players"), - util.getBoolean("disable-chat"), - util.getBoolean("void-teleport"), - util.getBoolean("prevent-hunger"), - util.getBoolean("respawn-on-join"), - util.getBoolean("hide-player-count"), - util.getBoolean("disable-recipe-discover") )); } }