Added a way to mute all chat
This commit is contained in:
parent
e7d508d8d1
commit
5a362ca67d
|
|
@ -238,6 +238,12 @@ public final class Config {
|
|||
|
||||
}
|
||||
|
||||
public static String SERVERMUTEPERMISSION = "chat.server-mute";
|
||||
|
||||
private static void permissions() {
|
||||
SERVERMUTEPERMISSION = getString("permissions.server-mute", SERVERMUTEPERMISSION);
|
||||
}
|
||||
|
||||
public static String IP = "0.0.0.0";
|
||||
public static String PORT = "3306";
|
||||
public static String DATABASE = "database";
|
||||
|
|
|
|||
|
|
@ -70,8 +70,10 @@ public final class ServerConfig {
|
|||
|
||||
public boolean GLOBALCHAT = true;
|
||||
public boolean JOINLEAVEMSSAGES = true;
|
||||
public boolean MUTED = false;
|
||||
private void ServerSettings() {
|
||||
GLOBALCHAT = getBoolean("global-chat-enabled", GLOBALCHAT);
|
||||
JOINLEAVEMSSAGES = getBoolean("joinleave-messages-enabled", JOINLEAVEMSSAGES);
|
||||
MUTED = getBoolean("server-muted", MUTED);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
37
galaxy/src/main/java/com/alttd/chat/commands/MuteServer.java
Normal file
37
galaxy/src/main/java/com/alttd/chat/commands/MuteServer.java
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package com.alttd.chat.commands;
|
||||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.util.Utility;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public class MuteServer implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
if(!(sender instanceof Player)) { // must be a player
|
||||
return true;
|
||||
}
|
||||
new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
UUID uuid = ((Player) sender).getUniqueId();
|
||||
if (!Utility.hasPermission(uuid, Config.SERVERMUTEPERMISSION)) {
|
||||
Utility.noPermission(sender);
|
||||
return;
|
||||
}
|
||||
ChatPlugin.getInstance().toggleServerMuted();
|
||||
sender.sendMessage(MiniMessage.get().parse("You have " + (!Utility.hasPermission(uuid, Config.GCPERMISSION) ? "<green>muted</green>" : "<red>unmuted</red>")) + " chat for this server."); // TODO load from config and minimessage
|
||||
}
|
||||
}.runTaskAsynchronously(ChatPlugin.getInstance());
|
||||
return false;
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user