summaryrefslogtreecommitdiffstats
path: root/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
diff options
context:
space:
mode:
Diffstat (limited to 'Essentials/src/com/earth2me/essentials/commands/Commandmail.java')
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmail.java45
1 files changed, 21 insertions, 24 deletions
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
index 7a2dad1b1..db39d1c01 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmail.java
@@ -1,8 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.User;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.utils.Util;
+import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.List;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@@ -11,19 +12,14 @@ import org.bukkit.entity.Player;
public class Commandmail extends EssentialsCommand
{
- public Commandmail()
- {
- super("mail");
- }
-
//TODO: Tidy this up
@Override
- public void run(final Server server, final User user, final String commandLabel, 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]))
{
- final List<String> mail = user.getMails();
- if (mail.isEmpty())
+ final List<String> mail = user.getData().getMails();
+ if (mail == null || mail.isEmpty())
{
user.sendMessage(_("noMail"));
throw new NoChargeException();
@@ -37,26 +33,26 @@ public class Commandmail extends EssentialsCommand
}
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
- if (!user.isAuthorized("essentials.mail.send"))
+ if (!Permissions.MAIL_SEND.isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.mail.send"));
}
Player player = server.getPlayer(args[1]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[1]);
+ u = ess.getUser(args[1]);
}
if (u == null)
{
throw new Exception(_("playerNeverOnServer", args[1]));
}
- if (!u.isIgnoredPlayer(user.getName()))
+ if (!u.isIgnoringPlayer(user.getName()))
{
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
u.addMail(user.getName() + ": " + mail);
@@ -66,7 +62,7 @@ public class Commandmail extends EssentialsCommand
}
if (args.length > 1 && "sendall".equalsIgnoreCase(args[0]))
{
- if (!user.isAuthorized("essentials.mail.sendall"))
+ if (!Permissions.MAIL_SENDALL.isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.mail.sendall"));
}
@@ -76,7 +72,8 @@ public class Commandmail extends EssentialsCommand
}
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
- user.setMails(null);
+ user.acquireWriteLock();
+ user.getData().setMails(null);
user.sendMessage(_("mailCleared"));
return;
}
@@ -84,27 +81,27 @@ public class Commandmail extends EssentialsCommand
}
@Override
- protected void run(Server server, CommandSender sender, String commandLabel, 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]))
{
- throw new Exception(_("onlyPlayers", commandLabel + " read"));
+ throw new Exception(_("onlyPlayers", commandName + " read"));
}
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
{
- throw new Exception(_("onlyPlayers", commandLabel + " clear"));
+ throw new Exception(_("onlyPlayers", commandName + " clear"));
}
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
{
Player player = server.getPlayer(args[1]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[1]);
+ u = ess.getUser(args[1]);
}
if (u == null)
{
@@ -122,14 +119,14 @@ public class Commandmail extends EssentialsCommand
{
//allow sending from console without "send" argument, since it's the only thing the console can do
Player player = server.getPlayer(args[0]);
- User u;
+ IUser u;
if (player != null)
{
u = ess.getUser(player);
}
else
{
- u = ess.getOfflineUser(args[0]);
+ u = ess.getUser(args[0]);
}
if (u == null)
{
@@ -157,7 +154,7 @@ public class Commandmail extends EssentialsCommand
{
for (String username : ess.getUserMap().getAllUniqueUsers())
{
- User user = ess.getUserMap().getUser(username);
+ IUser user = ess.getUserMap().getUser(username);
if (user != null)
{
user.addMail(message);