Processor* -> Scenario*
This commit is contained in:
@@ -67,9 +67,9 @@ public class Main {
|
||||
//endregion
|
||||
|
||||
ServerComponent serverComponent = DaggerServerComponent.builder()
|
||||
.processorModule(new ProcessorModule(configComponent.getConfig()))
|
||||
.processorModule(new ScenarioModule(configComponent.getConfig()))
|
||||
.build();
|
||||
serverComponent.getProcessors().forEach(processor -> processor.setup(serverComponent.getProtocolHandlersBus()));
|
||||
serverComponent.getPacketScenarios().forEach(scenario -> scenario.setup(serverComponent.getProtocolHandlersBus()));
|
||||
|
||||
NettyServer server = serverComponent.getNettyServer();
|
||||
|
||||
|
||||
@@ -7,42 +7,42 @@ import dagger.multibindings.IntoSet;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import mc.protocol.world.World;
|
||||
import mc.server.PlayerManager;
|
||||
import mc.server.processor.*;
|
||||
import mc.server.scenario.*;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Random;
|
||||
|
||||
@Module
|
||||
@RequiredArgsConstructor
|
||||
public class ProcessorModule {
|
||||
public class ScenarioModule {
|
||||
|
||||
private final Config config;
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Singleton
|
||||
PacketProcessor provideProcessorHadshake() {
|
||||
return new ProcessorHandshake();
|
||||
PacketScenario provideProcessorHadshake() {
|
||||
return new ScenarioHandshake();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Singleton
|
||||
PacketProcessor provideProcessorStatus() {
|
||||
return new ProcessorStatus(config);
|
||||
PacketScenario provideProcessorStatus() {
|
||||
return new ScenarioStatus(config);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Singleton
|
||||
PacketProcessor provideProcessorLogin(PlayerManager playerManager, World world) {
|
||||
return new ProcessorLogin(playerManager, new Random(System.currentTimeMillis()), config, world);
|
||||
PacketScenario provideProcessorLogin(PlayerManager playerManager, World world) {
|
||||
return new ScenarioLogin(playerManager, new Random(System.currentTimeMillis()), config, world);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@IntoSet
|
||||
@Singleton
|
||||
PacketProcessor provideProcessorPlay() {
|
||||
return new ProcessorPlay();
|
||||
PacketScenario provideProcessorPlay() {
|
||||
return new ScenarioPlay();
|
||||
}
|
||||
}
|
||||
@@ -3,13 +3,13 @@ package mc.server.di;
|
||||
import dagger.Component;
|
||||
import mc.protocol.handler.ProtocolHandlersBus;
|
||||
import mc.server.NettyServer;
|
||||
import mc.server.processor.PacketProcessor;
|
||||
import mc.server.scenario.PacketScenario;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Set;
|
||||
|
||||
@Component(modules = {
|
||||
ServerModule.class, ProcessorModule.class, PlayerManagerModule.class,
|
||||
ServerModule.class, ScenarioModule.class, PlayerManagerModule.class,
|
||||
WorldModule.class
|
||||
})
|
||||
@Singleton
|
||||
@@ -17,5 +17,5 @@ public interface ServerComponent {
|
||||
|
||||
ProtocolHandlersBus getProtocolHandlersBus();
|
||||
NettyServer getNettyServer();
|
||||
Set<PacketProcessor> getProcessors();
|
||||
Set<PacketScenario> getPacketScenarios();
|
||||
}
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
package mc.server.processor;
|
||||
package mc.server.scenario;
|
||||
|
||||
import mc.protocol.handler.ProtocolHandlersBus;
|
||||
|
||||
public interface PacketProcessor {
|
||||
public interface PacketScenario {
|
||||
|
||||
void setup(ProtocolHandlersBus protocolHandlersBus);
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package mc.server.processor;
|
||||
package mc.server.scenario;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import mc.protocol.ProtocolAttributes;
|
||||
@@ -6,7 +6,7 @@ import mc.protocol.State;
|
||||
import mc.protocol.handler.ProtocolHandlersBus;
|
||||
import mc.protocol.packets.handshaking.client.HandshakePacket;
|
||||
|
||||
public class ProcessorHandshake implements PacketProcessor {
|
||||
public class ScenarioHandshake implements PacketScenario {
|
||||
|
||||
@Override
|
||||
public void setup(ProtocolHandlersBus protocolHandlersBus) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package mc.server.processor;
|
||||
package mc.server.scenario;
|
||||
|
||||
import com.typesafe.config.Config;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -24,7 +24,7 @@ import mc.server.util.LocationUtils;
|
||||
import java.util.Random;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ProcessorLogin implements PacketProcessor {
|
||||
public class ScenarioLogin implements PacketScenario {
|
||||
|
||||
private final PlayerManager playerManager;
|
||||
private final Random random;
|
||||
@@ -1,4 +1,4 @@
|
||||
package mc.server.processor;
|
||||
package mc.server.scenario;
|
||||
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@@ -9,7 +9,7 @@ import mc.protocol.packets.KeepAlivePacket;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@Slf4j
|
||||
public class ProcessorPlay implements PacketProcessor {
|
||||
public class ScenarioPlay implements PacketScenario {
|
||||
|
||||
@Override
|
||||
public void setup(ProtocolHandlersBus protocolHandlersBus) {
|
||||
@@ -1,4 +1,4 @@
|
||||
package mc.server.processor;
|
||||
package mc.server.scenario;
|
||||
|
||||
import com.typesafe.config.Config;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
@@ -16,7 +16,7 @@ import mc.protocol.packets.status.server.StatusServerResponse;
|
||||
import java.util.Collections;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
public class ProcessorStatus implements PacketProcessor {
|
||||
public class ScenarioStatus implements PacketScenario {
|
||||
|
||||
private final Config config;
|
||||
|
||||
Reference in New Issue
Block a user