From a7f6a34fbefc647f85206dac403496f09046fccc Mon Sep 17 00:00:00 2001 From: GrizzlT <13691001+GrizzlT@users.noreply.github.com> Date: Sat, 21 Aug 2021 15:32:32 +0200 Subject: [PATCH 1/4] Added option to disable chat --- src/main/java/com/loohp/limbo/file/ServerProperties.java | 6 ++++++ src/main/java/com/loohp/limbo/player/Player.java | 2 +- src/main/resources/permission.yml | 1 + src/main/resources/server.properties | 3 +++ 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/loohp/limbo/file/ServerProperties.java b/src/main/java/com/loohp/limbo/file/ServerProperties.java index 8e7c981..85da867 100644 --- a/src/main/java/com/loohp/limbo/file/ServerProperties.java +++ b/src/main/java/com/loohp/limbo/file/ServerProperties.java @@ -38,6 +38,7 @@ public class ServerProperties { private Location worldSpawn; private boolean reducedDebugInfo; private boolean allowFlight; + private boolean allowChat; private String motdJson; private String versionString; private int protocol; @@ -93,6 +94,7 @@ public class ServerProperties { worldSpawn = new Location(world, x, y, z, yaw, pitch); reducedDebugInfo = Boolean.parseBoolean(prop.getProperty("reduced-debug-info")); allowFlight = Boolean.parseBoolean(prop.getProperty("allow-flight")); + allowChat = Boolean.parseBoolean(prop.getProperty("allow-chat")); motdJson = prop.getProperty("motd"); versionString = prop.getProperty("version"); bungeecord = Boolean.parseBoolean(prop.getProperty("bungeecord")); @@ -213,6 +215,10 @@ public class ServerProperties { return allowFlight; } + public boolean isAllowChat() { + return this.allowChat; + } + public String getMotdJson() { return motdJson; } diff --git a/src/main/java/com/loohp/limbo/player/Player.java b/src/main/java/com/loohp/limbo/player/Player.java index 6fe8c3d..401c999 100644 --- a/src/main/java/com/loohp/limbo/player/Player.java +++ b/src/main/java/com/loohp/limbo/player/Player.java @@ -249,7 +249,7 @@ public class Player extends LivingEntity implements CommandSender { public void chat(String message) { String format = "<%name%> %message%"; PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, format, message, false)); - if (!event.isCancelled()) { + if ((!event.isCancelled() || this.hasPermission("limboserver.chat")) && Limbo.getInstance().getServerProperties().isAllowChat()) { String chat = event.getFormat().replace("%name%", username).replace("%message%", event.getMessage()); Limbo.getInstance().getConsole().sendMessage(chat); for (Player each : Limbo.getInstance().getPlayers()) { diff --git a/src/main/resources/permission.yml b/src/main/resources/permission.yml index 662a2e5..1741352 100644 --- a/src/main/resources/permission.yml +++ b/src/main/resources/permission.yml @@ -6,6 +6,7 @@ groups: - limboserver.gamemode default: - limboserver.spawn + - limboserver.chat players: LOOHP: diff --git a/src/main/resources/server.properties b/src/main/resources/server.properties index cc712b1..e22ba23 100644 --- a/src/main/resources/server.properties +++ b/src/main/resources/server.properties @@ -31,6 +31,9 @@ level-dimension=minecraft:overworld #Whether Flying is allowed allow-flight=false +#Whether chat messages are allowed +allow-chat=true + #GameMode, survival, creative, adventure, spectator default-gamemode=creative From 268b8dc2349106dfb8bca6d20f6565f35db921d3 Mon Sep 17 00:00:00 2001 From: GrizzlT <13691001+GrizzlT@users.noreply.github.com> Date: Sat, 21 Aug 2021 15:44:03 +0200 Subject: [PATCH 2/4] Corrected conditions to better meet expectations --- src/main/java/com/loohp/limbo/player/Player.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/loohp/limbo/player/Player.java b/src/main/java/com/loohp/limbo/player/Player.java index 401c999..b02d579 100644 --- a/src/main/java/com/loohp/limbo/player/Player.java +++ b/src/main/java/com/loohp/limbo/player/Player.java @@ -249,7 +249,7 @@ public class Player extends LivingEntity implements CommandSender { public void chat(String message) { String format = "<%name%> %message%"; PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, format, message, false)); - if ((!event.isCancelled() || this.hasPermission("limboserver.chat")) && Limbo.getInstance().getServerProperties().isAllowChat()) { + if (!event.isCancelled() && (Limbo.getInstance().getServerProperties().isAllowChat() || this.hasPermission("limboserver.chat"))) { String chat = event.getFormat().replace("%name%", username).replace("%message%", event.getMessage()); Limbo.getInstance().getConsole().sendMessage(chat); for (Player each : Limbo.getInstance().getPlayers()) { From 6ce1a73411e841e9370ec08788603da548a1efb5 Mon Sep 17 00:00:00 2001 From: GrizzlT <13691001+GrizzlT@users.noreply.github.com> Date: Sat, 21 Aug 2021 18:58:25 +0200 Subject: [PATCH 3/4] Changed chat conditions --- .../java/com/loohp/limbo/player/Player.java | 16 ++--- src/main/resources/server.properties | 1 + target/classes/server.properties | 59 +++++++++++++++++++ 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 target/classes/server.properties diff --git a/src/main/java/com/loohp/limbo/player/Player.java b/src/main/java/com/loohp/limbo/player/Player.java index b02d579..ff34b48 100644 --- a/src/main/java/com/loohp/limbo/player/Player.java +++ b/src/main/java/com/loohp/limbo/player/Player.java @@ -247,13 +247,15 @@ public class Player extends LivingEntity implements CommandSender { } public void chat(String message) { - String format = "<%name%> %message%"; - PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, format, message, false)); - if (!event.isCancelled() && (Limbo.getInstance().getServerProperties().isAllowChat() || this.hasPermission("limboserver.chat"))) { - String chat = event.getFormat().replace("%name%", username).replace("%message%", event.getMessage()); - Limbo.getInstance().getConsole().sendMessage(chat); - for (Player each : Limbo.getInstance().getPlayers()) { - each.sendMessage(chat, uuid); + if (Limbo.getInstance().getServerProperties().isAllowChat()) { + String format = "<%name%> %message%"; + PlayerChatEvent event = (PlayerChatEvent) Limbo.getInstance().getEventsManager().callEvent(new PlayerChatEvent(this, format, message, false)); + if (!event.isCancelled() && this.hasPermission("limboserver.chat")) { + String chat = event.getFormat().replace("%name%", username).replace("%message%", event.getMessage()); + Limbo.getInstance().getConsole().sendMessage(chat); + for (Player each : Limbo.getInstance().getPlayers()) { + each.sendMessage(chat, uuid); + } } } } diff --git a/src/main/resources/server.properties b/src/main/resources/server.properties index e22ba23..bdf62be 100644 --- a/src/main/resources/server.properties +++ b/src/main/resources/server.properties @@ -32,6 +32,7 @@ level-dimension=minecraft:overworld allow-flight=false #Whether chat messages are allowed +#Setting this property to false should give more performance but will render the "limboserver.chat" permission powerless allow-chat=true #GameMode, survival, creative, adventure, spectator diff --git a/target/classes/server.properties b/target/classes/server.properties new file mode 100644 index 0000000..e22ba23 --- /dev/null +++ b/target/classes/server.properties @@ -0,0 +1,59 @@ +#Server max players, -1 for no limit +max-players=-1 + +#Server port +server-port=30000 + +#Server ip, localhost for local access only +server-ip=0.0.0.0 + +#Whether this server is behind a bungeecord proxy +#Mutually exclusive with velocity-modern and bungee-guard +bungeecord=false + +#Whether this server is behind a velocity proxy with modern player forwarding +#Mutually exclusive with bungeecord and bungee-guard +velocity-modern=false + +#Whether this server is behind a bungeecord proxy with BungeeGuard installed (velocity can do this too for <1.13) +#Mutually exclusive with bungeecord and velocity-modern +bungee-guard=false + +#For Velocity Modern Forwarding or BungeeGuard a list (separated by `;`) of valid secrets +forwarding-secrets= + +#World Name and the Schematic file containing map +level-name=world;spawn.schem + +#Dimension, "minecraft:overworld", "minecraft:the_nether" or "minecraft:the_end" +level-dimension=minecraft:overworld + +#Whether Flying is allowed +allow-flight=false + +#Whether chat messages are allowed +allow-chat=true + +#GameMode, survival, creative, adventure, spectator +default-gamemode=creative + +#Spawn location +world-spawn=world;20.5;17;22.5;-90;0 + +#Reduce debug info +reduced-debug-info=false + +#The view distance of the server +view-distance=6 + +#Ticks per second of the server +ticks-per-second=5 + +#Should a message be printed to the console when a handshake occurs +handshake-verbose=true + +#Server list message in Json +motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]} + +#Server list version as string +version=Limbo! \ No newline at end of file From 01cbb1859bdd583e98de56647da3dd9e41cd5e94 Mon Sep 17 00:00:00 2001 From: GrizzlT <13691001+GrizzlT@users.noreply.github.com> Date: Sat, 21 Aug 2021 19:08:50 +0200 Subject: [PATCH 4/4] Please add a gitignore, would be really convenient --- target/classes/server.properties | 59 -------------------------------- 1 file changed, 59 deletions(-) delete mode 100644 target/classes/server.properties diff --git a/target/classes/server.properties b/target/classes/server.properties deleted file mode 100644 index e22ba23..0000000 --- a/target/classes/server.properties +++ /dev/null @@ -1,59 +0,0 @@ -#Server max players, -1 for no limit -max-players=-1 - -#Server port -server-port=30000 - -#Server ip, localhost for local access only -server-ip=0.0.0.0 - -#Whether this server is behind a bungeecord proxy -#Mutually exclusive with velocity-modern and bungee-guard -bungeecord=false - -#Whether this server is behind a velocity proxy with modern player forwarding -#Mutually exclusive with bungeecord and bungee-guard -velocity-modern=false - -#Whether this server is behind a bungeecord proxy with BungeeGuard installed (velocity can do this too for <1.13) -#Mutually exclusive with bungeecord and velocity-modern -bungee-guard=false - -#For Velocity Modern Forwarding or BungeeGuard a list (separated by `;`) of valid secrets -forwarding-secrets= - -#World Name and the Schematic file containing map -level-name=world;spawn.schem - -#Dimension, "minecraft:overworld", "minecraft:the_nether" or "minecraft:the_end" -level-dimension=minecraft:overworld - -#Whether Flying is allowed -allow-flight=false - -#Whether chat messages are allowed -allow-chat=true - -#GameMode, survival, creative, adventure, spectator -default-gamemode=creative - -#Spawn location -world-spawn=world;20.5;17;22.5;-90;0 - -#Reduce debug info -reduced-debug-info=false - -#The view distance of the server -view-distance=6 - -#Ticks per second of the server -ticks-per-second=5 - -#Should a message be printed to the console when a handshake occurs -handshake-verbose=true - -#Server list message in Json -motd={"text":"","extra":[{"text":"Limbo Server!","color":"yellow"}]} - -#Server list version as string -version=Limbo! \ No newline at end of file