Now storing spawn locations in config.yml
This commit is contained in:
parent
1105385d87
commit
ba8b380b4d
1
pom.xml
1
pom.xml
|
@ -55,6 +55,7 @@
|
||||||
<filtering>true</filtering>
|
<filtering>true</filtering>
|
||||||
<includes>
|
<includes>
|
||||||
<include>plugin.yml</include>
|
<include>plugin.yml</include>
|
||||||
|
<include>config.yml</include>
|
||||||
</includes>
|
</includes>
|
||||||
</resource>
|
</resource>
|
||||||
<resource>
|
<resource>
|
||||||
|
|
|
@ -4,7 +4,8 @@ import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
public class EasySpawn extends JavaPlugin{
|
public class EasySpawn extends JavaPlugin{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -12,22 +13,42 @@ public class EasySpawn extends JavaPlugin{
|
||||||
String label, String[] args) {
|
String label, String[] args) {
|
||||||
if(sender instanceof Player){
|
if(sender instanceof Player){
|
||||||
Player player = (Player)sender;
|
Player player = (Player)sender;
|
||||||
|
|
||||||
|
//Spawn
|
||||||
if(command.getName().equalsIgnoreCase("spawn")){
|
if(command.getName().equalsIgnoreCase("spawn")){
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
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.");
|
player.sendMessage("You have been teleported to spawn.");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Setspawn
|
||||||
if(command.getName().equalsIgnoreCase("setspawn")){
|
if(command.getName().equalsIgnoreCase("setspawn")){
|
||||||
player.getWorld().setSpawnLocation(player.getLocation().getBlockX(),
|
Location location = player.getLocation();
|
||||||
player.getLocation().getBlockY(),player.getLocation().getBlockZ());
|
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.");
|
player.sendMessage("Spawn set.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Bed
|
||||||
if(command.getName().equalsIgnoreCase("bed")){
|
if(command.getName().equalsIgnoreCase("bed")){
|
||||||
if(player.getBedSpawnLocation()!=null){
|
if(player.getBedSpawnLocation()!=null){
|
||||||
player.teleport(player.getBedSpawnLocation());
|
player.teleport(player.getBedSpawnLocation());
|
||||||
player.sendMessage("You have been teleported to your bed.");
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue