Update 3.3.3

This commit is contained in:
Xephi
2014-02-20 12:54:10 +01:00
parent 5a089fa690
commit 4e7e9e6cb4
21 changed files with 315 additions and 127 deletions
@@ -1,9 +1,6 @@
package fr.xephi.authme.settings;
import java.io.File;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@@ -14,7 +11,6 @@ import org.bukkit.Location;
public class Spawn extends CustomConfiguration {
private static Spawn spawn;
private static List<String> emptyList = new ArrayList<String>();
public Spawn() {
super(new File("./plugins/AuthMe/spawn.yml"));
@@ -26,7 +22,6 @@ public class Spawn extends CustomConfiguration {
private void saveDefault() {
if (!contains("spawn")) {
set("spawn", emptyList);
set("spawn.world", "");
set("spawn.x", "");
set("spawn.y", "");
@@ -35,6 +30,15 @@ public class Spawn extends CustomConfiguration {
set("spawn.pitch", "");
save();
}
if (!contains("firstspawn")) {
set("firstspawn.world", "");
set("firstspawn.x", "");
set("firstspawn.y", "");
set("firstspawn.z", "");
set("firstspawn.yaw", "");
set("firstspawn.pitch", "");
save();
}
}
public static Spawn getInstance() {
@@ -59,7 +63,27 @@ public class Spawn extends CustomConfiguration {
}
}
public boolean setFirstSpawn(Location location) {
try {
set("firstspawn.world", location.getWorld().getName());
set("firstspawn.x", location.getX());
set("firstspawn.y", location.getY());
set("firstspawn.z", location.getZ());
set("firstspawn.yaw", location.getYaw());
set("firstspawn.pitch", location.getPitch());
save();
return true;
} catch (NullPointerException npe) {
return false;
}
}
@Deprecated
public Location getLocation() {
return getSpawn();
}
public Location getSpawn() {
try {
if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world") == "") return null;
Location location = new Location(Bukkit.getWorld(this.getString("spawn.world")), this.getDouble("spawn.x"), this.getDouble("spawn.y"), this.getDouble("spawn.z"), Float.parseFloat(this.getString("spawn.yaw")), Float.parseFloat(this.getString("spawn.pitch")));
@@ -70,5 +94,17 @@ public class Spawn extends CustomConfiguration {
return null;
}
}
public Location getFirstSpawn() {
try {
if (this.getString("firstspawn.world").isEmpty() || this.getString("firstspawn.world") == "") return null;
Location location = new Location(Bukkit.getWorld(this.getString("firstspawn.world")), this.getDouble("firstspawn.x"), this.getDouble("firstspawn.y"), this.getDouble("firstspawn.z"), Float.parseFloat(this.getString("firstspawn.yaw")), Float.parseFloat(this.getString("firstspawn.pitch")));
return location;
} catch (NullPointerException npe) {
return null;
} catch (NumberFormatException nfe) {
return null;
}
}
}