From 1c0e963c474bbf6b5ab0ef8c4d39f90b96700665 Mon Sep 17 00:00:00 2001 From: bensku Date: Sun, 10 Apr 2016 13:53:00 +0300 Subject: [PATCH] More progress on particle system --- .../ch/njol/skript/util/VisualEffect.java | 40 ++++++++++++------- src/main/resources/lang/english.lang | 24 +++++------ 2 files changed, 38 insertions(+), 26 deletions(-) diff --git a/src/main/java/ch/njol/skript/util/VisualEffect.java b/src/main/java/ch/njol/skript/util/VisualEffect.java index 9e68eba23fb..50f18c9f484 100644 --- a/src/main/java/ch/njol/skript/util/VisualEffect.java +++ b/src/main/java/ch/njol/skript/util/VisualEffect.java @@ -29,6 +29,7 @@ import org.bukkit.EntityEffect; import org.bukkit.Location; import org.bukkit.Material; +import org.bukkit.Particle; import org.bukkit.block.BlockFace; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -89,19 +90,19 @@ public Object getData(final @Nullable Object raw, final Location l) { MAGIC_CRIT(Effect.MAGIC_CRIT), POTION_SWIRL(Effect.POTION_SWIRL) { @Override - public boolean supportsColors() { + public boolean isColorable() { return true; } }, POTION_SWIRL_TRANSPARENT(Effect.POTION_SWIRL_TRANSPARENT) { @Override - public boolean supportsColors() { + public boolean isColorable() { return true; } }, SPELL(Effect.SPELL), INSTANT_SPELL(Effect.INSTANT_SPELL), - WITCH_MAGIC(Effect.WITCH_MAGIC), + WITCH_SPELL(Effect.WITCH_MAGIC), NOTE(Effect.NOTE), PORTAL(Effect.PORTAL), FLYING_GLYPH(Effect.FLYING_GLYPH), @@ -118,7 +119,7 @@ public boolean supportsColors() { CLOUD(Effect.CLOUD), COLOURED_DUST(Effect.COLOURED_DUST) { @Override - public boolean supportsColors() { + public boolean isColorable() { return true; } }, @@ -131,7 +132,7 @@ public boolean supportsColors() { ANGRY_VILLAGER(Effect.VILLAGER_THUNDERCLOUD), HAPPY_VILLAGER(Effect.HAPPY_VILLAGER), LARGE_SMOKE(Effect.LARGE_SMOKE), - ITEM_BREAK(Effect.ITEM_BREAK) { + ITEM_CRACK(Effect.ITEM_BREAK) { @Override public Object getData(final @Nullable Object raw, final Location l) { if (raw == null) @@ -147,7 +148,7 @@ else if (raw instanceof ItemType) { } } }, - TILE_BREAK(Effect.TILE_BREAK) { + BLOCK_BREAK(Effect.TILE_BREAK) { @SuppressWarnings("null") @Override public Object getData(final @Nullable Object raw, final Location l) { @@ -164,7 +165,7 @@ else if (raw instanceof ItemType) { } } }, - TILE_DUST(Effect.TILE_DUST) { + BLOCK_DUST(Effect.TILE_DUST) { @SuppressWarnings("null") @Override public Object getData(final @Nullable Object raw, final Location l) { @@ -204,7 +205,7 @@ public Object getData(final @Nullable Object raw, final Location l) { /** * Checks if this effect has color support. */ - public boolean supportsColors() { + public boolean isColorable() { return false; } } @@ -235,7 +236,7 @@ public void onLanguageChange() { Skript.warning("Missing pattern at '" + (node + ".pattern") + "' in the " + Language.getName() + " language file"); } else { types.add(ts[i]); - if (ts[i].supportsColors()) + if (ts[i].isColorable()) patterns.add(pattern); else { String dVarExpr = Language.get_(LANGUAGE_NODE + ".area_expression"); @@ -272,7 +273,7 @@ public VisualEffect() {} public boolean init(final Expression[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) { type = types.get(matchedPattern); - if (type.supportsColors()) { + if (type.isColorable()) { for (Expression expr : exprs) { if (expr.getReturnType() == Color.class) color = (Color) expr.getSingle(null); @@ -322,19 +323,30 @@ public final static VisualEffect parse(final String s) { } public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e) { - play(ps, l, e, 0); + play(ps, l, e, 0, 0); } - public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e, final int radius) { + @SuppressWarnings({"deprecation", "null"}) + public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e, final int count, final int radius) { assert e == null || l.equals(e.getLocation()); if (isEntityEffect()) { if (e != null) e.playEffect((EntityEffect) type.effect); } else { if (ps == null) { - if (radius == 0) + int id = 0; + int dt = 0; + + if (data instanceof Material) { + id = ((Material) data).getId(); + } else if (data instanceof MaterialData) { + id = ((MaterialData) data).getItemTypeId(); + dt = ((MaterialData) data).getData(); + } + + if (radius == 0) { l.getWorld().playEffect(l, (Effect) type.effect, type.getData(data, l)); - else + } else l.getWorld().playEffect(l, (Effect) type.effect, type.getData(data, l), radius); } else { for (final Player p : ps) diff --git a/src/main/resources/lang/english.lang b/src/main/resources/lang/english.lang index 75f78ae1f53..134b605aba0 100644 --- a/src/main/resources/lang/english.lang +++ b/src/main/resources/lang/english.lang @@ -870,9 +870,9 @@ visual effects: instant_spell: name: spell @a pattern: instant (spell|thrown potion) - witch_magic: - name: witch magic @- - pattern: witch magic|purple sparks + witch_spell: + name: witch spell @- + pattern: witch (magic|spell)|purple sparks note: name: note @a pattern: note @@ -889,8 +889,8 @@ visual effects: name: lava pop @a pattern: lava [pop] footstep: - name: footstep @a - pattern: footstep + name: footstep @x + pattern: footsteps splash: name: water splash @a pattern: [water] splash @@ -945,14 +945,14 @@ visual effects: large_smoke: name: large smoke @- pattern: large smoke - item_break: - name: item break @- - pattern: %itemtype% item break[ing] - tile_break: - name: tile break @- + item_crack: + name: item crack @- + pattern: %itemtype% item (break|crack)[ing] + block_break: + name: block break @- pattern: %itemtype% break[ing] - tile_dust: - name: tile dust @- + block_dust: + name: block dust @- pattern: [sprinting] dust of [%itemtype%] area_expression: [with] [area of %number%, %number%(,| and) %number%][[ and] speed of %number%]