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


Java BlockSnapshot.getState方法代码示例

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


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

示例1: onBlockPlace

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的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

示例2: onBlockBreak

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的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

示例3: onBlockBreakGlobal

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
public void onBlockBreakGlobal(ChangeBlockEvent.Break e, @First Player p) {
	RedProtect.get().logger.debug("default","RPGlobalListener - Is BlockBreakEvent event! Cancelled? " + e.isCancelled());

	BlockSnapshot bt = e.getTransactions().get(0).getOriginal();
	BlockState b = bt.getState();
	World w = bt.getLocation().get().getExtent();
	Region r = RedProtect.get().rm.getTopRegion(bt.getLocation().get());
	if (r != null){
		return;
	}

	if (!RPUtil.canBuildNear(p, bt.getLocation().get())){
		e.setCancelled(true);
		return;
	}

	if (!bypassBuild(p, bt, 2)){
		e.setCancelled(true);
	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:22,代码来源:RPGlobalListener.java

示例4: onFireSpread

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener(order = Order.FIRST, beforeModifications = true)	
   public void onFireSpread(NotifyNeighborBlockEvent  e, @First BlockSnapshot source){
	
	Map<Direction, BlockState> dirs = e.getNeighbors();
   	
   	for (Direction dir:dirs.keySet()){
   		BlockSnapshot b = source.getLocation().get().getRelative(dir).createSnapshot();
   		BlockState bstate = source.getState();
       	Region r = RedProtect.get().rm.getTopRegion(b.getLocation().get());   
   		if (r != null){
       		return;
       	}
   		
   		if ((bstate.getType().equals(BlockTypes.FIRE) || bstate.getType().getName().contains("lava")) && 
   				!RedProtect.get().cfgs.getGlobalFlag(b.getLocation().get().getExtent().getName(),"fire-spread")){
   			e.setCancelled(true);
   			return;
   		}
   	}
}
 
开发者ID:FabioZumbi12,项目名称:RedProtect,代码行数:21,代码来源:RPGlobalListener.java

示例5: onPlayerClick

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onPlayerClick(InteractBlockEvent.Secondary event, @First Player player) {
    if (state.equals(State.CLICK) && player.getUniqueId().equals(getParent().getUUID())) {
        BlockSnapshot snapshot = event.getTargetBlock();
        // Make sure the block was clicked twice
        if (doubleClickCurrent == null) {
            doubleClickTick = Sponge.getServer().getRunningTimeTicks();
            doubleClickCurrent = snapshot;
        } else {
            if (doubleClickCurrent.equals(snapshot) && Sponge.getServer().getRunningTimeTicks() - doubleClickTick > 5) {
                doubleClickCurrent = null;
                doubleClickTick = 0;
                player.sendMessage(messages.getMessage("creation.breakcurrency"));
                blockState = snapshot.getState();
                state = State.CURRENCY;
            } else {
                doubleClickTick = Sponge.getServer().getRunningTimeTicks();
                doubleClickCurrent = snapshot;
            }
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:23,代码来源:BreakTask.java

示例6: onPlayerClick

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onPlayerClick(InteractBlockEvent event, @First Player player) {
    if (state.equals(State.CLICK) && player.getUniqueId().equals(getParent().getUUID())) {
        BlockSnapshot snapshot = event.getTargetBlock();
        // Make sure the block was clicked twice
        if (doubleClickCurrent == null) {
            doubleClickTick = Sponge.getServer().getRunningTimeTicks();
            doubleClickCurrent = snapshot;
        } else {
            if (doubleClickCurrent.equals(snapshot) && Sponge.getServer().getRunningTimeTicks() - doubleClickTick > 5) {
                doubleClickCurrent = null;
                doubleClickTick = 0;
                player.sendMessage(messages.getMessage("creation.placecurrency"));
                blockState = snapshot.getState();
                state = State.CURRENCY;
            } else {
                doubleClickTick = Sponge.getServer().getRunningTimeTicks();
                doubleClickCurrent = snapshot;
            }
        }
    }
}
 
开发者ID:Flibio,项目名称:JobsLite,代码行数:23,代码来源:PlaceTask.java

示例7: BlockSnapshotView

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
public BlockSnapshotView(BlockSnapshot value) {
    super(value);

    this.creator = value.getCreator().orElse(null);
    this.location = value.getLocation().orElse(null);
    this.state = value.getState();
}
 
开发者ID:Valandur,项目名称:Web-API,代码行数:8,代码来源:BlockSnapshotView.java

示例8: onBlockBreak

import org.spongepowered.api.block.BlockSnapshot; //导入方法依赖的package包/类
@Listener
public void onBlockBreak(ChangeBlockEvent.Break event, @Named(NamedCause.SOURCE) Entity srcEnt) {
  if (!isApplicable(srcEnt)) {
    return;
  }

  List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
  for (Transaction<BlockSnapshot> block : transactions) {
    BlockSnapshot original = block.getOriginal();
    if (original.getCreator().isPresent()) {
      continue;
    }

    Optional<Location<World>> optLoc = original.getLocation();

    if (!optLoc.isPresent()) {
      continue;
    }

    Location<World> loc = optLoc.get();

    BlockState state = original.getState();

    // Prevent item dupe glitch by removing the position before subsequent breaks
    markedOrePoints.remove(loc);
    if (config.getDropModification().blocks(state)) {
      markedOrePoints.add(loc);
    }
  }
}
 
开发者ID:Skelril,项目名称:Skree,代码行数:31,代码来源:BuildWorldWrapper.java


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