mirror of
https://gitlab.bixilon.de/bixilon/minosoft.git
synced 2025-09-17 03:15:35 -04:00
DefaultPluginChannels: use identifier instead of String
This commit is contained in:
parent
a69bb91f64
commit
cd6afe325c
@ -13,26 +13,29 @@
|
||||
|
||||
package de.bixilon.minosoft.protocol.modding.channels;
|
||||
|
||||
import de.bixilon.minosoft.game.datatypes.Identifier;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public enum DefaultPluginChannels {
|
||||
MC_BRAND("MC|Brand");
|
||||
MC_BRAND(new Identifier("MC|Brand", "minecraft:brand"));
|
||||
|
||||
|
||||
final String name;
|
||||
final Identifier identifier;
|
||||
|
||||
DefaultPluginChannels(String name) {
|
||||
this.name = name;
|
||||
DefaultPluginChannels(Identifier identifier) {
|
||||
this.identifier = identifier;
|
||||
}
|
||||
|
||||
public static DefaultPluginChannels byName(String name) {
|
||||
public static DefaultPluginChannels byName(String name, ProtocolVersion version) {
|
||||
for (DefaultPluginChannels d : values()) {
|
||||
if (d.getName().equals(name)) {
|
||||
if (d.getIdentifier().get(version).equals(name)) {
|
||||
return d;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return name;
|
||||
public Identifier getIdentifier() {
|
||||
return identifier;
|
||||
}
|
||||
}
|
||||
|
@ -74,7 +74,7 @@ public class PluginChannelHandler {
|
||||
return;
|
||||
}
|
||||
// check if channel was registered or if it is a default channel
|
||||
if (!registeredClientChannels.contains(name) && DefaultPluginChannels.byName(name) == null) {
|
||||
if (!registeredClientChannels.contains(name) && DefaultPluginChannels.byName(name, connection.getVersion()) == null) {
|
||||
Log.debug(String.format("Server tried to send data into unregistered plugin channel (name=\"%s\", messageLength=%d, string=\"%s\")", name, data.length, new String(data)));
|
||||
return;
|
||||
}
|
||||
@ -97,7 +97,7 @@ public class PluginChannelHandler {
|
||||
}
|
||||
|
||||
public void registerServerChannel(String name) {
|
||||
if (DefaultPluginChannels.byName(name) != null) {
|
||||
if (DefaultPluginChannels.byName(name, connection.getVersion()) != null) {
|
||||
// channel is a default channel, can not register
|
||||
throw new IllegalArgumentException(String.format("Can not register default Minecraft plugin channel (name=%s)", name));
|
||||
}
|
||||
@ -106,7 +106,7 @@ public class PluginChannelHandler {
|
||||
}
|
||||
|
||||
public void unregisterServerChannel(String name) {
|
||||
if (DefaultPluginChannels.byName(name) != null) {
|
||||
if (DefaultPluginChannels.byName(name, connection.getVersion()) != null) {
|
||||
// channel is a default channel, can not unregister
|
||||
throw new IllegalArgumentException(String.format("Can not unregister default Minecraft plugin channel (name=%s)", name));
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class Connection {
|
||||
|
||||
public void registerDefaultChannels() {
|
||||
// MC|Brand
|
||||
getPluginChannelHandler().registerClientHandler(DefaultPluginChannels.MC_BRAND.getName(), (handler, buffer) -> {
|
||||
getPluginChannelHandler().registerClientHandler(DefaultPluginChannels.MC_BRAND.getIdentifier().get(version), (handler, buffer) -> {
|
||||
String serverVersion;
|
||||
String clientVersion = (Minosoft.getConfig().getBoolean(GameConfiguration.NETWORK_FAKE_CLIENT_BRAND) ? "vanilla" : "Minosoft");
|
||||
OutByteBuffer toSend = new OutByteBuffer(getVersion());
|
||||
@ -210,7 +210,7 @@ public class Connection {
|
||||
}
|
||||
Log.info(String.format("Server is running \"%s\", connected with %s", serverVersion, getVersion().getName()));
|
||||
|
||||
getPluginChannelHandler().sendRawData(DefaultPluginChannels.MC_BRAND.getName(), toSend);
|
||||
getPluginChannelHandler().sendRawData(DefaultPluginChannels.MC_BRAND.getIdentifier().get(version), toSend);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -19,13 +19,13 @@ import de.bixilon.minosoft.protocol.protocol.OutPacketBuffer;
|
||||
import de.bixilon.minosoft.protocol.protocol.Packets;
|
||||
import de.bixilon.minosoft.protocol.protocol.ProtocolVersion;
|
||||
|
||||
public class PacketConfirmTransaction implements ServerboundPacket {
|
||||
public class PacketConfirmTransactionSending implements ServerboundPacket {
|
||||
|
||||
final byte windowId;
|
||||
final short actionNumber;
|
||||
final boolean accepted;
|
||||
|
||||
public PacketConfirmTransaction(byte windowId, short actionNumber, boolean accepted) {
|
||||
public PacketConfirmTransactionSending(byte windowId, short actionNumber, boolean accepted) {
|
||||
this.windowId = windowId;
|
||||
this.actionNumber = actionNumber;
|
||||
this.accepted = accepted;
|
Loading…
x
Reference in New Issue
Block a user