org.bukkit.block.BlockFace#valueOf ( )源码实例Demo

下面列出了org.bukkit.block.BlockFace#valueOf ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: AnnihilationPro   文件: AnniSign.java
public AnniSign(ConfigurationSection configSection)
{
	if(configSection == null)
		throw new NullPointerException();
	
	boolean signpost = configSection.getBoolean("isSignPost");
	//Location loc = ConfigManager.getLocation(configSection.getConfigurationSection("Location"));
	Loc loc = new Loc(configSection.getConfigurationSection("Location"));
	BlockFace facing = BlockFace.valueOf(configSection.getString("FacingDirection"));	
	obj = new FacingObject(facing, loc);
	this.signPost = signpost;
	String data = configSection.getString("Data");
	if(data.equalsIgnoreCase("Brewing"))
		type = SignType.Brewing;
	else if(data.equalsIgnoreCase("Weapon"))
		type = SignType.Weapon;
	else
		type = SignType.newTeamSign(AnniTeam.getTeamByName(data.split("-")[1]));
}
 
源代码2 项目: Slimefun4   文件: ProgrammableAndroid.java
protected void rotate(Block b, int mod) {
    BlockFace current = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));
    int index = POSSIBLE_ROTATIONS.indexOf(current) + mod;

    if (index == POSSIBLE_ROTATIONS.size()) {
        index = 0;
    }
    else if (index < 0) {
        index = POSSIBLE_ROTATIONS.size() - 1;
    }

    BlockFace rotation = POSSIBLE_ROTATIONS.get(index);

    Rotatable rotatatable = (Rotatable) b.getBlockData();
    rotatatable.setRotation(rotation);
    b.setBlockData(rotatatable);
    BlockStorage.addBlockInfo(b, "rotation", rotation.name());
}
 
源代码3 项目: Shopkeepers   文件: SignShop.java
@Override
protected void load(ConfigurationSection config) {
	super.load(config);
	if (config.isString("signFacing")) {
		String signFacingName = config.getString("signFacing");
		if (signFacingName != null) {
			try {
				signFacing = BlockFace.valueOf(signFacingName);
			} catch (IllegalArgumentException e) {
			}
		}
	}

	// in case no sign facing is stored: try getting the current sign facing from sign in the world
	// if it is not possible (for ex. because the world isn't loaded yet), we will reattempt this
	// during the periodically checks
	if (signFacing == null) {
		signFacing = this.getSignFacingFromWorld();
	}
}
 
源代码4 项目: GriefDefender   文件: PlayerUtil.java
public BlockFace getBlockFace(String param) {
    BlockFace face = null;
    try {
        face = BlockFace.valueOf(param.toUpperCase());
    } catch (IllegalArgumentException e) {
        // ignore
    }
    return face;
}
 
源代码5 项目: AnnihilationPro   文件: FacingObject.java
public static FacingObject loadFromConfig(ConfigurationSection configSection)
{
	if(configSection != null)
	{
		//Location loc = ConfigManager.getLocation(configSection.getConfigurationSection("Location"));
		Loc loc = new Loc(configSection.getConfigurationSection("Location"));
		BlockFace facing = BlockFace.valueOf(configSection.getString("FacingDirection"));
		return new FacingObject(facing,loc);
	}
	return null;
}
 
源代码6 项目: AreaShop   文件: RegionSign.java
/**
 * Get the facing of the sign as saved in the config.
 * @return BlockFace the sign faces, or null if unknown
 */
public BlockFace getFacing() {
	try {
		return BlockFace.valueOf(getRegion().getConfig().getString("general.signs." + key + ".facing"));
	} catch(NullPointerException | IllegalArgumentException e) {
		return null;
	}
}
 
源代码7 项目: Slimefun4   文件: ProgrammableAndroid.java
protected void tick(Block b) {
    if (b.getType() != Material.PLAYER_HEAD) {
        // The Android was destroyed or moved.
        return;
    }

    if ("false".equals(BlockStorage.getLocationInfo(b.getLocation(), "paused"))) {
        BlockMenu menu = BlockStorage.getInventory(b);
        float fuel = Float.parseFloat(BlockStorage.getLocationInfo(b.getLocation(), "fuel"));

        if (fuel < 0.001) {
            consumeFuel(b, menu);
        }
        else {
            String[] script = PatternUtils.DASH.split(BlockStorage.getLocationInfo(b.getLocation(), "script"));

            int index = Integer.parseInt(BlockStorage.getLocationInfo(b.getLocation(), "index")) + 1;
            if (index >= script.length) {
                index = 0;
            }

            boolean refresh = true;
            BlockStorage.addBlockInfo(b, "fuel", String.valueOf(fuel - 1));
            Instruction instruction = Instruction.valueOf(script[index]);

            if (getAndroidType().isType(instruction.getRequiredType())) {
                BlockFace face = BlockFace.valueOf(BlockStorage.getLocationInfo(b.getLocation(), "rotation"));

                switch (instruction) {
                case START:
                case WAIT:
                    // Just "waiting" here which means we do nothing
                    break;
                case REPEAT:
                    BlockStorage.addBlockInfo(b, "index", String.valueOf(0));
                    break;
                case CHOP_TREE:
                    refresh = chopTree(b, menu, face);
                    break;
                default:
                    instruction.execute(this, b, menu, face);
                    break;
                }
            }

            if (refresh) {
                BlockStorage.addBlockInfo(b, "index", String.valueOf(index));
            }
        }
    }
}