diff options
author | snowleo <schneeleo@gmail.com> | 2012-01-02 22:38:47 +0100 |
---|---|---|
committer | snowleo <schneeleo@gmail.com> | 2012-01-02 22:38:47 +0100 |
commit | 41e0e64a5f83cb036e90d3c299f65b69caa9dd63 (patch) | |
tree | 13afb78219a5faadbc22c179a9d062899097d393 /EssentialsSpawn/src/com/earth2me | |
parent | a20e96af4e31deb60e85454698945df05fc7e817 (diff) | |
download | Essentials-41e0e64a5f83cb036e90d3c299f65b69caa9dd63.tar Essentials-41e0e64a5f83cb036e90d3c299f65b69caa9dd63.tar.gz Essentials-41e0e64a5f83cb036e90d3c299f65b69caa9dd63.tar.lz Essentials-41e0e64a5f83cb036e90d3c299f65b69caa9dd63.tar.xz Essentials-41e0e64a5f83cb036e90d3c299f65b69caa9dd63.zip |
EssentialsSpawn and EssentialsChat should build now again
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me')
3 files changed, 85 insertions, 10 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java index 7eb62238a..7376ed8c4 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java @@ -5,6 +5,7 @@ import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.ICommandHandler; import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IEssentialsModule; +import com.earth2me.essentials.api.ISettings; import java.util.logging.Level; import java.util.logging.Logger; import org.bukkit.Bukkit; @@ -43,7 +44,7 @@ public class EssentialsSpawn extends JavaPlugin commandHandler = new EssentialsCommandHandler(EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.", spawns, ess); final EssentialsSpawnPlayerListener playerListener = new EssentialsSpawnPlayerListener(ess, spawns); - pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, ess.getSettings().getRespawnPriority(), this); + pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, spawns.getRespawnPriority(), this); pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this); LOGGER.info(_("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), "essentials team")); diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java index 4c4a60997..a345b3f30 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.spawn; import static com.earth2me.essentials.I18n._; import com.earth2me.essentials.api.IEssentials; +import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.IUser; import java.util.logging.Level; import org.bukkit.Bukkit; @@ -28,8 +29,16 @@ public class EssentialsSpawnPlayerListener extends PlayerListener public void onPlayerRespawn(final PlayerRespawnEvent event) { final IUser user = ess.getUser(event.getPlayer()); - - if (ess.getSettings().getRespawnAtHome()) + + boolean respawnAtHome = false; + ISettings settings = ess.getSettings(); + settings.acquireReadLock(); + try { + respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome(); + } finally { + settings.unlock(); + } + if (respawnAtHome) { Location home = user.getHome(user.getLocation()); if (home == null) @@ -53,20 +62,29 @@ public class EssentialsSpawnPlayerListener extends PlayerListener public void onPlayerJoin(final PlayerJoinEvent event) { final IUser user = ess.getUser(event.getPlayer()); + user.acquireReadLock(); + try + { - if (!user.isNew() || user.getBedSpawnLocation() != null) + if (!user.getData().isNewplayer() || user.getBedSpawnLocation() != null) + { + return; + } + user.acquireWriteLock(); + user.getData().setNewplayer(false); + } + finally { - return; + user.unlock(); } - user.setNew(false); - if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn())) + if (spawns.getNewbieSpawn() != null) { ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user)); } - if (ess.getSettings().getAnnounceNewPlayers()) + if (spawns.getAnnounceNewPlayers()) { - ess.broadcastMessage(user, ess.getSettings().getAnnounceNewPlayerFormat(user)); + ess.broadcastMessage(user, spawns.getAnnounceNewPlayerFormat(user)); } } @@ -85,7 +103,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener { try { - Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn()); + Location spawn = spawns.getNewbieSpawn(); if (spawn != null) { user.getTeleport().now(spawn, false, TeleportCause.PLUGIN); diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java index 61304fbf4..0c351c753 100644 --- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java +++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/SpawnStorage.java @@ -2,6 +2,7 @@ package com.earth2me.essentials.spawn; 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,7 @@ import java.util.Locale; import java.util.Map; import org.bukkit.Location; import org.bukkit.World; +import org.bukkit.event.Event.Priority; public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IEssentialsModule @@ -87,4 +89,58 @@ public class SpawnStorage extends AsyncStorageObjectHolder<Spawns> implements IE } return ess.getServer().getWorlds().get(0).getSpawnLocation(); } + + public Priority getRespawnPriority() + { + acquireReadLock(); + try + { + for (Priority priority : Priority.values()) + { + if (priority.toString().equalsIgnoreCase(getData().getRespawnPriority())) { + return priority; + } + } + return Priority.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(); + } + } } |