Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
76 changes: 50 additions & 26 deletions src/net/TheDgtl/iChat/VariableHandler.java
Original file line number Diff line number Diff line change
Expand Up @@ -115,36 +115,60 @@ public void loadConfig() {
public void addPlayer(Player player) {
HashMap<String, String> tmpList = new HashMap<String, String>();

String group = ichat.API.getGroup(player);
String world = player.getWorld().getName().toLowerCase();

// Check if the world the player is in has variables
HashMap<String, String> wVars = worldVars.get(world);
if (wVars != null && !wVars.isEmpty()) {
tmpList.putAll(wVars);
}

if (group != null && !group.isEmpty()) {
// Add the players cached group to the group list
playerGroups.put(player.getName().toLowerCase(), group);

group = group.toLowerCase();
HashMap<String, String> gVars = groupVars.get(group);
if (gVars != null)
tmpList.putAll(gVars);

// Check if this group has world-specific vars
HashMap<String, HashMap<String, String>> worlds = wGroupVars.get(world);
if (worlds != null) {
HashMap<String, String> wgVars = worlds.get(group);
if (wgVars != null)
tmpList.putAll(wgVars);
if (ichat.pexPlug == null) {
String group = ichat.API.getGroup(player);
String world = player.getWorld().getName().toLowerCase();
if (group != null && !group.isEmpty()) {
// Add the players cached group to the group list
playerGroups.put(player.getName().toLowerCase(), group);

group = group.toLowerCase();
HashMap<String, String> gVars = groupVars.get(group);
if (gVars != null)
tmpList.putAll(gVars);

// Check if this group has world-specific vars
HashMap<String, HashMap<String, String>> worlds = wGroupVars.get(world);
if (worlds != null) {
HashMap<String, String> wgVars = worlds.get(group);
if (wgVars != null)
tmpList.putAll(wgVars);
}
} else {
// Remove players cached group
playerGroups.remove(player.getName().toLowerCase());
}
} else {
// Remove players cached group
playerGroups.remove(player.getName().toLowerCase());
String[] group = ichat.API.getPexGroup(player);
String world = player.getWorld().getName().toLowerCase();

for (String g : group)
{
if (g != null && !g.isEmpty()) {
// Add the players cached group to the group list
playerGroups.put(player.getName().toLowerCase(), g);

g = g.toLowerCase();
HashMap<String, String> gVars = groupVars.get(g);
if (gVars != null)
tmpList.putAll(gVars);

// Check if this group has world-specific vars
HashMap<String, HashMap<String, String>> worlds = wGroupVars.get(world);
if (worlds != null) {
HashMap<String, String> wgVars = worlds.get(g);
if (wgVars != null)
tmpList.putAll(wgVars);
}
} else {
// Remove players cached group
playerGroups.remove(player.getName().toLowerCase());
}
}
}

String world = player.getWorld().getName().toLowerCase();

HashMap<String, String> uVars = userVars.get(player.getName().toLowerCase());
if (uVars != null)
tmpList.putAll(uVars);
Expand Down
20 changes: 13 additions & 7 deletions src/net/TheDgtl/iChat/iChatAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -158,9 +158,6 @@ public String getRawInfo(Player player, String info) {
if (ichat.pbPlug != null) {
return getPermBGroup(player);
}
if (ichat.pexPlug != null) {
return getPexGroup(player);
}
if (ichat.gMan != null) {
return getGManGroup(player);
}
Expand Down Expand Up @@ -271,12 +268,21 @@ private String getPermBGroup(Player player) {
return groups.get(0).getName();
}

private String getPexGroup(Player player) {
String[] getPexGroup(Player player) {
PermissionUser user = PermissionsEx.getUser(player);
if (user == null) return "";
if (user == null) return null;
PermissionGroup[] groups = user.getGroups(player.getWorld().getName());
if (groups.length == 0) return "";
return groups[0].getName();
if (groups.length == 0) return null;

int count = 0;
String[] playerGroup = new String[groups.length];
for (PermissionGroup g : groups)
{
playerGroup[count] = ChatColor.translateAlternateColorCodes('&', g.getName());
count++;
}

return playerGroup;
}

private String getGManGroup(Player player) {
Expand Down