0

Fixed cg info output

This commit is contained in:
Pepich 2017-02-01 19:51:49 +01:00
parent 3216cde9ec
commit 0c3b931ef0

View File

@ -2,6 +2,7 @@ package com.redstoner.modules.chatgroups;
import java.io.File; import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.UUID; import java.util.UUID;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -25,7 +26,7 @@ import com.redstoner.modules.Module;
* *
* @author Pepich */ * @author Pepich */
@AutoRegisterListener @AutoRegisterListener
@Version(major = 1, minor = 1, revision = 5, compatible = 1) @Version(major = 1, minor = 1, revision = 6, compatible = 1)
public class Chatgroups implements Module, Listener public class Chatgroups implements Module, Listener
{ {
private static final char defaultKey = ':'; private static final char defaultKey = ':';
@ -126,31 +127,33 @@ public class Chatgroups implements Module, Listener
Utils.sendModuleHeader(sender); Utils.sendModuleHeader(sender);
Utils.sendMessage(sender, "", "Your current chatgroup is: §6" + group); Utils.sendMessage(sender, "", "Your current chatgroup is: §6" + group);
ArrayList<String> players = new ArrayList<String>(); ArrayList<String> players = new ArrayList<String>();
for (int i = 0; i < groups.entrySet().size(); i++) Iterator<String> iter = groups.keySet().iterator();
while (iter.hasNext())
{ {
String t_group = (String) groups.entrySet().toArray(new Object[] {})[i]; String id = iter.next();
if (t_group.equals(group)) if (((String) groups.get(id)).equals(group))
{ {
String name = (String) groups.values().toArray(new Object[] {})[i]; if (!id.equals("CONSOLE"))
if (!name.equals("CONSOLE"))
{ {
UUID uuid = UUID.fromString(name); UUID uuid = UUID.fromString(id);
Player p = Bukkit.getPlayer(uuid); Player p = Bukkit.getPlayer(uuid);
if (p != null) if (p != null)
players.add(p.getDisplayName()); players.add(p.getDisplayName());
else else
players.add(Bukkit.getOfflinePlayer(UUID.fromString(name)).getName()); players.add(Bukkit.getOfflinePlayer(UUID.fromString(id)).getName());
} }
players.add(name); else
players.add(id);
} }
StringBuilder sb = new StringBuilder("&6"); }
StringBuilder sb = new StringBuilder("&6Other players in this group: &9");
for (String player : players) for (String player : players)
{ {
sb.append(player); sb.append(player);
sb.append(", "); sb.append("&7, &9");
} }
sb.delete(sb.length() - 2, sb.length()); sb.delete(sb.length() - 2, sb.length());
} Utils.sendMessage(sender, "", sb.toString(), '&');
} }
return true; return true;
} }