Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
Merge branch 'master' of https://github.com/MylesIsCool/ViaVersion
Dieser Commit ist enthalten in:
Commit
559674bf58
@ -4,6 +4,7 @@ import us.myles.ViaVersion.api.ViaVersionConfig;
|
|||||||
import us.myles.ViaVersion.util.Configuration;
|
import us.myles.ViaVersion.util.Configuration;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class ViaConfig implements ViaVersionConfig {
|
public class ViaConfig implements ViaVersionConfig {
|
||||||
private final ViaVersionPlugin plugin;
|
private final ViaVersionPlugin plugin;
|
||||||
@ -169,4 +170,14 @@ public class ViaConfig implements ViaVersionConfig {
|
|||||||
public boolean isForceJsonTransform() {
|
public boolean isForceJsonTransform() {
|
||||||
return plugin.getConfig().getBoolean("force-json-transform", false);
|
return plugin.getConfig().getBoolean("force-json-transform", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Integer> getBlockedProtocols() {
|
||||||
|
return plugin.getConfig().getIntegerList("block-protocols");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getBlockedDisconnectMsg() {
|
||||||
|
return plugin.getConfig().getString("block-disconnect-msg", "You are using an unsupported Minecraft version!");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package us.myles.ViaVersion.api;
|
package us.myles.ViaVersion.api;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public interface ViaVersionConfig {
|
public interface ViaVersionConfig {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -193,4 +195,18 @@ public interface ViaVersionConfig {
|
|||||||
* @return True if enabled
|
* @return True if enabled
|
||||||
*/
|
*/
|
||||||
boolean isForceJsonTransform();
|
boolean isForceJsonTransform();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the blocked protocols
|
||||||
|
*
|
||||||
|
* @return An Integer list
|
||||||
|
*/
|
||||||
|
List<Integer> getBlockedProtocols();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the custom disconnect message
|
||||||
|
*
|
||||||
|
* @return Disconnect message
|
||||||
|
*/
|
||||||
|
String getBlockedDisconnectMsg();
|
||||||
}
|
}
|
||||||
|
@ -21,6 +21,7 @@ import us.myles.ViaVersion.api.remapper.PacketRemapper;
|
|||||||
import us.myles.ViaVersion.api.type.Type;
|
import us.myles.ViaVersion.api.type.Type;
|
||||||
import us.myles.ViaVersion.packets.Direction;
|
import us.myles.ViaVersion.packets.Direction;
|
||||||
import us.myles.ViaVersion.packets.State;
|
import us.myles.ViaVersion.packets.State;
|
||||||
|
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -31,6 +32,8 @@ public class BaseProtocol extends Protocol {
|
|||||||
@Override
|
@Override
|
||||||
protected void registerPackets() {
|
protected void registerPackets() {
|
||||||
/* Outgoing Packets */
|
/* Outgoing Packets */
|
||||||
|
|
||||||
|
// Status Response Packet
|
||||||
registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() { // Status Response Packet
|
registerOutgoing(State.STATUS, 0x00, 0x00, new PacketRemapper() { // Status Response Packet
|
||||||
@Override
|
@Override
|
||||||
public void registerMap() {
|
public void registerMap() {
|
||||||
@ -43,20 +46,26 @@ public class BaseProtocol extends Protocol {
|
|||||||
try {
|
try {
|
||||||
JSONObject json = (JSONObject) new JSONParser().parse(originalStatus);
|
JSONObject json = (JSONObject) new JSONParser().parse(originalStatus);
|
||||||
JSONObject version = (JSONObject) json.get("version");
|
JSONObject version = (JSONObject) json.get("version");
|
||||||
if (ViaVersion.getConfig().isSendSupportedVersions())
|
int protocolVersion = ((Long) version.get("protocol")).intValue();
|
||||||
|
|
||||||
|
if (ViaVersion.getConfig().isSendSupportedVersions()) //Send supported versions
|
||||||
version.put("supportedVersions", ViaVersion.getInstance().getSupportedVersions());
|
version.put("supportedVersions", ViaVersion.getInstance().getSupportedVersions());
|
||||||
if (ProtocolRegistry.SERVER_PROTOCOL == -1) {
|
|
||||||
Long original = (Long) version.get("protocol");
|
if (ProtocolRegistry.SERVER_PROTOCOL == -1) // Set the Server protocol if the detection on startup failed
|
||||||
ProtocolRegistry.SERVER_PROTOCOL = original.intValue();
|
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
|
||||||
}
|
|
||||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), ProtocolRegistry.SERVER_PROTOCOL);
|
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), ProtocolRegistry.SERVER_PROTOCOL);
|
||||||
if (protocols != null) {
|
if (protocols != null) {
|
||||||
if ((long) version.get("protocol") != 9999) //Fix serverlistplus
|
if (protocolVersion != 9999) //Fix ServerListPlus
|
||||||
version.put("protocol", info.getProtocolVersion());
|
version.put("protocol", info.getProtocolVersion());
|
||||||
} else {
|
} else {
|
||||||
// not compatible :(, *plays very sad violin*
|
// not compatible :(, *plays very sad violin*
|
||||||
wrapper.user().setActive(false);
|
wrapper.user().setActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ViaVersion.getConfig().getBlockedProtocols().contains(info.getProtocolVersion()))
|
||||||
|
version.put("protocol", -1); // Show blocked versions as outdated
|
||||||
|
|
||||||
wrapper.set(Type.STRING, 0, json.toJSONString()); // Update value
|
wrapper.set(Type.STRING, 0, json.toJSONString()); // Update value
|
||||||
} catch (ParseException e) {
|
} catch (ParseException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
@ -88,6 +97,10 @@ public class BaseProtocol extends Protocol {
|
|||||||
info.setUsername(wrapper.get(Type.STRING, 1));
|
info.setUsername(wrapper.get(Type.STRING, 1));
|
||||||
// Add to ported clients
|
// Add to ported clients
|
||||||
((ViaVersionPlugin) ViaVersion.getInstance()).addPortedClient(wrapper.user());
|
((ViaVersionPlugin) ViaVersion.getInstance()).addPortedClient(wrapper.user());
|
||||||
|
|
||||||
|
if (info.getPipeline().pipes().size() == 1 && info.getPipeline().pipes().get(0).getClass() == BaseProtocol.class) // Only base protocol
|
||||||
|
wrapper.user().setActive(false);
|
||||||
|
|
||||||
if (ViaVersion.getInstance().isDebug()) {
|
if (ViaVersion.getInstance().isDebug()) {
|
||||||
// Print out the route to console
|
// Print out the route to console
|
||||||
((ViaVersionPlugin) ViaVersion.getInstance()).getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
((ViaVersionPlugin) ViaVersion.getInstance()).getLogger().log(Level.INFO, "{0} logged in with protocol {1}, Route: {2}",
|
||||||
@ -130,11 +143,6 @@ public class BaseProtocol extends Protocol {
|
|||||||
pipeline.add(prot.getValue());
|
pipeline.add(prot.getValue());
|
||||||
}
|
}
|
||||||
wrapper.set(Type.VAR_INT, 0, ProtocolRegistry.SERVER_PROTOCOL);
|
wrapper.set(Type.VAR_INT, 0, ProtocolRegistry.SERVER_PROTOCOL);
|
||||||
} else {
|
|
||||||
if (state == 2) {
|
|
||||||
// not compatible :(, *plays very sad violin*
|
|
||||||
wrapper.user().setActive(false);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Change state
|
// Change state
|
||||||
@ -151,7 +159,28 @@ public class BaseProtocol extends Protocol {
|
|||||||
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
|
registerIncoming(State.STATUS, 0x00, 0x00); // Status Request Packet
|
||||||
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet
|
registerIncoming(State.STATUS, 0x01, 0x01); // Status Ping Packet
|
||||||
|
|
||||||
registerIncoming(State.LOGIN, 0x00, 0x00); // Login Start Packet
|
// Login Start Packet
|
||||||
|
registerIncoming(State.LOGIN, 0x00, 0x00, new PacketRemapper() {
|
||||||
|
@Override
|
||||||
|
public void registerMap() {
|
||||||
|
handler(new PacketHandler() {
|
||||||
|
@Override
|
||||||
|
public void handle(PacketWrapper wrapper) throws Exception {
|
||||||
|
int protocol = wrapper.user().get(ProtocolInfo.class).getProtocolVersion();
|
||||||
|
if (ViaVersion.getConfig().getBlockedProtocols().contains(protocol)) {
|
||||||
|
if (!wrapper.user().getChannel().isOpen()) return;
|
||||||
|
|
||||||
|
PacketWrapper disconnectPacket = new PacketWrapper(0x00, null, wrapper.user()); // Disconnect Packet
|
||||||
|
Protocol1_9TO1_8.FIX_JSON.write(disconnectPacket, ViaVersion.getConfig().getBlockedDisconnectMsg());
|
||||||
|
disconnectPacket.send(BaseProtocol.class);
|
||||||
|
|
||||||
|
wrapper.cancel();
|
||||||
|
wrapper.user().getChannel().closeFuture();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}); // Login Start Packet
|
||||||
registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet
|
registerIncoming(State.LOGIN, 0x01, 0x01); // Encryption Response Packet
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -12,6 +12,11 @@
|
|||||||
checkforupdates: true
|
checkforupdates: true
|
||||||
# Send the supported versions with the Status (Ping) response packet
|
# Send the supported versions with the Status (Ping) response packet
|
||||||
send-supported-versions: false
|
send-supported-versions: false
|
||||||
|
# Block specific Minecraft protocols that ViaVersion allows
|
||||||
|
# List of all Minecraft protocol versions: http://wiki.vg/Protocol_version_numbers
|
||||||
|
block-protocols: []
|
||||||
|
# Change the blocked disconnect message
|
||||||
|
block-disconnect-msg: "You are using an unsupported Minecraft version!"
|
||||||
#
|
#
|
||||||
#----------------------------------------------------------#
|
#----------------------------------------------------------#
|
||||||
# GLOBAL PACKET LIMITER #
|
# GLOBAL PACKET LIMITER #
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren