From 5f95c9edd1ab21557083ccd2b590822342e33325 Mon Sep 17 00:00:00 2001 From: FlorianMichael <60033407+FlorianMichael@users.noreply.github.com> Date: Tue, 2 Apr 2024 13:18:13 +0200 Subject: [PATCH] Rename feature classes to their actual functionality --- .../viarewind/legacysupport/BukkitPlugin.java | 63 ++++++++++--------- ...ener.java => AreaEffectCloudEmulator.java} | 4 +- ...xFixer.java => BlockCollisionChanges.java} | 2 +- ...ener.java => BlockPlaceSoundEmulator.java} | 8 +-- ...r.java => BrewingInteractionEmulator.java} | 2 +- ...tener.java => ElytraVelocityEmulator.java} | 2 +- ...stener.java => EnchantingGuiEmulator.java} | 4 +- ...Listener.java => SlimeBounceEmulator.java} | 2 +- 8 files changed, 44 insertions(+), 43 deletions(-) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{AreaEffectCloudListener.java => AreaEffectCloudEmulator.java} (96%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{BoundingBoxFixer.java => BlockCollisionChanges.java} (99%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{SoundListener.java => BlockPlaceSoundEmulator.java} (96%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{BrewingListener.java => BrewingInteractionEmulator.java} (98%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{ElytraListener.java => ElytraVelocityEmulator.java} (98%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{EnchantingListener.java => EnchantingGuiEmulator.java} (97%) rename src/main/java/com/viaversion/viarewind/legacysupport/feature/{BounceListener.java => SlimeBounceEmulator.java} (97%) diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/BukkitPlugin.java b/src/main/java/com/viaversion/viarewind/legacysupport/BukkitPlugin.java index 326337f..94fee9d 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/BukkitPlugin.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/BukkitPlugin.java @@ -18,15 +18,15 @@ package com.viaversion.viarewind.legacysupport; -import com.viaversion.viarewind.legacysupport.feature.BoundingBoxFixer; +import com.viaversion.viarewind.legacysupport.feature.BlockCollisionChanges; import com.viaversion.viarewind.legacysupport.versioninfo.VersionInformer; import com.viaversion.viaversion.api.Via; -import com.viaversion.viarewind.legacysupport.feature.AreaEffectCloudListener; -import com.viaversion.viarewind.legacysupport.feature.BounceListener; -import com.viaversion.viarewind.legacysupport.feature.BrewingListener; -import com.viaversion.viarewind.legacysupport.feature.ElytraListener; -import com.viaversion.viarewind.legacysupport.feature.EnchantingListener; -import com.viaversion.viarewind.legacysupport.feature.SoundListener; +import com.viaversion.viarewind.legacysupport.feature.AreaEffectCloudEmulator; +import com.viaversion.viarewind.legacysupport.feature.SlimeBounceEmulator; +import com.viaversion.viarewind.legacysupport.feature.BrewingInteractionEmulator; +import com.viaversion.viarewind.legacysupport.feature.ElytraVelocityEmulator; +import com.viaversion.viarewind.legacysupport.feature.EnchantingGuiEmulator; +import com.viaversion.viarewind.legacysupport.feature.BlockPlaceSoundEmulator; import com.viaversion.viaversion.api.protocol.version.ProtocolVersion; import org.bukkit.Bukkit; import org.bukkit.configuration.file.FileConfiguration; @@ -56,35 +56,36 @@ public void run() { cancel(); 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 (config.getBoolean("enchanting-gui-fix")) { + Bukkit.getPluginManager().registerEvents(new EnchantingGuiEmulator(), BukkitPlugin.this); + } + if (config.getBoolean("slime-fix")) { + Bukkit.getPluginManager().registerEvents(new SlimeBounceEmulator(), BukkitPlugin.this); + } } if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_9)) { - if (config.getBoolean("sound-fix")) - Bukkit.getPluginManager().registerEvents(new SoundListener(BukkitPlugin.this), BukkitPlugin.this); - - if (config.getBoolean("ladder-fix")) // 15w31a - BoundingBoxFixer.fixLadder(getLogger(), serverProtocol); - - if (config.getBoolean("area-effect-cloud-particles")) // 15w32c - Bukkit.getPluginManager().registerEvents(new AreaEffectCloudListener(BukkitPlugin.this), BukkitPlugin.this); - - if (config.getBoolean("elytra-fix")) // 15w40b - Bukkit.getPluginManager().registerEvents(new ElytraListener(), BukkitPlugin.this); - - if (config.getBoolean("brewing-stand-gui-fix")) // 15w41b - Bukkit.getPluginManager().registerEvents(new BrewingListener(), BukkitPlugin.this); - - if (config.getBoolean("lily-pad-fix")) // 15w44b - BoundingBoxFixer.fixLilyPad(getLogger(), serverProtocol); + if (config.getBoolean("sound-fix")) { + Bukkit.getPluginManager().registerEvents(new BlockPlaceSoundEmulator(BukkitPlugin.this), BukkitPlugin.this); + } + if (config.getBoolean("ladder-fix")) { // 15w31a + BlockCollisionChanges.fixLadder(getLogger(), serverProtocol); + } + if (config.getBoolean("area-effect-cloud-particles")) { // 15w32c + Bukkit.getPluginManager().registerEvents(new AreaEffectCloudEmulator(BukkitPlugin.this), BukkitPlugin.this); + } + if (config.getBoolean("elytra-fix")) { // 15w40b + Bukkit.getPluginManager().registerEvents(new ElytraVelocityEmulator(), BukkitPlugin.this); + } + if (config.getBoolean("brewing-stand-gui-fix")) { // 15w41b + Bukkit.getPluginManager().registerEvents(new BrewingInteractionEmulator(), BukkitPlugin.this); + } + if (config.getBoolean("lily-pad-fix")) { // 15w44b + BlockCollisionChanges.fixLilyPad(getLogger(), serverProtocol); + } } if (serverProtocol.newerThanOrEqualTo(ProtocolVersion.v1_14_4) && config.getBoolean("carpet-fix")) { - BoundingBoxFixer.fixCarpet(getLogger(), serverProtocol); + BlockCollisionChanges.fixCarpet(getLogger(), serverProtocol); } - if (config.getBoolean("versioninfo.active")) { new VersionInformer(BukkitPlugin.this, config); } diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudEmulator.java similarity index 96% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudEmulator.java index 9018100..ed99b93 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/AreaEffectCloudEmulator.java @@ -35,10 +35,10 @@ import java.util.stream.Collectors; @SuppressWarnings("unchecked") -public class AreaEffectCloudListener implements Listener { +public class AreaEffectCloudEmulator implements Listener { private final ArrayList effectClouds = new ArrayList<>(); - public AreaEffectCloudListener(final BukkitPlugin plugin) { + public AreaEffectCloudEmulator(final BukkitPlugin plugin) { Bukkit.getScheduler().runTaskTimer(plugin, () -> { final Set affectedPlayers = Bukkit.getOnlinePlayers().stream().filter(p -> Via.getAPI().getPlayerProtocolVersion(p).newerThanOrEqualTo(ProtocolVersion.v1_8)).collect(Collectors.toSet()); effectClouds.removeIf(e -> !e.isValid()); diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BoundingBoxFixer.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockCollisionChanges.java similarity index 99% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/BoundingBoxFixer.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockCollisionChanges.java index d665a66..8763803 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BoundingBoxFixer.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockCollisionChanges.java @@ -30,7 +30,7 @@ import static com.viaversion.viarewind.legacysupport.util.ReflectionUtil.*; import static com.viaversion.viarewind.legacysupport.util.NMSUtil.*; -public class BoundingBoxFixer { +public class BlockCollisionChanges { public static void fixLilyPad(final Logger logger, final ProtocolVersion serverVersion) { try { diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/SoundListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockPlaceSoundEmulator.java similarity index 96% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/SoundListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockPlaceSoundEmulator.java index 139ceba..e63a656 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/SoundListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BlockPlaceSoundEmulator.java @@ -43,7 +43,7 @@ import static com.viaversion.viarewind.legacysupport.util.NMSUtil.*; @SuppressWarnings("unchecked") -public class SoundListener implements Listener { +public class BlockPlaceSoundEmulator implements Listener { private static boolean isSoundCategory = false; @@ -55,7 +55,7 @@ public class SoundListener implements Listener { } } - public SoundListener(final BukkitPlugin plugin) { + public BlockPlaceSoundEmulator(final BukkitPlugin plugin) { try { Class.forName("org.bukkit.event.entity.EntityPickupItemEvent"); @@ -65,7 +65,7 @@ public SoundListener(final BukkitPlugin plugin) { public void onItemPickUp(EntityPickupItemEvent e) { if (!(e.getEntity() instanceof Player)) return; - SoundListener.this.onItemPickUp((Player) e.getEntity()); + BlockPlaceSoundEmulator.this.onItemPickUp((Player) e.getEntity()); } }, plugin); @@ -74,7 +74,7 @@ public void onItemPickUp(EntityPickupItemEvent e) { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onItemPickUp(PlayerPickupItemEvent e) { - SoundListener.this.onItemPickUp(e.getPlayer()); + BlockPlaceSoundEmulator.this.onItemPickUp(e.getPlayer()); } }, plugin); diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingInteractionEmulator.java similarity index 98% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingInteractionEmulator.java index f9cc184..8e97bb3 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/BrewingInteractionEmulator.java @@ -32,7 +32,7 @@ import org.bukkit.inventory.EquipmentSlot; import org.bukkit.inventory.ItemStack; -public class BrewingListener implements Listener { +public class BrewingInteractionEmulator implements Listener { @EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true) public void onPlayerInteract(PlayerInteractEvent e) { diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraVelocityEmulator.java similarity index 98% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraVelocityEmulator.java index ccbf27c..6d347de 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/ElytraVelocityEmulator.java @@ -28,7 +28,7 @@ import org.bukkit.util.Vector; @SuppressWarnings("unchecked") -public class ElytraListener implements Listener { +public class ElytraVelocityEmulator implements Listener { @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true) public void onPlayerMove(PlayerMoveEvent e) { diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingGuiEmulator.java similarity index 97% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingGuiEmulator.java index 4f8b442..9c6c1ca 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/EnchantingGuiEmulator.java @@ -34,12 +34,12 @@ import java.util.Map; @SuppressWarnings("unchecked") -public class EnchantingListener implements Listener { +public class EnchantingGuiEmulator implements Listener { private final boolean newMaterialNames; private final Material lapisMaterial; - public EnchantingListener() { + public EnchantingGuiEmulator() { newMaterialNames = Material.getMaterial("LAPIS_LAZULI") != null; if (newMaterialNames) { diff --git a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BounceListener.java b/src/main/java/com/viaversion/viarewind/legacysupport/feature/SlimeBounceEmulator.java similarity index 97% rename from src/main/java/com/viaversion/viarewind/legacysupport/feature/BounceListener.java rename to src/main/java/com/viaversion/viarewind/legacysupport/feature/SlimeBounceEmulator.java index 85fcf71..5da943e 100644 --- a/src/main/java/com/viaversion/viarewind/legacysupport/feature/BounceListener.java +++ b/src/main/java/com/viaversion/viarewind/legacysupport/feature/SlimeBounceEmulator.java @@ -29,7 +29,7 @@ import org.bukkit.util.Vector; @SuppressWarnings({"unchecked", "DataFlowIssue"}) -public class BounceListener implements Listener { +public class SlimeBounceEmulator implements Listener { @EventHandler public void onPlayerMove(PlayerMoveEvent e) {