From b6c575c002047512d6f11bdbf86fcc9d0ce94c69 Mon Sep 17 00:00:00 2001 From: singh Date: Sat, 8 Jun 2024 00:28:51 +0530 Subject: [PATCH] [Added] 1.20.6 Support [Updated] Some NMS changes. [Fixed] LaggSpike on 1.20.6 on start due to a deprecated method. --- EpicHoppers-API/pom.xml | 2 +- EpicHoppers-Plugin/pom.xml | 22 ++++++++++++++----- .../hopper/levels/LevelManagerImpl.java | 4 ++-- .../hopper/levels/modules/ModuleSuction.java | 1 - .../listeners/HopperListeners.java | 6 ++--- .../craftaro/epichoppers/tasks/HopTask.java | 19 +++++++++++----- .../epichoppers/utils/HopperDirection.java | 2 +- pom.xml | 2 +- 8 files changed, 38 insertions(+), 20 deletions(-) diff --git a/EpicHoppers-API/pom.xml b/EpicHoppers-API/pom.xml index 959e033..bcd0713 100644 --- a/EpicHoppers-API/pom.xml +++ b/EpicHoppers-API/pom.xml @@ -63,7 +63,7 @@ org.spigotmc spigot-api - 1.18-R0.1-SNAPSHOT + 1.20.6-R0.1-SNAPSHOT provided diff --git a/EpicHoppers-Plugin/pom.xml b/EpicHoppers-Plugin/pom.xml index 641d180..3ec0f3b 100644 --- a/EpicHoppers-Plugin/pom.xml +++ b/EpicHoppers-Plugin/pom.xml @@ -56,10 +56,10 @@ false **/nms/v*/** + **/third_party/net/kyori/** **/third_party/org/apache/** - **/third_party/net/kyori/** **/third_party/com/zaxxer/** **/third_party/org/jooq/** **/third_party/org/mariadb/** @@ -95,6 +95,16 @@ https://repo.songoda.com/repository/public/ + + bg-repo + https://repo.bg-software.com/repository/api/ + + + + songoda-public + https://repo.songoda.com/repository/minecraft-plugins/ + + jitpack.io https://jitpack.io/ @@ -119,21 +129,21 @@ org.spigotmc spigot-api - 1.19.4-R0.1-SNAPSHOT + 1.20.4-R0.1-SNAPSHOT provided com.craftaro FabledSkyBlock - 3.0.4 + 3.0.8-SNAPSHOT provided com.craftaro EpicFarming - 4.1.1 + 4.2.1-SNAPSHOT provided @@ -160,8 +170,8 @@ com.bgsoftware - wildstacker - 3.5.1 + WildStackerAPI + 2024.1 provided diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/LevelManagerImpl.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/LevelManagerImpl.java index 99ac8f3..e9d9e97 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/LevelManagerImpl.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/LevelManagerImpl.java @@ -1,6 +1,6 @@ package com.craftaro.epichoppers.hopper.levels; -import com.craftaro.core.nms.NmsManager; +import com.craftaro.core.nms.Nms; import com.craftaro.core.nms.nbt.NBTCore; import com.craftaro.core.third_party.de.tr7zw.nbtapi.NBTItem; import com.craftaro.epichoppers.hopper.levels.modules.Module; @@ -45,7 +45,7 @@ public class LevelManagerImpl implements LevelManager { @Override public boolean isEpicHopper(ItemStack item) { - NBTCore nbt = NmsManager.getNbt(); + NBTCore nbt = Nms.getImplementations().getNbt(); if (nbt.of(item).has("level")) { return true; diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/modules/ModuleSuction.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/modules/ModuleSuction.java index 5e7d801..8cc4af3 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/modules/ModuleSuction.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/hopper/levels/modules/ModuleSuction.java @@ -8,7 +8,6 @@ import com.craftaro.core.locale.Locale; import com.craftaro.third_party.com.cryptomorin.xseries.XMaterial; import com.craftaro.core.utils.TextUtils; import com.craftaro.epichoppers.hopper.Hopper; -import com.craftaro.epichoppers.hopper.HopperImpl; import com.craftaro.epichoppers.settings.Settings; import com.craftaro.epichoppers.utils.Methods; import com.craftaro.epichoppers.utils.StorageContainerCache; diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/listeners/HopperListeners.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/listeners/HopperListeners.java index 321cc9d..13b064b 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/listeners/HopperListeners.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/listeners/HopperListeners.java @@ -1,7 +1,7 @@ package com.craftaro.epichoppers.listeners; import com.craftaro.core.compatibility.ServerVersion; -import com.craftaro.core.nms.NmsManager; +import com.craftaro.core.nms.Nms; import com.craftaro.epichoppers.hopper.HopperImpl; import com.craftaro.epichoppers.settings.Settings; import com.craftaro.epichoppers.EpicHoppers; @@ -140,12 +140,12 @@ public class HopperListeners implements Listener { // we need to instead cancel and manually remove the item to move source.removeItem(moveInstead); if (sourceLocation != null) { - NmsManager.getWorld().updateAdjacentComparators(sourceLocation.getBlock()); + Nms.getImplementations().getWorld().updateAdjacentComparators(sourceLocation.getBlock()); } // now add it to the hopper destination.addItem(moveInstead); if (destinationLocation != null) { - NmsManager.getWorld().updateAdjacentComparators(destinationLocation.getBlock()); + Nms.getImplementations().getWorld().updateAdjacentComparators(destinationLocation.getBlock()); } } return; diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/tasks/HopTask.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/tasks/HopTask.java index 5edd321..7750547 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/tasks/HopTask.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/tasks/HopTask.java @@ -1,7 +1,7 @@ package com.craftaro.epichoppers.tasks; +import com.craftaro.core.compatibility.ServerVersion; import com.craftaro.epichoppers.boost.BoostData; -import com.craftaro.epichoppers.boost.BoostDataImpl; import com.craftaro.epichoppers.containers.CustomContainer; import com.craftaro.epichoppers.hopper.HopperImpl; import com.craftaro.epichoppers.hopper.levels.modules.ModuleAutoCrafting; @@ -18,6 +18,7 @@ import org.bukkit.OfflinePlayer; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.block.Hopper; +import org.bukkit.block.data.Directional; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; import org.bukkit.entity.Minecart; @@ -81,11 +82,19 @@ public class HopTask extends BukkitRunnable { int maxToMove = hopper.getLevel().getAmount() * (boostData == null ? 1 : boostData.getMultiplier()); // Get hopper state data. - Hopper hopperState = (Hopper) block.getState(); - HopperDirection hopperDirection = HopperDirection.getDirection(hopperState.getRawData()); - Location pointingLocation = hopperDirection.getLocation(location); + HopperDirection hopperDirection; + Location pointingLocation; + if (ServerVersion.isServerVersionBelow(ServerVersion.V1_20)){ + Hopper hopperState = (Hopper) block.getState(); + hopperDirection = HopperDirection.getDirection(hopperState.getRawData()); + pointingLocation = hopperDirection.getLocation(location); + } + else{ + hopperDirection = HopperDirection.valueOf(((Directional) block.getBlockData()).getFacing().name()); + BlockFace blockFace = hopperDirection.getDirectionFacing(); + pointingLocation = block.getLocation().getBlock().getRelative(blockFace).getLocation(); + } final StorageContainerCache.Cache hopperCache = StorageContainerCache.getCachedInventory(block); - // Create list to hold blocked materials. List blockedMaterials = new ArrayList<>(); diff --git a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/utils/HopperDirection.java b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/utils/HopperDirection.java index 62db58c..e334f73 100644 --- a/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/utils/HopperDirection.java +++ b/EpicHoppers-Plugin/src/main/java/com/craftaro/epichoppers/utils/HopperDirection.java @@ -39,7 +39,7 @@ public enum HopperDirection { return location.clone().add(getX(), getY(), getZ()); } - public BlockFace getDirection() { + public BlockFace getDirectionFacing() { switch (this) { case NORTH: return BlockFace.NORTH; diff --git a/pom.xml b/pom.xml index 81d4d68..93a7c54 100644 --- a/pom.xml +++ b/pom.xml @@ -20,7 +20,7 @@ https://craftaro.com/marketplace/product/15 - 3.0.0-SNAPSHOT + 3.0.7-SNAPSHOT 8 1.8