summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsnowleo <schneeleo@gmail.com>2012-01-18 04:01:01 +0100
committersnowleo <schneeleo@gmail.com>2012-01-18 04:01:01 +0100
commitf0dd81ee000b333b2aca59b9949518c7686cceb1 (patch)
treecf620b5603e1b25656550f87a37975b6dc5351af
parent27b0cc86de8c21f089e0e68a5db3ebb42f4df2d2 (diff)
parent5c1d49fd0efe56c24d6ae5f63f4d0cc31329243d (diff)
downloadEssentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.gz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.lz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.tar.xz
Essentials-f0dd81ee000b333b2aca59b9949518c7686cceb1.zip
Merge branch 'refs/heads/master' into 3.0
Did some tweaks, so that it actually works. Conflicts: Essentials/src/com/earth2me/essentials/Essentials.java Essentials/src/com/earth2me/essentials/User.java Essentials/src/com/earth2me/essentials/Util.java Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java Essentials/src/com/earth2me/essentials/commands/Commandmail.java Essentials/src/com/earth2me/essentials/commands/Commandme.java Essentials/src/com/earth2me/essentials/commands/Commandmsg.java Essentials/src/com/earth2me/essentials/commands/Commandnick.java Essentials/src/com/earth2me/essentials/commands/Commandr.java Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayer.java EssentialsChat/src/com/earth2me/essentials/chat/EssentialsChatPlayerListenerLowest.java EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java build.xml
-rw-r--r--Essentials/nbproject/project.properties4
-rw-r--r--Essentials/src/com/earth2me/essentials/Enchantments.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/UserData.java22
-rw-r--r--Essentials/src/com/earth2me/essentials/UserMap.java1
-rw-r--r--Essentials/src/com/earth2me/essentials/Util.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandafk.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandantioch.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandback.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbackup.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbalance.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandban.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbanip.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbreak.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandburn.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandcompass.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanddepth.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandeco.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandenchant.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandext.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfeed.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfireball.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgc.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgive.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgod.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandheal.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhelp.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhome.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandignore.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandinfo.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditem.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandjails.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandjump.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkick.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkickall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkill.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkillall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkit.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandlightning.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandlist.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmail.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandme.java9
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmore.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmotd.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmsg.java47
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmute.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnear.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnick.java12
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandnuke.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpay.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandping.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandptime.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandr.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrealname.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandremove.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrepair.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandrules.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandseen.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsell.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsethome.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawner.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsudo.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtempban.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandthunder.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtime.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtop.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtp.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpa.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpall.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtphere.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtppos.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtree.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunban.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwarp.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandweather.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandwhois.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandworld.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandworth.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java14
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java75
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/Methods.java53
-rw-r--r--Essentials/src/com/earth2me/essentials/register/payment/methods/VaultEco.java328
-rw-r--r--Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java13
-rw-r--r--Essentials/src/com/earth2me/essentials/textreader/TextInput.java77
-rw-r--r--Essentials/src/config.yml12
-rw-r--r--EssentialsGroupManager/src/Changelog.txt20
-rw-r--r--EssentialsGroupManager/src/config.yml32
-rw-r--r--EssentialsGroupManager/src/globalgroups.yml65
-rw-r--r--EssentialsGroupManager/src/groups.yml3
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java65
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java2
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java118
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java50
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java106
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java538
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java332
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java22
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java8
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java64
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java123
-rw-r--r--EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java2
-rw-r--r--EssentialsGroupManager/src/plugin.yml3
-rw-r--r--EssentialsGroupManager/src/users.yml4
-rw-r--r--EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java61
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java2
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java4
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java5
-rw-r--r--EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java30
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java2
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java2
-rw-r--r--EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java2
-rw-r--r--lib/Vault.jarbin0 -> 180183 bytes
144 files changed, 1673 insertions, 957 deletions
diff --git a/Essentials/nbproject/project.properties b/Essentials/nbproject/project.properties
index 7aac1ae1a..b6b6c3142 100644
--- a/Essentials/nbproject/project.properties
+++ b/Essentials/nbproject/project.properties
@@ -76,6 +76,7 @@ file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
file.reference.Permissions3.jar=../lib/Permissions3.jar
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
+file.reference.Vault.jar=../lib/Vault.jar
includes=**
jar.archive.disabled=${jnlp.enabled}
jar.compress=true
@@ -93,7 +94,8 @@ javac.classpath=\
${file.reference.lombok-0.10.1.jar}:\
${reference.EssentialsGroupManager.jar}:\
${file.reference.bukkit.jar}:\
- ${file.reference.craftbukkit.jar}
+ ${file.reference.craftbukkit.jar}:\
+ ${file.reference.Vault.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false
diff --git a/Essentials/src/com/earth2me/essentials/Enchantments.java b/Essentials/src/com/earth2me/essentials/Enchantments.java
index 4e851db44..c4c6be3a4 100644
--- a/Essentials/src/com/earth2me/essentials/Enchantments.java
+++ b/Essentials/src/com/earth2me/essentials/Enchantments.java
@@ -62,7 +62,9 @@ public final class Enchantments
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
+ ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
+ ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
}
public static Enchantment getByName(final String name) {
diff --git a/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java b/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java
index 5c0fdbafa..1c04a5694 100644
--- a/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java
+++ b/Essentials/src/com/earth2me/essentials/EssentialsCommandHandler.java
@@ -125,14 +125,14 @@ public class EssentialsCommandHandler implements ICommandHandler
{
if (user == null)
{
- cmd.run(sender, command, args);
+ cmd.run(sender, command, commandLabel, args);
}
else
{
user.acquireReadLock();
try
{
- cmd.run(user, command, args);
+ cmd.run(user, command, commandLabel, args);
}
finally
{
diff --git a/Essentials/src/com/earth2me/essentials/UserData.java b/Essentials/src/com/earth2me/essentials/UserData.java
index b72a5d516..85e7cd04e 100644
--- a/Essentials/src/com/earth2me/essentials/UserData.java
+++ b/Essentials/src/com/earth2me/essentials/UserData.java
@@ -53,7 +53,6 @@ public abstract class UserData extends PlayerExtension implements IConf
lastLogout = _getLastLogout();
lastLoginAddress = _getLastLoginAddress();
afk = getAfk();
- newplayer = getNew();
geolocation = _getGeoLocation();
isSocialSpyEnabled = _isSocialSpyEnabled();
isNPC = _isNPC();
@@ -265,6 +264,11 @@ public abstract class UserData extends PlayerExtension implements IConf
{
return (List<String>)powertools.get(stack.getTypeId());
}
+
+ public List<String> getPowertool(int id)
+ {
+ return (List<String>)powertools.get(id);
+ }
public void setPowertool(ItemStack stack, List<String> commandList)
{
@@ -736,22 +740,6 @@ public abstract class UserData extends PlayerExtension implements IConf
}
private boolean newplayer;
- private boolean getNew()
- {
- return config.getBoolean("newplayer", true);
- }
-
- public boolean isNew()
- {
- return newplayer;
- }
-
- public void setNew(boolean set)
- {
- newplayer = set;
- config.setProperty("newplayer", set);
- config.save();
- }
private String geolocation;
private String _getGeoLocation()
diff --git a/Essentials/src/com/earth2me/essentials/UserMap.java b/Essentials/src/com/earth2me/essentials/UserMap.java
index 4c3f338ec..7f7c5c056 100644
--- a/Essentials/src/com/earth2me/essentials/UserMap.java
+++ b/Essentials/src/com/earth2me/essentials/UserMap.java
@@ -7,7 +7,6 @@ import com.google.common.cache.CacheLoader;
import com.google.common.util.concurrent.UncheckedExecutionException;
import java.io.File;
import java.util.Collections;
-import java.util.Locale;
import java.util.Set;
import java.util.concurrent.ConcurrentSkipListSet;
import java.util.concurrent.ExecutionException;
diff --git a/Essentials/src/com/earth2me/essentials/Util.java b/Essentials/src/com/earth2me/essentials/Util.java
index 58ee96c5e..6f2065b46 100644
--- a/Essentials/src/com/earth2me/essentials/Util.java
+++ b/Essentials/src/com/earth2me/essentials/Util.java
@@ -620,7 +620,7 @@ public final class Util
perm.recalculatePermissibles();
return perm;
}
- private static transient final Pattern COLOR_PATTERN = Pattern.compile("(?i)\u00A7[0-9A-F]");
+ private static transient final Pattern COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
public static String stripColor(final String input)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
index a3e1fd141..c5f02a990 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandafk.java
@@ -10,7 +10,7 @@ import org.bukkit.permissions.PermissionDefault;
public class Commandafk extends EssentialsCommand
{
@Override
- public void run(IUser user, String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized(Permissions.AFK_OTHERS))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
index f1ced883e..989275d56 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandantioch.java
@@ -9,7 +9,7 @@ import org.bukkit.entity.TNTPrimed;
public class Commandantioch extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandback.java b/Essentials/src/com/earth2me/essentials/commands/Commandback.java
index 3b997240e..01a65ae64 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandback.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandback.java
@@ -8,7 +8,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandback extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
index 0f22ba51a..867135a93 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbackup.java
@@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
public class Commandbackup extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final IBackup backup = ess.getBackup();
backup.run();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
index e0e7c806f..73cadde0d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalance.java
@@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
public class Commandbalance extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -20,7 +20,7 @@ public class Commandbalance extends EssentialsCommand
}
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final double bal = (args.length < 1
|| !user.isAuthorized(Permissions.BALANCE_OTHERS)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
index 757cb6c1d..6c7237eb9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbalancetop.java
@@ -21,7 +21,7 @@ public class Commandbalancetop extends EssentialsCommand
private static ReentrantReadWriteLock lock = new ReentrantReadWriteLock();
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
int page = 0;
boolean force = false;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandban.java b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
index 5deddca30..4e0190b35 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandban.java
@@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class Commandban extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
index 64f315a9b..c9d4caa89 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbanip.java
@@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
public class Commandbanip extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
index 39ef14d57..3e9396519 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbigtree.java
@@ -10,7 +10,7 @@ import org.bukkit.TreeType;
public class Commandbigtree extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
TreeType tree;
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
index bb38c3583..12b25a14a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbreak.java
@@ -10,7 +10,7 @@ public class Commandbreak extends EssentialsCommand
{
//TODO: Switch to use util class
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final Block block = user.getTargetBlock(null, 20);
if (block == null)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
index ea70f1c10..572da8f67 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandbroadcast.java
@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class Commandbroadcast extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
index 11b332ad2..08b8739b5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandburn.java
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
public class Commandburn extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
index 55195f9bc..cd16aa1ee 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandclearinventory.java
@@ -11,7 +11,7 @@ public class Commandclearinventory extends EssentialsCommand
{
//TODO: Cleanup
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
{
@@ -53,7 +53,7 @@ public class Commandclearinventory extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
index 7b9b590cb..7314f8b6e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandcompass.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandcompass extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final int bearing = (int)(user.getLocation().getYaw() + 180 + 360) % 360;
String dir;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
index 14bda2212..92df03637 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelhome.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commanddelhome extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
index dc097a803..9daae2fad 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddeljail.java
@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class Commanddeljail extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
index b122f76bc..482652b15 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddelwarp.java
@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class Commanddelwarp extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
index 031bb29d5..73d3c7150 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanddepth.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commanddepth extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final int depth = user.getLocation().getBlockY() - 63;
if (depth > 0)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
index b9c47a29f..bf9ebaef6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandeco.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandeco extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
index e43226def..37d0fdd1d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandenchant.java
@@ -16,7 +16,7 @@ public class Commandenchant extends EssentialsCommand
{
//TODO: Implement charge costs: final Trade charge = new Trade("enchant-" + enchantmentName, ess);
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
if (stack == null)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
index 7cff555fc..ddc6d775e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -16,7 +16,7 @@ public class Commandessentials extends EssentialsCommand
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length == 0)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandext.java b/Essentials/src/com/earth2me/essentials/commands/Commandext.java
index 8520915df..8e689506a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandext.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandext.java
@@ -8,10 +8,8 @@ import org.bukkit.entity.Player;
public class Commandext extends EssentialsCommand
{
-
-
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -22,7 +20,7 @@ public class Commandext extends EssentialsCommand
}
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
index 9b2f858d6..c815c6375 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfeed.java
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Commandfeed extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.feed.others"))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
index 87d564c90..f13f3ee75 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfireball.java
@@ -9,7 +9,7 @@ import org.bukkit.util.Vector;
public class Commandfireball extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
boolean small = false;
if (args.length > 0 && args[0].equalsIgnoreCase("small"))
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
index f951eb19b..dfab50ee6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgamemode.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandgamemode extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -22,7 +22,7 @@ public class Commandgamemode extends EssentialsCommand
}
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
index 560541de6..8c7d2b485 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgc.java
@@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
public class Commandgc extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
index b4d3c2e00..3ce81b156 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
@@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
public class Commandgetpos extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
{
@@ -22,7 +22,7 @@ public class Commandgetpos extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
index c00a21c49..446eff530 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgive.java
@@ -14,7 +14,7 @@ public class Commandgive extends EssentialsCommand
{
//TODO: move these messages to message file
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
index 6be1a2e9c..2530d8674 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgod.java
@@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class Commandgod extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -20,7 +20,7 @@ public class Commandgod extends EssentialsCommand
}
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.god.others"))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
index b27daabc8..3e4437aeb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandheal.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandheal extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length > 0 && user.isAuthorized("essentials.heal.others"))
@@ -30,7 +30,7 @@ public class Commandheal extends EssentialsCommand
}
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
index 1d850cb65..48c679736 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelp.java
@@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
public class Commandhelp extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
IText output;
String pageStr = args.length > 0 ? args[0] : null;
@@ -35,11 +35,11 @@ public class Commandhelp extends EssentialsCommand
output = new KeywordReplacer(input, user, ess);
}
final TextPager pager = new TextPager(output);
- pager.showPage(pageStr, chapterPageStr, "help", user);
+ pager.showPage(pageStr, chapterPageStr, commandLabel, user);
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage(_("helpConsole"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
index d811004cc..1622570a4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhelpop.java
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
import java.util.logging.Level;
import org.bukkit.entity.Player;
@@ -9,14 +10,14 @@ import org.bukkit.entity.Player;
public class Commandhelpop extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
- final String message = _("helpOp", user.getDisplayName(), getFinalArg(args, 0));
+ final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
logger.log(Level.INFO, message);
for (Player onlinePlayer : server.getOnlinePlayers())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
index 365afe30c..6fe74335c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
@@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandhome extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
@@ -44,7 +44,7 @@ public class Commandhome extends EssentialsCommand
if (bed != null)
{
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
- return;
+ throw new NoChargeException();
}
}
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
@@ -58,10 +58,10 @@ public class Commandhome extends EssentialsCommand
if (bed != null)
{
user.getTeleport().teleport(bed, charge, TeleportCause.COMMAND);
- return;
+ throw new NoChargeException();
}
user.getTeleport().respawn(charge, TeleportCause.COMMAND);
- return;
+
}
else if (homes.isEmpty())
{
@@ -70,7 +70,6 @@ public class Commandhome extends EssentialsCommand
else if (homes.size() == 1 && player.equals(user))
{
user.getTeleport().home(player, homes.get(0), charge);
- return;
}
else
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
index 1e734d9b4..9b3ff71cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandignore.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandignore extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
index 2d14b60f7..d694c9fa4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinfo.java
@@ -10,11 +10,11 @@ import org.bukkit.command.CommandSender;
public class Commandinfo extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final IText input = new TextInput(sender, "info", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output);
- pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "info", sender);
+ pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
index b90d7bf89..4b772e0ec 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandinvsee.java
@@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandinvsee extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1 && user.getData().getInventory() == null)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index 1a5b5edb9..9483f2661 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -11,7 +11,7 @@ import org.bukkit.inventory.ItemStack;
public class Commanditem extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
index 07d88eac6..6d0a17037 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditemdb.java
@@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class Commanditemdb extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ItemStack itemStack = null;
if (args.length < 1)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
index 6cdbe4b0b..f7865e78b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandjails.java
@@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
public class Commandjails extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("§7" + Util.joinList(" ", ess.getJails().getList()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
index d57e6ad65..ff0c80d51 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandjump.java
@@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandjump extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
Location loc;
final Location cloc = user.getLocation();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
index 981d52db4..ada0c1296 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkick.java
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Commandkick extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
index 8f8f10bf7..e460f5cbd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkickall.java
@@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
public class Commandkickall extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
for (Player onlinePlayer : server.getOnlinePlayers())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
index f0d291c1a..6b79a757b 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkill.java
@@ -9,7 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
public class Commandkill extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
index 83a906a01..7d952a8bb 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkillall.java
@@ -15,7 +15,7 @@ public class Commandkillall extends EssentialsCommand
{
//TODO: Tidy - missed this during command cleanup
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
String type = "all";
int radius = -1;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
index ceb3c6be0..a21e4b38d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
@@ -12,7 +12,7 @@ import java.util.Locale;
public class Commandkit extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
index beed577e3..0973b2137 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlightning.java
@@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class Commandlightning extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
IUser user = null;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
index 305ba29bf..26a070ec2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandlist extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
boolean showhidden = false;
if (sender instanceof Player)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
index 46979b31e..abd46b545 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
import java.util.List;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -11,7 +12,7 @@ public class Commandmail extends EssentialsCommand
{
//TODO: Tidy this up
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
{
@@ -51,7 +52,7 @@ public class Commandmail extends EssentialsCommand
}
if (!u.isIgnoringPlayer(user.getName()))
{
- u.addMail(user.getName() + ": " + getFinalArg(args, 2));
+ u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2)));
}
user.sendMessage(_("mailSent"));
return;
@@ -62,7 +63,7 @@ public class Commandmail extends EssentialsCommand
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
- ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + getFinalArg(args, 1)));
+ ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
user.sendMessage(_("mailSent"));
return;
}
@@ -77,7 +78,7 @@ public class Commandmail extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
index 0504d0f65..252244cba 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
@@ -2,12 +2,13 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
public class Commandme extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (user.getData().isMuted())
{
@@ -22,8 +23,12 @@ public class Commandme extends EssentialsCommand
String message = getFinalArg(args, 0);
if (user.isAuthorized("essentials.chat.color"))
{
- message = message.replaceAll("&([0-9a-f])", "§$1");
+ message = message.replaceAll("&([0-9a-fk])", "§$1");
}
+ else {
+ message = Util.stripColor(message);
+ }
+
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
index c36de8d6b..d28d8e0fe 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmore.java
@@ -10,7 +10,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandmore extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final ItemStack stack = user.getItemInHand();
if (stack == null)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
index 4958d774e..3531d0708 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmotd.java
@@ -10,11 +10,11 @@ import org.bukkit.command.CommandSender;
public class Commandmotd extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final IText input = new TextInput(sender, "motd", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
final TextPager pager = new TextPager(output);
- pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, "motd", sender);
+ pager.showPage(args.length > 0 ? args[0] : null, args.length > 1 ? args[1] : null, commandLabel, sender);
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
index 87445e11b..a61d6c49c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IReplyTo;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
import java.util.List;
import lombok.Cleanup;
import org.bukkit.command.CommandSender;
@@ -13,13 +14,14 @@ import org.bukkit.entity.Player;
public class Commandmsg extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
{
throw new NotEnoughArgumentsException();
}
+ String message = getFinalArg(args, 1);
if (sender instanceof Player)
{
@Cleanup
@@ -29,13 +31,24 @@ public class Commandmsg extends EssentialsCommand
{
throw new Exception(_("voiceSilenced"));
}
+ if (user.isAuthorized("essentials.msg.color"))
+ {
+ message = message.replaceAll("&([0-9a-fk])", "§$1");
+ }
+ else
+ {
+ message = Util.stripColor(message);
+ }
+ }
+ else
+ {
+ message = message.replaceAll("&([0-9a-fk])", "§$1");
}
- String message = getFinalArg(args, 1);
- String translatedMe = _("me");
+ final String translatedMe = _("me");
- IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
- String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
+ final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
+ final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
if (args[0].equalsIgnoreCase(Console.NAME))
{
@@ -47,38 +60,38 @@ public class Commandmsg extends EssentialsCommand
return;
}
- List<Player> matches = server.matchPlayer(args[0]);
+ final List<Player> matchedPlayers = server.matchPlayer(args[0]);
- if (matches.isEmpty())
+ if (matchedPlayers.isEmpty())
{
throw new Exception(_("playerNotFound"));
}
int i = 0;
- for (Player p : matches)
+ for (Player matchedPlayer : matchedPlayers)
{
- final IUser u = ess.getUser(p);
+ final IUser u = ess.getUser(matchedPlayer);
if (u.isHidden())
{
i++;
}
}
- if (i == matches.size())
+ if (i == matchedPlayers.size())
{
throw new Exception(_("playerNotFound"));
}
- for (Player p : matches)
+ for (Player matchedPlayer : matchedPlayers)
{
- sender.sendMessage(_("msgFormat", translatedMe, p.getDisplayName(), message));
- final IUser u = ess.getUser(p);
- if (sender instanceof Player && (u.isIgnoringPlayer(((Player)sender).getName()) || u.isHidden()))
+ sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
+ final IUser matchedUser = ess.getUser(matchedPlayer);
+ if (sender instanceof Player && (matchedUser.isIgnoringPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
{
continue;
}
- p.sendMessage(_("msgFormat", senderName, translatedMe, message));
- replyTo.setReplyTo(ess.getUser(p));
- ess.getUser(p).setReplyTo(sender);
+ matchedPlayer.sendMessage(_("msgFormat", senderName, translatedMe, message));
+ replyTo.setReplyTo(ess.getUser(matchedPlayer));
+ ess.getUser(matchedPlayer).setReplyTo(sender);
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
index eb31ed0ec..59d401f96 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmute.java
@@ -11,7 +11,7 @@ import org.bukkit.command.CommandSender;
public class Commandmute extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
index 0fb2900c6..368dd90a3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnear.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandnear extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
long radius = 200;
IUser otherUser = null;
@@ -54,7 +54,7 @@ public class Commandnear extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
IUser otherUser = null;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
index 1461fc634..add0a2129 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnick.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
import java.util.Locale;
import lombok.Cleanup;
import org.bukkit.Server;
@@ -13,7 +14,7 @@ import org.bukkit.entity.Player;
public class Commandnick extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -40,7 +41,7 @@ public class Commandnick extends EssentialsCommand
}
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
@@ -68,9 +69,10 @@ public class Commandnick extends EssentialsCommand
{
if (user == null || user.isAuthorized("essentials.nick.color"))
{
- return nick.replace('&', '\u00a7').replace("\u00a7\u00a7", "&");
+ return nick.replace('&', '\u00a7').replaceAll("\u00a7+k", "");
+ } else {
+ return Util.stripColor(nick);
}
- return nick;
}
private void resetAllNicknames(final Server server)
@@ -89,7 +91,7 @@ public class Commandnick extends EssentialsCommand
private void setNickname(final IUser target, final String nick) throws Exception
{
- if (nick.matches("[^a-zA-Z_0-9]"))
+ if (!nick.matches("^[a-zA-Z_0-9\u00a7]+$"))
{
throw new Exception(_("nickNamesAlpha"));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
index b508e19fa..20bdc140a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandnuke.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.TNTPrimed;
public class Commandnuke extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
{
List<Player> targets;
if (args.length > 0)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
index b7261aab5..837360f18 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpay.java
@@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
public class Commandpay extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandping.java b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
index b5ab2bd18..e87542acd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandping.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
@@ -7,8 +7,8 @@ import com.earth2me.essentials.api.IUser;
public class Commandping extends EssentialsCommand
{
@Override
- public void run(final IUser player, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
- player.sendMessage(_("pong"));
+ user.sendMessage(_("pong"));
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
index e7de661b9..78e338722 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
@@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandpowertool extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
String command = getFinalArg(args, 0);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
index 74205cda5..24481bcec 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertooltoggle.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandpowertooltoggle extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (!user.getData().hasPowerTools())
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
index 9d84ded94..62a6fa298 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandptime.java
@@ -22,7 +22,7 @@ public class Commandptime extends EssentialsCommand
}
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
// Which Players(s) / Users(s) are we interested in?
String userSelector = null;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandr.java b/Essentials/src/com/earth2me/essentials/commands/Commandr.java
index ee3acc1b8..48a723513 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandr.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandr.java
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Console;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IReplyTo;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.Util;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -11,16 +12,38 @@ import org.bukkit.entity.Player;
public class Commandr extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
- final String message = getFinalArg(args, 0);
- final IReplyTo replyTo = sender instanceof Player ? ess.getUser((Player)sender) : Console.getConsoleReplyTo();
- final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
+ String message = getFinalArg(args, 0);
+ IReplyTo replyTo;
+ String senderName;
+
+ if (sender instanceof Player)
+ {
+ IUser user = ess.getUser((Player)sender);
+ if (user.isAuthorized("essentials.msg.color"))
+ {
+ message = message.replaceAll("&([0-9a-fk])", "§$1");
+ }
+ else
+ {
+ message = Util.stripColor(message);
+ }
+ replyTo = user;
+ senderName = user.getDisplayName();
+ }
+ else
+ {
+ message = message.replaceAll("&([0-9a-fk])", "§$1");
+ replyTo = Console.getConsoleReplyTo();
+ senderName = Console.NAME;
+ }
+
final CommandSender target = replyTo.getReplyTo();
final String targetName = target instanceof Player ? ((Player)target).getDisplayName() : Console.NAME;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
index db4dbd31e..303ec8294 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrealname.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class Commandrealname extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
index 78314401b..66cdf625d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandremove.java
@@ -22,7 +22,7 @@ public class Commandremove extends EssentialsCommand
}
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
index 1e8ad4cb1..6ad0d729c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrepair.java
@@ -15,7 +15,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandrepair extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
index a696469ad..5445b9bc6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandrules.java
@@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
public class Commandrules extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final IText input = new TextInput(sender, "rules", true, ess);
final IText output = new KeywordReplacer(input, sender, ess);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
index d15bf0e04..6b987c628 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
@@ -10,7 +10,7 @@ import org.bukkit.command.CommandSender;
public class Commandseen extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
index 6b6390a18..20923dcdd 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsell.java
@@ -14,7 +14,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandsell extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
index 62296fc40..c92c24dab 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsethome.java
@@ -11,7 +11,7 @@ import org.bukkit.Location;
public class Commandsethome extends EssentialsCommand
{
@Override
- public void run(final IUser user, String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, String[] args) throws Exception
{
if (args.length > 0)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
index ab7fe2c3f..2fcad7bd2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetjail.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandsetjail extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
index 5d7b99451..5a0599789 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetwarp.java
@@ -9,7 +9,7 @@ import org.bukkit.Location;
public class Commandsetwarp extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
index 9e9a0e71e..3e0b3f52c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
@@ -8,7 +8,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandsetworth extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
index a4e8127b3..86ae15fc8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsocialspy.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandsocialspy extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
user.sendMessage("§7SocialSpy " + (user.toggleSocialSpy() ? _("enabled") : _("disabled")));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
index 444b54d8c..23e3b9a7e 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawner.java
@@ -12,7 +12,7 @@ import org.bukkit.block.CreatureSpawner;
public class Commandspawner extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1 || args[0].length() < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
index f85f5cf66..9649a50e4 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandspawnmob.java
@@ -17,7 +17,7 @@ import org.bukkit.entity.*;
public class Commandspawnmob extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
index 771c7bbc1..d93bbc466 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsudo.java
@@ -8,7 +8,7 @@ import org.bukkit.command.PluginCommand;
public class Commandsudo extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
index 3560d5340..2e89faf85 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsuicide.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandsuicide extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
user.setHealth(0);
user.sendMessage(_("suicideMessage"));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
index e181a8cf4..fb631be20 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtempban.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class Commandtempban extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
index cdb132c4a..23c2e13b9 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandthunder.java
@@ -8,7 +8,7 @@ import org.bukkit.World;
public class Commandthunder extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
index 579458cb5..991eea80d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtime.java
@@ -12,7 +12,7 @@ import org.bukkit.entity.Player;
public class Commandtime extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
// Which World(s) are we interested in?
String worldSelector = null;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
index 9bdc1122f..4406d5958 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtogglejail.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class Commandtogglejail extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
index 480fed1ec..01fa24c1d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtop.java
@@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtop extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final int topX = user.getLocation().getBlockX();
final int topZ = user.getLocation().getBlockZ();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
index fa5969718..85c72605a 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtp.java
@@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtp extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
switch (args.length)
{
@@ -49,7 +49,7 @@ public class Commandtp extends EssentialsCommand
}
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
index ee8b72878..6790883c6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java
@@ -9,7 +9,7 @@ import lombok.Cleanup;
public class Commandtpa extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
index de80b02ff..ad3bb0aa5 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java
@@ -11,7 +11,7 @@ import org.bukkit.entity.Player;
public class Commandtpaall extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
index 8e047ade9..b32158069 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java
@@ -11,7 +11,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpaccept extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (user.getTeleportRequester() == null)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
index 4e7a44877..b28898cd6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
@@ -9,7 +9,7 @@ import lombok.Cleanup;
public class Commandtpahere extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index 67bf8d279..ee1cd230f 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpall extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
index 9477ad059..15d3f7728 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpdeny.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandtpdeny extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final IUser player = user.getTeleportRequester();
if (player == null)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
index 76d42c6ec..b2cb09ca2 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
@@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtphere extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
@Cleanup
final IUser player = getPlayer(args, 0);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 0aca2c83a..c7b5312c8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpo extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
index 5ddafee81..bfd52562d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpohere.java
@@ -9,7 +9,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtpohere extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
index 2d0149a10..c2fd75707 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtppos.java
@@ -10,7 +10,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandtppos extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 3)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
index fea85e51b..2c39271ac 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtptoggle.java
@@ -7,7 +7,7 @@ import com.earth2me.essentials.api.IUser;
public class Commandtptoggle extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
user.sendMessage(user.toggleTeleportEnabled()
? _("teleportationEnabled")
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
index 9483f6880..d3fd4df67 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtree.java
@@ -10,7 +10,7 @@ import org.bukkit.TreeType;
public class Commandtree extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
TreeType tree;
if (args.length < 1)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
index 6f1b9a833..a18856d66 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunban.java
@@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
public class Commandunban extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
index 6de7cbbd9..14d2c8ae6 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunbanip.java
@@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
public class Commandunbanip extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
index 0c86b59ba..ebfad6ee8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandunlimited.java
@@ -13,7 +13,7 @@ import org.bukkit.inventory.ItemStack;
public class Commandunlimited extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
index f6b0deb29..06a203f85 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwarp.java
@@ -17,7 +17,7 @@ public class Commandwarp extends EssentialsCommand
private final static int WARPS_PER_PAGE = 20;
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length == 0 || args[0].matches("[0-9]+"))
{
@@ -47,7 +47,7 @@ public class Commandwarp extends EssentialsCommand
}
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2 || args[0].matches("[0-9]+"))
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
index 051bc24d1..2df5b1eac 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandweather.java
@@ -10,7 +10,7 @@ public class Commandweather extends EssentialsCommand
{
//TODO: Remove duplication
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -39,7 +39,7 @@ public class Commandweather extends EssentialsCommand
//TODO: Translate these
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 2) //running from console means inserting a world arg before other args
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
index d96eebd77..1632722bc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandwhois.java
@@ -13,7 +13,7 @@ import org.bukkit.entity.Player;
public class Commandwhois extends EssentialsCommand
{
@Override
- public void run(final CommandSender sender, final String[] args) throws Exception
+ public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
@@ -40,7 +40,7 @@ public class Commandwhois extends EssentialsCommand
{
@Cleanup
final IUser user = ess.getUser(onlinePlayer);
-
+
if (user.isHidden() && !showhidden)
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
index 26413fc4e..920900a57 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworld.java
@@ -12,7 +12,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandworld extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
World world;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
index b36d71695..57955b6ba 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandworth.java
@@ -12,7 +12,7 @@ public class Commandworth extends EssentialsCommand
{
//TODO: Remove duplication
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
ItemStack iStack = user.getInventory().getItemInHand();
int amount = iStack.getAmount();
@@ -56,7 +56,7 @@ public class Commandworth extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
index 1cd54adf2..a70471327 100644
--- a/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/EssentialsCommand.java
@@ -85,26 +85,26 @@ public abstract class EssentialsCommand extends AbstractSuperpermsPermission imp
}
@Override
- public final void run(final IUser user, final Command cmd, final String[] args) throws Exception
+ public final void run(final IUser user, final Command cmd, final String commandLabel, final String[] args) throws Exception
{
final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
- run(user, args);
+ run(user, commandLabel, args);
charge.charge(user);
}
- protected void run(final IUser user, final String[] args) throws Exception
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
- run((CommandSender)user.getBase(), args);
+ run((CommandSender)user.getBase(), commandLabel, args);
}
@Override
- public final void run(final CommandSender sender, final Command cmd, final String[] args) throws Exception
+ public final void run(final CommandSender sender, final Command cmd, final String commandLabel, final String[] args) throws Exception
{
- run(sender, args);
+ run(sender, commandLabel, args);
}
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
throw new Exception(_("onlyPlayers", commandName));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java
index ae54c75c3..b4c1b40f8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java
+++ b/Essentials/src/com/earth2me/essentials/commands/IEssentialsCommand.java
@@ -10,10 +10,10 @@ import org.bukkit.command.CommandSender;
public interface IEssentialsCommand extends IPermission
{
- void run(IUser user, Command cmd, String[] args)
+ void run(IUser user, Command cmd, String commandLabel, String[] args)
throws Exception;
- void run(CommandSender sender, Command cmd, String[] args)
+ void run(CommandSender sender, Command cmd, String commandLabel, String[] args)
throws Exception;
void init(IEssentials ess, String commandLabel);
diff --git a/Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java b/Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java
index a71273044..6e5ff855a 100644
--- a/Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java
+++ b/Essentials/src/com/earth2me/essentials/listener/EssentialsPlayerListener.java
@@ -198,7 +198,6 @@ public class EssentialsPlayerListener extends PlayerListener
{
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
{
- LOGGER.log(Level.INFO, "Disconnecting user {0} due to {1}", new Object[]{event.getPlayer().toString(), event.getResult().toString()});
return;
}
@Cleanup
@@ -268,7 +267,8 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
{
- @Cleanup final IUser user = ess.getUser(event.getPlayer());
+ @Cleanup
+ final IUser user = ess.getUser(event.getPlayer());
user.acquireReadLock();
if (user.getData().hasUnlimited(event.getBucket()))
{
@@ -289,46 +289,57 @@ public class EssentialsPlayerListener extends PlayerListener
{
final IUser user = ess.getUser(event.getPlayer());
user.updateActivity(true);
- usePowertools(event);
+ if (event.getAnimationType() == PlayerAnimationType.ARM_SWING)
+ {
+ usePowertools(user);
+ }
}
- private void usePowertools(final PlayerAnimationEvent event)
+ private void usePowertools(final IUser user)
{
- if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
- {
- return;
- }
- @Cleanup
- final IUser user = ess.getUser(event.getPlayer());
user.acquireReadLock();
- final ItemStack hand = user.getItemInHand();
- if (hand == null || hand.getType() == Material.AIR || !user.getData().isPowerToolsEnabled())
+ try
{
- return;
- }
- final List<String> commandList = user.getData().getPowertool(hand.getType());
- if (commandList == null || commandList.isEmpty())
- {
- return;
- }
+ if (!user.getData().hasPowerTools() || !user.getData().isPowerToolsEnabled())
+ {
+ return;
+ }
- // We need to loop through each command and execute
- for (String command : commandList)
- {
- if (command.matches(".*\\{player\\}.*"))
+ final ItemStack hand = user.getItemInHand();
+ Material type;
+ if (hand == null || (type = hand.getType()) == Material.AIR)
{
- //user.sendMessage("Click a player to use this command");
- continue;
+ return;
}
- else if (command.startsWith("c:"))
+ final List<String> commandList = user.getData().getPowertool(type);
+
+ if (commandList == null || commandList.isEmpty())
{
- user.chat(command.substring(2));
+ return;
}
- else
+
+ // We need to loop through each command and execute
+ for (String command : commandList)
{
- user.getServer().dispatchCommand(event.getPlayer(), command);
+ if (command.matches(".*\\{player\\}.*"))
+ {
+ //user.sendMessage("Click a player to use this command");
+ continue;
+ }
+ else if (command.startsWith("c:"))
+ {
+ user.chat(command.substring(2));
+ }
+ else
+ {
+ user.getServer().dispatchCommand(user.getBase(), command);
+ }
}
}
+ finally
+ {
+ user.unlock();
+ }
}
@Override
@@ -363,9 +374,11 @@ public class EssentialsPlayerListener extends PlayerListener
@Override
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
{
- @Cleanup final ISettings settings = ess.getSettings();
+ @Cleanup
+ final ISettings settings = ess.getSettings();
settings.acquireReadLock();
- @Cleanup final IUser user = ess.getUser(event.getPlayer());
+ @Cleanup
+ final IUser user = ess.getUser(event.getPlayer());
user.acquireReadLock();
if (!settings.getData().getWorldOptions(event.getPlayer().getLocation().getWorld().getName()).isGodmode() && !user.isAuthorized("essentials.nogod.override"))
{
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
index 32acc0442..f8729923e 100644
--- a/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
+++ b/Essentials/src/com/earth2me/essentials/register/payment/Methods.java
@@ -7,23 +7,23 @@ import org.bukkit.plugin.PluginManager;
/**
- * The <code>Methods</code> initializes Methods that utilize the Method interface
- * based on a "first come, first served" basis.
+ * The
+ * <code>Methods</code> initializes Methods that utilize the Method interface based on a "first come, first served"
+ * basis.
*
* Allowing you to check whether a payment method exists or not.
*
- * Methods also allows you to set a preferred method of payment before it captures
- * payment plugins in the initialization process.
+ * Methods also allows you to set a preferred method of payment before it captures payment plugins in the initialization
+ * process.
*
- * in <code>bukkit.yml</code>:
- * <blockquote><pre>
+ * in
+ * <code>bukkit.yml</code>: <blockquote><pre>
* economy:
* preferred: "iConomy"
* </pre></blockquote>
*
- * @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
- * @copyright: Copyright (C) 2011
- * @license: AOL license <http://aol.nexua.org>
+ * @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun) @copyright: Copyright (C) 2011 @license: AOL license
+ * <http://aol.nexua.org>
*/
public class Methods
{
@@ -52,6 +52,7 @@ public class Methods
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
addMethod("Currency", new com.earth2me.essentials.register.payment.methods.MCUR());
Dependencies.add("MultiCurrency");
+ addMethod("Vault", new com.earth2me.essentials.register.payment.methods.VaultEco());
}
/**
@@ -78,6 +79,7 @@ public class Methods
/**
* Use to get version of Register plugin
+ *
* @return version
*/
public static String getVersion()
@@ -86,10 +88,11 @@ public class Methods
}
/**
- * Returns an array of payment method names that have been loaded
- * through the <code>_init</code> method.
+ * Returns an array of payment method names that have been loaded through the
+ * <code>_init</code> method.
*
- * @return <code>Set<String></code> - Array of payment methods that are loaded.
+ * @return
+ * <code>Set<String></code> - Array of payment methods that are loaded.
* @see #setMethod(org.bukkit.plugin.Plugin)
*/
public static Set<String> getDependencies()
@@ -98,8 +101,8 @@ public class Methods
}
/**
- * Interprets Plugin class data to verify whether it is compatible with an existing payment
- * method to use for payments and other various economic activity.
+ * Interprets Plugin class data to verify whether it is compatible with an existing payment method to use for
+ * payments and other various economic activity.
*
* @param plugin Plugin data from bukkit, Internal Class file.
* @return Method <em>or</em> Null
@@ -127,7 +130,8 @@ public class Methods
/**
* Verifies if Register has set a payment method for usage yet.
*
- * @return <code>boolean</code>
+ * @return
+ * <code>boolean</code>
* @see #setMethod(org.bukkit.plugin.Plugin)
* @see #checkDisabled(org.bukkit.plugin.Plugin)
*/
@@ -137,11 +141,11 @@ public class Methods
}
/**
- * Checks Plugin Class against a multitude of checks to verify it's usability
- * as a payment method.
+ * Checks Plugin Class against a multitude of checks to verify it's usability as a payment method.
*
* @param <code>PluginManager</code> the plugin manager for the server
- * @return <code>boolean</code> True on success, False on failure.
+ * @return
+ * <code>boolean</code> True on success, False on failure.
*/
public static boolean setMethod(PluginManager manager)
{
@@ -242,7 +246,8 @@ public class Methods
/**
* Sets the preferred economy
*
- * @return <code>boolean</code>
+ * @return
+ * <code>boolean</code>
*/
public static boolean setPreferred(String check)
{
@@ -258,7 +263,9 @@ public class Methods
/**
* Grab the existing and initialized (hopefully) Method Class.
*
- * @return <code>Method</code> <em>or</em> <code>Null</code>
+ * @return
+ * <code>Method</code> <em>or</em>
+ * <code>Null</code>
*/
public static Method getMethod()
{
@@ -266,11 +273,11 @@ public class Methods
}
/**
- * Verify is a plugin is disabled, only does this if we there is an existing payment
- * method initialized in Register.
+ * Verify is a plugin is disabled, only does this if we there is an existing payment method initialized in Register.
*
* @param method Plugin data from bukkit, Internal Class file.
- * @return <code>boolean</code>
+ * @return
+ * <code>boolean</code>
*/
public static boolean checkDisabled(Plugin method)
{
diff --git a/Essentials/src/com/earth2me/essentials/register/payment/methods/VaultEco.java b/Essentials/src/com/earth2me/essentials/register/payment/methods/VaultEco.java
new file mode 100644
index 000000000..c7757f66b
--- /dev/null
+++ b/Essentials/src/com/earth2me/essentials/register/payment/methods/VaultEco.java
@@ -0,0 +1,328 @@
+package com.earth2me.essentials.register.payment.methods;
+
+import net.milkbowl.vault.Vault;
+import net.milkbowl.vault.economy.Economy;
+
+import org.bukkit.plugin.Plugin;
+import org.bukkit.plugin.RegisteredServiceProvider;
+
+import com.earth2me.essentials.register.payment.Method;
+
+
+public class VaultEco implements Method
+{
+ private Vault vault;
+ private Economy economy;
+
+ @Override
+ public Vault getPlugin()
+ {
+ return this.vault;
+ }
+
+ @Override
+ public boolean createAccount(String name, Double amount)
+ {
+ if (hasAccount(name))
+ {
+ return false;
+ }
+
+ return false;
+ }
+
+ @Override
+ public String getName()
+ {
+
+ return this.vault.getDescription().getName().concat(" - Economy: ").concat(economy == null ? "NoEco" : economy.getName());
+ }
+
+ @Override
+ public String getVersion()
+ {
+ return this.vault.getDescription().getVersion();
+ }
+
+ @Override
+ public int fractionalDigits()
+ {
+ return 0;
+ }
+
+ @Override
+ public String format(double amount)
+ {
+ return this.economy.format(amount);
+ }
+
+ @Override
+ public boolean hasBanks()
+ {
+ return this.economy.hasBankSupport();
+ }
+
+ @Override
+ public boolean hasBank(String bank)
+ {
+ return this.economy.getBanks().contains(bank);
+ }
+
+ @Override
+ public boolean hasAccount(String name)
+ {
+ return this.economy.hasAccount(name);
+ }
+
+ @Override
+ public boolean hasBankAccount(String bank, String name)
+ {
+ return this.economy.isBankOwner(bank, name).transactionSuccess()
+ || this.economy.isBankMember(bank, name).transactionSuccess();
+ }
+
+ @Override
+ public boolean createAccount(String name)
+ {
+ return this.economy.createBank(name, "").transactionSuccess();
+ }
+
+ public boolean createAccount(String name, double balance)
+ {
+ if (!this.economy.createBank(name, "").transactionSuccess())
+ {
+ return false;
+ }
+ return this.economy.bankDeposit(name, balance).transactionSuccess();
+ }
+
+ @Override
+ public MethodAccount getAccount(String name)
+ {
+ if (!hasAccount(name))
+ {
+ return null;
+ }
+
+ return new VaultAccount(name, this.economy);
+ }
+
+ @Override
+ public MethodBankAccount getBankAccount(String bank, String name)
+ {
+ if (!hasBankAccount(bank, name))
+ {
+ return null;
+ }
+
+ return new VaultBankAccount(bank, economy);
+ }
+
+ @Override
+ public boolean isCompatible(Plugin plugin)
+ {
+ RegisteredServiceProvider<Economy> ecoPlugin = plugin.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+ return plugin instanceof Vault && ecoPlugin != null && !ecoPlugin.getProvider().getName().equals("Essentials Economy");
+ }
+
+ @Override
+ public void setPlugin(Plugin plugin)
+ {
+ this.vault = (Vault)plugin;
+ RegisteredServiceProvider<Economy> economyProvider = this.vault.getServer().getServicesManager().getRegistration(net.milkbowl.vault.economy.Economy.class);
+ if (economyProvider != null)
+ {
+ this.economy = economyProvider.getProvider();
+ }
+ }
+
+
+ public class VaultAccount implements MethodAccount
+ {
+ private final String name;
+ private final Economy economy;
+
+ public VaultAccount(String name, Economy economy)
+ {
+ this.name = name;
+ this.economy = economy;
+ }
+
+ @Override
+ public double balance()
+ {
+ return this.economy.getBalance(this.name);
+ }
+
+ @Override
+ public boolean set(double amount)
+ {
+ if (!this.economy.withdrawPlayer(this.name, this.balance()).transactionSuccess())
+ {
+ return false;
+ }
+ if (amount == 0)
+ {
+ return true;
+ }
+ return this.economy.depositPlayer(this.name, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean add(double amount)
+ {
+ return this.economy.depositPlayer(this.name, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean subtract(double amount)
+ {
+ return this.economy.withdrawPlayer(this.name, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean multiply(double amount)
+ {
+ double balance = this.balance();
+ return this.set(balance * amount);
+ }
+
+ @Override
+ public boolean divide(double amount)
+ {
+ double balance = this.balance();
+ return this.set(balance / amount);
+ }
+
+ @Override
+ public boolean hasEnough(double amount)
+ {
+ return (this.balance() >= amount);
+ }
+
+ @Override
+ public boolean hasOver(double amount)
+ {
+ return (this.balance() > amount);
+ }
+
+ @Override
+ public boolean hasUnder(double amount)
+ {
+ return (this.balance() < amount);
+ }
+
+ @Override
+ public boolean isNegative()
+ {
+ return (this.balance() < 0);
+ }
+
+ @Override
+ public boolean remove()
+ {
+ return this.set(0.0);
+ }
+ }
+
+
+ public class VaultBankAccount implements MethodBankAccount
+ {
+ private final String bank;
+ private final Economy economy;
+
+ public VaultBankAccount(String bank, Economy economy)
+ {
+ this.bank = bank;
+ this.economy = economy;
+ }
+
+ @Override
+ public String getBankName()
+ {
+ return this.bank;
+ }
+
+ @Override
+ public int getBankId()
+ {
+ return -1;
+ }
+
+ @Override
+ public double balance()
+ {
+ return this.economy.bankBalance(this.bank).balance;
+ }
+
+ @Override
+ public boolean set(double amount)
+ {
+ if (!this.economy.bankWithdraw(this.bank, this.balance()).transactionSuccess())
+ {
+ return false;
+ }
+ if (amount == 0)
+ {
+ return true;
+ }
+ return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean add(double amount)
+ {
+ return this.economy.bankDeposit(this.bank, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean subtract(double amount)
+ {
+ return this.economy.bankWithdraw(this.bank, amount).transactionSuccess();
+ }
+
+ @Override
+ public boolean multiply(double amount)
+ {
+ double balance = this.balance();
+ return this.set(balance * amount);
+ }
+
+ @Override
+ public boolean divide(double amount)
+ {
+ double balance = this.balance();
+ return this.set(balance / amount);
+ }
+
+ @Override
+ public boolean hasEnough(double amount)
+ {
+ return (this.balance() >= amount);
+ }
+
+ @Override
+ public boolean hasOver(double amount)
+ {
+ return (this.balance() > amount);
+ }
+
+ @Override
+ public boolean hasUnder(double amount)
+ {
+ return (this.balance() < amount);
+ }
+
+ @Override
+ public boolean isNegative()
+ {
+ return (this.balance() < 0);
+ }
+
+ @Override
+ public boolean remove()
+ {
+ return this.set(0.0);
+ }
+ }
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
index 775b0cf95..a7a1117a2 100644
--- a/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
+++ b/Essentials/src/com/earth2me/essentials/textreader/KeywordReplacer.java
@@ -4,6 +4,7 @@ import com.earth2me.essentials.DescParseTickFormat;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;
import java.text.DateFormat;
+import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Map;
@@ -17,15 +18,17 @@ import org.bukkit.plugin.Plugin;
public class KeywordReplacer implements IText
{
private final transient IText input;
+ private final transient List<String> replaced;
private final transient IEssentials ess;
-
+
public KeywordReplacer(final IText input, final CommandSender sender, final IEssentials ess)
{
this.input = input;
+ this.replaced = new ArrayList<String>(this.input.getLines().size());
this.ess = ess;
replaceKeywords(sender);
}
-
+
private void replaceKeywords(final CommandSender sender)
{
String displayName, ipAddress, balance, mails, world;
@@ -44,7 +47,7 @@ public class KeywordReplacer implements IText
world = user.getLocation().getWorld().getName();
worldTime12 = DescParseTickFormat.format12(user.getWorld().getTime());
worldTime24 = DescParseTickFormat.format24(user.getWorld().getTime());
- worldDate = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(DescParseTickFormat.ticksToDate(user.getWorld().getTime()));
+ worldDate = DateFormat.getDateInstance(DateFormat.MEDIUM, ess.getI18n().getCurrentLocale()).format(DescParseTickFormat.ticksToDate(user.getWorld().getFullTime()));
}
else
{
@@ -123,14 +126,14 @@ public class KeywordReplacer implements IText
line = line.replace("{WORLDDATE}", worldDate);
line = line.replace("{PLUGINS}", plugins);
line = line.replace("{VERSION}", version);
- input.getLines().set(i, line);
+ replaced.add(line);
}
}
@Override
public List<String> getLines()
{
- return input.getLines();
+ return replaced;
}
@Override
diff --git a/Essentials/src/com/earth2me/essentials/textreader/TextInput.java b/Essentials/src/com/earth2me/essentials/textreader/TextInput.java
index 350831033..0856d5ff6 100644
--- a/Essentials/src/com/earth2me/essentials/textreader/TextInput.java
+++ b/Essentials/src/com/earth2me/essentials/textreader/TextInput.java
@@ -5,6 +5,7 @@ import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.api.InvalidNameException;
import java.io.*;
+import java.lang.ref.SoftReference;
import java.util.*;
import java.util.logging.Level;
import org.bukkit.Bukkit;
@@ -14,9 +15,11 @@ import org.bukkit.entity.Player;
public class TextInput implements IText
{
- private final transient List<String> lines = new ArrayList<String>();
- private final transient List<String> chapters = new ArrayList<String>();
- private final transient Map<String, Integer> bookmarks = new HashMap<String, Integer>();
+ private final transient List<String> lines;
+ private final transient List<String> chapters;
+ private final transient Map<String, Integer> bookmarks;
+ private final transient long lastChange;
+ private final static HashMap<String, SoftReference<TextInput>> cache = new HashMap<String, SoftReference<TextInput>>();
public TextInput(final CommandSender sender, final String filename, final boolean createFile, final IEssentials ess) throws IOException
{
@@ -44,33 +47,62 @@ public class TextInput implements IText
}
if (file.exists())
{
- final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
- try
+ lastChange = file.lastModified();
+ boolean readFromfile;
+ synchronized (cache)
{
- int lineNumber = 0;
- while (bufferedReader.ready())
+ final SoftReference<TextInput> inputRef = cache.get(file.getName());
+ TextInput input;
+ if (inputRef == null || (input = inputRef.get()) == null || input.lastChange < lastChange)
{
- final String line = bufferedReader.readLine();
- if (line == null)
- {
- break;
- }
- if (line.length() > 0 && line.charAt(0) == '#')
- {
- bookmarks.put(line.substring(1).toLowerCase(Locale.ENGLISH).replaceAll("&[0-9a-f]", ""), lineNumber);
- chapters.add(line.substring(1).replace('&', '§').replace("§§", "&"));
- }
- lines.add(line.replace('&', '§').replace("§§", "&"));
- lineNumber++;
+ lines = new ArrayList<String>();
+ chapters = new ArrayList<String>();
+ bookmarks = new HashMap<String, Integer>();
+ cache.put(file.getName(), new SoftReference<TextInput>(this));
+ readFromfile = true;
+ }
+ else
+ {
+ lines = Collections.unmodifiableList(input.getLines());
+ chapters = Collections.unmodifiableList(input.getChapters());
+ bookmarks = Collections.unmodifiableMap(input.getBookmarks());
+ readFromfile = false;
}
}
- finally
+ if (readFromfile)
{
- bufferedReader.close();
+ final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
+ try
+ {
+ int lineNumber = 0;
+ while (bufferedReader.ready())
+ {
+ final String line = bufferedReader.readLine();
+ if (line == null)
+ {
+ break;
+ }
+ if (line.length() > 0 && line.charAt(0) == '#')
+ {
+ bookmarks.put(line.substring(1).toLowerCase(Locale.ENGLISH).replaceAll("&[0-9a-f]", ""), lineNumber);
+ chapters.add(line.substring(1).replace('&', '§').replace("§§", "&"));
+ }
+ lines.add(line.replace('&', '§').replace("§§", "&"));
+ lineNumber++;
+ }
+ }
+ finally
+ {
+ bufferedReader.close();
+ }
}
}
else
{
+ lastChange = 0;
+ lines = Collections.emptyList();
+ chapters = Collections.emptyList();
+ bookmarks = Collections.emptyMap();
if (createFile)
{
final InputStream input = ess.getResource(filename + ".txt");
@@ -78,8 +110,7 @@ public class TextInput implements IText
try
{
final byte[] buffer = new byte[1024];
- int length = 0;
- length = input.read(buffer);
+ int length = input.read(buffer);
while (length > 0)
{
output.write(buffer, 0, length);
diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml
index d09a0f6c0..fac2f6080 100644
--- a/Essentials/src/config.yml
+++ b/Essentials/src/config.yml
@@ -260,10 +260,7 @@ cancel-tp-requests-on-world-change: false
# +------------------------------------------------------+ #
############################################################
-# When users die, should they respawn at their first home, instead of the spawnpoint or bed?
-respawn-at-home: false
-
-# If no home is set send you to bed or spawn when /home is used
+# If no home is set, send players to spawn when /home is used
spawn-if-no-home: true
# Allows people to set their bed at daytime
@@ -539,8 +536,11 @@ newbies:
spawnpoint: newbies
# Set this to lowest, if you want Multiverse to handle the respawning
-# Set this to normal, if you want EssentialsSpawn to handle the respawning
+# Set this to high, if you want EssentialsSpawn to handle the respawning
# Set this to highest, if you want to force EssentialsSpawn to handle the respawning
-respawn-listener-priority: normal
+respawn-listener-priority: high
+
+# When users die, should they respawn at their first home or bed, instead of the spawnpoint?
+respawn-at-home: false
# End of File <-- No seriously, you're done with configuration.
diff --git a/EssentialsGroupManager/src/Changelog.txt b/EssentialsGroupManager/src/Changelog.txt
index 47a0f6b79..876dc28b7 100644
--- a/EssentialsGroupManager/src/Changelog.txt
+++ b/EssentialsGroupManager/src/Changelog.txt
@@ -85,4 +85,22 @@ v 1.7:
- Offline player checks now support partial name matches.
- Added custom events so plugins can now be notified of changes within GroupManager.
- GM now registers with Bukkits ServicesManager.
- - deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException. \ No newline at end of file
+ - deleting the contents of GlobalGroups.yml will no longer thrown a NullPointerException.
+ - Removed op permissions from admins in the default GloblaGroups.yml.
+v 1.8:
+ - Changed ServicesManager registration to lowest from normal.
+ - Fixed 'manucheckp' returning a null for the searched node when it's a group/subgroup.
+ - manpromote and mandemote now correctly send the notification to the console if the command was issued there.
+ - Expanded GlobalGroups.yml and Groups.yml to include Towny permissions.
+ - Delayed GroupManager events so Superperms will be fully updated before plugins receive the events.
+ - Changed the way events are raised to prevent variable corruption.
+ - Reload GlobalGroups when you perform a world load.
+ - Changed GlobalGroups to save/load before local groups in the scheduled data saving/loading
+ - Fix 'manucheckp' to correctly report if a permission is available from GroupManager or Bukkit.
+ - Changed over to a reflection method for populating superperms as Bukkit lags when you handle permissions one at a time.
+ - Major, MAJOR changes to support partial/full world mirroring.
+ You can now mirror groups.yml, users.yml or both files between different worlds.
+ - Catch NullPointerErrors generated by blank permission nodes.
+ - Removed '- bukkit.command' form the globalgroups permission nodes.
+v 1.9:
+ - Optimize populating Bukkit perms so we no longer calculate the child nodes (Bukkit already does this). \ No newline at end of file
diff --git a/EssentialsGroupManager/src/config.yml b/EssentialsGroupManager/src/config.yml
index 2fe5e509c..13b59d343 100644
--- a/EssentialsGroupManager/src/config.yml
+++ b/EssentialsGroupManager/src/config.yml
@@ -4,9 +4,9 @@ settings:
# The user will be able to promote players to the same group or even above.
opOverrides: true
- # If enabled any plugins bukkit permissions which default to true will be left enabled.
+ # If enabled any bukkit permissiosn which default to true will be left enabled.
# If the player is op any permissions set to Op will follow suit.
- bukkit_perms_override: false
+ bukkit_perms_override: true
# Default setting for 'mantoglevalidate'
# true will cause GroupManager to attempt name matching by default.
@@ -25,14 +25,22 @@ settings:
level: INFO
mirrors:
- # Worlds listed here have their permissions mirrored in their children.
- # the first element 'world' is the main worlds name
- # subsequent elements '- world_nether' are worlds which will use the same
- # user/groups permissions as the parent.
+ # Worlds listed here have their settings mirrored in their children.
+ # The first element 'world' is the main worlds name
+ # subsequent elements 'world_nether' and 'world_the_end' are worlds which will use
+ # the same user/groups files as the parent.
+ # Each child world can be configured to mirror the 'groups', 'users' or both files from it's parent.
world:
- - world_nether
- - world_the_end
- - world2
- - world3
- # world4:
- # - world5 \ No newline at end of file
+ world_nether:
+ - users
+ - groups
+ world_the_end:
+ - users
+ - groups
+ # world2: (World2 would have it's own set of user and groups files)
+ # world3:
+ # - users (World3 would use the users.yml from world2, but it's own groups.yml)
+ # world4:
+ # - groups (World4 would use the groups.yml from world2, but it's own users.yml)
+ # world5:
+ # - world6 (this would cause world6 to mirror both files from world5) \ No newline at end of file
diff --git a/EssentialsGroupManager/src/globalgroups.yml b/EssentialsGroupManager/src/globalgroups.yml
index 9662baf43..f21034237 100644
--- a/EssentialsGroupManager/src/globalgroups.yml
+++ b/EssentialsGroupManager/src/globalgroups.yml
@@ -1,9 +1,5 @@
groups:
- g:bukkit_default:
- permissions:
- - bukkit.broadcast.user
-
g:essentials_default:
permissions:
- essentials.help
@@ -129,6 +125,11 @@ groups:
- groupmanager.manucheckp
- groupmanager.manulistp
+ g:bukkit_default:
+ permissions:
+ - bukkit.broadcast.user
+ - -bukkit.command.plugins
+
g:bukkit_moderator:
permissions:
- bukkit.command.ban
@@ -144,15 +145,14 @@ groups:
permissions:
- bukkit.broadcast
- bukkit.broadcast.admin
- - bukkit.command
- bukkit.command.give
- bukkit.command.help
- bukkit.command.kill
- bukkit.command.list
- bukkit.command.me
- - bukkit.command.op
- - bukkit.command.op.give
- - bukkit.command.op.take
+ - -bukkit.command.op
+ - -bukkit.command.op.give
+ - -bukkit.command.op.take
- bukkit.command.plugins
- bukkit.command.reload
- bukkit.command.save
@@ -174,3 +174,52 @@ groups:
- bukkit.command.whitelist.list
- bukkit.command.whitelist.reload
- bukkit.command.whitelist.remove
+
+ g:towny_builder:
+ permissions:
+ - towny.town.*
+ - towny.nation.*
+ - towny.chat.tc
+ - towny.chat.nc
+ - towny.wild.block.6.*
+ - towny.wild.block.14.destroy
+ - towny.wild.block.15.destroy
+ - towny.wild.block.16.destroy
+ - towny.wild.block.17.*
+ - towny.wild.block.18.destroy
+ - towny.wild.block.21.destroy
+ - towny.wild.block.31.destroy
+ - towny.wild.block.37.destroy
+ - towny.wild.block.38.destroy
+ - towny.wild.block.39.destroy
+ - towny.wild.block.40.destroy
+ - towny.wild.block.50.destroy
+ - towny.wild.block.56.destroy
+ - towny.wild.block.73.destroy
+ - towny.wild.block.74.destroy
+ - towny.wild.block.78.destroy
+ - towny.wild.block.81.destroy
+ - towny.wild.block.82.destroy
+ - towny.wild.block.83.destroy
+ - towny.wild.block.86.destroy
+ - towny.wild.block.103.destroy
+ - towny.wild.block.106.destroy
+ - towny.wild.block.111.destroy
+ - towny.wild.block.115.destroy
+
+ g:towny_moderator:
+ permissions:
+ - towny.chat.mod
+ - towny.wild.block.64.switch
+ - towny.wild.block.83.build
+ - towny.wild.block.86.build
+ - towny.wild.block.103.build
+ - towny.wild.block.111.build
+ - towny.wild.block.115.build
+
+ g:towny_admin:
+ permissions:
+ - towny.admin
+ - -towny.wild.block.119.destroy
+ - -towny.wild.block.120.destroy
+ - towny.chat.admin \ No newline at end of file
diff --git a/EssentialsGroupManager/src/groups.yml b/EssentialsGroupManager/src/groups.yml
index 81fb4f030..e50054c9f 100644
--- a/EssentialsGroupManager/src/groups.yml
+++ b/EssentialsGroupManager/src/groups.yml
@@ -24,6 +24,7 @@ groups:
inheritance:
- default
- g:essentials_builder
+ - g:towny_moderator
info:
prefix: '&2'
build: true
@@ -35,6 +36,7 @@ groups:
- builder
- g:essentials_moderator
- g:bukkit_moderator
+ - g:towny_moderator
info:
prefix: '&5'
build: true
@@ -46,6 +48,7 @@ groups:
- moderator
- g:essentials_admin
- g:bukkit_admin
+ - g:towny_admin
info:
prefix: '&c'
build: true
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
index 2d46e74c8..8134a1c23 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/GroupManager.java
@@ -161,7 +161,7 @@ public class GroupManager extends JavaPlugin {
System.out.println(pdfFile.getName() + " version " + pdfFile.getVersion() + " is enabled!");
// Register as a service
- this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Normal);
+ this.getServer().getServicesManager().register(AnjoPermissionsHandler.class, this.permissionHandler, this, ServicePriority.Lowest);
}
public static boolean isLoaded() {
@@ -415,7 +415,7 @@ public class GroupManager extends JavaPlugin {
// PARECE OK
auxUser.setGroup(auxGroup);
- if (!sender.hasPermission("groupmanager.notify.other"))
+ if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed player '" + auxUser.getName() + "' group to '" + auxGroup.getName() + "'.");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
@@ -787,29 +787,29 @@ public class GroupManager extends JavaPlugin {
}
targetPlayer = this.getServer().getPlayer(auxUser.getName());
// VALIDANDO PERMISSAO
- permissionResult = permissionHandler.checkFullUserPermission(auxUser, args[1]);
+ permissionResult = permissionHandler.checkFullGMPermission(auxUser, args[1], false);
+
if (permissionResult.resultType.equals(PermissionCheckResult.Type.NOTFOUND)) {
+ //No permissions found in GM so fall through and check Bukkit.
sender.sendMessage(ChatColor.RED + "The player doesn't have access to that permission");
- sender.sendMessage(ChatColor.YELLOW + "SuperPerms reports Node: " + targetPlayer.hasPermission(args[1]));
- return false;
- }
- // PARECE OK
- // auxString =
- // permissionHandler.checkUserOnlyPermission(auxUser, args[1]);
- if (permissionResult.owner instanceof User) {
- if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
- sender.sendMessage(ChatColor.RED + "The user has directly a negation node for that permission.");
- } else {
- sender.sendMessage(ChatColor.YELLOW + "The user has directly this permission.");
- }
- sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
- } else if (permissionResult.owner instanceof Group) {
- if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
- sender.sendMessage(ChatColor.RED + "The user inherits the a negation permission from group: " + permissionResult.owner.getName());
- } else {
- sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName());
+
+ } else {
+ // This permission was found in groupmanager.
+ if (permissionResult.owner instanceof User) {
+ if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
+ sender.sendMessage(ChatColor.RED + "The user has directly a negation node for that permission.");
+ } else {
+ sender.sendMessage(ChatColor.YELLOW + "The user has directly this permission.");
+ }
+ sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
+ } else if (permissionResult.owner instanceof Group) {
+ if (permissionResult.resultType.equals(PermissionCheckResult.Type.NEGATION)) {
+ sender.sendMessage(ChatColor.RED + "The user inherits a negation permission from group: " + permissionResult.owner.getName());
+ } else {
+ sender.sendMessage(ChatColor.YELLOW + "The user inherits the permission from group: " + permissionResult.owner.getName());
+ }
+ sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
}
- sender.sendMessage(ChatColor.YELLOW + "Permission Node: " + permissionResult.accessLevel);
}
// superperms
@@ -948,7 +948,7 @@ public class GroupManager extends JavaPlugin {
}
} else {
- sender.sendMessage(ChatColor.YELLOW + "The grpup '" + auxGroup.getName() + "' has no specific permissions.");
+ sender.sendMessage(ChatColor.YELLOW + "The group '" + auxGroup.getName() + "' has no specific permissions.");
auxString = "";
for (String grp : auxGroup.getInherits()) {
auxString += grp + ", ";
@@ -1504,7 +1504,9 @@ public class GroupManager extends JavaPlugin {
isLoaded = false; // Disable Bukkit Perms update
+ globalGroups.load();
worldsHolder.loadWorld(auxString);
+
sender.sendMessage("The request to world '" + auxString + "' was sent.");
isLoaded = true;
@@ -1520,7 +1522,8 @@ public class GroupManager extends JavaPlugin {
}
// WORKING
config.load();
-
+ worldsHolder.mirrorSetUp();
+
isLoaded = false;
if (args.length > 0) {
@@ -1537,7 +1540,6 @@ public class GroupManager extends JavaPlugin {
worldsHolder.reloadAll();
sender.sendMessage(ChatColor.YELLOW + " The current world was reloaded.");
}
- worldsHolder.mirrorSetUp();
isLoaded = true;
@@ -1610,7 +1612,7 @@ public class GroupManager extends JavaPlugin {
}
// PARECE OK
auxUser.setGroup(auxGroup);
- if (!sender.hasPermission("groupmanager.notify.other"))
+ if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
@@ -1666,7 +1668,7 @@ public class GroupManager extends JavaPlugin {
}
// PARECE OK
auxUser.setGroup(auxGroup);
- if (!sender.hasPermission("groupmanager.notify.other"))
+ if (!sender.hasPermission("groupmanager.notify.other") || (isConsole))
sender.sendMessage(ChatColor.YELLOW + "You changed " + auxUser.getName() + " group to " + auxGroup.getName() + ".");
targetPlayer = this.getServer().getPlayer(auxUser.getName());
@@ -1837,15 +1839,6 @@ public class GroupManager extends JavaPlugin {
return match;
}
-
- /**
- * Triggers all GroupManager events for other plugins to see.
- *
- * @param event
- */
- public static void callEvent(GroupManagerEvent event) {
- Bukkit.getServer().getPluginManager().callEvent(event);
- }
/**
* @return the config
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
index f4b805c35..8788fc83b 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/Tasks/BukkitPermsUpdateTask.java
@@ -18,7 +18,7 @@ public class BukkitPermsUpdateTask implements Runnable {
public void run() {
// Signal loaded and update BukkitPermissions.
GroupManager.setLoaded(true);
- GroupManager.BukkitPermissions.collectPermissions();
+ //GroupManager.BukkitPermissions.collectPermissions();
GroupManager.BukkitPermissions.updateAllPlayers();
GroupManager.logger.info("Bukkit Permissions Updated!");
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java
new file mode 100644
index 000000000..4fc819245
--- /dev/null
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/GroupsDataHolder.java
@@ -0,0 +1,118 @@
+package org.anjocaido.groupmanager.dataholder;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.anjocaido.groupmanager.data.Group;
+
+
+
+/**
+ * @author ElgarL
+ *
+ */
+public class GroupsDataHolder {
+
+ /**
+ * Root World name this set of groups is associated with.
+ */
+ private String name;
+ private Group defaultGroup = null;
+ private File groupsFile;
+ private boolean haveGroupsChanged = false;
+ private long timeStampGroups = 0;
+
+ /**
+ * The actual groups holder
+ */
+ private Map<String, Group> groups = new HashMap<String, Group>();
+
+ /**
+ * Constructor
+ */
+ protected GroupsDataHolder() {
+ }
+
+ protected void setWorldName(String worldName) {
+ name = worldName;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getWorldName() {
+ return name;
+ }
+
+ /**
+ * @return the defaultGroup
+ */
+ public Group getDefaultGroup() {
+ return defaultGroup;
+ }
+
+ /**
+ * @param defaultGroup the defaultGroup to set
+ */
+ public void setDefaultGroup(Group defaultGroup) {
+ this.defaultGroup = defaultGroup;
+ }
+
+ /**
+ * @return the groups
+ */
+ public Map<String, Group> getGroups() {
+ return groups;
+ }
+
+ /**
+ * @param groups the groups to set
+ */
+ public void setGroups(Map<String, Group> groups) {
+ this.groups = groups;
+ }
+
+ /**
+ * @return the groupsFile
+ */
+ public File getGroupsFile() {
+ return groupsFile;
+ }
+
+ /**
+ * @param groupsFile the groupsFile to set
+ */
+ public void setGroupsFile(File groupsFile) {
+ this.groupsFile = groupsFile;
+ }
+
+ /**
+ * @return the haveGroupsChanged
+ */
+ public boolean HaveGroupsChanged() {
+ return haveGroupsChanged;
+ }
+
+ /**
+ * @param haveGroupsChanged the haveGroupsChanged to set
+ */
+ public void setGroupsChanged(boolean haveGroupsChanged) {
+ this.haveGroupsChanged = haveGroupsChanged;
+ }
+
+ /**
+ * @return the timeStampGroups
+ */
+ public long getTimeStampGroups() {
+ return timeStampGroups;
+ }
+
+ /**
+ * @param timeStampGroups the timeStampGroups to set
+ */
+ public void setTimeStampGroups(long timeStampGroups) {
+ this.timeStampGroups = timeStampGroups;
+ }
+
+} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
index 8e2df5d10..b37c55e51 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/OverloadedWorldHolder.java
@@ -25,13 +25,11 @@ public class OverloadedWorldHolder extends WorldDataHolder {
*
* @param ph
*/
- @SuppressWarnings("deprecation")
public OverloadedWorldHolder(WorldDataHolder ph) {
super(ph.getName());
- this.f = ph.f;
- this.groupsFile = ph.groupsFile;
- this.usersFile = ph.usersFile;
- this.defaultGroup = ph.defaultGroup;
+ this.setGroupsFile(ph.getGroupsFile());
+ this.setUsersFile(ph.getUsersFile());
+ //this.setDefaultGroup(ph.getDefaultGroup());
this.groups = ph.groups;
this.users = ph.users;
}
@@ -49,11 +47,11 @@ public class OverloadedWorldHolder extends WorldDataHolder {
return overloadedUsers.get(userNameLowered);
}
//END CODE
- if (users.containsKey(userNameLowered)) {
- return users.get(userNameLowered);
+ if (getUsers().containsKey(userNameLowered)) {
+ return getUsers().get(userNameLowered);
}
User newUser = createUser(userName);
- haveUsersChanged = true;
+ setUsersChanged(true);
return newUser;
}
@@ -69,8 +67,8 @@ public class OverloadedWorldHolder extends WorldDataHolder {
if (theUser == null) {
return;
}
- if ((theUser.getGroup() == null) || (!groups.containsKey(theUser.getGroupName().toLowerCase()))) {
- theUser.setGroup(defaultGroup);
+ if ((theUser.getGroup() == null) || (!getGroups().containsKey(theUser.getGroupName().toLowerCase()))) {
+ theUser.setGroup(getDefaultGroup());
}
//OVERLOADED CODE
if (overloadedUsers.containsKey(theUser.getName().toLowerCase())) {
@@ -80,8 +78,8 @@ public class OverloadedWorldHolder extends WorldDataHolder {
}
//END CODE
removeUser(theUser.getName());
- users.put(theUser.getName().toLowerCase(), theUser);
- haveUsersChanged = true;
+ getUsers().put(theUser.getName().toLowerCase(), theUser);
+ setUsersChanged(true);
}
/**
@@ -97,9 +95,9 @@ public class OverloadedWorldHolder extends WorldDataHolder {
return true;
}
//END CODE
- if (users.containsKey(userName.toLowerCase())) {
- users.remove(userName.toLowerCase());
- haveUsersChanged = true;
+ if (getUsers().containsKey(userName.toLowerCase())) {
+ getUsers().remove(userName.toLowerCase());
+ setUsersChanged(true);
return true;
}
return false;
@@ -107,16 +105,16 @@ public class OverloadedWorldHolder extends WorldDataHolder {
@Override
public boolean removeGroup(String groupName) {
- if (groupName.equals(defaultGroup)) {
+ if (groupName.equals(getDefaultGroup())) {
return false;
}
- for (String key : groups.keySet()) {
+ for (String key : getGroups().keySet()) {
if (groupName.equalsIgnoreCase(key)) {
- groups.remove(key);
- for (String userKey : users.keySet()) {
- User user = users.get(userKey);
+ getGroups().remove(key);
+ for (String userKey : getUsers().keySet()) {
+ User user = getUsers().get(userKey);
if (user.getGroupName().equalsIgnoreCase(key)) {
- user.setGroup(defaultGroup);
+ user.setGroup(getDefaultGroup());
}
}
@@ -124,12 +122,12 @@ public class OverloadedWorldHolder extends WorldDataHolder {
for (String userKey : overloadedUsers.keySet()) {
User user = overloadedUsers.get(userKey);
if (user.getGroupName().equalsIgnoreCase(key)) {
- user.setGroup(defaultGroup);
+ user.setGroup(getDefaultGroup());
}
}
//END OVERLOAD
- haveGroupsChanged = true;
+ setGroupsChanged(true);
return true;
}
}
@@ -143,7 +141,7 @@ public class OverloadedWorldHolder extends WorldDataHolder {
@Override
public Collection<User> getUserList() {
Collection<User> overloadedList = new ArrayList<User>();
- Collection<User> normalList = users.values();
+ Collection<User> normalList = getUsers().values();
for (User u : normalList) {
if (overloadedUsers.containsKey(u.getName().toLowerCase())) {
overloadedList.add(overloadedUsers.get(u.getName().toLowerCase()));
@@ -198,8 +196,8 @@ public class OverloadedWorldHolder extends WorldDataHolder {
if (!isOverloaded(userName)) {
return getUser(userName);
}
- if (users.containsKey(userName.toLowerCase())) {
- return users.get(userName.toLowerCase());
+ if (getUsers().containsKey(userName.toLowerCase())) {
+ return getUsers().get(userName.toLowerCase());
}
User newUser = createUser(userName);
return newUser;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java
new file mode 100644
index 000000000..37e1c4b43
--- /dev/null
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/UsersDataHolder.java
@@ -0,0 +1,106 @@
+package org.anjocaido.groupmanager.dataholder;
+
+import java.io.File;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.anjocaido.groupmanager.data.User;
+
+
+
+/**
+ * @author ElgarL
+ *
+ */
+public class UsersDataHolder {
+
+ /**
+ * Root World name this set of groups is associated with.
+ */
+ private String name;
+ private File usersFile;
+ private boolean haveUsersChanged = false;
+ private long timeStampUsers = 0;
+
+ /**
+ * The actual groups holder
+ */
+ private Map<String, User> users = new HashMap<String, User>();
+
+ /**
+ * Constructor
+ */
+ protected UsersDataHolder() {
+ }
+
+ /**
+ * @param worldName
+ */
+ public void setWorldName(String worldName) {
+ this.name = worldName;
+ }
+
+ /**
+ * @return the name
+ */
+ public String getWorldName() {
+ return this.name;
+ }
+
+ /**
+ * @return the users
+ */
+ public Map<String, User> getUsers() {
+ return users;
+ }
+
+ /**
+ * @param users the users to set
+ */
+ public void setUsers(Map<String, User> users) {
+ this.users = users;
+ }
+
+ /**
+ * @return the usersFile
+ */
+ public File getUsersFile() {
+ return usersFile;
+ }
+
+ /**
+ * @param usersFile the usersFile to set
+ */
+ public void setUsersFile(File usersFile) {
+ this.usersFile = usersFile;
+ }
+
+ /**
+ * @return the haveUsersChanged
+ */
+ public boolean HaveUsersChanged() {
+ return haveUsersChanged;
+ }
+
+ /**
+ * @param haveUsersChanged the haveUsersChanged to set
+ */
+ public void setUsersChanged(boolean haveUsersChanged) {
+ this.haveUsersChanged = haveUsersChanged;
+ }
+
+ /**
+ * @return the timeStampUsers
+ */
+ public long getTimeStampUsers() {
+ return timeStampUsers;
+ }
+
+ /**
+ * @param timeStampUsers the timeStampUsers to set
+ */
+ public void setTimeStampUsers(long timeStampUsers) {
+ this.timeStampUsers = timeStampUsers;
+ }
+
+} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
index 2a944856b..c9c1d2b64 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/WorldDataHolder.java
@@ -8,7 +8,6 @@ import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
-import java.io.FileWriter;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
@@ -49,72 +48,37 @@ public class WorldDataHolder {
/**
* The actual groups holder
*/
- protected Map<String, Group> groups = new HashMap<String, Group>();
+ protected GroupsDataHolder groups = new GroupsDataHolder();
/**
* The actual users holder
*/
- protected Map<String, User> users = new HashMap<String, User>();
-
- /**
- * Points to the default group
- */
- protected Group defaultGroup = null;
-
- /**
- * The file, which this class loads/save data from/to
- * @deprecated
- */
- @Deprecated
- protected File f;
-
+ protected UsersDataHolder users = new UsersDataHolder();
/**
*
*/
protected AnjoPermissionsHandler permissionsHandler;
- /**
- *
- */
- protected File usersFile;
- /**
- *
- */
- protected File groupsFile;
- /**
- *
- */
- protected boolean haveUsersChanged = false;
- /**
- *
- */
- protected boolean haveGroupsChanged = false;
- /**
- *
- */
- protected long timeStampGroups = 0;
- /**
- *
- */
- protected long timeStampUsers = 0;
/**
* Prevent direct instantiation
* @param worldName
*/
- protected WorldDataHolder(String worldName) {
+ public WorldDataHolder(String worldName) {
name = worldName;
}
/**
* The main constructor for a new WorldDataHolder
- * Please don't set the default group as null
* @param worldName
- * @param defaultGroup the default group. its good to start with one
+ * @param groups
+ * @param users
*/
- public WorldDataHolder(String worldName, Group defaultGroup) {
+ public WorldDataHolder(String worldName, GroupsDataHolder groups, UsersDataHolder users) {
this.name = worldName;
- groups.put(defaultGroup.getName().toLowerCase(), defaultGroup);
- this.defaultGroup = defaultGroup;
+ this.groups = groups;
+ this.users = users;
+
+ //this.defaultGroup = defaultGroup;
}
/**
@@ -125,8 +89,8 @@ public class WorldDataHolder {
* @return class that manage that user permission
*/
public User getUser(String userName) {
- if (users.containsKey(userName.toLowerCase())) {
- return users.get(userName.toLowerCase());
+ if (getUsers().containsKey(userName.toLowerCase())) {
+ return getUsers().get(userName.toLowerCase());
}
User newUser = createUser(userName);
return newUser;
@@ -144,11 +108,11 @@ public class WorldDataHolder {
return;
}
if ((theUser.getGroup() == null)) {
- theUser.setGroup(defaultGroup);
+ theUser.setGroup(groups.getDefaultGroup());
}
removeUser(theUser.getName());
- users.put(theUser.getName().toLowerCase(), theUser);
- haveUsersChanged = true;
+ getUsers().put(theUser.getName().toLowerCase(), theUser);
+ setUsersChanged(true);
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(theUser, Action.USER_ADDED);
}
@@ -159,9 +123,9 @@ public class WorldDataHolder {
* @return true if it had something to remove
*/
public boolean removeUser(String userName) {
- if (users.containsKey(userName.toLowerCase())) {
- users.remove(userName.toLowerCase());
- haveUsersChanged = true;
+ if (getUsers().containsKey(userName.toLowerCase())) {
+ getUsers().remove(userName.toLowerCase());
+ setUsersChanged(true);
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(userName, GMUserEvent.Action.USER_REMOVED);
return true;
@@ -175,7 +139,7 @@ public class WorldDataHolder {
* @return true if we have data for this player.
*/
public boolean isUserDeclared(String userName) {
- return users.containsKey(userName.toLowerCase());
+ return getUsers().containsKey(userName.toLowerCase());
}
/**
@@ -183,11 +147,11 @@ public class WorldDataHolder {
* @param group the group you want make default.
*/
public void setDefaultGroup(Group group) {
- if (!groups.containsKey(group.getName().toLowerCase()) || (group.getDataSource() != this)) {
+ if (!getGroups().containsKey(group.getName().toLowerCase()) || (group.getDataSource() != this)) {
addGroup(group);
}
- defaultGroup = this.getGroup(group.getName());
- haveGroupsChanged = true;
+ groups.setDefaultGroup(getGroup(group.getName()));
+ setGroupsChanged(true);
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.DEFAULT_GROUP_CHANGED);
}
@@ -197,7 +161,7 @@ public class WorldDataHolder {
* @return the default group
*/
public Group getDefaultGroup() {
- return defaultGroup;
+ return groups.getDefaultGroup();
}
/**
@@ -209,7 +173,7 @@ public class WorldDataHolder {
if (groupName.toLowerCase().startsWith("g:"))
return GroupManager.getGlobalGroups().getGroup(groupName);
else
- return groups.get(groupName.toLowerCase());
+ return getGroups().get(groupName.toLowerCase());
}
/**
@@ -222,7 +186,7 @@ public class WorldDataHolder {
if (groupName.toLowerCase().startsWith("g:"))
return GroupManager.getGlobalGroups().hasGroup(groupName);
else
- return groups.containsKey(groupName.toLowerCase());
+ return getGroups().containsKey(groupName.toLowerCase());
}
/**
@@ -240,8 +204,8 @@ public class WorldDataHolder {
groupToAdd = groupToAdd.clone(this);
}
removeGroup(groupToAdd.getName());
- groups.put(groupToAdd.getName().toLowerCase(), groupToAdd);
- haveGroupsChanged = true;
+ getGroups().put(groupToAdd.getName().toLowerCase(), groupToAdd);
+ setGroupsChanged(true);
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(groupToAdd, GMGroupEvent.Action.GROUP_ADDED);
}
@@ -256,12 +220,12 @@ public class WorldDataHolder {
return GroupManager.getGlobalGroups().removeGroup(groupName);
}
- if (defaultGroup != null && groupName.equalsIgnoreCase(defaultGroup.getName())) {
+ if (getDefaultGroup() != null && groupName.equalsIgnoreCase(getDefaultGroup().getName())) {
return false;
}
- if (groups.containsKey(groupName.toLowerCase())) {
- groups.remove(groupName.toLowerCase());
- haveGroupsChanged = true;
+ if (getGroups().containsKey(groupName.toLowerCase())) {
+ getGroups().remove(groupName.toLowerCase());
+ setGroupsChanged(true);
if (GroupManager.isLoaded())
GroupManagerEventHandler.callEvent(groupName.toLowerCase(), GMGroupEvent.Action.GROUP_REMOVED);
return true;
@@ -277,13 +241,13 @@ public class WorldDataHolder {
* @return null if user already exists. or new User
*/
public User createUser(String userName) {
- if (this.users.containsKey(userName.toLowerCase())) {
+ if (getUsers().containsKey(userName.toLowerCase())) {
return null;
}
User newUser = new User(this, userName);
- newUser.setGroup(defaultGroup);
- this.addUser(newUser);
- haveUsersChanged = true;
+ newUser.setGroup(groups.getDefaultGroup());
+ addUser(newUser);
+ setUsersChanged(true);
return newUser;
}
@@ -299,13 +263,13 @@ public class WorldDataHolder {
return GroupManager.getGlobalGroups().newGroup(newGroup);
}
- if (this.groups.containsKey(groupName.toLowerCase())) {
+ if (getGroups().containsKey(groupName.toLowerCase())) {
return null;
}
Group newGroup = new Group(this, groupName);
- this.addGroup(newGroup);
- haveGroupsChanged = true;
+ addGroup(newGroup);
+ setGroupsChanged(true);
return newGroup;
}
@@ -314,7 +278,7 @@ public class WorldDataHolder {
* @return a collection of the groups
*/
public Collection<Group> getGroupList() {
- return groups.values();
+ return getGroups().values();
}
/**
@@ -322,7 +286,7 @@ public class WorldDataHolder {
* @return a collection of the users
*/
public Collection<User> getUserList() {
- return users.values();
+ return getUsers().values();
}
/**
@@ -352,9 +316,9 @@ public class WorldDataHolder {
for (Group tempGroup : ph.getGroupList()) {
tempGroup.clone(this);
}
- this.setDefaultGroup(this.getGroup(ph.getDefaultGroup().getName()));
+ this.setDefaultGroup(getGroup(ph.getDefaultGroup().getName()));
this.removeGroupsChangedFlag();
- this.timeStampGroups = getGroupsFile().lastModified();
+ this.setTimeStampGroups(getGroupsFile().lastModified());
ph = null;
} catch (Exception ex) {
@@ -377,7 +341,7 @@ public class WorldDataHolder {
tempGroup.clone(ph);
}
// setup the default group before loading user data.
- ph.setDefaultGroup(ph.getGroup(this.getDefaultGroup().getName()));
+ ph.setDefaultGroup(ph.getGroup(getDefaultGroup().getName()));
loadUsers(ph, getUsersFile());
// transfer new data
resetUsers();
@@ -385,7 +349,7 @@ public class WorldDataHolder {
tempUser.clone(this);
}
this.removeUsersChangedFlag();
- this.timeStampUsers = getUsersFile().lastModified();
+ this.setTimeStampUsers(getUsersFile().lastModified());
ph = null;
} catch (Exception ex) {
@@ -395,165 +359,39 @@ public class WorldDataHolder {
GroupManagerEventHandler.callEvent(GMSystemEvent.Action.RELOADED);
}
- /**
- * Save by yourself!
- * @deprecated
- */
- @Deprecated
- public void commit() {
- writeGroups(this, getGroupsFile());
- writeUsers(this, getUsersFile());
- }
-
- /**
- * Returns a data holder for the given file
- *
- * @param worldName
- * @param file
- * @return a new WorldDataHolder
- *
- * @throws Exception
- * @deprecated
- */
- @SuppressWarnings({"rawtypes", "unchecked"})
- @Deprecated
- public static WorldDataHolder load(String worldName, File file) throws Exception {
- WorldDataHolder ph = new WorldDataHolder(worldName);
- ph.f = file;
- final Yaml yaml = new Yaml(new SafeConstructor());
- Map<String, Object> rootDataNode;
- if (!file.exists()) {
- throw new Exception("The file which should contain permissions does not exist!\n" + file.getPath());
- }
- FileInputStream rx = new FileInputStream(file);
- try {
- rootDataNode = (Map<String, Object>) yaml.load(new UnicodeReader(rx));
- if (rootDataNode == null) {
- throw new NullPointerException();
- }
- } catch (Exception ex) {
- throw new Exception("The following file couldn't pass on Parser.\n" + file.getPath(), ex);
- } finally {
- rx.close();
- }
- Map<String, List<String>> inheritance = new HashMap<String, List<String>>();
- try {
- Map<String, Object> allGroupsNode = (Map<String, Object>) rootDataNode.get("groups");
- for (String groupKey : allGroupsNode.keySet()) {
- Map<String, Object> thisGroupNode = (Map<String, Object>) allGroupsNode.get(groupKey);
- Group thisGrp = ph.createGroup(groupKey);
- if (thisGrp == null) {
- throw new IllegalArgumentException("I think this group was declared more than once: " + groupKey);
- }
- if (thisGroupNode.get("default") == null) {
- thisGroupNode.put("default", false);
- }
- if ((Boolean.parseBoolean(thisGroupNode.get("default").toString()))) {
- if (ph.getDefaultGroup() != null) {
- GroupManager.logger.warning("The group " + thisGrp.getName() + " is declaring be default where" + ph.getDefaultGroup().getName() + " already was.");
- GroupManager.logger.warning("Overriding first request.");
- }
- ph.setDefaultGroup(thisGrp);
- }
-
- //PERMISSIONS NODE
- if (thisGroupNode.get("permissions") == null) {
- thisGroupNode.put("permissions", new ArrayList<String>());
- }
- if (thisGroupNode.get("permissions") instanceof List) {
- for (Object o : ((List) thisGroupNode.get("permissions"))) {
- thisGrp.addPermission(o.toString());
- }
- } else if (thisGroupNode.get("permissions") instanceof String) {
- thisGrp.addPermission((String) thisGroupNode.get("permissions"));
- } else {
- throw new IllegalArgumentException("Unknown type of permissions node(Should be String or List<String>): " + thisGroupNode.get("permissions").getClass().getName());
- }
-
- //INFO NODE
- Map<String, Object> infoNode = (Map<String, Object>) thisGroupNode.get("info");
- if (infoNode != null) {
- thisGrp.setVariables(infoNode);
- }
-
- //END INFO NODE
-
- Object inheritNode = thisGroupNode.get("inheritance");
- if (inheritNode == null) {
- thisGroupNode.put("inheritance", new ArrayList<String>());
- } else if (inheritNode instanceof List) {
- List<String> groupsInh = (List<String>) inheritNode;
- for (String grp : groupsInh) {
- if (inheritance.get(groupKey) == null) {
- List<String> thisInherits = new ArrayList<String>();
- inheritance.put(groupKey, thisInherits);
- }
- inheritance.get(groupKey).add(grp);
-
- }
- }
- }
- } catch (Exception ex) {
- ex.printStackTrace();
- throw new Exception("Your Permissions config file is invalid. See console for details.");
- }
- if (ph.defaultGroup == null) {
- throw new IllegalArgumentException("There was no Default Group declared.");
- }
- for (String groupKey : inheritance.keySet()) {
- List<String> inheritedList = inheritance.get(groupKey);
- Group thisGroup = ph.getGroup(groupKey);
- for (String inheritedKey : inheritedList) {
- Group inheritedGroup = ph.getGroup(inheritedKey);
- if (thisGroup != null && inheritedGroup != null) {
- thisGroup.addInherits(inheritedGroup);
- }
- }
- }
- // Process USERS
- Map<String, Object> allUsersNode = (Map<String, Object>) rootDataNode.get("users");
- for (String usersKey : allUsersNode.keySet()) {
- Map<String, Object> thisUserNode = (Map<String, Object>) allUsersNode.get(usersKey);
- User thisUser = ph.createUser(usersKey);
- if (thisUser == null) {
- GroupManager.logger.warning("I think this user was declared more than once: " + usersKey);
- continue;
- }
- if (thisUserNode.get("permissions") == null) {
- thisUserNode.put("permissions", new ArrayList<String>());
- }
- if (thisUserNode.get("permissions") instanceof List) {
- for (Object o : ((List) thisUserNode.get("permissions"))) {
- thisUser.addPermission(o.toString());
- }
- } else if (thisUserNode.get("permissions") instanceof String) {
- thisUser.addPermission(thisUserNode.get("permissions").toString());
- }
+ public void loadGroups(File groupsFile) {
+ GroupManager.setLoaded(false);
+ try {
+ setGroupsFile(groupsFile);
+ loadGroups(this, groupsFile);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("The file which should contain groups does not exist!\n" + groupsFile.getPath());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Error access the groups file!\n" + groupsFile.getPath());
+ }
- //USER INFO NODE - BETA
+ GroupManager.setLoaded(true);
+ }
+
+ public void loadUsers(File usersFile) {
- //INFO NODE
- Map<String, Object> infoNode = (Map<String, Object>) thisUserNode.get("info");
- if (infoNode != null) {
- thisUser.setVariables(infoNode);
- }
- //END INFO NODE - BETA
+ GroupManager.setLoaded(false);
+ try {
+ setUsersFile(usersFile);
+ loadUsers(this, usersFile);
+ } catch (FileNotFoundException e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("The file which should contain users does not exist!\n" + usersFile.getPath());
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new IllegalArgumentException("Error access the users file!\n" + usersFile.getPath());
+ }
- if (thisUserNode.get("group") != null) {
- Group hisGroup = ph.getGroup(thisUserNode.get("group").toString());
- if (hisGroup == null) {
- GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName());
- thisUser.setGroup(ph.defaultGroup);
- }
- thisUser.setGroup(hisGroup);
- } else {
- thisUser.setGroup(ph.defaultGroup);
- }
- }
- return ph;
+ GroupManager.setLoaded(true);
}
-
/**
* Returns a NEW data holder containing data read from the files
*
@@ -568,8 +406,8 @@ public class WorldDataHolder {
WorldDataHolder ph = new WorldDataHolder(worldName);
GroupManager.setLoaded(false);
- loadGroups(ph, groupsFile);
- loadUsers(ph, usersFile);
+ if (groupsFile != null) loadGroups(ph, groupsFile);
+ if (usersFile != null) loadUsers(ph, usersFile);
GroupManager.setLoaded(true);
return ph;
@@ -632,7 +470,12 @@ public class WorldDataHolder {
}
if (thisGroupNode.get("permissions") instanceof List) {
for (Object o : ((List) thisGroupNode.get("permissions"))) {
- thisGrp.addPermission(o.toString());
+ try {
+ thisGrp.addPermission(o.toString());
+ } catch (NullPointerException e) {
+ // Ignore this entry as it's null.
+ //throw new IllegalArgumentException("Invalid permission node in group: " + thisGrp.getName() + " in file: " + groupsFile.getPath());
+ }
}
} else if (thisGroupNode.get("permissions") instanceof String) {
thisGrp.addPermission((String) thisGroupNode.get("permissions"));
@@ -673,7 +516,7 @@ public class WorldDataHolder {
// ex.printStackTrace();
// throw new IllegalArgumentException("Your Permissions config file is invalid. See console for details.");
//}
- if (ph.defaultGroup == null) {
+ if (ph.getDefaultGroup() == null) {
throw new IllegalArgumentException("There was no Default Group declared in file: " + groupsFile.getPath());
}
for (String groupKey : inheritance.keySet()) {
@@ -689,7 +532,7 @@ public class WorldDataHolder {
ph.removeGroupsChangedFlag();
// Update the LastModified time.
- ph.groupsFile = groupsFile;
+ ph.setGroupsFile(groupsFile);
ph.setTimeStampGroups(groupsFile.lastModified());
//return ph;
@@ -744,7 +587,12 @@ public class WorldDataHolder {
thisUser.addPermission(o.toString());
}
} else if (thisUserNode.get("permissions") instanceof String) {
- thisUser.addPermission(thisUserNode.get("permissions").toString());
+ try {
+ thisUser.addPermission(thisUserNode.get("permissions").toString());
+ } catch (NullPointerException e) {
+ // Ignore this entry as it's null.
+ //throw new IllegalArgumentException("Invalid permission node for user: " + thisUser.getName() + " in file: " + UserFile.getPath());
+ }
}
//SUBGROUPS LOADING
@@ -788,111 +636,24 @@ public class WorldDataHolder {
Group hisGroup = ph.getGroup(thisUserNode.get("group").toString());
if (hisGroup == null) {
GroupManager.logger.warning("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName() + ": Set to '" + ph.getDefaultGroup().getName() + "' for file: " + usersFile.getPath());
- hisGroup = ph.defaultGroup;
+ hisGroup = ph.getDefaultGroup();
//throw new IllegalArgumentException("There is no group " + thisUserNode.get("group").toString() + ", as stated for player " + thisUser.getName());
}
thisUser.setGroup(hisGroup);
} else {
- thisUser.setGroup(ph.defaultGroup);
+ thisUser.setGroup(ph.getDefaultGroup());
}
}
ph.removeUsersChangedFlag();
// Update the LastModified time.
- ph.usersFile = usersFile;
+ ph.setUsersFile(usersFile);
ph.setTimeStampUsers(usersFile.lastModified());
}
/**
* Write a dataHolder in a specified file
* @param ph
- * @param file
- * @deprecated
- */
- @Deprecated
- public static void write(WorldDataHolder ph, File file) {
- Map<String, Object> root = new HashMap<String, Object>();
-
- Map<String, Object> pluginMap = new HashMap<String, Object>();
- root.put("plugin", pluginMap);
-
- Map<String, Object> permissionsMap = new HashMap<String, Object>();
- pluginMap.put("permissions", permissionsMap);
-
- permissionsMap.put("system", "default");
-
- Map<String, Object> groupsMap = new HashMap<String, Object>();
- root.put("groups", groupsMap);
- for (String groupKey : ph.groups.keySet()) {
- Group group = ph.groups.get(groupKey);
-
- Map<String, Object> aGroupMap = new HashMap<String, Object>();
- groupsMap.put(group.getName(), aGroupMap);
-
- aGroupMap.put("default", group.equals(ph.defaultGroup));
-
- Map<String, Object> infoMap = new HashMap<String, Object>();
- aGroupMap.put("info", infoMap);
-
- for (String infoKey : group.getVariables().getVarKeyList()) {
- infoMap.put(infoKey, group.getVariables().getVarObject(infoKey));
- }
-
- aGroupMap.put("inheritance", group.getInherits());
-
- aGroupMap.put("permissions", group.getPermissionList());
- }
-
- Map<String, Object> usersMap = new HashMap<String, Object>();
- root.put("users", usersMap);
- for (String userKey : ph.users.keySet()) {
- User user = ph.users.get(userKey);
- if ((user.getGroup() == null || user.getGroup().equals(ph.defaultGroup)) && user.getPermissionList().isEmpty()) {
- continue;
- }
-
- Map<String, Object> aUserMap = new HashMap<String, Object>();
- usersMap.put(user.getName(), aUserMap);
-
- if (user.getGroup() == null) {
- aUserMap.put("group", ph.defaultGroup.getName());
- } else {
- aUserMap.put("group", user.getGroup().getName());
- }
- //USER INFO NODE - BETA
- if (user.getVariables().getSize() > 0) {
- Map<String, Object> infoMap = new HashMap<String, Object>();
- aUserMap.put("info", infoMap);
-
- for (String infoKey : user.getVariables().getVarKeyList()) {
- infoMap.put(infoKey, user.getVariables().getVarObject(infoKey));
- }
- }
- //END USER INFO NODE - BETA
-
- aUserMap.put("permissions", user.getPermissionList());
- }
- DumperOptions opt = new DumperOptions();
- opt.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
- final Yaml yaml = new Yaml(opt);
-
- FileWriter tx = null;
- try {
- tx = new FileWriter(file, false);
- tx.write(yaml.dump(root));
- tx.flush();
- } catch (Exception e) {
- } finally {
- try {
- tx.close();
- } catch (IOException ex) {
- }
- }
- }
-
- /**
- * Write a dataHolder in a specified file
- * @param ph
* @param groupsFile
*/
public static void writeGroups(WorldDataHolder ph, File groupsFile) {
@@ -901,16 +662,16 @@ public class WorldDataHolder {
Map<String, Object> groupsMap = new HashMap<String, Object>();
root.put("groups", groupsMap);
- for (String groupKey : ph.groups.keySet()) {
- Group group = ph.groups.get(groupKey);
+ for (String groupKey : ph.getGroups().keySet()) {
+ Group group = ph.getGroups().get(groupKey);
Map<String, Object> aGroupMap = new HashMap<String, Object>();
groupsMap.put(group.getName(), aGroupMap);
- if (ph.defaultGroup == null) {
+ if (ph.getDefaultGroup() == null) {
GroupManager.logger.severe("There is no default group for world: " + ph.getName());
}
- aGroupMap.put("default", group.equals(ph.defaultGroup));
+ aGroupMap.put("default", group.equals(ph.getDefaultGroup()));
Map<String, Object> infoMap = new HashMap<String, Object>();
aGroupMap.put("info", infoMap);
@@ -951,7 +712,7 @@ public class WorldDataHolder {
}
// Update the LastModified time.
- ph.groupsFile = groupsFile;
+ ph.setGroupsFile(groupsFile);
ph.setTimeStampGroups(groupsFile.lastModified());
ph.removeGroupsChangedFlag();
@@ -982,9 +743,9 @@ public class WorldDataHolder {
Map<String, Object> usersMap = new HashMap<String, Object>();
root.put("users", usersMap);
- for (String userKey : ph.users.keySet()) {
- User user = ph.users.get(userKey);
- if ((user.getGroup() == null || user.getGroup().equals(ph.defaultGroup)) && user.getPermissionList().isEmpty() && user.getVariables().isEmpty() && user.isSubGroupsEmpty()) {
+ for (String userKey : ph.getUsers().keySet()) {
+ User user = ph.getUsers().get(userKey);
+ if ((user.getGroup() == null || user.getGroup().equals(ph.getDefaultGroup())) && user.getPermissionList().isEmpty() && user.getVariables().isEmpty() && user.isSubGroupsEmpty()) {
continue;
}
@@ -992,7 +753,7 @@ public class WorldDataHolder {
usersMap.put(user.getName(), aUserMap);
if (user.getGroup() == null) {
- aUserMap.put("group", ph.defaultGroup.getName());
+ aUserMap.put("group", ph.getDefaultGroup().getName());
} else {
aUserMap.put("group", user.getGroup().getName());
}
@@ -1027,7 +788,7 @@ public class WorldDataHolder {
}
// Update the LastModified time.
- ph.usersFile = usersFile;
+ ph.setUsersFile(usersFile);
ph.setTimeStampUsers(usersFile.lastModified());
ph.removeUsersChangedFlag();
@@ -1083,16 +844,23 @@ public class WorldDataHolder {
}
return permissionsHandler;
}
+
+ /**
+ * @param haveUsersChanged the haveUsersChanged to set
+ */
+ public void setUsersChanged(boolean haveUsersChanged) {
+ users.setUsersChanged(haveUsersChanged);
+ }
/**
*
* @return true if any user data has changed
*/
public boolean haveUsersChanged() {
- if (haveUsersChanged) {
+ if (users.HaveUsersChanged()) {
return true;
}
- for (User u : users.values()) {
+ for (User u : users.getUsers().values()) {
if (u.isChanged()) {
return true;
}
@@ -1101,14 +869,21 @@ public class WorldDataHolder {
}
/**
+ * @param setGroupsChanged the haveGroupsChanged to set
+ */
+ public void setGroupsChanged(boolean setGroupsChanged) {
+ groups.setGroupsChanged(setGroupsChanged);
+ }
+
+ /**
*
* @return true if any group data has changed.
*/
public boolean haveGroupsChanged() {
- if (haveGroupsChanged) {
+ if (groups.HaveGroupsChanged()) {
return true;
}
- for (Group g : groups.values()) {
+ for (Group g : groups.getGroups().values()) {
if (g.isChanged()) {
return true;
}
@@ -1120,8 +895,8 @@ public class WorldDataHolder {
*
*/
public void removeUsersChangedFlag() {
- haveUsersChanged = false;
- for (User u : users.values()) {
+ setUsersChanged(false);
+ for (User u : getUsers().values()) {
u.flagAsSaved();
}
}
@@ -1130,8 +905,8 @@ public class WorldDataHolder {
*
*/
public void removeGroupsChangedFlag() {
- haveGroupsChanged = false;
- for (Group g : groups.values()) {
+ setGroupsChanged(false);
+ for (Group g : getGroups().values()) {
g.flagAsSaved();
}
}
@@ -1140,14 +915,28 @@ public class WorldDataHolder {
* @return the usersFile
*/
public File getUsersFile() {
- return usersFile;
+ return users.getUsersFile();
+ }
+
+ /**
+ * @param file the usersFile to set
+ */
+ public void setUsersFile(File file) {
+ users.setUsersFile(file);
}
/**
* @return the groupsFile
*/
public File getGroupsFile() {
- return groupsFile;
+ return groups.getGroupsFile();
+ }
+
+ /**
+ * @param file the groupsFile to set
+ */
+ public void setGroupsFile(File file) {
+ groups.setGroupsFile(file);
}
/**
@@ -1161,60 +950,85 @@ public class WorldDataHolder {
* Resets Groups.
*/
public void resetGroups() {
- this.defaultGroup = null;
- this.groups = new HashMap<String, Group>();
+ //setDefaultGroup(null);
+ groups.setGroups(new HashMap<String, Group>());
}
/**
* Resets Users
*/
public void resetUsers() {
- this.users = new HashMap<String, User>();
+ users.setUsers(new HashMap<String, User>());
}
/**
* @return the groups
*/
public Map<String, Group> getGroups() {
- return groups;
+ return groups.getGroups();
}
/**
* @return the users
*/
public Map<String, User> getUsers() {
+ return users.getUsers();
+ }
+
+ /**
+ * @return the groups
+ */
+ public GroupsDataHolder getGroupsObject() {
+ return groups;
+ }
+ /**
+ * @param groupsDataHolder the GroupsDataHolder to set
+ */
+ public void setGroupsObject(GroupsDataHolder groupsDataHolder) {
+ groups = groupsDataHolder;
+ }
+ /**
+ * @return the users
+ */
+ public UsersDataHolder getUsersObject() {
return users;
}
+ /**
+ * @param usersDataHolder the UsersDataHolder to set
+ */
+ public void setUsersObject(UsersDataHolder usersDataHolder) {
+ users = usersDataHolder;
+ }
/**
* @return the timeStampGroups
*/
public long getTimeStampGroups() {
- return timeStampGroups;
+ return groups.getTimeStampGroups();
}
/**
* @return the timeStampUsers
*/
public long getTimeStampUsers() {
- return timeStampUsers;
+ return users.getTimeStampUsers();
}
/**
* @param timeStampGroups the timeStampGroups to set
*/
protected void setTimeStampGroups(long timeStampGroups) {
- this.timeStampGroups = timeStampGroups;
+ groups.setTimeStampGroups(timeStampGroups);
}
/**
* @param timeStampUsers the timeStampUsers to set
*/
protected void setTimeStampUsers(long timeStampUsers) {
- this.timeStampUsers = timeStampUsers;
+ users.setTimeStampUsers(timeStampUsers);
}
public void setTimeStamps() {
- if (groupsFile != null)
- setTimeStampGroups(groupsFile.lastModified());
- if (usersFile != null)
- setTimeStampUsers(usersFile.lastModified());
+ if (getGroupsFile() != null)
+ setTimeStampGroups(getGroupsFile().lastModified());
+ if (getUsersFile() != null)
+ setTimeStampUsers(getUsersFile().lastModified());
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
index 25eaf8526..1a765c7b4 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/dataholder/worlds/WorldsHolder.java
@@ -6,7 +6,6 @@ package org.anjocaido.groupmanager.dataholder.worlds;
import java.io.File;
import java.io.FileInputStream;
-import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
@@ -22,6 +21,7 @@ import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
import org.anjocaido.groupmanager.utils.Tasks;
import org.bukkit.World;
+import org.bukkit.configuration.MemorySection;
import org.bukkit.entity.Player;
/**
@@ -34,6 +34,7 @@ public class WorldsHolder {
* Map with instances of loaded worlds.
*/
private Map<String, OverloadedWorldHolder> worldsData = new HashMap<String, OverloadedWorldHolder>();
+
/**
* Map of mirrors: <nonExistingWorldName, existingAndLoadedWorldName>
* The key is the mirror.
@@ -41,7 +42,9 @@ public class WorldsHolder {
*
* Mirror shows the same data of mirrored.
*/
- private Map<String, String> mirrors = new HashMap<String, String>();
+ private Map<String, String> mirrorsGroup = new HashMap<String, String>();
+ private Map<String, String> mirrorsUser = new HashMap<String, String>();
+
private OverloadedWorldHolder defaultWorld;
private String serverDefaultWorldName;
private GroupManager plugin;
@@ -85,7 +88,7 @@ public class WorldsHolder {
*/
for (World world: plugin.getServer().getWorlds())
if ((!worldsData.containsKey(world.getName().toLowerCase()))
- && (!mirrors.containsKey(world.getName().toLowerCase())))
+ && ((!mirrorsGroup.containsKey(world.getName().toLowerCase())) || (!mirrorsUser.containsKey(world.getName().toLowerCase()))))
setupWorldFolder(world.getName());
/*
* Loop over all folders within the worlds folder
@@ -97,10 +100,11 @@ public class WorldsHolder {
/*
* don't load any worlds which are already loaded
- * or mirrored worlds that don't need data.
+ * or fully mirrored worlds that don't need data.
*/
if (!worldsData.containsKey(folder.getName().toLowerCase())
- && !mirrors.containsKey(folder.getName().toLowerCase())) {
+ && ((!mirrorsGroup.containsKey(folder.getName().toLowerCase()))
+ || (!mirrorsUser.containsKey(folder.getName().toLowerCase())))) {
loadWorld(folder.getName());
}
@@ -110,7 +114,8 @@ public class WorldsHolder {
@SuppressWarnings("rawtypes")
public void mirrorSetUp() {
- mirrors.clear();
+ mirrorsGroup.clear();
+ mirrorsUser.clear();
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
if (mirrorsMap != null) {
for (String source : mirrorsMap.keySet()) {
@@ -122,16 +127,52 @@ public class WorldsHolder {
if (mirrorsMap.get(source) instanceof ArrayList) {
ArrayList mirrorList = (ArrayList) mirrorsMap.get(source);
+
+ // These worlds fully mirror their parent
for (Object o : mirrorList) {
try {
- mirrors.remove(o.toString().toLowerCase());
+ mirrorsGroup.remove(o.toString().toLowerCase());
+ mirrorsUser.remove(o.toString().toLowerCase());
} catch (Exception e) {
}
- mirrors.put(o.toString().toLowerCase(), getWorldData(source).getName());
+ mirrorsGroup.put(o.toString().toLowerCase(), getWorldData(source).getName());
+ mirrorsUser.put(o.toString().toLowerCase(), getWorldData(source).getName());
}
- } else if (mirrorsMap.get(source) instanceof Object) {
- String aMirror = mirrorsMap.get(source).toString();
- mirrors.put(aMirror.toLowerCase(), getWorldData(source).getName());
+ } else if (mirrorsMap.get(source) instanceof MemorySection) {
+ MemorySection subSection = (MemorySection) mirrorsMap.get(source);
+
+ for (String key : subSection.getKeys(true)) {
+ //System.out.print("Key - " + key);
+
+ if (subSection.get(key) instanceof ArrayList) {
+ ArrayList mirrorList = (ArrayList) subSection.get(key);
+
+ // These worlds have defined mirroring
+ for (Object o : mirrorList) {
+ String type = o.toString().toLowerCase();
+ try {
+ if (type.equals("groups"))
+ mirrorsGroup.remove(key.toLowerCase());
+
+ if (type.equals("users"))
+ mirrorsUser.remove(key.toLowerCase());
+
+ } catch (Exception e) {
+ }
+ if (type.equals("groups"))
+ mirrorsGroup.put(key.toLowerCase(), getWorldData(source).getName());
+
+ if (type.equals("users"))
+ mirrorsUser.put(key.toLowerCase(), getWorldData(source).getName());
+ }
+
+
+
+ } else {
+ throw new IllegalStateException("Unknown mirroring format for " + key);
+ }
+
+ }
}
}
}
@@ -141,16 +182,22 @@ public class WorldsHolder {
*
*/
public void reloadAll() {
+ // Load global groups
+ GroupManager.getGlobalGroups().load();
+
ArrayList<WorldDataHolder> alreadyDone = new ArrayList<WorldDataHolder>();
for (WorldDataHolder w : worldsData.values()) {
if (alreadyDone.contains(w)) {
continue;
}
- w.reload();
+ if (!mirrorsGroup.containsKey(w.getName().toLowerCase()))
+ w.reloadGroups();
+ if (!mirrorsUser.containsKey(w.getName().toLowerCase()))
+ w.reloadUsers();
+
alreadyDone.add(w);
}
- // Load global groups
- GroupManager.getGlobalGroups().load();
+
}
/**
@@ -158,7 +205,10 @@ public class WorldsHolder {
* @param worldName
*/
public void reloadWorld(String worldName) {
- getWorldData(worldName).reload();
+ if (!mirrorsGroup.containsKey(worldName.toLowerCase()))
+ getWorldData(worldName).reloadGroups();
+ if (!mirrorsUser.containsKey(worldName.toLowerCase()))
+ getWorldData(worldName).reloadUsers();
}
/**
@@ -176,6 +226,16 @@ public class WorldsHolder {
ArrayList<WorldDataHolder> alreadyDone = new ArrayList<WorldDataHolder>();
Tasks.removeOldFiles(plugin, plugin.getBackupFolder());
+ // Write Global Groups
+ if (GroupManager.getGlobalGroups().haveGroupsChanged()) {
+ GroupManager.getGlobalGroups().writeGroups(overwrite);
+ } else {
+ if (GroupManager.getGlobalGroups().getTimeStampGroups() < GroupManager.getGlobalGroups().getGlobalGroupsFile().lastModified()) {
+ System.out.print("Newer GlobalGroups file found (Loading changes)!");
+ GroupManager.getGlobalGroups().load();
+ }
+ }
+
for (OverloadedWorldHolder w : worldsData.values()) {
if (alreadyDone.contains(w)) {
continue;
@@ -184,59 +244,52 @@ public class WorldsHolder {
GroupManager.logger.severe("WHAT HAPPENED?");
continue;
}
- if (w.haveGroupsChanged()) {
- if (overwrite || (!overwrite && (w.getTimeStampGroups() >= w.getGroupsFile().lastModified()))) {
- // Backup Groups file
- backupFile(w,true);
-
- WorldDataHolder.writeGroups(w, w.getGroupsFile());
- //w.removeGroupsChangedFlag();
- } else {
- // Newer file found.
- GroupManager.logger.log(Level.WARNING, "Newer Groups file found for " + w.getName() + ", but we have local changes!");
- throw new IllegalStateException("Unable to save unless you issue a '/mansave force'");
- }
- } else {
- //Check for newer file as no local changes.
- if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
- System.out.print("Newer Groups file found (Loading changes)!");
- // Backup Groups file
- backupFile(w,true);
- w.reloadGroups();
- }
- }
- if (w.haveUsersChanged()) {
- if (overwrite || (!overwrite && (w.getTimeStampUsers() >= w.getUsersFile().lastModified()))) {
- // Backup Users file
- backupFile(w,false);
-
- WorldDataHolder.writeUsers(w, w.getUsersFile());
- //w.removeUsersChangedFlag();
- } else {
- // Newer file found.
- GroupManager.logger.log(Level.WARNING, "Newer Users file found for " + w.getName() + ", but we have local changes!");
- throw new IllegalStateException("Unable to save unless you issue a '/mansave force'");
- }
- } else {
- //Check for newer file as no local changes.
- if (w.getTimeStampUsers() < w.getUsersFile().lastModified()) {
- System.out.print("Newer Users file found (Loading changes)!");
- // Backup Users file
- backupFile(w,false);
- w.reloadUsers();
- }
- }
+ if (!mirrorsGroup.containsKey(w.getName().toLowerCase()))
+ if (w.haveGroupsChanged()) {
+ if (overwrite || (!overwrite && (w.getTimeStampGroups() >= w.getGroupsFile().lastModified()))) {
+ // Backup Groups file
+ backupFile(w,true);
+
+ WorldDataHolder.writeGroups(w, w.getGroupsFile());
+ //w.removeGroupsChangedFlag();
+ } else {
+ // Newer file found.
+ GroupManager.logger.log(Level.WARNING, "Newer Groups file found for " + w.getName() + ", but we have local changes!");
+ throw new IllegalStateException("Unable to save unless you issue a '/mansave force'");
+ }
+ } else {
+ //Check for newer file as no local changes.
+ if (w.getTimeStampGroups() < w.getGroupsFile().lastModified()) {
+ System.out.print("Newer Groups file found (Loading changes)!");
+ // Backup Groups file
+ backupFile(w,true);
+ w.reloadGroups();
+ }
+ }
+ if (!mirrorsUser.containsKey(w.getName().toLowerCase()))
+ if (w.haveUsersChanged()) {
+ if (overwrite || (!overwrite && (w.getTimeStampUsers() >= w.getUsersFile().lastModified()))) {
+ // Backup Users file
+ backupFile(w,false);
+
+ WorldDataHolder.writeUsers(w, w.getUsersFile());
+ //w.removeUsersChangedFlag();
+ } else {
+ // Newer file found.
+ GroupManager.logger.log(Level.WARNING, "Newer Users file found for " + w.getName() + ", but we have local changes!");
+ throw new IllegalStateException("Unable to save unless you issue a '/mansave force'");
+ }
+ } else {
+ //Check for newer file as no local changes.
+ if (w.getTimeStampUsers() < w.getUsersFile().lastModified()) {
+ System.out.print("Newer Users file found (Loading changes)!");
+ // Backup Users file
+ backupFile(w,false);
+ w.reloadUsers();
+ }
+ }
alreadyDone.add(w);
}
- // Write Global Groups
- if (GroupManager.getGlobalGroups().haveGroupsChanged()) {
- GroupManager.getGlobalGroups().writeGroups(overwrite);
- } else {
- if (GroupManager.getGlobalGroups().getTimeStampGroups() < GroupManager.getGlobalGroups().getGlobalGroupsFile().lastModified()) {
- System.out.print("Newer GlobalGroups file found (Loading changes)!");
- GroupManager.getGlobalGroups().load();
- }
- }
}
/**
@@ -269,11 +322,12 @@ public class WorldsHolder {
*/
public OverloadedWorldHolder getWorldData(String worldName) {
String worldNameLowered = worldName.toLowerCase();
+ // If a mirror change to the real world to load.
+ if (mirrorsGroup.containsKey(worldNameLowered)) {
+ worldNameLowered = mirrorsGroup.get(worldNameLowered);
+ }
OverloadedWorldHolder data = worldsData.get(worldNameLowered);
- if (mirrors.containsKey(worldNameLowered)) {
- String realOne = mirrors.get(worldNameLowered);
- data = worldsData.get(realOne.toLowerCase());
- }
+
if (data == null) {
GroupManager.logger.finest("Requested world " + worldName + " not found or badly mirrored. Returning default world...");
data = getDefaultWorld();
@@ -282,8 +336,9 @@ public class WorldsHolder {
}
/**
- * Do a matching of playerName, if it s found only one player, do
+ * Do a matching of playerName, if its found only one player, do
* getWorldData(player)
+ *
* @param playerName
* @return null if matching returned no player, or more than one.
*/
@@ -350,60 +405,45 @@ public class WorldsHolder {
}
- public void setupWorldFolder(String worldName) {
- worldsFolder = new File(plugin.getDataFolder(), "worlds");
- if (!worldsFolder.exists()) {
- worldsFolder.mkdirs();
- }
-
- File defaultWorldFolder = new File(worldsFolder, worldName);
- if (!defaultWorldFolder.exists()) {
- defaultWorldFolder.mkdirs();
- }
- if (defaultWorldFolder.exists()) {
- File groupsFile = new File(defaultWorldFolder, "groups.yml");
- File usersFile = new File(defaultWorldFolder, "users.yml");
- File oldDataFile = new File(plugin.getDataFolder(), "data.yml");
- if (!groupsFile.exists() || groupsFile.length() == 0) {
- if (oldDataFile.exists()) {
- try {
- Tasks.copy(oldDataFile, groupsFile);
- } catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
- } else {
- InputStream template = plugin.getResourceAsStream("groups.yml");
- try {
- Tasks.copy(template, groupsFile);
- } catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
- }
- }
- if (!usersFile.exists() || usersFile.length() == 0) {
- if (oldDataFile.exists()) {
- try {
- Tasks.copy(oldDataFile, usersFile);
- } catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
- } else {
- InputStream template = plugin.getResourceAsStream("users.yml");
- try {
- Tasks.copy(template, usersFile);
- } catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- }
- }
- }
- try {
- if (oldDataFile.exists()) {
- oldDataFile.renameTo(new File(plugin.getDataFolder(), "NOT_USED_ANYMORE_data.yml"));
- }
- } catch (Exception ex) {
- }
- }
- }
+ public void setupWorldFolder(String worldName) {
+ worldsFolder = new File(plugin.getDataFolder(), "worlds");
+ if (!worldsFolder.exists()) {
+ worldsFolder.mkdirs();
+ }
+
+ File defaultWorldFolder = new File(worldsFolder, worldName);
+ if ((!defaultWorldFolder.exists()) && ((!mirrorsGroup.containsKey(worldName.toLowerCase()))) || (!mirrorsUser.containsKey(worldName.toLowerCase()))) {
+ defaultWorldFolder.mkdirs();
+ }
+ if (defaultWorldFolder.exists()) {
+ if (!mirrorsGroup.containsKey(worldName.toLowerCase())) {
+ File groupsFile = new File(defaultWorldFolder, "groups.yml");
+ if (!groupsFile.exists() || groupsFile.length() == 0) {
+
+ InputStream template = plugin.getResourceAsStream("groups.yml");
+ try {
+ Tasks.copy(template, groupsFile);
+ } catch (IOException ex) {
+ GroupManager.logger.log(Level.SEVERE, null, ex);
+ }
+ }
+ }
+
+ if (!mirrorsUser.containsKey(worldName.toLowerCase())) {
+ File usersFile = new File(defaultWorldFolder, "users.yml");
+ if (!usersFile.exists() || usersFile.length() == 0) {
+
+ InputStream template = plugin.getResourceAsStream("users.yml");
+ try {
+ Tasks.copy(template, usersFile);
+ } catch (IOException ex) {
+ GroupManager.logger.log(Level.SEVERE, null, ex);
+ }
+
+ }
+ }
+ }
+ }
/**
* Copies the specified world data to another world
@@ -448,16 +488,36 @@ public class WorldsHolder {
GroupManager.logger.finest("Trying to load world " + worldName + "...");
File thisWorldFolder = new File(worldsFolder, worldName);
if (thisWorldFolder.exists() && thisWorldFolder.isDirectory()) {
- File groupsFile = new File(thisWorldFolder, "groups.yml");
- File usersFile = new File(thisWorldFolder, "users.yml");
- if (!groupsFile.exists()) {
+
+ // Setup file handles, if not mirrored
+ File groupsFile = (mirrorsGroup.containsKey(worldName.toLowerCase()))? null : new File(thisWorldFolder, "groups.yml");
+ File usersFile = (mirrorsUser.containsKey(worldName.toLowerCase()))? null : new File(thisWorldFolder, "users.yml");
+
+ if ((groupsFile != null) && (!groupsFile.exists())) {
throw new IllegalArgumentException("Groups file for world '" + worldName + "' doesnt exist: " + groupsFile.getPath());
}
- if (!usersFile.exists()) {
+ if ((usersFile != null) && (!usersFile.exists())) {
throw new IllegalArgumentException("Users file for world '" + worldName + "' doesnt exist: " + usersFile.getPath());
}
- try {
- OverloadedWorldHolder thisWorldData = new OverloadedWorldHolder(WorldDataHolder.load(worldName, groupsFile, usersFile));
+
+ WorldDataHolder tempHolder = new WorldDataHolder(worldName);
+
+ // Map the group object for any mirror
+ if (mirrorsGroup.containsKey(worldName.toLowerCase()))
+ tempHolder.setGroupsObject(this.getWorldData(mirrorsGroup.get(worldName.toLowerCase())).getGroupsObject());
+ else
+ tempHolder.loadGroups(groupsFile);
+
+ // Map the user object for any mirror
+ if (mirrorsUser.containsKey(worldName.toLowerCase()))
+ tempHolder.setUsersObject(this.getWorldData(mirrorsUser.get(worldName.toLowerCase())).getUsersObject());
+ else
+ tempHolder.loadUsers(usersFile);
+
+ OverloadedWorldHolder thisWorldData = new OverloadedWorldHolder(tempHolder);
+
+ // null the object so we don't keep file handles open where we shouldn't
+ tempHolder = null;
// Set the file TimeStamps as it will be default from the initial load.
thisWorldData.setTimeStamps();
@@ -467,13 +527,7 @@ public class WorldsHolder {
worldsData.put(worldName.toLowerCase(), thisWorldData);
return;
}
- } catch (FileNotFoundException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- return;
- } catch (IOException ex) {
- GroupManager.logger.log(Level.SEVERE, null, ex);
- return;
- }
+
//GroupManager.logger.severe("Failed to load world " + worldName + "...");
}
}
@@ -487,7 +541,7 @@ public class WorldsHolder {
* @return true if world is loaded or mirrored. false if not listed
*/
public boolean isInList(String worldName) {
- if (worldsData.containsKey(worldName.toLowerCase()) || mirrors.containsKey(worldName.toLowerCase())) {
+ if (worldsData.containsKey(worldName.toLowerCase()) || mirrorsGroup.containsKey(worldName.toLowerCase())) {
return true;
}
return false;
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
index 856abbc28..0834b3ada 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEvent.java
@@ -1,6 +1,8 @@
package org.anjocaido.groupmanager.events;
+import org.anjocaido.groupmanager.GroupManager;
+import org.bukkit.Bukkit;
import org.bukkit.event.Event;
/**
@@ -13,10 +15,28 @@ public abstract class GroupManagerEvent extends Event {
*
*/
private static final long serialVersionUID = 8790362185329926951L;
-
+
protected GroupManagerEvent(String name) {
super(name);
}
+ /**
+ * Triggers all GroupManager events for other plugins to see.
+ * Schedules events for 1 tick later to allow GM to finish populating super perms.
+ *
+ * @param event
+ */
+ public void schedule(final GroupManagerEvent event) {
+
+ if (Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Bukkit.getPluginManager().getPlugin("GroupManager"), new Runnable() {
+
+ @Override
+ public void run() {
+ Bukkit.getServer().getPluginManager().callEvent(event);
+ }
+ }, 1) == -1)
+ GroupManager.logger.warning("Could not schedule GM Event.");
+ }
+
} \ No newline at end of file
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
index 83cac393d..3c077b6c6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/events/GroupManagerEventHandler.java
@@ -1,11 +1,9 @@
package org.anjocaido.groupmanager.events;
-import org.anjocaido.groupmanager.GroupManager;
import org.anjocaido.groupmanager.data.Group;
import org.anjocaido.groupmanager.data.User;
-
/**
* @author ElgarL
*
@@ -13,13 +11,13 @@ import org.anjocaido.groupmanager.data.User;
public class GroupManagerEventHandler {
protected static void callEvent(GMGroupEvent event) {
- GroupManager.callEvent(event);
+ event.schedule(event);
}
protected static void callEvent(GMUserEvent event) {
- GroupManager.callEvent(event);
+ event.schedule(event);
}
protected static void callEvent(GMSystemEvent event) {
- GroupManager.callEvent(event);
+ event.schedule(event);
}
public static void callEvent(Group group, GMGroupEvent.Action action) {
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
index 6e18bf3f8..167103796 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/AnjoPermissionsHandler.java
@@ -90,13 +90,24 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
/**
* Returns All permissions (including inheritance and sub groups) for the
- * player.
+ * player, including child nodes from Bukkit.
*
* @param userName
* @return List<String> of all players permissions.
*/
@Override
public List<String> getAllPlayersPermissions(String userName) {
+ return getAllPlayersPermissions(userName, true);
+ }
+ /**
+ * Returns All permissions (including inheritance and sub groups) for the
+ * player. With or without Bukkit child nodes.
+ *
+ * @param userName
+ * @return List<String> of all players permissions.
+ */
+ @Override
+ public List<String> getAllPlayersPermissions(String userName, Boolean includeChildren) {
List<String> playerPermArray = new ArrayList<String>();
@@ -104,14 +115,16 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
playerPermArray.add(perm);
- Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
-
- if (children != null) {
- for (String child : children.keySet()) {
- if (children.get(child))
- if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child))) {
- playerPermArray.add(child);
- }
+ if (includeChildren) {
+ Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
+
+ if (children != null) {
+ for (String child : children.keySet()) {
+ if (children.get(child))
+ if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child))) {
+ playerPermArray.add(child);
+ }
+ }
}
}
}
@@ -122,12 +135,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
playerPermArray.add(perm);
- Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
- if (children != null) {
- for (String child : children.keySet()) {
- if (children.get(child))
- if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child)))
- playerPermArray.add(child);
+ if (includeChildren) {
+ Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
+ if (children != null) {
+ for (String child : children.keySet()) {
+ if (children.get(child))
+ if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child)))
+ playerPermArray.add(child);
+ }
}
}
}
@@ -137,13 +152,15 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
if ((!playerPermArray.contains(perm)) && (!playerPermArray.contains("-" + perm))) {
playerPermArray.add(perm);
- Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
- if (children != null) {
- for (String child : children.keySet()) {
- if (children.get(child))
- if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child))) {
- playerPermArray.add(child);
- }
+ if (includeChildren) {
+ Map<String, Boolean> children = GroupManager.BukkitPermissions.getAllChildren(perm, playerPermArray);
+ if (children != null) {
+ for (String child : children.keySet()) {
+ if (children.get(child))
+ if ((!playerPermArray.contains(child)) && (!playerPermArray.contains("-" + child))) {
+ playerPermArray.add(child);
+ }
+ }
}
}
}
@@ -711,12 +728,14 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
PermissionCheckResult resultUser = checkUserOnlyPermission(user, targetPermission);
if (resultUser.resultType != PermissionCheckResult.Type.NOTFOUND) {
+ resultUser.accessLevel = targetPermission;
return resultUser;
}
// IT ONLY CHECKS GROUPS PERMISSIONS IF RESULT FOR USER IS NOT FOUND
PermissionCheckResult resultGroup = checkGroupPermissionWithInheritance(user.getGroup(), targetPermission);
if (resultGroup.resultType != PermissionCheckResult.Type.NOTFOUND) {
+ resultGroup.accessLevel = targetPermission;
return resultGroup;
}
@@ -724,6 +743,7 @@ public class AnjoPermissionsHandler extends PermissionsReaderInterface {
for (Group subGroup : user.subGroupListCopy()) {
PermissionCheckResult resultSubGroup = checkGroupPermissionWithInheritance(subGroup, targetPermission);
if (resultSubGroup.resultType != PermissionCheckResult.Type.NOTFOUND) {
+ resultSubGroup.accessLevel = targetPermission;
return resultSubGroup;
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
index 202e27e3a..91f9a9bd6 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/BukkitPermissions.java
@@ -16,6 +16,7 @@
package org.anjocaido.groupmanager.permissions;
+import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.LinkedList;
@@ -23,9 +24,9 @@ import java.util.List;
import java.util.Map;
import org.anjocaido.groupmanager.GroupManager;
-import org.anjocaido.groupmanager.data.User;
+//import org.anjocaido.groupmanager.data.User;
import org.anjocaido.groupmanager.dataholder.OverloadedWorldHolder;
-import org.anjocaido.groupmanager.utils.PermissionCheckResult;
+//import org.anjocaido.groupmanager.utils.PermissionCheckResult;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
@@ -43,8 +44,7 @@ import org.bukkit.event.server.ServerListener;
import org.bukkit.permissions.Permission;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
-import org.bukkit.permissions.PermissionDefault;
-import org.bukkit.plugin.Plugin;
+//import org.bukkit.permissions.PermissionDefault;
import org.bukkit.plugin.PluginManager;
@@ -52,7 +52,7 @@ import org.bukkit.plugin.PluginManager;
*
* BukkitPermissions overrides to force GM reponses to Superperms
*
- * @author ElgarL, based upon PermissionsEX implementation
+ * @author ElgarL, originally based upon PermissionsEX implementation
*/
public class BukkitPermissions {
@@ -62,13 +62,25 @@ public class BukkitPermissions {
protected boolean dumpAllPermissions = true;
protected boolean dumpMatchedPermissions = true;
public boolean player_join = false;
+
+ private static Field permissions;
+
+ // Setup reflection (Thanks to Codename_B for the reflection source)
+ static {
+ try {
+ permissions = PermissionAttachment.class.getDeclaredField("permissions");
+ permissions.setAccessible(true);
+ } catch (SecurityException e) {
+ e.printStackTrace();
+ } catch (NoSuchFieldException e) {
+ e.printStackTrace();
+ }
+ }
public BukkitPermissions(GroupManager plugin) {
this.plugin = plugin;
-
this.collectPermissions();
this.registerEvents();
-
this.updateAllPlayers();
GroupManager.logger.info("Superperms support enabled.");
@@ -93,50 +105,69 @@ public class BukkitPermissions {
manager.registerEvent(Event.Type.PLUGIN_DISABLE, serverListener, Event.Priority.Normal, plugin);
}
+
public void collectPermissions() {
registeredPermissions.clear();
+ /*
for (Plugin bukkitPlugin : Bukkit.getServer().getPluginManager().getPlugins()) {
for (Permission permission : bukkitPlugin.getDescription().getPermissions())
registeredPermissions.push(permission);
}
+ */
+
+ registeredPermissions = new LinkedList<Permission>(Bukkit.getPluginManager().getPermissions());
+
}
+
public void updatePermissions(Player player) {
this.updatePermissions(player, null);
}
+
+ /**
+ * Push all permissions which are registered with GM for this player, on this world to Bukkit
+ * and make it update for the child nodes.
+ *
+ * @param player
+ * @param world
+ */
public void updatePermissions(Player player, String world) {
if (player == null || !GroupManager.isLoaded()) {
return;
}
- if (!this.attachments.containsKey(player)) {
- this.attachments.put(player, player.addAttachment(plugin));
+ PermissionAttachment attachment;
+ // Find the players current attachment, or add a new one.
+ if (this.attachments.containsKey(player)) {
+ attachment = this.attachments.get(player);
+ } else {
+ attachment = player.addAttachment(plugin);
+ this.attachments.put(player, attachment);;
}
if (world == null) {
world = player.getWorld().getName();
}
- // All permissions registered with Bukkit for this player
- PermissionAttachment attachment = this.attachments.get(player);
-
OverloadedWorldHolder worldData = plugin.getWorldsHolder().getWorldData(world);
+ Boolean value = false;
+ //User user = worldData.getUser(player.getName());
- User user = worldData.getUser(player.getName());
-
+ /*
// clear permissions
for (String permission : attachment.getPermissions().keySet())
attachment.unsetPermission(permission);
-
+ */
+
/*
* find matching permissions
*
* and base bukkit perms if we are set to allow bukkit permissions to
* override.
*/
- Boolean value = false;
-
+
+ /*
for (Permission permission : registeredPermissions) {
PermissionCheckResult result = worldData.getPermissionsHandler().checkFullGMPermission(user, permission.getName(), false);
@@ -163,35 +194,48 @@ public class BukkitPermissions {
if ((value == true) || (result.resultType == PermissionCheckResult.Type.NEGATION)) {
attachment.setPermission(permission, value);
}
- /*
- if ((value == true) || (result.resultType == PermissionCheckResult.Type.NOTFOUND)) {
- // fetch and set all children of this permission node
- Map<String, Boolean> children = permission.getChildren();
- if (children != null) {
- for (String child : children.keySet()) {
- if (children.get(child))
- attachment.setPermission(child, value);
- }
- }
- }*/
-
}
+ */
- // Add any missing permissions for this player (non bukkit plugins and child nodes)
- List<String> playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName());
-
+ // Add all permissions for this player (GM only)
+ // child nodes will be calculated by Bukkit.
+ List<String> playerPermArray = worldData.getPermissionsHandler().getAllPlayersPermissions(player.getName(), false);
+ Map<String, Boolean> newPerms = new HashMap<String, Boolean>();
+
for (String permission : playerPermArray) {
value = true;
if (permission.startsWith("-")) {
permission = permission.substring(1); // cut off -
value = false;
}
-
+ /*
if (!attachment.getPermissions().containsKey(permission)) {
attachment.setPermission(permission, value);
}
+ */
+ newPerms.put(permission, value);
+ }
+
+ //player.recalculatePermissions();
+
+ /**
+ * This is put in place until such a time as Bukkit pull 466 is implemented
+ * https://github.com/Bukkit/Bukkit/pull/466
+ */
+ try { // Codename_B source
+ @SuppressWarnings("unchecked")
+ Map<String, Boolean> orig = (Map<String, Boolean>) permissions.get(attachment);
+ // Clear the map (faster than removing the attachment and recalculating)
+ orig.clear();
+ // Then whack our map into there
+ orig.putAll(newPerms);
+ // That's all folks!
+ attachment.getPermissible().recalculatePermissions();
+ } catch (IllegalArgumentException e) {
+ e.printStackTrace();
+ } catch (IllegalAccessException e) {
+ e.printStackTrace();
}
- player.recalculatePermissions();
}
/**
@@ -245,6 +289,12 @@ public class BukkitPermissions {
return null;
}
+ /**
+ * List all effective permissions for this player.
+ *
+ * @param player
+ * @return List<String> of permissions
+ */
public List<String> listPerms(Player player) {
List<String> perms = new ArrayList<String>();
@@ -266,6 +316,9 @@ public class BukkitPermissions {
return perms;
}
+ /**
+ * force Bukkit to update every OnlinePlayers permissions.
+ */
public void updateAllPlayers() {
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
updatePermissions(player);
@@ -332,7 +385,7 @@ public class BukkitPermissions {
@Override
public void onPluginDisable(PluginDisableEvent event) {
- // collectPermissions();
+ collectPermissions();
// updateAllPlayers();
}
}
diff --git a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java
index c0383c160..cf11bd37f 100644
--- a/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java
+++ b/EssentialsGroupManager/src/org/anjocaido/groupmanager/permissions/PermissionsReaderInterface.java
@@ -234,4 +234,6 @@ public abstract class PermissionsReaderInterface {
//////////////////////////////
public abstract List<String> getAllPlayersPermissions(String userName);
+
+ public abstract List<String> getAllPlayersPermissions(String userName, Boolean includeChildren);
}
diff --git a/EssentialsGroupManager/src/plugin.yml b/EssentialsGroupManager/src/plugin.yml
index 115e92ba2..dc9b4c29c 100644
--- a/EssentialsGroupManager/src/plugin.yml
+++ b/EssentialsGroupManager/src/plugin.yml
@@ -1,11 +1,12 @@
name: GroupManager
-version: "1.7 (Phoenix)"
+version: GMBuildVer (Phoenix)
main: org.anjocaido.groupmanager.GroupManager
website: http://www.anjocaido.info/
description: Provides on-the-fly system for permissions system created by Nijikokun. But all in memory, and with flat-file saving schedule.
authors:
- AnjoCaido
- Gabriel Couto
+ - ElgarL
commands:
manuadd:
description: Move a player to desired group.(Adds to the file if not exists)
diff --git a/EssentialsGroupManager/src/users.yml b/EssentialsGroupManager/src/users.yml
index 28fa79910..72a7b652f 100644
--- a/EssentialsGroupManager/src/users.yml
+++ b/EssentialsGroupManager/src/users.yml
@@ -3,7 +3,7 @@ users:
snowleo:
subgroups: []
permissions: []
- group: Admin
+ group: Builder
KHobbits:
subgroups: []
permissions: []
@@ -11,5 +11,5 @@ users:
ElgarL:
subgroups: []
permissions: []
- group: Owner
+ group: Moderator
diff --git a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
index 117c27a57..1d90384c1 100644
--- a/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
+++ b/EssentialsProtect/src/com/earth2me/essentials/protect/EssentialsProtectBlockListener.java
@@ -59,7 +59,7 @@ public class EssentialsProtectBlockListener extends BlockListener
final Block below = blockPlaced.getRelative(BlockFace.DOWN);
if ((below.getType() == Material.RAILS || below.getType() == Material.POWERED_RAIL || below.getType() == Material.DETECTOR_RAIL)
&& settings.getData().getSignsAndRails().isPreventBlockAboveRails()
- && prot.getStorage().isProtected(below, user.getName()))
+ && isProtected(below, user, settings))
{
event.setCancelled(true);
return;
@@ -72,7 +72,7 @@ public class EssentialsProtectBlockListener extends BlockListener
{
protect.add(blockPlaced);
if (settings.getData().getSignsAndRails().isBlockBelow()
- && !prot.getStorage().isProtected(blockPlaced.getRelative(BlockFace.DOWN), user.getName()))
+ && !isProtected(blockPlaced.getRelative(BlockFace.DOWN), user, settings))
{
protect.add(blockPlaced.getRelative(BlockFace.DOWN));
}
@@ -85,7 +85,7 @@ public class EssentialsProtectBlockListener extends BlockListener
if (settings.getData().getSignsAndRails().isBlockBelow()
&& event.getBlockAgainst().getType() != Material.SIGN_POST
&& event.getBlockAgainst().getType() != Material.WALL_SIGN
- && !prot.getStorage().isProtected(event.getBlockAgainst(), user.getName()))
+ && !isProtected(event.getBlockAgainst(), user, settings))
{
protect.add(event.getBlockAgainst());
}
@@ -321,7 +321,7 @@ public class EssentialsProtectBlockListener extends BlockListener
else
{
- final boolean isProtected = storage.isProtected(block, user.getName());
+ final boolean isProtected = isProtected(block, user, settings);
if (isProtected)
{
event.setCancelled(true);
@@ -483,4 +483,57 @@ public class EssentialsProtectBlockListener extends BlockListener
settings.unlock();
}
}
+
+ private boolean isProtected(final Block block, final IUser user, final ProtectHolder settings)
+ {
+ final Material type = block.getType();
+ if (settings.getData().getSignsAndRails().isProtectSigns())
+ {
+ if (type == Material.WALL_SIGN || type == Material.SIGN_POST)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+
+ final Block up = block.getRelative(BlockFace.UP);
+ if (up != null && up.getType() == Material.SIGN_POST)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ final BlockFace[] directions = new BlockFace[]
+ {
+ BlockFace.NORTH,
+ BlockFace.EAST,
+ BlockFace.SOUTH,
+ BlockFace.WEST
+ };
+ for (BlockFace blockFace : directions)
+ {
+ final Block signblock = block.getRelative(blockFace);
+ if (signblock.getType() == Material.WALL_SIGN)
+ {
+ final org.bukkit.material.Sign signMat = (org.bukkit.material.Sign)signblock.getState().getData();
+ if (signMat != null && signMat.getFacing() == blockFace)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ }
+ }
+
+ }
+ if (settings.getData().getSignsAndRails().isProtectRails()) {
+ if (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL)
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ if (settings.getData().getSignsAndRails().isBlockBelow())
+ {
+ final Block up = block.getRelative(BlockFace.UP);
+ if (up != null && (type == Material.RAILS || type == Material.POWERED_RAIL || type == Material.DETECTOR_RAIL))
+ {
+ return prot.getStorage().isProtected(block, user.getName());
+ }
+ }
+ }
+ return false;
+ }
}
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java
index 036276770..d0383bd4a 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandsetspawn.java
@@ -8,7 +8,7 @@ import com.earth2me.essentials.commands.EssentialsCommand;
public class Commandsetspawn extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final String group = args.length > 0 ? getFinalArg(args, 0) : "default";
((SpawnStorage)module).setSpawn(user.getLocation(), group);
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
index b70a522fb..07532653c 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/Commandspawn.java
@@ -13,7 +13,7 @@ import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
public class Commandspawn extends EssentialsCommand
{
@Override
- public void run(final IUser user, final String[] args) throws Exception
+ public void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
final Trade charge = new Trade(commandName, ess);
charge.isAffordableFor(user);
@@ -34,7 +34,7 @@ public class Commandspawn extends EssentialsCommand
}
@Override
- protected void run(final CommandSender sender, final String[] args) throws Exception
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
diff --git a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java
index 8cbd57c31..2e4b5eaa6 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawn.java
@@ -9,7 +9,6 @@ import java.util.logging.Logger;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
-import org.bukkit.event.Event.Priority;
import org.bukkit.event.Event.Type;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
@@ -38,12 +37,12 @@ public class EssentialsSpawn extends JavaPlugin
spawns = new SpawnStorage(ess);
ess.addReloadListener(spawns);
-
+
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, spawns.getRespawnPriority(), this);
- pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Low, this);
+ pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, spawns.getRespawnPriority(), 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 a345b3f30..08bb4d739 100644
--- a/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
+++ b/EssentialsSpawn/src/com/earth2me/essentials/spawn/EssentialsSpawnPlayerListener.java
@@ -29,13 +29,16 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
public void onPlayerRespawn(final PlayerRespawnEvent event)
{
final IUser user = ess.getUser(event.getPlayer());
-
+
boolean respawnAtHome = false;
- ISettings settings = ess.getSettings();
+ final ISettings settings = ess.getSettings();
settings.acquireReadLock();
- try {
+ try
+ {
respawnAtHome = ess.getSettings().getData().getCommands().getHome().isRespawnAtHome();
- } finally {
+ }
+ finally
+ {
settings.unlock();
}
if (respawnAtHome)
@@ -62,24 +65,15 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
public void onPlayerJoin(final PlayerJoinEvent event)
{
final IUser user = ess.getUser(event.getPlayer());
- user.acquireReadLock();
- try
- {
- if (!user.getData().isNewplayer() || user.getBedSpawnLocation() != null)
- {
- return;
- }
- user.acquireWriteLock();
- user.getData().setNewplayer(false);
- }
- finally
+ if (user.hasPlayedBefore())
{
- user.unlock();
+ return;
}
+
if (spawns.getNewbieSpawn() != null)
{
- ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user));
+ ess.scheduleSyncDelayedTask(new NewPlayerTeleport(user), 1L);
}
if (spawns.getAnnounceNewPlayers())
@@ -103,7 +97,7 @@ public class EssentialsSpawnPlayerListener extends PlayerListener
{
try
{
- Location spawn = spawns.getNewbieSpawn();
+ final Location spawn = spawns.getNewbieSpawn();
if (spawn != null)
{
user.getTeleport().now(spawn, false, TeleportCause.PLUGIN);
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java
index fd3510aa0..4fe9283df 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandsetxmpp.java
@@ -8,7 +8,7 @@ import com.earth2me.essentials.commands.NotEnoughArgumentsException;
public class Commandsetxmpp extends EssentialsCommand
{
@Override
- protected void run(final IUser user, final String[] args) throws NotEnoughArgumentsException
+ protected void run(final IUser user, final String commandLabel, final String[] args) throws NotEnoughArgumentsException
{
if (args.length < 1)
{
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java
index c275e8778..23bd34170 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmpp.java
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Commandxmpp extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws NotEnoughArgumentsException
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException
{
if (args.length < 2)
{
diff --git a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java
index 968058fb3..5da4d8f93 100644
--- a/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java
+++ b/EssentialsXMPP/src/com/earth2me/essentials/xmpp/Commandxmppspy.java
@@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
public class Commandxmppspy extends EssentialsCommand
{
@Override
- protected void run(final CommandSender sender, final String[] args) throws NotEnoughArgumentsException
+ protected void run(final CommandSender sender, final String commandLabel, final String[] args) throws NotEnoughArgumentsException
{
if (args.length < 1)
{
diff --git a/lib/Vault.jar b/lib/Vault.jar
new file mode 100644
index 000000000..96b1625c4
--- /dev/null
+++ b/lib/Vault.jar
Binary files differ