Catching all vanilla broadcasts in Minecraft #44

Merged
NorbiPeti merged 6 commits from dev into master 2017-12-02 19:25:51 +00:00
3 changed files with 26 additions and 5 deletions
Showing only changes of commit 20ff9cc3e6 - Show all commits

View 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
}

View file

@ -44,14 +44,21 @@ public class DiscordPlugin extends JavaPlugin implements IListener<ReadyEvent> {
public static DiscordPlugin plugin;
public static boolean SafeMode = true;
public static List<String> GameRoles;
public static boolean hooked = false;
@SuppressWarnings("unchecked")
@Override
public void onEnable() {
try {
Bukkit.getLogger().info("Initializing DiscordPlugin...");
PlayerListWatcher.hookUp();
Bukkit.getLogger().info("Finished hooking into the player list");
try {
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;
lastannouncementtime = getConfig().getLong("lastannouncementtime");
lastseentime = getConfig().getLong("lastseentime");

View file

@ -68,7 +68,8 @@ public class MCListener implements Listener {
+ " do /discord accept");
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;
DiscordPlugin.updatePlayerList();
}
@ -83,7 +84,8 @@ public class MCListener implements Listener {
() -> MCChatListener.ConnectedSenders.values().stream()
.filter(s -> s.getUniqueId().equals(e.getPlayer().getUniqueId())).findAny()
.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);
}
@ -105,7 +107,8 @@ public class MCListener implements Listener {
@EventHandler(priority = EventPriority.LOW)
public void onPlayerDeath(PlayerDeathEvent e) {
MCChatListener.sendSystemMessageToChat(e.getDeathMessage());
if (!DiscordPlugin.hooked)
MCChatListener.sendSystemMessageToChat(e.getDeathMessage());
}
@EventHandler