Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-26 16:12:42 +01:00
[~] smaller bugfixes]
[~] switched back to jdk 7
Dieser Commit ist enthalten in:
Ursprung
1262847a0e
Commit
1aea00036f
4
pom.xml
4
pom.xml
@ -68,8 +68,8 @@
|
|||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.5.1</version>
|
<version>3.5.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<source>1.8</source>
|
<source>${jdkVersion}</source>
|
||||||
<target>1.8</target>
|
<target>${jdkVersion}</target>
|
||||||
<!--
|
<!--
|
||||||
<testSource>${testJreVersion}</testSource>
|
<testSource>${testJreVersion}</testSource>
|
||||||
<testTarget>${testJreVersion}</testTarget>
|
<testTarget>${testJreVersion}</testTarget>
|
||||||
|
@ -1,5 +1,10 @@
|
|||||||
package org.spacehq.mc.protocol.data.game.chunk;
|
package org.spacehq.mc.protocol.data.game.chunk;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
public class Column {
|
public class Column {
|
||||||
private int x;
|
private int x;
|
||||||
private int z;
|
private int z;
|
||||||
@ -43,26 +48,11 @@ public class Column {
|
|||||||
this.biomeData = biomeData;
|
this.biomeData = biomeData;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX() {
|
|
||||||
return this.x;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getZ() {
|
|
||||||
return this.z;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Chunk[] getChunks() {
|
|
||||||
return this.chunks;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasBiomeData() {
|
public boolean hasBiomeData() {
|
||||||
return this.biomeData != null;
|
return this.biomeData != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte[] getBiomeData() {
|
|
||||||
return this.biomeData;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean hasSkylight() {
|
public boolean hasSkylight() {
|
||||||
return this.skylight;
|
return this.skylight;
|
||||||
}
|
}
|
||||||
|
@ -82,7 +82,12 @@ public class ConnectionInfo {
|
|||||||
|
|
||||||
public void sendRawPacket(final ByteBuf packet) {
|
public void sendRawPacket(final ByteBuf packet) {
|
||||||
final ChannelHandler handler = channel.pipeline().get("encoder");
|
final ChannelHandler handler = channel.pipeline().get("encoder");
|
||||||
channel.eventLoop().submit((Runnable) () -> channel.pipeline().context(handler).writeAndFlush(packet));
|
channel.eventLoop().submit(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
channel.pipeline().context(handler).writeAndFlush(packet);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOpenWindow() {
|
public String getOpenWindow() {
|
||||||
|
@ -31,6 +31,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
import java.util.concurrent.Callable;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.Future;
|
import java.util.concurrent.Future;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
@ -42,11 +43,14 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
|
|
||||||
public static ItemStack getHandItem(final ConnectionInfo info) {
|
public static ItemStack getHandItem(final ConnectionInfo info) {
|
||||||
try {
|
try {
|
||||||
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), () -> {
|
return Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<ItemStack>() {
|
||||||
|
@Override
|
||||||
|
public ItemStack call() throws Exception {
|
||||||
if (info.getPlayer() != null) {
|
if (info.getPlayer() != null) {
|
||||||
return info.getPlayer().getItemInHand();
|
return info.getPlayer().getItemInHand();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
}
|
||||||
}).get(10, TimeUnit.SECONDS);
|
}).get(10, TimeUnit.SECONDS);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
System.out.println("Error fetching hand item ");
|
System.out.println("Error fetching hand item ");
|
||||||
@ -196,9 +200,12 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
|
|
||||||
public void run(final Runnable runnable, boolean wait) {
|
public void run(final Runnable runnable, boolean wait) {
|
||||||
try {
|
try {
|
||||||
Future f = Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), () -> {
|
Future f = Bukkit.getScheduler().callSyncMethod(Bukkit.getPluginManager().getPlugin("ViaVersion"), new Callable<Boolean>() {
|
||||||
|
@Override
|
||||||
|
public Boolean call() throws Exception {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return true;
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (wait) {
|
if (wait) {
|
||||||
f.get(10, TimeUnit.SECONDS);
|
f.get(10, TimeUnit.SECONDS);
|
||||||
|
@ -71,10 +71,13 @@ public class ArmorListener implements Listener {
|
|||||||
if (ArmorType.isArmor(e.getMaterial())) {
|
if (ArmorType.isArmor(e.getMaterial())) {
|
||||||
final Player player = e.getPlayer();
|
final Player player = e.getPlayer();
|
||||||
// Due to odd bugs it's 3 ticks later
|
// Due to odd bugs it's 3 ticks later
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (ViaVersion.getInstance().isPorted(player)) {
|
if (ViaVersion.getInstance().isPorted(player)) {
|
||||||
sendArmorUpdate(player);
|
sendArmorUpdate(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}, 3L);
|
}, 3L);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -87,12 +90,13 @@ public class ArmorListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void sendDelayedArmorUpdate(final Player player) {
|
public void sendDelayedArmorUpdate(final Player player) {
|
||||||
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, () -> {
|
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
if (ViaVersion.getInstance().isPorted(player)) {
|
if (ViaVersion.getInstance().isPorted(player)) {
|
||||||
sendArmorUpdate(player);
|
sendArmorUpdate(player);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -24,6 +24,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void encode(final ChannelHandlerContext ctx, Object o, final ByteBuf bytebuf) throws Exception {
|
protected void encode(final ChannelHandlerContext ctx, Object o, final ByteBuf bytebuf) throws Exception {
|
||||||
// handle the packet type
|
// handle the packet type
|
||||||
@ -37,7 +38,10 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
final Object world = ReflectionUtil.get(o, "world", ReflectionUtil.nms("World"));
|
final Object world = ReflectionUtil.get(o, "world", ReflectionUtil.nms("World"));
|
||||||
Class<?> mapChunk = ReflectionUtil.nms("PacketPlayOutMapChunk");
|
Class<?> mapChunk = ReflectionUtil.nms("PacketPlayOutMapChunk");
|
||||||
final Constructor constructor = mapChunk.getDeclaredConstructor(ReflectionUtil.nms("Chunk"), boolean.class, int.class);
|
final Constructor constructor = mapChunk.getDeclaredConstructor(ReflectionUtil.nms("Chunk"), boolean.class, int.class);
|
||||||
Runnable chunks = () -> {
|
Runnable chunks = new Runnable() {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
|
||||||
for (int i = 0; i < locX.length; i++) {
|
for (int i = 0; i < locX.length; i++) {
|
||||||
int x = locX[i];
|
int x = locX[i];
|
||||||
@ -47,10 +51,11 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
Object chunk = ReflectionUtil.nms("World").getDeclaredMethod("getChunkAt", int.class, int.class).invoke(world, x, z);
|
Object chunk = ReflectionUtil.nms("World").getDeclaredMethod("getChunkAt", int.class, int.class).invoke(world, x, z);
|
||||||
Object packet = constructor.newInstance(chunk, true, 65535);
|
Object packet = constructor.newInstance(chunk, true, 65535);
|
||||||
ctx.pipeline().writeAndFlush(packet);
|
ctx.pipeline().writeAndFlush(packet);
|
||||||
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
|
} catch (InstantiationException | InvocationTargetException | ClassNotFoundException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
};
|
};
|
||||||
// Synced allows timings to work properly.
|
// Synced allows timings to work properly.
|
||||||
// if (ViaVersion.getInstance().isSyncedChunks()) {
|
// if (ViaVersion.getInstance().isSyncedChunks()) {
|
||||||
|
@ -1,10 +1,8 @@
|
|||||||
package us.myles.ViaVersion.metadata;
|
package us.myles.ViaVersion.metadata;
|
||||||
|
|
||||||
import lombok.AllArgsConstructor;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.bukkit.entity.*;
|
import org.bukkit.entity.*;
|
||||||
|
|
||||||
@AllArgsConstructor
|
|
||||||
@Getter
|
@Getter
|
||||||
public enum MetaIndex {
|
public enum MetaIndex {
|
||||||
|
|
||||||
@ -140,6 +138,14 @@ public enum MetaIndex {
|
|||||||
this.newType = newType;
|
this.newType = newType;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MetaIndex(Class<?> type, int index, Type oldType, int newIndex, NewType newType) {
|
||||||
|
this.clazz = type;
|
||||||
|
this.index = index;
|
||||||
|
this.oldType = oldType;
|
||||||
|
this.newIndex = newIndex;
|
||||||
|
this.newType = newType;
|
||||||
|
}
|
||||||
|
|
||||||
public static MetaIndex getIndex(EntityType type, int index) {
|
public static MetaIndex getIndex(EntityType type, int index) {
|
||||||
Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass();
|
Class<? extends org.bukkit.entity.Entity> entityClass = type.getEntityClass();
|
||||||
if (entityClass == null) {
|
if (entityClass == null) {
|
||||||
|
@ -50,7 +50,7 @@ public class MetadataRewriter {
|
|||||||
}
|
}
|
||||||
output.writeBoolean(toWrite != null);
|
output.writeBoolean(toWrite != null);
|
||||||
if (toWrite != null)
|
if (toWrite != null)
|
||||||
PacketUtil.writeUUID((UUID) toWrite, output);
|
PacketUtil.writeUUID(toWrite, output);
|
||||||
break;
|
break;
|
||||||
case BlockID:
|
case BlockID:
|
||||||
// if we have both sources :))
|
// if we have both sources :))
|
||||||
|
@ -3,7 +3,6 @@ package us.myles.ViaVersion.transformers;
|
|||||||
import io.netty.buffer.ByteBuf;
|
import io.netty.buffer.ByteBuf;
|
||||||
import io.netty.buffer.ByteBufInputStream;
|
import io.netty.buffer.ByteBufInputStream;
|
||||||
import io.netty.buffer.ByteBufOutputStream;
|
import io.netty.buffer.ByteBufOutputStream;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
@ -34,7 +33,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import static us.myles.ViaVersion.util.PacketUtil.*;
|
import static us.myles.ViaVersion.util.PacketUtil.*;
|
||||||
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class OutgoingTransformer {
|
public class OutgoingTransformer {
|
||||||
|
|
||||||
private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
private final ViaVersionPlugin plugin = (ViaVersionPlugin) ViaVersion.getInstance();
|
||||||
@ -46,6 +45,10 @@ public class OutgoingTransformer {
|
|||||||
private boolean cancel = false;
|
private boolean cancel = false;
|
||||||
private boolean autoTeam = false;
|
private boolean autoTeam = false;
|
||||||
|
|
||||||
|
public OutgoingTransformer(ConnectionInfo info) {
|
||||||
|
this.info = info;
|
||||||
|
}
|
||||||
|
|
||||||
public static String fixJson(String line) {
|
public static String fixJson(String line) {
|
||||||
if (line == null || line.equalsIgnoreCase("null")) {
|
if (line == null || line.equalsIgnoreCase("null")) {
|
||||||
line = "{\"text\":\"\"}";
|
line = "{\"text\":\"\"}";
|
||||||
@ -654,7 +657,12 @@ public class OutgoingTransformer {
|
|||||||
if (autoTeam && name.equalsIgnoreCase(info.getUsername())) {
|
if (autoTeam && name.equalsIgnoreCase(info.getUsername())) {
|
||||||
if (mode == 4) {
|
if (mode == 4) {
|
||||||
// since removing add to auto team
|
// since removing add to auto team
|
||||||
plugin.run(() -> sendTeamPacket(true), false);
|
plugin.run(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sendTeamPacket(true);
|
||||||
|
}
|
||||||
|
}, false);
|
||||||
} else {
|
} else {
|
||||||
// since adding remove from auto team
|
// since adding remove from auto team
|
||||||
sendTeamPacket(false);
|
sendTeamPacket(false);
|
||||||
@ -746,7 +754,9 @@ public class OutgoingTransformer {
|
|||||||
if (info.getLastPacket().getClass().getName().endsWith("PacketPlayOutMapChunkBulk")) {
|
if (info.getLastPacket().getClass().getName().endsWith("PacketPlayOutMapChunkBulk")) {
|
||||||
try {
|
try {
|
||||||
sk = ReflectionUtil.get(info.getLastPacket(), "d", boolean.class);
|
sk = ReflectionUtil.get(info.getLastPacket(), "d", boolean.class);
|
||||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -332,7 +332,7 @@ public class PacketUtil {
|
|||||||
|
|
||||||
// Data Array Length
|
// Data Array Length
|
||||||
byte[] blockData = convertBlockArray(chunk.getBlocks());
|
byte[] blockData = convertBlockArray(chunk.getBlocks());
|
||||||
writeVarInt(blockData.length / 8, buffer); // Notchian is divide by 8
|
writeVarInt((blockData != null ? blockData.length : 0) / 8, buffer); // Notchian is divide by 8
|
||||||
|
|
||||||
buffer.writeBytes(blockData);
|
buffer.writeBytes(blockData);
|
||||||
// Block Light
|
// Block Light
|
||||||
@ -356,9 +356,8 @@ public class PacketUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static BitSet append(BitSet base, int index, MagicBitSet toAdd) {
|
private static BitSet append(BitSet base, int index, MagicBitSet toAdd) {
|
||||||
int length = index;
|
|
||||||
for (int i = 0; i < toAdd.getTrueLength(); i++) {
|
for (int i = 0; i < toAdd.getTrueLength(); i++) {
|
||||||
base.set(length + i, toAdd.get(i));
|
base.set(index + i, toAdd.get(i));
|
||||||
}
|
}
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren