From 69c32578c319184e18ae09e9ab616e1248a563cb Mon Sep 17 00:00:00 2001 From: Pepich Date: Wed, 1 Feb 2017 18:05:07 +0100 Subject: [PATCH] Changed save structure to work with already existing data --- .../modules/chatgroups/Chatgroups.java | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/com/redstoner/modules/chatgroups/Chatgroups.java b/src/com/redstoner/modules/chatgroups/Chatgroups.java index a05ff80..ddeafd9 100644 --- a/src/com/redstoner/modules/chatgroups/Chatgroups.java +++ b/src/com/redstoner/modules/chatgroups/Chatgroups.java @@ -24,7 +24,7 @@ import com.redstoner.modules.Module; * * @author Pepich */ @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 { private static final char defaultKey = ':'; @@ -183,7 +183,7 @@ public class Chatgroups implements Module, Listener @Command(hook = "cgjoin") public boolean cgJoin(CommandSender sender, String name) { - groups.put(sender, name); + setGroup(sender, name); saveGroups(); return true; } @@ -239,6 +239,19 @@ public class Chatgroups implements Module, Listener 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 * * @param target the CommandSender to get their group removed. */