Advertisement
Guest User

Untitled

a guest
Jan 4th, 2012
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.62 KB | None | 0 0
  1. package de.V10lator.V10verlap;
  2.  
  3. import org.bukkit.Chunk;
  4. import org.bukkit.Location;
  5. import org.bukkit.Server;
  6. import org.bukkit.World;
  7. import org.bukkit.entity.Entity;
  8. import org.bukkit.entity.LivingEntity;
  9. import org.bukkit.util.Vector;
  10.  
  11. class V10verlapTask implements Runnable
  12. {
  13.   private final V10verlap plugin;
  14.   private final String world;
  15.   private final String lowerWorld;
  16.   private final String upperWorld;
  17.  
  18.   V10verlapTask(V10verlap plugin, String world, String lowerWorld, String upperWorld)
  19.   {
  20.     this.plugin = plugin;
  21.     this.world = world;
  22.     this.lowerWorld = lowerWorld;
  23.     this.upperWorld = upperWorld;
  24.   }
  25.  
  26.   public void run()
  27.   {
  28.     Server s = plugin.getServer();
  29.     World w = s.getWorld(world);
  30.     Location loc;
  31.     World to;
  32.     int y;
  33.     Vector v;
  34.     for(Chunk c: w.getLoadedChunks())
  35.     {
  36.       for(Entity e: c.getEntities())
  37.       {
  38.         if(e instanceof LivingEntity &&
  39.                 ((LivingEntity)e).isInsideVehicle())
  40.           continue;
  41.         loc = e.getLocation();
  42.         y = loc.getBlockY();
  43.         if(lowerWorld != null && y < 0)
  44.         {
  45.           to = s.getWorld(lowerWorld);
  46.           if(to == null)
  47.             continue;
  48.          
  49.           loc.setWorld(to);
  50.           loc.setY(to.getMaxHeight() - 1);
  51.           e.teleport(loc);
  52.           System.out.print("Teleporting "+e.getClass().getName()+" from "+world+" down to "+to.getName());
  53.         }
  54.         else if(upperWorld != null && y > w.getMaxHeight())
  55.         {
  56.           to = s.getWorld(upperWorld);
  57.           if(to == null)
  58.             continue;
  59.           loc.setWorld(to);
  60.           loc.setY(1);
  61.           e.teleport(loc);
  62.           System.out.print("Teleporting "+e.getClass().getName()+" from "+world+" up to "+to.getName());
  63.         }
  64.       }
  65.     }
  66.   }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement