Created
December 21, 2011 22:09
-
-
Save macalinao/1507954 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@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