Compare commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
f256309487 | ||
|
|
462abb1ef9 | ||
|
|
a35408d14f | ||
|
|
81d4deaea7 | ||
|
|
9103f89aff | ||
|
|
8e4c2648a3 | ||
|
|
ad020ec329 | ||
|
|
df3be302af | ||
|
|
8e3b8cb572 | ||
|
|
ff1554556e | ||
|
|
b15c93c416 | ||
|
|
071b42c9e0 | ||
|
|
304f9b34fd | ||
|
|
c817a0e9cb | ||
|
|
744252d492 | ||
|
|
9186361a29 | ||
|
|
bf01c9ea0e | ||
|
|
bee260e2b4 | ||
|
|
21811991f1 | ||
|
|
a2809f8d5c | ||
|
|
95f2b597da | ||
|
|
fa348fbc23 | ||
|
|
d277701caa | ||
|
|
9b7f68a888 | ||
|
|
7e837ef9db | ||
|
|
eb78fe4bfc | ||
|
|
689f0fd5db | ||
|
|
32316cf3ab |
No files matched your search
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+2
-4
@@ -6,14 +6,12 @@ import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import us.myles.ViaVersion.api.minecraft.item.Item;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.*;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class HandItemCache extends BukkitRunnable {
|
||||
public static boolean CACHE = false;
|
||||
private static ConcurrentHashMap<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||
private static Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||
|
||||
public static Item getHandItem(UUID player) {
|
||||
if (!handCache.containsKey(player))
|
||||
|
||||
@@ -52,6 +52,11 @@ public class BukkitConfigAPI extends Config implements ViaVersionConfig {
|
||||
return getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPistonAnimationPatch() {
|
||||
return getBoolean("piston-animation-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return getBoolean("bossbar-patch", true);
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -37,7 +37,7 @@
|
||||
<dependency>
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion-common</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -5,6 +5,7 @@ import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
import us.myles.ViaVersion.api.Pair;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
@@ -47,8 +48,9 @@ public class BungeeServerHandler implements Listener {
|
||||
|
||||
// Set the handshake version every time someone connects to any server
|
||||
@EventHandler
|
||||
public void onServerConnect(ServerConnectEvent e) throws NoSuchFieldException, IllegalAccessException {
|
||||
public void onServerConnect(ServerConnectEvent e) {
|
||||
UserConnection user = Via.getManager().getConnection(e.getPlayer().getUniqueId());
|
||||
if (user == null) return;
|
||||
if (!user.has(BungeeStorage.class)) {
|
||||
user.put(new BungeeStorage(user, e.getPlayer()));
|
||||
}
|
||||
@@ -61,12 +63,12 @@ public class BungeeServerHandler implements Listener {
|
||||
Object pendingConnection = getPendingConnection.invoke(e.getPlayer());
|
||||
Object handshake = getHandshake.invoke(pendingConnection);
|
||||
setProtocol.invoke(handshake, protocols == null ? user.get(ProtocolInfo.class).getProtocolVersion() : protocolId);
|
||||
} catch (InvocationTargetException e1) {
|
||||
} catch (InvocationTargetException | IllegalAccessException e1) {
|
||||
e1.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onServerConnected(ServerConnectedEvent e) {
|
||||
try {
|
||||
checkServerChange(e, Via.getManager().getConnection(e.getPlayer().getUniqueId()));
|
||||
@@ -76,6 +78,7 @@ public class BungeeServerHandler implements Listener {
|
||||
}
|
||||
|
||||
public void checkServerChange(ServerConnectedEvent e, UserConnection user) throws Exception {
|
||||
if (user == null) return;
|
||||
if (user.has(BungeeStorage.class)) {
|
||||
BungeeStorage storage = user.get(BungeeStorage.class);
|
||||
ProxiedPlayer player = storage.getPlayer();
|
||||
@@ -88,12 +91,11 @@ public class BungeeServerHandler implements Listener {
|
||||
|
||||
int protocolId = ProtocolDetectorService.getProtocolId(serverName);
|
||||
|
||||
UserConnection viaConnection = Via.getManager().getConnection(player.getUniqueId());
|
||||
ProtocolInfo info = viaConnection.get(ProtocolInfo.class);
|
||||
ProtocolInfo info = user.get(ProtocolInfo.class);
|
||||
// Refresh the pipes
|
||||
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocolId);
|
||||
ProtocolPipeline pipeline = viaConnection.get(ProtocolInfo.class).getPipeline();
|
||||
viaConnection.clearStoredObjects();
|
||||
ProtocolPipeline pipeline = user.get(ProtocolInfo.class).getPipeline();
|
||||
user.clearStoredObjects();
|
||||
pipeline.cleanPipes();
|
||||
if (protocols == null) {
|
||||
// TODO Check Bungee Supported Protocols? *shrugs*
|
||||
@@ -104,14 +106,14 @@ public class BungeeServerHandler implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
viaConnection.put(info);
|
||||
viaConnection.put(storage);
|
||||
user.put(info);
|
||||
user.put(storage);
|
||||
|
||||
viaConnection.setActive(protocols != null);
|
||||
user.setActive(protocols != 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(viaConnection);
|
||||
protocol.init(user);
|
||||
}
|
||||
|
||||
Object wrapper = channelWrapper.get(player);
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package us.myles.ViaVersion.bungee.listeners;
|
||||
|
||||
import net.md_5.bungee.api.event.ServerConnectedEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
import us.myles.ViaVersion.api.PacketWrapper;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.Metadata;
|
||||
import us.myles.ViaVersion.api.minecraft.metadata.types.MetaType1_9;
|
||||
import us.myles.ViaVersion.api.type.Type;
|
||||
import us.myles.ViaVersion.api.type.types.version.Types1_9;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
/*
|
||||
* This patches https://github.com/MylesIsCool/ViaVersion/issues/555
|
||||
*/
|
||||
public class ElytraPatch implements Listener {
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onServerConnected(ServerConnectedEvent event) {
|
||||
UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId());
|
||||
if (user == null) return;
|
||||
|
||||
try {
|
||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
|
||||
int entityId = user.get(EntityTracker.class).getProvidedEntityId();
|
||||
|
||||
PacketWrapper wrapper = new PacketWrapper(0x39, null, user);
|
||||
|
||||
wrapper.write(Type.VAR_INT, entityId);
|
||||
wrapper.write(Types1_9.METADATA_LIST, Collections.singletonList(new Metadata(0, MetaType1_9.Byte, (byte) 0)));
|
||||
|
||||
wrapper.send(Protocol1_9TO1_8.class);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package us.myles.ViaVersion.bungee.listeners;
|
||||
|
||||
import net.md_5.bungee.api.event.ServerConnectEvent;
|
||||
import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.data.UserConnection;
|
||||
import us.myles.ViaVersion.protocols.base.ProtocolInfo;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9TO1_8;
|
||||
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
|
||||
/*
|
||||
This solves the wrong mainhand issue when you join with BungeeCord on a 1.8 server, and switch to a 1.9 or higher.
|
||||
*/
|
||||
public class MainHandPatch implements Listener {
|
||||
private static Method getSettings = null;
|
||||
private static Method setMainHand = null;
|
||||
|
||||
static {
|
||||
try {
|
||||
getSettings = Class.forName("net.md_5.bungee.UserConnection").getDeclaredMethod("getSettings");
|
||||
setMainHand = Class.forName("net.md_5.bungee.protocol.packet.ClientSettings").getDeclaredMethod("setMainHand", int.class);
|
||||
} catch (Exception ignored) {
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onServerConnect(ServerConnectEvent event) {
|
||||
// Ignore if it doesn't exist (Like BungeeCord 1.8)
|
||||
if (setMainHand == null)
|
||||
return;
|
||||
|
||||
UserConnection user = Via.getManager().getConnection(event.getPlayer().getUniqueId());
|
||||
if(user == null) return;
|
||||
|
||||
try {
|
||||
if (user.get(ProtocolInfo.class).getPipeline().contains(Protocol1_9TO1_8.class)) {
|
||||
Object settings = getSettings.invoke(event.getPlayer());
|
||||
setMainHand.invoke(settings, user.get(EntityTracker.class).getMainHand());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -86,6 +86,11 @@ public class BungeeConfigAPI extends Config implements ViaVersionConfig {
|
||||
return getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPistonAnimationPatch() {
|
||||
return getBoolean("piston-animation-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return getBoolean("bossbar-patch", true);
|
||||
|
||||
@@ -6,6 +6,8 @@ import us.myles.ViaVersion.BungeePlugin;
|
||||
import us.myles.ViaVersion.api.Via;
|
||||
import us.myles.ViaVersion.api.platform.ViaPlatformLoader;
|
||||
import us.myles.ViaVersion.bungee.handlers.BungeeServerHandler;
|
||||
import us.myles.ViaVersion.bungee.listeners.ElytraPatch;
|
||||
import us.myles.ViaVersion.bungee.listeners.MainHandPatch;
|
||||
import us.myles.ViaVersion.bungee.listeners.UpdateListener;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeEntityIdProvider;
|
||||
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
|
||||
@@ -27,6 +29,8 @@ public class BungeeViaLoader implements ViaPlatformLoader {
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, plugin);
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, new UpdateListener());
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, new BungeeServerHandler());
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, new MainHandPatch());
|
||||
ProxyServer.getInstance().getPluginManager().registerListener(plugin, new ElytraPatch());
|
||||
|
||||
// Providers
|
||||
Via.getManager().getProviders().use(MovementTransmitterProvider.class, new BungeeMovementTransmitter());
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
@@ -283,9 +283,23 @@ public class PacketWrapper {
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline) throws Exception {
|
||||
send(packetProtocol, skipCurrentPipeline, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send this packet to the associated user.
|
||||
* Be careful not to send packets twice.
|
||||
* (Sends it after current)
|
||||
*
|
||||
* @param packetProtocol - The protocol version of the packet.
|
||||
* @param skipCurrentPipeline - Skip the current pipeline
|
||||
* @param currentThread - Run in the same thread
|
||||
* @throws Exception if it fails to write
|
||||
*/
|
||||
public void send(Class<? extends Protocol> packetProtocol, boolean skipCurrentPipeline, boolean currentThread) throws Exception {
|
||||
if (!isCancelled()) {
|
||||
ByteBuf output = constructPacket(packetProtocol, skipCurrentPipeline);
|
||||
user().sendRawPacket(output);
|
||||
user().sendRawPacket(output, currentThread);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -53,6 +53,13 @@ public interface ViaVersionConfig {
|
||||
*/
|
||||
boolean isHologramPatch();
|
||||
|
||||
/**
|
||||
* Get if the 1.11 piston animation patch is enabled
|
||||
*
|
||||
* @return true if the piston patch is enabled.
|
||||
*/
|
||||
boolean isPistonAnimationPatch();
|
||||
|
||||
/**
|
||||
* Get if boss bars are fixed for 1.9 & 1.10 clients
|
||||
*
|
||||
|
||||
@@ -37,7 +37,7 @@ public class ProtocolRegistry {
|
||||
registerProtocol(new Protocol1_9_1_2TO1_9_3_4(), Arrays.asList(ProtocolVersion.v1_9_1.getId(), ProtocolVersion.v1_9_2.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
registerProtocol(new Protocol1_10To1_9_3_4(), Collections.singletonList(ProtocolVersion.v1_10.getId()), ProtocolVersion.v1_9_3.getId());
|
||||
|
||||
registerProtocol(new Protocol1_11To1_10(), Collections.singletonList(ProtocolVersion.v1_11.getId()), ProtocolVersion.v1_10.getId());
|
||||
registerProtocol(new Protocol1_11To1_10(), Arrays.asList(ProtocolVersion.v1_11.getId(), ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_10.getId());
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -28,6 +28,7 @@ public class ProtocolVersion {
|
||||
public static final ProtocolVersion v1_9_3;
|
||||
public static final ProtocolVersion v1_10;
|
||||
public static final ProtocolVersion v1_11;
|
||||
public static final ProtocolVersion v1_11_1;
|
||||
public static final ProtocolVersion unknown;
|
||||
|
||||
private final int id;
|
||||
@@ -52,6 +53,7 @@ public class ProtocolVersion {
|
||||
register(v1_9_3 = new ProtocolVersion(110, "1.9.3/4"));
|
||||
register(v1_10 = new ProtocolVersion(210, "1.10"));
|
||||
register(v1_11 = new ProtocolVersion(315, "1.11"));
|
||||
register(v1_11_1 = new ProtocolVersion(316, "1.11.1"));
|
||||
register(unknown = new ProtocolVersion(-1, "UNKNOWN"));
|
||||
}
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public abstract class ViaCommandHandler implements ViaVersionCommand {
|
||||
ViaSubCommand handler = getSubCommand(args[0]);
|
||||
|
||||
if (!hasPermission(sender, handler.permission())) {
|
||||
sender.sendMessage(color("&cYou are not allowed to use this commands!"));
|
||||
sender.sendMessage(color("&cYou are not allowed to use this command!"));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
@@ -41,7 +41,7 @@ public class ListSubCmd extends ViaSubCommand {
|
||||
}
|
||||
|
||||
for (Map.Entry<ProtocolVersion, Set<String>> entry : playerVersions.entrySet())
|
||||
sendMessage(sender, "&8[&6%s&8]: &b%s", entry.getKey().getName(), entry.getValue());
|
||||
sendMessage(sender, "&8[&6%s&8] (&7%d&8): &b%s", entry.getKey().getName(), entry.getValue().size(), entry.getValue());
|
||||
|
||||
playerVersions.clear();
|
||||
return true;
|
||||
|
||||
@@ -113,7 +113,12 @@ public class BaseProtocol extends Protocol {
|
||||
ProtocolInfo info = wrapper.user().get(ProtocolInfo.class);
|
||||
info.setState(State.PLAY);
|
||||
// Save other info
|
||||
UUID uuid = UUID.fromString(wrapper.get(Type.STRING, 0));
|
||||
String stringUUID = wrapper.get(Type.STRING, 0);
|
||||
if (stringUUID.length() == 32) { // Trimmed UUIDs are 32 characters
|
||||
// Trimmed
|
||||
stringUUID = addDashes(stringUUID);
|
||||
}
|
||||
UUID uuid = UUID.fromString(stringUUID);
|
||||
info.setUuid(uuid);
|
||||
info.setUsername(wrapper.get(Type.STRING, 1));
|
||||
// Add to ported clients
|
||||
@@ -232,4 +237,13 @@ public class BaseProtocol extends Protocol {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static String addDashes(String trimmedUUID) {
|
||||
StringBuffer idBuff = new StringBuffer(trimmedUUID);
|
||||
idBuff.insert(20, '-');
|
||||
idBuff.insert(16, '-');
|
||||
idBuff.insert(12, '-');
|
||||
idBuff.insert(8, '-');
|
||||
return idBuff.toString();
|
||||
}
|
||||
}
|
||||
+42
@@ -219,6 +219,30 @@ public class Protocol1_11To1_10 extends Protocol {
|
||||
}
|
||||
});
|
||||
|
||||
// Block action packet
|
||||
registerOutgoing(State.PLAY, 0x0A, 0x0A, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.POSITION); // 0 - Position
|
||||
map(Type.UNSIGNED_BYTE); // 1 - Action ID
|
||||
map(Type.UNSIGNED_BYTE); // 2 - Action Param
|
||||
map(Type.VAR_INT); // 3 - Block Type
|
||||
|
||||
// Cheap hack to ensure it's always right block
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(final PacketWrapper actionWrapper) throws Exception {
|
||||
if (Via.getConfig().isPistonAnimationPatch()) {
|
||||
int id = actionWrapper.get(Type.VAR_INT, 0);
|
||||
if (id == 33 || id == 29) {
|
||||
actionWrapper.cancel();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/*
|
||||
INCOMING PACKETS
|
||||
*/
|
||||
@@ -236,6 +260,24 @@ public class Protocol1_11To1_10 extends Protocol {
|
||||
map(Type.FLOAT, toOldByte);
|
||||
}
|
||||
});
|
||||
|
||||
// Chat Message Incoming
|
||||
registerIncoming(State.PLAY, 0x02, 0x02, new PacketRemapper() {
|
||||
@Override
|
||||
public void registerMap() {
|
||||
map(Type.STRING); // 0 - Message
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
// 100 character limit on older servers
|
||||
String msg = wrapper.get(Type.STRING, 0);
|
||||
if (msg.length() > 100) {
|
||||
wrapper.set(Type.STRING, 0, msg.substring(0, 100));
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
private int getNewSoundId(int id) { //TODO Make it better, suggestions are welcome. It's ugly and hardcoded now.
|
||||
|
||||
+4
-4
@@ -81,14 +81,14 @@ public class InventoryPackets {
|
||||
if (wrapper.get(Type.STRING, 0).equalsIgnoreCase("MC|TrList")) {
|
||||
wrapper.passthrough(Type.INT); // Passthrough Window ID
|
||||
|
||||
int size = wrapper.passthrough(Type.BYTE);
|
||||
int size = wrapper.passthrough(Type.UNSIGNED_BYTE);
|
||||
for (int i = 0; i < size; i++) {
|
||||
ItemRewriter.toClient(wrapper.read(Type.ITEM)); // Input Item
|
||||
ItemRewriter.toClient(wrapper.read(Type.ITEM)); // Output Item
|
||||
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Input Item
|
||||
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Output Item
|
||||
|
||||
boolean secondItem = wrapper.passthrough(Type.BOOLEAN); // Has second item
|
||||
if (secondItem)
|
||||
ItemRewriter.toClient(wrapper.read(Type.ITEM)); // Second Item
|
||||
ItemRewriter.toClient(wrapper.passthrough(Type.ITEM)); // Second Item
|
||||
|
||||
wrapper.passthrough(Type.BOOLEAN); // Trade disabled
|
||||
wrapper.passthrough(Type.INT); // Number of tools uses
|
||||
|
||||
+1
-1
@@ -72,7 +72,7 @@ public class MetadataRewriter {
|
||||
id = (Short) value;
|
||||
}
|
||||
if (id != -1 && data != -1) {
|
||||
int combined = id << 4 | data;
|
||||
int combined = id | (data & 0xF);
|
||||
data = -1;
|
||||
id = -1;
|
||||
entry.setValue(combined);
|
||||
|
||||
+4
-4
@@ -226,9 +226,9 @@ public class InventoryPackets {
|
||||
wrapper.create(0x16, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.UNSIGNED_BYTE, (short) 0);
|
||||
wrapper.write(Type.BYTE, (byte) 0);
|
||||
wrapper.write(Type.SHORT, slot);
|
||||
wrapper.write(Type.SHORT, (short) -1);
|
||||
wrapper.write(Type.ITEM, null);
|
||||
}
|
||||
}).send(Protocol1_9TO1_8.class);
|
||||
// Finally reset to simulate throwing item
|
||||
@@ -281,9 +281,9 @@ public class InventoryPackets {
|
||||
wrapper.create(0x16, new ValueCreator() {
|
||||
@Override
|
||||
public void write(PacketWrapper wrapper) throws Exception {
|
||||
wrapper.write(Type.UNSIGNED_BYTE, windowID);
|
||||
wrapper.write(Type.BYTE, (byte) windowID);
|
||||
wrapper.write(Type.SHORT, slot);
|
||||
wrapper.write(Type.SHORT, (short) -1);
|
||||
wrapper.write(Type.ITEM, null);
|
||||
}
|
||||
}).send(Protocol1_9TO1_8.class);
|
||||
// Finally reset to simulate throwing item
|
||||
|
||||
+10
-1
@@ -433,7 +433,16 @@ public class PlayerPackets {
|
||||
map(Type.VAR_INT, Type.BYTE); // 2 - Chat Mode
|
||||
map(Type.BOOLEAN); // 3 - If Chat Colours on
|
||||
map(Type.UNSIGNED_BYTE); // 4 - Skin Parts
|
||||
map(Type.VAR_INT, Type.NOTHING); // 5 - Main Hand
|
||||
|
||||
handler(new PacketHandler() {
|
||||
@Override
|
||||
public void handle(PacketWrapper wrapper) throws Exception {
|
||||
int hand = wrapper.read(Type.VAR_INT);
|
||||
|
||||
EntityTracker tracker = wrapper.user().get(EntityTracker.class);
|
||||
tracker.setMainHand(hand);
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
+1
-1
@@ -162,7 +162,7 @@ public class WorldPackets {
|
||||
output.setId(-1); // -1 for no writing of id
|
||||
output.writeToBuffer(buffer);
|
||||
PacketWrapper chunkPacket = new PacketWrapper(0x21, buffer, wrapper.user());
|
||||
chunkPacket.send(Protocol1_9TO1_8.class, false);
|
||||
chunkPacket.send(Protocol1_9TO1_8.class, false, true);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
+2
@@ -51,6 +51,8 @@ public class EntityTracker extends StoredObject {
|
||||
private boolean teamExists = false;
|
||||
@Setter
|
||||
private GameMode gameMode;
|
||||
@Setter
|
||||
private int mainHand;
|
||||
|
||||
public EntityTracker(UserConnection user) {
|
||||
super(user);
|
||||
|
||||
@@ -33,7 +33,7 @@ public abstract class Config implements ConfigurationProvider {
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public Map<String, Object> loadConfig(File location) {
|
||||
public synchronized Map<String, Object> loadConfig(File location) {
|
||||
List<String> unsupported = getUnsupportedOptions();
|
||||
URL jarConfigFile = Config.class.getClassLoader().getResource("config.yml");
|
||||
try {
|
||||
@@ -87,7 +87,7 @@ public abstract class Config implements ConfigurationProvider {
|
||||
|
||||
protected abstract void handleConfig(Map<String, Object> config);
|
||||
|
||||
public void saveConfig(File location, Map<String, Object> config) {
|
||||
public synchronized void saveConfig(File location, Map<String, Object> config) {
|
||||
try {
|
||||
commentStore.writeComments(yaml.get().dump(config), location);
|
||||
} catch (IOException e) {
|
||||
@@ -145,7 +145,11 @@ public abstract class Config implements ConfigurationProvider {
|
||||
|
||||
public int getInt(String key, int def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (int) this.config.get(key);
|
||||
if (this.config.get(key) instanceof Number) {
|
||||
return ((Number) this.config.get(key)).intValue();
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
@@ -153,7 +157,11 @@ public abstract class Config implements ConfigurationProvider {
|
||||
|
||||
public double getDouble(String key, double def) {
|
||||
if (this.config.containsKey(key)) {
|
||||
return (double) this.config.get(key);
|
||||
if (this.config.get(key) instanceof Number) {
|
||||
return ((Number) this.config.get(key)).doubleValue();
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
} else {
|
||||
return def;
|
||||
}
|
||||
|
||||
@@ -79,6 +79,9 @@ tracking-max-kick-msg: "You are sending too many packets, :("
|
||||
hologram-patch: false
|
||||
# This is the offset, should work as default when enabled.
|
||||
hologram-y: -0.96
|
||||
# Should we disable piston animation for 1.11/1.11.1 clients?
|
||||
# In some cases when firing lots of pistons it crashes them.
|
||||
piston-animation-patch: false
|
||||
#
|
||||
#----------------------------------------------------------#
|
||||
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS #
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<name>viaversion-jar</name>
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>us.myles</groupId>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
<packaging>pom</packaging>
|
||||
|
||||
<name>viaversion-parent</name>
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+1
-1
@@ -5,7 +5,7 @@
|
||||
<parent>
|
||||
<artifactId>viaversion-parent</artifactId>
|
||||
<groupId>us.myles</groupId>
|
||||
<version>1.0.0</version>
|
||||
<version>1.0.2</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
|
||||
+2
-1
@@ -12,12 +12,13 @@ import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class HandItemCache implements Runnable {
|
||||
public static boolean CACHE = false;
|
||||
private static ConcurrentHashMap<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||
private static Map<UUID, Item> handCache = new ConcurrentHashMap<>();
|
||||
private static Field GET_DAMAGE;
|
||||
private static Method GET_ID;
|
||||
private static ItemGrabber grabber;
|
||||
|
||||
@@ -59,6 +59,11 @@ public class SpongeConfigAPI extends Config implements ViaVersionConfig {
|
||||
return getBoolean("hologram-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPistonAnimationPatch() {
|
||||
return getBoolean("piston-animation-patch", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBossbarPatch() {
|
||||
return getBoolean("bossbar-patch", true);
|
||||
|
||||
Reference in new issue
Block a user