From 5a515b7d82b14430a43f5a51ed0e2690aae3d4e7 Mon Sep 17 00:00:00 2001 From: cnaude Date: Sat, 21 Mar 2015 10:42:07 -0700 Subject: [PATCH] Add hooks command. Some refactoring and cleanup. --- pom.xml | 2 - .../com/cnaude/purpleirc/CommandHandlers.java | 1 + .../com/cnaude/purpleirc/Commands/CTCP.java | 2 +- .../com/cnaude/purpleirc/Commands/Hooks.java | 65 ++++ .../com/cnaude/purpleirc/Commands/Motd.java | 2 +- .../com/cnaude/purpleirc/Commands/Notice.java | 2 +- .../com/cnaude/purpleirc/Commands/Send.java | 2 +- .../cnaude/purpleirc/Commands/SendRaw.java | 2 +- .../cnaude/purpleirc/Hooks/TownyChatHook.java | 2 +- .../java/com/cnaude/purpleirc/PurpleIRC.java | 362 +++++++++++------- .../com/cnaude/purpleirc/Utilities/Query.java | 2 +- src/main/resources/plugin.yml | 3 + 12 files changed, 293 insertions(+), 154 deletions(-) create mode 100644 src/main/java/com/cnaude/purpleirc/Commands/Hooks.java diff --git a/pom.xml b/pom.xml index 1479605..9f1ad25 100644 --- a/pom.xml +++ b/pom.xml @@ -355,11 +355,9 @@ - org.apache.maven.plugins maven-compiler-plugin 3.2 - 1.7 1.7 diff --git a/src/main/java/com/cnaude/purpleirc/CommandHandlers.java b/src/main/java/com/cnaude/purpleirc/CommandHandlers.java index 82df625..7eb88cc 100644 --- a/src/main/java/com/cnaude/purpleirc/CommandHandlers.java +++ b/src/main/java/com/cnaude/purpleirc/CommandHandlers.java @@ -52,6 +52,7 @@ public class CommandHandlers implements CommandExecutor { commands.put("devoice", new DeVoice(plugin)); commands.put("debug", new Debug(plugin)); commands.put("disconnect", new Disconnect(plugin)); + commands.put("hooks", new Hooks(plugin)); commands.put("join", new Join(plugin)); commands.put("kick", new Kick(plugin)); commands.put("leave", new Leave(plugin)); diff --git a/src/main/java/com/cnaude/purpleirc/Commands/CTCP.java b/src/main/java/com/cnaude/purpleirc/Commands/CTCP.java index 7081e25..e2365f1 100644 --- a/src/main/java/com/cnaude/purpleirc/Commands/CTCP.java +++ b/src/main/java/com/cnaude/purpleirc/Commands/CTCP.java @@ -52,7 +52,7 @@ public class CTCP implements IRCCommandInterface { plugin.logDebug("Dispatching ctcp command..."); int msgIdx = 2; String target; - java.util.List myBots = new ArrayList(); + java.util.List myBots = new ArrayList<>(); if (plugin.ircBots.containsKey(args[1])) { myBots.add(plugin.ircBots.get(args[1])); msgIdx = 3; diff --git a/src/main/java/com/cnaude/purpleirc/Commands/Hooks.java b/src/main/java/com/cnaude/purpleirc/Commands/Hooks.java new file mode 100644 index 0000000..c206d15 --- /dev/null +++ b/src/main/java/com/cnaude/purpleirc/Commands/Hooks.java @@ -0,0 +1,65 @@ +/* + * 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.Commands; + +import com.cnaude.purpleirc.PurpleIRC; +import org.bukkit.command.CommandSender; + +/** + * + * @author cnaude + */ +public class Hooks implements IRCCommandInterface { + + private final PurpleIRC plugin; + private final String usage = ""; + private final String desc = "List all hooks"; + private final String name = "hooks"; + + /** + * + * @param plugin + */ + public Hooks(PurpleIRC plugin) { + this.plugin = plugin; + } + + /** + * + * @param sender + * @param args + */ + @Override + public void dispatch(CommandSender sender, String[] args) { + plugin.getPurpleHooks(sender, true); + } + + @Override + public String name() { + return name; + } + + @Override + public String desc() { + return desc; + } + + @Override + public String usage() { + return usage; + } +} diff --git a/src/main/java/com/cnaude/purpleirc/Commands/Motd.java b/src/main/java/com/cnaude/purpleirc/Commands/Motd.java index b264b26..c1020c8 100644 --- a/src/main/java/com/cnaude/purpleirc/Commands/Motd.java +++ b/src/main/java/com/cnaude/purpleirc/Commands/Motd.java @@ -47,7 +47,7 @@ public class Motd implements IRCCommandInterface { */ @Override public void dispatch(CommandSender sender, String[] args) { - java.util.List myBots = new ArrayList(); + java.util.List myBots = new ArrayList<>(); if (args.length >= 2) { if (plugin.ircBots.containsKey(args[1])) { myBots.add(plugin.ircBots.get(args[1])); diff --git a/src/main/java/com/cnaude/purpleirc/Commands/Notice.java b/src/main/java/com/cnaude/purpleirc/Commands/Notice.java index 39d64af..4ad12ee 100644 --- a/src/main/java/com/cnaude/purpleirc/Commands/Notice.java +++ b/src/main/java/com/cnaude/purpleirc/Commands/Notice.java @@ -53,7 +53,7 @@ public class Notice implements IRCCommandInterface { plugin.logDebug("Dispatching notice command..."); int msgIdx = 2; String target; - java.util.List myBots = new ArrayList(); + java.util.List myBots = new ArrayList<>(); if (plugin.ircBots.containsKey(args[1])) { myBots.add(plugin.ircBots.get(args[1])); msgIdx = 3; diff --git a/src/main/java/com/cnaude/purpleirc/Commands/Send.java b/src/main/java/com/cnaude/purpleirc/Commands/Send.java index e03d29b..e01374f 100644 --- a/src/main/java/com/cnaude/purpleirc/Commands/Send.java +++ b/src/main/java/com/cnaude/purpleirc/Commands/Send.java @@ -54,7 +54,7 @@ public class Send implements IRCCommandInterface { if (args.length >= 2) { int msgIdx = 1; String channelName = null; - List myBots = new ArrayList(); + List myBots = new ArrayList<>(); if (plugin.ircBots.containsKey(args[1])) { myBots.add(plugin.ircBots.get(args[1])); msgIdx = 2; diff --git a/src/main/java/com/cnaude/purpleirc/Commands/SendRaw.java b/src/main/java/com/cnaude/purpleirc/Commands/SendRaw.java index 08da63a..37a06d9 100644 --- a/src/main/java/com/cnaude/purpleirc/Commands/SendRaw.java +++ b/src/main/java/com/cnaude/purpleirc/Commands/SendRaw.java @@ -52,7 +52,7 @@ public class SendRaw implements IRCCommandInterface { public void dispatch(CommandSender sender, String[] args) { if (args.length >= 2) { int msgIdx = 1; - List myBots = new ArrayList(); + List myBots = new ArrayList<>(); if (plugin.ircBots.containsKey(args[1])) { myBots.add(plugin.ircBots.get(args[1])); msgIdx = 2; diff --git a/src/main/java/com/cnaude/purpleirc/Hooks/TownyChatHook.java b/src/main/java/com/cnaude/purpleirc/Hooks/TownyChatHook.java index 627d203..2ec4128 100644 --- a/src/main/java/com/cnaude/purpleirc/Hooks/TownyChatHook.java +++ b/src/main/java/com/cnaude/purpleirc/Hooks/TownyChatHook.java @@ -42,7 +42,7 @@ public class TownyChatHook { public TownyChatHook(PurpleIRC plugin) { this.plugin = plugin; chat = (Chat) plugin.getServer().getPluginManager().getPlugin("TownyChat"); - townyChannelTypes = new ArrayList(); + townyChannelTypes = new ArrayList<>(); townyChannelTypes.add(channelTypes.TOWN); townyChannelTypes.add(channelTypes.GLOBAL); townyChannelTypes.add(channelTypes.NATION); diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index def5352..fb68754 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -76,6 +76,7 @@ import java.text.Collator; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; +import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.UUID; @@ -87,8 +88,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.entity.Player; -import org.bukkit.permissions.PermissionAttachment; -import org.bukkit.permissions.PermissionAttachmentInfo; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.pircbotx.IdentServer; @@ -192,6 +191,27 @@ public class PurpleIRC extends JavaPlugin { private final File uuidCacheFile; public int reconnectSuppression; + final String PL_ESSENTIALS = "Essentials"; + final String PL_REPORTRTS = "ReportRTS"; + final String PL_SUPERVANISH = "SuperVanish"; + final String PL_VANISHNOPACKET = "VanishNoPacket"; + final String PL_OREBROADCAST = "OreBroadcast"; + final String PL_DYNMAP = "dynmap"; + final String PL_SHORTIFY = "Shortify"; + final String PL_DEATHMESSAGES = "DeathMessages"; + final String PL_JOBS = "Jobs"; + final String PL_COMMANDBOOK = "CommandBook"; + final String PL_ADMINPRIVATECHAT = "AdminPrivateChat"; + final String PL_FACTIONCHAT = "FactionChat"; + final String PL_MCMMO = "mcMMO"; + final String PL_CLEVERNOTCH = "CleverNotch"; + final String PL_TOWNYCHAT = "TownyChat"; + final String PL_REDDITSTREAM = "RedditStream"; + final String PL_PRISM = "Prism"; + final String PL_TITANCHAT = "TitanChat"; + final String PL_HEROCHAT = "Herochat"; + List hookList = new ArrayList<>(); + public PurpleIRC() { this.MAINCONFIG = "MAIN-CONFIG"; this.sampleFileName = "SampleBot.yml"; @@ -250,146 +270,8 @@ public class PurpleIRC extends JavaPlugin { getServer().getPluginManager().registerEvents(new GamePlayerKickListener(this), this); getServer().getPluginManager().registerEvents(new GamePlayerQuitListener(this), this); getServer().getPluginManager().registerEvents(new GameServerCommandListener(this), this); - if (isPluginEnabled("Herochat")) { - logInfo("Enabling HeroChat support."); - getServer().getPluginManager().registerEvents(new HeroChatListener(this), this); - heroConfig = new YamlConfiguration(); - heroConfigFile = new File(getServer().getPluginManager() - .getPlugin("Herochat").getDataFolder(), "config.yml"); - try { - heroConfig.load(heroConfigFile); - } catch (IOException | InvalidConfigurationException ex) { - logError(ex.getMessage()); - } - heroChatEmoteFormat = heroConfig.getString("format.emote", ""); - } else { - logInfo("HeroChat not detected."); - } - if (isPluginEnabled("TitanChat")) { - logInfo("Enabling TitanChat support."); - getServer().getPluginManager().registerEvents(new TitanChatListener(this), this); - } else { - logInfo("TitanChat not detected."); - } - if (isPluginEnabled("Prism")) { - logInfo("Enabling Prism support."); - getServer().getPluginManager().registerEvents(new PrismListener(this), this); - } else { - logInfo("Prism not detected."); - } - if (isPluginEnabled("RedditStream")) { - logInfo("Enabling RedditStream support."); - getServer().getPluginManager().registerEvents(new RedditStreamListener(this), this); - } else { - logInfo("RedditStream not detected."); - } - if (isPluginEnabled("TownyChat")) { - logInfo("Enabling TownyChat support."); - getServer().getPluginManager().registerEvents(new TownyChatListener(this), this); - tcHook = new TownyChatHook(this); - } else { - logInfo("TownyChat not detected."); - } - if (isPluginEnabled("CleverNotch")) { - logInfo("Enabling CleverNotch support."); - getServer().getPluginManager().registerEvents(new CleverNotchListener(this), this); - } else { - logInfo("CleverNotch not detected."); - } - if (isPluginEnabled("mcMMO")) { - logInfo("Enabling mcMMO support."); - getServer().getPluginManager().registerEvents(new McMMOChatListener(this), this); - } else { - logInfo("mcMMO not detected."); - } - if (isFactionsEnabled()) { - if (isPluginEnabled("FactionChat")) { - String factionChatVersion = getServer().getPluginManager().getPlugin("FactionChat").getDescription().getVersion(); - if (factionChatVersion.startsWith("1.7")) { - logError("FactionChat v" + factionChatVersion + " not supported. Please install 1.8 or newer."); - } else { - logInfo("Enabling FactionChat support."); - fcHook = new FactionChatHook(this); - } - } else { - logInfo("FactionChat not detected."); - } - } - if (isPluginEnabled("AdminPrivateChat")) { - logInfo("Enabling AdminPrivateChat support."); - adminPrivateChatHook = new AdminPrivateChatHook(this); - getServer().getPluginManager().registerEvents(new AdminChatListener(this), this); - } else { - logInfo("AdminPrivateChat not detected."); - } - if (isPluginEnabled("CommandBook")) { - logInfo("Enabling CommandBook support."); - commandBookHook = new CommandBookHook(this); - } else { - logInfo("CommandBook not detected."); - } - if (isPluginEnabled("Jobs")) { - logInfo("Enabling new Jobs support."); - jobsHook = new JobsHook(this); - } else { - logInfo("Jobs not detected."); - } - if (isPluginEnabled("DeathMessages")) { - logInfo("Enabling DeathMessages support."); - getServer().getPluginManager().registerEvents(new DeathMessagesListener(this), this); - } else { - logInfo("DeathMessages not detected."); - } - if (isPluginEnabled("Shortify")) { - String shortifyVersion = getServer().getPluginManager().getPlugin("Shortify").getDescription().getVersion(); - if (shortifyVersion.startsWith("1.8")) { - logInfo("Enabling Shortify v" + shortifyVersion + " support."); - shortifyHook = new ShortifyHook(this); - } else { - logError("Shortify v" + shortifyVersion + " not supported. Please use the latest version from http://jenkins.cnaude.org/job/Shortify/"); - } - } else { - logInfo("Shortify not detected."); - } - if (isPluginEnabled("dynmap")) { - logInfo("Enabling Dynmap support."); - getServer().getPluginManager().registerEvents(new DynmapListener(this), this); - dynmapHook = new DynmapHook(this); - } else { - logInfo("Dynmap not detected."); - } - if (isPluginEnabled("OreBroadcast")) { - logInfo("Enabling OreBroadcast support."); - getServer().getPluginManager().registerEvents(new OreBroadcastListener(this), this); - } else { - logInfo("OreBroadcast not detected."); - } - vanishHook = new VanishHook(this); - if (isPluginEnabled("VanishNoPacket")) { - logInfo("Enabling VanishNoPacket support."); - getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this); - } else { - logInfo("VanishNoPacket not detected."); - } - if (isPluginEnabled("SuperVanish")) { - logInfo("Enabling SuperVanish support."); - superVanishHook = new SuperVanishHook(this); - } else { - logInfo("SuperVanish not detected."); - } - if (isPluginEnabled("ReportRTS")) { - logInfo("Enabling ReportRTS support."); - getServer().getPluginManager().registerEvents(new ReportRTSListener(this), this); - reportRTSHook = new ReportRTSHook(this); - } else { - logInfo("ReportRTS not detected."); - } - if (isPluginEnabled("Essentials")) { - logInfo("Enabling Essentials support."); - getServer().getPluginManager().registerEvents(new EssentialsListener(this), this); - } else { - logInfo("Essentials not detected."); - } + detectHooks(); + getPurpleHooks(getServer().getConsoleSender(), false); commandHandlers = new CommandHandlers(this); ircTabCompleter = new PurpleTabCompleter(this); getCommand("irc").setExecutor(commandHandlers); @@ -414,7 +296,7 @@ public class PurpleIRC extends JavaPlugin { botWatcher = new BotWatcher(this); ircMessageHandler = new IRCMessageHandler(this); commandQueue = new CommandQueueWatcher(this); - updateChecker = new UpdateChecker(this); + updateChecker = new UpdateChecker(this); } /** @@ -902,7 +784,7 @@ public class PurpleIRC extends JavaPlugin { Collections.sort(tmp, Collator.getInstance()); pList = Joiner.on(listSeparator).join(tmp); } else { - // sort without nick prefixes + // sort without nick prefixes pList = Joiner.on(listSeparator).join(playerList.values()); } @@ -1232,7 +1114,7 @@ public class PurpleIRC extends JavaPlugin { logDebug("getGroupPrefix: 10"); if (group == null) { logDebug("getGroupPrefix: 11"); - group = ""; + group = ""; } logDebug("getGroupPrefix: 12"); prefix = vaultHelpers.chat.getGroupPrefix(worldName, group); @@ -1469,4 +1351,194 @@ public class PurpleIRC extends JavaPlugin { return updateCheckerMode; } + private String hookFormat(String name, boolean enabled) { + String message; + + if (enabled) { + String version = getServer().getPluginManager().getPlugin(name).getDescription().getVersion(); + logInfo("Enabling " + name + " support."); + message = ChatColor.WHITE + "[" + ChatColor.GREEN + "Y" + ChatColor.WHITE + "]"; + message = message + " [" + ChatColor.GOLD + name + ChatColor.WHITE + "] [" + + ChatColor.GOLD + "v" + version + ChatColor.WHITE + "]"; + } else { + logInfo("Enabling " + name + " support."); + message = ChatColor.WHITE + "[" + ChatColor.RED + "N" + ChatColor.WHITE + "]"; + message = message + " [" + ChatColor.GRAY + name + ChatColor.WHITE + "]"; + } + + return message; + } + + private void detectHooks() { + logInfo("Detecting plugin hooks..."); + if (isPluginEnabled(PL_HEROCHAT)) { + hookList.add(hookFormat(PL_HEROCHAT, true)); + getServer().getPluginManager().registerEvents(new HeroChatListener(this), this); + heroConfig = new YamlConfiguration(); + heroConfigFile = new File(getServer().getPluginManager() + .getPlugin(PL_HEROCHAT).getDataFolder(), "config.yml"); + try { + heroConfig.load(heroConfigFile); + } catch (IOException | InvalidConfigurationException ex) { + logError(ex.getMessage()); + } + heroChatEmoteFormat = heroConfig.getString("format.emote", ""); + } else { + hookList.add(hookFormat(PL_HEROCHAT, false)); + } + if (isPluginEnabled(PL_TITANCHAT)) { + hookList.add(hookFormat(PL_TITANCHAT, true)); + getServer().getPluginManager().registerEvents(new TitanChatListener(this), this); + } else { + hookList.add(hookFormat(PL_TITANCHAT, false)); + } + if (isPluginEnabled(PL_PRISM)) { + hookList.add(hookFormat(PL_PRISM, true)); + getServer().getPluginManager().registerEvents(new PrismListener(this), this); + } else { + hookList.add(hookFormat(PL_PRISM, false)); + } + if (isPluginEnabled(PL_REDDITSTREAM)) { + hookList.add(hookFormat(PL_REDDITSTREAM, true)); + getServer().getPluginManager().registerEvents(new RedditStreamListener(this), this); + } else { + hookList.add(hookFormat(PL_REDDITSTREAM, false)); + } + if (isPluginEnabled(PL_TOWNYCHAT)) { + hookList.add(hookFormat(PL_TOWNYCHAT, true)); + getServer().getPluginManager().registerEvents(new TownyChatListener(this), this); + tcHook = new TownyChatHook(this); + } else { + hookList.add(hookFormat(PL_TOWNYCHAT, false)); + } + if (isPluginEnabled(PL_CLEVERNOTCH)) { + hookList.add(hookFormat(PL_CLEVERNOTCH, true)); + getServer().getPluginManager().registerEvents(new CleverNotchListener(this), this); + } else { + hookList.add(hookFormat(PL_CLEVERNOTCH, false)); + } + if (isPluginEnabled(PL_MCMMO)) { + hookList.add(hookFormat(PL_MCMMO, true)); + getServer().getPluginManager().registerEvents(new McMMOChatListener(this), this); + } else { + hookList.add(hookFormat(PL_MCMMO, false)); + } + if (isFactionsEnabled()) { + if (isPluginEnabled(PL_FACTIONCHAT)) { + String factionChatVersion = getServer().getPluginManager().getPlugin(PL_FACTIONCHAT).getDescription().getVersion(); + if (factionChatVersion.startsWith("1.7")) { + logError(PL_FACTIONCHAT + " v" + factionChatVersion + " not supported. Please install 1.8 or newer."); + hookList.add(hookFormat(PL_FACTIONCHAT, false)); + } else { + hookList.add(hookFormat(PL_FACTIONCHAT, true)); + fcHook = new FactionChatHook(this); + } + } else { + hookList.add(hookFormat(PL_FACTIONCHAT, false)); + } + } else { + hookList.add(hookFormat(PL_FACTIONCHAT, false)); + } + if (isPluginEnabled(PL_ADMINPRIVATECHAT)) { + hookList.add(hookFormat(PL_ADMINPRIVATECHAT, true)); + adminPrivateChatHook = new AdminPrivateChatHook(this); + getServer().getPluginManager().registerEvents(new AdminChatListener(this), this); + } else { + hookList.add(hookFormat(PL_ADMINPRIVATECHAT, false)); + } + if (isPluginEnabled(PL_COMMANDBOOK)) { + hookList.add(hookFormat(PL_COMMANDBOOK, true)); + commandBookHook = new CommandBookHook(this); + } else { + hookList.add(hookFormat(PL_COMMANDBOOK, false)); + } + if (isPluginEnabled(PL_JOBS)) { + hookList.add(hookFormat(PL_JOBS, true)); + jobsHook = new JobsHook(this); + } else { + hookList.add(hookFormat(PL_JOBS, false)); + } + if (isPluginEnabled(PL_DEATHMESSAGES)) { + hookList.add(hookFormat(PL_DEATHMESSAGES, true)); + getServer().getPluginManager().registerEvents(new DeathMessagesListener(this), this); + } else { + hookList.add(hookFormat(PL_DEATHMESSAGES, false)); + } + if (isPluginEnabled(PL_SHORTIFY)) { + String shortifyVersion = getServer().getPluginManager().getPlugin(PL_SHORTIFY).getDescription().getVersion(); + if (shortifyVersion.startsWith("1.8")) { + hookList.add(hookFormat(PL_SHORTIFY, true)); + shortifyHook = new ShortifyHook(this); + } else { + hookList.add(hookFormat(PL_SHORTIFY, false)); + logError(PL_SHORTIFY + " v" + shortifyVersion + " not supported. Please use the latest version from http://jenkins.cnaude.org/job/Shortify/"); + } + } else { + hookList.add(hookFormat(PL_SHORTIFY, false)); + } + if (isPluginEnabled(PL_DYNMAP)) { + hookList.add(hookFormat(PL_DYNMAP, true)); + getServer().getPluginManager().registerEvents(new DynmapListener(this), this); + dynmapHook = new DynmapHook(this); + } else { + hookList.add(hookFormat(PL_DYNMAP, false)); + } + if (isPluginEnabled(PL_OREBROADCAST)) { + hookList.add(hookFormat(PL_OREBROADCAST, true)); + getServer().getPluginManager().registerEvents(new OreBroadcastListener(this), this); + } else { + hookList.add(hookFormat(PL_OREBROADCAST, false)); + } + vanishHook = new VanishHook(this); + if (isPluginEnabled(PL_VANISHNOPACKET)) { + hookList.add(hookFormat(PL_VANISHNOPACKET, true)); + getServer().getPluginManager().registerEvents(new VanishNoPacketListener(this), this); + } else { + hookList.add(hookFormat(PL_VANISHNOPACKET, false)); + } + if (isPluginEnabled(PL_SUPERVANISH)) { + hookList.add(hookFormat(PL_SUPERVANISH, true)); + superVanishHook = new SuperVanishHook(this); + } else { + hookList.add(hookFormat(PL_SUPERVANISH, false)); + } + if (isPluginEnabled(PL_REPORTRTS)) { + hookList.add(hookFormat(PL_REPORTRTS, true)); + getServer().getPluginManager().registerEvents(new ReportRTSListener(this), this); + reportRTSHook = new ReportRTSHook(this); + } else { + hookList.add(hookFormat(PL_REPORTRTS, false)); + } + if (isPluginEnabled(PL_ESSENTIALS)) { + hookList.add(hookFormat(PL_ESSENTIALS, true)); + getServer().getPluginManager().registerEvents(new EssentialsListener(this), this); + } else { + hookList.add(hookFormat(PL_ESSENTIALS, false)); + } + } + + public void getPurpleHooks(CommandSender sender, boolean colors) { + String header = ChatColor.DARK_PURPLE + "-----[" + ChatColor.WHITE + + " PurpleIRC " + ChatColor.DARK_PURPLE + + "-" + ChatColor.WHITE + " Plugin Hooks " + ChatColor.DARK_PURPLE + "]-----"; + String footer = ChatColor.DARK_PURPLE + "-------------------------------------"; + if (colors) { + sender.sendMessage(header); + } else { + sender.sendMessage(ChatColor.stripColor(header)); + } + for (String s : hookList) { + if (colors) { + sender.sendMessage(s); + } else { + sender.sendMessage(ChatColor.stripColor(s)); + } + } + if (colors) { + sender.sendMessage(footer); + } else { + sender.sendMessage(ChatColor.stripColor(footer)); + } + } + } diff --git a/src/main/java/com/cnaude/purpleirc/Utilities/Query.java b/src/main/java/com/cnaude/purpleirc/Utilities/Query.java index ab5a075..b45e540 100644 --- a/src/main/java/com/cnaude/purpleirc/Utilities/Query.java +++ b/src/main/java/com/cnaude/purpleirc/Utilities/Query.java @@ -156,7 +156,7 @@ public class Query { } } readString(receiveData, cursor); - final Set players = new HashSet(); + final Set players = new HashSet<>(); while (cursor.get() < length) { final String name = readString(receiveData, cursor); if (name.length() > 0) { diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 3553099..f0a4fe5 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -107,4 +107,7 @@ permissions: default: op 'irc.unload': description: Gives player access to the /irc unload command. + default: op + 'irc.hooks': + description: Gives player access to the /irc hooks command. default: op \ No newline at end of file