This repository has been archived by the owner on May 13, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 7
/
ChatManager.java
218 lines (161 loc) · 8.88 KB
/
ChatManager.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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
package me.h1dd3nxn1nja.chatmanager;
import com.ryderbelserion.chatmanager.ApiLoader;
import me.h1dd3nxn1nja.chatmanager.api.CrazyManager;
import me.h1dd3nxn1nja.chatmanager.commands.*;
import me.h1dd3nxn1nja.chatmanager.commands.tabcompleter.*;
import me.h1dd3nxn1nja.chatmanager.listeners.*;
import me.h1dd3nxn1nja.chatmanager.managers.AutoBroadcastManager;
import me.h1dd3nxn1nja.chatmanager.support.PluginManager;
import me.h1dd3nxn1nja.chatmanager.support.PluginSupport;
import me.h1dd3nxn1nja.chatmanager.utils.BossBarUtil;
import me.h1dd3nxn1nja.chatmanager.utils.MetricsHandler;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.PluginCommand;
import org.bukkit.command.TabCompleter;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
public class ChatManager extends JavaPlugin {
private static ChatManager plugin;
private SettingsManager settingsManager;
private CrazyManager crazyManager;
private PluginManager pluginManager;
private ApiLoader api;
public void onEnable() {
plugin = this;
settingsManager = new SettingsManager();
settingsManager.setup();
api = new ApiLoader();
api.load();
boolean metricsEnabled = settingsManager.getConfig().getBoolean("Metrics_Enabled");
pluginManager = new PluginManager();
crazyManager = new CrazyManager();
if (metricsEnabled) {
MetricsHandler metricsHandler = new MetricsHandler();
metricsHandler.start();
}
crazyManager.load(true);
if (!PluginSupport.LUCKPERMS.isPluginEnabled()) plugin.getLogger().severe("A permissions plugin was not found. You will likely have issues without one.");
if (PluginSupport.VAULT.isPluginEnabled()) {
registerCommands();
registerEvents();
setupAutoBroadcast();
setupChatRadius();
}
}
public void onDisable() {
getServer().getScheduler().cancelTasks(this);
for (Player all : getServer().getOnlinePlayers()) {
Methods.cm_chatCooldown.remove(all);
Methods.cm_cooldownTask.remove(all);
Methods.cm_commandCooldown.remove(all);
Methods.cm_cooldownTask.remove(all);
BossBarUtil bossBar = new BossBarUtil();
bossBar.removeAllBossBars(all);
}
}
public void registerCommands() {
CommandBroadcast broadCastCommand = new CommandBroadcast();
registerCommand(getCommand("Announcement"), null, broadCastCommand);
registerCommand(getCommand("Warning"), null, broadCastCommand);
registerCommand(getCommand("Broadcast"), null, broadCastCommand);
registerCommand(getCommand("AutoBroadcast"), new TabCompleteAutoBroadcast(), new CommandAutoBroadcast());
CommandLists listsCommand = new CommandLists();
registerCommand(getCommand("List"), null, listsCommand);
registerCommand(getCommand("Staff"), null, listsCommand);
registerCommand(getCommand("ClearChat"), null, new CommandClearChat());
registerCommand(getCommand("BannedCommands"), new TabCompleteBannedCommands(), new CommandBannedCommands());
registerCommand(getCommand("AntiSwear"), new TabCompleteAntiSwear(), new CommandAntiSwear());
CommandColor commandColor = new CommandColor();
registerCommand(getCommand("Colors"), null, commandColor);
registerCommand(getCommand("Formats"), null, commandColor);
CommandMessage commandMessage = new CommandMessage();
registerCommand(getCommand("Reply"), null, commandMessage);
registerCommand(getCommand("TogglePM"), null, commandMessage);
registerCommand(getCommand("Message"), new TabCompleteMessage(), commandMessage);
registerCommand(getCommand("StaffChat"), null, new CommandStaffChat());
registerCommand(getCommand("ChatRadius"), null, new CommandRadius());
registerCommand(getCommand("ChatManager"), new TabCompleteChatManager(), new CommandChatManager());
CommandSpy commandSpy = new CommandSpy();
registerCommand(getCommand("CommandSpy"), null, commandSpy);
registerCommand(getCommand("SocialSpy"), null, commandSpy);
registerCommand(getCommand("MuteChat"), null, new CommandMuteChat());
registerCommand(getCommand("PerWorldChat"), null, new CommandPerWorldChat());
registerCommand(getCommand("Ping"), null, new CommandPing());
registerCommand(getCommand("Rules"), null, new CommandRules());
registerCommand(getCommand("ToggleChat"), null, new CommandToggleChat());
registerCommand(getCommand("ToggleMentions"), null, new CommandToggleMentions());
}
private void registerCommand(PluginCommand pluginCommand, TabCompleter tabCompleter, CommandExecutor commandExecutor) {
if (pluginCommand != null) {
pluginCommand.setExecutor(commandExecutor);
if (tabCompleter != null) pluginCommand.setTabCompleter(tabCompleter);
}
}
public void registerEvents() {
getServer().getPluginManager().registerEvents(new ListenerAntiAdvertising(), this);
getServer().getPluginManager().registerEvents(new ListenerAntiBot(), this);
getServer().getPluginManager().registerEvents(new ListenerAntiSpam(), this);
getServer().getPluginManager().registerEvents(new ListenerAntiUnicode(), this);
getServer().getPluginManager().registerEvents(new ListenerBannedCommand(), this);
getServer().getPluginManager().registerEvents(new ListenerCaps(), this);
getServer().getPluginManager().registerEvents(new ListenerChatFormat(), this);
getServer().getPluginManager().registerEvents(new ListenerColor(), this);
getServer().getPluginManager().registerEvents(new ListenerRadius(), this);
getServer().getPluginManager().registerEvents(new ListenerGrammar(), this);
getServer().getPluginManager().registerEvents(new ListenerLogs(), this);
getServer().getPluginManager().registerEvents(new CommandMOTD(), this);
getServer().getPluginManager().registerEvents(new ListenerMentions(), this);
getServer().getPluginManager().registerEvents(new ListenerMuteChat(), this);
getServer().getPluginManager().registerEvents(new ListenerPerWorldChat(), this);
getServer().getPluginManager().registerEvents(new ListenerPlayerJoin(), this);
getServer().getPluginManager().registerEvents(new ListenerSpy(), this);
getServer().getPluginManager().registerEvents(new ListenerStaffChat(), this);
getServer().getPluginManager().registerEvents(new ListenerSwear(), this);
getServer().getPluginManager().registerEvents(new ListenerToggleChat(), this);
}
public void setupChatRadius() {
if (settingsManager.getConfig().getBoolean("Chat_Radius.Enable")) {
for (Player all : getServer().getOnlinePlayers()) {
if (settingsManager.getConfig().getString("Chat_Radius.Default_Channel").equalsIgnoreCase("Local")) {
plugin.api().getLocalChatData().addUser(all.getUniqueId());
} else if (settingsManager.getConfig().getString("Chat_Radius.Default_Channel").equalsIgnoreCase("Global")) {
plugin.api.getGlobalChatData().addUser(all.getUniqueId());
} else if (settingsManager.getConfig().getString("Chat_Radius.Default_Channel").equalsIgnoreCase("World")) {
plugin.api.getWorldChatData().addUser(all.getUniqueId());
}
}
}
}
public void setupAutoBroadcast() {
try {
if (settingsManager.getAutoBroadcast().getBoolean("Auto_Broadcast.Actionbar_Messages.Enable"))
AutoBroadcastManager.actionbarMessages();
if (settingsManager.getAutoBroadcast().getBoolean("Auto_Broadcast.Global_Messages.Enable"))
AutoBroadcastManager.globalMessages();
if (settingsManager.getAutoBroadcast().getBoolean("Auto_Broadcast.Per_World_Messages.Enable"))
AutoBroadcastManager.perWorldMessages();
if (settingsManager.getAutoBroadcast().getBoolean("Auto_Broadcast.Title_Messages.Enable"))
AutoBroadcastManager.titleMessages();
if (settingsManager.getAutoBroadcast().getBoolean("Auto_Broadcast.Bossbar_Messages.Enable"))
AutoBroadcastManager.bossBarMessages();
} catch (Exception e) {
getLogger().severe("There has been an error setting up auto broadcast. Stacktrace...");
e.printStackTrace();
}
}
public static ChatManager getPlugin() {
return plugin;
}
public ApiLoader api() {
return this.api;
}
public SettingsManager getSettingsManager() {
return settingsManager;
}
public CrazyManager getCrazyManager() {
return crazyManager;
}
public PluginManager getPluginManager() {
return pluginManager;
}
}