当前位置: 首页>>代码示例>>Java>>正文


Java Getter类代码示例

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


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


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