2323
2424import java .util .Date ;
2525import java .util .HashMap ;
26+ import java .util .UUID ;
2627
2728public class MAdvanced extends JavaPlugin {
2829 // Default Plugin Data
2930 private PluginManager pm ;
3031 private PluginDescriptionFile pdfFile ;
3132
3233 // Maps
33- public HashMap <String , Boolean > isChatting = new HashMap <String , Boolean >();
34- public HashMap <String , Boolean > isAFK = new HashMap <String , Boolean >();
34+ public HashMap <UUID , Boolean > isChatting = new HashMap <>();
35+ public HashMap <UUID , Boolean > isAFK = new HashMap <>();
3536
36- public HashMap <String , Location > AFKLoc = new HashMap <String , Location >();
37+ public HashMap <UUID , Location > AFKLoc = new HashMap <>();
3738
38- public HashMap <String , Long > lastMove = new HashMap <String , Long >();
39+ public HashMap <UUID , Long > lastMove = new HashMap <>();
3940
4041
4142 public void onEnable () {
@@ -72,9 +73,9 @@ public void run() {
7273 setupCommands ();
7374
7475 for (Player players : getServer ().getOnlinePlayers ()) {
75- isChatting .put (players .getName (), false );
76- isAFK .put (players .getName (), false );
77- lastMove .put (players .getName (), new Date ().getTime ());
76+ isChatting .put (players .getUniqueId (), false );
77+ isAFK .put (players .getUniqueId (), false );
78+ lastMove .put (players .getUniqueId (), new Date ().getTime ());
7879 }
7980
8081 // Stop the Timer
@@ -127,19 +128,19 @@ public void run() {
127128 }
128129
129130 for (Player player : getServer ().getOnlinePlayers ()) {
130- if (isAFK .get (player .getName ()) == null ) {
131- isAFK .put (player .getName (), false );
131+ if (isAFK .get (player .getUniqueId ()) == null ) {
132+ isAFK .put (player .getUniqueId (), false );
132133 }
133134
134- if (isAFK .get (player .getName ()) || lastMove .get (player .getName ()) == null
135+ if (isAFK .get (player .getUniqueId ()) || lastMove .get (player .getUniqueId ()) == null
135136 || API .checkPermissions (player .getName (), player .getWorld ().getName (), "mchat.bypass.afk" )) {
136137 continue ;
137138 }
138139
139- if (new Date ().getTime () - (ConfigType .OPTION_AFK_TIMER .getInteger () * 1000 ) > lastMove .get (player .getName ())) {
140+ if (new Date ().getTime () - (ConfigType .OPTION_AFK_TIMER .getInteger () * 1000 ) > lastMove .get (player .getUniqueId ())) {
140141 getServer ().dispatchCommand (getServer ().getConsoleSender (), "mchatafkother " + player .getName () + " " + LocaleType .MESSAGE_AFK_DEFAULT .getVal ());
141142 } else {
142- isAFK .put (player .getName (), false );
143+ isAFK .put (player .getUniqueId (), false );
143144 }
144145 }
145146 }
@@ -156,11 +157,11 @@ public void run() {
156157 continue ;
157158 }
158159
159- if (!isAFK .get (player .getName ())) {
160+ if (!isAFK .get (player .getUniqueId ())) {
160161 continue ;
161162 }
162163
163- if (new Date ().getTime () - (ConfigType .OPTION_AFK_KICK_TIMER .getInteger () * 1000 ) > lastMove .get (player .getName ())) {
164+ if (new Date ().getTime () - (ConfigType .OPTION_AFK_KICK_TIMER .getInteger () * 1000 ) > lastMove .get (player .getUniqueId ())) {
164165 player .kickPlayer (LocaleType .MESSAGE_AFK_DEFAULT .getVal ());
165166 }
166167 }
0 commit comments