-
-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathSimplePMs.java
More file actions
66 lines (53 loc) · 2.36 KB
/
SimplePMs.java
File metadata and controls
66 lines (53 loc) · 2.36 KB
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
package adhdmc.simplepms;
import adhdmc.simplepms.commands.PrivateMessage;
import adhdmc.simplepms.commands.ReloadCommand;
import adhdmc.simplepms.commands.ReplyCommand;
import adhdmc.simplepms.commands.SocialSpyCommand;
import adhdmc.simplepms.config.LocaleConfig;
import adhdmc.simplepms.listeners.LoginListener;
import adhdmc.simplepms.listeners.MessageRegexListener;
import adhdmc.simplepms.listeners.QuitListener;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.entity.Player;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.java.JavaPlugin;
import java.util.HashSet;
import java.util.Objects;
public final class SimplePMs extends JavaPlugin {
private static Plugin instance;
private static final MiniMessage miniMessage = MiniMessage.miniMessage();
private static boolean papiEnabled = false;
@Override
public void onEnable() {
instance = this;
registerCommands();
this.getServer().getPluginManager().registerEvents(new LoginListener(), this);
this.getServer().getPluginManager().registerEvents(new QuitListener(), this);
this.getServer().getPluginManager().registerEvents(new MessageRegexListener(), this);
if (this.getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
papiEnabled = true;
} else {
this.getLogger().info("You do not have PlaceholderAPI loaded on your server. Any PlaceholderAPI placeholders used in this plugin's messages, will not work.");
}
LocaleConfig.getInstance().reloadLocale();
}
public static MiniMessage getMiniMessage() {
return miniMessage;
}
public static Plugin getInstance() {
return instance;
}
public static boolean isPapiEnabled() {
return papiEnabled;
}
private void registerCommands() {
Objects.requireNonNull(this.getCommand("msg")).setExecutor(new PrivateMessage());
Objects.requireNonNull(this.getCommand("reply")).setExecutor(new ReplyCommand());
Objects.requireNonNull(this.getCommand("socialspy")).setExecutor(new SocialSpyCommand());
Objects.requireNonNull(this.getCommand("spmreload")).setExecutor(new ReloadCommand());
}
private static final HashSet<Player> spyingPlayers = new HashSet<>();
public static HashSet<Player> getSpyingPlayers() {
return spyingPlayers;
}
}