Replace FredrickProcessor dependence on NoteDao

This commit is contained in:
P0nk
2022-12-27 10:52:49 +01:00
parent 389b3ad2a4
commit af14da987e
8 changed files with 47 additions and 58 deletions

View File

@@ -30,6 +30,7 @@ import client.inventory.Item;
import client.inventory.ItemFactory;
import client.inventory.manipulator.CashIdGenerator;
import client.newyear.NewYearCardRecord;
import client.processor.npc.FredrickProcessor;
import config.YamlConfig;
import constants.game.GameConstants;
import constants.inventory.ItemConstants;
@@ -842,7 +843,7 @@ public class Server {
throw new IllegalStateException("Failed to initiate a connection to the database");
}
registerChannelDependencies();
ChannelDependencies channelDependencies = registerChannelDependencies();
final ExecutorService initExecutor = Executors.newFixedThreadPool(10);
// Run slow operations asynchronously to make startup faster
@@ -872,7 +873,7 @@ public class Server {
}
ThreadManager.getInstance().start();
initializeTimelyTasks(); // aggregated method for timely tasks thanks to lxconan
initializeTimelyTasks(channelDependencies); // aggregated method for timely tasks thanks to lxconan
try {
int worldCount = Math.min(GameConstants.WORLD_NAMES.length, YamlConfig.config.server.WORLDS);
@@ -920,14 +921,14 @@ public class Server {
}
}
private void registerChannelDependencies() {
NoteDao noteDao = new NoteDao();
ChannelDependencies channelDependencies = new ChannelDependencies(
new NoteService(noteDao)
);
private ChannelDependencies registerChannelDependencies() {
NoteService noteService = new NoteService(new NoteDao());
FredrickProcessor fredrickProcessor = new FredrickProcessor(noteService);
ChannelDependencies channelDependencies = new ChannelDependencies(noteService, fredrickProcessor);
PacketProcessor.registerGameHandlerDependencies(channelDependencies);
return channelDependencies;
}
private LoginServer initLoginServer(int port) {
@@ -948,7 +949,7 @@ public class Server {
}
}
private void initializeTimelyTasks() {
private void initializeTimelyTasks(ChannelDependencies channelDependencies) {
TimerManager tMan = TimerManager.getInstance();
tMan.start();
tMan.register(tMan.purge(), YamlConfig.config.server.PURGING_INTERVAL);//Purging ftw...
@@ -962,7 +963,7 @@ public class Server {
tMan.register(new LoginCoordinatorTask(), HOURS.toMillis(1), timeLeft);
tMan.register(new EventRecallCoordinatorTask(), HOURS.toMillis(1), timeLeft);
tMan.register(new LoginStorageTask(), MINUTES.toMillis(2), MINUTES.toMillis(2));
tMan.register(new DueyFredrickTask(), HOURS.toMillis(1), timeLeft);
tMan.register(new DueyFredrickTask(channelDependencies.fredrickProcessor()), HOURS.toMillis(1), timeLeft);
tMan.register(new InvitationTask(), SECONDS.toMillis(30), SECONDS.toMillis(30));
tMan.register(new RespawnTask(), YamlConfig.config.server.RESPAWN_INTERVAL, YamlConfig.config.server.RESPAWN_INTERVAL);