summaryrefslogtreecommitdiffstats
path: root/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java
diff options
context:
space:
mode:
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java')
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java63
1 files changed, 60 insertions, 3 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java
index 088ee9052..13eb1f7df 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java
@@ -1,7 +1,8 @@
package com.earth2me.essentials.spawn;
-import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.IEssentialsModule;
+import com.earth2me.essentials.api.IEssentials;
+import com.earth2me.essentials.api.IEssentialsModule;
+import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.settings.Spawns;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
import java.io.File;
@@ -10,6 +11,8 @@ import java.util.Locale;
import java.util.Map;
import org.bukkit.Location;
import org.bukkit.World;
+import org.bukkit.event.Event.Priority;
+import org.bukkit.event.EventPriority;
public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule
@@ -17,7 +20,7 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
public SpawnStorage(final IEssentials ess)
{
super(ess, Spawns.class);
- reloadConfig();
+ onReload();
}
@Override
@@ -87,4 +90,58 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE
}
return ess.getServer().getWorlds().get(0).getSpawnLocation();
}
+
+ public EventPriority getRespawnPriority()
+ {
+ acquireReadLock();
+ try
+ {
+ for (EventPriority priority : EventPriority.values())
+ {
+ if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority())) {
+ return priority;
+ }
+ }
+ return EventPriority.NORMAL;
+ } finally {
+ unlock();
+ }
+ }
+
+ public Location getNewbieSpawn()
+ {
+ acquireReadLock();
+ try
+ {
+ if (getData().getNewbieSpawn() == null || getData().getNewbieSpawn().isEmpty() ||
+ getData().getNewbieSpawn().equalsIgnoreCase("none")) {
+ return null;
+ }
+ return getSpawn(getData().getNewbieSpawn());
+ } finally {
+ unlock();
+ }
+ }
+
+ public boolean getAnnounceNewPlayers()
+ {
+ acquireReadLock();
+ try
+ {
+ return getData().getNewPlayerAnnouncement() != null && !getData().getNewPlayerAnnouncement().isEmpty();
+ } finally {
+ unlock();
+ }
+ }
+
+ public String getAnnounceNewPlayerFormat(IUser user)
+ {
+ acquireReadLock();
+ try
+ {
+ return getData().getNewPlayerAnnouncement().replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
+ } finally {
+ unlock();
+ }
+ }
}