summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Essentials/src/com/earth2me/essentials/Kits.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/api/IKits.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/api/IUser.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandessentials.java121
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandexp.java31
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandfly.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandhome.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commanditem.java3
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkit.java36
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java23
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandlist.java5
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandme.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandmsg.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandping.java4
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandseen.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java28
-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/Commandtphere.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/commands/Commandtpo.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/permissions/Permissions.java6
-rw-r--r--Essentials/src/com/earth2me/essentials/settings/General.java2
-rw-r--r--Essentials/src/com/earth2me/essentials/user/User.java1
25 files changed, 164 insertions, 168 deletions
diff --git a/Essentials/src/com/earth2me/essentials/Kits.java b/Essentials/src/com/earth2me/essentials/Kits.java
index a9fd1fa2f..74d2a73e5 100644
--- a/Essentials/src/com/earth2me/essentials/Kits.java
+++ b/Essentials/src/com/earth2me/essentials/Kits.java
@@ -4,8 +4,12 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IKits;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.settings.Kit;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
+import com.earth2me.essentials.user.UserData;
+import com.earth2me.essentials.user.UserData.TimestampType;
+import com.earth2me.essentials.utils.DateUtil;
import java.io.File;
import java.io.IOException;
import java.util.*;
@@ -101,4 +105,31 @@ public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.setti
{
throw new UnsupportedOperationException("Not supported yet.");
}
+
+ public void checkTime(final IUser user, Kit kit) throws NoChargeException
+ {
+ final double delay = kit.getDelay();
+ final Calendar c = new GregorianCalendar();
+ c.add(Calendar.SECOND, -(int)delay);
+ c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
+
+ final long mintime = c.getTimeInMillis();
+
+ //todo multiple kit times
+ final Long lastTime = user.getTimestamp(TimestampType.KIT);
+ if (lastTime == null || lastTime < mintime)
+ {
+ final Calendar now = new GregorianCalendar();
+ user.setTimestamp(TimestampType.KIT, now.getTimeInMillis());
+ }
+ else
+ {
+ final Calendar future = new GregorianCalendar();
+ future.setTimeInMillis(lastTime);
+ future.add(Calendar.SECOND, (int)delay);
+ future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
+ user.sendMessage(_("kitTimed", DateUtil.formatDateDiff(future.getTimeInMillis())));
+ throw new NoChargeException();
+ }
+ }
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IKits.java b/Essentials/src/com/earth2me/essentials/api/IKits.java
index 85ca4cdea..33d0de153 100644
--- a/Essentials/src/com/earth2me/essentials/api/IKits.java
+++ b/Essentials/src/com/earth2me/essentials/api/IKits.java
@@ -1,5 +1,6 @@
package com.earth2me.essentials.api;
+import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.settings.Kit;
import java.util.Collection;
@@ -15,4 +16,6 @@ public interface IKits extends IReload
Collection<String> getList() throws Exception;
boolean isEmpty();
+
+ void checkTime(final IUser user, Kit kit) throws NoChargeException;
}
diff --git a/Essentials/src/com/earth2me/essentials/api/IUser.java b/Essentials/src/com/earth2me/essentials/api/IUser.java
index a1d49f250..c5177162c 100644
--- a/Essentials/src/com/earth2me/essentials/api/IUser.java
+++ b/Essentials/src/com/earth2me/essentials/api/IUser.java
@@ -116,5 +116,8 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload,
void toggleVanished();
- void update(final Player base);
+ boolean isInvSee();
+
+ void setInvSee(boolean invsee);
+
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
index 72aa66e99..84e439e6d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandessentials.java
@@ -19,40 +19,35 @@ public class Commandessentials extends EssentialsCommand
{
private transient int taskid;
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
-
+
@Override
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
- if (args.length == 0)
- {
- run_disabled(sender, args);
+ if (args.length == 0) {
+ run_disabled(sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("debug"))
{
- run_debug(sender, args);
+ run_debug(sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("nya"))
{
- run_nya(sender, args);
+ run_nya(sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("moo"))
{
- run_moo(server, sender, commandLabel, args);
+ run_moo(sender, commandLabel, args);
}
else if (args[0].equalsIgnoreCase("opt-out"))
{
- run_optout(server, sender, commandLabel, args);
+ run_optout(sender, commandLabel, args);
}
else {
- run_reload(server, sender, commandLabel, args);
- }
- else
- {
- run_reload(sender, args);
+ run_reload(sender, commandLabel, args);
}
}
- private void run_disabled(final CommandSender sender, final String[] args) throws Exception
+ private void run_disabled(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
sender.sendMessage("/<command> <reload/debug>");
@@ -60,8 +55,7 @@ public class Commandessentials extends EssentialsCommand
final StringBuilder disabledCommands = new StringBuilder();
for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet())
{
- if (disabledCommands.length() > 0)
- {
+ if (disabledCommands.length() > 0) {
disabledCommands.append(", ");
}
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
@@ -69,19 +63,19 @@ public class Commandessentials extends EssentialsCommand
sender.sendMessage(disabledCommands.toString());
}
- private void run_debug(final CommandSender sender, final String[] args) throws Exception
+ private void run_debug(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.getSettings().setDebug(!ess.getSettings().isDebug());
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
}
- private void run_reload(final CommandSender sender, final String[] args) throws Exception
+ private void run_reload(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
ess.reload();
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion()));
}
- private void run_nya(final CommandSender sender, final String[] args) throws Exception
+ private void run_nya(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0);
@@ -108,60 +102,60 @@ public class Commandessentials extends EssentialsCommand
noteMap.put("2D#", (byte)(0x9 + 0xC));
noteMap.put("2E", (byte)(0xA + 0xC));
noteMap.put("2F", (byte)(0xB + 0xC));
- if (!noteBlocks.isEmpty())
- {
- return;
- }
- final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2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1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1A#,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
- final String[] tune = tuneStr.split(",");
- for (Player player : server.getOnlinePlayers())
- {
- final Location loc = player.getLocation();
- loc.add(0, 3, 0);
- while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
+ if (!noteBlocks.isEmpty())
{
- loc.add(0, 1, 0);
+ return;
}
- if (loc.getBlock().getTypeId() == 0)
- {
- noteBlocks.put(player, loc.getBlock());
- player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0);
- }
- }
- taskid = ess.scheduleSyncRepeatingTask(new Runnable()
- {
- int i = 0;
-
- @Override
- public void run()
+ final String tuneStr = "1D#,1E,2F#,,2A#,1E,1D#,1E,2F#,2B,2D#,2E,2D#,2A#,2B,,2F#,,1D#,1E,2F#,2B,2C#,2A#,2B,2C#,2E,2D#,2E,2C#,,2F#,,2G#,,1D,1D#,,1C#,1D,1C#,1B,,1B,,1C#,,1D,,1D,1C#,1B,1C#,1D#,2F#,2G#,1D#,2F#,1C#,1D#,1B,1C#,1B,1D#,,2F#,,2G#,1D#,2F#,1C#,1D#,1B,1D,1D#,1D,1C#,1B,1C#,1D,,1B,1C#,1D#,2F#,1C#,1D,1C#,1B,1C#,,1B,,1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1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,1F#,1E,1D#,1C#,1B,,,,1F#,1B,,1F#,1G#,1B,,1F#,1G#,1B,1B,1C#,1D#,1B,1F#,1G#,1F#,1B,,1B,1A#,1B,1F#,1G#,1B,1E,1D#,1E,2F#,1B,,1B,,";
+ final String[] tune = tuneStr.split(",");
+ for (Player player : server.getOnlinePlayers())
{
- final String note = tune[i];
- i++;
- if (i >= tune.length)
+ final Location loc = player.getLocation();
+ loc.add(0, 3, 0);
+ while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
{
- Commandessentials.this.stopTune();
+ loc.add(0, 1, 0);
}
- if (note.isEmpty())
+ if (loc.getBlock().getTypeId() == 0)
{
- return;
+ noteBlocks.put(player, loc.getBlock());
+ loc.getBlock().setType(Material.NOTE_BLOCK);
}
- Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
- for (Player onlinePlayer : server.getOnlinePlayers())
+ }
+ taskid = ess.scheduleSyncRepeatingTask(new Runnable()
+ {
+ int i = 0;
+
+ @Override
+ public void run()
{
- final Block block = noteBlocks.get(onlinePlayer);
- if (block == null || block.getType() != Material.NOTE_BLOCK)
+ final String note = tune[i];
+ i++;
+ if (i >= tune.length)
+ {
+ Commandessentials.this.stopTune();
+ }
+ if (note.isEmpty())
+ {
+ return;
+ }
+ Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
+ for (Player onlinePlayer : server.getOnlinePlayers())
{
- continue;
+ final Block block = noteBlocks.get(onlinePlayer);
+ if (block == null || block.getType() != Material.NOTE_BLOCK)
+ {
+ continue;
+ }
+ onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
}
- onlinePlayer.playNote(block.getLocation(), (byte)0, noteMap.get(note));
}
- }
- }, 20, 2);
+ }, 20, 2);
}
private void stopTune()
{
- ess.getServer().getScheduler().cancelTask(taskid);
+ server.getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values())
{
if (block.getType() == Material.NOTE_BLOCK)
@@ -171,16 +165,16 @@ public class Commandessentials extends EssentialsCommand
}
noteBlocks.clear();
}
-
- private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
+
+ private void run_moo(final CommandSender sender, final String command, final String args[])
{
if(sender instanceof ConsoleCommandSender)
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
else
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
}
-
- private void run_optout(final Server server, final CommandSender sender, final String command, final String args[])
+
+ private void run_optout(final CommandSender sender, final String command, final String args[])
{
final Metrics metrics = ess.getMetrics();
try
@@ -197,4 +191,5 @@ public class Commandessentials extends EssentialsCommand
{
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
}
-}
+ }
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
index d0306d76f..687335f0d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandexp.java
@@ -1,31 +1,30 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.user.User;
+import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix;
-import org.bukkit.command.CommandSender;
+import com.earth2me.essentials.permissions.Permissions;
import org.bukkit.entity.Player;
public class Commandexp extends EssentialsCommand
{
- //todo - fix this
@Override
- public void run(final CommandSender sender, 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 == 0 && sender instanceof Player)
+ if (args.length == 0)
{
- showExp((User)sender, (User)sender);
+ showExp(user, user);
}
- else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
+ else if (args[0].equalsIgnoreCase("set") && Permissions.EXP_SET.isAuthorized(user))
{
- if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
+ if (args.length == 3 && Permissions.EXP_SET_OTHERS.isAuthorized(user))
{
Boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(args[1]))
{
- User target = ess.getUser(matchPlayer);
+ IUser target = ess.getUser(matchPlayer);
setExp(user, target, args[2], false);
foundUser = true;
}
@@ -37,14 +36,14 @@ public class Commandexp extends EssentialsCommand
}
setExp(user, user, args[1], false);
}
- else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
+ else if (args[0].equalsIgnoreCase("give") && Permissions.EXP_GIVE.isAuthorized(user))
{
- if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
+ if (args.length == 3 && Permissions.EXP_GIVE_OTHERS.isAuthorized(user))
{
Boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(args[1]))
{
- User target = ess.getUser(matchPlayer);
+ IUser target = ess.getUser(matchPlayer);
setExp(user, target, args[2], true);
foundUser = true;
}
@@ -63,27 +62,27 @@ public class Commandexp extends EssentialsCommand
{
search = args[1].trim();
}
- if (search.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
+ if (search.equalsIgnoreCase("show") || !Permissions.EXP_OTHERS.isAuthorized(user))
{
showExp(user, user);
return;
}
for (Player matchPlayer : server.matchPlayer(search))
{
- User target = ess.getUser(matchPlayer);
+ IUser target = ess.getUser(matchPlayer);
showExp(user, target);
}
}
}
- private void showExp(final User user, final User target)
+ private void showExp(final IUser user, final IUser target)
{
final int totalExp = SetExpFix.getTotalExperience(target);
final int expLeft = (int)Util.roundDouble(((((3.5 * target.getLevel()) + 6.7) - (totalExp - ((1.75 * (target.getLevel() * target.getLevel())) + (5.00 * target.getLevel())))) + 1));
user.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), expLeft));
}
- private void setExp(final User user, final User target, final String strAmount, final boolean give)
+ private void setExp(final IUser user, final IUser target, final String strAmount, final boolean give)
{
Long amount = Long.parseLong(strAmount);
if (give)
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java b/Essentials/src/com/earth2me/essentials/commands/Commandfly.java
index 46ae31a16..d785823cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandfly.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandfly.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.permissions.Permissions;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -24,7 +25,7 @@ public class Commandfly extends EssentialsCommand
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{
//todo permissions
- if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
+ if (args.length > 0 && args[0].trim().length() > 2 && Permissions.FLY_OTHERS.isAuthorized(user))
{
flyOtherPlayers(server, user, args[0]);
return;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
index 3ffce7595..c31c76d3c 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandgetpos.java
@@ -15,7 +15,7 @@ public class Commandgetpos extends EssentialsCommand
{
//todo permissions
final IUser otherUser = getPlayer(args, 0);
- if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
+ if (!otherUser.isHidden() || Permissions.LIST_HIDDEN.isAuthorized(user))
{
outputPosition(user, otherUser.getLocation(), user.getLocation());
return;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
index 645e8fd8b..cb3220479 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandhome.java
@@ -4,7 +4,9 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.economy.Trade;
import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.permissions.WorldPermissions;
import com.earth2me.essentials.utils.Util;
+import de.bananaco.permissions.worlds.WorldPermissionSet;
import java.util.List;
import java.util.Locale;
import org.bukkit.Location;
@@ -97,7 +99,7 @@ public class Commandhome extends EssentialsCommand
throw new NotEnoughArgumentsException();
}
if (user.getWorld() != loc.getWorld() && ess.getSettings().getData().getGeneral().isWorldHomePermissions()
- && !user.isAuthorized("essentials.world." + loc.getWorld().getName()))
+ && !WorldPermissions.getPermission(loc.getWorld().getName()).isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
index bf955fbb5..0dae772cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commanditem.java
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.ItemPermissions;
+import com.earth2me.essentials.permissions.Permissions;
import java.util.Locale;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
@@ -36,7 +37,7 @@ public class Commanditem extends EssentialsCommand
{
stack.setAmount(ess.getSettings().getData().getGeneral().getDefaultStacksize());
}
- else if (ess.getSettings().getData().getGeneral().getOversizedStacksize()> 0 && user.isAuthorized("essentials.oversizedstacks"))
+ else if (ess.getSettings().getData().getGeneral().getOversizedStacksize()> 0 && Permissions.OVERSIZEDSTACKS.isAuthorized(user))
{
stack.setAmount(ess.getSettings().getData().getGeneral().getOversizedStacksize());
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
index 2d71302b7..a6c1183ad 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkit.java
@@ -1,16 +1,16 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.economy.Trade;
-import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.economy.Trade;
import com.earth2me.essentials.permissions.KitPermissions;
import com.earth2me.essentials.settings.Kit;
+import com.earth2me.essentials.utils.Util;
import java.util.Collection;
import java.util.List;
import java.util.Locale;
-import java.util.Map;
import org.bukkit.command.CommandSender;
+import org.bukkit.inventory.ItemStack;
public class Commandkit extends EssentialsCommand
@@ -38,16 +38,18 @@ public class Commandkit extends EssentialsCommand
}
throw new NoChargeException();
}
- else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
+ else if (args.length > 1 && KitPermissions.getPermission("others").isAuthorized(user))
{
final IUser userTo = getPlayer(args, 1, true);
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
giveKit(userTo, user, kitName);
+
}
else
{
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
giveKit(user, user, kitName);
+
}
}
@@ -59,53 +61,47 @@ public class Commandkit extends EssentialsCommand
listKits(sender);
throw new NoChargeException();
}
- else
{
final IUser userTo = getPlayer(args, 1, true);
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Kit kit = ess.getKits().getKit(kitName);
- final List<String> items = Kit.getItems(userTo, kit);
- Kit.expandItems(ess,userTo,items);
-
-
-
- //TODO: Check kit delay
+ ess.getKits().sendKit(userTo, kit);
sender.sendMessage(_("kitGive", kitName));
}
}
private void listKits(CommandSender sender) throws Exception
{
- final String kitList = Kit.listKits(ess, null);
- if (kitList.length() > 0)
+ Collection<String> kitList = ess.getKits().getList();
+ if (kitList.isEmpty())
{
sender.sendMessage(_("kits", kitList));
}
else
{
- sender.sendMessage(_("noKits"));
+ sender.sendMessage(_("kits", Util.joinList(kitList)));
}
}
private void giveKit(IUser userTo, IUser userFrom, String kitName) throws Exception
{
- final Map<String, Object> kit = ess.getSettings().getKit(kitName);
-
- if (!userFrom.isAuthorized("essentials.kit." + kitName))
+ if (!KitPermissions.getPermission(kitName).isAuthorized(userFrom))
{
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
}
+ final Kit kit = ess.getKits().getKit(kitName);
+
- final List<String> items = Kit.getItems(userTo, kit);
- Kit.checkTime(userFrom, kitName, kit);
+ ess.getKits().checkTime(userFrom, kit);
final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(userFrom);
- Kit.expandItems(ess, userTo, items);
+ ess.getKits().sendKit(userTo, kit);
charge.charge(userFrom);
userTo.sendMessage(_("kitGive", kitName));
}
}
+
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java b/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
index 602f324ad..99a6aa0f3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandkittycannon.java
@@ -1,17 +1,10 @@
package com.earth2me.essentials.commands;
-<<<<<<< HEAD
-import com.earth2me.essentials.Mob;
-import com.earth2me.essentials.User;
-import java.util.Random;
-import org.bukkit.Location;
-import org.bukkit.Server;
-=======
-import com.earth2me.essentials.bukkit.Mob;
+
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.bukkit.Mob;
import java.util.Random;
import org.bukkit.Location;
->>>>>>> 3.0
import org.bukkit.entity.Ocelot;
@@ -19,18 +12,8 @@ public class Commandkittycannon extends EssentialsCommand
{
private static Random random = new Random();
-<<<<<<< HEAD
- public Commandkittycannon()
- {
- super("kittycannon");
- }
-
- @Override
- protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
-=======
@Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
->>>>>>> 3.0
{
final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
@@ -53,4 +36,4 @@ public class Commandkittycannon extends EssentialsCommand
}
}, 20);
}
-}
+} \ No newline at end of file
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
index 0a433ad7e..db8ec5aea 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandlist.java
@@ -1,11 +1,10 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.Permissions;
-import com.earth2me.essentials.Util;
+import com.earth2me.essentials.utils.Util;
import java.util.*;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@@ -77,7 +76,7 @@ public class Commandlist extends EssentialsCommand
for (String group : groups)
{
final StringBuilder groupString = new StringBuilder();
- groupString.append(_("listGroupTag",Util.replaceColor(group)));
+ groupString.append(_("listGroupTag",Util.replaceFormat(group)));
final List<IUser> users = sort.get(group);
Collections.sort(users);
boolean first = true;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandme.java b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
index 8477c98bc..c420195cc 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandme.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandme.java
@@ -24,7 +24,7 @@ public class Commandme extends EssentialsCommand
String message = getFinalArg(args, 0);
if (Permissions.CHAT_COLOR.isAuthorized(user))
{
- message = Util.replaceColor(message);
+ message = Util.replaceFormat(message);
}
else {
message = Util.stripColor(message);
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
index 8cc683e55..b28346ae1 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandmsg.java
@@ -34,7 +34,7 @@ public class Commandmsg extends EssentialsCommand
}
if (Permissions.MSG_COLOR.isAuthorized(user))
{
- message = Util.replaceColor(message);
+ message = Util.replaceFormat(message);
}
else
{
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandping.java b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
index 5da879907..8c253e183 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandping.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandping.java
@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser;
+import com.earth2me.essentials.utils.Util;
public class Commandping extends EssentialsCommand
@@ -16,7 +16,7 @@ public class Commandping extends EssentialsCommand
}
else
{
- sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
+ user.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
index 9f0cf006a..1f5a6912f 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandpowertool.java
@@ -1,9 +1,9 @@
package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._;
-import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.Permissions;
+import com.earth2me.essentials.utils.Util;
import java.util.ArrayList;
import java.util.List;
import java.util.Locale;
@@ -97,9 +97,9 @@ public class Commandpowertool extends EssentialsCommand
user.sendMessage(_("powerToolRemoveAll", itemName));
}
- if (!user.arePowerToolsEnabled())
+ if (!user.getData().isPowerToolsEnabled())
{
- user.setPowerToolsEnabled(true);
+ user.getData().setPowerToolsEnabled(true);
user.sendMessage(_("powerToolsEnabled"));
}
user.acquireWriteLock();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
index fd20419ff..d9f456a0d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandseen.java
@@ -58,10 +58,10 @@ public class Commandseen extends EssentialsCommand
}
if (extra)
{
- sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
- final Location loc = player.getLastLocation();
+ sender.sendMessage(_("whoisIPAddress", player.getData().getIpAddress()));
+ final Location loc = player.getData().getLastLocation();
if (loc != null) {
- sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
+ sender.sendMessage(_("whoisLocation", loc.getWorldName(), loc.getX(), loc.getY(), loc.getZ()));
}
}
}
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
index e42c11651..8bb06e48d 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandsetworth.java
@@ -33,37 +33,11 @@ public class Commandsetworth extends EssentialsCommand
ess.getWorth().setPrice(stack, Double.parseDouble(price));
user.sendMessage(_("worthSet"));
- }
+ }
@Override
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
- if (args.length < 1)
- {
- throw new NotEnoughArgumentsException();
- }
-
- ItemStack stack;
- String price;
-
- if (args.length == 1)
- {
- stack = user.getInventory().getItemInHand();
- price = args[0];
- }
- else
- {
- stack = ess.getItemDb().get(args[0]);
- price = args[1];
- }
-
- ess.getWorth().setPrice(stack, Double.parseDouble(price));
- user.sendMessage(_("worthSet"));
- }
-
- @Override
- public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
- {
if (args.length < 2)
{
throw new NotEnoughArgumentsException();
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
index c483f256b..3de6c0ba8 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java
@@ -27,7 +27,7 @@ public class Commandtpahere extends EssentialsCommand
@Cleanup
ISettings settings = ess.getSettings();
settings.acquireReadLock();
- if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions()
+ if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
index a34ce13bd..e9f7419c3 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpall.java
@@ -43,7 +43,7 @@ public class Commandtpall extends EssentialsCommand
ISettings settings = ess.getSettings();
settings.acquireReadLock();
- if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions()
+ if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{
continue;
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
index d5449c9e5..1954b0874 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtphere.java
@@ -24,7 +24,7 @@ public class Commandtphere extends EssentialsCommand
@Cleanup
ISettings settings = ess.getSettings();
settings.acquireReadLock();
- if (user.getWorld() != player.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions()
+ if (user.getWorld() != player.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
index 0dc54b8d7..006812e48 100644
--- a/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
+++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpo.java
@@ -53,7 +53,7 @@ public class Commandtpo extends EssentialsCommand
throw new NoSuchFieldException(_("playerNotFound"));
}
settings.acquireReadLock();
- if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().getData().getGeneral().isWorldTeleportPermissions()
+ if (target.getWorld() != toPlayer.getWorld() && settings.getData().getGeneral().isWorldTeleportPermissions()
&& !WorldPermissions.getPermission(toPlayer.getWorld().getName()).isAuthorized(user))
{
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));
diff --git a/Essentials/src/com/earth2me/essentials/permissions/Permissions.java b/Essentials/src/com/earth2me/essentials/permissions/Permissions.java
index e832fbc8d..aa6bfa583 100644
--- a/Essentials/src/com/earth2me/essentials/permissions/Permissions.java
+++ b/Essentials/src/com/earth2me/essentials/permissions/Permissions.java
@@ -24,7 +24,13 @@ public enum Permissions implements IPermission
CLEARINVENTORY_OTHERS,
DELHOME_OTHERS,
ECO_LOAN(PermissionDefault.FALSE),
+ EXP_GIVE,
+ EXP_GIVE_OTHERS,
+ EXP_SET,
+ EXP_SET_OTHERS,
+ EXP_OTHERS,
FEED_OTHERS,
+ FLY_OTHERS,
GAMEMODE_OTHERS,
GEOIP_HIDE(PermissionDefault.FALSE),
GEOIP_SHOW(PermissionDefault.TRUE),
diff --git a/Essentials/src/com/earth2me/essentials/settings/General.java b/Essentials/src/com/earth2me/essentials/settings/General.java
index 033a6ce31..f1b827675 100644
--- a/Essentials/src/com/earth2me/essentials/settings/General.java
+++ b/Essentials/src/com/earth2me/essentials/settings/General.java
@@ -82,6 +82,8 @@ public class General implements StorageObject
})
private boolean worldTeleportPermissions = false;
+ private boolean worldHomePermissions = false;
+
@Comment("Prevent creatures spawning")
private Map<String, Boolean> creatureSpawn = new HashMap<String, Boolean>();
diff --git a/Essentials/src/com/earth2me/essentials/user/User.java b/Essentials/src/com/earth2me/essentials/user/User.java
index 1fa972441..5c9015237 100644
--- a/Essentials/src/com/earth2me/essentials/user/User.java
+++ b/Essentials/src/com/earth2me/essentials/user/User.java
@@ -88,6 +88,7 @@ public class User extends UserBase implements IUser
@Getter
private transient boolean vanished;
@Getter
+ @Setter
private boolean invSee = false;
private transient Location afkPosition;
private static final Logger logger = Bukkit.getLogger();