Bridge: обновление протокола
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
group = 'asys'
|
group = 'asys'
|
||||||
version = '0.7-SNAPSHOT'
|
version = '0.7.1-SNAPSHOT'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
maven { url 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
maven { url 'https://hub.spigotmc.org/nexus/content/groups/public/' }
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ import asys.bridge.client.AbstractBridge;
|
|||||||
import asys.bridge.client.IBridge;
|
import asys.bridge.client.IBridge;
|
||||||
import asys.bridge.client.IConfig;
|
import asys.bridge.client.IConfig;
|
||||||
import asys.bridge.client.ILogger;
|
import asys.bridge.client.ILogger;
|
||||||
|
import io.netty.channel.Channel;
|
||||||
import org.apache.logging.log4j.LogManager;
|
import org.apache.logging.log4j.LogManager;
|
||||||
import org.apache.logging.log4j.core.Logger;
|
import org.apache.logging.log4j.core.Logger;
|
||||||
|
|
||||||
@@ -15,13 +16,14 @@ public class BridgeBukkitImpl extends AbstractBridge implements IBridge {
|
|||||||
private BridgePlugin plugin;
|
private BridgePlugin plugin;
|
||||||
private LoggerBukkitImpl logger;
|
private LoggerBukkitImpl logger;
|
||||||
private ConfigBukkitImpl configBukkit;
|
private ConfigBukkitImpl configBukkit;
|
||||||
|
private BridgeLoggerAppender loggerAppender;
|
||||||
|
|
||||||
public BridgeBukkitImpl(BridgePlugin plugin) {
|
public BridgeBukkitImpl(BridgePlugin plugin) {
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.logger = new LoggerBukkitImpl(plugin.getLogger());
|
this.logger = new LoggerBukkitImpl(plugin.getLogger());
|
||||||
this.configBukkit = new ConfigBukkitImpl(plugin.getConfig());
|
this.configBukkit = new ConfigBukkitImpl(plugin.getConfig());
|
||||||
|
|
||||||
((Logger) LogManager.getRootLogger()).addAppender(new BridgeLoggerAppender());
|
((Logger) LogManager.getRootLogger()).addAppender(loggerAppender = new BridgeLoggerAppender());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@@ -46,4 +48,9 @@ public class BridgeBukkitImpl extends AbstractBridge implements IBridge {
|
|||||||
command
|
command
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setChannelFromConsoleMessages(Channel channel) {
|
||||||
|
this.loggerAppender.setChannel(channel);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ public class ClientPacketHandler extends ChannelInboundHandlerAdapter implements
|
|||||||
private static final BiMap<Integer, Class<? extends Packet>> knownPackets = ImmutableBiMap.of(
|
private static final BiMap<Integer, Class<? extends Packet>> knownPackets = ImmutableBiMap.of(
|
||||||
3, CS_Ping.class,
|
3, CS_Ping.class,
|
||||||
4, CS_ConsoleMessage.class,
|
4, CS_ConsoleMessage.class,
|
||||||
5, SC_Command.class
|
5, SC_Command.class,
|
||||||
|
6, SC_ToggleSendMessages.class
|
||||||
);
|
);
|
||||||
private IBridge bridge;
|
private IBridge bridge;
|
||||||
|
|
||||||
@@ -35,7 +36,8 @@ public class ClientPacketHandler extends ChannelInboundHandlerAdapter implements
|
|||||||
if (handshakeHandlers == null) {
|
if (handshakeHandlers == null) {
|
||||||
handshakeHandlers = ImmutableMap.of(
|
handshakeHandlers = ImmutableMap.of(
|
||||||
SC_HandshakeResult.class, this,
|
SC_HandshakeResult.class, this,
|
||||||
SC_Command.class, this
|
SC_Command.class, this,
|
||||||
|
SC_ToggleSendMessages.class, this
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,6 +75,8 @@ public class ClientPacketHandler extends ChannelInboundHandlerAdapter implements
|
|||||||
handleHandshakeResult((SC_HandshakeResult) packet, context);
|
handleHandshakeResult((SC_HandshakeResult) packet, context);
|
||||||
} else if (packet instanceof SC_Command) {
|
} else if (packet instanceof SC_Command) {
|
||||||
handleCommand((SC_Command) packet);
|
handleCommand((SC_Command) packet);
|
||||||
|
} else if (packet instanceof SC_ToggleSendMessages) {
|
||||||
|
handleToggleSendMessages((SC_ToggleSendMessages) packet, context);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -92,4 +96,8 @@ public class ClientPacketHandler extends ChannelInboundHandlerAdapter implements
|
|||||||
bridge.getLogger().info("Command: " + packet.getCommand());
|
bridge.getLogger().info("Command: " + packet.getCommand());
|
||||||
bridge.dispatchCommand(packet.getCommand());
|
bridge.dispatchCommand(packet.getCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void handleToggleSendMessages(SC_ToggleSendMessages packet, ChannelHandlerContext context) {
|
||||||
|
bridge.setChannelFromConsoleMessages(packet.isNeedSend() ? context.channel() : null);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,6 +11,7 @@ public interface IBridge {
|
|||||||
IConfig getConfig();
|
IConfig getConfig();
|
||||||
int getCountOnlinePlayers();
|
int getCountOnlinePlayers();
|
||||||
void dispatchCommand(String command);
|
void dispatchCommand(String command);
|
||||||
|
void setChannelFromConsoleMessages(Channel channel);
|
||||||
void startReconnect();
|
void startReconnect();
|
||||||
boolean isNeedReconnect();
|
boolean isNeedReconnect();
|
||||||
void setNeedReconnect(boolean value);
|
void setNeedReconnect(boolean value);
|
||||||
|
|||||||
Reference in New Issue
Block a user