Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c9e1360951 | ||
|
|
c11ad7930f | ||
|
|
7b36a9de51 | ||
|
|
d5e9170109 | ||
|
|
47b447f195 | ||
|
|
e2d27df1a8 | ||
|
|
9a781d940f | ||
|
|
fed36c9487 |
No files matched your search
@@ -1,4 +1,4 @@
|
||||
# ViaVersion 0.6.0
|
||||
# ViaVersion 0.6.2
|
||||
[](https://travis-ci.org/MylesIsCool/ViaVersion)
|
||||
**Allows the connection of 1.9 clients to 1.8**
|
||||
|
||||
@@ -40,6 +40,8 @@ Contributors:
|
||||
|
||||
**fillefilip8**
|
||||
|
||||
**lenis0012**
|
||||
|
||||
|
||||
|
||||
Releases / Dev Builds:
|
||||
@@ -55,6 +57,9 @@ You can find unofficial dev builds here:
|
||||
|
||||
**fillefilip8's Build Server:** http://build.fillecraft.com:8080/job/ViaVersion
|
||||
|
||||
**sgdc3's Build Server:** http://ci.xephi.fr/job/ViaVersion/
|
||||
**sgdc3's Maven:** http://ci.xephi.fr/plugin/repository/everything/
|
||||
|
||||
License:
|
||||
--------
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion</artifactId>
|
||||
<version>0.6.1-SNAPSHOT</version>
|
||||
<version>0.6.3-SNAPSHOT</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ViaVersion</name>
|
||||
|
||||
@@ -12,6 +12,9 @@ import us.myles.ViaVersion.packets.State;
|
||||
@Getter
|
||||
@Setter
|
||||
public class ConnectionInfo {
|
||||
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 final SocketChannel channel;
|
||||
private Object lastPacket;
|
||||
private java.util.UUID UUID;
|
||||
@@ -22,6 +25,7 @@ public class ConnectionInfo {
|
||||
private int entityID;
|
||||
private boolean active = true;
|
||||
private String username;
|
||||
private long nextIdlePacket = 0L;
|
||||
|
||||
public ConnectionInfo(SocketChannel socketChannel) {
|
||||
this.channel = socketChannel;
|
||||
@@ -33,6 +37,7 @@ public class ConnectionInfo {
|
||||
|
||||
public void setActive(boolean active) {
|
||||
this.active = active;
|
||||
this.nextIdlePacket = System.currentTimeMillis() + IDLE_PACKET_DELAY; // Update every 50 ticks
|
||||
}
|
||||
|
||||
public void sendRawPacket(final ByteBuf packet, boolean currentThread) {
|
||||
@@ -56,4 +61,10 @@ public class ConnectionInfo {
|
||||
public void closeWindow() {
|
||||
this.openWindow = null;
|
||||
}
|
||||
|
||||
public void incrementIdlePacket() {
|
||||
// Notify of next update
|
||||
// Allow a maximum lag spike of 1 second (20 ticks/updates)
|
||||
this.nextIdlePacket = Math.max(nextIdlePacket + IDLE_PACKET_DELAY, System.currentTimeMillis() - IDLE_PACKET_DELAY * IDLE_PACKET_LIMIT);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,42 @@
|
||||
package us.myles.ViaVersion;
|
||||
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import us.myles.ViaVersion.api.ViaVersion;
|
||||
import us.myles.ViaVersion.util.ReflectionUtil;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public class ViaIdleThread extends BukkitRunnable {
|
||||
private final Map<UUID, ConnectionInfo> portedPlayers;
|
||||
private final Class<?> idlePacketClass;
|
||||
|
||||
public ViaIdleThread(Map<UUID, ConnectionInfo> portedPlayers) {
|
||||
this.portedPlayers = portedPlayers;
|
||||
try {
|
||||
this.idlePacketClass = ReflectionUtil.nms("PacketPlayInFlying");
|
||||
} catch(ClassNotFoundException e) {
|
||||
throw new RuntimeException("Couldn't find player idle packet, help!", e);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
for(ConnectionInfo info : portedPlayers.values()) {
|
||||
long nextIdleUpdate = info.getNextIdlePacket();
|
||||
if(nextIdleUpdate <= System.currentTimeMillis()) {
|
||||
try {
|
||||
Object packet = idlePacketClass.newInstance();
|
||||
info.getChannel().pipeline().fireChannelRead(packet);
|
||||
} catch(InstantiationException | IllegalAccessException e) {
|
||||
System.out.println("Failed to create idle packet.");
|
||||
if(ViaVersion.getInstance().isDebug()) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} finally {
|
||||
info.incrementIdlePacket();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -73,6 +73,8 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
|
||||
getLogger().info("ViaVersion " + getDescription().getVersion() + " is now enabled, injecting. (Allows 1.8 to be accessed via 1.9)");
|
||||
injectPacketHandler();
|
||||
if (getConfig().getBoolean("simulate-pt", true))
|
||||
new ViaIdleThread(portedPlayers).runTaskTimerAsynchronously(this, 1L, 1L); // Updates player's idle status
|
||||
|
||||
if (getConfig().getBoolean("checkforupdates"))
|
||||
UpdateUtil.sendUpdateMessage(this);
|
||||
@@ -119,18 +121,19 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
final Object value = field.get(connection);
|
||||
if (value instanceof List) {
|
||||
// Inject the list
|
||||
field.set(connection, new ListWrapper((List) value) {
|
||||
List wrapper = new ListWrapper((List) value) {
|
||||
@Override
|
||||
public void handleAdd(Object o) {
|
||||
synchronized (value) {
|
||||
public synchronized void handleAdd(Object o) {
|
||||
synchronized (this) {
|
||||
if (o instanceof ChannelFuture) {
|
||||
inject((ChannelFuture) o);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
field.set(connection, wrapper);
|
||||
// Iterate through current list
|
||||
synchronized (value) {
|
||||
synchronized (wrapper) {
|
||||
for (Object o : (List) value) {
|
||||
if (o instanceof ChannelFuture) {
|
||||
inject((ChannelFuture) o);
|
||||
@@ -229,6 +232,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
||||
return getConfig().getBoolean("shield-blocking", true);
|
||||
}
|
||||
|
||||
public boolean isHologramPatch() {
|
||||
return getConfig().getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
public double getHologramYOffset() {
|
||||
return getConfig().getDouble("hologram-y", -1D);
|
||||
}
|
||||
|
||||
public boolean isAutoTeam() {
|
||||
// Collision has to be enabled first
|
||||
if (!isPreventCollision()) return false;
|
||||
|
||||
@@ -43,6 +43,11 @@ public class IncomingTransformer {
|
||||
if (packet == PacketType.PLAY_TP_CONFIRM || packet == PacketType.PLAY_VEHICLE_MOVE_REQUEST) { //TODO handle client-sided horse riding
|
||||
throw new CancelException();
|
||||
}
|
||||
// Handle movement increment
|
||||
// Update idle status (player, position, look, positionandlook)
|
||||
if(packet == PacketType.PLAY_PLAYER || packet == PacketType.PLAY_PLAYER_POSITION_REQUEST || packet == PacketType.PLAY_PLAYER_LOOK_REQUEST || packet == PacketType.PLAY_PLAYER_POSITION_LOOK_REQUEST) {
|
||||
info.incrementIdlePacket();
|
||||
}
|
||||
PacketUtil.writeVarInt(packetID, output);
|
||||
if (packet == PacketType.HANDSHAKE) {
|
||||
int protVer = PacketUtil.readVarInt(input);
|
||||
|
||||
@@ -39,6 +39,7 @@ public class OutgoingTransformer {
|
||||
private final Map<Integer, EntityType> clientEntityTypes = new HashMap<>();
|
||||
private final Map<Integer, Integer> vehicleMap = new HashMap<>();
|
||||
private final Set<Integer> validBlocking = new HashSet<>();
|
||||
private final Set<Integer> knownHolograms = new HashSet<>();
|
||||
private boolean autoTeam = false;
|
||||
|
||||
public OutgoingTransformer(ConnectionInfo info) {
|
||||
@@ -216,13 +217,15 @@ public class OutgoingTransformer {
|
||||
return;
|
||||
}
|
||||
if (packet == PacketType.PLAY_ENTITY_TELEPORT) {
|
||||
// Port this so that it relative moves :P
|
||||
int id = PacketUtil.readVarInt(input);
|
||||
PacketUtil.writeVarInt(id, output);
|
||||
|
||||
int x = input.readInt();
|
||||
output.writeDouble(x / 32D);
|
||||
int y = input.readInt();
|
||||
if(plugin.isHologramPatch() & knownHolograms.contains(id)){
|
||||
y = (int) ((y) + (plugin.getHologramYOffset() * 32D));
|
||||
}
|
||||
output.writeDouble(y / 32D);
|
||||
int z = input.readInt();
|
||||
output.writeDouble(z / 32D);
|
||||
@@ -243,6 +246,9 @@ public class OutgoingTransformer {
|
||||
int x = input.readByte();
|
||||
output.writeShort(x * 128);
|
||||
int y = input.readByte();
|
||||
if(plugin.isHologramPatch() & knownHolograms.contains(id)){
|
||||
y = (int) ((y) + plugin.getHologramYOffset());
|
||||
}
|
||||
output.writeShort(y * 128);
|
||||
int z = input.readByte();
|
||||
output.writeShort(z * 128);
|
||||
@@ -263,12 +269,16 @@ public class OutgoingTransformer {
|
||||
short x = (short) (input.readByte());
|
||||
output.writeShort(x * 128);
|
||||
short y = (short) (input.readByte());
|
||||
if(plugin.isHologramPatch() & knownHolograms.contains(id)){
|
||||
y = (short) (y - 1);
|
||||
}
|
||||
output.writeShort(y * 128);
|
||||
short z = (short) (input.readByte());
|
||||
output.writeShort(z * 128);
|
||||
|
||||
boolean onGround = input.readBoolean();
|
||||
output.writeBoolean(onGround);
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
@@ -372,6 +382,7 @@ public class OutgoingTransformer {
|
||||
int[] toDestroy = PacketUtil.readVarInts(count, input);
|
||||
for (int entityID : toDestroy) {
|
||||
clientEntityTypes.remove(entityID);
|
||||
knownHolograms.remove(entityID);
|
||||
PacketUtil.writeVarInt(entityID, output);
|
||||
}
|
||||
return;
|
||||
@@ -845,6 +856,25 @@ public class OutgoingTransformer {
|
||||
}
|
||||
}
|
||||
}
|
||||
if(type == EntityType.ARMOR_STAND && plugin.isHologramPatch()){
|
||||
if(entry.getOldID() == 0){
|
||||
byte data = (byte) entry.getValue();
|
||||
if((data & 0x20) == 0x20){
|
||||
if(!knownHolograms.contains(entityID)) {
|
||||
knownHolograms.add(entityID);
|
||||
// Send movement
|
||||
ByteBuf buf = info.getChannel().alloc().buffer();
|
||||
PacketUtil.writeVarInt(PacketType.PLAY_ENTITY_RELATIVE_MOVE.getNewPacketID(), buf);
|
||||
PacketUtil.writeVarInt(entityID, buf);
|
||||
buf.writeShort(0);
|
||||
buf.writeShort((short) (128D * (plugin.getHologramYOffset() * 32D)));
|
||||
buf.writeShort(0);
|
||||
buf.writeBoolean(true);
|
||||
info.sendRawPacket(buf, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -15,43 +15,43 @@ public abstract class ListWrapper implements List {
|
||||
public abstract void handleAdd(Object o);
|
||||
|
||||
@Override
|
||||
public int size() {
|
||||
public synchronized int size() {
|
||||
return this.list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty() {
|
||||
public synchronized boolean isEmpty() {
|
||||
return this.list.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean contains(Object o) {
|
||||
public synchronized boolean contains(Object o) {
|
||||
return this.list.contains(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Iterator iterator() {
|
||||
public synchronized Iterator iterator() {
|
||||
return this.list.iterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray() {
|
||||
public synchronized Object[] toArray() {
|
||||
return this.list.toArray();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean add(Object o) {
|
||||
public synchronized boolean add(Object o) {
|
||||
handleAdd(o);
|
||||
return this.list.add(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean remove(Object o) {
|
||||
public synchronized boolean remove(Object o) {
|
||||
return this.list.remove(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(Collection c) {
|
||||
public synchronized boolean addAll(Collection c) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public abstract class ListWrapper implements List {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAll(int index, Collection c) {
|
||||
public synchronized boolean addAll(int index, Collection c) {
|
||||
for (Object o : c) {
|
||||
handleAdd(o);
|
||||
}
|
||||
@@ -67,72 +67,72 @@ public abstract class ListWrapper implements List {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clear() {
|
||||
public synchronized void clear() {
|
||||
this.list.clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object get(int index) {
|
||||
public synchronized Object get(int index) {
|
||||
return this.list.get(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object set(int index, Object element) {
|
||||
public synchronized Object set(int index, Object element) {
|
||||
return this.list.set(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void add(int index, Object element) {
|
||||
public synchronized void add(int index, Object element) {
|
||||
this.list.add(index, element);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object remove(int index) {
|
||||
public synchronized Object remove(int index) {
|
||||
return this.list.remove(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int indexOf(Object o) {
|
||||
public synchronized int indexOf(Object o) {
|
||||
return this.list.indexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int lastIndexOf(Object o) {
|
||||
public synchronized int lastIndexOf(Object o) {
|
||||
return this.list.lastIndexOf(o);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator listIterator() {
|
||||
public synchronized ListIterator listIterator() {
|
||||
return this.list.listIterator();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ListIterator listIterator(int index) {
|
||||
return this.listIterator(index);
|
||||
public synchronized ListIterator listIterator(int index) {
|
||||
return this.list.listIterator(index);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List subList(int fromIndex, int toIndex) {
|
||||
public synchronized List subList(int fromIndex, int toIndex) {
|
||||
return this.list.subList(fromIndex, toIndex);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean retainAll(Collection c) {
|
||||
public synchronized boolean retainAll(Collection c) {
|
||||
return this.list.retainAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeAll(Collection c) {
|
||||
public synchronized boolean removeAll(Collection c) {
|
||||
return this.list.removeAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean containsAll(Collection c) {
|
||||
public synchronized boolean containsAll(Collection c) {
|
||||
return this.list.containsAll(c);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object[] toArray(Object[] a) {
|
||||
public synchronized Object[] toArray(Object[] a) {
|
||||
return this.list.toArray(a);
|
||||
}
|
||||
}
|
||||
@@ -11,4 +11,11 @@ auto-team: true
|
||||
# When enabled if certain metadata can't be read we won't tell you about it
|
||||
suppress-metadata-errors: false
|
||||
# When enabled 1.9 will be able to block by using shields
|
||||
shield-blocking: true
|
||||
shield-blocking: true
|
||||
# Should we enable our hologram patch?
|
||||
# If they're in the wrong place enable this
|
||||
hologram-patch: false
|
||||
# This is the offset, should work as default when enabled.
|
||||
hologram-y: -1
|
||||
# Enable player tick simulation, this fixes eating, drinking, nether portals.
|
||||
simulate-pt: true
|
||||
Reference in new issue
Block a user