Skip to content

Instantly share code, notes, and snippets.

@macalinao
Created December 21, 2011 22:09
Show Gist options
  • Save macalinao/1507954 to your computer and use it in GitHub Desktop.
Save macalinao/1507954 to your computer and use it in GitHub Desktop.
@SpellInfo(id = "thunderstorm",
name = "ThunderStorm")
public class SpellThunderStorm implements Spell {
public Map<String, Integer> taskID = new HashMap<String, Integer>();
private MagicRPG mr;
public SpellThunderStorm(MagicRPG mr) {
this.mr = mr;
}
public void cast(final Player caster) {
final Random rand = new Random();
final Location playerLoc = caster.getLocation();
final int stormTask = Bukkit.getScheduler().scheduleSyncRepeatingTask(mr, new Runnable() {
int i = 0;
public void run() {
i++;
if (i == 10) {
Bukkit.getScheduler().cancelTask(taskID.get(caster.getName()));
}
Location loc = new Location(caster.getWorld(), playerLoc.getBlockX() + rand.nextInt(10), playerLoc.getBlockY() - rand.nextInt(5), playerLoc.getBlockZ() + rand.nextInt(10));
caster.getWorld().strikeLightning(loc);
caster.getWorld().strikeLightning(loc);
}
}, 0L, 20L);
taskID.put(caster.getName(), stormTask);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment