summaryrefslogtreecommitdiffstats
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
commit654663c0fd9f274374282038d12dd1d0490aefb0 (patch)
tree9f1f3c5bb5c35d7cf2cf7f8e60e32ef625d2361d
parent00d12585f3ab4d63e5b08e74a3ed738c572f96b3 (diff)
downloadEssentials-654663c0fd9f274374282038d12dd1d0490aefb0.tar
Essentials-654663c0fd9f274374282038d12dd1d0490aefb0.tar.gz
Essentials-654663c0fd9f274374282038d12dd1d0490aefb0.tar.lz
Essentials-654663c0fd9f274374282038d12dd1d0490aefb0.tar.xz
Essentials-654663c0fd9f274374282038d12dd1d0490aefb0.zip
Adding starter/newbie kit to EssentialsSpawn
Optimization to EssentialsSpawn join event.
-rw-r--r--Essentials/src/com/earth2me/essentials/IEssentials.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/ISettings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/Kit.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/Settings.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkit.java4
-rw-r--r--Essentials/src/config.yml5
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java31
7 files changed, 45 insertions, 13 deletions
diff --git a/Essentials/src/com/earth2me/essentials/IEssentials.java b/Essentials/src/com/earth2me/essentials/IEssentials.java
index 20c6c300e..6b820440a 100644
--- a/Essentials/src/com/earth2me/essentials/IEssentials.java
+++ b/Essentials/src/com/earth2me/essentials/IEssentials.java
@@ -9,6 +9,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.plugin.Plugin;
import org.bukkit.scheduler.BukkitScheduler;
+
/**
* @deprecated This will be moved to the api package soon
*/
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java
index 6186736b4..ec3941cd1 100644
--- a/Essentials/src/com/earth2me/essentials/ISettings.java
+++ b/Essentials/src/com/earth2me/essentials/ISettings.java
@@ -20,6 +20,8 @@ public interface ISettings extends IConf
boolean getAnnounceNewPlayers();
+ String getNewPlayerKit();
+
String getBackupCommand();
long getBackupInterval();
@@ -115,11 +117,11 @@ public interface ISettings extends IConf
boolean warnOnSmite();
double getMaxMoney();
-
+
double getMinMoney();
boolean isEcoLogEnabled();
-
+
boolean isEcoLogUpdateEnabled();
boolean removeGodOnDisconnect();
diff --git a/Essentials/src/com/earth2me/essentials/Kit.java b/Essentials/src/com/earth2me/essentials/Kit.java
index 47e5e6ac2..cf39997ea 100644
--- a/Essentials/src/com/earth2me/essentials/Kit.java
+++ b/Essentials/src/com/earth2me/essentials/Kit.java
@@ -63,10 +63,11 @@ public class Kit
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
{
- if (kit == null) {
+ if (kit == null)
+ {
throw new Exception(_("kitError2"));
}
-
+
try
{
return (List<String>)kit.get("items");
diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java
index e3992e52c..c9232f107 100644
--- a/Essentials/src/com/earth2me/essentials/Settings.java
+++ b/Essentials/src/com/earth2me/essentials/Settings.java
@@ -352,6 +352,12 @@ public class Settings implements ISettings
}
@Override
+ public String getNewPlayerKit()
+ {
+ return config.getString("newbies.kit", "");
+ }
+
+ @Override
public String getNewbieSpawn()
{
return config.getString("newbies.spawnpoint", "default");
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
index aee0af910..67f0fafd0 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
@@ -38,7 +38,7 @@ public class Commandkit extends EssentialsCommand
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
-
+
final List<String> items = Kit.getItems(user, kit);
Kit.checkTime(user, kitName, kit);
@@ -47,7 +47,7 @@ public class Commandkit extends EssentialsCommand
charge.isAffordableFor(user);
Kit.expandItems(ess, user, items);
-
+
charge.charge(user);
user.sendMessage(_("kitGive", kitName));
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 81d911c82..11bc38329 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -547,6 +547,11 @@ newbies:
# When we spawn for the first time, which spawnpoint do we use?
# Set to "none" if you want to use the spawn point of the world.
spawnpoint: newbies
+
+ # Do we want to give users anything on first join? Set to '' to disable
+ # This kit will be given reguardless of cost, and permissions.
+ #kit: ''
+ kit: tools
# Set this to lowest, if you want Multiverse to handle the respawning
# Set this to high, if you want EssentialsSpawn to handle the respawning
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);