Skip to content
Browse files

Maybe fix for bperms? Fix user prefix's

  • Loading branch information...
1 parent 32244ff commit 294a225d54a32862977f733360101b5145f2c166 Fletchto99 committed
View
BIN dependencies/Vault.jar
Binary file not shown.
View
2 src/main/java/org/monstercraft/irc/plugin/managers/handlers/IRCHandler.java
@@ -170,7 +170,7 @@ public boolean connect(final IRCServer server) {
watch.start();
print = new Thread(DISPATCH);
print.setDaemon(true);
- print.setPriority(Thread.NORM_PRIORITY);
+ print.setPriority(Thread.MAX_PRIORITY);
print.start();
} catch (Exception e) {
IRC.log("Failed to connect to IRC! Try again in about 1 minute!");
View
46 src/main/java/org/monstercraft/irc/plugin/managers/listeners/MonsterIRCListener.java
@@ -188,7 +188,7 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace(
"{prefix}",
StringUtils
- .getPrefix(player.getDisplayName())
+ .getPrefix(player)
.replace("§", "§")
.replace("&", "§"))
.replace(
@@ -197,17 +197,14 @@ private void handleMessage(final Player player, final IRCChannel c,
.getDisplayName()))
.replace(
"{suffix}",
- StringUtils.getSuffix(player
- .getDisplayName()))
+ StringUtils.getSuffix(player))
.replace(
"{groupPrefix}",
- StringUtils.getGroupPrefix(player
- .getDisplayName()))
+ StringUtils.getGroupPrefix(player))
.replace(
"{groupSuffix}",
- StringUtils.getGroupSuffix(player
- .getDisplayName()))
+ StringUtils.getGroupSuffix(player))
.replace(
"{message}",
" "
@@ -216,7 +213,7 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace(
"{world}",
StringUtils.getWorld(player
- .getDisplayName()))
+ .getName()))
.replace("&", "§"));
IRC.sendMessage(c, ColorUtils.formatGameMessage(result
.toString().replace(
@@ -257,7 +254,7 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace(
"{prefix}",
StringUtils
- .getPrefix(player.getDisplayName())
+ .getPrefix(player)
.replace("§", "§")
.replace("&", "§"))
.replace(
@@ -266,17 +263,14 @@ private void handleMessage(final Player player, final IRCChannel c,
.getDisplayName()))
.replace(
"{suffix}",
- StringUtils.getSuffix(player
- .getDisplayName()))
+ StringUtils.getSuffix(player))
.replace(
"{groupPrefix}",
- StringUtils.getGroupPrefix(player
- .getDisplayName()))
+ StringUtils.getGroupPrefix(player))
.replace(
"{groupSuffix}",
- StringUtils.getGroupSuffix(player
- .getDisplayName()))
+ StringUtils.getGroupSuffix(player))
.replace(
"{HCchannelColor}",
"§"
@@ -292,7 +286,7 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace(
"{world}",
StringUtils.getWorld(player
- .getDisplayName()))
+ .getName()))
.replace("&", "§"));
IRC.sendMessage(c.getChannel(), ColorUtils
.formatGameMessage(result.toString().replace(
@@ -315,21 +309,21 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace("{heroChatTag}", "")
.replace(
"{prefix}",
- StringUtils.getPrefix(player.getDisplayName())
+ StringUtils.getPrefix(player)
.replace("§", "§").replace("&", "§"))
.replace("{name}",
StringUtils.getDisplayName(player.getDisplayName()))
.replace("{suffix}",
- StringUtils.getSuffix(player.getDisplayName()))
+ StringUtils.getSuffix(player))
.replace("{groupPrefix}",
- StringUtils.getGroupPrefix(player.getDisplayName()))
+ StringUtils.getGroupPrefix(player))
.replace("{groupSuffix}",
- StringUtils.getGroupSuffix(player.getDisplayName()))
+ StringUtils.getGroupSuffix(player))
.replace("{message}",
" " + message.replace("§", "§").replace("&", "§"))
.replace("{world}",
- StringUtils.getWorld(player.getDisplayName()))
+ StringUtils.getWorld(player.getName()))
.replace("&", "§"));
IRC.sendMessage(
c,
@@ -348,21 +342,21 @@ private void handleMessage(final Player player, final IRCChannel c,
.replace("{heroChatTag}", "")
.replace(
"{prefix}",
- StringUtils.getPrefix(player.getDisplayName())
+ StringUtils.getPrefix(player)
.replace("§", "§").replace("&", "§"))
.replace("{name}",
StringUtils.getDisplayName(player.getDisplayName()))
.replace("{suffix}",
- StringUtils.getSuffix(player.getDisplayName()))
+ StringUtils.getSuffix(player))
.replace("{groupPrefix}",
- StringUtils.getGroupPrefix(player.getDisplayName()))
+ StringUtils.getGroupPrefix(player))
.replace("{groupSuffix}",
- StringUtils.getGroupSuffix(player.getDisplayName()))
+ StringUtils.getGroupSuffix(player))
.replace("{message}",
" " + message.replace("§", "§").replace("&", "§"))
.replace("{world}",
- StringUtils.getWorld(player.getDisplayName()))
+ StringUtils.getWorld(player.getName()))
.replace("&", "§"));
IRC.sendMessage(
c,
View
130 src/main/java/org/monstercraft/irc/plugin/util/StringUtils.java
@@ -1,6 +1,7 @@
package org.monstercraft.irc.plugin.util;
import org.bukkit.Bukkit;
+import org.bukkit.entity.Player;
import org.monstercraft.irc.MonsterIRC;
public class StringUtils {
@@ -34,6 +35,33 @@ public static String getPrefix(String name) {
}
/**
+ * Fetches the users prefix.
+ *
+ * @param name
+ * The user's name to look up.
+ * @return The users prefix.
+ */
+ public static String getPrefix(Player player) {
+ try {
+ String s = "";
+ if (MonsterIRC.getHookManager() != null) {
+ if (MonsterIRC.getHookManager().getChatHook() != null) {
+ if (MonsterIRC.getHookManager().getChatHook().isEnabled()) {
+ if (MonsterIRC.getHookManager().getChatHook()
+ .getPlayerPrefix(player) != null) {
+ s = MonsterIRC.getHookManager().getChatHook()
+ .getPlayerPrefix(player).replace("&", "§");
+ }
+ }
+ }
+ }
+ return s;
+ } catch (Exception e) {
+ return "";
+ }
+ }
+
+ /**
* Fetches the users suffix.
*
* @param name
@@ -60,6 +88,32 @@ public static String getSuffix(String name) {
}
/**
+ * Fetches the users suffix.
+ *
+ * @param name
+ * The user's name to look up.
+ * @return The users suffix.
+ */
+ public static String getSuffix(Player p) {
+ try {
+ String s = "";
+ if (MonsterIRC.getHookManager() != null) {
+ if (MonsterIRC.getHookManager().getChatHook() != null) {
+ if (MonsterIRC.getHookManager().getChatHook()
+ .getPlayerSuffix(p) != null) {
+ s = MonsterIRC.getHookManager().getChatHook()
+ .getPlayerSuffix(p).replace("&", "§");
+
+ }
+ }
+ }
+ return s;
+ } catch (Exception e) {
+ return "";
+ }
+ }
+
+ /**
* Fetches the special name of the user.
*
* @param name
@@ -109,6 +163,44 @@ public static String getGroupSuffix(String name) {
}
/**
+ * Fetches the group suffix for the user.
+ *
+ * @param name
+ * The user's name to look up.
+ * @return The groups suffix.
+ */
+ public static String getGroupSuffix(Player p) {
+ try {
+ String s = "";
+ if (MonsterIRC.getHookManager() != null) {
+ if (MonsterIRC.getHookManager().getChatHook() != null) {
+ if (MonsterIRC
+ .getHookManager()
+ .getChatHook()
+ .getGroupSuffix(
+ "",
+ MonsterIRC.getHookManager().getChatHook()
+ .getPrimaryGroup(p)) != null) {
+ s = MonsterIRC
+ .getHookManager()
+ .getChatHook()
+ .getGroupSuffix(
+ "",
+ MonsterIRC.getHookManager()
+ .getChatHook()
+ .getPrimaryGroup(p))
+ .replace("&", "§");
+
+ }
+ }
+ }
+ return s;
+ } catch (Exception e) {
+ return "";
+ }
+ }
+
+ /**
* Fetches the group prefix for the user.
*
* @param name
@@ -145,6 +237,44 @@ public static String getGroupPrefix(String name) {
return "";
}
}
+
+ /**
+ * Fetches the group prefix for the user.
+ *
+ * @param name
+ * The user's name to look up.
+ * @return The groups prefix.
+ */
+ public static String getGroupPrefix(Player p) {
+ try {
+ String s = "";
+ if (MonsterIRC.getHookManager() != null) {
+ if (MonsterIRC.getHookManager().getChatHook() != null) {
+ if (MonsterIRC
+ .getHookManager()
+ .getChatHook()
+ .getGroupPrefix(
+ "",
+ MonsterIRC.getHookManager().getChatHook()
+ .getPrimaryGroup(p)) != null) {
+ s = MonsterIRC
+ .getHookManager()
+ .getChatHook()
+ .getGroupPrefix(
+ "",
+ MonsterIRC.getHookManager()
+ .getChatHook()
+ .getPrimaryGroup(p))
+ .replace("&", "§");
+
+ }
+ }
+ }
+ return s;
+ } catch (Exception e) {
+ return "";
+ }
+ }
/**
* Fetches the group prefix for the user.

1 comment on commit 294a225

@codename-B

How changing player.getDisplayName() (where two players can have the same display name) counts as a fix for bPermissions I will never know

Please sign in to comment.
Something went wrong with that request. Please try again.