mirror of
https://github.com/ViaVersion/ViaRewind-Legacy-Support.git
synced 2025-01-09 19:17:34 +01:00
Merge master changes
This commit is contained in:
parent
99cf5cddf9
commit
74ad92d944
@ -23,7 +23,7 @@ version = project.maven_version
|
||||
group = project.maven_group
|
||||
|
||||
dependencies {
|
||||
compileOnly "com.viaversion:viaversion-api:4.9.3"
|
||||
compileOnly "com.viaversion:viaversion-api:4.10.0-24w09a-SNAPSHOT"
|
||||
compileOnly "org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT"
|
||||
}
|
||||
|
||||
|
@ -49,18 +49,18 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
final int serverProtocol = Via.getAPI().getServerVersion().lowestSupportedVersion();
|
||||
if (serverProtocol == -1) return;
|
||||
final ProtocolVersion serverProtocol = Via.getAPI().getServerVersion().lowestSupportedProtocolVersion();
|
||||
if (!serverProtocol.isKnown()) return;
|
||||
cancel();
|
||||
|
||||
if (serverProtocol >= ProtocolVersion.v1_8.getVersion()) {
|
||||
if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_8)) {
|
||||
if (config.getBoolean("enchanting-gui-fix"))
|
||||
Bukkit.getPluginManager().registerEvents(new EnchantingListener(), BukkitPlugin.this);
|
||||
|
||||
if (config.getBoolean("slime-fix"))
|
||||
Bukkit.getPluginManager().registerEvents(new BounceListener(), BukkitPlugin.this);
|
||||
}
|
||||
if (serverProtocol >= ProtocolVersion.v1_9.getVersion()) {
|
||||
if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_9)) {
|
||||
if (config.getBoolean("sound-fix"))
|
||||
Bukkit.getPluginManager().registerEvents(new SoundListener(BukkitPlugin.this), BukkitPlugin.this);
|
||||
|
||||
@ -79,7 +79,7 @@ public class BukkitPlugin extends JavaPlugin {
|
||||
if (config.getBoolean("lily-pad-fix")) // 15w44b
|
||||
BoundingBoxFixer.fixLilyPad(getLogger(), serverProtocol);
|
||||
}
|
||||
if (serverProtocol >= ProtocolVersion.v1_14_4.getVersion() && config.getBoolean("carpet-fix")) {
|
||||
if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_14_4) && config.getBoolean("carpet-fix")) {
|
||||
BoundingBoxFixer.fixCarpet(getLogger(), serverProtocol);
|
||||
}
|
||||
|
||||
|
@ -30,10 +30,9 @@ import java.util.logging.Logger;
|
||||
|
||||
public class BoundingBoxFixer {
|
||||
|
||||
public static void fixLilyPad(final Logger logger, final int serverVersion) {
|
||||
public static void fixLilyPad(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(NMSReflection.getNMSBlock("BlockWaterLily"),
|
||||
serverVersion <= ProtocolVersion.v1_20_2.getVersion() ? "a" : "b");
|
||||
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(NMSReflection.getNMSBlock("BlockWaterLily"), serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2) ? "a" : "b");
|
||||
|
||||
setBoundingBox(boundingBoxField.get(null), 0.0625, 0.0, 0.0625, 0.9375, 0.015625, 0.9375);
|
||||
} catch (Exception ex) {
|
||||
@ -41,23 +40,23 @@ public class BoundingBoxFixer {
|
||||
}
|
||||
}
|
||||
|
||||
public static void fixCarpet(final Logger logger, final int serverVersion) {
|
||||
public static void fixCarpet(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final Class<?> blockCarpetClass = serverVersion <= ProtocolVersion.v1_16_4.getVersion() ? NMSReflection.getNMSBlock("BlockCarpet") : NMSReflection.getNMSBlock("CarpetBlock");
|
||||
final Class<?> blockCarpetClass = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_16_4) ? NMSReflection.getNMSBlock("BlockCarpet") : NMSReflection.getNMSBlock("CarpetBlock");
|
||||
|
||||
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(blockCarpetClass, serverVersion <= ProtocolVersion.v1_20_2.getVersion() ? "a" : "b");
|
||||
final Field boundingBoxField = ReflectionAPI.getFieldAccessible(blockCarpetClass, serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2) ? "a" : "b");
|
||||
setBoundingBox(boundingBoxField.get(0), 0.0D, -0.0000001D, 0.0D, 1.0D, 0.0000001D, 1.0D);
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, "Could not fix carpet bounding box.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void fixLadder(final Logger logger, final int serverVersion) {
|
||||
public static void fixLadder(final Logger logger, final ProtocolVersion serverVersion) {
|
||||
try {
|
||||
final boolean pre1_12_2 = serverVersion <= ProtocolVersion.v1_12_2.getVersion();
|
||||
final boolean pre1_13_2 = serverVersion <= ProtocolVersion.v1_13_2.getVersion();
|
||||
final boolean pre1_16_4 = serverVersion <= ProtocolVersion.v1_16_4.getVersion();
|
||||
final boolean pre1_20_2 = serverVersion <= ProtocolVersion.v1_20_2.getVersion();
|
||||
final boolean pre1_12_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_12_2);
|
||||
final boolean pre1_13_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_13_2);
|
||||
final boolean pre1_16_4 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_16_4);
|
||||
final boolean pre1_20_2 = serverVersion.olderThanOrEqualTo(ProtocolVersion.v1_20_2);
|
||||
|
||||
final Class<?> blockLadderClass = NMSReflection.getNMSBlock("BlockLadder");
|
||||
|
||||
|
@ -41,7 +41,7 @@ public class AreaEffectCloudListener implements Listener {
|
||||
|
||||
public AreaEffectCloudListener(final BukkitPlugin plugin) {
|
||||
Bukkit.getScheduler().runTaskTimer(plugin, () -> {
|
||||
final Set<Player> affectedPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> Via.getAPI().getPlayerVersion(p) >= ProtocolVersion.v1_8.getVersion()).collect(Collectors.toSet());
|
||||
final Set<Player> affectedPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> Via.getAPI().getPlayerProtocolVersion(p).newerThanOrEqualTo(ProtocolVersion.v1_8)).collect(Collectors.toSet());
|
||||
effectClouds.removeIf(e -> !e.isValid());
|
||||
effectClouds.forEach(cloud -> {
|
||||
final Location location = cloud.getLocation();
|
||||
|
@ -36,7 +36,7 @@ public class BounceListener implements Listener {
|
||||
if (e.getTo().getY() >= e.getFrom().getY()) return; // Only check upwards motion
|
||||
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerVersion(player) >= ProtocolVersion.v1_8.getVersion()) return; // Only apply for 1.7 and below players
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_8)) return; // Only apply for 1.7 and below players
|
||||
|
||||
if (Math.floor(e.getTo().getY()) + 0.01 < e.getTo().getY()) return;
|
||||
if (player.isSneaking()) return;
|
||||
|
@ -38,8 +38,8 @@ public class BrewingListener implements Listener {
|
||||
public void onPlayerInteract(PlayerInteractEvent e) {
|
||||
if (!e.hasBlock() || e.getClickedBlock().getType() != Material.BREWING_STAND) return;
|
||||
Player player = e.getPlayer();
|
||||
int version = Via.getAPI().getPlayerVersion(player);
|
||||
if (version > ProtocolVersion.v1_9.getVersion()) return;
|
||||
ProtocolVersion version = Via.getAPI().getPlayerProtocolVersion(player);
|
||||
if (version.newerThan(ProtocolVersion.v1_9)) return;
|
||||
ItemStack blazePowder = new ItemStack(Material.BLAZE_POWDER);
|
||||
ItemStack playerItem = e.getItem();
|
||||
if (playerItem == null) playerItem = new ItemStack(Material.AIR);
|
||||
|
@ -34,7 +34,7 @@ public class ElytraListener implements Listener {
|
||||
public void onPlayerMove(PlayerMoveEvent e) {
|
||||
final Player player = e.getPlayer();
|
||||
|
||||
if (Via.getAPI().getPlayerVersion(player) >= ProtocolVersion.v1_9.getVersion()) return; // Only apply for 1.8 and below players
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_9)) return; // Only apply for 1.8 and below players
|
||||
if (!player.isGliding()) return; // Only apply if the player is gliding
|
||||
|
||||
final Vector direction = player.getLocation().getDirection();
|
||||
|
@ -54,7 +54,7 @@ public class EnchantingListener implements Listener {
|
||||
if (!(e.getInventory() instanceof EnchantingInventory)) return;
|
||||
|
||||
final Player player = (Player) e.getPlayer();
|
||||
if (Via.getAPI().getPlayerVersion(player) >= ProtocolVersion.v1_8.getVersion()) return;
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_8)) return;
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final ItemStack lapis = newMaterialNames ? new ItemStack(lapisMaterial) : new ItemStack(lapisMaterial, 1, (short) 4);
|
||||
@ -89,7 +89,7 @@ public class EnchantingListener implements Listener {
|
||||
if (!(e.getInventory() instanceof EnchantingInventory)) return;
|
||||
|
||||
final Player player = (Player) e.getPlayer();
|
||||
if (Via.getAPI().getPlayerVersion(player) >= ProtocolVersion.v1_8.getVersion()) return;
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_8)) return;
|
||||
|
||||
final PlayerInventory inv = player.getInventory();
|
||||
final EnchantingInventory replacement = (EnchantingInventory) e.getInventory();
|
||||
|
@ -84,9 +84,9 @@ public class SoundListener implements Listener {
|
||||
@EventHandler
|
||||
public void onBlockPlace(BlockPlaceEvent e) {
|
||||
final Player player = e.getPlayer();
|
||||
if (Via.getAPI().getPlayerVersion(player) >= ProtocolVersion.v1_9.getVersion()) return;
|
||||
if (Via.getAPI().getPlayerProtocolVersion(player).newerThanOrEqualTo(ProtocolVersion.v1_9)) return;
|
||||
|
||||
if (Via.getAPI().getServerVersion().lowestSupportedVersion() >= ProtocolVersion.v1_17.getVersion()) {
|
||||
if (Via.getAPI().getServerVersion().lowestSupportedProtocolVersion().newerThanOrEqualTo(ProtocolVersion.v1_17)) {
|
||||
player.playSound(e.getBlockPlaced().getLocation(), e.getBlock().getBlockData().getSoundGroup().getPlaceSound(), 1.0f, 0.8f);
|
||||
} else {
|
||||
try {
|
||||
|
Loading…
Reference in New Issue
Block a user