本文整理汇总了Java中org.spongepowered.api.event.item.inventory.ChangeInventoryEvent.Pickup方法的典型用法代码示例。如果您正苦于以下问题:Java ChangeInventoryEvent.Pickup方法的具体用法?Java ChangeInventoryEvent.Pickup怎么用?Java ChangeInventoryEvent.Pickup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.item.inventory.ChangeInventoryEvent
的用法示例。
在下文中一共展示了ChangeInventoryEvent.Pickup方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: pickupItem
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
@Exclude({ChangeInventoryEvent.Pickup.Pre.class})
public void pickupItem(ChangeInventoryEvent.Pickup event, @Root Player player) {
List<SlotTransaction> transactions = event.getTransactions();
if (transactions.isEmpty()) {
return;
}
int itemQuantity = transactions.get(0).getFinal().getQuantity() - transactions.get(0).getOriginal().getQuantity();
// Sometimes it's 0 for some odd reason
if (itemQuantity == 0) {
return;
}
processEvent(event, player, itemQuantity);
}
示例2: onPickupItem
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onPickupItem(ChangeInventoryEvent.Pickup event, @Root Player player)
{
if (!player.hasPermission("essentialcmds.blacklist.bypass"))
{
for (SlotTransaction transaction : event.getTransactions())
{
if (Utils.getBlacklistItems().contains(transaction.getFinal().createStack().getItem().getId()))
{
if (Utils.areBlacklistMsgsEnabled())
player.sendMessage(Text.of(TextColors.RED, "The item ", TextColors.GRAY, transaction.getFinal().createStack().getItem().getId(), TextColors.RED, " has been confiscated as it is blacklisted."));
transaction.setCustom(Sponge.getRegistry().createBuilder(ItemStack.Builder.class).itemType(ItemTypes.DIRT).quantity(1).build());
}
}
}
}
示例3: onPlayerItemPickUp
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onPlayerItemPickUp(ChangeInventoryEvent.Pickup event, @First Player player) {
if (!Config.Values.Synchronize.getEnableInventory())
return;
synchronized (waitingPlayers) {
if (waitingPlayers.containsKey(player.getUniqueId())) {
event.setCancelled(true);
}
}
}
示例4: onPickupItem
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onPickupItem(ChangeInventoryEvent.Pickup event, @First Player player)
{
if (module.isHidden(player) && !player.hasPermission(module.perms().PICKUP.getId()))
{
event.setCancelled(true);
}
}
示例5: onPickup
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onPickup(ChangeInventoryEvent.Pickup event, @First Player p) {
ModuleConfig config = Modules.BLACKLIST.get().getConfig().get();
CommentedConfigurationNode hnode = config.get();
Item item = event.getTargetEntity();
CommentedConfigurationNode node = hnode.getNode("items", item.getItemType().getId());
if (!node.isVirtual()) {
if (node.getNode("deny-drop").getBoolean()) {
event.setCancelled(true);
}
}
}
示例6: onPickup
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onPickup(ChangeInventoryEvent.Pickup event, @First Player p) {
UltimateUser up = UltimateCore.get().getUserService().getUser(p);
if (!up.get(VanishKeys.VANISH).get()) {
return;
}
ModuleConfig config = Modules.VANISH.get().getConfig().get();
if (!config.get().getNode("events", "pickup").getBoolean()) {
event.setCancelled(true);
}
}
示例7: onChangeInventoryPickup
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onChangeInventoryPickup(ChangeInventoryEvent.Pickup event, @Root @Has(ViewerData.class) Player player) {
event.setCancelled(true);
}
示例8: onPlayerItemPickup
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerItemPickup(ChangeInventoryEvent.Pickup pickupItemEvent, @Root Player player) {
checkLoginStatus(pickupItemEvent, player);
}
示例9: onItemPickup
import org.spongepowered.api.event.item.inventory.ChangeInventoryEvent; //导入方法依赖的package包/类
/**
* Saves event records when a player picks up an item.
*
* @param event Pickup event.
*/
@Listener(order = Order.POST)
public void onItemPickup(final ChangeInventoryEvent.Pickup event, @Root Player player) {
PrismRecord.create().player(player).pickedUp(event.getTargetEntity()).save();
}