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