diff --git a/pom.xml b/pom.xml index 9baf115..739b1e0 100644 --- a/pom.xml +++ b/pom.xml @@ -5,7 +5,7 @@ com.loohp Limbo Limbo - 0.6.0-ALPHA + 0.6.1-ALPHA Standalone Limbo Minecraft Server. https://github.com/LOOHP/Limbo 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..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()) { - 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/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..bdf62be 100644 --- a/src/main/resources/server.properties +++ b/src/main/resources/server.properties @@ -31,6 +31,10 @@ level-dimension=minecraft:overworld #Whether Flying is allowed 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 default-gamemode=creative