mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2024-07-08 11:10:02 +00:00
Lombok implementation removal. I have also gone through and replaced things with inline methods and variables, lambdas, and simplified loops down, removed unnecessary guard clauses, and overall cleaned up every single class. This took a long time, please do remember to follow proper naming conventions, don't include unnecessary guard clauses, follow exception rules and comment rules, and please PLEASE remember to use the DIAMOND OPERATOR rather than just inferring RAW TYPES!!! Thank you!!
65 lines
1.2 KiB
Java
65 lines
1.2 KiB
Java
package me.totalfreedom.totalfreedommod.world;
|
|
|
|
import io.papermc.lib.PaperLib;
|
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
import org.bukkit.Bukkit;
|
|
import org.bukkit.World;
|
|
import org.bukkit.entity.Player;
|
|
|
|
public abstract class CustomWorld extends FreedomService
|
|
{
|
|
private final String name;
|
|
//
|
|
private World world;
|
|
|
|
public CustomWorld(String name)
|
|
{
|
|
this.name = name;
|
|
}
|
|
|
|
@Override
|
|
public void onStart()
|
|
{
|
|
}
|
|
|
|
@Override
|
|
public void onStop()
|
|
{
|
|
}
|
|
|
|
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
|
|
{
|
|
PaperLib.teleportAsync(player, getWorld().getSpawnLocation());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
player.sendMessage(ex.getMessage());
|
|
}
|
|
}
|
|
|
|
protected abstract World generateWorld();
|
|
|
|
public String getName()
|
|
{
|
|
return name;
|
|
}
|
|
}
|