Split toggleglobalchat into another command
This commit is contained in:
parent
96dbdc6dd0
commit
04ac327365
|
|
@ -3,6 +3,7 @@ package com.alttd.chat;
|
||||||
import com.alttd.chat.commands.GlobalChat;
|
import com.alttd.chat.commands.GlobalChat;
|
||||||
import com.alttd.chat.commands.Message;
|
import com.alttd.chat.commands.Message;
|
||||||
import com.alttd.chat.commands.Reply;
|
import com.alttd.chat.commands.Reply;
|
||||||
|
import com.alttd.chat.commands.ToggleGlobalChat;
|
||||||
import com.alttd.chat.config.Config;
|
import com.alttd.chat.config.Config;
|
||||||
import com.alttd.chat.database.DatabaseConnection;
|
import com.alttd.chat.database.DatabaseConnection;
|
||||||
import com.alttd.chat.handler.ChatHandler;
|
import com.alttd.chat.handler.ChatHandler;
|
||||||
|
|
@ -32,6 +33,7 @@ public class ChatPlugin extends JavaPlugin {
|
||||||
DatabaseConnection.initialize();
|
DatabaseConnection.initialize();
|
||||||
registerListener(new PlayerListener(), new ChatListener());
|
registerListener(new PlayerListener(), new ChatListener());
|
||||||
registerCommand("globalchat", new GlobalChat());
|
registerCommand("globalchat", new GlobalChat());
|
||||||
|
registerCommand("toggleglobalchat", new ToggleGlobalChat());
|
||||||
registerCommand("message", new Message());
|
registerCommand("message", new Message());
|
||||||
registerCommand("reply", new Reply());
|
registerCommand("reply", new Reply());
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -20,15 +20,6 @@ public class GlobalChat implements CommandExecutor {
|
||||||
}
|
}
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
if(args.length == 0) return false;
|
if(args.length == 0) return false;
|
||||||
if(args[0].equalsIgnoreCase("togglegc")) {
|
|
||||||
new BukkitRunnable() {
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
Objects.requireNonNull(ChatUserManager.getChatUser(((Player) sender).getUniqueId())).toggleGc();
|
|
||||||
}
|
|
||||||
}.runTask(ChatPlugin.getInstance());
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
String message = StringUtils.join(args, " ", 0, args.length);
|
String message = StringUtils.join(args, " ", 0, args.length);
|
||||||
ChatPlugin.getInstance().getChatHandler().globalChat(player, message);
|
ChatPlugin.getInstance().getChatHandler().globalChat(player, message);
|
||||||
|
|
|
||||||
33
galaxy/src/main/java/com/alttd/chat/commands/ToggleGlobalChat.java
Executable file
33
galaxy/src/main/java/com/alttd/chat/commands/ToggleGlobalChat.java
Executable file
|
|
@ -0,0 +1,33 @@
|
||||||
|
package com.alttd.chat.commands;
|
||||||
|
|
||||||
|
import com.alttd.chat.ChatPlugin;
|
||||||
|
import com.alttd.chat.managers.ChatUserManager;
|
||||||
|
import com.alttd.chat.objects.ChatUser;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
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.Objects;
|
||||||
|
|
||||||
|
public class ToggleGlobalChat 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() {
|
||||||
|
ChatUser chatUser = ChatUserManager.getChatUser(((Player) sender).getUniqueId());
|
||||||
|
chatUser.toggleGc();
|
||||||
|
sender.sendMessage("You have turned globalchat " + (chatUser.isGcOn() ? "<green>on." : "<red>off.")); // TODO load from config and minimessage
|
||||||
|
}
|
||||||
|
}.runTask(ChatPlugin.getInstance());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
@ -9,6 +9,10 @@ commands:
|
||||||
permission: command.globalchat
|
permission: command.globalchat
|
||||||
permission-message: You do not have permission!
|
permission-message: You do not have permission!
|
||||||
aliases: gc
|
aliases: gc
|
||||||
|
toggleglobalchat:
|
||||||
|
permission: command.globalchat
|
||||||
|
permission-message: You do not have permission!
|
||||||
|
aliases: togglegc
|
||||||
message:
|
message:
|
||||||
permission: command.message
|
permission: command.message
|
||||||
aliases: msg
|
aliases: msg
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user