Merge branch 'master' into dev

This commit is contained in:
Myles 2019-01-12 17:42:47 +00:00
commit 77a57d2243
10 changed files with 102 additions and 27 deletions

View File

@ -234,4 +234,14 @@ public class BukkitViaConfig extends Config implements ViaVersionConfig {
public boolean isReduceBlockStorageMemory() { public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false); return getBoolean("reduce-blockstorage-memory", false);
} }
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
} }

View File

@ -287,4 +287,14 @@ public class BungeeViaConfig extends Config implements ViaVersionConfig {
public boolean isReduceBlockStorageMemory() { public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false); return getBoolean("reduce-blockstorage-memory", false);
} }
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
} }

View File

@ -287,4 +287,19 @@ public interface ViaVersionConfig {
* @return True if enabled * @return True if enabled
*/ */
boolean isReduceBlockStorageMemory(); boolean isReduceBlockStorageMemory();
/**
* When activated with serverside-blockconnections, flower parts with blocks above will be sent as stems.
* Useful for lobbyservers where users can't build and those stems are used decoratively.
*
* @return True if enabled
*/
boolean isStemWhenBlockAbove();
/**
* When activated, the 1-layer snow will be sent as 2-layer snow to 1.13+ clients to have collision.
*
* @return True if enabled
*/
boolean isSnowCollisionFix();
} }

View File

@ -1,5 +1,6 @@
package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections; package us.myles.ViaVersion.protocols.protocol1_13to1_12_2.blockconnections;
import us.myles.ViaVersion.api.Via;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.api.minecraft.BlockFace; import us.myles.ViaVersion.api.minecraft.BlockFace;
import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.api.minecraft.Position;
@ -11,10 +12,10 @@ import java.util.Set;
public class FlowerConnectionHandler extends ConnectionHandler { public class FlowerConnectionHandler extends ConnectionHandler {
private static Set<String> baseFlower = new HashSet<>();
private static Map<Integer, Integer> flowers = new HashMap<>(); private static Map<Integer, Integer> flowers = new HashMap<>();
static void init() { static void init() {
Set<String> baseFlower = new HashSet<>();
baseFlower.add("minecraft:rose_bush"); baseFlower.add("minecraft:rose_bush");
baseFlower.add("minecraft:sunflower"); baseFlower.add("minecraft:sunflower");
baseFlower.add("minecraft:peony"); baseFlower.add("minecraft:peony");
@ -22,9 +23,7 @@ public class FlowerConnectionHandler extends ConnectionHandler {
baseFlower.add("minecraft:large_fern"); baseFlower.add("minecraft:large_fern");
baseFlower.add("minecraft:lilac"); baseFlower.add("minecraft:lilac");
FlowerConnectionHandler handler = new FlowerConnectionHandler(); FlowerConnectionHandler handler = new FlowerConnectionHandler();
for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) { for (Map.Entry<String, Integer> blockState : ConnectionData.keyToId.entrySet()) {
WrappedBlockData data = WrappedBlockData.fromString(blockState.getKey()); WrappedBlockData data = WrappedBlockData.fromString(blockState.getKey());
if (baseFlower.contains(data.getMinecraftKey())) { if (baseFlower.contains(data.getMinecraftKey())) {
@ -40,9 +39,16 @@ public class FlowerConnectionHandler extends ConnectionHandler {
@Override @Override
public int connect(UserConnection user, Position position, int blockState) { public int connect(UserConnection user, Position position, int blockState) {
int blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM)); int blockBelowId = getBlockData(user, position.getRelative(BlockFace.BOTTOM));
if (flowers.containsKey(blockBelowId) && !flowers.containsKey(getBlockData(user, position.getRelative(BlockFace.TOP)))) { if (flowers.containsKey(blockBelowId)) {
int blockAboveId = getBlockData(user, position.getRelative(BlockFace.TOP));
if (Via.getConfig().isStemWhenBlockAbove()) {
if (blockAboveId == 0) {
return flowers.get(blockBelowId); return flowers.get(blockBelowId);
} }
} else if (!flowers.containsKey(blockAboveId)) {
return flowers.get(blockBelowId);
}
}
return blockState; return blockState;
} }
} }

View File

@ -195,6 +195,10 @@ public class MappingData {
private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) { private BlockMappingsShortArray(JsonObject mapping1_12, JsonObject mapping1_13) {
Arrays.fill(oldToNew, (short) -1); Arrays.fill(oldToNew, (short) -1);
mapIdentifiers(oldToNew, mapping1_12, mapping1_13); mapIdentifiers(oldToNew, mapping1_12, mapping1_13);
// Map minecraft:snow[layers=1] of 1.12 to minecraft:snow[layers=2] in 1.13
if (Via.getConfig().isSnowCollisionFix()) {
oldToNew[1248] = 3416;
}
} }
@Override @Override

View File

@ -114,9 +114,21 @@ team-colour-fix: true
suppress-1_13-conversion-errors: false suppress-1_13-conversion-errors: false
# 1.13 introduced new auto complete which can trigger "Kicked for spamming" for servers older than 1.13, the following option will disable it completely. # 1.13 introduced new auto complete which can trigger "Kicked for spamming" for servers older than 1.13, the following option will disable it completely.
disable-1_13-auto-complete: false disable-1_13-auto-complete: false
# For 1.13 clients the smallest (1 layer) snow doesn't have collision, this will send these as 2 snowlayers for 1.13+ clients to prevent them bugging through them
fix-low-snow-collision: false
#
# Enable serverside block-connections for 1.13+ clients
serverside-blockconnections: false
# Sets the method for the block connections (world for world-level or packet for packet-level)
blockconnection-method: world
# When activated, only the most important blocks are stored in the blockstorage. (fences, glass panes etc. won't connect to solid blocks)
reduce-blockstorage-memory: false
# When activated with serverside-blockconnections, flower parts with blocks above will be sent as stems
# Useful for lobbyservers where users can't build and those stems are used decoratively
flowerstem-when-block-above: false
# #
#----------------------------------------------------------# #----------------------------------------------------------#
# 1.9 & 1.10 CLIENTS ON 1.8 SERVERS OPTIONS # # 1.9+ CLIENTS ON 1.8 SERVERS OPTIONS #
#----------------------------------------------------------# #----------------------------------------------------------#
# #
# No collide options, these allow you to configure how collision works. # No collide options, these allow you to configure how collision works.
@ -126,7 +138,7 @@ prevent-collision: true
auto-team: true auto-team: true
# When enabled if certain metadata can't be read we won't tell you about it # When enabled if certain metadata can't be read we won't tell you about it
suppress-metadata-errors: false suppress-metadata-errors: false
# When enabled 1.9 & 1.10 will be able to block by using shields # When enabled 1.9+ will be able to block by using shields
shield-blocking: true shield-blocking: true
# Enable player tick simulation, this fixes eating, drinking, nether portals. # Enable player tick simulation, this fixes eating, drinking, nether portals.
simulate-pt: true simulate-pt: true
@ -134,15 +146,15 @@ simulate-pt: true
nms-player-ticking: true nms-player-ticking: true
# Should we patch boss bars so they work? (Default: true, disable if you're having issues) # Should we patch boss bars so they work? (Default: true, disable if you're having issues)
bossbar-patch: true bossbar-patch: true
# If your boss bar flickers on 1.9 & 1.10, set this to 'true'. It will keep all boss bars on 100% (not recommended) # If your boss bar flickers on 1.9+, set this to 'true'. It will keep all boss bars on 100% (not recommended)
bossbar-anti-flicker: false bossbar-anti-flicker: false
# This will show the new effect indicator in the top-right corner for 1.9 & 1.10 players. # This will show the new effect indicator in the top-right corner for 1.9+ players.
use-new-effect-indicator: true use-new-effect-indicator: true
# Show the new death messages for 1.9 & 1.10 on the death screen # Show the new death messages for 1.9+ on the death screen
use-new-deathmessages: true use-new-deathmessages: true
# Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items # Should we cache our items, this will prevent server from being lagged out, however the cost is a constant task caching items
item-cache: true item-cache: true
# Patch the Anti xray to work on 1.9 & 1.10 (If your server is 1.8) This can cost more performance, so disable it if you don't use it. # Patch the anti xray to work on 1.9+ (If your server is 1.8) This can cost more performance, so disable it if you don't use it.
anti-xray-patch: true anti-xray-patch: true
# Should we replace extended pistons to fix 1.10.1 (Only on chunk load) # Should we replace extended pistons to fix 1.10.1 (Only on chunk load)
replace-pistons: false replace-pistons: false
@ -152,9 +164,3 @@ replacement-piston-id: 0
force-json-transform: false force-json-transform: false
# Minimize the cooldown animation in 1.8 servers # Minimize the cooldown animation in 1.8 servers
minimize-cooldown: true minimize-cooldown: true
# Enable serverside block-connections for 1.13+ clients
serverside-blockconnections: false
# Sets the method for the block connections (world for world-level or packet for packet-level)
blockconnection-method: world
# When activated, only the most important blocks are stored in the blockstorage. (fences, glass panes etc. won't connect to solid blocks)
reduce-blockstorage-memory: false

View File

@ -240,4 +240,14 @@ public class SpongeViaConfig extends Config implements ViaVersionConfig {
public boolean isReduceBlockStorageMemory() { public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false); return getBoolean("reduce-blockstorage-memory", false);
} }
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
} }

View File

@ -14,7 +14,6 @@ import us.myles.ViaVersion.api.protocol.ProtocolPipeline;
import us.myles.ViaVersion.api.protocol.ProtocolRegistry; import us.myles.ViaVersion.api.protocol.ProtocolRegistry;
import us.myles.ViaVersion.protocols.base.ProtocolInfo; import us.myles.ViaVersion.protocols.base.ProtocolInfo;
import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker; import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker;
import us.myles.ViaVersion.util.ReflectionUtil;
import us.myles.ViaVersion.velocity.service.ProtocolDetectorService; import us.myles.ViaVersion.velocity.service.ProtocolDetectorService;
import us.myles.ViaVersion.velocity.storage.VelocityStorage; import us.myles.ViaVersion.velocity.storage.VelocityStorage;
@ -26,6 +25,8 @@ import java.util.concurrent.Semaphore;
public class VelocityServerHandler { public class VelocityServerHandler {
private static Method setProtocolVersion; private static Method setProtocolVersion;
private static Method setNextProtocolVersion; private static Method setNextProtocolVersion;
private static Method getMinecraftConnection;
private static Method getNextProtocolVersion;
static { static {
try { try {
@ -33,6 +34,10 @@ public class VelocityServerHandler {
.getDeclaredMethod("setProtocolVersion", ProtocolVersion.class); .getDeclaredMethod("setProtocolVersion", ProtocolVersion.class);
setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection") setNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
.getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class); .getDeclaredMethod("setNextProtocolVersion", ProtocolVersion.class);
getMinecraftConnection = Class.forName("com.velocitypowered.proxy.connection.client.ConnectedPlayer")
.getDeclaredMethod("getMinecraftConnection");
getNextProtocolVersion = Class.forName("com.velocitypowered.proxy.connection.MinecraftConnection")
.getDeclaredMethod("getNextProtocolVersion");
} catch (NoSuchMethodException | ClassNotFoundException e) { } catch (NoSuchMethodException | ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -51,12 +56,12 @@ public class VelocityServerHandler {
List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.get(ProtocolInfo.class).getProtocolVersion(), protocolId); List<Pair<Integer, Protocol>> protocols = ProtocolRegistry.getProtocolPath(user.get(ProtocolInfo.class).getProtocolVersion(), protocolId);
// Check if ViaVersion can support that version // Check if ViaVersion can support that version
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection"); Object connection = getMinecraftConnection.invoke(e.getPlayer());
setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null setNextProtocolVersion.invoke(connection, ProtocolVersion.getProtocolVersion(protocols == null
? user.get(ProtocolInfo.class).getProtocolVersion() ? user.get(ProtocolInfo.class).getProtocolVersion()
: protocolId)); : protocolId));
} catch (IllegalAccessException | NoSuchMethodException | InvocationTargetException e1) { } catch (IllegalAccessException | InvocationTargetException e1) {
e1.printStackTrace(); e1.printStackTrace();
} }
} }
@ -132,8 +137,8 @@ public class VelocityServerHandler {
protocol.init(user); protocol.init(user);
} }
Object connection = ReflectionUtil.invoke(e.getPlayer(), "getConnection"); Object connection = getMinecraftConnection.invoke(e.getPlayer());
ProtocolVersion version = (ProtocolVersion) ReflectionUtil.invoke(connection, "getNextProtocolVersion"); ProtocolVersion version = (ProtocolVersion) getNextProtocolVersion.invoke(connection);
setProtocolVersion.invoke(connection, version); setProtocolVersion.invoke(connection, version);
} }
} }

View File

@ -292,4 +292,14 @@ public class VelocityViaConfig extends Config implements ViaVersionConfig {
public boolean isReduceBlockStorageMemory() { public boolean isReduceBlockStorageMemory() {
return getBoolean("reduce-blockstorage-memory", false); return getBoolean("reduce-blockstorage-memory", false);
} }
@Override
public boolean isStemWhenBlockAbove() {
return getBoolean("flowerstem-when-block-above", false);
}
@Override
public boolean isSnowCollisionFix() {
return getBoolean("fix-low-snow-collision", false);
}
} }

View File

@ -5,9 +5,7 @@ import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import us.myles.ViaVersion.api.data.StoredObject; import us.myles.ViaVersion.api.data.StoredObject;
import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.data.UserConnection;
import us.myles.ViaVersion.util.ReflectionUtil;
import java.lang.reflect.InvocationTargetException;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
@ -24,15 +22,16 @@ public class VelocityStorage extends StoredObject {
this.currentServer = ""; this.currentServer = "";
// Get bossbar list if it's supported // Get bossbar list if it's supported
/* TODO make this work - do we need this?
try { try {
Object connection = ReflectionUtil.invoke(player, "getConnection"); Object connection = ReflectionUtil.invoke(player, "getConnection");
Object sessionHandler = ReflectionUtil.invoke(connection, "getSessionHandler"); Object sessionHandler = ReflectionUtil.invoke(connection, "getSessionHandler");
if (sessionHandler.getClass().getSimpleName().contains("Play")) { if (sessionHandler.getClass().getSimpleName().contains("Play")) {
bossbar = (Set<UUID>) ReflectionUtil.invoke(sessionHandler, "getServerBossBars"); bossbar = (Set<UUID>) ReflectionUtil.invoke(sessionHandler, "getServerBossBars");
// TODO make this work
} }
} catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) { } catch (NoSuchMethodException | InvocationTargetException | IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
*/
} }
} }