diff --git a/src/main/java/com/cnaude/purpleirc/CommandHandlers.java b/src/main/java/com/cnaude/purpleirc/CommandHandlers.java index 5d5a90a..beeb0c0 100644 --- a/src/main/java/com/cnaude/purpleirc/CommandHandlers.java +++ b/src/main/java/com/cnaude/purpleirc/CommandHandlers.java @@ -142,27 +142,25 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, return true; } } else if (commandLabel.equalsIgnoreCase("r")) { - plugin.logDebug("Command: r"); + if (!sender.hasPermission("irc.smsg")) { + sender.sendMessage(plugin.noPermission); + return true; + } if (plugin.privateMsgReply.containsKey(sender.getName())) { - plugin.logDebug("Command: r2"); if (args.length >= 1) { - plugin.logDebug("Command: r3"); - if (!sender.hasPermission("irc.smsg")) { - sender.sendMessage(plugin.noPermission); - return true; - } - plugin.logDebug("Command: r4"); ArrayList list = new ArrayList<>(); list.add("smsg"); list.add(plugin.privateMsgReply.get(sender.getName())); list.addAll(Arrays.asList(args)); plugin.logDebug("R: " + list); commands.get("smsg").dispatch(sender, list.toArray(new String[list.size()])); - return true; + } else { + sender.sendMessage(ChatColor.WHITE + "Usage: " + ChatColor.GOLD + "/r [message]"); } } else { sender.sendMessage(ChatColor.RED + "No messages received."); } + return true; } commands.get("help").dispatch(sender, args); return true; diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java index 47c8a01..6f6c4bf 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerJoinListener.java @@ -60,6 +60,7 @@ public void run() { if (plugin.netPackets != null) { plugin.netPackets.updateTabList(event.getPlayer()); } + ircBot.sendRemotePlayerInfo(); } plugin.updateDisplayNameCache(event.getPlayer()); plugin.updateUuidCache(event.getPlayer()); diff --git a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java index 3724fed..1854941 100644 --- a/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java +++ b/src/main/java/com/cnaude/purpleirc/GameListeners/GamePlayerQuitListener.java @@ -58,6 +58,7 @@ public void onPlayerQuitEvent(PlayerQuitEvent event) { if (plugin.netPackets != null) { plugin.netPackets.updateTabList(event.getPlayer()); } + ircBot.sendRemotePlayerInfo(); } } } diff --git a/src/main/java/com/cnaude/purpleirc/IRCListeners/NoticeListener.java b/src/main/java/com/cnaude/purpleirc/IRCListeners/NoticeListener.java index 947f936..aadf0d5 100644 --- a/src/main/java/com/cnaude/purpleirc/IRCListeners/NoticeListener.java +++ b/src/main/java/com/cnaude/purpleirc/IRCListeners/NoticeListener.java @@ -21,6 +21,7 @@ import com.cnaude.purpleirc.Utilities.CaseInsensitiveMap; import java.util.ArrayList; import org.apache.commons.codec.binary.Base64; +import org.bukkit.ChatColor; import org.pircbotx.Channel; import org.pircbotx.User; import org.pircbotx.hooks.ListenerAdapter; @@ -70,9 +71,13 @@ public void onNotice(NoticeEvent event) { if (command.equals("LINK_REQUEST")) { ircBot.linkRequests.put(user.getNick(), code); - plugin.logInfo("PurpleIRC bot link request from " + user.getNick()); - plugin.logInfo("To accept: /irc linkaccept " - + ircBot.getFileName().replace(".yml", "") + " " + user.getNick()); + plugin.broadcastToGame(ChatColor.LIGHT_PURPLE + + "PurpleIRC bot link request from " + + ChatColor.WHITE + user.getNick(), "irc.link"); + plugin.broadcastToGame(ChatColor.LIGHT_PURPLE + "To accept: " + + ChatColor.WHITE + "/irc linkaccept " + + ircBot.getFileName().replace(".yml", "") + + " " + user.getNick(), "irc.link"); return; } diff --git a/src/main/java/com/cnaude/purpleirc/LinkUpdater.java b/src/main/java/com/cnaude/purpleirc/LinkUpdater.java new file mode 100644 index 0000000..efc5296 --- /dev/null +++ b/src/main/java/com/cnaude/purpleirc/LinkUpdater.java @@ -0,0 +1,55 @@ +/* + * Copyright (C) 2014 cnaude + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see . + */ +package com.cnaude.purpleirc; + +import org.bukkit.scheduler.BukkitTask; + +/** + * + * @author Chris Naude This thread checks each for users and updates the + * internal lists. + */ +public class LinkUpdater { + + private final PurpleIRC plugin; + private final BukkitTask bt; + + /** + * + * @param plugin + */ + public LinkUpdater(final PurpleIRC plugin) { + this.plugin = plugin; + + bt = this.plugin.getServer().getScheduler().runTaskTimerAsynchronously(this.plugin, new Runnable() { + @Override + public void run() { + for (PurpleBot ircBot : plugin.ircBots.values()) { + ircBot.sendRemotePlayerInfo(); + } + } + }, 0, 400); + } + + /** + * + */ + public void cancel() { + bt.cancel(); + } + +} diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index 7b7d175..04782b2 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -165,6 +165,7 @@ public class PurpleIRC extends JavaPlugin { public Long ircConnCheckInterval; public Long ircChannelCheckInterval; public ChannelWatcher channelWatcher; + public LinkUpdater linkUpdater; public ColorConverter colorConverter; public RegexGlobber regexGlobber; public CaseInsensitiveMap ircBots; @@ -297,6 +298,7 @@ public void onEnable() { loadBots(); createSampleBot(); channelWatcher = new ChannelWatcher(this); + linkUpdater = new LinkUpdater(this); setupVault(); if (customTabList) { if (checkForProtocolLib()) { @@ -324,6 +326,10 @@ public void onDisable() { logDebug("Disabling channelWatcher ..."); channelWatcher.cancel(); } + if (linkUpdater != null) { + logDebug("Disabling linkUpdater ..."); + linkUpdater.cancel(); + } if (botWatcher != null) { logDebug("Disabling botWatcher ..."); botWatcher.cancel(); diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 27b81f9..9cd443a 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -41,7 +41,7 @@ permissions: default: op 'irc.reloadbotconfig': description: Gives player access to the /irc reloadconfig. - default: op + default: op 'irc.reconnect': description: Gives player access to the /irc reconnect. default: op @@ -62,7 +62,7 @@ permissions: default: false 'irc.message.quit': description: Receive IRC quit messages. - default: false + default: false 'irc.message.disconnect': description: Receive IRC disconnect messages. default: op @@ -74,46 +74,58 @@ permissions: default: false 'irc.message.kick': description: Receive IRC kick messages. - default: false + default: false 'irc.message.part': description: Receive IRC part messages. - default: false + default: false 'irc.listbots': description: Gives player access to the /irc listbots command. default: op 'irc.list': description: Gives player access to the /irc list command. - default: op + default: op 'irc.tablist': description: Allow player to see IRC nick list in the tab list default: op 'irc.msg': description: Gives player access to the /irc msg command. - default: op + default: op 'irc.sendraw': description: Gives player access to the /irc sendraw command. - default: op + default: op 'irc.ctcp': description: Gives player access to the /irc ctcp command. - default: op + default: op 'irc.notice': description: Gives player access to the /irc notice command. - default: op + default: op 'irc.message.mode': description: Player receives IRC mode change messages. - default: op + default: op 'irc.message.notice': description: Player receives IRC notice messages. - default: op + default: op 'irc.motd': description: Gives player access to the /irc motd command. - default: op + default: op 'irc.load': description: Gives player access to the /irc load command. - default: op + default: op 'irc.unload': description: Gives player access to the /irc unload command. - default: op + default: op 'irc.hooks': description: Gives player access to the /irc hooks command. - default: op \ No newline at end of file + default: op + 'irc.link': + description: Gives player access to the /irc link command. + default: op + 'irc.linkaccept': + description: Gives player access to the /irc linkaccept command. + default: op + 'irc.slist': + description: Gives player access to the /irc slist command. + default: true + 'irc.smsg': + description: Gives player access to the /irc smsg command. + default: true \ No newline at end of file