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