本文整理汇总了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() + '!'));
}
}
}
示例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() + '!'));
}
}
}
示例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;
}
}
}
示例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;
}
}
}
示例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() + '!'));
}
}
示例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() + '!'));
}
}