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


Java EntityType.getId方法代码示例

本文整理汇总了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!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:17,代码来源:DamageEntityListener.java

示例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!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:SecondaryEntityListener.java

示例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!"));
        }
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:21,代码来源:PrimaryEntityListener.java

示例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!"));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:RideEntityMountListener.java

示例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!"));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:TameEntityListener.java

示例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!"));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:SecondaryListener.java

示例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!"));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:15,代码来源:PrimaryListener.java


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