Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package de.V10lator.V10verlap;
- import org.bukkit.Chunk;
- import org.bukkit.Location;
- import org.bukkit.Server;
- import org.bukkit.World;
- import org.bukkit.entity.Entity;
- import org.bukkit.entity.LivingEntity;
- import org.bukkit.util.Vector;
- class V10verlapTask implements Runnable
- {
- private final V10verlap plugin;
- private final String world;
- private final String lowerWorld;
- private final String upperWorld;
- V10verlapTask(V10verlap plugin, String world, String lowerWorld, String upperWorld)
- {
- this.plugin = plugin;
- this.world = world;
- this.lowerWorld = lowerWorld;
- this.upperWorld = upperWorld;
- }
- public void run()
- {
- Server s = plugin.getServer();
- World w = s.getWorld(world);
- Location loc;
- World to;
- int y;
- Vector v;
- for(Chunk c: w.getLoadedChunks())
- {
- for(Entity e: c.getEntities())
- {
- if(e instanceof LivingEntity &&
- ((LivingEntity)e).isInsideVehicle())
- continue;
- loc = e.getLocation();
- y = loc.getBlockY();
- if(lowerWorld != null && y < 0)
- {
- to = s.getWorld(lowerWorld);
- if(to == null)
- continue;
- loc.setWorld(to);
- loc.setY(to.getMaxHeight() - 1);
- e.teleport(loc);
- System.out.print("Teleporting "+e.getClass().getName()+" from "+world+" down to "+to.getName());
- }
- else if(upperWorld != null && y > w.getMaxHeight())
- {
- to = s.getWorld(upperWorld);
- if(to == null)
- continue;
- loc.setWorld(to);
- loc.setY(1);
- e.teleport(loc);
- System.out.print("Teleporting "+e.getClass().getName()+" from "+world+" up to "+to.getName());
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement