diff --git a/pom.xml b/pom.xml
index ece7295..3a07345 100644
--- a/pom.xml
+++ b/pom.xml
@@ -55,6 +55,7 @@
true
plugin.yml
+ config.yml
diff --git a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java
index 5394de4..0d0f9e2 100644
--- a/src/main/java/nz/jimmy/easyspawn/EasySpawn.java
+++ b/src/main/java/nz/jimmy/easyspawn/EasySpawn.java
@@ -4,7 +4,8 @@ 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
@@ -12,22 +13,42 @@ public class EasySpawn extends JavaPlugin{
String label, String[] args) {
if(sender instanceof Player){
Player player = (Player)sender;
+
+ //Spawn
if(command.getName().equalsIgnoreCase("spawn")){
- player.teleport(player.getWorld().getSpawnLocation());
- player.sendMessage("You have been teleported to 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")){
- player.getWorld().setSpawnLocation(player.getLocation().getBlockX(),
- player.getLocation().getBlockY(),player.getLocation().getBlockZ());
+ 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("Your bed cannot be found.");
+ }else sender.sendMessage("You need to sleep in a bed first.");
return true;
}
}