Advertisement
madcatzano

Simple "Animated" horse display class - Bukkit

Mar 13th, 2015
228
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.49 KB | None | 0 0
  1. public class testCounter
  2. {
  3.   private final Plugin plugin;
  4.   private int countdownTimer;
  5.   private LivingEntity horse;
  6.   private String name;
  7.   private WitherSkull skull;
  8.   private boolean stopped;
  9.   public static List<Integer> test = new ArrayList<Integer>();
  10.   @SuppressWarnings("deprecation")
  11. public testCounter(Plugin plugin2, String name)
  12.   {
  13.       this.stopped = false;
  14.       this.name = name;
  15.     this.plugin = plugin2;
  16.    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);
  17.    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);
  18.    this.skull.setPassenger((Entity) this.horse);
  19.    this.skull.setDirection(new Vector(0,0,0));
  20.    ((CraftAgeable) this.horse).setAge(-1700000);
  21.    this.horse.setCustomName(name);
  22.    this.horse.setCustomNameVisible(true);
  23.    this.start(this.skull.getLocation(), this.name);
  24.   }
  25.  
  26.   public void stop() {
  27.       this.stopped = true;
  28.   }
  29.   public void start(Location horse, final String msg)
  30.   {
  31.       this.countdownTimer = Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(this.plugin, new Runnable()
  32.       {
  33.           int i = 0;
  34.       @SuppressWarnings("deprecation")
  35.     public void run()
  36.       {
  37.    
  38.         if (this.i > 0)
  39.         {
  40.             if(i < msg.length()+1) {
  41.                     ((Entity) testCounter.this.horse).remove();
  42.                     Location skulls = new Location(testCounter.this.skull.getLocation().getWorld(), testCounter.this.skull.getLocation().getBlockX(), testCounter.this.skull.getLocation().getBlockY(), testCounter.this.skull.getLocation().getBlockZ());
  43.                     testCounter.this.skull.remove();
  44.                     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);
  45.                    
  46.                     testCounter.this.horse.setNoDamageTicks(40);
  47.                    testCounter.this.skull =  Bukkit.getPlayer(name).getWorld().spawn(skulls, WitherSkull.class);
  48.                    testCounter.this.skull.setPassenger((Entity) testCounter.this.horse);
  49.                    ((CraftAgeable) testCounter.this.horse).setAge(-1700000);
  50.                    testCounter.this.horse.setCustomName(name.substring(0, this.i));
  51.                    testCounter.this.horse.setCustomNameVisible(true);
  52.                    testCounter.this.skull.setDirection(new Vector(0,0,0));
  53.                     this.i++;
  54.             } else {
  55.                     testCounter.this.cancel();
  56.                     if(!stopped) {
  57.                     testCounter.this.start(testCounter.this.skull.getLocation(), testCounter.this.name);
  58.                     }
  59.                     this.i = 0;
  60.             }
  61.         } else {
  62.             this.i++;
  63.         }
  64.       }
  65.     }, 0L, 2L);
  66.       testCounter.test.add(this.countdownTimer);
  67.   }
  68.  
  69.   public static void cancelAll() {
  70.       for(int sc : testCounter.test) {
  71.           Bukkit.getScheduler().cancelTask(sc);
  72.       }
  73.   }
  74.      
  75.   public void cancel()
  76.   {
  77.     Bukkit.getScheduler().cancelTask(this.countdownTimer);
  78.   }
  79. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement