當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。