Fix issues with sometimes-loaded worlds in location flags.

This commit is contained in:
wizjany 2019-05-25 18:12:28 -04:00
parent 0f989fc1b4
commit ce35798f67
4 changed files with 14 additions and 3 deletions

View File

@ -1089,7 +1089,7 @@ public void teleport(CommandContext args, Actor sender) throws CommandException
// Lookup the existing region
World world = checkWorld(args, player, 'w');
RegionManager regionManager = checkRegionManager(world);
ProtectedRegion existing = checkExistingRegion(regionManager, args.getString(0), false);
ProtectedRegion existing = checkExistingRegion(regionManager, args.getString(0), true);
// Check permissions
if (!getPermissionModel(player).mayTeleportTo(existing)) {

View File

@ -26,6 +26,7 @@
import com.sk89q.worldedit.world.World;
import com.sk89q.worldguard.LocalPlayer;
import javax.annotation.Nullable;
import java.util.Iterator;
import java.util.List;
@ -150,6 +151,7 @@ default Iterable<LocalPlayer> matchPlayers(LocalPlayer player) {
* @param worldName The name
* @return The world
*/
@Nullable
World getWorldByName(String worldName);
/**

View File

@ -58,7 +58,12 @@ public Extent getExtent() {
}
// try loading the world again now
// if it fails it will throw an error later (presumably when trying to teleport someone there)
return Optional.ofNullable(findWorld(getWorldName())).orElse(NullWorld.getInstance());
return Optional.ofNullable(findWorld(getWorldName())).orElse(new NullWorld() {
@Override
public String getName() {
return worldName;
}
});
}
public String getWorldName() {

View File

@ -218,7 +218,11 @@ public Actor matchPlayerOrConsole(Actor sender, String filter) throws CommandExc
@Override
public World getWorldByName(String worldName) {
return BukkitAdapter.adapt(Bukkit.getServer().getWorld(worldName));
final org.bukkit.World bukkitW = Bukkit.getServer().getWorld(worldName);
if (bukkitW == null) {
return null;
}
return BukkitAdapter.adapt(bukkitW);
}
@Override