Use getWorldFromName in MapCommand and Back when needed

This commit is contained in:
Spencer 2017-12-30 20:15:25 -05:00 committed by Alexander Meech
parent 98f1bd151e
commit dcafcbef76
5 changed files with 17 additions and 21 deletions

View File

@ -6,7 +6,11 @@ import com.google.common.collect.Sets;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilPlayerBase;
import mineplex.core.common.util.UtilWorld;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.entity.Player;
import java.io.BufferedReader;

View File

@ -11,12 +11,12 @@ import org.bukkit.entity.Player;
/**
*
*/
public class InfoCommand extends BaseCommand
public class GameTypeInfoCommand extends BaseCommand
{
public InfoCommand(MapParser plugin)
public GameTypeInfoCommand(MapParser plugin)
{
super(plugin, "gameinfo");
super(plugin, "gameinfo", "gametypeinfo");
setUsage("/info <gametype> & /info addInfo <gameType> <info>");
}

View File

@ -97,19 +97,7 @@ public class MapCommand extends BaseCommand
System.out.println("Could not delete uid.dat for " + worldName);
}
World world = getPlugin().getMapWorld(worldName);
if (world == null)
{
if (getPlugin().doesMapExist(worldName))
{
world = Bukkit.createWorld(new WorldCreator(worldName));
}
else
{
message(player, "Map Not Found: " + F.elem(worldName));
return true;
}
}
World world = getPlugin().getWorldFromName(worldName);
//Error (This should not occur!)
if (world == null)
@ -119,9 +107,9 @@ public class MapCommand extends BaseCommand
}
//Permission
if (!getPlugin().getData(world.getName()).CanJoin(player))
if (!_teleportManager.canTeleportTo(player, world.getSpawnLocation()))
{
message(player, "You do not have Join-Access on this Map.");
message(player, "You are not permitted to access this map.");
return true;
}

View File

@ -5,7 +5,6 @@ import java.util.LinkedList;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import mineplex.mapparser.MapParser;
import mineplex.mapparser.command.BaseCommand;
public class BackCommand extends BaseCommand
@ -70,12 +69,18 @@ public class BackCommand extends BaseCommand
return true;
}
if (_teleportManager.canTeleportTo(player, location))
if (!_teleportManager.canTeleportTo(player, location))
{
message(player, "You don't have access to teleport back to that location.");
return true;
}
// If the world doesn't already exist, load it
if (location.getWorld() == null || (!location.getWorld().equals(player.getWorld()) && location.getWorld().getPlayers().size() == 0))
{
_teleportManager.getPlugin().getWorldFromName(location.getWorld().getName());
}
player.teleport(location);
return true;
}

View File

@ -2,7 +2,6 @@ package mineplex.mapparser.command.teleport;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import org.bukkit.Location;