本文整理汇总了Java中org.spongepowered.api.event.item.inventory.InteractInventoryEvent.Open方法的典型用法代码示例。如果您正苦于以下问题:Java InteractInventoryEvent.Open方法的具体用法?Java InteractInventoryEvent.Open怎么用?Java InteractInventoryEvent.Open使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.event.item.inventory.InteractInventoryEvent
的用法示例。
在下文中一共展示了InteractInventoryEvent.Open方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onInventoryOpen
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryOpen(InteractInventoryEvent.Open event, @First Player player)
{
if (!(event.getTargetInventory() instanceof CarriedInventory)
|| !((CarriedInventory) event.getTargetInventory()).getCarrier().isPresent())
{
return;
}
Object carrier = ((CarriedInventory) event.getTargetInventory()).getCarrier().get();
Location<World> loc = null;
if (carrier instanceof BlockCarrier)
{
loc = ((BlockCarrier) carrier).getLocation();
}
else if (carrier instanceof Entity)
{
loc = ((Entity) carrier).getLocation();
}
Lock lock = this.manager.getLockOfInventory(((CarriedInventory) event.getTargetInventory()));
if (lock == null) return;
lock.handleInventoryOpen(event, event.getTargetInventory(), loc, player);
}
示例2: fireOpenEvent
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
private void fireOpenEvent(InteractInventoryEvent.Open e)
{
Optional<Player> optional = Sponge.getServer().getPlayer(playerUniqueId);
if (optional.isPresent())
{
Player player = optional.get();
Container targetContainer = e.getTargetInventory();
Inventory targetInventory = targetContainer.first();
plugin.getVirtualChestActions().submitCommands(player, parsedOpenAction, ImmutableList.of());
if (updateIntervalTick > 0)
{
Task.Builder builder = Sponge.getScheduler().createTaskBuilder().execute(task ->
{
if (player.getOpenInventory().filter(targetContainer::equals).isPresent())
{
refreshMappingFrom(targetInventory, updateInventory(player, targetInventory));
}
else
{
task.cancel();
}
});
builder.delayTicks(updateIntervalTick).intervalTicks(updateIntervalTick).submit(plugin);
}
logger.debug("Player {} opens the chest GUI", player.getName());
plugin.getScriptManager().onOpeningInventory(player);
refreshMappingFrom(targetInventory, updateInventory(player, targetInventory));
}
}
示例3: onInventoryOpened
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onInventoryOpened(InteractInventoryEvent.Open event) {
Optional<Player> cause = event.getCause().first(Player.class);
if (cause.isPresent()) {
// openShops.remove(cause.get().getUniqueId());
// VillagerShops.l("%s opened and inventory %s", cause.get().getName(), event.getTargetInventory().getName());
} else {
// VillagerShops.w("Can't get player opening inventory");
}
}
示例4: onPlayerInteractInventoryOpen
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)
public void onPlayerInteractInventoryOpen(InteractInventoryEvent.Open event, @First Player player) {
if (!GPFlags.INTERACT_INVENTORY || !GriefPreventionPlugin.instance.claimsEnabledForWorld(player.getWorld().getProperties())) {
return;
}
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.startTimingIfSync();
final Cause cause = event.getCause();
final EventContext context = cause.getContext();
final BlockSnapshot blockSnapshot = context.get(EventContextKeys.BLOCK_HIT).orElse(BlockSnapshot.NONE);
if (blockSnapshot == BlockSnapshot.NONE) {
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
return;
}
final Location<World> location = blockSnapshot.getLocation().get();
final GPClaim claim = this.dataStore.getClaimAt(location);
final GPPlayerData playerData = this.dataStore.getOrCreatePlayerData(player.getWorld(), player.getUniqueId());
if (playerData.lastInteractItemBlockResult == Tristate.TRUE) {
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
return;
}
final Tristate result = GPPermissionHandler.getClaimPermission(event, location, claim, GPPermissions.INVENTORY_OPEN, player, blockSnapshot, player, TrustType.CONTAINER, true);
if (result == Tristate.FALSE) {
Text message = GriefPreventionPlugin.instance.messageData.permissionInventoryOpen
.apply(ImmutableMap.of(
"owner", claim.getOwnerName(),
"block", blockSnapshot.getState().getType().getId())).build();
GriefPreventionPlugin.sendClaimDenyMessage(claim, player, message);
((EntityPlayerMP) player).closeScreen();
event.setCancelled(true);
}
GPTimings.PLAYER_INTERACT_INVENTORY_OPEN_EVENT.stopTimingIfSync();
}
示例5: onChestOpen
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onChestOpen(InteractInventoryEvent.Open event, @Root Player player) {
Optional<GoldRushInstance> optInst = manager.getApplicableZone(player);
if (!optInst.isPresent()) {
return;
}
GoldRushInstance inst = optInst.get();
Inventory inventory = event.getTargetInventory();
if (!inst.isLocked() && inventory instanceof ContainerChest) {
IInventory chestInv = ((ContainerChest) inventory).getLowerChestInventory();
if (chestInv instanceof ILockableContainer) {
LockCode newLockCode = new LockCode(UUID.randomUUID().toString());
tileEntityClaimMap.put(newLockCode.getLock(), player);
((ILockableContainer) chestInv).setLockCode(newLockCode);
BigDecimal risk = Optional.ofNullable(
inst.cofferRisk.get(player.getUniqueId())
).orElse(BigDecimal.ZERO);
Collection<org.spongepowered.api.item.inventory.ItemStack> queue = CofferValueMap.inst().satisfy(risk.toBigInteger());
Iterator<org.spongepowered.api.item.inventory.ItemStack> it = queue.iterator();
for (int i = 0; i < chestInv.getSizeInventory(); ++i) {
if (it.hasNext()) {
chestInv.setInventorySlotContents(i, tf(it.next()));
continue;
}
chestInv.setInventorySlotContents(i, ItemStack.EMPTY);
}
}
}
}
示例6: onOpenInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onOpenInventory(InteractInventoryEvent.Open event, @Root Player player, @Getter("getTargetInventory") Container inventory)
{
// When opening prompt activation
if (inventory instanceof CarriedInventory && inventory.size() > 0)
{
((CarriedInventory<?>) inventory).getCarrier().ifPresent(carrier -> this.promptActivation(carrier, false, player));
}
}
示例7: observe
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Override
public Action observe(InteractInventoryEvent.Open event)
{
Action action = newReport();
action.addData(CAUSE, Observe.causes(event.getCause()));
// TODO get TargetInventory
return action;
}
示例8: onOpenInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onOpenInventory(InteractInventoryEvent.Open evt){
scheduleInventoryUpdate(evt.getTargetInventory(), true);
}
示例9: onOpenInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener
public void onOpenInventory(InteractInventoryEvent.Open e, @First Player p) {
if (manager.matchesTick(p.getUniqueId(), Sponge.getServer().getRunningTimeTicks())) {
manager.setActive(p.getUniqueId());
}
}
示例10: onInteractInventory
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void onInteractInventory(InteractInventoryEvent.Open event) {
webHookService.notifyHooks(WebHookService.WebHookType.INVENTORY_OPEN, event);
}
示例11: onInventoryOpen
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.EARLY)
public void onInventoryOpen(InteractInventoryEvent.Open e, @Root Player player) {
IActiveCharacter character = characterService.getCharacter(player);
e.setCancelled(characterService.processUserAction(character, UserActionType.E));
}
示例12: listen
import org.spongepowered.api.event.item.inventory.InteractInventoryEvent; //导入方法依赖的package包/类
@Listener(order = Order.POST)
public void listen(InteractInventoryEvent.Open event, @First Player player)
{
report(observe(event));
}