mirror of
https://github.com/songoda/UltimateStacker.git
synced 2024-11-23 02:25:31 +01:00
added hopper support.
This commit is contained in:
parent
8b8e2c3018
commit
1e01dcd4ec
6
.gitignore
vendored
6
.gitignore
vendored
@ -152,3 +152,9 @@ target/classes/com/songoda/ultimatestacker/events/InteractListeners\.class
|
||||
target/classes/com/songoda/ultimatestacker/utils/Reflection\.class
|
||||
|
||||
target/classes/com/songoda/ultimatestacker/utils/ServerVersion\.class
|
||||
|
||||
target/classes/com/songoda/ultimatestacker/command/commands/CommandRemoveAll\.class
|
||||
|
||||
target/classes/com/songoda/ultimatestacker/command/commands/CommandSettings\.class
|
||||
|
||||
target/classes/SettingDefinitions\.yml
|
||||
|
@ -7,6 +7,7 @@ import org.bukkit.Material;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.inventory.InventoryPickupItemEvent;
|
||||
import org.bukkit.event.player.PlayerInteractAtEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.Vector;
|
||||
@ -21,6 +22,32 @@ public class InteractListeners implements Listener {
|
||||
this.instance = instance;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onAccept(InventoryPickupItemEvent event) {
|
||||
ItemStack item = event.getItem().getItemStack();
|
||||
instance.getStackingTask().setMax(item, 0, true);
|
||||
int amt = item.getAmount();
|
||||
int max = item.getMaxStackSize();
|
||||
|
||||
if (amt <= max) return;
|
||||
|
||||
item.setAmount(max);
|
||||
amt = amt - max;
|
||||
|
||||
while (amt > max) {
|
||||
ItemStack newItem = new ItemStack(item);
|
||||
newItem.setAmount(max);
|
||||
|
||||
event.getInventory().addItem(newItem);
|
||||
amt = amt - max;
|
||||
}
|
||||
|
||||
ItemStack newItem = new ItemStack(item);
|
||||
newItem.setAmount(amt);
|
||||
|
||||
event.getInventory().addItem(newItem);
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onInteract(PlayerInteractAtEntityEvent event) {
|
||||
Player player = event.getPlayer();
|
||||
|
Loading…
Reference in New Issue
Block a user