本文整理汇总了Java中org.spongepowered.api.event.item.inventory.InteractInventoryEvent.Close方法的典型用法代码示例。如果您正苦于以下问题:Java InteractInventoryEvent.Close方法的具体用法?Java InteractInventoryEvent.Close怎么用?Java InteractInventoryEvent.Close使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.item.inventory.InteractInventoryEvent
的用法示例。
在下文中一共展示了InteractInventoryEvent.Close方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInteractInventoryEventClose
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInteractInventoryEventClose(InteractInventoryEvent.Close event) throws IOException, SQLException {
final Container container = (Container) event.getTargetInventory();
if (container instanceof ContainerChest) {
final ContainerChest containerChest = (ContainerChest) container;
if (containerChest.getLowerChestInventory() instanceof BackpackInventory) {
final BackpackInventory inventory = (BackpackInventory) containerChest.getLowerChestInventory();
final Backpacks record = inventory.getRecord();
final Session session = DatabaseManager.getSessionFactory().openSession();
session.beginTransaction();
for (int i = 0; i < record.getSize(); i++) {
final ItemStack stack = (ItemStack) (Object) inventory.getStackInSlot(i);
DatabaseManager.saveSlot(session, record, i, stack == null ? null : stack.toContainer());
}
session.getTransaction().commit();
session.close();
}
}
}
示例2: manageClose
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void manageClose(InteractInventoryEvent.Close event) {
Container container = event.getTargetInventory();
if (FirstGuiPreview.FIRST_GUI_CONTAINERS.containsKey(container)) {
FirstGuiPreview.FIRST_GUI_CONTAINERS.remove(container);
} else if (SecondGuiPreview.SECOND_GUI_CONTAINERS.containsKey(container)) {
SecondGuiPreview.SECOND_GUI_CONTAINERS.remove(container);
}
}
示例3: cancelClose
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void cancelClose(InteractInventoryEvent.Close event) {
Container container = event.getTargetInventory();
if (!FirstOpenManager.SHOWN_GUI.contains(container) &&
FirstOpenManager.FIRST_GUI_CONTAINERS.containsKey(container) &&
FirstOpenManager.FIRST_GUI_CONTAINERS.get(container).getKey().isForbidClose()) {
event.setCancelled(true);
}
}
示例4: fireCloseEvent
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
private void fireCloseEvent(InteractInventoryEvent.Close e)
{
Optional<Player> optional = Sponge.getServer().getPlayer(playerUniqueId);
if (optional.isPresent())
{
Player player = optional.get();
plugin.getVirtualChestActions().submitCommands(player, parsedCloseAction, ImmutableList.of());
logger.debug("Player {} closes the chest GUI", player.getName());
actionIntervalManager.onClosingInventory(player);
}
}
示例5: onInventoryClosed
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryClosed(InteractInventoryEvent.Close event) {
Optional<Player> cause = event.getCause().first(Player.class);
if (cause.isPresent()) {
UUID target = cause.get().getUniqueId();
VillagerShops.openShops.remove(target);
VillagerShops.actionUnstack.remove(target);
// l("%s closed an inventory", cause.get().getName());
} else {
// l("An inventory was closed");
}
}
示例6: onCloseInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player player, @Getter("getTargetInventory") Container inventory)
{
// When closing update filters and prompt activation
if (inventory instanceof CarriedInventory && inventory.size() > 0)
{
((CarriedInventory<?>) inventory).getCarrier().ifPresent(carrier -> this.promptActivation(carrier, true, player));
}
}
示例7: onCloseInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player player, @Getter("getTargetInventory") Container inventory)
{
// When closing update filters
if (inventory instanceof CarriedInventory<?>) {
((CarriedInventory<?>) inventory).getCarrier().ifPresent(carrier -> {
if (carrier instanceof DuctFilterCarrier)
{
((DuctFilterCarrier) carrier).update(event.getTargetInventory().iterator().next());
}
});
}
}
示例8: onInventoryClose
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryClose(InteractInventoryEvent.Close event, @First Player player)
{
Container inventory = event.getTargetInventory();
if (inventory instanceof CarriedInventory)
{
if (((CarriedInventory)inventory).getCarrier().orElse(null) instanceof BackpackHolder)
{
BackpackHolder holder = (BackpackHolder)((CarriedInventory)inventory).getCarrier().get();
holder.getBackpack().closeInventory(inventory, player);
}
}
}
示例9: onCloseInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close e, @First Player p) {
manager.removePlayer(p.getUniqueId());
}
示例10: onInteractInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent.Close event) {
webHookService.notifyHooks(WebHookService.WebHookType.INVENTORY_CLOSE, event);
}
示例11: onCloseInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(final InteractInventoryEvent.Close event, @Root Player player) {
this.stopThem.remove(player.getUniqueId());
}
示例12: PlayerMoveInv
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void PlayerMoveInv(InteractInventoryEvent.Close e, @Root Player p){
RPUtil.removeGuiItem(p);
}
示例13: onDeath
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onDeath(InteractInventoryEvent.Close event){
if (event.getTargetInventory().getName().get().equals(this.inv.getName().get())){
close();
}
}
示例14: onCloseInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onCloseInventory(InteractInventoryEvent.Close event, @Root Player p) {
//Player closed invsee
UltimateUser up = UltimateCore.get().getUserService().getUser(p);
up.offer(InventoryKeys.INVSEE_TARGET, null);
}
示例15: close
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void close(InteractInventoryEvent.Close event, @First Player player) {
Container inv = event.getTargetInventory();
if (!(inv.getViewers().contains(viewer))) {
return;
}
if (!player.getUniqueId().equals(viewer.getUniqueId()) && player.hasPermission(Permissions.ADMIN)) {
return;
}
if (!inv.getName().equals(inventory.getName())) {
return;
}
SpongeItemBank.instance().map(SpongeItemBank.class::cast).ifPresent(plugin -> {
SpongeConfig config = plugin.getConfig();
IntStream.range(0, inv.capacity()).forEach(x -> getItem(inv, x).filter(is -> is.getType() != ItemTypes.AIR).ifPresent(itemStack -> {
itemAmount = 0;
StreamSupport.stream(inv.spliterator(), false).map(Inventory::peek).filter(Optional::isPresent).map(Optional::get).filter(is -> is.getType() != ItemTypes.AIR && itemStack.getType() == is.getType() && IBUtils.isSameVariant(itemStack, is)).forEach(is -> itemAmount += itemStack.getQuantity());
ItemStack configItem = config.getItem(itemStack);
if (configItem != null && config.isWhitelist()) {
handleMaxAmount(inv, x, configItem, itemStack, player);
}
else if (configItem == null && config.isWhitelist()) {
spawnItem(itemStack, player.getLocation());
setItem(inv, x, ItemStack.empty());
hasIllegalItems = true;
}
}));
if (hasIllegalItems) {
player.sendMessage(Text.builder(Messages.ACCOUNT_ILLEGAL_ITEM).color(TextColors.RED).build());
}
if (hasIllegalAmount) {
player.sendMessage(Text.builder(Messages.ACCOUNT_ILLEGAL_AMOUNT).color(TextColors.RED).build());
}
IntStream.range(0, inv.size()).forEach(slot -> getItem(inv, slot).ifPresent(itemStack -> {
if (itemStack.getType() == ItemTypes.AIR) {
page.clearSlot(slot);
}
else {
page.setSlot(new AccountSlot<>(slot, itemStack));
}
}));
});
Sponge.getEventManager().unregisterListeners(this);
}