mirror of
https://github.com/ViaVersion/ViaVersion.git
synced 2024-11-21 17:45:36 +01:00
Some cosmetic code changes and typo fixes
This commit is contained in:
parent
67ba0e9566
commit
b1b0874c0f
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
2
.github/ISSUE_TEMPLATE/bug_report.yml
vendored
@ -71,7 +71,7 @@ body:
|
||||
attributes:
|
||||
label: Additional Server Info
|
||||
description: |
|
||||
Do you use a proxy (eg. BungeeCord)? What software do you use and what plugins?
|
||||
Do you use a proxy (e.g. BungeeCord)? What software do you use and what plugins?
|
||||
placeholder: |
|
||||
Example: "I also use BungeeCord with the following plugins: x, y, z"
|
||||
validations:
|
||||
|
@ -117,7 +117,7 @@ public interface ViaAPI<T> {
|
||||
* Sends a raw packet to the player.
|
||||
*
|
||||
* @param player the platform's player object, e.g. for Bukkit this is Player
|
||||
* @param packet the packet; you need a VarInt Id, then the packet contents
|
||||
* @param packet the packet; you need a VarInt id, then the packet contents
|
||||
* @throws IllegalArgumentException if the player is not injected by Via
|
||||
*/
|
||||
void sendRawPacket(T player, ByteBuf packet);
|
||||
@ -126,7 +126,7 @@ public interface ViaAPI<T> {
|
||||
* Sends a raw packet to the player.
|
||||
*
|
||||
* @param uuid the uuid from the player to send packet
|
||||
* @param packet the packet; you need a VarInt Id, then the packet contents
|
||||
* @param packet the packet; you need a VarInt id, then the packet contents
|
||||
* @throws IllegalArgumentException if the player is not injected by Via
|
||||
*/
|
||||
void sendRawPacket(UUID uuid, ByteBuf packet);
|
||||
|
@ -28,7 +28,7 @@ public interface ViaCommandSender {
|
||||
/**
|
||||
* Check if the sender has a permission.
|
||||
*
|
||||
* @param permission Permission string eg. viaversion.admin
|
||||
* @param permission Permission string e.g. viaversion.admin
|
||||
* @return True if the sender has the permission
|
||||
*/
|
||||
boolean hasPermission(String permission);
|
||||
|
@ -65,7 +65,7 @@ public interface ConnectionManager {
|
||||
|
||||
/**
|
||||
* Returns the UUID from the frontend connection to this proxy server
|
||||
* Returns null when there isn't a server or this connection isn't frontend or it doesn't have an id
|
||||
* Returns null when there isn't a server or this connection isn't frontend, or it doesn't have an id
|
||||
* When ViaVersion is reloaded, this method may not return some players.
|
||||
* May not return ProtocolSupport players.
|
||||
* <p>
|
||||
|
@ -31,14 +31,14 @@ public interface ViaInjector {
|
||||
/**
|
||||
* Inject into the current Platform
|
||||
*
|
||||
* @throws Exception If there is an error with injecting
|
||||
* @throws Exception if there is an error with injecting
|
||||
*/
|
||||
void inject() throws Exception;
|
||||
|
||||
/**
|
||||
* Uninject into the current Platform
|
||||
*
|
||||
* @throws Exception If there is an error with uninjecting
|
||||
* @throws Exception if there is an error with uninjecting
|
||||
*/
|
||||
void uninject() throws Exception;
|
||||
|
||||
@ -57,7 +57,7 @@ public interface ViaInjector {
|
||||
* For proxies, this returns the lowest supported protocol version.
|
||||
*
|
||||
* @return server protocol version
|
||||
* @throws Exception if there is an error with getting this info, eg. not binded
|
||||
* @throws Exception if there is an error with getting this info, e.g. not binded
|
||||
* @see ViaPlatform#isProxy()
|
||||
*/
|
||||
int getServerProtocolVersion() throws Exception;
|
||||
@ -66,7 +66,7 @@ public interface ViaInjector {
|
||||
* Returns the supported server protocol versions.
|
||||
*
|
||||
* @return server protocol versions
|
||||
* @throws Exception if there is an error with getting this info, eg. not binded
|
||||
* @throws Exception if there is an error with getting this info, e.g. not binded
|
||||
* @see ViaPlatform#isProxy()
|
||||
*/
|
||||
default IntSortedSet getServerProtocolVersions() throws Exception {
|
||||
|
@ -25,7 +25,7 @@ package com.viaversion.viaversion.api.platform;
|
||||
public interface ViaPlatformLoader {
|
||||
|
||||
/**
|
||||
* Initialise the loading for a platform, eg. registering listeners / providers / events etc.
|
||||
* Initialise the loading for a platform, e.g. registering listeners / providers / events etc.
|
||||
*/
|
||||
void load();
|
||||
|
||||
|
@ -27,7 +27,7 @@ import com.viaversion.viaversion.api.protocol.packet.Direction;
|
||||
import com.viaversion.viaversion.api.protocol.packet.ServerboundPacketType;
|
||||
|
||||
/**
|
||||
* Dummy protocol class when there is no need of any of the
|
||||
* Dummy protocol class when there is no need of the
|
||||
* existing packet type enums or automated channel mappings.
|
||||
*
|
||||
* @see Protocol
|
||||
|
@ -23,8 +23,7 @@
|
||||
package com.viaversion.viaversion.api.protocol.packet;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by server outgoing packet type enums,
|
||||
* representing PLAY state packets, ordered by their packet id.
|
||||
* Interface to be implemented by server outgoing packet types.
|
||||
*/
|
||||
public interface ClientboundPacketType extends PacketType {
|
||||
|
||||
|
@ -81,11 +81,9 @@ public class PacketTracker {
|
||||
if (connection.isClientSide()) return false; // Don't apply PPS limiting for client-side
|
||||
ViaVersionConfig conf = Via.getConfig();
|
||||
// Max PPS Checker
|
||||
if (conf.getMaxPPS() > 0) {
|
||||
if (packetsPerSecond >= conf.getMaxPPS()) {
|
||||
connection.disconnect(conf.getMaxPPSKickMessage().replace("%pps", Long.toString(packetsPerSecond)));
|
||||
return true; // don't send current packet
|
||||
}
|
||||
if (conf.getMaxPPS() > 0 && packetsPerSecond >= conf.getMaxPPS()) {
|
||||
connection.disconnect(conf.getMaxPPSKickMessage().replace("%pps", Long.toString(packetsPerSecond)));
|
||||
return true; // don't send current packet
|
||||
}
|
||||
|
||||
// Tracking PPS Checker
|
||||
|
@ -23,8 +23,7 @@
|
||||
package com.viaversion.viaversion.api.protocol.packet;
|
||||
|
||||
/**
|
||||
* Interface to be implemented by server incoming packet type enums,
|
||||
* representing PLAY state packets, ordered by their packet id.
|
||||
* Interface to be implemented by server incoming packet types.
|
||||
*/
|
||||
public interface ServerboundPacketType extends PacketType {
|
||||
|
||||
|
@ -107,7 +107,7 @@ public class ProtocolVersion {
|
||||
* @param snapshotVersion snapshot protocol version, or -1 if not a snapshot
|
||||
* @param name version name
|
||||
* @param versionRange range of versions that are supported by this protocol version, null if not a range
|
||||
* @return registered {@link ProtocolVersion}
|
||||
* @return registered ProtocolVersion
|
||||
*/
|
||||
public static ProtocolVersion register(int version, int snapshotVersion, String name, @Nullable VersionRange versionRange) {
|
||||
ProtocolVersion protocol = new ProtocolVersion(version, snapshotVersion, name, versionRange);
|
||||
@ -130,11 +130,11 @@ public class ProtocolVersion {
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a {@link ProtocolVersion} instance, even if this protocol version
|
||||
* Returns a ProtocolVersion instance, even if this protocol version
|
||||
* has not been registered. See {@link #isRegistered(int)} berorehand or {@link #isKnown()}.
|
||||
*
|
||||
* @param version protocol version
|
||||
* @return registered or unknown {@link ProtocolVersion}
|
||||
* @return registered or unknown ProtocolVersion
|
||||
*/
|
||||
public static @NonNull ProtocolVersion getProtocol(int version) {
|
||||
ProtocolVersion protocolVersion = VERSIONS.get(version);
|
||||
@ -185,10 +185,8 @@ public class ProtocolVersion {
|
||||
if (majorVersion.equals(protocol) || (protocol.startsWith(name.substring(0, name.length() - 1)))) {
|
||||
return version;
|
||||
}
|
||||
} else if (version.isRange()) {
|
||||
if (version.getIncludedVersions().contains(protocol)) {
|
||||
return version;
|
||||
}
|
||||
} else if (version.isRange() && version.getIncludedVersions().contains(protocol)) {
|
||||
return version;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
@ -248,7 +246,7 @@ public class ProtocolVersion {
|
||||
* Returns the snapshot protocol version without the snapshot indicator bit if this is a snapshot protocol version.
|
||||
*
|
||||
* @return snapshot protocol version without the snapshot indicator bit
|
||||
* @throws IllegalArgumentException if the version if not a snapshot version
|
||||
* @throws IllegalArgumentException if the version is not a snapshot version
|
||||
* @see #isSnapshot()
|
||||
*/
|
||||
public int getSnapshotVersion() {
|
||||
@ -260,7 +258,7 @@ public class ProtocolVersion {
|
||||
* Returns the snapshot protocol version with the snapshot indicator bit if this is a snapshot protocol version.
|
||||
*
|
||||
* @return snapshot protocol version with the snapshot indicator bit
|
||||
* @throws IllegalArgumentException if the version if not a snapshot version
|
||||
* @throws IllegalArgumentException if the version is not a snapshot version
|
||||
* @see #isSnapshot()
|
||||
*/
|
||||
public int getFullSnapshotVersion() {
|
||||
|
@ -52,7 +52,7 @@ public interface ServerProtocolVersion {
|
||||
|
||||
/**
|
||||
* Returns true if the actual protocol version has not yet been identified.
|
||||
* In that case, all methods above will returns -1.
|
||||
* In that case, all methods above will return -1.
|
||||
*
|
||||
* @return true if set, false if unknown (yet)
|
||||
*/
|
||||
|
@ -25,6 +25,7 @@ package com.viaversion.viaversion.api.protocol.version;
|
||||
import com.viaversion.viaversion.api.connection.UserConnection;
|
||||
import com.viaversion.viaversion.api.platform.providers.Provider;
|
||||
|
||||
@FunctionalInterface
|
||||
public interface VersionProvider extends Provider {
|
||||
|
||||
/**
|
||||
|
@ -30,7 +30,7 @@ import java.nio.charset.StandardCharsets;
|
||||
|
||||
public class StringType extends Type<String> {
|
||||
// String#length() (used to limit the string in Minecraft source code) uses char[]#length
|
||||
private static final int maxJavaCharUtf8Length = Character.toString(Character.MAX_VALUE)
|
||||
private static final int MAX_CHAR_UTF_8_LENGTH = Character.toString(Character.MAX_VALUE)
|
||||
.getBytes(StandardCharsets.UTF_8).length;
|
||||
private final int maxLength;
|
||||
|
||||
@ -47,8 +47,8 @@ public class StringType extends Type<String> {
|
||||
public String read(ByteBuf buffer) throws Exception {
|
||||
int len = Type.VAR_INT.readPrimitive(buffer);
|
||||
|
||||
Preconditions.checkArgument(len <= maxLength * maxJavaCharUtf8Length,
|
||||
"Cannot receive string longer than Short.MAX_VALUE * " + maxJavaCharUtf8Length + " bytes (got %s bytes)", len);
|
||||
Preconditions.checkArgument(len <= maxLength * MAX_CHAR_UTF_8_LENGTH,
|
||||
"Cannot receive string longer than Short.MAX_VALUE * " + MAX_CHAR_UTF_8_LENGTH + " bytes (got %s bytes)", len);
|
||||
|
||||
String string = buffer.toString(buffer.readerIndex(), len, StandardCharsets.UTF_8);
|
||||
buffer.skipBytes(len);
|
||||
|
@ -58,7 +58,7 @@ public final class PaperViaInjector {
|
||||
try {
|
||||
Class.forName("org.bukkit.UnsafeValues").getDeclaredMethod("getProtocolVersion");
|
||||
return true;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
} catch (final ClassNotFoundException | NoSuchMethodException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@ -75,7 +75,7 @@ public final class PaperViaInjector {
|
||||
try {
|
||||
Class.forName(className);
|
||||
return true;
|
||||
} catch (ReflectiveOperationException e) {
|
||||
} catch (final ClassNotFoundException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -65,30 +65,28 @@ public class BungeeEncodeHandler extends MessageToMessageEncoder<ByteBuf> {
|
||||
|
||||
private boolean handleCompressionOrder(ChannelHandlerContext ctx, ByteBuf buf) {
|
||||
boolean needsCompress = false;
|
||||
if (!handledCompression) {
|
||||
if (ctx.pipeline().names().indexOf("compress") > ctx.pipeline().names().indexOf("via-encoder")) {
|
||||
// Need to decompress this packet due to bad order
|
||||
ByteBuf decompressed = BungeePipelineUtil.decompress(ctx, buf);
|
||||
if (!handledCompression && ctx.pipeline().names().indexOf("compress") > ctx.pipeline().names().indexOf("via-encoder")) {
|
||||
// Need to decompress this packet due to bad order
|
||||
ByteBuf decompressed = BungeePipelineUtil.decompress(ctx, buf);
|
||||
|
||||
// Ensure the buffer wasn't reused
|
||||
if (buf != decompressed) {
|
||||
try {
|
||||
buf.clear().writeBytes(decompressed);
|
||||
} finally {
|
||||
decompressed.release();
|
||||
}
|
||||
// Ensure the buffer wasn't reused
|
||||
if (buf != decompressed) {
|
||||
try {
|
||||
buf.clear().writeBytes(decompressed);
|
||||
} finally {
|
||||
decompressed.release();
|
||||
}
|
||||
|
||||
// Reorder the pipeline
|
||||
ChannelHandler dec = ctx.pipeline().get("via-decoder");
|
||||
ChannelHandler enc = ctx.pipeline().get("via-encoder");
|
||||
ctx.pipeline().remove(dec);
|
||||
ctx.pipeline().remove(enc);
|
||||
ctx.pipeline().addAfter("decompress", "via-decoder", dec);
|
||||
ctx.pipeline().addAfter("compress", "via-encoder", enc);
|
||||
needsCompress = true;
|
||||
handledCompression = true;
|
||||
}
|
||||
|
||||
// Reorder the pipeline
|
||||
ChannelHandler decoder = ctx.pipeline().get("via-decoder");
|
||||
ChannelHandler encoder = ctx.pipeline().get("via-encoder");
|
||||
ctx.pipeline().remove(decoder);
|
||||
ctx.pipeline().remove(encoder);
|
||||
ctx.pipeline().addAfter("decompress", "via-decoder", decoder);
|
||||
ctx.pipeline().addAfter("compress", "via-encoder", encoder);
|
||||
needsCompress = true;
|
||||
handledCompression = true;
|
||||
}
|
||||
return needsCompress;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
import net.md_5.bungee.api.connection.Server;
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.event.ServerSwitchEvent;
|
||||
@ -140,150 +141,147 @@ public class BungeeServerHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
|
||||
if (user == null) return;
|
||||
public void checkServerChange(ServerConnectedEvent event, UserConnection user) throws Exception {
|
||||
if (user == null || !user.has(BungeeStorage.class)) {
|
||||
return;
|
||||
}
|
||||
|
||||
// Auto-team handling
|
||||
// Handle server/version change
|
||||
if (user.has(BungeeStorage.class)) {
|
||||
BungeeStorage storage = user.get(BungeeStorage.class);
|
||||
ProxiedPlayer player = storage.getPlayer();
|
||||
BungeeStorage storage = user.get(BungeeStorage.class);
|
||||
Server server = event.getServer();
|
||||
if (server == null || server.getInfo().getName().equals(storage.getCurrentServer())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (e.getServer() != null) {
|
||||
if (!e.getServer().getInfo().getName().equals(storage.getCurrentServer())) {
|
||||
// Clear auto-team
|
||||
EntityTracker1_9 oldEntityTracker = user.getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (oldEntityTracker != null) {
|
||||
if (oldEntityTracker.isAutoTeam() && oldEntityTracker.isTeamExists()) {
|
||||
oldEntityTracker.sendTeamPacket(false, true);
|
||||
}
|
||||
}
|
||||
// Clear auto-team
|
||||
EntityTracker1_9 oldEntityTracker = user.getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (oldEntityTracker != null) {
|
||||
if (oldEntityTracker.isAutoTeam() && oldEntityTracker.isTeamExists()) {
|
||||
oldEntityTracker.sendTeamPacket(false, true);
|
||||
}
|
||||
}
|
||||
|
||||
String serverName = e.getServer().getInfo().getName();
|
||||
String serverName = event.getServer().getInfo().getName();
|
||||
|
||||
storage.setCurrentServer(serverName);
|
||||
storage.setCurrentServer(serverName);
|
||||
|
||||
int protocolId = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName);
|
||||
int protocolId = Via.proxyPlatform().protocolDetectorService().serverProtocolVersion(serverName);
|
||||
|
||||
if (protocolId <= ProtocolVersion.v1_8.getVersion()) { // 1.8 doesn't have BossBar packet
|
||||
if (storage.getBossbar() != null) {
|
||||
// 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)) {
|
||||
for (UUID uuid : storage.getBossbar()) {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSSBAR, null, user);
|
||||
wrapper.write(Type.UUID, uuid);
|
||||
wrapper.write(Type.VAR_INT, 1); // remove
|
||||
wrapper.send(Protocol1_9To1_8.class);
|
||||
}
|
||||
}
|
||||
storage.getBossbar().clear();
|
||||
}
|
||||
}
|
||||
if (protocolId <= ProtocolVersion.v1_8.getVersion() && 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.
|
||||
if (user.getProtocolInfo().getPipeline().contains(Protocol1_9To1_8.class)) {
|
||||
for (UUID uuid : storage.getBossbar()) {
|
||||
PacketWrapper wrapper = PacketWrapper.create(ClientboundPackets1_9.BOSSBAR, null, user);
|
||||
wrapper.write(Type.UUID, uuid);
|
||||
wrapper.write(Type.VAR_INT, 1); // remove
|
||||
wrapper.send(Protocol1_9To1_8.class);
|
||||
}
|
||||
}
|
||||
storage.getBossbar().clear();
|
||||
}
|
||||
|
||||
ProtocolInfo info = user.getProtocolInfo();
|
||||
int previousServerProtocol = info.getServerProtocolVersion();
|
||||
ProtocolInfo info = user.getProtocolInfo();
|
||||
int previousServerProtocol = info.getServerProtocolVersion();
|
||||
|
||||
// Refresh the pipes
|
||||
List<ProtocolPathEntry> protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.getProtocolVersion(), protocolId);
|
||||
ProtocolPipeline pipeline = user.getProtocolInfo().getPipeline();
|
||||
user.clearStoredObjects(true);
|
||||
pipeline.cleanPipes();
|
||||
if (protocolPath == null) {
|
||||
// TODO Check Bungee Supported Protocols? *shrugs*
|
||||
protocolId = info.getProtocolVersion();
|
||||
// Refresh the pipes
|
||||
List<ProtocolPathEntry> protocolPath = Via.getManager().getProtocolManager().getProtocolPath(info.getProtocolVersion(), protocolId);
|
||||
ProtocolPipeline pipeline = user.getProtocolInfo().getPipeline();
|
||||
user.clearStoredObjects(true);
|
||||
pipeline.cleanPipes();
|
||||
if (protocolPath == null) {
|
||||
// TODO Check Bungee Supported Protocols? *shrugs*
|
||||
protocolId = info.getProtocolVersion();
|
||||
} else {
|
||||
List<Protocol> protocols = new ArrayList<>(protocolPath.size());
|
||||
for (ProtocolPathEntry entry : protocolPath) {
|
||||
protocols.add(entry.protocol());
|
||||
}
|
||||
pipeline.add(protocols);
|
||||
}
|
||||
|
||||
info.setServerProtocolVersion(protocolId);
|
||||
// Add version-specific base Protocol
|
||||
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(protocolId));
|
||||
|
||||
// Workaround 1.13 server change
|
||||
int id1_13 = ProtocolVersion.v1_13.getVersion();
|
||||
boolean toNewId = previousServerProtocol < id1_13 && protocolId >= id1_13;
|
||||
boolean toOldId = previousServerProtocol >= id1_13 && protocolId < id1_13;
|
||||
if (previousServerProtocol != -1 && (toNewId || toOldId)) {
|
||||
Collection<String> registeredChannels = (Collection<String>) getRegisteredChannels.invoke(event.getPlayer().getPendingConnection());
|
||||
if (!registeredChannels.isEmpty()) {
|
||||
Collection<String> newChannels = new HashSet<>();
|
||||
for (Iterator<String> iterator = registeredChannels.iterator(); iterator.hasNext(); ) {
|
||||
String channel = iterator.next();
|
||||
String oldChannel = channel;
|
||||
if (toNewId) {
|
||||
channel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
} else {
|
||||
List<Protocol> protocols = new ArrayList<>(protocolPath.size());
|
||||
for (ProtocolPathEntry entry : protocolPath) {
|
||||
protocols.add(entry.protocol());
|
||||
}
|
||||
pipeline.add(protocols);
|
||||
channel = InventoryPackets.getOldPluginChannelId(channel);
|
||||
}
|
||||
|
||||
info.setServerProtocolVersion(protocolId);
|
||||
// Add version-specific base Protocol
|
||||
pipeline.add(Via.getManager().getProtocolManager().getBaseProtocol(protocolId));
|
||||
|
||||
// Workaround 1.13 server change
|
||||
int id1_13 = ProtocolVersion.v1_13.getVersion();
|
||||
boolean toNewId = previousServerProtocol < id1_13 && protocolId >= id1_13;
|
||||
boolean toOldId = previousServerProtocol >= id1_13 && protocolId < id1_13;
|
||||
if (previousServerProtocol != -1 && (toNewId || toOldId)) {
|
||||
Collection<String> registeredChannels = (Collection<String>) getRegisteredChannels.invoke(e.getPlayer().getPendingConnection());
|
||||
if (!registeredChannels.isEmpty()) {
|
||||
Collection<String> newChannels = new HashSet<>();
|
||||
for (Iterator<String> iterator = registeredChannels.iterator(); iterator.hasNext(); ) {
|
||||
String channel = iterator.next();
|
||||
String oldChannel = channel;
|
||||
if (toNewId) {
|
||||
channel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
} else {
|
||||
channel = InventoryPackets.getOldPluginChannelId(channel);
|
||||
}
|
||||
if (channel == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
if (!oldChannel.equals(channel)) {
|
||||
iterator.remove();
|
||||
newChannels.add(channel);
|
||||
}
|
||||
}
|
||||
registeredChannels.addAll(newChannels);
|
||||
}
|
||||
PluginMessage brandMessage = (PluginMessage) getBrandMessage.invoke(e.getPlayer().getPendingConnection());
|
||||
if (brandMessage != null) {
|
||||
String channel = brandMessage.getTag();
|
||||
if (toNewId) {
|
||||
channel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
} else {
|
||||
channel = InventoryPackets.getOldPluginChannelId(channel);
|
||||
}
|
||||
if (channel != null) {
|
||||
brandMessage.setTag(channel);
|
||||
}
|
||||
}
|
||||
if (channel == null) {
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
|
||||
user.put(storage);
|
||||
|
||||
user.setActive(protocolPath != null);
|
||||
|
||||
// Init all protocols TODO check if this can get moved up to the previous for loop, and doesn't require the pipeline to already exist.
|
||||
for (Protocol protocol : pipeline.pipes()) {
|
||||
protocol.init(user);
|
||||
if (!oldChannel.equals(channel)) {
|
||||
iterator.remove();
|
||||
newChannels.add(channel);
|
||||
}
|
||||
}
|
||||
registeredChannels.addAll(newChannels);
|
||||
}
|
||||
|
||||
EntityTracker1_9 newTracker = user.getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (newTracker != null) {
|
||||
if (Via.getConfig().isAutoTeam()) {
|
||||
String currentTeam = null;
|
||||
for (Team team : player.getScoreboard().getTeams()) {
|
||||
if (team.getPlayers().contains(info.getUsername())) {
|
||||
currentTeam = team.getName();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
// Reinitialize auto-team
|
||||
newTracker.setAutoTeam(true);
|
||||
if (currentTeam == null) {
|
||||
// Send auto-team as it was cleared above
|
||||
newTracker.sendTeamPacket(true, true);
|
||||
newTracker.setCurrentTeam("viaversion");
|
||||
} else {
|
||||
// Auto-team will be sent when bungee send remove packet
|
||||
newTracker.setAutoTeam(Via.getConfig().isAutoTeam());
|
||||
newTracker.setCurrentTeam(currentTeam);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Object wrapper = channelWrapper.get(player);
|
||||
setVersion.invoke(wrapper, protocolId);
|
||||
|
||||
Object entityMap = getEntityMap.invoke(null, protocolId);
|
||||
entityRewrite.set(player, entityMap);
|
||||
PluginMessage brandMessage = (PluginMessage) getBrandMessage.invoke(event.getPlayer().getPendingConnection());
|
||||
if (brandMessage != null) {
|
||||
String channel = brandMessage.getTag();
|
||||
if (toNewId) {
|
||||
channel = InventoryPackets.getNewPluginChannelId(channel);
|
||||
} else {
|
||||
channel = InventoryPackets.getOldPluginChannelId(channel);
|
||||
}
|
||||
if (channel != null) {
|
||||
brandMessage.setTag(channel);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
user.put(storage);
|
||||
|
||||
user.setActive(protocolPath != null);
|
||||
|
||||
// Init all protocols TODO check if this can get moved up to the previous for loop, and doesn't require the pipeline to already exist.
|
||||
for (Protocol protocol : pipeline.pipes()) {
|
||||
protocol.init(user);
|
||||
}
|
||||
|
||||
ProxiedPlayer player = storage.getPlayer();
|
||||
EntityTracker1_9 newTracker = user.getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (newTracker != null && Via.getConfig().isAutoTeam()) {
|
||||
String currentTeam = null;
|
||||
for (Team team : player.getScoreboard().getTeams()) {
|
||||
if (team.getPlayers().contains(info.getUsername())) {
|
||||
currentTeam = team.getName();
|
||||
}
|
||||
}
|
||||
|
||||
// Reinitialize auto-team
|
||||
newTracker.setAutoTeam(true);
|
||||
if (currentTeam == null) {
|
||||
// Send auto-team as it was cleared above
|
||||
newTracker.sendTeamPacket(true, true);
|
||||
newTracker.setCurrentTeam("viaversion");
|
||||
} else {
|
||||
// Auto-team will be sent when bungee send remove packet
|
||||
newTracker.setAutoTeam(Via.getConfig().isAutoTeam());
|
||||
newTracker.setCurrentTeam(currentTeam);
|
||||
}
|
||||
}
|
||||
|
||||
Object wrapper = channelWrapper.get(player);
|
||||
setVersion.invoke(wrapper, protocolId);
|
||||
|
||||
Object entityMap = getEntityMap.invoke(null, protocolId);
|
||||
entityRewrite.set(player, entityMap);
|
||||
}
|
||||
}
|
||||
|
@ -27,21 +27,17 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class BungeePipelineUtil {
|
||||
private static Method DECODE_METHOD;
|
||||
private static Method ENCODE_METHOD;
|
||||
private static final Method DECODE_METHOD;
|
||||
private static final Method ENCODE_METHOD;
|
||||
|
||||
static {
|
||||
try {
|
||||
DECODE_METHOD = MessageToMessageDecoder.class.getDeclaredMethod("decode", ChannelHandlerContext.class, Object.class, List.class);
|
||||
DECODE_METHOD.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
ENCODE_METHOD = MessageToByteEncoder.class.getDeclaredMethod("encode", ChannelHandlerContext.class, Object.class, ByteBuf.class);
|
||||
ENCODE_METHOD.setAccessible(true);
|
||||
} catch (NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -32,7 +32,7 @@ public abstract class ViaListener {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the UserConnection from an UUID
|
||||
* Get the UserConnection from a UUID
|
||||
*
|
||||
* @param uuid UUID object
|
||||
* @return The UserConnection
|
||||
|
@ -47,7 +47,7 @@ public class ProtocolInfoImpl implements ProtocolInfo {
|
||||
@Override
|
||||
public void setClientState(final State clientState) {
|
||||
if (Via.getManager().debugHandler().enabled()) {
|
||||
Via.getPlatform().getLogger().info("Client state changed from " + this.clientState + " to " + clientState + " for " + connection.getProtocolInfo().getUuid());
|
||||
Via.getPlatform().getLogger().info("Client state changed from " + this.clientState + " to " + clientState + " for " + uuid);
|
||||
}
|
||||
this.clientState = clientState;
|
||||
}
|
||||
@ -60,7 +60,7 @@ public class ProtocolInfoImpl implements ProtocolInfo {
|
||||
@Override
|
||||
public void setServerState(final State serverState) {
|
||||
if (Via.getManager().debugHandler().enabled()) {
|
||||
Via.getPlatform().getLogger().info("Server state changed from " + this.serverState + " to " + serverState + " for " + connection.getProtocolInfo().getUuid());
|
||||
Via.getPlatform().getLogger().info("Server state changed from " + this.serverState + " to " + serverState + " for " + uuid);
|
||||
}
|
||||
this.serverState = serverState;
|
||||
}
|
||||
|
@ -372,7 +372,9 @@ public class PacketWrapperImpl implements PacketWrapper {
|
||||
}
|
||||
|
||||
private void sendRaw(boolean currentThread) throws Exception {
|
||||
if (isCancelled()) return;
|
||||
if (isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
ByteBuf output = inputBuffer == null ? user().getChannel().alloc().buffer() : inputBuffer.alloc().buffer();
|
||||
try {
|
||||
|
@ -40,7 +40,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
||||
if (item == null) return null;
|
||||
boolean newItem = item.identifier() >= 213 && item.identifier() <= 217;
|
||||
if (newItem) { // Replace server-side unknown items
|
||||
item.setIdentifier((short) 1);
|
||||
item.setIdentifier(1);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
return item;
|
||||
|
@ -40,7 +40,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
||||
if (item == null) return null;
|
||||
boolean newItem = item.identifier() == 452;
|
||||
if (newItem) { // Replace server-side unknown items
|
||||
item.setIdentifier((short) 1);
|
||||
item.setIdentifier(1);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
return null;
|
||||
|
@ -83,7 +83,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
||||
boolean newItem = item.identifier() >= 218 && item.identifier() <= 234;
|
||||
newItem |= item.identifier() == 449 || item.identifier() == 450;
|
||||
if (newItem) { // Replace server-side unknown items
|
||||
item.setIdentifier((short) 1);
|
||||
item.setIdentifier(1);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
return item;
|
||||
|
@ -122,7 +122,7 @@ public class InventoryPackets extends ItemRewriter<ClientboundPackets1_9_3, Serv
|
||||
boolean newItem = item.identifier() >= 235 && item.identifier() <= 252;
|
||||
newItem |= item.identifier() == 453;
|
||||
if (newItem) { // Replace server-side unknown items
|
||||
item.setIdentifier((short) 1);
|
||||
item.setIdentifier(1);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
return item;
|
||||
|
@ -18,17 +18,17 @@
|
||||
package com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.packets;
|
||||
|
||||
import com.viaversion.viaversion.api.minecraft.metadata.Metadata;
|
||||
import com.viaversion.viaversion.api.protocol.Protocol;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandler;
|
||||
import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13;
|
||||
import com.viaversion.viaversion.api.type.types.version.Types1_13_2;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13_2to1_13_1.Protocol1_13_2To1_13_1;
|
||||
import com.viaversion.viaversion.protocols.protocol1_13to1_12_2.ClientboundPackets1_13;
|
||||
|
||||
public class EntityPackets {
|
||||
|
||||
public static void register(Protocol protocol) {
|
||||
public static void register(Protocol1_13_2To1_13_1 protocol) {
|
||||
final PacketHandler metaTypeHandler = wrapper -> {
|
||||
for (Metadata metadata : wrapper.get(Types1_13_2.METADATA_LIST, 0)) {
|
||||
metadata.setMetaType(Types1_13_2.META_TYPES.byId(metadata.metaType().typeId()));
|
||||
|
@ -26,10 +26,8 @@ public class TabCompleteThread implements Runnable {
|
||||
public void run() {
|
||||
for (UserConnection info : Via.getManager().getConnectionManager().getConnections()) {
|
||||
if (info.getProtocolInfo() == null) continue;
|
||||
if (info.getProtocolInfo().getPipeline().contains(Protocol1_13To1_12_2.class)) {
|
||||
if (info.getChannel().isOpen()) {
|
||||
info.get(TabCompleteTracker.class).sendPacketToServer(info);
|
||||
}
|
||||
if (info.getProtocolInfo().getPipeline().contains(Protocol1_13To1_12_2.class) && info.getChannel().isOpen()) {
|
||||
info.get(TabCompleteTracker.class).sendPacketToServer(info);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -77,7 +77,7 @@ public class SpawnEggRewriter {
|
||||
spawnEggs.put(key, spawnEggs.size());
|
||||
}
|
||||
|
||||
// Make it a non existing block id
|
||||
// Make it a non-existing block id
|
||||
public static int getSpawnEggId(String entityIdentifier) {
|
||||
// Fallback to bat
|
||||
if (!spawnEggs.containsKey(entityIdentifier))
|
||||
|
@ -88,7 +88,9 @@ public class BlockEntityProvider implements Provider {
|
||||
wrapper.send(Protocol1_13To1_12_2.class);
|
||||
}
|
||||
|
||||
@FunctionalInterface
|
||||
public interface BlockEntityHandler {
|
||||
|
||||
int transform(UserConnection user, CompoundTag tag);
|
||||
}
|
||||
}
|
||||
|
@ -30,7 +30,8 @@ public class EntityTracker1_14 extends EntityTrackerBase {
|
||||
private final Int2ObjectMap<Byte> playerEntityFlags = Int2ObjectSyncMap.hashmap();
|
||||
private int latestTradeWindowId;
|
||||
private boolean forceSendCenterChunk = true;
|
||||
private int chunkCenterX, chunkCenterZ;
|
||||
private int chunkCenterX;
|
||||
private int chunkCenterZ;
|
||||
|
||||
public EntityTracker1_14(UserConnection user) {
|
||||
super(user, Entity1_14Types.PLAYER);
|
||||
|
@ -207,7 +207,7 @@ public class ItemRewriter {
|
||||
newItem |= item.identifier() == 397 && item.data() == 5;
|
||||
newItem |= item.identifier() >= 432 && item.identifier() <= 448;
|
||||
if (newItem) { // Replace server-side unknown items
|
||||
item.setIdentifier((short) 1);
|
||||
item.setIdentifier(1);
|
||||
item.setData((short) 0);
|
||||
}
|
||||
}
|
||||
|
@ -93,9 +93,9 @@ public class EntityPackets {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // 0 - Entity ID
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 1 - X - Needs to be divide by 32
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 2 - Y - Needs to be divide by 32
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 3 - Z - Needs to be divide by 32
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 1 - X - Needs to be divided by 32
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 2 - Y - Needs to be divided by 32
|
||||
map(Type.INT, SpawnPackets.toNewDouble); // 3 - Z - Needs to be divided by 32
|
||||
|
||||
map(Type.BYTE); // 4 - Pitch
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
@ -176,12 +176,11 @@ public class EntityPackets {
|
||||
int entityID = wrapper.get(Type.VAR_INT, 0);
|
||||
Item stack = wrapper.get(Type.ITEM, 0);
|
||||
|
||||
if (stack != null) {
|
||||
if (Protocol1_9To1_8.isSword(stack.identifier())) {
|
||||
entityTracker.getValidBlocking().add(entityID);
|
||||
return;
|
||||
}
|
||||
if (stack != null && Protocol1_9To1_8.isSword(stack.identifier())) {
|
||||
entityTracker.getValidBlocking().add(entityID);
|
||||
return;
|
||||
}
|
||||
|
||||
entityTracker.getValidBlocking().remove(entityID);
|
||||
});
|
||||
}
|
||||
@ -234,7 +233,7 @@ public class EntityPackets {
|
||||
handler(wrapper -> {
|
||||
boolean showParticles = wrapper.read(Type.BOOLEAN); //In 1.8 = true->Show particles : false->Hide particles
|
||||
boolean newEffect = Via.getConfig().isNewEffectIndicator();
|
||||
//0: hide, 1: shown without indictator, 2: shown with indicator, 3: hide with beacon indicator but we don't use it.
|
||||
//0: hide, 1: shown without indictator, 2: shown with indicator, 3: hide with beacon indicator, but we don't use it.
|
||||
wrapper.write(Type.BYTE, (byte) (showParticles ? newEffect ? 2 : 1 : 0));
|
||||
});
|
||||
}
|
||||
|
@ -47,21 +47,19 @@ public class InventoryPackets {
|
||||
final short property = wrapper.get(Type.SHORT, 0);
|
||||
short value = wrapper.get(Type.SHORT, 1);
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
if (inventoryTracker.getInventory() != null) {
|
||||
if (inventoryTracker.getInventory().equalsIgnoreCase("minecraft:enchanting_table")) {
|
||||
if (property > 3 && property < 7) {
|
||||
// Send 2 properties, splitting it into enchantID & level
|
||||
final short level = (short) (value >> 8);
|
||||
final short enchantID = (short) (value & 0xFF);
|
||||
wrapper.create(wrapper.getId(), propertyPacket -> {
|
||||
propertyPacket.write(Type.UNSIGNED_BYTE, windowId);
|
||||
propertyPacket.write(Type.SHORT, property);
|
||||
propertyPacket.write(Type.SHORT, enchantID);
|
||||
}).scheduleSend(Protocol1_9To1_8.class);
|
||||
if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equalsIgnoreCase("minecraft:enchanting_table")) {
|
||||
if (property > 3 && property < 7) {
|
||||
// Send 2 properties, splitting it into enchantID & level
|
||||
final short level = (short) (value >> 8);
|
||||
final short enchantID = (short) (value & 0xFF);
|
||||
wrapper.create(wrapper.getId(), propertyPacket -> {
|
||||
propertyPacket.write(Type.UNSIGNED_BYTE, windowId);
|
||||
propertyPacket.write(Type.SHORT, property);
|
||||
propertyPacket.write(Type.SHORT, enchantID);
|
||||
}).scheduleSend(Protocol1_9To1_8.class);
|
||||
|
||||
wrapper.set(Type.SHORT, 0, (short) (property + 3));
|
||||
wrapper.set(Type.SHORT, 1, level);
|
||||
}
|
||||
wrapper.set(Type.SHORT, 0, (short) (property + 3));
|
||||
wrapper.set(Type.SHORT, 1, level);
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -125,11 +123,9 @@ public class InventoryPackets {
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
|
||||
short slotID = wrapper.get(Type.SHORT, 0);
|
||||
if (inventoryTracker.getInventory() != null) {
|
||||
if (inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
if (slotID >= 4) {
|
||||
wrapper.set(Type.SHORT, 0, (short) (slotID + 1));
|
||||
}
|
||||
if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
if (slotID >= 4) {
|
||||
wrapper.set(Type.SHORT, 0, (short) (slotID + 1));
|
||||
}
|
||||
}
|
||||
});
|
||||
@ -171,21 +167,19 @@ public class InventoryPackets {
|
||||
// Brewing Patch
|
||||
handler(wrapper -> {
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
if (inventoryTracker.getInventory() != null) {
|
||||
if (inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
Item[] oldStack = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
Item[] newStack = new Item[oldStack.length + 1];
|
||||
for (int i = 0; i < newStack.length; i++) {
|
||||
if (i > 4) {
|
||||
newStack[i] = oldStack[i - 1];
|
||||
} else {
|
||||
if (i != 4) { // Leave index 3 blank
|
||||
newStack[i] = oldStack[i];
|
||||
}
|
||||
if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
Item[] oldStack = wrapper.get(Type.ITEM_ARRAY, 0);
|
||||
Item[] newStack = new Item[oldStack.length + 1];
|
||||
for (int i = 0; i < newStack.length; i++) {
|
||||
if (i > 4) {
|
||||
newStack[i] = oldStack[i - 1];
|
||||
} else {
|
||||
if (i != 4) { // Leave index 3 blank
|
||||
newStack[i] = oldStack[i];
|
||||
}
|
||||
}
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, newStack);
|
||||
}
|
||||
wrapper.set(Type.ITEM_ARRAY, 0, newStack);
|
||||
}
|
||||
});
|
||||
}
|
||||
@ -298,14 +292,12 @@ public class InventoryPackets {
|
||||
final short slot = wrapper.get(Type.SHORT, 0);
|
||||
boolean throwItem = (slot == 45 && windowID == 0);
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
if (inventoryTracker.getInventory() != null) {
|
||||
if (inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
if (slot == 4) {
|
||||
throwItem = true;
|
||||
}
|
||||
if (slot > 4) {
|
||||
wrapper.set(Type.SHORT, 0, (short) (slot - 1));
|
||||
}
|
||||
if (inventoryTracker.getInventory() != null && inventoryTracker.getInventory().equals("minecraft:brewing_stand")) {
|
||||
if (slot == 4) {
|
||||
throwItem = true;
|
||||
}
|
||||
if (slot > 4) {
|
||||
wrapper.set(Type.SHORT, 0, (short) (slot - 1));
|
||||
}
|
||||
}
|
||||
|
||||
@ -328,49 +320,53 @@ public class InventoryPackets {
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new PacketHandlers() {
|
||||
protocol.registerServerbound(ServerboundPackets1_9.CLOSE_WINDOW, new
|
||||
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
PacketHandlers() {
|
||||
|
||||
// Inventory tracking
|
||||
handler(wrapper -> {
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
inventoryTracker.setInventory(null);
|
||||
inventoryTracker.resetInventory(wrapper.get(Type.UNSIGNED_BYTE, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.UNSIGNED_BYTE); // 0 - Window ID
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // 0 - Slot id
|
||||
|
||||
// Blocking patch
|
||||
handler(wrapper -> {
|
||||
boolean showShieldWhenSwordInHand = Via.getConfig().isShowShieldWhenSwordInHand()
|
||||
&& Via.getConfig().isShieldBlocking();
|
||||
|
||||
EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (entityTracker.isBlocking()) {
|
||||
entityTracker.setBlocking(false);
|
||||
|
||||
if (!showShieldWhenSwordInHand) {
|
||||
entityTracker.setSecondHand(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (showShieldWhenSwordInHand) {
|
||||
// Update current held item slot index
|
||||
entityTracker.setHeldItemSlot(wrapper.get(Type.SHORT, 0));
|
||||
|
||||
// Sync shield item in offhand with main hand
|
||||
entityTracker.syncShieldWithSword();
|
||||
// Inventory tracking
|
||||
handler(wrapper -> {
|
||||
InventoryTracker inventoryTracker = wrapper.user().get(InventoryTracker.class);
|
||||
inventoryTracker.setInventory(null);
|
||||
inventoryTracker.resetInventory(wrapper.get(Type.UNSIGNED_BYTE, 0));
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
protocol.registerServerbound(ServerboundPackets1_9.HELD_ITEM_CHANGE, new
|
||||
|
||||
PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.SHORT); // 0 - Slot id
|
||||
|
||||
// Blocking patch
|
||||
handler(wrapper -> {
|
||||
boolean showShieldWhenSwordInHand = Via.getConfig().isShowShieldWhenSwordInHand()
|
||||
&& Via.getConfig().isShieldBlocking();
|
||||
|
||||
EntityTracker1_9 entityTracker = wrapper.user().getEntityTracker(Protocol1_9To1_8.class);
|
||||
if (entityTracker.isBlocking()) {
|
||||
entityTracker.setBlocking(false);
|
||||
|
||||
if (!showShieldWhenSwordInHand) {
|
||||
entityTracker.setSecondHand(null);
|
||||
}
|
||||
}
|
||||
|
||||
if (showShieldWhenSwordInHand) {
|
||||
// Update current held item slot index
|
||||
entityTracker.setHeldItemSlot(wrapper.get(Type.SHORT, 0));
|
||||
|
||||
// Sync shield item in offhand with main hand
|
||||
entityTracker.syncShieldWithSword();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
@ -195,7 +195,7 @@ public class PlayerPackets {
|
||||
clientWorld.setEnvironment(dimensionId);
|
||||
});
|
||||
|
||||
// Gotta fake their op
|
||||
// Fake their op status
|
||||
handler(wrapper -> {
|
||||
CommandBlockProvider provider = Via.getManager().getProviders().get(CommandBlockProvider.class);
|
||||
provider.sendPermission(wrapper.user());
|
||||
@ -381,11 +381,9 @@ public class PlayerPackets {
|
||||
handler(wrapper -> {
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
|
||||
if (Via.getConfig().isLeftHandedHandling()) {
|
||||
// Add 0x80 if left handed
|
||||
if (hand == 0) wrapper.set(Type.UNSIGNED_BYTE, 0,
|
||||
(short) (wrapper.get(Type.UNSIGNED_BYTE, 0).intValue() | 0x80)
|
||||
);
|
||||
// Add 0x80 if left-handed
|
||||
if (Via.getConfig().isLeftHandedHandling() && hand == 0) {
|
||||
wrapper.set(Type.UNSIGNED_BYTE, 0, (short) (wrapper.get(Type.UNSIGNED_BYTE, 0).intValue() | 0x80));
|
||||
}
|
||||
wrapper.sendToServer(Protocol1_9To1_8.class);
|
||||
wrapper.cancel();
|
||||
|
@ -69,9 +69,9 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divided by 32
|
||||
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
map(Type.BYTE); // 7 - Yaw
|
||||
@ -82,7 +82,9 @@ public class SpawnPackets {
|
||||
handler(wrapper -> {
|
||||
int data = wrapper.get(Type.INT, 0); // Data (1st Integer)
|
||||
|
||||
short vX = 0, vY = 0, vZ = 0;
|
||||
short vX = 0;
|
||||
short vY = 0;
|
||||
short vZ = 0;
|
||||
if (data > 0) {
|
||||
vX = wrapper.read(Type.SHORT);
|
||||
vY = wrapper.read(Type.SHORT);
|
||||
@ -134,9 +136,9 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 1 - X - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 2 - Y - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Z - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 1 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 2 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Z - Needs to be divided by 32
|
||||
|
||||
map(Type.SHORT); // 4 - Amount to spawn
|
||||
}
|
||||
@ -156,9 +158,9 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divided by 32
|
||||
}
|
||||
});
|
||||
|
||||
@ -183,9 +185,9 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 3 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 5 - Z - Needs to be divided by 32
|
||||
|
||||
map(Type.BYTE); // 6 - Yaw
|
||||
map(Type.BYTE); // 7 - Pitch
|
||||
@ -255,9 +257,9 @@ public class SpawnPackets {
|
||||
tracker.sendMetadataBuffer(entityID);
|
||||
});
|
||||
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divide by 32
|
||||
map(Type.INT, toNewDouble); // 2 - X - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 3 - Y - Needs to be divided by 32
|
||||
map(Type.INT, toNewDouble); // 4 - Z - Needs to be divided by 32
|
||||
|
||||
map(Type.BYTE); // 5 - Yaw
|
||||
map(Type.BYTE); // 6 - Pitch
|
||||
|
@ -32,8 +32,8 @@ import com.viaversion.viaversion.api.protocol.remapper.PacketHandlers;
|
||||
import com.viaversion.viaversion.api.type.Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ClientboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_8.ServerboundPackets1_8;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_1to1_9.types.Chunk1_9_1_2Type;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9_3to1_9_1_2.storage.ClientWorld;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ClientboundPackets1_9;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.ItemRewriter;
|
||||
import com.viaversion.viaversion.protocols.protocol1_9to1_8.Protocol1_9To1_8;
|
||||
@ -92,7 +92,7 @@ public class WorldPackets {
|
||||
public void register() {
|
||||
map(Type.STRING); // 0 - Sound Name
|
||||
// 1 - Sound Category ID
|
||||
// Everything else get's written through
|
||||
// Everything else gets written through
|
||||
|
||||
handler(wrapper -> {
|
||||
String name = wrapper.get(Type.STRING, 0);
|
||||
@ -298,17 +298,15 @@ public class WorldPackets {
|
||||
: item != null && Protocol1_9To1_8.isSword(item.identifier());
|
||||
|
||||
if (isSword) {
|
||||
if (hand == 0) {
|
||||
if (!tracker.isBlocking()) {
|
||||
tracker.setBlocking(true);
|
||||
if (hand == 0 && !tracker.isBlocking()) {
|
||||
tracker.setBlocking(true);
|
||||
|
||||
// Check if the shield is already in the offhand
|
||||
if (!showShieldWhenSwordInHand && tracker.getItemInSecondHand() == null) {
|
||||
// Check if the shield is already in the offhand
|
||||
if (!showShieldWhenSwordInHand && tracker.getItemInSecondHand() == null) {
|
||||
|
||||
// Set shield in offhand when interacting with main hand
|
||||
Item shield = new DataItem(442, (byte) 1, (short) 0, null);
|
||||
tracker.setSecondHand(shield);
|
||||
}
|
||||
// Set shield in offhand when interacting with main hand
|
||||
Item shield = new DataItem(442, (byte) 1, (short) 0, null);
|
||||
tracker.setSecondHand(shield);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class CommandBlockStorage implements StorableObject {
|
||||
private final Map<Pair<Integer, Integer>, Map<Position, CompoundTag>> storedCommandBlocks = new ConcurrentHashMap<>();
|
||||
private boolean permissions = false;
|
||||
private boolean permissions;
|
||||
|
||||
public void unloadChunk(int x, int z) {
|
||||
Pair<Integer, Integer> chunkPos = new Pair<>(x, z);
|
||||
@ -38,14 +38,15 @@ public class CommandBlockStorage implements StorableObject {
|
||||
public void addOrUpdateBlock(Position position, CompoundTag tag) {
|
||||
Pair<Integer, Integer> chunkPos = getChunkCoords(position);
|
||||
|
||||
if (!storedCommandBlocks.containsKey(chunkPos))
|
||||
if (!storedCommandBlocks.containsKey(chunkPos)) {
|
||||
storedCommandBlocks.put(chunkPos, new ConcurrentHashMap<>());
|
||||
}
|
||||
|
||||
Map<Position, CompoundTag> blocks = storedCommandBlocks.get(chunkPos);
|
||||
|
||||
if (blocks.containsKey(position))
|
||||
if (blocks.get(position).equals(tag))
|
||||
return;
|
||||
if (blocks.containsKey(position) && blocks.get(position).equals(tag)) {
|
||||
return;
|
||||
}
|
||||
|
||||
blocks.put(position, tag);
|
||||
}
|
||||
|
@ -117,7 +117,7 @@ public class EntityTracker1_9 extends EntityTrackerBase {
|
||||
// Update if there is no sword in the main hand or if the player has no shield in the second hand but a sword in the main hand
|
||||
if (!swordInHand || this.itemInSecondHand == null) {
|
||||
|
||||
// Update shield in off hand depending if a sword is in the main hand
|
||||
// Update shield in off-hand depending on whether a sword is in the main hand
|
||||
setSecondHand(swordInHand ? new DataItem(442, (byte) 1, (short) 0, null) : null);
|
||||
}
|
||||
}
|
||||
|
@ -22,8 +22,8 @@ import com.viaversion.viaversion.api.connection.StorableObject;
|
||||
public class MovementTracker implements StorableObject {
|
||||
private static final long IDLE_PACKET_DELAY = 50L; // Update every 50ms (20tps)
|
||||
private static final long IDLE_PACKET_LIMIT = 20; // Max 20 ticks behind
|
||||
private long nextIdlePacket = 0L;
|
||||
private boolean ground = false;
|
||||
private long nextIdlePacket;
|
||||
private boolean ground;
|
||||
|
||||
public void incrementIdlePacket() {
|
||||
// Notify of next update
|
||||
|
@ -41,7 +41,7 @@ public class SoundRewriter<C extends ClientboundPacketType> {
|
||||
protocol.registerClientbound(packetType, new PacketHandlers() {
|
||||
@Override
|
||||
public void register() {
|
||||
map(Type.VAR_INT); // Sound Id
|
||||
map(Type.VAR_INT); // Sound id
|
||||
handler(getSoundHandler());
|
||||
}
|
||||
});
|
||||
|
@ -111,7 +111,7 @@ public class Version implements Comparable<Version> {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the tag, eg. -ALPHA
|
||||
* Get the tag, e.g. -ALPHA
|
||||
*
|
||||
* @return The version tag
|
||||
*/
|
||||
|
@ -26,7 +26,7 @@ block-disconnect-msg: "You are using an unsupported Minecraft version!"
|
||||
# (We don't suggest using reload either, use a plugin manager)
|
||||
# You can customise the message we kick people with if you use ProtocolLib here.
|
||||
reload-disconnect-msg: "Server reload, please rejoin!"
|
||||
# We warn when there's a error converting item and block data over versions, should we suppress these? (Only suggested if spamming)
|
||||
# We warn when there's an error converting item and block data over versions, should we suppress these? (Only suggested if spamming)
|
||||
suppress-conversion-warnings: false
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
@ -41,7 +41,7 @@ suppress-conversion-warnings: false
|
||||
bungee-ping-interval: 60
|
||||
# If the above is enabled, should we save the info to the config (in the section below)
|
||||
bungee-ping-save: true
|
||||
# To get a servers protocol, ViaVersion will do the following:
|
||||
# To get a server's protocol, ViaVersion will do the following:
|
||||
# Look for the server in the following section, then look for the last ping if bungee-ping is enabled
|
||||
# otherwise use default.
|
||||
#
|
||||
@ -63,14 +63,14 @@ bungee-servers: {}
|
||||
velocity-ping-interval: 60
|
||||
# If the above is enabled, should we save the info to the config (in the section below)
|
||||
velocity-ping-save: true
|
||||
# To get a servers protocol, ViaVersion will do the following:
|
||||
# To get a server's protocol, ViaVersion will do the following:
|
||||
# Look for the server in the following section, then look for the last ping if velocity-ping is enabled
|
||||
# otherwise use default.
|
||||
#
|
||||
# The format for the following is:
|
||||
# servername: protocolversion
|
||||
# You can find protocol ids on https://wiki.vg/Protocol_version_numbers
|
||||
# It will fallback to the default option if none found.
|
||||
# It will fall back to the default option if none found.
|
||||
velocity-servers: {}
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
@ -135,14 +135,14 @@ change-1_9-hitbox: false
|
||||
# WARNING: This gives 1.14+ players the ability to sneak under blocks, that players under that version cannot (sneaking in places that are only 1.5 blocks high)!
|
||||
# Another thing to remember is that those players might be missed by projectiles and other hits directed at the very top of their head whilst sneaking.
|
||||
change-1_14-hitbox: false
|
||||
# Fixes 1.14+ clients on sub 1.14 servers having a light value of 0 for non full blocks.
|
||||
# Fixes 1.14+ clients on sub 1.14 servers having a light value of 0 for non-full blocks.
|
||||
fix-non-full-blocklight: true
|
||||
# Fixes walk animation not shown when health is set to Float.NaN
|
||||
fix-1_14-health-nan: true
|
||||
# Should 1.15+ clients respawn instantly / without showing a death screen?
|
||||
use-1_15-instant-respawn: false
|
||||
#
|
||||
# Enable serverside block-connections for 1.13+ clients - all of the options in this section are built around this option
|
||||
# Enable serverside block-connections for 1.13+ clients - all the options in this section are built around this option
|
||||
serverside-blockconnections: true
|
||||
# Sets the method for the block connections (world for highly experimental (USE AT OWN RISK) world-level or packet for packet-level)
|
||||
blockconnection-method: packet
|
||||
@ -191,7 +191,7 @@ auto-team: true
|
||||
suppress-metadata-errors: false
|
||||
# When enabled 1.9+ will be able to block by using shields
|
||||
shield-blocking: true
|
||||
# If this setting is active, the main hand is used instead of the off hand to trigger the blocking of the player.
|
||||
# If this setting is active, the main hand is used instead of the off-hand to trigger the blocking of the player.
|
||||
# With the main hand the blocking starts way faster.
|
||||
# (Requires "show-shield-when-sword-in-hand" to be disabled)
|
||||
no-delay-shield-blocking: false
|
||||
|
@ -1,4 +1,3 @@
|
||||
// Data from https://minecraft.gamepedia.com/1.13/Flattening
|
||||
{
|
||||
"wooden_slab": [
|
||||
"oak_slab",
|
||||
|
@ -221,7 +221,7 @@ public class VelocityPlugin implements ViaServerProxyPlatform<Player> {
|
||||
true,
|
||||
p.getDescription().getName().orElse(p.getDescription().getId()),
|
||||
p.getDescription().getVersion().orElse("Unknown Version"),
|
||||
p.getInstance().isPresent() ? p.getInstance().get().getClass().getCanonicalName() : "Unknown",
|
||||
p.getInstance().map(instance -> instance.getClass().getCanonicalName()).orElse("Unknown"),
|
||||
p.getDescription().getAuthors()
|
||||
));
|
||||
}
|
||||
|
@ -70,12 +70,10 @@ public class VelocityDecodeHandler extends MessageToMessageDecoder<ByteBuf> {
|
||||
// Move Via codec handlers back to right position
|
||||
ChannelPipeline pipeline = ctx.pipeline();
|
||||
|
||||
ChannelHandler encoder = pipeline.get(VelocityChannelInitializer.VIA_ENCODER);
|
||||
pipeline.remove(encoder);
|
||||
ChannelHandler encoder = pipeline.remove(VelocityChannelInitializer.VIA_ENCODER);
|
||||
pipeline.addBefore(VelocityChannelInitializer.MINECRAFT_ENCODER, VelocityChannelInitializer.VIA_ENCODER, encoder);
|
||||
|
||||
ChannelHandler decoder = pipeline.get(VelocityChannelInitializer.VIA_DECODER);
|
||||
pipeline.remove(decoder);
|
||||
ChannelHandler decoder = pipeline.remove(VelocityChannelInitializer.VIA_DECODER);
|
||||
pipeline.addBefore(VelocityChannelInitializer.MINECRAFT_DECODER, VelocityChannelInitializer.VIA_DECODER, decoder);
|
||||
|
||||
super.userEventTriggered(ctx, event);
|
||||
|
Loading…
Reference in New Issue
Block a user