diff --git a/src/main/java/com/cnaude/purpleirc/PurpleBot.java b/src/main/java/com/cnaude/purpleirc/PurpleBot.java index cc21dcb..8504e55 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleBot.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleBot.java @@ -55,6 +55,8 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReadWriteLock; import java.util.concurrent.locks.ReentrantReadWriteLock; +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocketFactory; import me.botsko.prism.actionlibs.QueryParameters; import me.botsko.prism.events.BlockStateChange; import org.bukkit.Achievement; @@ -69,6 +71,7 @@ import org.pircbotx.Configuration; import org.pircbotx.PircBotX; import org.pircbotx.User; import org.pircbotx.UtilSSLSocketFactory; +import org.pircbotx.cap.TLSCapHandler; import org.pircbotx.exception.IrcException; import org.pircbotx.hooks.ListenerAdapter; @@ -87,6 +90,7 @@ public final class PurpleBot { private boolean connected; public boolean autoConnect; public boolean ssl; + public boolean tls; public boolean trustAllCerts; public boolean sendRawMessageOnConnect; public boolean showMOTD; @@ -270,6 +274,9 @@ public final class PurpleBot { socketFactory.trustAllCertificates(); } configBuilder.setSocketFactory(socketFactory); + if (tls) { + configBuilder.addCapHandler(new TLSCapHandler(socketFactory, true)); + } } if (charSet.isEmpty()) { if (!reload) { @@ -630,6 +637,7 @@ public final class PurpleBot { config.load(file); autoConnect = config.getBoolean("autoconnect", true); ssl = config.getBoolean("ssl", false); + tls = config.getBoolean("tls", false); trustAllCerts = config.getBoolean("trust-all-certs", false); sendRawMessageOnConnect = config.getBoolean("raw-message-on-connect", false); rawMessage = config.getString("raw-message", ""); @@ -668,6 +676,7 @@ public final class PurpleBot { plugin.logDebug("Channel Auto Join Delay => " + channelAutoJoinDelay); plugin.logDebug(("Bind => ") + bindAddress); plugin.logDebug("SSL => " + ssl); + plugin.logDebug("TLS => " + tls); plugin.logDebug("Trust All Certs => " + trustAllCerts); plugin.logDebug("Port => " + botServerPort); plugin.logDebug("Command Prefix => " + commandPrefix); @@ -693,7 +702,7 @@ public final class PurpleBot { for (String s : config.getStringList("custom-prefixes")) { String pair[] = s.split(" ", 2); if (pair.length > 0) { - userPrefixes.put(pair[0], ChatColor.translateAlternateColorCodes('&', pair[1])); + userPrefixes.put(pair[0], ChatColor.translateAlternateColorCodes('&', pair[1])); } } for (String key : userPrefixes.keySet()) { @@ -941,7 +950,7 @@ public final class PurpleBot { connectMessage = "Connecting to " + botServer + ":" + botServerPort + ": [Nick: " + botNick + "] [SSL: " + ssl + "]" + " [TrustAllCerts: " - + trustAllCerts + "]"; + + trustAllCerts + "] [TLS: " + tls + "]"; } } } catch (IOException | InvalidConfigurationException ex) { diff --git a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java index 5f93fdd..def5352 100644 --- a/src/main/java/com/cnaude/purpleirc/PurpleIRC.java +++ b/src/main/java/com/cnaude/purpleirc/PurpleIRC.java @@ -87,6 +87,8 @@ 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; @@ -412,7 +414,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); } /** @@ -968,6 +970,7 @@ public class PurpleIRC extends JavaPlugin { try { if (vaultHelpers != null) { if (vaultHelpers.permission != null && vaultHelpers.permission != null) { + logDebug("getPlayerGroup: " + player.getName()); groupName = vaultHelpers.permission.getPrimaryGroup(player); } } @@ -1006,6 +1009,7 @@ public class PurpleIRC extends JavaPlugin { if (vaultHelpers.permission != null && vaultHelpers.permission != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (offlinePlayer != null) { + logDebug("getPlayerGroup: " + worldName + " " + player); groupName = vaultHelpers.permission.getPrimaryGroup(worldName, offlinePlayer); } } @@ -1051,6 +1055,7 @@ public class PurpleIRC extends JavaPlugin { if (vaultHelpers.chat != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (offlinePlayer != null) { + logDebug("getPlayerPrefix: " + worldName + " " + player); prefix = vaultHelpers.chat.getPlayerPrefix(worldName, offlinePlayer); } } @@ -1096,6 +1101,7 @@ public class PurpleIRC extends JavaPlugin { if (vaultHelpers.chat != null) { OfflinePlayer offlinePlayer = getServer().getOfflinePlayer(uuid); if (offlinePlayer != null) { + logDebug("getPlayerSuffix: " + worldName + " " + offlinePlayer.getName()); suffix = vaultHelpers.chat.getPlayerSuffix(worldName, offlinePlayer); } } diff --git a/src/main/java/com/cnaude/purpleirc/Utilities/CaseInsensitiveMap.java b/src/main/java/com/cnaude/purpleirc/Utilities/CaseInsensitiveMap.java index 0e79e00..40d4df3 100644 --- a/src/main/java/com/cnaude/purpleirc/Utilities/CaseInsensitiveMap.java +++ b/src/main/java/com/cnaude/purpleirc/Utilities/CaseInsensitiveMap.java @@ -34,7 +34,7 @@ import java.util.concurrent.ConcurrentHashMap; */ public class CaseInsensitiveMap extends AbstractMap { - private final Map map = new ConcurrentHashMap(); + private final Map map = new ConcurrentHashMap<>(); private static final class KeySet extends AbstractSet { @@ -201,7 +201,7 @@ public class CaseInsensitiveMap extends AbstractMap { */ @Override public Entry next() { - return new MapEntry(this.iterator.next()); + return new MapEntry<>(this.iterator.next()); } /** @@ -265,7 +265,7 @@ public class CaseInsensitiveMap extends AbstractMap { */ @Override public Iterator> iterator() { - return new EntrySetIterator(this.entrySet.iterator()); + return new EntrySetIterator<>(this.entrySet.iterator()); } /** @@ -397,7 +397,7 @@ public class CaseInsensitiveMap extends AbstractMap { */ @Override public Set> entrySet() { - return new EntrySet(this.map.entrySet(), this); + return new EntrySet<>(this.map.entrySet(), this); } /** diff --git a/src/main/resources/SampleBot.yml b/src/main/resources/SampleBot.yml index 422a99c..568b785 100644 --- a/src/main/resources/SampleBot.yml +++ b/src/main/resources/SampleBot.yml @@ -19,6 +19,8 @@ server: irc.excample.com port: 6667 # Attempt ssl connection to IRC server ssl: false +# Enable TLS support +tls: false # Trust all SSL certs trust-all-certs: false # Bind address