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


Java BlockState.getId方法代码示例

本文整理汇总了Java中org.spongepowered.api.block.BlockState.getId方法的典型用法代码示例。如果您正苦于以下问题:Java BlockState.getId方法的具体用法?Java BlockState.getId怎么用?Java BlockState.getId使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.spongepowered.api.block.BlockState的用法示例。


在下文中一共展示了BlockState.getId方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: onInteractBlockPrimaryMain

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onInteractBlockPrimaryMain(InteractBlockEvent.Primary event, @Root Player player) {
    Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
    if(itemStackOptional.isPresent()) {

        BlockState blockState = event.getTargetBlock().getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        ItemType itemType = itemStackOptional.get().getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

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

示例2: onInteractBlockSecondaryMain

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onInteractBlockSecondaryMain(InteractBlockEvent.Secondary event, @Root Player player) {
    Optional<ItemStack> itemStackOptional = player.getItemInHand(event.getHandType());
    if(itemStackOptional.isPresent()) {

        BlockState blockState = event.getTargetBlock().getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        ItemType itemType = itemStackOptional.get().getType();
        String itemId = itemType.getId();

        PermHandler ph = PermHandler.getInstance();

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

示例3: onBlockPlace

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onBlockPlace(ChangeBlockEvent.Place event, @Root Player player) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    for (Transaction<BlockSnapshot> transaction : transactions) {

        BlockSnapshot snapshot = transaction.getFinal();
        BlockState blockState = snapshot.getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        PermHandler ph = PermHandler.getInstance();

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

示例4: onBlockBreak

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Root Player player) {
    List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
    for (Transaction<BlockSnapshot> transaction : transactions) {

        BlockSnapshot snapshot = transaction.getOriginal();
        BlockState blockState = snapshot.getState();
        String blockTypeId = blockState.getType().getId();
        String blockStateId = blockState.getId();

        PermHandler ph = PermHandler.getInstance();

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

示例5: onInteractBlockSecondary

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onInteractBlockSecondary(InteractBlockEvent.Secondary event, @Root Player player) {

    BlockState blockState = event.getTargetBlock().getState();
    String blockTypeId = blockState.getType().getId();
    String blockStateId = blockState.getId();

    PermHandler ph = PermHandler.getInstance();

    if (!ph.checkPerm(player, "protectionperms.block.interact." + blockTypeId + ".secondary",
            "protectionperms.block.interact." + blockStateId + ".secondary")) {
        event.setCancelled(true);
        player.sendMessage(ChatTypes.ACTION_BAR,
                Text.of(TextColors.RED, "You don't have permission to secondary interact with " + blockState.getName() + '!'));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:17,代码来源:SecondaryListener.java

示例6: onInteractBlockPrimary

import org.spongepowered.api.block.BlockState; //导入方法依赖的package包/类
@Listener
public void onInteractBlockPrimary(InteractBlockEvent.Primary event, @Root Player player) {

    BlockState blockState = event.getTargetBlock().getState();
    String blockTypeId = blockState.getType().getId();
    String blockStateId = blockState.getId();

    PermHandler ph = PermHandler.getInstance();

    if (!ph.checkPerm(player, "protectionperms.block.interact." + blockTypeId + ".primary",
            "protectionperms.block.interact." + blockStateId + ".primary")) {
        event.setCancelled(true);
        player.sendMessage(ChatTypes.ACTION_BAR,
                Text.of(TextColors.RED, "You don't have permission to primary interact with " + blockState.getName() + '!'));
    }
}
 
开发者ID:Zerthick,项目名称:ProtectionPerms,代码行数:17,代码来源:PrimaryListener.java


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