-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
CmdTeamChat.java
93 lines (76 loc) · 3.25 KB
/
CmdTeamChat.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
package com.bgsoftware.superiorskyblock.commands.player;
import com.bgsoftware.superiorskyblock.SuperiorSkyblockPlugin;
import com.bgsoftware.superiorskyblock.api.island.Island;
import com.bgsoftware.superiorskyblock.api.wrappers.SuperiorPlayer;
import com.bgsoftware.superiorskyblock.commands.ISuperiorCommand;
import com.bgsoftware.superiorskyblock.commands.arguments.CommandArguments;
import com.bgsoftware.superiorskyblock.commands.arguments.IslandArgument;
import com.bgsoftware.superiorskyblock.lang.Message;
import com.bgsoftware.superiorskyblock.utils.islands.IslandUtils;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
public final class CmdTeamChat implements ISuperiorCommand {
@Override
public List<String> getAliases() {
return Arrays.asList("teamchat", "chat", "tc");
}
@Override
public String getPermission() {
return "superior.island.teamchat";
}
@Override
public String getUsage(java.util.Locale locale) {
return "teamchat [" + Message.COMMAND_ARGUMENT_MESSAGE.getMessage(locale) + "]";
}
@Override
public String getDescription(java.util.Locale locale) {
return Message.COMMAND_DESCRIPTION_TEAM_CHAT.getMessage(locale);
}
@Override
public int getMinArgs() {
return 1;
}
@Override
public int getMaxArgs() {
return Integer.MAX_VALUE;
}
@Override
public boolean canBeExecutedByConsole() {
return false;
}
@Override
public void execute(SuperiorSkyblockPlugin plugin, CommandSender sender, String[] args) {
IslandArgument arguments = CommandArguments.getSenderIsland(plugin, sender);
Island island = arguments.getIsland();
if (island == null)
return;
SuperiorPlayer superiorPlayer = arguments.getSuperiorPlayer();
if (args.length == 1) {
if (superiorPlayer.hasTeamChatEnabled()) {
Message.TOGGLED_TEAM_CHAT_OFF.send(superiorPlayer);
} else {
Message.TOGGLED_TEAM_CHAT_ON.send(superiorPlayer);
}
superiorPlayer.toggleTeamChat();
} else {
String message = CommandArguments.buildLongString(args, 1, superiorPlayer.hasPermissionWithoutOP("superior.chat.color"));
IslandUtils.sendMessage(island, Message.TEAM_CHAT_FORMAT, new ArrayList<>(), superiorPlayer.getPlayerRole(),
superiorPlayer.getName(), message);
Message.SPY_TEAM_CHAT_FORMAT.send(Bukkit.getConsoleSender(), superiorPlayer.getPlayerRole(), superiorPlayer.getName(), message);
for (Player _onlinePlayer : Bukkit.getOnlinePlayers()) {
SuperiorPlayer onlinePlayer = plugin.getPlayers().getSuperiorPlayer(_onlinePlayer);
if (onlinePlayer.hasAdminSpyEnabled())
Message.SPY_TEAM_CHAT_FORMAT.send(onlinePlayer, superiorPlayer.getPlayerRole(), superiorPlayer.getName(), message);
}
}
}
@Override
public List<String> tabComplete(SuperiorSkyblockPlugin plugin, CommandSender sender, String[] args) {
return Collections.emptyList();
}
}