summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKHobbits <rob@khobbits.co.uk>2012-08-08 02:10:25 +0100
committerKHobbits <rob@khobbits.co.uk>2012-08-08 02:10:25 +0100
commitfca3ad4df9d8aeace1bd13d55245a147c99f294d (patch)
treee2fa542b8148c5f9de0017a16d3e0263a97a8668
parent0b9725bf77feea451d6f4b05cf976314eb44038a (diff)
parentba6cc5a9ee7175edb4986a732c96adaef7d09dd9 (diff)
downloadEssentials-fca3ad4df9d8aeace1bd13d55245a147c99f294d.tar
Essentials-fca3ad4df9d8aeace1bd13d55245a147c99f294d.tar.gz
Essentials-fca3ad4df9d8aeace1bd13d55245a147c99f294d.tar.lz
Essentials-fca3ad4df9d8aeace1bd13d55245a147c99f294d.tar.xz
Essentials-fca3ad4df9d8aeace1bd13d55245a147c99f294d.zip
Merge branch '2.9' into release
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandexp.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java44
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandweather.java21
-rw-r--r--Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java35
-rw-r--r--Essentials/src/com/earth2me/essentials/signs/SignKit.java5
-rw-r--r--Essentials/src/config.yml12
-rw-r--r--Essentials/src/items.csv2
-rw-r--r--Essentials/src/plugin.yml4
-rw-r--r--EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java39
-rw-r--r--EssentialsGroupManager/src/globalgroups.yml1
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java12
11 files changed, 157 insertions, 41 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
index 0f1fe4ea6..f3dac79e2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.User;
import com.earth2me.essentials.craftbukkit.SetExpFix;
+import java.util.Locale;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -103,7 +104,7 @@ public class Commandexp extends EssentialsCommand
}
}
- private void expMatch(final Server server, final CommandSender sender, final String match, final String amount, final boolean toggle) throws NotEnoughArgumentsException
+ private void expMatch(final Server server, final CommandSender sender, final String match, String amount, final boolean toggle) throws NotEnoughArgumentsException
{
boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(match))
@@ -124,9 +125,25 @@ public class Commandexp extends EssentialsCommand
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), SetExpFix.getExpUntilNextLevel(target)));
}
- private void setExp(final CommandSender sender, final User target, final String strAmount, final boolean give)
+ private void setExp(final CommandSender sender, final User target, String strAmount, final boolean give)
{
- Long amount = Long.parseLong(strAmount);
+ Long amount;
+ strAmount = strAmount.toLowerCase(Locale.ENGLISH);
+ if (strAmount.startsWith("l"))
+ {
+ strAmount = strAmount.substring(1);
+ int neededLevel = Integer.parseInt(strAmount);
+ if (give)
+ {
+ neededLevel += target.getLevel();
+ }
+ amount = (long)SetExpFix.getExpToLevel(neededLevel);
+ SetExpFix.setTotalExperience(target, 0);
+ }
+ else {
+ amount = Long.parseLong(strAmount);
+ }
+
if (give)
{
amount += SetExpFix.getTotalExperience(target);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 8e5b7c017..92d564391 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -20,10 +20,16 @@ public class Commandtime extends EssentialsCommand
@Override
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
+ boolean add = false;
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
- if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
+ if (argList.remove("set") && !argList.isEmpty() && Util.isInt(argList.get(0)))
{
- ess.getLogger().info("debug edited 0" + argList.get(0).toString());
+ argList.set(0, argList.get(0) + "t");
+ }
+ if (argList.remove("add") && !argList.isEmpty() && Util.isInt(argList.get(0)))
+ {
+ add = true;
+ argList.set(0, argList.get(0) + "t");
}
final String[] validArgs = argList.toArray(new String[0]);
@@ -34,12 +40,27 @@ public class Commandtime extends EssentialsCommand
worldSelector = validArgs[1];
}
final Set<World> worlds = getWorlds(server, sender, worldSelector);
+ final String setTime;
// If no arguments we are reading the time
if (validArgs.length == 0)
{
- getWorldsTime(sender, worlds);
- return;
+ if (commandLabel.equalsIgnoreCase("day") || commandLabel.equalsIgnoreCase("eday"))
+ {
+ setTime = "day";
+ }
+ else if (commandLabel.equalsIgnoreCase("night") || commandLabel.equalsIgnoreCase("enight"))
+ {
+ setTime = "night";
+ }
+ else
+ {
+ getWorldsTime(sender, worlds);
+ return;
+ }
+ }
+ else {
+ setTime = validArgs[0];
}
final User user = ess.getUser(sender);
@@ -53,14 +74,14 @@ public class Commandtime extends EssentialsCommand
long ticks;
try
{
- ticks = DescParseTickFormat.parse(validArgs[0]);
+ ticks = DescParseTickFormat.parse(setTime);
}
catch (NumberFormatException e)
{
throw new NotEnoughArgumentsException(e);
}
- setWorldsTime(sender, worlds, ticks);
+ setWorldsTime(sender, worlds, ticks, add);
}
/**
@@ -84,14 +105,17 @@ public class Commandtime extends EssentialsCommand
/**
* Used to set the time and inform of the change
*/
- private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks)
+ private void setWorldsTime(final CommandSender sender, final Collection<World> worlds, final long ticks, final boolean add)
{
// Update the time
for (World world : worlds)
{
long time = world.getTime();
- time -= time % 24000;
- world.setTime(time + 24000 + ticks);
+ if (!add)
+ {
+ time -= time % 24000;
+ }
+ world.setTime(time + (add ? 0 : 24000) + ticks);
}
final StringBuilder output = new StringBuilder();
@@ -159,4 +183,4 @@ class WorldNameComparator implements Comparator<World>
{
return a.getName().compareTo(b.getName());
}
-}
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
index 1229c9ee4..dc9f767d5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
@@ -18,12 +18,27 @@ public class Commandweather extends EssentialsCommand
@Override
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
{
+ final boolean isStorm;
if (args.length < 1)
{
- throw new NotEnoughArgumentsException();
+ if (commandLabel.equalsIgnoreCase("sun") || commandLabel.equalsIgnoreCase("esun"))
+ {
+ isStorm = false;
+ }
+ else if (commandLabel.equalsIgnoreCase("storm") || commandLabel.equalsIgnoreCase("estorm")
+ || commandLabel.equalsIgnoreCase("rain") || commandLabel.equalsIgnoreCase("erain"))
+ {
+ isStorm = true;
+ }
+ else
+ {
+ throw new NotEnoughArgumentsException();
+ }
+ }
+ else
+ {
+ isStorm = args[0].equalsIgnoreCase("storm");
}
-
- final boolean isStorm = args[0].equalsIgnoreCase("storm");
final World world = user.getWorld();
if (args.length > 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java b/Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java
index e4a226da0..7ed3034c3 100644
--- a/Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java
+++ b/Essentials/src/com/earth2me/essentials/craftbukkit/SetExpFix.java
@@ -22,7 +22,7 @@ public class SetExpFix
int amount = exp;
while (amount > 0)
{
- final int expToLevel = getExpToLevel(player);
+ final int expToLevel = getExpAtLevel(player);
amount -= expToLevel;
if (amount >= 0)
{
@@ -39,43 +39,56 @@ public class SetExpFix
}
}
- private static int getExpToLevel(final Player player)
+ private static int getExpAtLevel(final Player player)
{
- return getExpToLevel(player.getLevel());
+ return getExpAtLevel(player.getLevel());
}
- private static int getExpToLevel(final int level)
+ public static int getExpAtLevel(final int level)
{
- if (level >= 30)
+ if (level > 29)
{
return 62 + (level - 30) * 7;
}
- if (level >= 15)
+ if (level > 15)
{
return 17 + (level - 15) * 3;
}
return 17;
}
+
+ public static int getExpToLevel(final int level)
+ {
+ int currentLevel = 0;
+ int exp = 0;
+
+ while (currentLevel < level)
+ {
+ exp += getExpAtLevel(currentLevel);
+ currentLevel++;
+ }
+ return exp;
+ }
//This method is required because the bukkit player.getTotalExperience() method, shows exp that has been 'spent'.
//Without this people would be able to use exp and then still sell it.
public static int getTotalExperience(final Player player)
{
- int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
+ int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
int currentLevel = player.getLevel();
while (currentLevel > 0)
{
currentLevel--;
- exp += getExpToLevel(currentLevel);
+ exp += getExpAtLevel(currentLevel);
}
return exp;
}
public static int getExpUntilNextLevel(final Player player)
{
- int exp = (int)Math.round(getExpToLevel(player) * player.getExp());
- int nextLevel = player.getLevel() + 1;
- return getExpToLevel(nextLevel) - exp;
+ int exp = (int)Math.round(getExpAtLevel(player) * player.getExp());
+ int nextLevel = player.getLevel();
+ return getExpAtLevel(nextLevel) - exp;
}
}
diff --git a/Essentials/src/com/earth2me/essentials/signs/SignKit.java b/Essentials/src/com/earth2me/essentials/signs/SignKit.java
index c1a4cd0fd..148854010 100644
--- a/Essentials/src/com/earth2me/essentials/signs/SignKit.java
+++ b/Essentials/src/com/earth2me/essentials/signs/SignKit.java
@@ -1,6 +1,7 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.*;
+import com.earth2me.essentials.commands.NoChargeException;
import java.util.List;
import java.util.Locale;
import java.util.Map;
@@ -62,6 +63,10 @@ public class SignKit extends EssentialsSign
Kit.expandItems(ess, player, items);
charge.charge(player);
}
+ catch (NoChargeException ex)
+ {
+ return false;
+ }
catch (Exception ex)
{
throw new SignException(ex.getMessage(), ex);
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index 34d13bf5a..617fb6677 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -156,11 +156,13 @@ player-commands:
- signs.use.disposal
- signs.use.enchant
- signs.use.free
- - signs.use.gamemode
+ - signs.use.gamemode
- signs.use.heal
+ - signs.use.info
- signs.use.kit
- signs.use.mail
- signs.use.protection
+ - signs.use.repair
- signs.use.sell
- signs.use.time
- signs.use.trade
@@ -194,7 +196,7 @@ kits:
delay: 10
items:
- 272 1
- - 273 1
+ - 273 1
- 274 1
- 275 1
@@ -207,7 +209,7 @@ kits:
enabledSigns:
#- color
#- balance
- #- buy
+ #- buy
#- sell
#- trade
#- free
@@ -454,7 +456,7 @@ protect:
alert:
on-placement: 10,11,46,327
on-use: 327
- on-break:
+ on-break:
blacklist:
@@ -512,7 +514,7 @@ protect:
ender_dragon: false
pig: false
sheep: false
- cow: false
+ cow: false
chicken: false
squid: false
wolf: false
diff --git a/Essentials/src/items.csv b/Essentials/src/items.csv
index 29920e69f..986331445 100644
--- a/Essentials/src/items.csv
+++ b/Essentials/src/items.csv
@@ -1733,6 +1733,8 @@ endgooframe,120,0
endergooframe,120,0
egooframe,120,0
eportalframe,120,0
+enderframe,120,0
+endframe,120,0
enderstone,121,0
endstone,121,0
endrock,121,0
diff --git a/Essentials/src/plugin.yml b/Essentials/src/plugin.yml
index 98058ab38..98af00ea3 100644
--- a/Essentials/src/plugin.yml
+++ b/Essentials/src/plugin.yml
@@ -341,7 +341,7 @@ commands:
time:
description: Display/Change the world time. Defaults to current world.
usage: /<command> [day|night|dawn|17:30|4pm|4000ticks] [worldname|all]
- aliases: [etime, day, night]
+ aliases: [etime, day, night, eday, enight]
togglejail:
description: Jails/Unjails a player and tp them to the jail specified.
usage: /<command> <player> <jailname> [datediff]
@@ -425,7 +425,7 @@ commands:
weather:
description: Setting the weather.
usage: /<command> <storm/sun> [duration]
- aliases: [sky,sun,storm,eweather,esky,esun,estorm]
+ aliases: [sky,sun,storm,eweather,rain,erain,esky,esun,estorm]
whois:
description: Determine the username behind a nickname.
usage: /<command> <nickname>
diff --git a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
index 9dce1169c..1ebb6389c 100644
--- a/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
+++ b/EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java
@@ -6,6 +6,7 @@ import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import java.util.Map;
+import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Location;
import org.bukkit.Server;
@@ -46,11 +47,25 @@ public abstract class EssentialsChatPlayer implements Listener
}
synchronized (listeners)
{
- for (IEssentialsChatListener listener : listeners.values())
+ for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
{
- if (listener.shouldHandleThisChat(event))
+ try
{
- return true;
+ if (listener.getValue().shouldHandleThisChat(event))
+ {
+ return true;
+ }
+ }
+ catch (Throwable t)
+ {
+ if (ess.getSettings().isDebug())
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
+ }
+ else
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
+ }
}
}
}
@@ -160,9 +175,23 @@ public abstract class EssentialsChatPlayer implements Listener
String message = String.format(event.getFormat(), type.concat(sender.getDisplayName()), event.getMessage());
synchronized (listeners)
{
- for (IEssentialsChatListener listener : listeners.values())
+ for (Map.Entry<String, IEssentialsChatListener> listener : listeners.entrySet())
{
- message = listener.modifyMessage(event, onlinePlayer, message);
+ try
+ {
+ message = listener.getValue().modifyMessage(event, onlinePlayer, message);
+ }
+ catch (Throwable t)
+ {
+ if (ess.getSettings().isDebug())
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage(), t);
+ }
+ else
+ {
+ logger.log(Level.WARNING, "Error with EssentialsChat listener of " + listener.getKey() + ": " + t.getMessage());
+ }
+ }
}
}
onlineUser.sendMessage(message);
diff --git a/EssentialsGroupManager/src/globalgroups.yml b/EssentialsGroupManager/src/globalgroups.yml
index a9a1f22cf..2027195e4 100644
--- a/EssentialsGroupManager/src/globalgroups.yml
+++ b/EssentialsGroupManager/src/globalgroups.yml
@@ -222,6 +222,7 @@ groups:
- essentials.warp.*
- essentials.weather
- essentials.whois
+ - essentials.workbench
- essentials.world
- essentials.world.*
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
index cc8181ddf..d0f5fed8b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GlobalGroups.java
@@ -161,7 +161,11 @@ public class GlobalGroups {
Object element;
// Permission nodes
- element = ((Map<String, Object>)allGroups.get(groupName)).get("permissions");
+ try {
+ element = ((Map<String, Object>)allGroups.get(groupName)).get("permissions");
+ } catch ( Exception ex) {
+ throw new IllegalArgumentException("The GlobalGroup ' " + groupName + "' is formatted incorrectly: ", ex);
+ }
if (element != null)
if (element instanceof List) {
@@ -180,7 +184,11 @@ public class GlobalGroups {
throw new IllegalArgumentException("Unknown type of permission node for global group: " + groupName);
// Info nodes
- element = ((Map<String, Object>)allGroups.get(groupName)).get("info");
+ try {
+ element = ((Map<String, Object>)allGroups.get(groupName)).get("info");
+ } catch ( Exception ex) {
+ throw new IllegalArgumentException("The GlobalGroup ' " + groupName + "' is formatted incorrectly: ", ex);
+ }
if (element != null)
if (element instanceof MemorySection) {