Move from deprecated BlockUtils#updateAdjacentComparators to WorldCore

Fixes `java.lang.NoSuchMethodException: org.bukkit.craftbukkit.v1_19_R3.CraftChunk.getHandle()`
in a mid-version NMS change in Spigot 1.19.4
This commit is contained in:
Christian Koop 2023-04-19 21:58:36 +02:00
parent 5940491279
commit 0b5d3481c9
No known key found for this signature in database
GPG Key ID: 89A8181384E010A3
2 changed files with 10 additions and 5 deletions

View File

@ -1,7 +1,7 @@
package com.songoda.epichoppers.listeners; package com.songoda.epichoppers.listeners;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.BlockUtils; import com.songoda.core.nms.NmsManager;
import com.songoda.epichoppers.EpicHoppers; import com.songoda.epichoppers.EpicHoppers;
import com.songoda.epichoppers.hopper.Hopper; import com.songoda.epichoppers.hopper.Hopper;
import com.songoda.epichoppers.hopper.levels.modules.Module; import com.songoda.epichoppers.hopper.levels.modules.Module;
@ -139,10 +139,14 @@ public class HopperListeners implements Listener {
//event.setItem(moveInstead); //event.setItem(moveInstead);
// we need to instead cancel and manually remove the item to move // we need to instead cancel and manually remove the item to move
source.removeItem(moveInstead); source.removeItem(moveInstead);
BlockUtils.updateAdjacentComparators(sourceLocation); if (sourceLocation != null) {
NmsManager.getWorld().updateAdjacentComparators(sourceLocation.getBlock());
}
// now add it to the hopper // now add it to the hopper
destination.addItem(moveInstead); destination.addItem(moveInstead);
BlockUtils.updateAdjacentComparators(destinationLocation); if (destinationLocation != null) {
NmsManager.getWorld().updateAdjacentComparators(destinationLocation.getBlock());
}
} }
return; return;
} }

View File

@ -2,7 +2,7 @@ package com.songoda.epichoppers.utils;
import com.songoda.core.compatibility.CompatibleMaterial; import com.songoda.core.compatibility.CompatibleMaterial;
import com.songoda.core.compatibility.ServerVersion; import com.songoda.core.compatibility.ServerVersion;
import com.songoda.core.utils.BlockUtils; import com.songoda.core.nms.NmsManager;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
@ -112,7 +112,8 @@ public class StorageContainerCache {
inventory.setItem(i, cachedInventory[i]); inventory.setItem(i, cachedInventory[i]);
} }
} }
BlockUtils.updateAdjacentComparators(e.getKey().getLocation());
NmsManager.getWorld().updateAdjacentComparators(e.getKey());
}); });
inventoryCache.clear(); inventoryCache.clear();
} }