Java Code Examples for org.bukkit.Location#setWorld()

The following examples show how to use org.bukkit.Location#setWorld() . These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@Override
public void handleNetherPortalEvent(PlayerPortalEvent event){
    Location loc = event.getFrom();
    MainConfiguration cfg = GameManager.getGameManager().getConfiguration();

    if (event.getFrom().getWorld().getEnvironment() == World.Environment.NETHER){
        loc.setWorld(Bukkit.getWorld(cfg.getOverworldUuid()));
        loc.setX(loc.getX() * 2d);
        loc.setZ(loc.getZ() * 2d);
        event.setTo(loc);
    }else{
        loc.setWorld(Bukkit.getWorld(cfg.getNetherUuid()));
        loc.setX(loc.getX() / 2d);
        loc.setZ(loc.getZ() / 2d);
        event.setTo(loc);
    }
}
 
Example 2
@Override
protected final void arrow(final SnipeData v)
{
    Player player = v.owner().getPlayer();
    Location location = this.getLastBlock().getLocation();
    Location playerLocation = player.getLocation();
    location.setPitch(playerLocation.getPitch());
    location.setYaw(playerLocation.getYaw());
    location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
    TaskManager.IMP.sync(new RunnableVal<Object>() {
        @Override
        public void run(Object value) {
            player.teleport(location);
        }
    });
}
 
Example 3
@Override
protected final void powder(final SnipeData v)
{
    Player player = v.owner().getPlayer();
    Location location = this.getLastBlock().getLocation();
    Location playerLocation = player.getLocation();
    location.setPitch(playerLocation.getPitch());
    location.setYaw(playerLocation.getYaw());
    location.setWorld(Bukkit.getWorld(location.getWorld().getName()));
    TaskManager.IMP.sync(new RunnableVal<Object>() {
        @Override
        public void run(Object value) {
            player.teleport(location);
        }
    });
}
 
Example 4
@EventHandler(priority = EventPriority.HIGHEST)
public void onPlayerRespawn(PlayerRespawnEvent event) {
	Resident resident = CivGlobal.getResident(event.getPlayer());
	
	if (!resident.isInsideArena()) {
		return;
	}
	
	Arena arena = resident.getCurrentArena();
	if (arena == null) {
		return;
	}
	
	Location loc = arena.getRespawnLocation(resident);
	if (loc != null) {
		CivMessage.send(resident, CivColor.LightGray+"Respawned in arena.");
		World world = Bukkit.getWorld(arena.getInstanceName());
		loc.setWorld(world);
		
		resident.setLastKilledTime(new Date());
		event.setRespawnLocation(loc);
	}
}
 
Example 5
Source Project: Kettle   File: CraftEntity.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(entity.posX);
        loc.setY(entity.posY);
        loc.setZ(entity.posZ);
        loc.setYaw(entity.getBukkitYaw());
        loc.setPitch(entity.rotationPitch);
    }

    return loc;
}
 
Example 6
Source Project: Kettle   File: CraftBlock.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
 
Example 7
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(world);
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
 
Example 8
Source Project: Skript   File: ExprWorld.java    License: GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(Event e, @Nullable Object[] delta, Changer.ChangeMode mode) {
	if (!(getExpr().getAll(e) instanceof Location[] && delta != null)) return;

	for (final Location loc : (Location[]) getExpr().getAll(e)) {
			loc.setWorld((World) delta[0]);
	}	
}
 
Example 9
@Nullable
@Override
public Location getLocation(final @Nullable Location loc) {
	if (loc != null) {
		loc.setWorld(getWorld());
		loc.setX(getX());
		loc.setY(getY());
		loc.setZ(getZ());
		loc.setPitch(0);
		loc.setYaw(0);
	}
	return loc;
}
 
Example 10
@Nullable
@Override
public Location getLocation(final @Nullable Location loc) {
	if (loc != null) {
		loc.setWorld(getWorld());
		loc.setX(getX());
		loc.setY(getY());
		loc.setZ(getZ());
		loc.setPitch(0);
		loc.setYaw(0);
	}
	return loc;
}
 
Example 11
Source Project: NyaaUtils   File: MailboxLocations.java    License: MIT License 5 votes vote down vote up
public Location getMailboxLocation(UUID uuid) {
    if (uuid == null) return null;
    Location loc = locationMap.get(uuid);
    if (loc == null || loc.getWorld() == null || !getLoadedWorldsName().contains(loc.getWorld().getName().toLowerCase())) {
        return null;
    }
    loc.setWorld(Bukkit.getWorld(loc.getWorld().getName()));
    return loc;
}
 
Example 12
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(entity.posX);
        loc.setY(entity.posY);
        loc.setZ(entity.posZ);
        loc.setYaw(entity.rotationYaw);
        loc.setPitch(entity.rotationPitch);
    }

    return loc;
}
 
Example 13
Source Project: Thermos   File: CraftBlock.java    License: GNU General Public License v3.0 5 votes vote down vote up
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(getWorld());
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
 
Example 14
public Location getLocation(Location loc) {
    if (loc != null) {
        loc.setWorld(world);
        loc.setX(x);
        loc.setY(y);
        loc.setZ(z);
        loc.setYaw(0);
        loc.setPitch(0);
    }

    return loc;
}
 
Example 15
@Override
public Location getLocation(Location loc) {
    if(loc != null) {
        loc.setWorld(this.getWorld());
        loc.setX((double)this.x);
        loc.setY((double)this.y);
        loc.setZ((double)this.z);
    }
    return loc;
}
 
Example 16
@Override
public Location getIslandNetherLocation() {
    Location l = getIslandLocation();
    World nether = uSkyBlock.getInstance().getWorldManager().getNetherWorld();
    if (nether == null) {
        return null;
    }
    if (l != null) {
        l.setWorld(nether);
        l.setY(l.getY() / 2);
    }
    return l;
}
 
Example 17
Location getNetherLocation(Location l) {
    Location netherLoc = l.clone();
    netherLoc.setWorld(plugin.getWorldManager().getNetherWorld());
    netherLoc.setY(Settings.nether_height);
    return netherLoc;
}
 
Example 18
private Location getNetherLocation(Location loc) {
    Location netherIsland = loc.clone();
    netherIsland.setWorld(plugin.getWorldManager().getNetherWorld());
    netherIsland.setY(loc.getY()/2);
    return netherIsland;
}