0

Changed save structure to work with already existing data

This commit is contained in:
Pepich 2017-02-01 18:05:07 +01:00
parent f4017c2e7d
commit 69c32578c3

View File

@ -24,7 +24,7 @@ import com.redstoner.modules.Module;
* *
* @author Pepich */ * @author Pepich */
@AutoRegisterListener @AutoRegisterListener
@Version(major = 1, minor = 1, revision = 3, compatible = 1) @Version(major = 1, minor = 1, revision = 4, compatible = 1)
public class Chatgroups implements Module, Listener public class Chatgroups implements Module, Listener
{ {
private static final char defaultKey = ':'; private static final char defaultKey = ':';
@ -183,7 +183,7 @@ public class Chatgroups implements Module, Listener
@Command(hook = "cgjoin") @Command(hook = "cgjoin")
public boolean cgJoin(CommandSender sender, String name) public boolean cgJoin(CommandSender sender, String name)
{ {
groups.put(sender, name); setGroup(sender, name);
saveGroups(); saveGroups();
return true; return true;
} }
@ -239,6 +239,19 @@ public class Chatgroups implements Module, Listener
return (String) groups.get("CONSOLE"); return (String) groups.get("CONSOLE");
} }
/** Sets the group of the CommandSender.
*
* @param target the CommandSender to set the group of.
* @param group the name of the group to join. */
private void setGroup(CommandSender target, String group)
{
if (target instanceof Player)
groups.put(((Player) target).getUniqueId().toString(), group);
else
groups.put("CONSOLE", group);
saveGroups();
}
/** Removes a CommandSender from their chatgroup. Will also save the groups after finishing /** Removes a CommandSender from their chatgroup. Will also save the groups after finishing
* *
* @param target the CommandSender to get their group removed. */ * @param target the CommandSender to get their group removed. */