mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-07-03 09:00:01 +00:00
Improved admin system Improved Rank system Implemented config converter Improved command handling Updated Aero
53 lines
1.1 KiB
Java
53 lines
1.1 KiB
Java
package me.totalfreedom.totalfreedommod.world;
|
|
|
|
import lombok.Getter;
|
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
import net.pravian.aero.component.PluginComponent;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.World;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public abstract class CustomWorld extends PluginComponent<TotalFreedomMod>
|
|
{
|
|
|
|
@Getter
|
|
private final String name;
|
|
//
|
|
private World world;
|
|
|
|
public CustomWorld(String name)
|
|
{
|
|
this.name = name;
|
|
}
|
|
|
|
public final World getWorld()
|
|
{
|
|
if (world == null || !Bukkit.getWorlds().contains(world))
|
|
{
|
|
world = generateWorld();
|
|
}
|
|
|
|
if (world == null)
|
|
{
|
|
FLog.warning("Could not load world: " + name);
|
|
}
|
|
|
|
return world;
|
|
}
|
|
|
|
public void sendToWorld(Player player)
|
|
{
|
|
try
|
|
{
|
|
player.teleport(getWorld().getSpawnLocation());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
player.sendMessage(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
protected abstract World generateWorld();
|
|
}
|