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


Java FireworkEffect.builder方法代码示例

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


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

示例1: playFirework

import org.bukkit.FireworkEffect; //导入方法依赖的package包/类
public void playFirework(Player p, Location loc, Color color1, Color color2, FireworkEffect.Type type) {
	loc.add(0.5, 1, 0.5);
	Firework fw = p.getWorld().spawn(loc, Firework.class);
	FireworkMeta fwmeta = ((org.bukkit.entity.Firework) fw).getFireworkMeta();
	FireworkEffect.Builder builder = FireworkEffect.builder();

	builder.withFlicker();
	builder.withFade(color2);
	builder.withColor(color1);
	builder.with(type);
	fwmeta.clearEffects();
	Field f;
	try {
		f = fwmeta.getClass().getDeclaredField("power");
		f.setAccessible(true);
		f.set(fwmeta, -1);
	} catch (Exception e) {
		return;
	}
	fwmeta.addEffect(builder.build());
	fw.setFireworkMeta(fwmeta);
}
 
开发者ID:ThEWiZ76,项目名称:KingdomFactions,代码行数:23,代码来源:Utils.java

示例2: read

import org.bukkit.FireworkEffect; //导入方法依赖的package包/类
@Override
public void read(DataInputStream input) throws IOException {
    FireworkEffect.Builder builder = FireworkEffect.builder();
    
    builder.flicker(input.readBoolean());
    builder.trail(input.readBoolean());
    
    int len = input.readInt();
    for(int i = 0; i < len; i++) {
        builder.withColor(Color.fromRGB(input.readInt(), input.readInt(), input.readInt()));
    }
    
    len = input.readInt();
    for(int i = 0; i < len; i++) {
        builder.withFade(Color.fromRGB(input.readInt(), input.readInt(), input.readInt()));
    }
    
    builder.with(FireworkEffect.Type.valueOf(input.readUTF()));
}
 
开发者ID:OrigamiDream,项目名称:Leveled-Storage,代码行数:20,代码来源:FireworkEffectStorage.java

示例3: KimuraFirework

import org.bukkit.FireworkEffect; //导入方法依赖的package包/类
@EventHandler
public void KimuraFirework(PlayerDeathEvent event) {
    Player player = event.getEntity();

    // check if player is Kimura or not
    if (!player.getPlayerListName().contains("schinchig")) return;

    // spawn Firework
    World world = player.getWorld();
    Firework firework = (Firework) world.spawnEntity(player.getLocation(), EntityType.FIREWORK);

    // set firework random meta infomations
    FireworkMeta meta = firework.getFireworkMeta();
    FireworkEffect.Builder builder = FireworkEffect.builder();

    builder.withColor(getRandomColors(1 + rand.nextInt(5)));
    builder.withFade(getRandomColors(1 + rand.nextInt(3)));
    builder.flicker(rand.nextBoolean());
    builder.trail(rand.nextBoolean());
    builder.with(FireworkEffect.Type.values()[rand.nextInt(5)]);

    meta.setPower(1 + rand.nextInt(4));

    meta.addEffect(builder.build());
    firework.setFireworkMeta(meta);
}
 
开发者ID:popkirby,项目名称:KimuraPlugin,代码行数:27,代码来源:KimuraFireworkOnDeath.java

示例4: getFireworkEffect

import org.bukkit.FireworkEffect; //导入方法依赖的package包/类
private static FireworkEffect getFireworkEffect(JsonObject json) {
    FireworkEffect.Builder builder = FireworkEffect.builder();

    //colors
    JsonArray colors = json.getAsJsonArray("colors");
    for (int j = 0; j < colors.size() - 1; j++) {
        builder.withColor(getColor(colors.get(j).getAsJsonObject()));
    }

    //fade colors
    JsonArray fadeColors = json.getAsJsonArray("fade-colors");
    for (int j = 0; j < fadeColors.size() - 1; j++) {
        builder.withFade(getColor(colors.get(j).getAsJsonObject()));
    }

    //hasFlicker
    if (json.get("flicker").getAsBoolean())
        builder.withFlicker();

    //trail
    if (json.get("trail").getAsBoolean())
        builder.withTrail();

    //type
    builder.with(FireworkEffect.Type.valueOf(json.get("type").getAsString()));

    return builder.build();
}
 
开发者ID:Gnat008,项目名称:PerWorldInventory,代码行数:29,代码来源:DeprecatedMethodUtil.java


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