mirror of
https://github.com/PlayPro/CoreProtect.git
synced 2024-12-27 17:37:34 +01:00
Added logging for player inventory transactions with allays
This commit is contained in:
parent
026b9ce322
commit
ce5c1c50bf
@ -7,6 +7,7 @@ import java.util.Locale;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Creature;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.ItemFrame;
|
||||
import org.bukkit.entity.Player;
|
||||
@ -21,6 +22,7 @@ import org.bukkit.inventory.ItemStack;
|
||||
import net.coreprotect.config.Config;
|
||||
import net.coreprotect.config.ConfigHandler;
|
||||
import net.coreprotect.consumer.Queue;
|
||||
import net.coreprotect.database.logger.ItemLogger;
|
||||
import net.coreprotect.model.BlockGroup;
|
||||
import net.coreprotect.utility.Util;
|
||||
|
||||
@ -74,6 +76,36 @@ public final class PlayerInteractEntityListener extends Queue implements Listene
|
||||
queueFrameTransaction(player.getName(), frame, false);
|
||||
}
|
||||
}
|
||||
else if (!event.isCancelled() && entity instanceof Creature && entity.getType().name().equals("ALLAY")) {
|
||||
ItemStack handItem = new ItemStack(Material.AIR);
|
||||
ItemStack mainHand = player.getInventory().getItemInMainHand();
|
||||
ItemStack offHand = player.getInventory().getItemInOffHand();
|
||||
if (event.getHand().equals(EquipmentSlot.HAND) && mainHand.getType() != Material.AIR) {
|
||||
handItem = mainHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND) && offHand.getType() != Material.AIR) {
|
||||
handItem = offHand;
|
||||
}
|
||||
else if (event.getHand().equals(EquipmentSlot.OFF_HAND)) {
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack allayItem = ((Creature) entity).getEquipment().getItemInMainHand();
|
||||
if (handItem.getType().equals(allayItem.getType())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (allayItem.getType().equals(Material.AIR)) {
|
||||
ItemStack removedItem = handItem.clone();
|
||||
removedItem.setAmount(1);
|
||||
CraftItemListener.logCraftedItem(player.getLocation(), player.getName(), removedItem, ItemLogger.ITEM_SELL);
|
||||
}
|
||||
else if (handItem.getType().equals(Material.AIR)) {
|
||||
ItemStack addItem = allayItem.clone();
|
||||
addItem.setAmount(1);
|
||||
CraftItemListener.logCraftedItem(player.getLocation(), player.getName(), addItem, ItemLogger.ITEM_BUY);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void queueFrameTransaction(String user, ItemFrame frame, boolean logDrop) {
|
||||
|
Loading…
Reference in New Issue
Block a user