Skip to content

Commit 1c0e963

Browse files
committed
More progress on particle system
1 parent 0b4e174 commit 1c0e963

File tree

2 files changed

+38
-26
lines changed

2 files changed

+38
-26
lines changed

src/main/java/ch/njol/skript/util/VisualEffect.java

Lines changed: 26 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
import org.bukkit.EntityEffect;
3030
import org.bukkit.Location;
3131
import org.bukkit.Material;
32+
import org.bukkit.Particle;
3233
import org.bukkit.block.BlockFace;
3334
import org.bukkit.entity.Entity;
3435
import org.bukkit.entity.Player;
@@ -89,19 +90,19 @@ public Object getData(final @Nullable Object raw, final Location l) {
8990
MAGIC_CRIT(Effect.MAGIC_CRIT),
9091
POTION_SWIRL(Effect.POTION_SWIRL) {
9192
@Override
92-
public boolean supportsColors() {
93+
public boolean isColorable() {
9394
return true;
9495
}
9596
},
9697
POTION_SWIRL_TRANSPARENT(Effect.POTION_SWIRL_TRANSPARENT) {
9798
@Override
98-
public boolean supportsColors() {
99+
public boolean isColorable() {
99100
return true;
100101
}
101102
},
102103
SPELL(Effect.SPELL),
103104
INSTANT_SPELL(Effect.INSTANT_SPELL),
104-
WITCH_MAGIC(Effect.WITCH_MAGIC),
105+
WITCH_SPELL(Effect.WITCH_MAGIC),
105106
NOTE(Effect.NOTE),
106107
PORTAL(Effect.PORTAL),
107108
FLYING_GLYPH(Effect.FLYING_GLYPH),
@@ -118,7 +119,7 @@ public boolean supportsColors() {
118119
CLOUD(Effect.CLOUD),
119120
COLOURED_DUST(Effect.COLOURED_DUST) {
120121
@Override
121-
public boolean supportsColors() {
122+
public boolean isColorable() {
122123
return true;
123124
}
124125
},
@@ -131,7 +132,7 @@ public boolean supportsColors() {
131132
ANGRY_VILLAGER(Effect.VILLAGER_THUNDERCLOUD),
132133
HAPPY_VILLAGER(Effect.HAPPY_VILLAGER),
133134
LARGE_SMOKE(Effect.LARGE_SMOKE),
134-
ITEM_BREAK(Effect.ITEM_BREAK) {
135+
ITEM_CRACK(Effect.ITEM_BREAK) {
135136
@Override
136137
public Object getData(final @Nullable Object raw, final Location l) {
137138
if (raw == null)
@@ -147,7 +148,7 @@ else if (raw instanceof ItemType) {
147148
}
148149
}
149150
},
150-
TILE_BREAK(Effect.TILE_BREAK) {
151+
BLOCK_BREAK(Effect.TILE_BREAK) {
151152
@SuppressWarnings("null")
152153
@Override
153154
public Object getData(final @Nullable Object raw, final Location l) {
@@ -164,7 +165,7 @@ else if (raw instanceof ItemType) {
164165
}
165166
}
166167
},
167-
TILE_DUST(Effect.TILE_DUST) {
168+
BLOCK_DUST(Effect.TILE_DUST) {
168169
@SuppressWarnings("null")
169170
@Override
170171
public Object getData(final @Nullable Object raw, final Location l) {
@@ -204,7 +205,7 @@ public Object getData(final @Nullable Object raw, final Location l) {
204205
/**
205206
* Checks if this effect has color support.
206207
*/
207-
public boolean supportsColors() {
208+
public boolean isColorable() {
208209
return false;
209210
}
210211
}
@@ -235,7 +236,7 @@ public void onLanguageChange() {
235236
Skript.warning("Missing pattern at '" + (node + ".pattern") + "' in the " + Language.getName() + " language file");
236237
} else {
237238
types.add(ts[i]);
238-
if (ts[i].supportsColors())
239+
if (ts[i].isColorable())
239240
patterns.add(pattern);
240241
else {
241242
String dVarExpr = Language.get_(LANGUAGE_NODE + ".area_expression");
@@ -272,7 +273,7 @@ public VisualEffect() {}
272273
public boolean init(final Expression<?>[] exprs, final int matchedPattern, final Kleenean isDelayed, final ParseResult parseResult) {
273274
type = types.get(matchedPattern);
274275

275-
if (type.supportsColors()) {
276+
if (type.isColorable()) {
276277
for (Expression<?> expr : exprs) {
277278
if (expr.getReturnType() == Color.class)
278279
color = (Color) expr.getSingle(null);
@@ -322,19 +323,30 @@ public final static VisualEffect parse(final String s) {
322323
}
323324

324325
public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e) {
325-
play(ps, l, e, 0);
326+
play(ps, l, e, 0, 0);
326327
}
327328

328-
public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e, final int radius) {
329+
@SuppressWarnings({"deprecation", "null"})
330+
public void play(final @Nullable Player[] ps, final Location l, final @Nullable Entity e, final int count, final int radius) {
329331
assert e == null || l.equals(e.getLocation());
330332
if (isEntityEffect()) {
331333
if (e != null)
332334
e.playEffect((EntityEffect) type.effect);
333335
} else {
334336
if (ps == null) {
335-
if (radius == 0)
337+
int id = 0;
338+
int dt = 0;
339+
340+
if (data instanceof Material) {
341+
id = ((Material) data).getId();
342+
} else if (data instanceof MaterialData) {
343+
id = ((MaterialData) data).getItemTypeId();
344+
dt = ((MaterialData) data).getData();
345+
}
346+
347+
if (radius == 0) {
336348
l.getWorld().playEffect(l, (Effect) type.effect, type.getData(data, l));
337-
else
349+
} else
338350
l.getWorld().playEffect(l, (Effect) type.effect, type.getData(data, l), radius);
339351
} else {
340352
for (final Player p : ps)

src/main/resources/lang/english.lang

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -870,9 +870,9 @@ visual effects:
870870
instant_spell:
871871
name: spell @a
872872
pattern: instant (spell|thrown potion)
873-
witch_magic:
874-
name: witch magic @-
875-
pattern: witch magic|purple sparks
873+
witch_spell:
874+
name: witch spell @-
875+
pattern: witch (magic|spell)|purple sparks
876876
note:
877877
name: note @a
878878
pattern: note
@@ -889,8 +889,8 @@ visual effects:
889889
name: lava pop @a
890890
pattern: lava [pop]
891891
footstep:
892-
name: footstep @a
893-
pattern: footstep
892+
name: footstep @x
893+
pattern: footsteps
894894
splash:
895895
name: water splash @a
896896
pattern: [water] splash
@@ -945,14 +945,14 @@ visual effects:
945945
large_smoke:
946946
name: large smoke @-
947947
pattern: large smoke
948-
item_break:
949-
name: item break @-
950-
pattern: %itemtype% item break[ing]
951-
tile_break:
952-
name: tile break @-
948+
item_crack:
949+
name: item crack @-
950+
pattern: %itemtype% item (break|crack)[ing]
951+
block_break:
952+
name: block break @-
953953
pattern: %itemtype% break[ing]
954-
tile_dust:
955-
name: tile dust @-
954+
block_dust:
955+
name: block dust @-
956956
pattern: [sprinting] dust of [%itemtype%]
957957
area_expression: [with] [area of %number%, %number%(,| and) %number%][[ and] speed of %number%]
958958

0 commit comments

Comments
 (0)