From fdb613733901f811b7702208bf6a3fcafa11ee1b Mon Sep 17 00:00:00 2001 From: KennyTV Date: Mon, 13 Apr 2020 20:19:55 +0200 Subject: [PATCH] Create bukkit-legacy module for 1.8 magic method usage No real changes to the classes other than them being moved --- bukkit-legacy/pom.xml | 63 +++++++++++++++++++ .../bukkit/listeners/ViaBukkitListener.java | 10 +-- .../protocol1_9to1_8/ArmorListener.java | 11 +--- .../protocol1_9to1_8/BlockListener.java | 4 +- .../protocol1_9to1_8/DeathListener.java | 5 +- .../protocol1_9to1_8/HandItemCache.java | 1 + .../protocol1_9to1_8/PaperPatch.java | 4 +- .../BukkitBlockConnectionProvider.java | 0 bukkit/pom.xml | 10 ++- .../EntityToggleGlideListener.java | 6 +- pom.xml | 13 ++++ sponge-legacy/pom.xml | 7 --- sponge/pom.xml | 7 --- velocity/pom.xml | 7 --- 14 files changed, 104 insertions(+), 44 deletions(-) create mode 100644 bukkit-legacy/pom.xml rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java (84%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java (93%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java (91%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java (95%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java (99%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java (96%) rename {bukkit => bukkit-legacy}/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java (100%) diff --git a/bukkit-legacy/pom.xml b/bukkit-legacy/pom.xml new file mode 100644 index 000000000..1a3bcd718 --- /dev/null +++ b/bukkit-legacy/pom.xml @@ -0,0 +1,63 @@ + + + + viaversion-parent + us.myles + 3.0.0-SNAPSHOT + + 4.0.0 + + viaversion-bukkit-legacy + + + 1.8.8-R0.1-SNAPSHOT + + + + + + . + true + src/main/resources/ + + * + + + + + + + + + us.myles + viaversion-common + ${project.parent.version} + provided + + + + + org.bukkit + bukkit + ${bukkitVersion} + provided + true + + + junit + junit + + + gson + com.google.code.gson + + + persistence-api + javax.persistence + + + + + \ No newline at end of file diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java similarity index 84% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java index a94bca5d3..e49620bf3 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/ViaBukkitListener.java @@ -1,21 +1,17 @@ package us.myles.ViaVersion.bukkit.listeners; -import lombok.AccessLevel; -import lombok.Getter; import lombok.NonNull; import org.bukkit.entity.Player; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; -import us.myles.ViaVersion.ViaVersionPlugin; import us.myles.ViaVersion.api.ViaListener; import us.myles.ViaVersion.api.data.UserConnection; import us.myles.ViaVersion.api.protocol.Protocol; -@Getter(AccessLevel.PROTECTED) public class ViaBukkitListener extends ViaListener implements Listener { private final Plugin plugin; - public ViaBukkitListener(ViaVersionPlugin plugin, Class requiredPipeline) { + public ViaBukkitListener(Plugin plugin, Class requiredPipeline) { super(requiredPipeline); this.plugin = plugin; } @@ -50,4 +46,8 @@ public class ViaBukkitListener extends ViaListener implements Listener { plugin.getServer().getPluginManager().registerEvents(this, plugin); setRegistered(true); } + + public Plugin getPlugin() { + return plugin; + } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java similarity index 93% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java index ce6192f2b..19aecfd04 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/ArmorListener.java @@ -14,7 +14,7 @@ import org.bukkit.event.player.PlayerJoinEvent; import org.bukkit.event.player.PlayerRespawnEvent; import org.bukkit.inventory.CraftingInventory; import org.bukkit.inventory.ItemStack; -import us.myles.ViaVersion.ViaVersionPlugin; +import org.bukkit.plugin.Plugin; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.type.Type; @@ -28,7 +28,7 @@ public class ArmorListener extends ViaBukkitListener { private static final UUID ARMOR_ATTRIBUTE = UUID.fromString("2AD3F246-FEE1-4E67-B886-69FD380BB150"); - public ArmorListener(ViaVersionPlugin plugin) { + public ArmorListener(Plugin plugin) { super(plugin, Protocol1_9To1_8.class); } @@ -81,12 +81,7 @@ public class ArmorListener extends ViaBukkitListener { if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) { final Player player = e.getPlayer(); // Due to odd bugs it's 3 ticks later - Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable() { - @Override - public void run() { - sendArmorUpdate(player); - } - }, 3L); + Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), () -> sendArmorUpdate(player), 3L); } } } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java similarity index 91% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java index 613ac2034..51212c4ab 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/BlockListener.java @@ -4,7 +4,7 @@ import org.bukkit.block.Block; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent; -import us.myles.ViaVersion.ViaVersionPlugin; +import org.bukkit.plugin.Plugin; import us.myles.ViaVersion.api.minecraft.Position; import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; @@ -12,7 +12,7 @@ import us.myles.ViaVersion.protocols.protocol1_9to1_8.storage.EntityTracker1_9; public class BlockListener extends ViaBukkitListener { - public BlockListener(ViaVersionPlugin plugin) { + public BlockListener(Plugin plugin) { super(plugin, Protocol1_9To1_8.class); } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java similarity index 95% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java index 9182406a7..75df92843 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/DeathListener.java @@ -5,7 +5,7 @@ import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.entity.PlayerDeathEvent; -import us.myles.ViaVersion.ViaVersionPlugin; +import org.bukkit.plugin.Plugin; import us.myles.ViaVersion.api.PacketWrapper; import us.myles.ViaVersion.api.Via; import us.myles.ViaVersion.api.data.UserConnection; @@ -14,7 +14,8 @@ import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; public class DeathListener extends ViaBukkitListener { - public DeathListener(ViaVersionPlugin plugin) { + + public DeathListener(Plugin plugin) { super(plugin, Protocol1_9To1_8.class); } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java similarity index 99% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java index 0acf86965..11603c003 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/HandItemCache.java @@ -13,6 +13,7 @@ import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; public class HandItemCache extends BukkitRunnable { + private final Map handCache = new ConcurrentHashMap<>(); @Override diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java similarity index 96% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java index e4a3eb9bc..7281ed60f 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java +++ b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_9to1_8/PaperPatch.java @@ -6,13 +6,13 @@ import org.bukkit.block.BlockFace; import org.bukkit.event.EventHandler; import org.bukkit.event.EventPriority; import org.bukkit.event.block.BlockPlaceEvent; -import us.myles.ViaVersion.ViaVersionPlugin; +import org.bukkit.plugin.Plugin; import us.myles.ViaVersion.bukkit.listeners.ViaBukkitListener; import us.myles.ViaVersion.protocols.protocol1_9to1_8.Protocol1_9To1_8; public class PaperPatch extends ViaBukkitListener { - public PaperPatch(ViaVersionPlugin plugin) { + public PaperPatch(Plugin plugin) { super(plugin, Protocol1_9To1_8.class); } diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java b/bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java similarity index 100% rename from bukkit/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java rename to bukkit-legacy/src/main/java/us/myles/ViaVersion/bukkit/providers/BukkitBlockConnectionProvider.java diff --git a/bukkit/pom.xml b/bukkit/pom.xml index 2d096d4d0..d20aad9cb 100644 --- a/bukkit/pom.xml +++ b/bukkit/pom.xml @@ -13,7 +13,7 @@ - 1.12.2-R0.1-SNAPSHOT + 1.15.2-R0.1-SNAPSHOT @@ -60,5 +60,13 @@ + + + + us.myles + viaversion-bukkit-legacy + ${project.parent.version} + compile + diff --git a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java index 59122387d..f2171ef35 100644 --- a/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java +++ b/bukkit/src/main/java/us/myles/ViaVersion/bukkit/listeners/protocol1_15to1_14_4/EntityToggleGlideListener.java @@ -36,6 +36,7 @@ public class EntityToggleGlideListener extends ViaBukkitListener { packet.write(Type.VAR_INT, player.getEntityId()); byte bitmask = 0; + // Collect other metadata for the mitmask if (player.getFireTicks() > 0) { bitmask |= 0x01; } @@ -46,10 +47,9 @@ public class EntityToggleGlideListener extends ViaBukkitListener { if (player.isSprinting()) { bitmask |= 0x08; } - //TODO isswimming - /*if (player.isSprinting()) { + if (player.isSwimming()) { bitmask |= 0x10; - }*/ + } if (player.hasPotionEffect(PotionEffectType.INVISIBILITY)) { bitmask |= 0x20; } diff --git a/pom.xml b/pom.xml index cce6f4403..ddb54884d 100644 --- a/pom.xml +++ b/pom.xml @@ -18,6 +18,7 @@ common bukkit + bukkit-legacy bungee fabric sponge @@ -52,6 +53,18 @@ https://oss.sonatype.org/content/repositories/snapshots + + + velocity + https://repo.velocitypowered.com/snapshots + + + + + sponge + https://repo.spongepowered.org/maven + + viaversion-repo diff --git a/sponge-legacy/pom.xml b/sponge-legacy/pom.xml index 4b8400c32..149e777b5 100644 --- a/sponge-legacy/pom.xml +++ b/sponge-legacy/pom.xml @@ -12,13 +12,6 @@ viaversion-sponge-legacy jar - - - sponge - https://repo.spongepowered.org/maven - - - diff --git a/sponge/pom.xml b/sponge/pom.xml index 0ca5336ea..2fce07c34 100644 --- a/sponge/pom.xml +++ b/sponge/pom.xml @@ -11,13 +11,6 @@ viaversion-sponge - - - sponge - https://repo.spongepowered.org/maven - - - diff --git a/velocity/pom.xml b/velocity/pom.xml index 6dc467fa3..ccbb0ef36 100644 --- a/velocity/pom.xml +++ b/velocity/pom.xml @@ -11,13 +11,6 @@ viaversion-velocity - - - velocity - https://repo.velocitypowered.com/snapshots - - -