Compare commits

...
42 Commits
Author SHA1 Message Date
Myles e3c1b9bf64 1.0.4 Release 2017-02-03 16:27:18 +00:00
Myles a52552dcb4 Save boss bars to BungeeCord which are made by Withers / Enderdragons 2017-02-03 16:24:14 +00:00
Myles e8039e158f Fix horse spawn eggs 2017-02-01 15:58:53 +00:00
Myles c37ef71f72 Fix spawn eggs for 1.11+ #598 2017-01-30 18:02:12 +00:00
Myles 0388f340cc Don’t support older versions if protocol support is installed, fixes #615 2017-01-30 17:15:47 +00:00
Myles 5e437d26d9 Fix typo 2017-01-12 22:10:05 +00:00
Myles c10c3547b9 Move dumps to gists #608 2017-01-03 15:53:20 +00:00
Myles 528a8e5587 Update OpenNBT 2016-12-24 17:27:59 +00:00
Myles ea4487e33f Back to dev 2016-12-20 21:46:19 +00:00
Myles c2578bd212 Bump to 1.0.3 2016-12-20 21:06:23 +00:00
Myles a1347dd669 Move 1.11.1 support to new class, fixes any other support issues (or just upgrade bungee etc) 2016-12-20 20:54:28 +00:00
Myles 3228ba65ae Fix #587 2016-12-20 20:13:19 +00:00
Myles 08b2d5b7e8 Fix #604 2016-12-20 20:11:21 +00:00
Myles 2b89dbce0e Back to snapshot 2016-12-20 16:14:13 +00:00
Myles f256309487 Bump version to 1.0.2 2016-12-20 16:07:37 +00:00
Myles 462abb1ef9 Update to snapshot 1.11.1 2016-12-15 15:39:38 +00:00
Myles a35408d14f New config option for disabling piston animation for 1.11 clients #570 2016-12-15 15:32:54 +00:00
Myles 81d4deaea7 Fix block metadata #580 2016-11-28 23:47:49 +00:00
Myles 9103f89aff 1.0.2-SNAPSHOT 2016-11-16 19:58:59 +00:00
Myles 8e4c2648a3 1.0.1 Release 2016-11-16 19:57:20 +00:00
Myles ad020ec329 Fix wrong packet format for 1.8 brewing #562 2016-11-16 18:14:47 +00:00
Matsv df3be302af Send the chunkbulk packets immediately. Fixes #535 2016-11-16 17:15:36 +01:00
Gianluca Falcomer 8e3b8cb572 Update ViaCommandHandler.java (#558) 2016-11-16 16:15:24 +01:00
Myles ff1554556e Fixed 1.7 UUID, oops. Thanks @MineTheCube 2016-11-15 21:17:39 +00:00
Myles b15c93c416 Use length for UUID compat as contains is expensive 2016-11-15 19:53:22 +00:00
Myles 071b42c9e0 Fix 1.7.2 support when used with ProtocolSupport 2016-11-15 19:11:40 +00:00
Matsv 304f9b34fd Send empty metadata flags on server switch to prevent an Elytra glitch on 1.8 fixes #555 2016-11-15 18:10:14 +01:00
Myles c817a0e9cb Add null check to hand patch 2016-11-15 17:07:31 +00:00
Myles 744252d492 Don't handle null users 2016-11-15 17:01:22 +00:00
Myles 9186361a29 Change ConcurrentHashMaps to just Maps for Java 7 support 2016-11-15 15:17:16 +00:00
Myles bf01c9ea0e Fix getting connection twice 2016-11-15 08:17:15 +00:00
Myles bee260e2b4 Ignore null users 2016-11-14 23:42:29 +00:00
Myles 21811991f1 Correct elytra dropping, fixes #545 2016-11-14 23:35:47 +00:00
Myles a2809f8d5c Add count to /viaver list, #540 2016-11-14 22:38:39 +00:00
Myles 95f2b597da This is billy, he got lost on his way to the last commit, apologies. 2016-11-14 22:20:08 +00:00
Myles fa348fbc23 Fix villager trading on 1.11 #534 2016-11-14 22:17:23 +00:00
Matsv d277701caa Ignore if the setMainHand doesn't exist 2016-11-14 21:13:18 +01:00
Matsv 9b7f68a888 Store the mainHand and change it on serverChange for Bungee, fixes #536 2016-11-14 20:59:06 +01:00
Myles 7e837ef9db Ensure we don't save and load config at same time 2016-11-14 18:46:27 +00:00
Myles eb78fe4bfc Better flexibility with number loading 2016-11-14 18:29:45 +00:00
Matsv 689f0fd5db Back to the snapshots 2016-11-14 19:17:20 +01:00
Myles 32316cf3ab Fix character limit to 100 for messages, #530 2016-11-14 18:14:49 +00:00
47 changed files with 568 additions and 79 deletions

No files matched your search

+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -253,4 +253,9 @@ public class ViaVersionPlugin extends JavaPlugin implements ViaPlatform {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return !protocolSupport; // Use protocolsupport for older clients
}
}
@@ -37,16 +37,19 @@ public class DeathListener extends ViaBukkitListener {
Via.getPlatform().runSync(new Runnable() {
@Override
public void run() {
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9TO1_8.FIX_JSON.write(wrapper, msg); // Message
// If online
if(getUserConnection(p) != null) {
PacketWrapper wrapper = new PacketWrapper(0x2C, null, getUserConnection(p));
try {
wrapper.write(Type.VAR_INT, 2); // Event - Entity dead
wrapper.write(Type.VAR_INT, p.getEntityId()); // Player ID
wrapper.write(Type.INT, p.getEntityId()); // Entity ID
Protocol1_9TO1_8.FIX_JSON.write(wrapper, msg); // Message
wrapper.send(Protocol1_9TO1_8.class);
} catch (Exception e) {
e.printStackTrace();
wrapper.send(Protocol1_9TO1_8.class);
} catch (Exception e) {
e.printStackTrace();
}
}
}
});
@@ -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
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</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.4</version>
</dependency>
</dependencies>
</project>
@@ -155,6 +155,11 @@ public class BungeePlugin extends Plugin implements ViaPlatform, Listener {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
@EventHandler
public void onQuit(PlayerDisconnectEvent e) {
Via.getManager().removePortedClient(e.getPlayer().getUniqueId());
@@ -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,51 @@
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 || getSettings == 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());
if (settings != null) {
if (user.has(EntityTracker.class)) {
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,12 +6,16 @@ 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.BungeeBossBarProvider;
import us.myles.ViaVersion.bungee.providers.BungeeEntityIdProvider;
import us.myles.ViaVersion.bungee.providers.BungeeMovementTransmitter;
import us.myles.ViaVersion.bungee.providers.BungeeVersionProvider;
import us.myles.ViaVersion.bungee.service.ProtocolDetectorService;
import us.myles.ViaVersion.protocols.base.VersionProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.MovementTransmitterProvider;
@@ -27,11 +31,15 @@ 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());
Via.getManager().getProviders().use(VersionProvider.class, new BungeeVersionProvider());
Via.getManager().getProviders().use(EntityIdProvider.class, new BungeeEntityIdProvider());
Via.getManager().getProviders().use(BossBarProvider.class, new BungeeBossBarProvider());
if (plugin.getConf().getBungeePingInterval() > 0) {
plugin.getProxy().getScheduler().schedule(plugin, new ProtocolDetectorService(plugin), 0, plugin.getConf().getBungeePingInterval(), TimeUnit.SECONDS);
}
@@ -0,0 +1,30 @@
package us.myles.ViaVersion.bungee.providers;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.bungee.storage.BungeeStorage;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
import java.util.UUID;
public class BungeeBossBarProvider extends BossBarProvider {
@Override
public void handleAdd(UserConnection user, UUID barUUID) {
if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class);
// Check if bossbars are supported by bungee, static maybe
if (storage.getBossbar() != null) {
storage.getBossbar().add(barUUID);
}
}
}
@Override
public void handleRemove(UserConnection user, UUID barUUID) {
if (user.has(BungeeStorage.class)) {
BungeeStorage storage = user.get(BungeeStorage.class);
if (storage.getBossbar() != null) {
storage.getBossbar().remove(barUUID);
}
}
}
}
@@ -6,15 +6,43 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection;
import java.lang.reflect.Field;
import java.util.Set;
import java.util.UUID;
@Data
@EqualsAndHashCode(callSuper = true)
public class BungeeStorage extends StoredObject {
private static Field bossField;
static {
try {
Class<?> user = Class.forName("net.md_5.bungee.UserConnection");
bossField = user.getDeclaredField("sentBossBars");
bossField.setAccessible(true);
} catch (ClassNotFoundException e) {
// Not supported *shrug* probably modified
} catch (NoSuchFieldException e) {
// Not supported, old version probably
}
}
private ProxiedPlayer player;
private String currentServer;
private Set<UUID> bossbar;
public BungeeStorage(UserConnection user, ProxiedPlayer player) {
super(user);
this.player = player;
this.currentServer = "";
// Get bossbar list if it's supported
if (bossField != null) {
try {
bossbar = (Set<UUID>) bossField.get(player);
} catch (IllegalAccessException e) {
e.printStackTrace();
}
}
}
}
+1 -2
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -13,7 +13,6 @@
<artifactId>viaversion-common</artifactId>
<dependencies>
<!-- Snake YAML -->
<dependency>
<groupId>org.yaml</groupId>
<artifactId>snakeyaml</artifactId>
@@ -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 &amp; 1.10 clients
*
@@ -167,4 +167,11 @@ public abstract class BossBar<T> {
* @return visibility changable with show() and hide()
*/
public abstract boolean isVisible();
/**
* Get the UUID of this bossbar
*
* @return Unique Id for this bossbar
*/
public abstract UUID getId();
}
@@ -140,4 +140,12 @@ public interface ViaPlatform<T> {
* @return The json data
*/
JsonObject getDump();
/**
* Get if older clients are allowed to be used using ViaVersion.
* (Only 1.9 on 1.9.2 server is supported by ViaVersion alone)
*
* @return True if allowed
*/
boolean isOldClientsAllowed();
}
@@ -6,6 +6,7 @@ import us.myles.ViaVersion.api.Pair;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.protocols.base.BaseProtocol;
import us.myles.ViaVersion.protocols.protocol1_10to1_9_3.Protocol1_10To1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_11_1to1_11.Protocol1_11_1To1_11;
import us.myles.ViaVersion.protocols.protocol1_11to1_10.Protocol1_11To1_10;
import us.myles.ViaVersion.protocols.protocol1_9_1_2to1_9_3_4.Protocol1_9_1_2TO1_9_3_4;
import us.myles.ViaVersion.protocols.protocol1_9_1to1_9.Protocol1_9_1TO1_9;
@@ -37,7 +38,8 @@ 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_10.getId());
registerProtocol(new Protocol1_11_1To1_11(), Arrays.asList(ProtocolVersion.v1_11_1.getId()), ProtocolVersion.v1_11.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"));
}
@@ -8,7 +8,9 @@ import org.spacehq.opennbt.NBTIO;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import us.myles.ViaVersion.api.type.Type;
import java.io.DataInput;
import java.io.DataInputStream;
import java.io.DataOutput;
import java.io.DataOutputStream;
public class NBTType extends Type<CompoundTag> {
@@ -28,7 +30,7 @@ public class NBTType extends Type<CompoundTag> {
buffer.readerIndex(readerIndex);
ByteBufInputStream bytebufStream = new ByteBufInputStream(buffer);
try (DataInputStream dataInputStream = new DataInputStream(bytebufStream)) {
return (CompoundTag) NBTIO.readTag(dataInputStream);
return (CompoundTag) NBTIO.readTag((DataInput) dataInputStream);
}
}
}
@@ -41,7 +43,7 @@ public class NBTType extends Type<CompoundTag> {
ByteBufOutputStream bytebufStream = new ByteBufOutputStream(buffer);
DataOutputStream dataOutputStream = new DataOutputStream(bytebufStream);
NBTIO.writeTag(dataOutputStream, object);
NBTIO.writeTag((DataOutput) dataOutputStream, object);
dataOutputStream.close();
}
@@ -138,6 +138,11 @@ public abstract class CommonBoss<T> extends BossBar<T> {
return visible;
}
@Override
public UUID getId() {
return uuid;
}
private void setVisible(boolean value) {
if (visible != value) {
visible = value;
@@ -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;
}
@@ -1,5 +1,6 @@
package us.myles.ViaVersion.commands.defaultsubs;
import com.google.common.io.CharStreams;
import com.google.gson.JsonObject;
import net.md_5.bungee.api.ChatColor;
import us.myles.ViaVersion.api.Via;
@@ -10,6 +11,7 @@ import us.myles.ViaVersion.dump.DumpTemplate;
import us.myles.ViaVersion.dump.VersionInfo;
import us.myles.ViaVersion.util.GsonUtil;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.InvalidObjectException;
import java.io.OutputStream;
@@ -50,35 +52,66 @@ public class DumpSubCmd extends ViaSubCommand {
Via.getPlatform().runAsync(new Runnable() {
@Override
public void run() {
try {
HttpURLConnection con = (HttpURLConnection) new URL("http://hastebin.com/documents").openConnection();
con.setRequestProperty("Content-Type", "text/plain");
HttpURLConnection con;
try {
con = (HttpURLConnection) new URL("https://api.github.com/gists").openConnection();
} catch (IOException e) {
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Gist", e);
return;
}
try {
con.setRequestProperty("Content-Type", "application/json");
con.addRequestProperty("User-Agent", "ViaVersion");
con.setRequestMethod("POST");
con.setDoOutput(true);
OutputStream out = con.getOutputStream();
out.write(GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template).getBytes(Charset.forName("UTF-8")));
String contents = GsonUtil.getGsonBuilder().setPrettyPrinting().create().toJson(template);
// Create payload
JsonObject payload = new JsonObject();
payload.addProperty("description", "ViaVersion Dump");
payload.addProperty("public", "false");
// Create file contents
JsonObject file = new JsonObject();
file.addProperty("content", contents);
// Create file list
JsonObject files = new JsonObject();
files.add("dump.json", file);
payload.add("files", files);
// Write to stream
out.write(GsonUtil.getGson().toJson(payload).getBytes(Charset.forName("UTF-8")));
out.close();
JsonObject output = GsonUtil.getGson().fromJson(new InputStreamReader(con.getInputStream()), JsonObject.class);
String rawOutput = CharStreams.toString(new InputStreamReader(con.getInputStream()));
con.getInputStream().close();
JsonObject output = GsonUtil.getGson().fromJson(rawOutput, JsonObject.class);
if (!output.has("key"))
throw new InvalidObjectException("Key is not given in Hastebin output");
sender.sendMessage(ChatColor.GREEN + "We've made a dump with useful information, report your issue and provide this url: " + getUrl(output.get("key").getAsString()));
if (!output.has("html_url"))
throw new InvalidObjectException("URL is not given in Gist output");
sender.sendMessage(ChatColor.GREEN + "We've made a dump with useful information, report your issue and provide this url: " + output.get("html_url").getAsString());
} catch (Exception e) {
sender.sendMessage(ChatColor.RED + "Failed to dump, please check the console for more information");
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Hastebin", e);
try {
if (con.getResponseCode() == 403) {
// Ensure 403 is due to rate limit being hit
if("0".equals(con.getHeaderField("X-RateLimit-Remaining"))) {
Via.getPlatform().getLogger().log(Level.WARNING, "You may only create 60 dumps per hour, please try again later.");
return;
}
}
Via.getPlatform().getLogger().log(Level.WARNING, "Could not paste ViaVersion dump to Gist", e);
} catch (IOException e1) {
Via.getPlatform().getLogger().log(Level.WARNING, "Failed to capture further info", e1);
}
}
}
});
return true;
}
private String getUrl(String id) {
return String.format("http://hastebin.com/%s.json", id);
}
}
@@ -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;
@@ -72,7 +72,12 @@ public class BaseProtocol extends Protocol {
ProtocolRegistry.SERVER_PROTOCOL = protocolVersion;
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
List<Pair<Integer, Protocol>> protocols = null;
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
}
if (protocols != null) {
if (protocolVersion != 9999) {
@@ -113,7 +118,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
@@ -158,7 +168,13 @@ public class BaseProtocol extends Protocol {
info.setProtocolVersion(protVer);
// Choose the pipe
int protocol = Via.getManager().getProviders().get(VersionProvider.class).getServerProtocol(wrapper.user());
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
List<Pair<Integer, Protocol>> protocols = null;
// Only allow newer clients or (1.9.2 on 1.9.4 server if the server supports it)
if (info.getProtocolVersion() >= protocol || Via.getPlatform().isOldClientsAllowed()) {
protocols = ProtocolRegistry.getProtocolPath(info.getProtocolVersion(), protocol);
}
ProtocolPipeline pipeline = wrapper.user().get(ProtocolInfo.class).getPipeline();
if (protocols != null) {
for (Pair<Integer, Protocol> prot : protocols) {
@@ -232,4 +248,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();
}
}
@@ -0,0 +1,16 @@
package us.myles.ViaVersion.protocols.protocol1_11_1to1_11;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.protocol.Protocol;
public class Protocol1_11_1To1_11 extends Protocol {
@Override
protected void registerPackets() {
// Only had metadata changes, see wiki.vg for full info.
}
@Override
public void init(UserConnection userConnection) {
}
}
@@ -1,16 +1,100 @@
package us.myles.ViaVersion.protocols.protocol1_11to1_10;
import com.google.common.collect.BiMap;
import com.google.common.collect.HashBiMap;
import org.spacehq.opennbt.tag.builtin.CompoundTag;
import org.spacehq.opennbt.tag.builtin.StringTag;
import us.myles.ViaVersion.api.minecraft.item.Item;
public class ItemRewriter {
private static BiMap<String, String> oldToNewNames = HashBiMap.create();
static {
oldToNewNames.put("AreaEffectCloud", "minecraft:area_effect_cloud");
oldToNewNames.put("ArmorStand", "minecraft:armor_stand");
oldToNewNames.put("Arrow", "minecraft:arrow");
oldToNewNames.put("Bat", "minecraft:bat");
oldToNewNames.put("Blaze", "minecraft:blaze");
oldToNewNames.put("Boat", "minecraft:boat");
oldToNewNames.put("CaveSpider", "minecraft:cave_spider");
oldToNewNames.put("Chicken", "minecraft:chicken");
oldToNewNames.put("Cow", "minecraft:cow");
oldToNewNames.put("Creeper", "minecraft:creeper");
oldToNewNames.put("Donkey", "minecraft:donkey");
oldToNewNames.put("DragonFireball", "minecraft:dragon_fireball");
oldToNewNames.put("ElderGuardian", "minecraft:elder_guardian");
oldToNewNames.put("EnderCrystal", "minecraft:ender_crystal");
oldToNewNames.put("EnderDragon", "minecraft:ender_dragon");
oldToNewNames.put("Enderman", "minecraft:enderman");
oldToNewNames.put("Endermite", "minecraft:endermite");
oldToNewNames.put("EntityHorse", "minecraft:horse");
oldToNewNames.put("EyeOfEnderSignal", "minecraft:eye_of_ender_signal");
oldToNewNames.put("FallingSand", "minecraft:falling_block");
oldToNewNames.put("Fireball", "minecraft:fireball");
oldToNewNames.put("FireworksRocketEntity", "minecraft:fireworks_rocket");
oldToNewNames.put("Ghast", "minecraft:ghast");
oldToNewNames.put("Giant", "minecraft:giant");
oldToNewNames.put("Guardian", "minecraft:guardian");
oldToNewNames.put("Husk", "minecraft:husk");
oldToNewNames.put("Item", "minecraft:item");
oldToNewNames.put("ItemFrame", "minecraft:item_frame");
oldToNewNames.put("LavaSlime", "minecraft:magma_cube");
oldToNewNames.put("LeashKnot", "minecraft:leash_knot");
oldToNewNames.put("MinecartChest", "minecraft:chest_minecart");
oldToNewNames.put("MinecartCommandBlock", "minecraft:commandblock_minecart");
oldToNewNames.put("MinecartFurnace", "minecraft:furnace_minecart");
oldToNewNames.put("MinecartHopper", "minecraft:hopper_minecart");
oldToNewNames.put("MinecartRideable", "minecraft:minecart");
oldToNewNames.put("MinecartSpawner", "minecraft:spawner_minecart");
oldToNewNames.put("MinecartTNT", "minecraft:tnt_minecart");
oldToNewNames.put("Mule", "minecraft:mule");
oldToNewNames.put("MushroomCow", "minecraft:mooshroom");
oldToNewNames.put("Ozelot", "minecraft:ocelot");
oldToNewNames.put("Painting", "minecraft:painting");
oldToNewNames.put("Pig", "minecraft:pig");
oldToNewNames.put("PigZombie", "minecraft:zombie_pigman");
oldToNewNames.put("PolarBear", "minecraft:polar_bear");
oldToNewNames.put("PrimedTnt", "minecraft:tnt");
oldToNewNames.put("Rabbit", "minecraft:rabbit");
oldToNewNames.put("Sheep", "minecraft:sheep");
oldToNewNames.put("Shulker", "minecraft:shulker");
oldToNewNames.put("ShulkerBullet", "minecraft:shulker_bullet");
oldToNewNames.put("Silverfish", "minecraft:silverfish");
oldToNewNames.put("Skeleton", "minecraft:skeleton");
oldToNewNames.put("SkeletonHorse", "minecraft:skeleton_horse");
oldToNewNames.put("Slime", "minecraft:slime");
oldToNewNames.put("SmallFireball", "minecraft:small_fireball");
oldToNewNames.put("Snowball", "minecraft:snowball");
oldToNewNames.put("SnowMan", "minecraft:snowman");
oldToNewNames.put("SpectralArrow", "minecraft:spectral_arrow");
oldToNewNames.put("Spider", "minecraft:spider");
oldToNewNames.put("Squid", "minecraft:squid");
oldToNewNames.put("Stray", "minecraft:stray");
oldToNewNames.put("ThrownEgg", "minecraft:egg");
oldToNewNames.put("ThrownEnderpearl", "minecraft:ender_pearl");
oldToNewNames.put("ThrownExpBottle", "minecraft:xp_bottle");
oldToNewNames.put("ThrownPotion", "minecraft:potion");
oldToNewNames.put("Villager", "minecraft:villager");
oldToNewNames.put("VillagerGolem", "minecraft:villager_golem");
oldToNewNames.put("Witch", "minecraft:witch");
oldToNewNames.put("WitherBoss", "minecraft:wither");
oldToNewNames.put("WitherSkeleton", "minecraft:wither_skeleton");
oldToNewNames.put("WitherSkull", "minecraft:wither_skull");
oldToNewNames.put("Wolf", "minecraft:wolf");
oldToNewNames.put("XPOrb", "minecraft:xp_orb");
oldToNewNames.put("Zombie", "minecraft:zombie");
oldToNewNames.put("ZombieHorse", "minecraft:zombie_horse");
oldToNewNames.put("ZombieVillager", "minecraft:zombie_villager");
}
public static void toClient(Item item) {
if (hasEntityTag(item)) {
CompoundTag entityTag = item.getTag().get("EntityTag");
if (entityTag.get("id") instanceof StringTag) {
StringTag id = entityTag.get("id");
id.setValue("minecraft:" + id.getValue().toLowerCase());
if (oldToNewNames.containsKey(id.getValue())) {
id.setValue(oldToNewNames.get(id.getValue()));
}
}
}
}
@@ -20,11 +104,9 @@ public class ItemRewriter {
CompoundTag entityTag = item.getTag().get("EntityTag");
if (entityTag.get("id") instanceof StringTag) {
StringTag id = entityTag.get("id");
String value = id.getValue().replaceAll("minecraft:", "");
if (value.length() > 1)
value = value.substring(0, 1).toUpperCase() + value.substring(1);
id.setValue(value);
if (oldToNewNames.inverse().containsKey(id.getValue())) {
id.setValue(oldToNewNames.inverse().get(id.getValue()));
}
}
}
}
@@ -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.
@@ -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
@@ -94,6 +94,7 @@ public class Protocol1_9TO1_8 extends Protocol {
providers.register(BulkChunkTranslatorProvider.class, new BulkChunkTranslatorProvider());
providers.register(CommandBlockProvider.class, new CommandBlockProvider());
providers.register(EntityIdProvider.class, new EntityIdProvider());
providers.register(BossBarProvider.class, new BossBarProvider());
providers.require(MovementTransmitterProvider.class);
if (Via.getConfig().isStimulatePlayerTick()) {
Via.getPlatform().runRepeatingSync(new ViaIdleThread(), 1L);
@@ -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);
@@ -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
@@ -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);
}
});
}
});
@@ -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);
}
}
});
@@ -0,0 +1,16 @@
package us.myles.ViaVersion.protocols.protocol1_9to1_8.providers;
import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.platform.providers.Provider;
import java.util.UUID;
public class BossBarProvider implements Provider {
public void handleAdd(UserConnection user, UUID barUUID) {
}
public void handleRemove(UserConnection user, UUID barUUID) {
}
}
@@ -24,6 +24,8 @@ 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.chat.GameMode;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.metadata.MetadataRewriter;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BossBarProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.BulkChunkTranslatorProvider;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.providers.EntityIdProvider;
import java.util.*;
@@ -51,6 +53,8 @@ public class EntityTracker extends StoredObject {
private boolean teamExists = false;
@Setter
private GameMode gameMode;
@Setter
private int mainHand;
public EntityTracker(UserConnection user) {
super(user);
@@ -93,6 +97,8 @@ public class EntityTracker extends StoredObject {
BossBar bar = bossBarMap.remove(entityID);
if (bar != null) {
bar.hide();
// Send to provider
Via.getManager().getProviders().get(BossBarProvider.class).handleRemove(getUser(), bar.getId());
}
}
@@ -201,6 +207,9 @@ public class EntityTracker extends StoredObject {
bossBarMap.put(entityID, bar);
bar.addPlayer(uuid);
bar.show();
// Send to provider
Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(getUser(), bar.getId());
} else {
bar.setTitle(title);
}
@@ -215,6 +224,8 @@ public class EntityTracker extends StoredObject {
bossBarMap.put(entityID, bar);
bar.addPlayer(uuid);
bar.show();
// Send to provider
Via.getManager().getProviders().get(BossBarProvider.class).handleAdd(getUser(), bar.getId());
} else {
bar.setHealth(health);
}
@@ -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;
}
+3
View File
@@ -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
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<name>viaversion-jar</name>
+4 -3
View File
@@ -6,7 +6,7 @@
<groupId>us.myles</groupId>
<artifactId>viaversion-parent</artifactId>
<version>1.0.0</version>
<version>1.0.4</version>
<packaging>pom</packaging>
<name>viaversion-parent</name>
@@ -65,6 +65,7 @@
<version>1.16.6</version>
<scope>provided</scope>
</dependency>
<!-- Javassist (Bytecode Library) -->
<dependency>
<groupId>org.javassist</groupId>
@@ -74,11 +75,11 @@
<optional>true</optional>
</dependency>
<!-- NBT Edit Library -->
<!-- OpenNBT Library -->
<dependency>
<groupId>org.spacehq</groupId>
<artifactId>opennbt</artifactId>
<version>1.0</version>
<version>1.1</version>
<scope>compile</scope>
<optional>true</optional>
</dependency>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
+1 -1
View File
@@ -5,7 +5,7 @@
<parent>
<artifactId>viaversion-parent</artifactId>
<groupId>us.myles</groupId>
<version>1.0.0</version>
<version>1.0.4</version>
</parent>
<modelVersion>4.0.0</modelVersion>
@@ -199,4 +199,9 @@ public class SpongePlugin implements ViaPlatform {
return platformSpecific;
}
@Override
public boolean isOldClientsAllowed() {
return true;
}
}
@@ -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);