Added back in deprecated methods.
This commit is contained in:
parent
b19b86435c
commit
2c3e0701c5
|
@ -686,42 +686,91 @@ public class IslandsManager {
|
|||
* @param name - named home location. Blank means default.
|
||||
* @return Location of a safe teleport spot or {@code null} if one cannot be
|
||||
* found or if the world is not an island world.
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
/*
|
||||
* @Nullable
|
||||
*
|
||||
* @Deprecated public Location getSafeHomeLocation(@NonNull World
|
||||
* world, @NonNull User user, String name) { // Check if the world is a gamemode
|
||||
* world if (!plugin.getIWM().inWorld(world)) { return null; } // Try the named
|
||||
* home location first Location l = getHomeLocation(world, user, name); if (l ==
|
||||
* null) { // Get the default home, which may be null too, but that's okay name
|
||||
* = ""; l = getHomeLocation(world, user, name); } // Check if it is safe if (l
|
||||
* != null) { if (isSafeLocation(l)) { return l; } // To cover slabs, stairs and
|
||||
* other half blocks, try one block above Location lPlusOne = l.clone();
|
||||
* lPlusOne.add(new Vector(0, 1, 0)); if (isSafeLocation(lPlusOne)) { // Adjust
|
||||
* the home location accordingly setHomeLocation(user, lPlusOne, name); return
|
||||
* lPlusOne; } } // Home location either isn't safe, or does not exist so try
|
||||
* the island // location if (inTeam(world, user.getUniqueId())) { l =
|
||||
* getIslandLocation(world, user.getUniqueId()); if (l != null &&
|
||||
* isSafeLocation(l)) { setHomeLocation(user, l, name); return l; } else { //
|
||||
* try owner's home UUID owner = getOwner(world, user.getUniqueId()); if (owner
|
||||
* != null) { Location tlh = getHomeLocation(world, owner); if (tlh != null &&
|
||||
* isSafeLocation(tlh)) { setHomeLocation(user, tlh, name); return tlh; } } } }
|
||||
* else { l = getIslandLocation(world, user.getUniqueId()); if (l != null &&
|
||||
* isSafeLocation(l)) { setHomeLocation(user, l, name); return l.clone().add(new
|
||||
* Vector(0.5D, 0, 0.5D)); } } if (l == null) { plugin.logWarning(user.getName()
|
||||
* + " player has no island in world " + world.getName() + "!"); return null; }
|
||||
* // If these island locations are not safe, then we need to get creative //
|
||||
* Try the default location Location dl = new Location(l.getWorld(), l.getX() +
|
||||
* 0.5D, l.getY() + 5D, l.getZ() + 2.5D, 0F, 30F); if (isSafeLocation(dl)) {
|
||||
* setHomeLocation(user, dl, name); return dl; } // Try just above the bedrock
|
||||
* dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() +
|
||||
* 0.5D, 0F, 30F); if (isSafeLocation(dl)) { setHomeLocation(user, dl, name);
|
||||
* return dl; } // Try all the way up to the sky for (int y = l.getBlockY(); y <
|
||||
* 255; y++) { final Location n = new Location(l.getWorld(), l.getX() + 0.5D, y,
|
||||
* l.getZ() + 0.5D); if (isSafeLocation(n)) { setHomeLocation(user, n, name);
|
||||
* return n; } } // Unsuccessful return null; }
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@Nullable
|
||||
public Location getSafeHomeLocation(@NonNull World world, @NonNull User user, String name) {
|
||||
// Check if the world is a gamemode world
|
||||
if (!plugin.getIWM().inWorld(world)) {
|
||||
return null;
|
||||
}
|
||||
// Try the named home location first
|
||||
Location l = getHomeLocation(world, user, name);
|
||||
if (l == null) {
|
||||
// Get the default home, which may be null too, but that's okay
|
||||
name = "";
|
||||
l = getHomeLocation(world, user, name);
|
||||
}
|
||||
// Check if it is safe
|
||||
if (l != null) {
|
||||
if (isSafeLocation(l)) {
|
||||
return l;
|
||||
}
|
||||
// To cover slabs, stairs and other half blocks, try one block above
|
||||
Location lPlusOne = l.clone();
|
||||
lPlusOne.add(new Vector(0, 1, 0));
|
||||
if (isSafeLocation(lPlusOne)) {
|
||||
// Adjust the home location accordingly
|
||||
setHomeLocation(user, lPlusOne, name);
|
||||
return lPlusOne;
|
||||
}
|
||||
}
|
||||
// Home location either isn't safe, or does not exist so try the island
|
||||
// location
|
||||
if (inTeam(world, user.getUniqueId())) {
|
||||
l = getIslandLocation(world, user.getUniqueId());
|
||||
if (l != null && isSafeLocation(l)) {
|
||||
setHomeLocation(user, l, name);
|
||||
return l;
|
||||
} else {
|
||||
// try owner's home
|
||||
UUID owner = getOwner(world, user.getUniqueId());
|
||||
if (owner != null) {
|
||||
Location tlh = getHomeLocation(world, owner);
|
||||
if (tlh != null && isSafeLocation(tlh)) {
|
||||
setHomeLocation(user, tlh, name);
|
||||
return tlh;
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
l = getIslandLocation(world, user.getUniqueId());
|
||||
if (l != null && isSafeLocation(l)) {
|
||||
setHomeLocation(user, l, name);
|
||||
return l.clone().add(new Vector(0.5D, 0, 0.5D));
|
||||
}
|
||||
}
|
||||
if (l == null) {
|
||||
plugin.logWarning(user.getName() + " player has no island in world " + world.getName() + "!");
|
||||
return null;
|
||||
}
|
||||
// If these island locations are not safe, then we need to get creative
|
||||
// Try the default location
|
||||
Location dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 2.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
setHomeLocation(user, dl, name);
|
||||
return dl;
|
||||
}
|
||||
// Try just above the bedrock
|
||||
dl = new Location(l.getWorld(), l.getX() + 0.5D, l.getY() + 5D, l.getZ() + 0.5D, 0F, 30F);
|
||||
if (isSafeLocation(dl)) {
|
||||
setHomeLocation(user, dl, name);
|
||||
return dl;
|
||||
}
|
||||
// Try all the way up to the sky
|
||||
for (int y = l.getBlockY(); y < 255; y++) {
|
||||
final Location n = new Location(l.getWorld(), l.getX() + 0.5D, y, l.getZ() + 0.5D);
|
||||
if (isSafeLocation(n)) {
|
||||
setHomeLocation(user, n, name);
|
||||
return n;
|
||||
}
|
||||
}
|
||||
// Unsuccessful
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets a default home location on user's island. Replaces previous default
|
||||
|
@ -965,13 +1014,16 @@ public class IslandsManager {
|
|||
* @param world world to check
|
||||
* @param playerUUID the player's UUID
|
||||
* @return island owner's UUID or null if player has no island
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
/*
|
||||
* @Deprecated
|
||||
*
|
||||
* @Nullable public UUID getOwner(@NonNull World world, @NonNull UUID
|
||||
* playerUUID) { return islandCache.getOwner(world, playerUUID); }
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
@Nullable
|
||||
public UUID getOwner(@NonNull World world, @NonNull UUID playerUUID) {
|
||||
return islandCache.getOwner(world, playerUUID);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks if a player has an island in the world and owns it. Note that players
|
||||
* may have more than one island
|
||||
|
@ -1236,12 +1288,15 @@ public class IslandsManager {
|
|||
/**
|
||||
* @param uniqueId - unique ID
|
||||
* @return true if the player is the owner of their island.
|
||||
* @deprecated This will be removed in 2.0 because it is ambiguous when a user
|
||||
* has more than one island in the world.
|
||||
*/
|
||||
/*
|
||||
* @Deprecated public boolean isOwner(@NonNull World world, @NonNull UUID
|
||||
* uniqueId) { return hasIsland(world, uniqueId) &&
|
||||
* uniqueId.equals(getIsland(world, uniqueId).getOwner()); }
|
||||
*/
|
||||
|
||||
@Deprecated(since = "2.0", forRemoval = true)
|
||||
public boolean isOwner(@NonNull World world, @NonNull UUID uniqueId) {
|
||||
return hasIsland(world, uniqueId) && uniqueId.equals(getIsland(world, uniqueId).getOwner());
|
||||
}
|
||||
|
||||
/**
|
||||
* Clear and reload all islands from database
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue