Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.skyxocuts.multicrafting.bungee.gamesmanager.server;
- import de.skyxocuts.multicrafting.bungee.Main;
- import io.netty.bootstrap.ServerBootstrap;
- import io.netty.channel.ChannelInitializer;
- import io.netty.channel.ChannelPipeline;
- import io.netty.channel.EventLoopGroup;
- import io.netty.channel.nio.NioEventLoopGroup;
- import io.netty.channel.socket.SocketChannel;
- import io.netty.channel.socket.nio.NioServerSocketChannel;
- import io.netty.handler.codec.DelimiterBasedFrameDecoder;
- import io.netty.handler.codec.Delimiters;
- import io.netty.handler.codec.string.StringDecoder;
- import io.netty.handler.codec.string.StringEncoder;
- /**
- * Created by Till on 01.06.2015.
- */
- public class BungeeServer {
- private int port;
- public BungeeServer() {
- this.port = 13494;
- Main.plugin.getProxy().getScheduler().runAsync(Main.plugin, new Runnable() {
- @Override
- public void run() {
- init();
- }
- });
- }
- public void init() {
- EventLoopGroup bossGroup = new NioEventLoopGroup();
- EventLoopGroup workerGroup = new NioEventLoopGroup();
- try {
- ServerBootstrap bootstrap = new ServerBootstrap()
- .group(bossGroup, workerGroup)
- .channel(NioServerSocketChannel.class)
- .childHandler(new ChannelInitializer<SocketChannel>() {
- @Override
- public void initChannel(SocketChannel socketChannel) throws Exception {
- Main.plugin.getLogger().info("TEst");
- ChannelPipeline pipeline = socketChannel.pipeline();
- pipeline.addLast("framer", new DelimiterBasedFrameDecoder(8192, Delimiters.lineDelimiter()));
- pipeline.addLast("decoder", new StringDecoder());
- pipeline.addLast("encoder", new StringEncoder());
- pipeline.addLast("handler", new BungeeServerHandler());
- }
- });
- bootstrap.bind(port).sync().channel().closeFuture().sync();
- } catch (InterruptedException e) {
- e.printStackTrace();
- } finally {
- bossGroup.shutdownGracefully();
- workerGroup.shutdownGracefully();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement