Merge branch 'development'

This commit is contained in:
Brianna 2020-09-02 12:14:00 -05:00
commit afa8a8b61c
3 changed files with 36 additions and 10 deletions

View File

@ -2,7 +2,7 @@
<groupId>com.songoda</groupId> <groupId>com.songoda</groupId>
<artifactId>EpicHoppers</artifactId> <artifactId>EpicHoppers</artifactId>
<modelVersion>4.0.0</modelVersion> <modelVersion>4.0.0</modelVersion>
<version>4.6.11</version> <version>4.6.12</version>
<build> <build>
<defaultGoal>clean install</defaultGoal> <defaultGoal>clean install</defaultGoal>
<finalName>EpicHoppers-${project.version}</finalName> <finalName>EpicHoppers-${project.version}</finalName>

View File

@ -2,21 +2,25 @@ package com.songoda.epichoppers.hopper.levels.modules;
import com.bgsoftware.wildstacker.api.WildStackerAPI; import com.bgsoftware.wildstacker.api.WildStackerAPI;
import com.songoda.core.compatibility.CompatibleMaterial; 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.core.locale.Locale;
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.settings.Settings;
import com.songoda.epichoppers.utils.Methods; import com.songoda.epichoppers.utils.Methods;
import com.songoda.epichoppers.utils.StorageContainerCache; import com.songoda.epichoppers.utils.StorageContainerCache;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType; 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.ItemStack;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.ItemMeta;
import java.lang.reflect.Method; import java.lang.reflect.Method;
@ -74,8 +78,18 @@ public class ModuleSuction extends Module {
.map(entity -> (Item) entity) .map(entity -> (Item) entity)
.collect(Collectors.toSet()); .collect(Collectors.toSet());
if (itemsToSuck.isEmpty())
return;
boolean filterEndpoint = hopper.getFilter().getEndPoint() != null; 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) { for (Item item : itemsToSuck) {
ItemStack itemStack = item.getItemStack(); ItemStack itemStack = item.getItemStack();
@ -116,6 +130,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 // try to add the items to the hopper
int toAdd, added = hopperCache.addAny(itemStack, toAdd = getActualItemAmount(item)); int toAdd, added = hopperCache.addAny(itemStack, toAdd = getActualItemAmount(item));
if (added == 0) if (added == 0)
@ -134,12 +156,11 @@ public class ModuleSuction extends Module {
() -> blacklist.remove(item.getUniqueId()), 10L); () -> blacklist.remove(item.getUniqueId()), 10L);
} }
if (ServerVersion.isServerVersionAtLeast(ServerVersion.V1_9)) { float xx = (float) (0 + (Math.random() * .1));
float xx = (float) (0 + (Math.random() * .1)); float yy = (float) (0 + (Math.random() * .1));
float yy = (float) (0 + (Math.random() * .1)); float zz = (float) (0 + (Math.random() * .1));
float zz = (float) (0 + (Math.random() * .1)); CompatibleParticleHandler.spawnParticles(CompatibleParticleHandler.ParticleType.FLAME,
item.getLocation().getWorld().spawnParticle(Particle.FLAME, item.getLocation(), 5, xx, yy, zz, 0); item.getLocation(), 5, xx, yy, zz);
}
} }
} }
@ -218,7 +239,7 @@ public class ModuleSuction extends Module {
private int getRadius(Hopper hopper) { private int getRadius(Hopper hopper) {
Object foundRadius = getData(hopper, "radius"); Object foundRadius = getData(hopper, "radius");
return foundRadius == null ? maxSearchRadius : (int) foundRadius; return foundRadius == null ? maxSearchRadius : (int) foundRadius;
} }
private void setRadius(Hopper hopper, int radius) { private void setRadius(Hopper hopper, int radius) {

View File

@ -85,6 +85,11 @@ public class Settings {
"Which economy plugin should be used?", "Which economy plugin should be used?",
"Supported plugins you have installed: \"" + EconomyManager.getManager().getRegisteredPlugins().stream().collect(Collectors.joining("\", \"")) + "\"."); "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 ECO_ICON = new ConfigSetting(config, "Interfaces.Economy Icon", "SUNFLOWER");
public static final ConfigSetting XP_ICON = new ConfigSetting(config, "Interfaces.XP Icon", "EXPERIENCE_BOTTLE"); public static final ConfigSetting XP_ICON = new ConfigSetting(config, "Interfaces.XP Icon", "EXPERIENCE_BOTTLE");