Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class testCounter
- {
- private final Plugin plugin;
- private int countdownTimer;
- private LivingEntity horse;
- private String name;
- private WitherSkull skull;
- private boolean stopped;
- public static List<Integer> test = new ArrayList<Integer>();
- @SuppressWarnings("deprecation")
- public testCounter(Plugin plugin2, String name)
- {
- this.stopped = false;
- this.name = name;
- this.plugin = plugin2;
- this.horse = Bukkit.getPlayer(name).getWorld().spawnCreature(new Location(Bukkit.getPlayer(name).getLocation().getWorld(), Bukkit.getPlayer(name).getLocation().getBlockX(), Bukkit.getPlayer(name).getLocation().getBlockY() + 68, Bukkit.getPlayer(name).getLocation().getBlockZ()), EntityType.HORSE);
- this.skull = Bukkit.getPlayer(name).getWorld().spawn((new Location(Bukkit.getPlayer(name).getLocation().getWorld(), Bukkit.getPlayer(name).getLocation().getBlockX(), Bukkit.getPlayer(name).getLocation().getBlockY() + 68, Bukkit.getPlayer(name).getLocation().getBlockZ())), WitherSkull.class);
- this.skull.setPassenger((Entity) this.horse);
- this.skull.setDirection(new Vector(0,0,0));
- ((CraftAgeable) this.horse).setAge(-1700000);
- this.horse.setCustomName(name);
- this.horse.setCustomNameVisible(true);
- this.start(this.skull.getLocation(), this.name);
- }
- public void stop() {
- this.stopped = true;
- }
- public void start(Location horse, final String msg)
- {
- this.countdownTimer = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, new Runnable()
- {
- int i = 0;
- @SuppressWarnings("deprecation")
- public void run()
- {
- if (this.i > 0)
- {
- if(i < msg.length()+1) {
- ((Entity) testCounter.this.horse).remove();
- Location skulls = new Location(testCounter.this.skull.getLocation().getWorld(), testCounter.this.skull.getLocation().getBlockX(), testCounter.this.skull.getLocation().getBlockY(), testCounter.this.skull.getLocation().getBlockZ());
- testCounter.this.skull.remove();
- testCounter.this.horse = Bukkit.getPlayer(name).getWorld().spawnCreature(new Location(testCounter.this.skull.getLocation().getWorld(), testCounter.this.skull.getLocation().getBlockX(), testCounter.this.skull.getLocation().getBlockY() + 65, testCounter.this.skull.getLocation().getBlockZ()), EntityType.HORSE);
- testCounter.this.horse.setNoDamageTicks(40);
- testCounter.this.skull = Bukkit.getPlayer(name).getWorld().spawn(skulls, WitherSkull.class);
- testCounter.this.skull.setPassenger((Entity) testCounter.this.horse);
- ((CraftAgeable) testCounter.this.horse).setAge(-1700000);
- testCounter.this.horse.setCustomName(name.substring(0, this.i));
- testCounter.this.horse.setCustomNameVisible(true);
- testCounter.this.skull.setDirection(new Vector(0,0,0));
- this.i++;
- } else {
- testCounter.this.cancel();
- if(!stopped) {
- testCounter.this.start(testCounter.this.skull.getLocation(), testCounter.this.name);
- }
- this.i = 0;
- }
- } else {
- this.i++;
- }
- }
- }, 0L, 2L);
- testCounter.test.add(this.countdownTimer);
- }
- public static void cancelAll() {
- for(int sc : testCounter.test) {
- Bukkit.getScheduler().cancelTask(sc);
- }
- }
- public void cancel()
- {
- Bukkit.getScheduler().cancelTask(this.countdownTimer);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement