本文整理汇总了Java中org.spongepowered.api.entity.EntityType.getId方法的典型用法代码示例。如果您正苦于以下问题:Java EntityType.getId方法的具体用法?Java EntityType.getId怎么用?Java EntityType.getId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.spongepowered.api.entity.EntityType
的用法示例。
在下文中一共展示了EntityType.getId方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: onEntityDamage
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onEntityDamage(DamageEntityEvent event, @Root EntityDamageSource dmgSource) {
if(dmgSource.getSource() instanceof Player) {
Player player = (Player)dmgSource.getSource();
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.damage." + entityId + ".deal")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to damage " + entityType.getName() + "s!"));
}
}
}
示例2: onInteractEntitySecondaryMain
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondaryMain(InteractEntityEvent.Secondary event, @Root Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
if(itemStackOptional.isPresent()) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
ItemType itemType = itemStackOptional.get().getType();
String itemId = itemType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
}
}
}
示例3: onInteractEntityPrimaryMain
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onInteractEntityPrimaryMain(InteractEntityEvent.Primary event, @Root Player player) {
Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
if(itemStackOptional.isPresent()) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
ItemType itemType = itemStackOptional.get().getType();
String itemId = itemType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.item.use." + itemId + ".on." + entityId + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to primary use " + itemType.getName() + " on " + entityType.getName() + "s!"));
}
}
}
示例4: onEntityMount
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onEntityMount(RideEntityEvent.Mount event, @Root Player player) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.mount." + entityId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to mount " + entityType.getName() + "s!"));
}
}
示例5: onEntityTame
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onEntityTame(TameEntityEvent event, @Root Player player) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.tame." + entityId)) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to tame " + entityType.getName() + "s!"));
}
}
示例6: onInteractEntitySecondary
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onInteractEntitySecondary(InteractEntityEvent.Secondary event, @Root Player player) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.interact." + entityId + ".secondary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to secondary interact with " + entityType.getName() + "s!"));
}
}
示例7: onInteractEntityPrimary
import org.spongepowered.api.entity.EntityType; //导入方法依赖的package包/类
@Listener
public void onInteractEntityPrimary(InteractEntityEvent.Primary event, @Root Player player) {
EntityType entityType = event.getTargetEntity().getType();
String entityId = entityType.getId();
PermHandler ph = PermHandler.getInstance();
if (!ph.checkPerm(player, "protectionperms.entity.interact." + entityId + ".primary")) {
event.setCancelled(true);
player.sendMessage(ChatTypes.ACTION_BAR,
Text.of(TextColors.RED, "You don't have permission to primary interact with " + entityType.getName() + "s!"));
}
}