• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Java Getter类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.spongepowered.api.event.filter.Getter的典型用法代码示例。如果您正苦于以下问题:Java Getter类的具体用法?Java Getter怎么用?Java Getter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Getter类属于org.spongepowered.api.event.filter包,在下文中一共展示了Getter类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: onItemForge

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemForge(ClickInventoryEvent event, @Root Player player, @Getter("getTargetInventory") Inventory inventory) {

    /*if (inventory.getArchetype() == InventoryArchetypes.ANVIL) {

        Inventory forgingInputs = inventory.query(InputSlot.class);

        PermHandler ph = PermHandler.getInstance();
        
        forgingInputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {
            String itemId = itemStack.getItem().getType().getId();
            if (!ph.checkPerm(player, "protectionperms.item.forge." + itemId)) {
                event.setCancelled(true);
                player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to forge " + itemId + '!'));
            }
        }));
    }*/
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:19,代码来源:ForgeItemListener.java


示例2: onItemEnchant

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemEnchant(ClickInventoryEvent event, @Root Player player, @Getter("getTargetInventory") Inventory inventory) {

    /*if (inventory.getArchetype() == InventoryArchetypes.ENCHANTING_TABLE) {

        Inventory enchantingInputs = inventory.query(InputSlot.class);

        enchantingInputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {
            String itemId = itemStack.getItem().getType().getId();

            itemStack.getValue(Keys.ITEM_ENCHANTMENTS).ifPresent(itemEnchantments -> itemEnchantments.forEach(enchantment -> {
                String enchantmentId = enchantment.getEnchantment().getId();
                if (!player.hasPermission("protectionperms.item.enchant." + itemId + ".with." + enchantmentId)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to enchant " + itemId + " with " + enchantmentId + '!'));
                }
            }));
        }));
    }*/
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:EnchantItemListener.java


示例3: onItemEquip

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemEquip(ClickInventoryEvent event, @First Player player, @Getter("getTargetInventory") Inventory inventory) {

    if (inventory.getArchetype() == InventoryArchetypes.PLAYER) {

        Inventory equipmentSlots = inventory.query(QueryOperationTypes.INVENTORY_TYPE.of(EquipmentSlot.class));

        equipmentSlots.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {

            ItemType itemType = itemStack.getType();
            String itemId = itemType.getId();

            PermHandler ph = PermHandler.getInstance();

            if (!ph.checkPerm(player, "protectionperms.item.equip." + itemId + ".on.self")) {
                event.setCancelled(true);
                player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to equip " + itemType.getName() + '!'));
            }
        }));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:22,代码来源:EquipItemListener.java


示例4: onItemCraft

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemCraft(ClickInventoryEvent event, @First Player player, @Getter("getTargetInventory") Inventory inventory) {

    if (inventory.getArchetype() == InventoryArchetypes.PLAYER || inventory.getArchetype() == InventoryArchetypes.WORKBENCH) {

        Inventory craftingOutputs = inventory.query(QueryOperationTypes.INVENTORY_TYPE.of(CraftingOutput.class));

        craftingOutputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {

            ItemType itemType = itemStack.getType();
            String itemId = itemType.getId();

            PermHandler ph = PermHandler.getInstance();

            if (!ph.checkPerm(player, "protectionperms.item.craft." + itemId)) {
                event.setCancelled(true);
                player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to craft " + itemType.getName() + '!'));
            }
        }));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:22,代码来源:CraftItemListener.java


示例5: onItemSmelt

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemSmelt(ClickInventoryEvent event, @Root Player player, @Getter("getTargetInventory") Inventory inventory) {

    /*if (inventory.getArchetype() == InventoryArchetypes.BREWING_STAND) {

        Inventory brewingInputs = inventory.query(InputSlot.class);

        brewingInputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {
            String itemId = itemStack.getItem().getType().getId();

            PermHandler ph = PermHandler.getInstance();
            
            if (slot instanceof FuelSlot) {
                if (!ph.checkPerm(player, "protectionperms.item.fuel." + itemId)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to use " + itemId + " as fuel!"));
                }
            } else {
                if (!ph.checkPerm(player, "protectionperms.item.brew." + itemId)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to brew " + itemId + '!'));
                }
            }
        }));
    }*/
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:27,代码来源:BrewItemListener.java


示例6: onClientConnectionEvent

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
/**
 * Supprime le joueur de la liste
 */
@Listener
public void onClientConnectionEvent(final ClientConnectionEvent.Disconnect event, @Getter("getTargetEntity") Player player_sponge) {
	EPlayer player = this.plugin.getEverAPI().getEServer().getEPlayer(event.getTargetEntity());
		
	// Jail
	Optional<SanctionJail> optSanction = player.getJail();
	if (optSanction.isPresent()) {
		Optional<Jail> jail = optSanction.get().getJail();
		if (jail.isPresent() && player.getBack().isPresent()) {
			player.setTransform(player.getBack().get());
		}
	}
	
	this.plugin.getSanctionService().removePlayer(event.getTargetEntity().getUniqueId());
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:19,代码来源:ESListener.java


示例7: getDelegate

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
public ParameterFilterSourceDelegate getDelegate(Annotation anno) {
    if (this == CAUSE_FIRST) {
        return new FirstCauseFilterSourceDelegate((First) anno);
    }
    if (this == CAUSE_LAST) {
        return new LastCauseFilterSourceDelegate((Last) anno);
    }
    if (this == CAUSE_BEFORE) {
        return new BeforeCauseFilterSourceDelegate((Before) anno);
    }
    if (this == CAUSE_AFTER) {
        return new AfterCauseFilterSourceDelegate((After) anno);
    }
    if (this == CAUSE_ALL) {
        return new AllCauseFilterSourceDelegate((All) anno);
    }
    if (this == CAUSE_ROOT) {
        return new RootCauseFilterSourceDelegate((Root) anno);
    }
    if (this == GETTER) {
        return new GetterFilterSourceDelegate((Getter) anno);
    }
    throw new UnsupportedOperationException();
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:25,代码来源:FilterGenerator.java


示例8: onLogin

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onLogin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
  if (!isApplicable(player)) {
    return;
  }

  Optional<WorldService> optWorldService = Sponge.getServiceManager().provide(WorldService.class);
  if (!optWorldService.isPresent()) {
    return;
  }

  WorldService worldService = optWorldService.get();

  Collection<World> worlds = worldService.getEffectWrapper(MainWorldWrapper.class).get().getWorlds();
  player.setLocation(worlds.iterator().next().getSpawnLocation());
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:InstanceWorldWrapper.java


示例9: onEntityDamage

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener(order = Order.LATE)
public void onEntityDamage(DamageEntityEvent event, @Getter(value = "getTargetEntity") Player player, @First DamageSource dmgSrc) {
  if (!isBlockable(dmgSrc)) {
    return;
  }

  Optional<Clause<Integer, Clause<ItemStack, Clause<Integer, Long>>>> optFeatherDetail = getHighestPoweredFeather(player);
  if (!optFeatherDetail.isPresent()) {
    return;
  }

  Clause<Integer, Clause<ItemStack, Clause<Integer, Long>>> featherDetail = optFeatherDetail.get();

  int redQ = featherDetail.getValue().getValue().getKey();
  final double dmg = event.getBaseDamage();
  final int k = (dmg > 80 ? 16 : dmg > 40 ? 8 : dmg > 20 ? 4 : 2);

  final double blockable = redQ * k;
  final double blocked = blockable - (blockable - dmg);

  event.setBaseDamage(Math.max(0, dmg - blocked));

  redQ = (int) ((blockable - blocked) / k);
  updateFeatherPower(featherDetail.getValue().getKey(), redQ, (long) blocked * 75);
  tf(player).inventory.mainInventory.set(featherDetail.getKey(), tf(featherDetail.getValue().getKey()));
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:27,代码来源:RedFeather.java


示例10: onEntityInteract

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onEntityInteract(InteractEntityEvent.Primary event, @First Player player, @Getter("getTargetEntity") Player targetPlayer) {
  Optional<org.spongepowered.api.item.inventory.ItemStack> optItemStack = player.getItemInHand(HandTypes.MAIN_HAND);
  if (!optItemStack.isPresent()) {
    return;
  }

  org.spongepowered.api.item.inventory.ItemStack itemStack = optItemStack.get();
  if (this.equals(itemStack.getItem()) && isAttuned(itemStack)) {
    if (playerAlreadyHasInvite(itemStack, targetPlayer)) {
      player.sendMessage(
          Text.of(TextColors.RED, targetPlayer.getName() + " already has an invite.")
      );
    } else {
      org.spongepowered.api.item.inventory.ItemStack newStack = createForMaster(itemStack, player);
      tf(targetPlayer).inventory.addItemStackToInventory(tf(newStack));
      targetPlayer.sendMessage(
          Text.of(TextColors.GOLD, player.getName() + " has invited you to " + getZone(itemStack).get() + ".")
      );
      player.sendMessage(
          Text.of(TextColors.GOLD, targetPlayer.getName() + " has been given invite.")
      );
    }
    event.setCancelled(true);
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:27,代码来源:ZoneMasterOrb.java


示例11: onEntityDeath

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onEntityDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Zombie zombie) {
  Optional<PatientXInstance> optInst = manager.getApplicableZone(zombie);
  if (!optInst.isPresent()) {
    return;
  }

  if (((EntityZombie) zombie).isChild()) {
    if (Probability.getChance(10)) {
      Task.builder().execute(() -> {
        new ItemDropper(zombie.getLocation()).dropStacks(
            Lists.newArrayList(newItemStack(ItemTypes.GOLD_INGOT, Probability.getRandom(16))),
            SpawnTypes.DROPPED_ITEM
        );
      }).delayTicks(1).submit(SkreePlugin.inst());
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:19,代码来源:PatientXListener.java


示例12: onPlayerDeath

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onPlayerDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Player player) {
  if (!isApplicable(player)) {
    return;
  }

  PlayerStateService service = Sponge.getServiceManager().provideUnchecked(PlayerStateService.class);
  try {
    service.storeInventory(player);
    service.releaseInventory(player);

    player.getInventory().clear();
  } catch (InventoryStorageStateException e) {
    e.printStackTrace();
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:17,代码来源:ZoneInventoryProtector.java


示例13: onDisconnect

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onDisconnect(ClientConnectionEvent.Disconnect event, @Getter("getTargetEntity") Player player) {
    // Remove the player from the mapping, other reasons why the player would be removed
    // are unknown.
    for (final Iterator<Map.Entry<PlayerWrapper, Trail>> iterator = this.playerTrails.entrySet().iterator(); iterator.hasNext(); ) {
        final Map.Entry<PlayerWrapper, Trail> next = iterator.next();
        if (next.getKey().playerId.equals(player.getUniqueId())) {
            iterator.remove();
            break;
        }
    }

}
 
开发者ID:gabizou,项目名称:HappyTrails,代码行数:14,代码来源:HappyTrails.java


示例14: onJoin

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onJoin(ClientConnectionEvent.Join event, @Getter("getTargetEntity") Player player) {
	if (this.useUptimes) {
		uptimes = uptimes.stream()
				.filter(u -> Duration.ofMillis(System.currentTimeMillis() - u.finishTimeMillis).toDays() <= 30)
				.collect(Collectors.toList());
	}
	if (contains(player)) {
		return;
	}
	changed = users.add(player) || changed;
}
 
开发者ID:rojo8399,项目名称:PlaceholderAPI,代码行数:13,代码来源:Defaults.java


示例15: onItemUse

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemUse(FishingEvent.Start event, @Root Player player, @Getter("getContext") EventContext context) {

    context.get(EventContextKeys.USED_ITEM).ifPresent(itemStackSnapshot -> {
        ItemType itemType = itemStackSnapshot.getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

        if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on.self")) {
            event.setCancelled(true);
            player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to use " + itemType.getName() + '!'));
        }
    });
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:16,代码来源:FishingStartListener.java


示例16: onItemSmelt

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onItemSmelt(ClickInventoryEvent event, @First Player player, @Getter("getTargetInventory") Inventory inventory) {

    if (inventory.getArchetype() == InventoryArchetypes.FURNACE) {

        Inventory smeltingInputs = inventory.query(QueryOperationTypes.INVENTORY_TYPE.of(InputSlot.class));

        PermHandler ph = PermHandler.getInstance();
        
        smeltingInputs.slots().forEach(slot -> slot.peek().ifPresent(itemStack -> {

            ItemType itemType = itemStack.getType();
            String itemId = itemType.getId();

            if (slot instanceof FuelSlot) {
                if (!ph.checkPerm(player, "protectionperms.item.fuel." + itemId)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to use " + itemType.getName() + " as fuel!"));
                }
            } else {
                if (!ph.checkPerm(player, "protectionperms.item.smelt." + itemId)) {
                    event.setCancelled(true);
                    player.sendMessage(ChatTypes.ACTION_BAR, Text.of(TextColors.RED, "You don't have permission to smelt " + itemType.getName() + '!'));
                }
            }
        }));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:29,代码来源:SmeltItemListener.java


示例17: onPlayerMove

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener
public void onPlayerMove(MoveEntityEvent event, @Getter("getTargetEntity") Player player_sponge) {
	// Même bloc
	if (event.getFromTransform().getExtent().equals(event.getToTransform().getExtent()) &&
			Math.ceil(event.getFromTransform().getPosition().getX()) == Math.ceil(event.getToTransform().getPosition().getX()) &&
			Math.ceil(event.getFromTransform().getPosition().getY()) == Math.ceil(event.getToTransform().getPosition().getY()) &&
			Math.ceil(event.getFromTransform().getPosition().getZ()) == Math.ceil(event.getToTransform().getPosition().getZ())) {
		return;
	}
	
	EPlayer player = this.plugin.getEverAPI().getEServer().getEPlayer(player_sponge);
	
	// Jail
	Optional<SanctionJail> optSanction = player.getJail();
	if (optSanction.isPresent()) {
		Optional<Jail> jail = optSanction.get().getJail();
		
		if (jail.isPresent()) {
			Transform<World> transform = jail.get().getTransform();
			if (!event.getToTransform().getExtent().equals(transform.getExtent()) ||
				event.getToTransform().getPosition().distance(transform.getPosition()) >= jail.get().getRadius()) {
				
				event.setToTransform(transform);
				player.sendActionBar(SanctionService.MESSAGE_JAIL, 3, ESMessages.JAIL_DISABLE_MOVE.getText());
			}
		}
	}	
}
 
开发者ID:EverCraft,项目名称:EverSanctions,代码行数:29,代码来源:ESListener.java


示例18: move

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener(order = Order.POST)
public void move(MoveEntityEvent event, @Getter("getTargetEntity") Player player) {
    // If the player teleported, just send the distance event (not including
    // their new location) and remove their player path
    if (event instanceof MoveEntityEvent.Teleport) {
        processEvent(event, player);
        sendAndRemove(player.getUniqueId());
        return;
    }

    PlayerPath playerPath;
    if (this.playerPaths.containsKey(player.getUniqueId())) {
        playerPath = this.playerPaths.get(player.getUniqueId());
    } else {
        playerPath = new PlayerPath();
        this.playerPaths.put(player.getUniqueId(), playerPath);
    }

    Vector3i position = player.getLocation().getBlockPosition();
    playerPath.addPoint(position);

    // Send the event every 20 blocks moved
    if (playerPath.size() >= 20) {
        sendAndRemove(player.getUniqueId());
    }

}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:28,代码来源:MoveEventListener.java


示例19: playerDeath

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@Listener(order = Order.POST)
public void playerDeath(DestructEntityEvent.Death event, @Getter("getTargetEntity") Player player)
        throws IllegalAccessException, IllegalArgumentException, InvocationTargetException {
    String key = "death";
    Optional<DamageSource> dmgSrcOpt = event.getCause().first(DamageSource.class);
    if (dmgSrcOpt.isPresent()) {
        key += ":" + dmgSrcOpt.get().getType().getId();
    }

    processEvent(event, player, key);
}
 
开发者ID:BadgeUp,项目名称:badgeup-sponge-client,代码行数:12,代码来源:GeneralEventListener.java


示例20: onChangeInventory

import org.spongepowered.api.event.filter.Getter; //导入依赖的package包/类
@SuppressWarnings("ConstantConditions")
@Listener
public void onChangeInventory(ChangeInventoryEvent event, @First Player player,
        @Getter("getTargetInventory") CarriedInventory<?> container) {
    if (!container.getName().get().equals("Furnace")) {
        return;
    }
    final Carrier carrier = container.getCarrier().orElse(null);
    if (!(carrier instanceof Furnace)) {
        return;
    }
    final Furnace furnace = (Furnace) carrier;
    final int passed = furnace.passedBurnTime().get();
    final int max = furnace.maxBurnTime().get();
    if (max <= 0 || passed >= max) {
        return;
    }
    for (SlotTransaction transaction : event.getTransactions()) {
        if (container.getInventoryProperty(transaction.getSlot(), SlotIndex.class).get().getValue() == 0) {
            if (transaction.getFinal().getType() == ItemTypes.DIRT) {
                player.getProgress(this.cookDirtAdvancement).grant();
            } else if (this.suicidalAdvancement != null && (transaction.getFinal().getType() == ItemTypes.TNT ||
                    transaction.getFinal().getType() == ItemTypes.TNT_MINECART)) {
                player.getProgress(this.suicidalAdvancement).grant();
                /*
                final Explosion explosion = Explosion.builder()
                        .location(furnace.getLocation())
                        .shouldBreakBlocks(true)
                        .canCauseFire(true)
                        .shouldDamageEntities(true)
                        .radius(7)
                        .build();
                explosion.getWorld().triggerExplosion(explosion);
                */
            }
        }
    }
}
 
开发者ID:LanternPowered,项目名称:LanternServer,代码行数:39,代码来源:AdvancementTest.java



注:本文中的org.spongepowered.api.event.filter.Getter类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java InvalidRequestException类代码示例发布时间:2022-05-22
下一篇:
Java ByteBufferWithInfo类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap