43 lines
1.2 KiB
Java
43 lines
1.2 KiB
Java
package nz.jimmy.easyspawn;
|
|
|
|
import org.bukkit.Location;
|
|
import org.bukkit.World;
|
|
import org.bukkit.configuration.file.FileConfiguration;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.event.EventHandler;
|
|
import org.bukkit.event.Listener;
|
|
import org.bukkit.event.player.PlayerJoinEvent;
|
|
|
|
|
|
/**
|
|
* PlayerListener
|
|
*/
|
|
public class PlayerListener implements Listener{
|
|
EasySpawn plugin;
|
|
public PlayerListener(EasySpawn plugin) {
|
|
this.plugin = plugin;
|
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
|
}
|
|
|
|
@EventHandler
|
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
|
Player player = event.getPlayer();
|
|
if(!player.hasPlayedBefore()){
|
|
World world = player.getWorld();
|
|
String w = world.getName();
|
|
FileConfiguration config = plugin.getConfig();
|
|
//Check if spawn is set
|
|
if(config.contains("spawn."+w)){
|
|
int x = config.getInt("spawn."+w+".x");
|
|
int y = config.getInt("spawn."+w+".y");
|
|
int z = config.getInt("spawn."+w+".z");
|
|
float pitch = config.getInt("spawn."+w+".pitch");
|
|
float yaw = config.getInt("spawn."+w+".yaw");
|
|
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
|