3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-26 08:10:09 +01:00

Consistent equalTo names

Dieser Commit ist enthalten in:
Nassim Jahnke 2024-02-14 19:14:41 +01:00
Ursprung 5c21f60ef7
Commit dccda57fc0
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: EF6771C01F6EF02F
8 geänderte Dateien mit 15 neuen und 15 gelöschten Zeilen

Datei anzeigen

@ -380,7 +380,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
* @param other other protocol version * @param other other protocol version
* @return true if this protocol version is higher than or equal to the other protocol version * @return true if this protocol version is higher than or equal to the other protocol version
*/ */
public boolean newerThanOrEquals(final ProtocolVersion other) { public boolean newerThanOrEqualTo(final ProtocolVersion other) {
return this.compareTo(other) >= 0; return this.compareTo(other) >= 0;
} }
@ -400,7 +400,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
* @param other other protocol version * @param other other protocol version
* @return true if this protocol version is lower than or equal to the other protocol version * @return true if this protocol version is lower than or equal to the other protocol version
*/ */
public boolean olderThanOrEquals(final ProtocolVersion other) { public boolean olderThanOrEqualTo(final ProtocolVersion other) {
return this.compareTo(other) <= 0; return this.compareTo(other) <= 0;
} }
@ -412,7 +412,7 @@ public class ProtocolVersion implements Comparable<ProtocolVersion> {
* @return true if this protocol version is between the given protocol versions, inclusive * @return true if this protocol version is between the given protocol versions, inclusive
*/ */
public boolean betweenInclusive(final ProtocolVersion min, final ProtocolVersion max) { public boolean betweenInclusive(final ProtocolVersion min, final ProtocolVersion max) {
return this.newerThanOrEquals(min) && this.olderThanOrEquals(max); return this.newerThanOrEqualTo(min) && this.olderThanOrEqualTo(max);
} }
/** /**

Datei anzeigen

@ -96,7 +96,7 @@ public class PlayerSneakListener extends ViaBukkitListener {
if (info == null) return; if (info == null) return;
ProtocolVersion protocolVersion = info.protocolVersion(); ProtocolVersion protocolVersion = info.protocolVersion();
if (is1_14Fix && protocolVersion.newerThanOrEquals(ProtocolVersion.v1_14)) { if (is1_14Fix && protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_14)) {
setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT); setHeight(player, event.isSneaking() ? HEIGHT_1_14 : STANDING_HEIGHT);
if (event.isSneaking()) if (event.isSneaking())
sneakingUuids.add(player.getUniqueId()); sneakingUuids.add(player.getUniqueId());
@ -108,7 +108,7 @@ public class PlayerSneakListener extends ViaBukkitListener {
sneaking.put(player, true); sneaking.put(player, true);
else else
sneaking.remove(player); sneaking.remove(player);
} else if (is1_9Fix && protocolVersion.newerThanOrEquals(ProtocolVersion.v1_9)) { } else if (is1_9Fix && protocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
setHeight(player, event.isSneaking() ? HEIGHT_1_9 : STANDING_HEIGHT); setHeight(player, event.isSneaking() ? HEIGHT_1_9 : STANDING_HEIGHT);
if (!useCache) return; if (!useCache) return;
if (event.isSneaking()) if (event.isSneaking())

Datei anzeigen

@ -133,7 +133,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion(); final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion();
if (protocol.equalTo(ProtocolVersion.v1_8)) { if (protocol.equalTo(ProtocolVersion.v1_8)) {
ReflectionUtil.set(packet, "shift", 1); ReflectionUtil.set(packet, "shift", 1);
} else if (protocol.newerThanOrEquals(ProtocolVersion.v1_9)) { } else if (protocol.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
ReflectionUtil.set(packet, "shift", clickTypeEnum); ReflectionUtil.set(packet, "shift", clickTypeEnum);
} }
} catch (Exception e) { } catch (Exception e) {
@ -170,7 +170,7 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
try { try {
this.windowClickPacketClass = NMSUtil.nms("PacketPlayInWindowClick"); this.windowClickPacketClass = NMSUtil.nms("PacketPlayInWindowClick");
final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion(); final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion();
if (protocol.newerThanOrEquals(ProtocolVersion.v1_9)) { if (protocol.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
Class<?> eclassz = NMSUtil.nms("InventoryClickType"); Class<?> eclassz = NMSUtil.nms("InventoryClickType");
Object[] constants = eclassz.getEnumConstants(); Object[] constants = eclassz.getEnumConstants();
this.clickTypeEnum = constants[1]; // QUICK_MOVE this.clickTypeEnum = constants[1]; // QUICK_MOVE
@ -199,6 +199,6 @@ public class BukkitInventoryQuickMoveProvider extends InventoryQuickMoveProvider
private boolean isSupported() { private boolean isSupported() {
final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion(); final ProtocolVersion protocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion();
return protocol.newerThanOrEquals(ProtocolVersion.v1_8) && protocol.olderThanOrEquals(ProtocolVersion.v1_11_1); return protocol.newerThanOrEqualTo(ProtocolVersion.v1_8) && protocol.olderThanOrEqualTo(ProtocolVersion.v1_11_1);
} }
} }

Datei anzeigen

@ -173,7 +173,7 @@ public class BungeeServerHandler implements Listener {
String serverName = server.getInfo().getName(); String serverName = server.getInfo().getName();
storage.setCurrentServer(serverName); storage.setCurrentServer(serverName);
ProtocolVersion serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName); ProtocolVersion serverProtocolVersion = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName);
if (serverProtocolVersion.olderThanOrEquals(ProtocolVersion.v1_8) && storage.getBossbar() != null) { // 1.8 doesn't have BossBar packet if (serverProtocolVersion.olderThanOrEqualTo(ProtocolVersion.v1_8) && storage.getBossbar() != null) { // 1.8 doesn't have BossBar packet
// This ensures we can encode it properly as only the 1.9 protocol is currently implemented. // This ensures we can encode it properly as only the 1.9 protocol is currently implemented.
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) { if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
for (UUID uuid : storage.getBossbar()) { for (UUID uuid : storage.getBossbar()) {
@ -210,8 +210,8 @@ public class BungeeServerHandler implements Listener {
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocolVersion)); pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(serverProtocolVersion));
// Workaround 1.13 server change // Workaround 1.13 server change
boolean toNewId = previousServerProtocol.olderThan(ProtocolVersion.v1_13) && serverProtocolVersion.newerThanOrEquals(ProtocolVersion.v1_13); boolean toNewId = previousServerProtocol.olderThan(ProtocolVersion.v1_13) && serverProtocolVersion.newerThanOrEqualTo(ProtocolVersion.v1_13);
boolean toOldId = previousServerProtocol.newerThanOrEquals(ProtocolVersion.v1_13) && serverProtocolVersion.olderThan(ProtocolVersion.v1_13); boolean toOldId = previousServerProtocol.newerThanOrEqualTo(ProtocolVersion.v1_13) && serverProtocolVersion.olderThan(ProtocolVersion.v1_13);
if (previousServerProtocol.isKnown() && (toNewId || toOldId)) { if (previousServerProtocol.isKnown() && (toNewId || toOldId)) {
Collection<String> registeredChannels = (Collection<String>) getRegisteredChannels.invoke(event.getPlayer().getPendingConnection()); Collection<String> registeredChannels = (Collection<String>) getRegisteredChannels.invoke(event.getPlayer().getPendingConnection());
if (!registeredChannels.isEmpty()) { if (!registeredChannels.isEmpty()) {

Datei anzeigen

@ -71,7 +71,7 @@ public class BaseProtocol extends AbstractProtocol<BaseClientboundPacket, BaseCl
List<ProtocolPathEntry> protocolPath = null; List<ProtocolPathEntry> protocolPath = null;
// Only allow newer clients (or 1.9.2 on 1.9.4 server if the server supports it) // Only allow newer clients (or 1.9.2 on 1.9.4 server if the server supports it)
if (info.protocolVersion().newerThanOrEquals(serverProtocol) || Via.getPlatform().isOldClientsAllowed()) { if (info.protocolVersion().newerThanOrEqualTo(serverProtocol) || Via.getPlatform().isOldClientsAllowed()) {
protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.protocolVersion(), serverProtocol); protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.protocolVersion(), serverProtocol);
} }

Datei anzeigen

@ -100,7 +100,7 @@ public class BaseProtocol1_7 extends AbstractProtocol<BaseClientboundPacket, Bas
ProtocolVersion closestServerProtocol = versionProvider.getClosestServerProtocol(wrapper.user()); ProtocolVersion closestServerProtocol = versionProvider.getClosestServerProtocol(wrapper.user());
List<ProtocolPathEntry> protocols = null; List<ProtocolPathEntry> protocols = null;
if (info.protocolVersion().newerThanOrEquals(closestServerProtocol) || Via.getPlatform().isOldClientsAllowed()) { if (info.protocolVersion().newerThanOrEqualTo(closestServerProtocol) || Via.getPlatform().isOldClientsAllowed()) {
protocols = Via.getManager().getProtocolManager() protocols = Via.getManager().getProtocolManager()
.getProtocolPath(info.protocolVersion(), closestServerProtocol); .getProtocolPath(info.protocolVersion(), closestServerProtocol);
} }

Datei anzeigen

@ -152,7 +152,7 @@ public class Protocol1_12To1_11_1 extends AbstractProtocol<ClientboundPackets1_9
clientChunks.setEnvironment(dimensionId); clientChunks.setEnvironment(dimensionId);
// Reset recipes // Reset recipes
if (user.getProtocolInfo().protocolVersion().newerThanOrEquals(ProtocolVersion.v1_13)) { if (user.getProtocolInfo().protocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_13)) {
wrapper.create(ClientboundPackets1_13.DECLARE_RECIPES, packetWrapper -> packetWrapper.write(Type.VAR_INT, 0)) wrapper.create(ClientboundPackets1_13.DECLARE_RECIPES, packetWrapper -> packetWrapper.write(Type.VAR_INT, 0))
.scheduleSend(Protocol1_13To1_12_2.class); .scheduleSend(Protocol1_13To1_12_2.class);
} }

Datei anzeigen

@ -59,7 +59,7 @@ public class GlassConnectionHandler extends AbstractFenceConnectionHandler {
if (states != 0) return states; if (states != 0) return states;
ProtocolInfo protocolInfo = user.getProtocolInfo(); ProtocolInfo protocolInfo = user.getProtocolInfo();
return protocolInfo.serverProtocolVersion().olderThanOrEquals(ProtocolVersion.v1_8) return protocolInfo.serverProtocolVersion().olderThanOrEqualTo(ProtocolVersion.v1_8)
&& protocolInfo.serverProtocolVersion().isKnown() ? 0xF : states; && protocolInfo.serverProtocolVersion().isKnown() ? 0xF : states;
} }
} }