Mirror von
https://github.com/ViaVersion/ViaVersion.git
synchronisiert 2024-12-27 08:30:09 +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>() {
|
||||||
if (info.getPlayer() != null) {
|
@Override
|
||||||
return info.getPlayer().getItemInHand();
|
public ItemStack call() throws Exception {
|
||||||
|
if (info.getPlayer() != null) {
|
||||||
|
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 ");
|
||||||
@ -182,7 +186,7 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaVersionAPI {
|
|||||||
|
|
||||||
public boolean isAutoTeam() {
|
public boolean isAutoTeam() {
|
||||||
// Collision has to be enabled first
|
// Collision has to be enabled first
|
||||||
if(!isPreventCollision()) return false;
|
if (!isPreventCollision()) return false;
|
||||||
return getConfig().getBoolean("auto-team", true);
|
return getConfig().getBoolean("auto-team", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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>() {
|
||||||
runnable.run();
|
@Override
|
||||||
return true;
|
public Boolean call() throws Exception {
|
||||||
|
runnable.run();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
});
|
});
|
||||||
if (wait) {
|
if (wait) {
|
||||||
f.get(10, TimeUnit.SECONDS);
|
f.get(10, TimeUnit.SECONDS);
|
||||||
|
@ -71,9 +71,12 @@ 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() {
|
||||||
if (ViaVersion.getInstance().isPorted(player)) {
|
@Override
|
||||||
sendArmorUpdate(player);
|
public void run() {
|
||||||
|
if (ViaVersion.getInstance().isPorted(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,18 +38,22 @@ 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() {
|
||||||
|
|
||||||
for (int i = 0; i < locX.length; i++) {
|
@Override
|
||||||
int x = locX[i];
|
public void run() {
|
||||||
int z = locZ[i];
|
|
||||||
// world invoke function
|
for (int i = 0; i < locX.length; i++) {
|
||||||
try {
|
int x = locX[i];
|
||||||
Object chunk = ReflectionUtil.nms("World").getDeclaredMethod("getChunkAt", int.class, int.class).invoke(world, x, z);
|
int z = locZ[i];
|
||||||
Object packet = constructor.newInstance(chunk, true, 65535);
|
// world invoke function
|
||||||
ctx.pipeline().writeAndFlush(packet);
|
try {
|
||||||
} catch (InstantiationException | InvocationTargetException | NoSuchMethodException | IllegalAccessException | ClassNotFoundException e) {
|
Object chunk = ReflectionUtil.nms("World").getDeclaredMethod("getChunkAt", int.class, int.class).invoke(world, x, z);
|
||||||
e.printStackTrace();
|
Object packet = constructor.newInstance(chunk, true, 65535);
|
||||||
|
ctx.pipeline().writeAndFlush(packet);
|
||||||
|
} catch (InstantiationException | InvocationTargetException | ClassNotFoundException | IllegalAccessException | NoSuchMethodException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -56,7 +61,7 @@ public class ViaEncodeHandler extends MessageToByteEncoder {
|
|||||||
// if (ViaVersion.getInstance().isSyncedChunks()) {
|
// if (ViaVersion.getInstance().isSyncedChunks()) {
|
||||||
// ((ViaVersionPlugin) ViaVersion.getInstance()).run(chunks, false);
|
// ((ViaVersionPlugin) ViaVersion.getInstance()).run(chunks, false);
|
||||||
// } else {
|
// } else {
|
||||||
chunks.run();
|
chunks.run();
|
||||||
// }
|
// }
|
||||||
bytebuf.readBytes(bytebuf.readableBytes());
|
bytebuf.readBytes(bytebuf.readableBytes());
|
||||||
throw new CancelException();
|
throw new CancelException();
|
||||||
|
@ -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