summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-05-07 00:05:02 +0100
committerKHobbits <rob@khobbits.co.uk>2012-05-07 00:05:02 +0100
commit9b731cc39c450c200c2c9a5c08492b54758d1344 (patch)
tree8eee24bb202d90be554b36b7faa341be2d788bf6
parent78cd64c388a0f6c259d0d119d03db43613ee47f7 (diff)
downloadEssentials-9b731cc39c450c200c2c9a5c08492b54758d1344.tar
Essentials-9b731cc39c450c200c2c9a5c08492b54758d1344.tar.gz
Essentials-9b731cc39c450c200c2c9a5c08492b54758d1344.tar.lz
Essentials-9b731cc39c450c200c2c9a5c08492b54758d1344.tar.xz
Essentials-9b731cc39c450c200c2c9a5c08492b54758d1344.zip
Update home count to include the bed home if set, this does not prevent people from setting a bed home if they are at max.
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsethome.java8
2 files changed, 17 insertions, 3 deletions
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index 5686e0439..533b58acf 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
import java.io.File;
import java.util.*;
import org.bukkit.Location;
+import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@@ -149,6 +150,17 @@ public abstract class UserData extends PlayerExtension implements IConf
return new ArrayList<String>(homes.keySet());
}
+ public int getHomeCount()
+ {
+ int count = getHomes().size();
+ Location bed = getBedSpawnLocation();
+ if (bed != null && bed.getBlock().getType() == Material.BED_BLOCK)
+ {
+ count++;
+ }
+ return count;
+ }
+
public void setHome(String name, Location loc)
{
//Invalid names will corrupt the yaml
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
index d59ac4a31..a4bdb08ad 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
@@ -29,10 +29,11 @@ public class Commandsethome extends EssentialsCommand
{
if (user.isAuthorized("essentials.sethome.multiple"))
{
- if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH))) {
+ if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
+ {
throw new NotEnoughArgumentsException();
}
- if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
+ if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomeCount() < ess.getSettings().getHomeLimit(user))
|| (user.getHomes().contains(args[0].toLowerCase(Locale.ENGLISH))))
{
user.setHome(args[0].toLowerCase(Locale.ENGLISH));
@@ -66,7 +67,8 @@ public class Commandsethome extends EssentialsCommand
{
name = "home";
}
- if ("bed".equals(name.toLowerCase(Locale.ENGLISH))) {
+ if ("bed".equals(name.toLowerCase(Locale.ENGLISH)))
+ {
throw new NotEnoughArgumentsException();
}
usersHome.setHome(name, user.getLocation());