1
0
mirror of https://github.com/essentials/Essentials.git synced 2025-09-25 13:49:12 +02:00

2.9 -> 3.0

Permissions and command fixes
Kit cleanup (needs timestamp work still)
This commit is contained in:
ementalo
2012-05-31 00:40:35 +01:00
parent cea3113df4
commit 03a52cd070
25 changed files with 166 additions and 170 deletions

View File

@@ -4,8 +4,12 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IEssentials; import com.earth2me.essentials.api.IEssentials;
import com.earth2me.essentials.api.IKits; import com.earth2me.essentials.api.IKits;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.settings.Kit; import com.earth2me.essentials.settings.Kit;
import com.earth2me.essentials.storage.AsyncStorageObjectHolder; 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.File;
import java.io.IOException; import java.io.IOException;
import java.util.*; import java.util.*;
@@ -101,4 +105,31 @@ public class Kits extends AsyncStorageObjectHolder<com.earth2me.essentials.setti
{ {
throw new UnsupportedOperationException("Not supported yet."); 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();
}
}
} }

View File

@@ -1,5 +1,6 @@
package com.earth2me.essentials.api; package com.earth2me.essentials.api;
import com.earth2me.essentials.commands.NoChargeException;
import com.earth2me.essentials.settings.Kit; import com.earth2me.essentials.settings.Kit;
import java.util.Collection; import java.util.Collection;
@@ -15,4 +16,6 @@ public interface IKits extends IReload
Collection<String> getList() throws Exception; Collection<String> getList() throws Exception;
boolean isEmpty(); boolean isEmpty();
void checkTime(final IUser user, Kit kit) throws NoChargeException;
} }

View File

@@ -116,5 +116,8 @@ public interface IUser extends Player, IStorageObjectHolder<UserData>, IReload,
void toggleVanished(); void toggleVanished();
void update(final Player base); boolean isInvSee();
void setInvSee(boolean invsee);
} }

View File

@@ -23,36 +23,31 @@ public class Commandessentials extends EssentialsCommand
@Override @Override
public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception public void run(final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{ {
if (args.length == 0) if (args.length == 0) {
{ run_disabled(sender, commandLabel, args);
run_disabled(sender, args);
} }
else if (args[0].equalsIgnoreCase("debug")) else if (args[0].equalsIgnoreCase("debug"))
{ {
run_debug(sender, args); run_debug(sender, commandLabel, args);
} }
else if (args[0].equalsIgnoreCase("nya")) else if (args[0].equalsIgnoreCase("nya"))
{ {
run_nya(sender, args); run_nya(sender, commandLabel, args);
} }
else if (args[0].equalsIgnoreCase("moo")) else if (args[0].equalsIgnoreCase("moo"))
{ {
run_moo(server, sender, commandLabel, args); run_moo(sender, commandLabel, args);
} }
else if (args[0].equalsIgnoreCase("opt-out")) else if (args[0].equalsIgnoreCase("opt-out"))
{ {
run_optout(server, sender, commandLabel, args); run_optout(sender, commandLabel, args);
} }
else { else {
run_reload(server, sender, commandLabel, args); run_reload(sender, commandLabel, args);
}
else
{
run_reload(sender, 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("Essentials " + ess.getDescription().getVersion());
sender.sendMessage("/<command> <reload/debug>"); sender.sendMessage("/<command> <reload/debug>");
@@ -60,8 +55,7 @@ public class Commandessentials extends EssentialsCommand
final StringBuilder disabledCommands = new StringBuilder(); final StringBuilder disabledCommands = new StringBuilder();
for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet()) for (Map.Entry<String, String> entry : ess.getCommandHandler().disabledCommands().entrySet())
{ {
if (disabledCommands.length() > 0) if (disabledCommands.length() > 0) {
{
disabledCommands.append(", "); disabledCommands.append(", ");
} }
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue()); disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
@@ -69,19 +63,19 @@ public class Commandessentials extends EssentialsCommand
sender.sendMessage(disabledCommands.toString()); 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()); ess.getSettings().setDebug(!ess.getSettings().isDebug());
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled")); 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(); ess.reload();
sender.sendMessage(_("essentialsReload", ess.getDescription().getVersion())); 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>(); final Map<String, Byte> noteMap = new HashMap<String, Byte>();
noteMap.put("1F#", (byte)0x0); noteMap.put("1F#", (byte)0x0);
@@ -125,7 +119,7 @@ public class Commandessentials extends EssentialsCommand
if (loc.getBlock().getTypeId() == 0) if (loc.getBlock().getTypeId() == 0)
{ {
noteBlocks.put(player, loc.getBlock()); noteBlocks.put(player, loc.getBlock());
player.sendBlockChange(loc, Material.NOTE_BLOCK, (byte)0); loc.getBlock().setType(Material.NOTE_BLOCK);
} }
} }
taskid = ess.scheduleSyncRepeatingTask(new Runnable() taskid = ess.scheduleSyncRepeatingTask(new Runnable()
@@ -161,7 +155,7 @@ public class Commandessentials extends EssentialsCommand
private void stopTune() private void stopTune()
{ {
ess.getServer().getScheduler().cancelTask(taskid); server.getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values()) for (Block block : noteBlocks.values())
{ {
if (block.getType() == Material.NOTE_BLOCK) if (block.getType() == Material.NOTE_BLOCK)
@@ -172,7 +166,7 @@ public class Commandessentials extends EssentialsCommand
noteBlocks.clear(); 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) if(sender instanceof ConsoleCommandSender)
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } ); sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
@@ -180,7 +174,7 @@ public class Commandessentials extends EssentialsCommand
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } ); 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(); final Metrics metrics = ess.getMetrics();
try try
@@ -197,4 +191,5 @@ public class Commandessentials extends EssentialsCommand
{ {
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage()); sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
} }
}
} }

View File

@@ -1,31 +1,30 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; 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.utils.Util;
import com.earth2me.essentials.craftbukkit.SetExpFix; import com.earth2me.essentials.craftbukkit.SetExpFix;
import org.bukkit.command.CommandSender; import com.earth2me.essentials.permissions.Permissions;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public class Commandexp extends EssentialsCommand public class Commandexp extends EssentialsCommand
{ {
//todo - fix this
@Override @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; Boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(args[1])) for (Player matchPlayer : server.matchPlayer(args[1]))
{ {
User target = ess.getUser(matchPlayer); IUser target = ess.getUser(matchPlayer);
setExp(user, target, args[2], false); setExp(user, target, args[2], false);
foundUser = true; foundUser = true;
} }
@@ -37,14 +36,14 @@ public class Commandexp extends EssentialsCommand
} }
setExp(user, user, args[1], false); 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; Boolean foundUser = false;
for (Player matchPlayer : server.matchPlayer(args[1])) for (Player matchPlayer : server.matchPlayer(args[1]))
{ {
User target = ess.getUser(matchPlayer); IUser target = ess.getUser(matchPlayer);
setExp(user, target, args[2], true); setExp(user, target, args[2], true);
foundUser = true; foundUser = true;
} }
@@ -63,27 +62,27 @@ public class Commandexp extends EssentialsCommand
{ {
search = args[1].trim(); 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); showExp(user, user);
return; return;
} }
for (Player matchPlayer : server.matchPlayer(search)) for (Player matchPlayer : server.matchPlayer(search))
{ {
User target = ess.getUser(matchPlayer); IUser target = ess.getUser(matchPlayer);
showExp(user, target); 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 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)); 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)); 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); Long amount = Long.parseLong(strAmount);
if (give) if (give)

View File

@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.Permissions;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; 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 protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
{ {
//todo permissions //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]); flyOtherPlayers(server, user, args[0]);
return; return;

View File

@@ -15,7 +15,7 @@ public class Commandgetpos extends EssentialsCommand
{ {
//todo permissions //todo permissions
final IUser otherUser = getPlayer(args, 0); 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()); outputPosition(user, otherUser.getLocation(), user.getLocation());
return; return;

View File

@@ -4,7 +4,9 @@ import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.economy.Trade; import com.earth2me.essentials.economy.Trade;
import com.earth2me.essentials.permissions.Permissions; import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.permissions.WorldPermissions;
import com.earth2me.essentials.utils.Util; import com.earth2me.essentials.utils.Util;
import de.bananaco.permissions.worlds.WorldPermissionSet;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Location; import org.bukkit.Location;
@@ -97,7 +99,7 @@ public class Commandhome extends EssentialsCommand
throw new NotEnoughArgumentsException(); throw new NotEnoughArgumentsException();
} }
if (user.getWorld() != loc.getWorld() && ess.getSettings().getData().getGeneral().isWorldHomePermissions() 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())); throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
} }

View File

@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.ItemPermissions; import com.earth2me.essentials.permissions.ItemPermissions;
import com.earth2me.essentials.permissions.Permissions;
import java.util.Locale; import java.util.Locale;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@@ -36,7 +37,7 @@ public class Commanditem extends EssentialsCommand
{ {
stack.setAmount(ess.getSettings().getData().getGeneral().getDefaultStacksize()); 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()); stack.setAmount(ess.getSettings().getData().getGeneral().getOversizedStacksize());
} }

View File

@@ -1,16 +1,16 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; 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.api.IUser;
import com.earth2me.essentials.economy.Trade;
import com.earth2me.essentials.permissions.KitPermissions; import com.earth2me.essentials.permissions.KitPermissions;
import com.earth2me.essentials.settings.Kit; import com.earth2me.essentials.settings.Kit;
import com.earth2me.essentials.utils.Util;
import java.util.Collection; import java.util.Collection;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
public class Commandkit extends EssentialsCommand public class Commandkit extends EssentialsCommand
@@ -38,16 +38,18 @@ public class Commandkit extends EssentialsCommand
} }
throw new NoChargeException(); 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 IUser userTo = getPlayer(args, 1, true);
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)); final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
giveKit(userTo, user, kitName); giveKit(userTo, user, kitName);
} }
else else
{ {
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH)); final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
giveKit(user, user, kitName); giveKit(user, user, kitName);
} }
} }
@@ -59,53 +61,47 @@ public class Commandkit extends EssentialsCommand
listKits(sender); listKits(sender);
throw new NoChargeException(); throw new NoChargeException();
} }
else
{ {
final IUser userTo = getPlayer(args, 1, true); final IUser userTo = getPlayer(args, 1, true);
final String kitName = args[0].toLowerCase(Locale.ENGLISH); final String kitName = args[0].toLowerCase(Locale.ENGLISH);
final Kit kit = ess.getKits().getKit(kitName); final Kit kit = ess.getKits().getKit(kitName);
final List<String> items = Kit.getItems(userTo, kit); ess.getKits().sendKit(userTo, kit);
Kit.expandItems(ess,userTo,items);
//TODO: Check kit delay
sender.sendMessage(_("kitGive", kitName)); sender.sendMessage(_("kitGive", kitName));
} }
} }
private void listKits(CommandSender sender) throws Exception private void listKits(CommandSender sender) throws Exception
{ {
final String kitList = Kit.listKits(ess, null); Collection<String> kitList = ess.getKits().getList();
if (kitList.length() > 0) if (kitList.isEmpty())
{ {
sender.sendMessage(_("kits", kitList)); sender.sendMessage(_("kits", kitList));
} }
else else
{ {
sender.sendMessage(_("noKits")); sender.sendMessage(_("kits", Util.joinList(kitList)));
} }
} }
private void giveKit(IUser userTo, IUser userFrom, String kitName) throws Exception private void giveKit(IUser userTo, IUser userFrom, String kitName) throws Exception
{ {
final Map<String, Object> kit = ess.getSettings().getKit(kitName); if (!KitPermissions.getPermission(kitName).isAuthorized(userFrom))
if (!userFrom.isAuthorized("essentials.kit." + kitName))
{ {
throw new Exception(_("noKitPermission", "essentials.kit." + kitName)); 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); final Trade charge = new Trade("kit-" + kitName, ess);
charge.isAffordableFor(userFrom); charge.isAffordableFor(userFrom);
Kit.expandItems(ess, userTo, items); ess.getKits().sendKit(userTo, kit);
charge.charge(userFrom); charge.charge(userFrom);
userTo.sendMessage(_("kitGive", kitName)); userTo.sendMessage(_("kitGive", kitName));
} }
} }

View File

@@ -1,17 +1,10 @@
package com.earth2me.essentials.commands; 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.api.IUser;
import com.earth2me.essentials.bukkit.Mob;
import java.util.Random; import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
>>>>>>> 3.0
import org.bukkit.entity.Ocelot; import org.bukkit.entity.Ocelot;
@@ -19,18 +12,8 @@ public class Commandkittycannon extends EssentialsCommand
{ {
private static Random random = new Random(); 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 @Override
protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception protected void run(final IUser user, final String commandLabel, final String[] args) throws Exception
>>>>>>> 3.0
{ {
final Mob cat = Mob.OCELOT; final Mob cat = Mob.OCELOT;
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation()); final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());

View File

@@ -1,11 +1,10 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.ISettings; import com.earth2me.essentials.api.ISettings;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.Permissions; import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.Util; import com.earth2me.essentials.utils.Util;
import java.util.*; import java.util.*;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@@ -77,7 +76,7 @@ public class Commandlist extends EssentialsCommand
for (String group : groups) for (String group : groups)
{ {
final StringBuilder groupString = new StringBuilder(); final StringBuilder groupString = new StringBuilder();
groupString.append(_("listGroupTag",Util.replaceColor(group))); groupString.append(_("listGroupTag",Util.replaceFormat(group)));
final List<IUser> users = sort.get(group); final List<IUser> users = sort.get(group);
Collections.sort(users); Collections.sort(users);
boolean first = true; boolean first = true;

View File

@@ -24,7 +24,7 @@ public class Commandme extends EssentialsCommand
String message = getFinalArg(args, 0); String message = getFinalArg(args, 0);
if (Permissions.CHAT_COLOR.isAuthorized(user)) if (Permissions.CHAT_COLOR.isAuthorized(user))
{ {
message = Util.replaceColor(message); message = Util.replaceFormat(message);
} }
else { else {
message = Util.stripColor(message); message = Util.stripColor(message);

View File

@@ -34,7 +34,7 @@ public class Commandmsg extends EssentialsCommand
} }
if (Permissions.MSG_COLOR.isAuthorized(user)) if (Permissions.MSG_COLOR.isAuthorized(user))
{ {
message = Util.replaceColor(message); message = Util.replaceFormat(message);
} }
else else
{ {

View File

@@ -1,8 +1,8 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.utils.Util;
public class Commandping extends EssentialsCommand public class Commandping extends EssentialsCommand
@@ -16,7 +16,7 @@ public class Commandping extends EssentialsCommand
} }
else else
{ {
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0))); user.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
} }
} }
} }

View File

@@ -1,9 +1,9 @@
package com.earth2me.essentials.commands; package com.earth2me.essentials.commands;
import static com.earth2me.essentials.I18n._; import static com.earth2me.essentials.I18n._;
import com.earth2me.essentials.utils.Util;
import com.earth2me.essentials.api.IUser; import com.earth2me.essentials.api.IUser;
import com.earth2me.essentials.permissions.Permissions; import com.earth2me.essentials.permissions.Permissions;
import com.earth2me.essentials.utils.Util;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Locale; import java.util.Locale;
@@ -97,9 +97,9 @@ public class Commandpowertool extends EssentialsCommand
user.sendMessage(_("powerToolRemoveAll", itemName)); user.sendMessage(_("powerToolRemoveAll", itemName));
} }
if (!user.arePowerToolsEnabled()) if (!user.getData().isPowerToolsEnabled())
{ {
user.setPowerToolsEnabled(true); user.getData().setPowerToolsEnabled(true);
user.sendMessage(_("powerToolsEnabled")); user.sendMessage(_("powerToolsEnabled"));
} }
user.acquireWriteLock(); user.acquireWriteLock();

View File

@@ -58,10 +58,10 @@ public class Commandseen extends EssentialsCommand
} }
if (extra) if (extra)
{ {
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress())); sender.sendMessage(_("whoisIPAddress", player.getData().getIpAddress()));
final Location loc = player.getLastLocation(); final Location loc = player.getData().getLastLocation();
if (loc != null) { 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()));
} }
} }
} }

View File

@@ -37,32 +37,6 @@ public class Commandsetworth extends EssentialsCommand
@Override @Override
public void run(final CommandSender sender, final String commandLabel, 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();
}
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) if (args.length < 2)
{ {

View File

@@ -27,7 +27,7 @@ public class Commandtpahere extends EssentialsCommand
@Cleanup @Cleanup
ISettings settings = ess.getSettings(); ISettings settings = ess.getSettings();
settings.acquireReadLock(); 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)) && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{ {
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName())); throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));

View File

@@ -43,7 +43,7 @@ public class Commandtpall extends EssentialsCommand
ISettings settings = ess.getSettings(); ISettings settings = ess.getSettings();
settings.acquireReadLock(); 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)) && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{ {
continue; continue;

View File

@@ -24,7 +24,7 @@ public class Commandtphere extends EssentialsCommand
@Cleanup @Cleanup
ISettings settings = ess.getSettings(); ISettings settings = ess.getSettings();
settings.acquireReadLock(); 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)) && !WorldPermissions.getPermission(user.getWorld().getName()).isAuthorized(user))
{ {
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName())); throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));

View File

@@ -53,7 +53,7 @@ public class Commandtpo extends EssentialsCommand
throw new NoSuchFieldException(_("playerNotFound")); throw new NoSuchFieldException(_("playerNotFound"));
} }
settings.acquireReadLock(); 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)) && !WorldPermissions.getPermission(toPlayer.getWorld().getName()).isAuthorized(user))
{ {
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName())); throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));

View File

@@ -24,7 +24,13 @@ public enum Permissions implements IPermission
CLEARINVENTORY_OTHERS, CLEARINVENTORY_OTHERS,
DELHOME_OTHERS, DELHOME_OTHERS,
ECO_LOAN(PermissionDefault.FALSE), ECO_LOAN(PermissionDefault.FALSE),
EXP_GIVE,
EXP_GIVE_OTHERS,
EXP_SET,
EXP_SET_OTHERS,
EXP_OTHERS,
FEED_OTHERS, FEED_OTHERS,
FLY_OTHERS,
GAMEMODE_OTHERS, GAMEMODE_OTHERS,
GEOIP_HIDE(PermissionDefault.FALSE), GEOIP_HIDE(PermissionDefault.FALSE),
GEOIP_SHOW(PermissionDefault.TRUE), GEOIP_SHOW(PermissionDefault.TRUE),

View File

@@ -82,6 +82,8 @@ public class General implements StorageObject
}) })
private boolean worldTeleportPermissions = false; private boolean worldTeleportPermissions = false;
private boolean worldHomePermissions = false;
@Comment("Prevent creatures spawning") @Comment("Prevent creatures spawning")
private Map<String, Boolean> creatureSpawn = new HashMap<String, Boolean>(); private Map<String, Boolean> creatureSpawn = new HashMap<String, Boolean>();

View File

@@ -88,6 +88,7 @@ public class User extends UserBase implements IUser
@Getter @Getter
private transient boolean vanished; private transient boolean vanished;
@Getter @Getter
@Setter
private boolean invSee = false; private boolean invSee = false;
private transient Location afkPosition; private transient Location afkPosition;
private static final Logger logger = Bukkit.getLogger(); private static final Logger logger = Bukkit.getLogger();