Permalink
Browse files

Maybe fix for bperms? Fix user prefix's

  • Loading branch information...
Fletchto99
Fletchto99 committed May 12, 2012
1 parent 32244ff commit 294a225d54a32862977f733360101b5145f2c166
View
Binary file not shown.
@@ -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!");
@@ -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,
@@ -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 {
@@ -33,6 +34,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.
*
@@ -59,6 +87,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.
*
@@ -108,6 +162,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.
*
@@ -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

This comment has been minimized.

Show comment
Hide comment
@codename-B

codename-B Jun 3, 2012

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

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.