summaryrefslogtreecommitdiffstats
path: root/EssentialsSpawn/src/com/earth2me
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-03-04 20:06:50 +0000
committerKHobbits <rob@khobbits.co.uk>2012-03-04 20:09:25 +0000
commit6a9027da6d7cd2c2c0c35f0163dc0207720708e6 (patch)
tree2e1cb5374523f6c0fee989c6731a95e7d6739724 /EssentialsSpawn/src/com/earth2me
parente55aa3cea7f8c12dd843a62f955c83a7b3153ce4 (diff)
downloadEssentials-6a9027da6d7cd2c2c0c35f0163dc0207720708e6.tar
Essentials-6a9027da6d7cd2c2c0c35f0163dc0207720708e6.tar.gz
Essentials-6a9027da6d7cd2c2c0c35f0163dc0207720708e6.tar.lz
Essentials-6a9027da6d7cd2c2c0c35f0163dc0207720708e6.tar.xz
Essentials-6a9027da6d7cd2c2c0c35f0163dc0207720708e6.zip
Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
Diffstat (limited to 'EssentialsSpawn/src/com/earth2me')
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java31
1 files changed, 24 insertions, 7 deletions
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
index c7a17845a..ba71c176f 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -1,12 +1,13 @@
package com.earth2me.essentials.spawn;
+import com.earth2me.essentials.*;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.IEssentials;
-import com.earth2me.essentials.OfflinePlayer;
-import com.earth2me.essentials.User;
import com.earth2me.essentials.textreader.IText;
import com.earth2me.essentials.textreader.KeywordReplacer;
import com.earth2me.essentials.textreader.SimpleTextPager;
+import java.util.List;
+import java.util.Locale;
+import java.util.Map;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Bukkit;
@@ -67,13 +68,14 @@ public class EssentialsSpawnPlayerListener implements Listener
public void onPlayerJoin(final PlayerJoinEvent event)
{
- final User user = ess.getUser(event.getPlayer());
-
- if (user.hasPlayedBefore())
+ if (event.getPlayer().hasPlayedBefore())
{
LOGGER.log(Level.FINE, "Old player join");
return;
}
+
+ final User user = ess.getUser(event.getPlayer());
+
if (!"none".equalsIgnoreCase(ess.getSettings().getNewbieSpawn()))
{
ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
@@ -86,6 +88,21 @@ public class EssentialsSpawnPlayerListener implements Listener
ess.broadcastMessage(user, pager.getString(0));
}
+ final String kitName = ess.getSettings().getNewPlayerKit();
+ if (!kitName.isEmpty())
+ {
+ try
+ {
+ final Map<String, Object> kit = ess.getSettings().getKit(kitName.toLowerCase(Locale.ENGLISH));
+ final List<String> items = Kit.getItems(user, kit);
+ Kit.expandItems(ess, user, items);
+ }
+ catch (Exception ex)
+ {
+ LOGGER.log(Level.WARNING, ex.getMessage());
+ }
+ }
+
LOGGER.log(Level.FINE, "New player join");
}
@@ -109,7 +126,7 @@ public class EssentialsSpawnPlayerListener implements Listener
try
{
- Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn());
+ final Location spawn = spawns.getSpawn(ess.getSettings().getNewbieSpawn());
if (spawn != null)
{
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);