Add NoteService to handle note operations
NoteService should be the only class with access to NoteDao; nowhere else should NoteDao be accessed directly. Channel dependencies are static in PacketProcessor, for now. Ideally they would be injected in the constructor, but since the constructor is private and I don't want to open up that can of worms, I'll leave it like this. At the very least, now we have a way of injecting services into the handlers. This will make further restructuring way easier.
This commit is contained in:
@@ -46,6 +46,7 @@ import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import scripting.event.EventInstanceManager;
|
||||
import server.life.MobSkill;
|
||||
import service.NoteService;
|
||||
import tools.DatabaseConnection;
|
||||
import tools.PacketCreator;
|
||||
import tools.Pair;
|
||||
@@ -63,6 +64,12 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
private static final Logger log = LoggerFactory.getLogger(PlayerLoggedinHandler.class);
|
||||
private static final Set<Integer> attemptingLoginAccounts = new HashSet<>();
|
||||
|
||||
private final NoteService noteService;
|
||||
|
||||
public PlayerLoggedinHandler(NoteService noteService) {
|
||||
this.noteService = noteService;
|
||||
}
|
||||
|
||||
private boolean tryAcquireAccount(int accId) {
|
||||
synchronized (attemptingLoginAccounts) {
|
||||
if (attemptingLoginAccounts.contains(accId)) {
|
||||
@@ -302,7 +309,8 @@ public final class PlayerLoggedinHandler extends AbstractPacketHandler {
|
||||
}
|
||||
}
|
||||
|
||||
player.showNote();
|
||||
noteService.show(player);
|
||||
|
||||
if (player.getParty() != null) {
|
||||
PartyCharacter pchar = player.getMPC();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user