Don't create a new chat user if we can't find one, only create a new one if we can't find one when a player joins
This commit is contained in:
parent
e51c893649
commit
321255eaa1
|
|
@ -1,5 +1,6 @@
|
|||
package com.alttd.chat.listeners;
|
||||
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.managers.RegexManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
|
|
@ -25,7 +26,9 @@ public class PlayerListener implements Listener {
|
|||
if(user != null) return;
|
||||
|
||||
// todo actually load the users from db
|
||||
ChatUserManager.addUser(new ChatUser(uuid, -1, false, false));
|
||||
ChatUser chatUser = new ChatUser(uuid, -1, false, false);
|
||||
ChatUserManager.addUser(chatUser);
|
||||
Queries.saveUser(chatUser);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@ package com.alttd.chat.listeners;
|
|||
|
||||
import com.alttd.chat.ChatPlugin;
|
||||
import com.alttd.chat.config.Config;
|
||||
import com.alttd.chat.database.Queries;
|
||||
import com.alttd.chat.managers.ChatUserManager;
|
||||
import com.alttd.chat.objects.ChatUser;
|
||||
import com.alttd.chat.util.ALogger;
|
||||
|
|
@ -51,6 +52,18 @@ public class PluginMessage implements PluginMessageListener {
|
|||
}
|
||||
break;
|
||||
}
|
||||
case "ignore": {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||
UUID targetUUID = UUID.fromString(in.readUTF());
|
||||
|
||||
if(!chatUser.getIgnoredPlayers().contains(targetUUID)) {
|
||||
chatUser.addIgnoredPlayers(targetUUID);
|
||||
}
|
||||
}
|
||||
case "unignore": {
|
||||
ChatUser chatUser = ChatUserManager.getChatUser(UUID.fromString(in.readUTF()));
|
||||
chatUser.removeIgnoredPlayers(UUID.fromString(in.readUTF()));
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user