Files
src
build.gradle
Code
5 169
src/main/java/com/kodari/safe/SafePlugin.java
package com.kodari.safe;
import com.kodari.safe.command.SpawnCommand;
import com.kodari.safe.listener.SafetyListener;
import org.bukkit.Location;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.plugin.java.JavaPlugin;
public class SafePlugin extends JavaPlugin {
private Location spawnLocation;
private static SafePlugin instance;
@Override
public void onEnable() {
instance = this;
loadSpawnLocation();
getServer().getPluginManager().registerEvents(new SafetyListener(), this);
getCommand("setspawn").setExecutor(new SpawnCommand(this));
getCommand("spawn").setExecutor(new SpawnCommand(this));
getLogger().info("SafePlugin enabled — suffocation damage cancelled, death teleport active.");
}
@Override
public void onDisable() {
saveSpawnLocation();
}
public void loadSpawnLocation() {
FileConfiguration config = getConfig();
if (config.contains("spawn")) {
spawnLocation = (Location) config.get("spawn");
}
}
public void saveSpawnLocation() {
if (spawnLocation != null) {
getConfig().set("spawn", spawnLocation);
saveConfig();
}
}
public Location getSpawnLocation() {
return spawnLocation;
}
public void setSpawnLocation(Location location) {
this.spawnLocation = location.clone();
saveSpawnLocation();
}
public static SafePlugin getInstance() {
return instance;
}
}