59 lines
1.9 KiB
Java
59 lines
1.9 KiB
Java
package nz.jimmy.easyspawn;
|
|
|
|
import org.bukkit.command.Command;
|
|
import org.bukkit.command.CommandSender;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.plugin.java.JavaPlugin;
|
|
import org.bukkit.Location;
|
|
import org.bukkit.World;
|
|
public class EasySpawn extends JavaPlugin{
|
|
|
|
@Override
|
|
public boolean onCommand(CommandSender sender, Command command,
|
|
String label, String[] args) {
|
|
if(sender instanceof Player){
|
|
Player player = (Player)sender;
|
|
|
|
//Spawn
|
|
if(command.getName().equalsIgnoreCase("spawn")){
|
|
World world = player.getWorld();
|
|
String w = world.getName();
|
|
if(getConfig().contains("spawn."+w)) {
|
|
int x = getConfig().getInt("spawn."+w+".x");
|
|
int y = getConfig().getInt("spawn."+w+".y");
|
|
int z = getConfig().getInt("spawn."+w+".z");
|
|
float pitch = getConfig().getInt("spawn."+w+".pitch");
|
|
float yaw = getConfig().getInt("spawn."+w+".yaw");
|
|
player.teleport(new Location(world, x, y, z, yaw, pitch));
|
|
player.sendMessage("You have been teleported to spawn.");
|
|
}
|
|
return true;
|
|
}
|
|
|
|
//Setspawn
|
|
if(command.getName().equalsIgnoreCase("setspawn")){
|
|
Location location = player.getLocation();
|
|
String world = player.getWorld().getName();
|
|
getConfig().set("spawn."+world+".x", location.getBlockX());
|
|
getConfig().set("spawn."+world+".y", location.getBlockY());
|
|
getConfig().set("spawn."+world+".z", location.getBlockZ());
|
|
getConfig().set("spawn."+world+".pitch", location.getPitch());
|
|
getConfig().set("spawn."+world+".yaw", location.getYaw());
|
|
player.sendMessage("Spawn set.");
|
|
return true;
|
|
}
|
|
|
|
//Bed
|
|
if(command.getName().equalsIgnoreCase("bed")){
|
|
if(player.getBedSpawnLocation()!=null){
|
|
player.teleport(player.getBedSpawnLocation());
|
|
player.sendMessage("You have been teleported to your bed.");
|
|
}else sender.sendMessage("You need to sleep in a bed first.");
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
}
|