Only showing join/leave/etc. messages if not hooked
This commit is contained in:
parent
0c9dd6f49a
commit
20ff9cc3e6
3 changed files with 26 additions and 5 deletions
11
src/main/java/buttondevteam/discordplugin/ChromaBot.java
Normal file
11
src/main/java/buttondevteam/discordplugin/ChromaBot.java
Normal file
|
@ -0,0 +1,11 @@
|
||||||
|
package buttondevteam.discordplugin;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class ChromaBot {
|
||||||
|
/**
|
||||||
|
* May be null if it's not initialized
|
||||||
|
*/
|
||||||
|
public @Getter ChromaBot instance;
|
||||||
|
// TODO
|
||||||
|
}
|
|
@ -44,14 +44,21 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
|
||||||
public static DiscordPlugin plugin;
|
public static DiscordPlugin plugin;
|
||||||
public static boolean SafeMode = true;
|
public static boolean SafeMode = true;
|
||||||
public static List<String> GameRoles;
|
public static List<String> GameRoles;
|
||||||
|
public static boolean hooked = false;
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
try {
|
try {
|
||||||
Bukkit.getLogger().info("Initializing DiscordPlugin...");
|
Bukkit.getLogger().info("Initializing DiscordPlugin...");
|
||||||
PlayerListWatcher.hookUp();
|
try {
|
||||||
Bukkit.getLogger().info("Finished hooking into the player list");
|
PlayerListWatcher.hookUp();
|
||||||
|
hooked = true;
|
||||||
|
Bukkit.getLogger().info("Finished hooking into the player list");
|
||||||
|
} catch (Throwable e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
Bukkit.getLogger().warning("Couldn't hook into the player list!");
|
||||||
|
}
|
||||||
plugin = this;
|
plugin = this;
|
||||||
lastannouncementtime = getConfig().getLong("lastannouncementtime");
|
lastannouncementtime = getConfig().getLong("lastannouncementtime");
|
||||||
lastseentime = getConfig().getLong("lastseentime");
|
lastseentime = getConfig().getLong("lastseentime");
|
||||||
|
|
|
@ -68,7 +68,8 @@ public class MCListener implements Listener {
|
||||||
+ " do /discord accept");
|
+ " do /discord accept");
|
||||||
p.sendMessage("§bIf it wasn't you, do /discord decline");
|
p.sendMessage("§bIf it wasn't you, do /discord decline");
|
||||||
}
|
}
|
||||||
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " joined the game");
|
if (!DiscordPlugin.hooked)
|
||||||
|
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " joined the game");
|
||||||
MCChatListener.ListC = 0;
|
MCChatListener.ListC = 0;
|
||||||
DiscordPlugin.updatePlayerList();
|
DiscordPlugin.updatePlayerList();
|
||||||
}
|
}
|
||||||
|
@ -83,7 +84,8 @@ public class MCListener implements Listener {
|
||||||
() -> MCChatListener.ConnectedSenders.values().stream()
|
() -> MCChatListener.ConnectedSenders.values().stream()
|
||||||
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
|
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
|
||||||
.ifPresent(dcp -> callEventExcludingSome(new PlayerJoinEvent(dcp, ""))));
|
.ifPresent(dcp -> callEventExcludingSome(new PlayerJoinEvent(dcp, ""))));
|
||||||
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " left the game");
|
if (!DiscordPlugin.hooked)
|
||||||
|
MCChatListener.sendSystemMessageToChat(e.GetPlayer().PlayerName().get() + " left the game");
|
||||||
Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, DiscordPlugin::updatePlayerList, 5);
|
Bukkit.getScheduler().runTaskLaterAsynchronously(DiscordPlugin.plugin, DiscordPlugin::updatePlayerList, 5);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -105,7 +107,8 @@ public class MCListener implements Listener {
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onPlayerDeath(PlayerDeathEvent e) {
|
public void onPlayerDeath(PlayerDeathEvent e) {
|
||||||
MCChatListener.sendSystemMessageToChat(e.getDeathMessage());
|
if (!DiscordPlugin.hooked)
|
||||||
|
MCChatListener.sendSystemMessageToChat(e.getDeathMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
|
|
Loading…
Reference in a new issue