Files
src
build.gradle
Code
9 655
src/main/java/com/kodari/secureauth/SecureAuthPlugin.java
package com.kodari.secureauth;
import org.bukkit.Bukkit;
import org.bukkit.World;
import org.bukkit.WorldCreator;
import org.bukkit.plugin.java.JavaPlugin;
public final class SecureAuthPlugin extends JavaPlugin {
private World authenticationWorld;
private World mainWorld;
private AuthManager authManager;
@Override
public void onEnable() {
saveDefaultConfig();
String authWorldName = getConfig().getString("auth-world", "kodari_auth");
authenticationWorld = Bukkit.getWorld(authWorldName);
if (authenticationWorld == null) {
authenticationWorld = Bukkit.createWorld(new WorldCreator(authWorldName).generator(new VoidChunkGenerator()));
}
if (authenticationWorld == null) {
getLogger().severe("Could not create or load the authentication world.");
getServer().getPluginManager().disablePlugin(this);
return;
}
authenticationWorld.setSpawnLocation(0, 100, 0);
mainWorld = Bukkit.getWorld(getConfig().getString("main-world", "world"));
if (mainWorld == null || mainWorld.equals(authenticationWorld)) {
mainWorld = Bukkit.getWorlds().stream()
.filter(world -> !world.equals(authenticationWorld))
.findFirst()
.orElse(null);
}
if (mainWorld == null) {
getLogger().severe("No main world is available; configure main-world in config.yml.");
getServer().getPluginManager().disablePlugin(this);
return;
}
authManager = new AuthManager(this);
getServer().getPluginManager().registerEvents(new AuthListener(this, authManager), this);
getCommand("register").setExecutor(new AuthCommand(authManager));
getCommand("login").setExecutor(new AuthCommand(authManager));
}
public World getAuthenticationWorld() {
return authenticationWorld;
}
public World getMainWorld() {
return mainWorld;
}
}