From 9a9043780f6675ed3c512f0c59314b142c0bb7e8 Mon Sep 17 00:00:00 2001 From: Brianna Date: Tue, 11 Aug 2020 09:49:29 -0500 Subject: [PATCH 1/3] Added support for suction particles on 1.8 --- .../hopper/levels/modules/ModuleSuction.java | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java index 73551da..b2909ab 100644 --- a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java +++ b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java @@ -2,7 +2,7 @@ package com.songoda.epichoppers.hopper.levels.modules; import com.bgsoftware.wildstacker.api.WildStackerAPI; import com.songoda.core.compatibility.CompatibleMaterial; -import com.songoda.core.compatibility.ServerVersion; +import com.songoda.core.compatibility.CompatibleParticleHandler; import com.songoda.core.locale.Locale; import com.songoda.epichoppers.EpicHoppers; import com.songoda.epichoppers.hopper.Hopper; @@ -11,7 +11,6 @@ import com.songoda.epichoppers.utils.StorageContainerCache; import org.apache.commons.lang.StringUtils; import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.Particle; import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; import org.bukkit.entity.Player; @@ -134,12 +133,11 @@ public class ModuleSuction extends Module { () -> blacklist.remove(item.getUniqueId()), 10L); } - if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { - float xx = (float) (0 + (Math.random() * .1)); - float yy = (float) (0 + (Math.random() * .1)); - float zz = (float) (0 + (Math.random() * .1)); - item.getLocation().getWorld().spawnParticle(Particle.FLAME, item.getLocation(), 5, xx, yy, zz, 0); - } + float xx = (float) (0 + (Math.random() * .1)); + float yy = (float) (0 + (Math.random() * .1)); + float zz = (float) (0 + (Math.random() * .1)); + CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.FLAME, + item.getLocation(), 5, xx, yy, zz); } } @@ -218,7 +216,7 @@ public class ModuleSuction extends Module { private int getRadius(Hopper hopper) { Object foundRadius = getData(hopper, "radius"); - return foundRadius == null ? maxSearchRadius : (int) foundRadius; + return foundRadius == null ? maxSearchRadius : (int) foundRadius; } private void setRadius(Hopper hopper, int radius) { From acba79cc6aaea1dc0966b2a15a8c0da38d126029 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 18 Aug 2020 12:38:57 +0200 Subject: [PATCH 2/3] add config option to emit inventorypickupevent --- .../hopper/levels/modules/ModuleSuction.java | 23 +++++++++++++++++++ .../epichoppers/settings/Settings.java | 5 ++++ 2 files changed, 28 insertions(+) diff --git a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java index b2909ab..25f516e 100644 --- a/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java +++ b/src/main/java/com/songoda/epichoppers/hopper/levels/modules/ModuleSuction.java @@ -6,6 +6,7 @@ import com.songoda.core.compatibility.CompatibleParticleHandler; import com.songoda.core.locale.Locale; import com.songoda.epichoppers.EpicHoppers; import com.songoda.epichoppers.hopper.Hopper; +import com.songoda.epichoppers.settings.Settings; import com.songoda.epichoppers.utils.Methods; import com.songoda.epichoppers.utils.StorageContainerCache; import org.apache.commons.lang.StringUtils; @@ -15,7 +16,11 @@ import org.bukkit.entity.EntityType; import org.bukkit.entity.Item; import org.bukkit.entity.Player; import org.bukkit.event.inventory.ClickType; +import org.bukkit.event.inventory.InventoryPickupItemEvent; +import org.bukkit.event.inventory.InventoryType; import org.bukkit.inventory.ItemStack; +import org.bukkit.inventory.Inventory; +import org.bukkit.inventory.InventoryHolder; import org.bukkit.inventory.meta.ItemMeta; import java.lang.reflect.Method; @@ -72,9 +77,19 @@ public class ModuleSuction extends Module { && entity.getLocation().getBlock().getType() != Material.HOPPER) .map(entity -> (Item) entity) .collect(Collectors.toSet()); + + if (itemsToSuck.isEmpty()) + return; boolean filterEndpoint = hopper.getFilter().getEndPoint() != null; + InventoryHolder inventoryHolder = null; + Inventory hopperInventory = null; + if (Settings.EMIT_INVENTORYPICKUPITEMEVENT.getBoolean()) { + inventoryHolder = (InventoryHolder) hopper.getBlock().getState(); + hopperInventory = Bukkit.createInventory(inventoryHolder, InventoryType.HOPPER); + } + for (Item item : itemsToSuck) { ItemStack itemStack = item.getItemStack(); @@ -114,6 +129,14 @@ public class ModuleSuction extends Module { } } } + + if (Settings.EMIT_INVENTORYPICKUPITEMEVENT.getBoolean()) { + hopperInventory.setContents(hopperCache.cachedInventory); + InventoryPickupItemEvent pickupevent = new InventoryPickupItemEvent(hopperInventory, item); + Bukkit.getPluginManager().callEvent(pickupevent); + if (pickupevent.isCancelled()) + continue; + } // try to add the items to the hopper int toAdd, added = hopperCache.addAny(itemStack, toAdd = getActualItemAmount(item)); diff --git a/src/main/java/com/songoda/epichoppers/settings/Settings.java b/src/main/java/com/songoda/epichoppers/settings/Settings.java index f324159..6f1d3a3 100644 --- a/src/main/java/com/songoda/epichoppers/settings/Settings.java +++ b/src/main/java/com/songoda/epichoppers/settings/Settings.java @@ -85,6 +85,11 @@ public class Settings { "Which economy plugin should be used?", "Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\"."); + public static final ConfigSetting EMIT_INVENTORYPICKUPITEMEVENT = new ConfigSetting(config, "Main.Emit InventoryPickupItemEvent", false, + "This event is used by other plugin to modify or monitor the behavior when a hopper picks up items on the ground.", + "However it is a high frequency event and may have an impact on your server performance which is why it is disabled by default.", + "If you absolutely need this enable it but be aware of the potential performance impact."); + public static final ConfigSetting ECO_ICON = new ConfigSetting(config, "Interfaces.Economy Icon", "SUNFLOWER"); public static final ConfigSetting XP_ICON = new ConfigSetting(config, "Interfaces.XP Icon", "EXPERIENCE_BOTTLE"); From 2ff10976912727e2868d5eea7af092d686842749 Mon Sep 17 00:00:00 2001 From: Aurora Date: Tue, 18 Aug 2020 15:18:04 +0200 Subject: [PATCH 3/3] version 4.6.12 --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 3e9c79c..9862551 100644 --- a/pom.xml +++ b/pom.xml @@ -2,7 +2,7 @@ com.songoda EpicHoppers 4.0.0 - 4.6.11 + 4.6.12 clean install EpicHoppers-${project.version}