Merge branch 'master' into groupmanager

This commit is contained in:
snowleo 2011-10-11 12:51:53 +02:00
commit 5395b6f73a
38 changed files with 655 additions and 112 deletions

View File

@ -5,6 +5,7 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
@ -12,7 +13,7 @@ import org.bukkit.craftbukkit.CraftServer;
public class Backup implements Runnable
{
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient final CraftServer server;
private transient final Server server;
private transient final IEssentials ess;
private transient boolean running = false;
private transient int taskId = -1;
@ -21,7 +22,7 @@ public class Backup implements Runnable
public Backup(final IEssentials ess)
{
this.ess = ess;
server = (CraftServer)ess.getServer();
server = ess.getServer();
if (server.getOnlinePlayers().length > 0)
{
startTask();
@ -60,7 +61,7 @@ public class Backup implements Runnable
return;
}
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
final CommandSender cs = server.getServer().console;
final CommandSender cs = server.getConsoleSender();
server.dispatchCommand(cs, "save-all");
server.dispatchCommand(cs, "save-off");

View File

@ -2,33 +2,35 @@ package com.earth2me.essentials;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.CraftServer;
public final class Console implements IReplyTo {
public final class Console implements IReplyTo
{
private static Console instance = new Console();
private CommandSender replyTo;
public final static String NAME = "Console";
private Console() {
}
public static CommandSender getCommandSender(Server server) throws Exception {
if (! (server instanceof CraftServer)) {
throw new Exception(Util.i18n("invalidServer"));
}
return ((CraftServer)server).getServer().console;
private Console()
{
}
public void setReplyTo(CommandSender user) {
public static CommandSender getCommandSender(Server server) throws Exception
{
return server.getConsoleSender();
}
public void setReplyTo(CommandSender user)
{
replyTo = user;
}
public CommandSender getReplyTo() {
public CommandSender getReplyTo()
{
return replyTo;
}
public static Console getConsoleReplyTo() {
public static Console getConsoleReplyTo()
{
return instance;
}
}

View File

@ -164,6 +164,7 @@ public class Essentials extends JavaPlugin implements IEssentials
pm.registerEvent(Type.PLAYER_EGG_THROW, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
pm.registerEvent(Type.PLAYER_BED_ENTER, playerListener, Priority.Lowest, this);
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);

View File

@ -9,6 +9,7 @@ import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.entity.EntityListener;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.entity.PlayerDeathEvent;
import org.bukkit.inventory.ItemStack;
@ -69,24 +70,29 @@ public class EssentialsEntityListener extends EntityListener
}
@Override
public void onEntityDeath(EntityDeathEvent event)
public void onEntityDeath(final EntityDeathEvent event)
{
if (event.getEntity() instanceof Player)
if (event instanceof PlayerDeathEvent)
{
User user = ess.getUser(event.getEntity());
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
final User user = ess.getUser(pdevent.getEntity());
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
{
user.setLastLocation();
user.sendMessage(Util.i18n("backAfterDeath"));
}
if (!ess.getSettings().areDeathMessagesEnabled())
{
pdevent.setDeathMessage("");
}
}
}
@Override
public void onFoodLevelChange(FoodLevelChangeEvent event)
{
{
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
{
{
//TODO: Remove the following line, when we're happy to remove backwards compatability with 1185.
event.setFoodLevel(20);
event.setCancelled(true);

View File

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.block.Action;
import org.bukkit.event.player.PlayerAnimationEvent;
import org.bukkit.event.player.PlayerAnimationType;
import org.bukkit.event.player.PlayerBedEnterEvent;
import org.bukkit.event.player.PlayerBucketEmptyEvent;
import org.bukkit.event.player.PlayerChatEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
@ -94,9 +95,16 @@ public class EssentialsPlayerListener extends PlayerListener
final Location from = event.getFrom();
final Location to = event.getTo().clone();
to.setX(from.getX());
to.setY(from.getBlock().getTypeId() == 0 ? from.getY() - 1 : from.getY());
to.setY(from.getY());
to.setZ(from.getZ());
event.setTo(to);
try
{
event.setTo(Util.getSafeDestination(to));
}
catch (Exception ex)
{
event.setTo(to);
}
return;
}
@ -380,4 +388,16 @@ public class EssentialsPlayerListener extends PlayerListener
user.updateActivity(true);
}
}
@Override
public void onPlayerBedEnter(PlayerBedEnterEvent event)
{
if (event.isCancelled()) {
return;
}
if (event.getPlayer().isSleepingIgnored()) {
event.setCancelled(true);
event.getPlayer().sendMessage("You can't go to bed, your sleep is ignored.");
}
}
}

View File

@ -0,0 +1,190 @@
package com.earth2me.essentials;
import java.util.HashMap;
import org.bukkit.Material;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
public class FakeInventory implements Inventory
{
ItemStack[] items;
public FakeInventory(ItemStack[] items)
{
this.items = new ItemStack[items.length];
for (int i = 0; i < items.length; i++)
{
if (items[i] == null)
{
continue;
}
this.items[i] = new ItemStack(items[i].getTypeId(), items[i].getAmount(), items[i].getDurability());
}
}
@Override
public int getSize()
{
return items.length;
}
@Override
public String getName()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack getItem(int i)
{
return items[i];
}
@Override
public void setItem(int i, ItemStack is)
{
items[i] = is;
}
@Override
public HashMap<Integer, ItemStack> addItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ItemStack> removeItem(ItemStack... iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public ItemStack[] getContents()
{
return items;
}
@Override
public void setContents(ItemStack[] iss)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(int i, int i1)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(Material mtrl, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public boolean contains(ItemStack is, int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public HashMap<Integer, ? extends ItemStack> all(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int first(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int firstEmpty()
{
for (int i = 0; i < items.length; i++)
{
if (items[i] == null || items[i].getTypeId() == 0) {
return i;
}
}
return -1;
}
@Override
public void remove(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(Material mtrl)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void remove(ItemStack is)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void clear(int i)
{
items[i] = null;
}
@Override
public void clear()
{
for (int i = 0; i < items.length; i++)
{
items[i] = null;
}
}
}

View File

@ -132,4 +132,6 @@ public interface ISettings extends IConf
long getAutoAfkKick();
boolean getFreezeAfkPlayers();
boolean areDeathMessagesEnabled();
}

View File

@ -64,6 +64,20 @@ public final class InventoryWorkaround
return -1;
}
public static boolean addAllItems(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Inventory fake = new FakeInventory(cinventory.getContents());
if (addItem(fake, forceDurability, items).isEmpty())
{
addItem(cinventory, forceDurability, items);
return true;
}
else
{
return false;
}
}
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
{
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
@ -106,7 +120,7 @@ public final class InventoryWorkaround
{
continue;
}
while (true)
{
// Do we already have a stack of it?

View File

@ -3,6 +3,7 @@ package com.earth2me.essentials;
import java.net.InetSocketAddress;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import org.bukkit.Achievement;
@ -725,4 +726,22 @@ public class OfflinePlayer implements Player
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public int getTicksLived()
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void setTicksLived(int i)
{
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public Map<String, Object> serialize()
{
throw new UnsupportedOperationException("Not supported yet.");
}
}

View File

@ -16,15 +16,6 @@ public class PlayerExtension extends PlayerWrapper
super(base);
this.ess = ess;
}
public float getCorrectedYaw()
{
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
if (angle < 0) {
angle += 360.0f;
}
return angle;
}
public void showInventory(IInventory inventory)
{

View File

@ -755,5 +755,23 @@ public class PlayerWrapper implements Player
{
return base.getPlayerListName();
}
@Override
public int getTicksLived()
{
return base.getTicksLived();
}
@Override
public void setTicksLived(int i)
{
base.setTicksLived(i);
}
@Override
public Map<String, Object> serialize()
{
return base.serialize();
}
}

View File

@ -523,4 +523,10 @@ public class Settings implements ISettings
{
return config.getBoolean("freeze-afk-players", false);
}
@Override
public boolean areDeathMessagesEnabled()
{
return config.getBoolean("death-messages", true);
}
}

View File

@ -18,22 +18,22 @@ public class Trade
private final transient Double money;
private final transient ItemStack itemStack;
private final transient IEssentials ess;
public Trade(final String command, final IEssentials ess)
{
this(command, null, null, ess);
}
public Trade(final double money, final IEssentials ess)
{
this(null, money, null, ess);
}
public Trade(final ItemStack items, final IEssentials ess)
{
this(null, null, items, ess);
}
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
{
this.command = command;
@ -41,7 +41,7 @@ public class Trade
this.itemStack = item;
this.ess = ess;
}
public void isAffordableFor(final IUser user) throws ChargeException
{
final double mon = user.getMoney();
@ -52,13 +52,13 @@ public class Trade
{
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
if (getItemStack() != null
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
{
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
}
if (command != null && !command.isEmpty()
&& !user.isAuthorized("essentials.nocommandcost.all")
&& !user.isAuthorized("essentials.nocommandcost." + command)
@ -69,24 +69,38 @@ public class Trade
throw new ChargeException(Util.i18n("notEnoughMoney"));
}
}
public void pay(final IUser user)
{
pay(user, true);
}
public boolean pay(final IUser user, final boolean dropItems)
{
boolean success = true;
if (getMoney() != null && getMoney() > 0)
{
user.giveMoney(getMoney());
}
if (getItemStack() != null)
{
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
for (ItemStack itemStack : leftOver.values())
if (dropItems)
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
for (ItemStack itemStack : leftOver.values())
{
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
}
}
else
{
success = InventoryWorkaround.addAllItems(user.getInventory(), true, getItemStack());
}
user.updateInventory();
}
return success;
}
public void charge(final IUser user) throws ChargeException
{
if (getMoney() != null)
@ -120,18 +134,18 @@ public class Trade
user.takeMoney(cost);
}
}
public Double getMoney()
{
return money;
}
public ItemStack getItemStack()
{
return itemStack;
}
private static FileWriter fw = null;
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
{
if (!ess.getSettings().isEcoLogEnabled())
@ -225,10 +239,11 @@ public class Trade
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
}
}
public static void closeLog()
{
if (fw != null) {
if (fw != null)
{
try
{
fw.close();

View File

@ -21,6 +21,7 @@ public final class Economy
}
private static final Logger logger = Logger.getLogger("Minecraft");
private static IEssentials ess;
private static final String noCallBeforeLoad = "Essentials API is called before Essentials is loaded.";
/**
* @param aEss the ess to set
@ -66,6 +67,10 @@ public final class Economy
private static User getUserByName(String name)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
User user;
Player player = ess.getServer().getPlayer(name);
if (player != null)
@ -176,6 +181,10 @@ public final class Economy
*/
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
setMoney(name, ess.getSettings().getStartingBalance());
}
@ -231,6 +240,10 @@ public final class Economy
*/
public static String format(double amount)
{
if (ess == null)
{
throw new RuntimeException(noCallBeforeLoad);
}
return Util.formatCurrency(amount, ess);
}

View File

@ -1,5 +1,6 @@
package com.earth2me.essentials.commands;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
@ -13,14 +14,24 @@ public class Commandbanip extends EssentialsCommand
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
final User u = ess.getUser(args[0]);
if (u == null)
{
ess.getServer().banIP(args[0]);
sender.sendMessage(Util.i18n("banIpAddress"));
}
else
{
ess.getServer().banIP(u.getAddress().getAddress().getHostAddress());
sender.sendMessage(Util.i18n("banIpAddress"));
}
}
}

View File

@ -15,7 +15,7 @@ public class Commandcompass extends EssentialsCommand
@Override
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
{
int r = (int)user.getCorrectedYaw();
int r = (int)user.getLocation().getYaw();
String dir;
if (r < 23) dir = "N";
else if (r < 68) dir = "NE";

View File

@ -56,7 +56,6 @@ public class Commandessentials extends EssentialsCommand
}
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,,1C#,,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,,1B,,1B,,1F#,1G#,1B,,1F#,1G#,1B,1C#,1D#,1B,1E,1D#,1E,2F#,1B,,1B,,1F#,1G#,1B,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,,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,,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();
@ -91,7 +90,7 @@ public class Commandessentials extends EssentialsCommand
for (Player player : server.getOnlinePlayers())
{
Block block = noteBlocks.get(player);
if (block == null)
if (block == null || block.getType() != Material.NOTE_BLOCK)
{
continue;
}
@ -110,7 +109,10 @@ public class Commandessentials extends EssentialsCommand
ess.getScheduler().cancelTask(taskid);
for (Block block : noteBlocks.values())
{
block.setType(Material.AIR);
if (block.getType() == Material.NOTE_BLOCK)
{
block.setType(Material.AIR);
}
}
noteBlocks.clear();
}

View File

@ -19,7 +19,7 @@ public class Commandgetpos extends EssentialsCommand
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+East <-> -West)");
user.sendMessage("§7Yaw: " + user.getCorrectedYaw() + " (Rotation)");
user.sendMessage("§7Yaw: " + coords.getYaw() + " (Rotation)");
user.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
}
}

View File

@ -4,6 +4,7 @@ import com.earth2me.essentials.Util;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.event.entity.EntityDamageEvent;
public class Commandkill extends EssentialsCommand
@ -23,6 +24,13 @@ public class Commandkill extends EssentialsCommand
for (Player p : server.matchPlayer(args[0]))
{
final EntityDamageEvent ede = new EntityDamageEvent(p, sender instanceof Player && ((Player)sender).getName().equals(p.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
server.getPluginManager().callEvent(ede);
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
{
continue;
}
p.setHealth(0);
sender.sendMessage(Util.format("kill", p.getDisplayName()));
}

View File

@ -30,6 +30,10 @@ public class Commandrepair extends EssentialsCommand
if (args[0].equalsIgnoreCase("hand"))
{
final ItemStack item = user.getItemInHand();
if (item == null)
{
throw new Exception(Util.i18n("repairInvalidType"));
}
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
@ -84,6 +88,10 @@ public class Commandrepair extends EssentialsCommand
{
for (ItemStack item : items)
{
if (item == null)
{
continue;
}
final String itemName = item.getType().toString().toLowerCase();
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
try

View File

@ -90,6 +90,23 @@ public interface Method
*/
public boolean hasBankAccount(String bank, String name);
/**
* Forces an account creation
*
* @param name Account name
* @return <code>boolean</code>
*/
public boolean createAccount(String name);
/**
* Forces an account creation
*
* @param name Account name
* @param balance Initial account balance
* @return <code>boolean</code>
*/
public boolean createAccount(String name, Double balance);
/**
* Returns a <code>MethodAccount</code> class for an account <code>name</code>.
*

View File

@ -2,6 +2,7 @@ package com.earth2me.essentials.register.payment;
import java.util.HashSet;
import java.util.Set;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
@ -168,7 +169,7 @@ public class Methods
}
plugin = manager.getPlugin(name);
if (plugin == null)
if (plugin == null || !plugin.isEnabled())
{
continue;
}

View File

@ -71,6 +71,29 @@ public class BOSE6 implements Method
|| this.BOSEconomy.isBankMember(bank, name);
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
this.BOSEconomy.registerPlayer(name);
return true;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))

View File

@ -70,6 +70,29 @@ public class BOSE7 implements Method
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
this.BOSEconomy.registerPlayer(name);
return true;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
this.BOSEconomy.registerPlayer(name);
this.BOSEconomy.setPlayerMoney(name, balance, false);
return true;
}
public MethodAccount getAccount(String name)
{
if (!hasAccount(name))

View File

@ -64,6 +64,18 @@ public class MCUR implements Method
return false;
}
public boolean createAccount(String name)
{
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0);
return true;
}
public boolean createAccount(String name, Double balance)
{
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance);
return true;
}
public MethodAccount getAccount(String name)
{
return new MCurrencyAccount(name);

View File

@ -64,6 +64,44 @@ public class iCo4 implements Method
return false;
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
try
{
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
}
catch (Exception E)
{
return false;
}
return true;
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
try
{
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
}
catch (Exception E)
{
return false;
}
return true;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));

View File

@ -67,6 +67,33 @@ public class iCo5 implements Method
return (hasBank(bank)) && com.iConomy.iConomy.getBank(bank).hasAccount(name);
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
return com.iConomy.iConomy.Accounts.create(name);
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
if (!com.iConomy.iConomy.Accounts.create(name))
{
return false;
}
getAccount(name).set(balance);
return true;
}
public MethodAccount getAccount(String name)
{
return new iCoAccount(com.iConomy.iConomy.getAccount(name));

View File

@ -66,6 +66,26 @@ public class iCo6 implements Method
return false;
}
public boolean createAccount(String name)
{
if (hasAccount(name))
{
return false;
}
return (new Accounts()).create(name);
}
public boolean createAccount(String name, Double balance)
{
if (hasAccount(name))
{
return false;
}
return (new Accounts()).create(name, balance);
}
public MethodAccount getAccount(String name)
{
return new iCoAccount((new Accounts()).get(name));

View File

@ -27,7 +27,9 @@ public class SignBuy extends EssentialsSign
final Trade items = getTrade(sign, 1, 2, player, ess);
final Trade charge = getTrade(sign, 3, ess);
charge.isAffordableFor(player);
items.pay(player);
if (!items.pay(player, false)) {
throw new ChargeException("Inventory full");
}
charge.charge(player);
Trade.log("Sign", "Buy", "Interact", username, charge, username, items, sign.getBlock().getLocation(), ess);
return true;

View File

@ -10,7 +10,6 @@ import org.bukkit.inventory.ItemStack;
public class SignTrade extends EssentialsSign
{
public SignTrade()
{
super("Trade");
@ -34,25 +33,33 @@ public class SignTrade extends EssentialsSign
{
if (sign.getLine(3).substring(2).equalsIgnoreCase(username))
{
final Trade store = rechargeSign(sign, ess, player);
Trade stored = null;
try
{
final Trade stored = getTrade(sign, 1, true, true, ess);
stored = getTrade(sign, 1, true, true, ess);
substractAmount(sign, 1, stored, ess);
stored.pay(player);
Trade.log("Sign", "Trade", "OwnerInteract", username, null, username, stored, sign.getBlock().getLocation(), ess);
}
}
catch (SignException e)
{
throw new SignException(Util.i18n("tradeSignEmptyOwner"));
}
if (store == null)
{
throw new SignException(Util.i18n("tradeSignEmptyOwner"), e);
}
}
Trade.log("Sign", "Trade", "OwnerInteract", username, store, username, stored, sign.getBlock().getLocation(), ess);
}
else
{
final Trade charge = getTrade(sign, 1, false, false, ess);
final Trade trade = getTrade(sign, 2, false, true, ess);
charge.isAffordableFor(player);
if (!trade.pay(player, false))
{
throw new ChargeException("Full inventory");
}
substractAmount(sign, 2, trade, ess);
trade.pay(player);
addAmount(sign, 1, charge, ess);
charge.charge(player);
Trade.log("Sign", "Trade", "Interact", sign.getLine(3), charge, username, trade, sign.getBlock().getLocation(), ess);
@ -61,17 +68,48 @@ public class SignTrade extends EssentialsSign
return true;
}
private Trade rechargeSign(final ISign sign, final IEssentials ess, final User player) throws SignException, ChargeException
{
final Trade trade = getTrade(sign, 2, false, false, ess);
if (trade.getItemStack() != null && player.getItemInHand() != null
&& trade.getItemStack().getTypeId() == player.getItemInHand().getTypeId()
&& trade.getItemStack().getDurability() == player.getItemInHand().getDurability())
{
int amount = player.getItemInHand().getAmount();
amount -= amount % trade.getItemStack().getAmount();
if (amount > 0)
{
final Trade store = new Trade(new ItemStack(player.getItemInHand().getTypeId(), amount, player.getItemInHand().getDurability()), ess);
addAmount(sign, 2, store, ess);
store.charge(player);
return store;
}
}
return null;
}
@Override
protected boolean onSignBreak(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
if ((sign.getLine(3).length() > 3 && sign.getLine(3).substring(2).equalsIgnoreCase(username))
|| player.isAuthorized("essentials.signs.trade.override"))
{
final Trade stored1 = getTrade(sign, 1, true, false, ess);
final Trade stored2 = getTrade(sign, 2, true, false, ess);
stored1.pay(player);
stored2.pay(player);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
try
{
final Trade stored1 = getTrade(sign, 1, true, false, ess);
final Trade stored2 = getTrade(sign, 2, true, false, ess);
stored1.pay(player);
stored2.pay(player);
Trade.log("Sign", "Trade", "Break", username, stored2, username, stored1, sign.getBlock().getLocation(), ess);
}
catch (SignException e)
{
if (player.isAuthorized("essentials.signs.trade.override"))
{
return true;
}
throw e;
}
return true;
}
else
@ -128,7 +166,7 @@ public class SignTrade extends EssentialsSign
throw new SignException(Util.i18n("moreThanZero"));
}
String newline = amount + " " + split[1] + ":0";
if ((newline + amount).length() > 16)
if ((newline + amount).length() > 15)
{
throw new SignException("Line can be too long!");
}
@ -237,7 +275,12 @@ public class SignTrade extends EssentialsSign
final Double amount = getDouble(split[1]);
if (money != null && amount != null)
{
sign.setLine(index, Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1));
final String newline = Util.formatCurrency(money, ess) + ":" + Util.formatCurrency(amount + value, ess).substring(1);
if (newline.length() > 15)
{
throw new SignException("Line too long!");
}
sign.setLine(index, newline);
return;
}
}
@ -247,7 +290,12 @@ public class SignTrade extends EssentialsSign
final int stackamount = getIntegerPositive(split[0]);
final ItemStack item = getItemStack(split[1], stackamount, ess);
final int amount = getInteger(split[2]);
sign.setLine(index, stackamount + " " + split[1] + ":" + (amount + Math.round(value)));
final String newline = stackamount + " " + split[1] + ":" + (amount + Math.round(value));
if (newline.length() > 15)
{
throw new SignException("Line too long!");
}
sign.setLine(index, newline);
return;
}
throw new SignException(Util.format("invalidSignLine", index + 1));

View File

@ -238,6 +238,9 @@ auto-afk-kick: -1
# The player has to use the command /afk to leave the afk mode.
freeze-afk-players: false
# You can disable the death messages of minecraft here
death-messages: true
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #

View File

@ -501,20 +501,20 @@ detecttrack,28,0
detectrail,28,0
dtrack,28,0
drail,28,0
stickypistonbase,29,0
stickypiston,29,0
stickpistonbase,29,0
stickpiston,29,0
stickyp,29,0
spistonbase,29,0
spiston,29,0
pistonstickybase,29,0
pistonsticky,29,0
pistonstickbase,29,0
pistonstick,29,0
pistonsbase,29,0
pistons,29,0
psticky,29,0
stickypistonbase,29,7
stickypiston,29,7
stickpistonbase,29,7
stickpiston,29,7
stickyp,29,7
spistonbase,29,7
spiston,29,7
pistonstickybase,29,7
pistonsticky,29,7
pistonstickbase,29,7
pistonstick,29,7
pistonsbase,29,7
pistons,29,7
psticky,29,7
spiderweb,30,0
sweb,30,0
web,30,0
@ -534,21 +534,21 @@ deadshrub,32,0
shrubdead,32,0
dshrub,32,0
shrubd,32,0
normalpistonbase,33,0
normalpiston,33,0
normpistonbase,33,0
normpiston,33,0
npistonbase,33,0
npiston,33,0
pistonnormalbase,33,0
pistonnormal,33,0
pistonnormbase,33,0
pistonnorm,33,0
pistonnbase,33,0
pistonn,33,0
pistonbase,33,0
piston,33,0
pistonblock,33,0
normalpistonbase,33,7
normalpiston,33,7
normpistonbase,33,7
normpiston,33,7
npistonbase,33,7
npiston,33,7
pistonnormalbase,33,7
pistonnormal,33,7
pistonnormbase,33,7
pistonnorm,33,7
pistonnbase,33,7
pistonn,33,7
pistonbase,33,7
piston,33,7
pistonblock,33,7
pistonextensionnormal,34,0
pistonextensionnorm,34,0
pistonextensionn,34,0
@ -1259,10 +1259,12 @@ sfstone,97,0
stonesilverfish,97,0
fishstone,97,0
trapstone,97,0
silverfish,97,0
stonebrick,98,0
stonebricks,98,0
stonebrickblock,98,0
stonebb,98,0
sbrick,98,0
mossystonebrick,98,1
mossystonebricks,98,1
mossystonebrickblock,98,1

1 #version: TeamCity
501 detectrail,28,0
502 dtrack,28,0
503 drail,28,0
504 stickypistonbase,29,0 stickypistonbase,29,7
505 stickypiston,29,0 stickypiston,29,7
506 stickpistonbase,29,0 stickpistonbase,29,7
507 stickpiston,29,0 stickpiston,29,7
508 stickyp,29,0 stickyp,29,7
509 spistonbase,29,0 spistonbase,29,7
510 spiston,29,0 spiston,29,7
511 pistonstickybase,29,0 pistonstickybase,29,7
512 pistonsticky,29,0 pistonsticky,29,7
513 pistonstickbase,29,0 pistonstickbase,29,7
514 pistonstick,29,0 pistonstick,29,7
515 pistonsbase,29,0 pistonsbase,29,7
516 pistons,29,0 pistons,29,7
517 psticky,29,0 psticky,29,7
518 spiderweb,30,0
519 sweb,30,0
520 web,30,0
534 shrubdead,32,0
535 dshrub,32,0
536 shrubd,32,0
537 normalpistonbase,33,0 normalpistonbase,33,7
538 normalpiston,33,0 normalpiston,33,7
539 normpistonbase,33,0 normpistonbase,33,7
540 normpiston,33,0 normpiston,33,7
541 npistonbase,33,0 npistonbase,33,7
542 npiston,33,0 npiston,33,7
543 pistonnormalbase,33,0 pistonnormalbase,33,7
544 pistonnormal,33,0 pistonnormal,33,7
545 pistonnormbase,33,0 pistonnormbase,33,7
546 pistonnorm,33,0 pistonnorm,33,7
547 pistonnbase,33,0 pistonnbase,33,7
548 pistonn,33,0 pistonn,33,7
549 pistonbase,33,0 pistonbase,33,7
550 piston,33,0 piston,33,7
551 pistonblock,33,0 pistonblock,33,7
552 pistonextensionnormal,34,0
553 pistonextensionnorm,34,0
554 pistonextensionn,34,0
1259 stonesilverfish,97,0
1260 fishstone,97,0
1261 trapstone,97,0
1262 silverfish,97,0
1263 stonebrick,98,0
1264 stonebricks,98,0
1265 stonebrickblock,98,0
1266 stonebb,98,0
1267 sbrick,98,0
1268 mossystonebrick,98,1
1269 mossystonebricks,98,1
1270 mossystonebrickblock,98,1

View File

@ -3,7 +3,7 @@ name: Essentials
main: com.earth2me.essentials.Essentials
# Note to developers: This next line cannot change, or the automatic versioning system will break.
version: TeamCity
website: http://www.earth2me.net:8001/
website: http://ci.earth2me.net/
description: Provides an essential, core set of commands for Bukkit.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology, KHobbits]
commands:

View File

@ -25,7 +25,7 @@ public class EssentialsChat extends JavaPlugin
chatListener = new HashMap<String, IEssentialsChatListener>();
final EssentialsChatPlayerListener playerListener = new EssentialsChatPlayerListener(getServer(), ess, chatListener);
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Highest, this);
pluginManager.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.High, this);
if (!this.getDescription().getVersion().equals(ess.getDescription().getVersion()))
{
LOGGER.log(Level.WARNING, Util.i18n("versionMismatchAll"));

View File

@ -159,7 +159,7 @@ public class GroupManager extends JavaPlugin {
}
};
scheduler = new ScheduledThreadPoolExecutor(1);
int minutes = getConfig().getSaveInterval();
int minutes = getGMConfig().getSaveInterval();
scheduler.scheduleAtFixedRate(commiter, minutes, minutes, TimeUnit.MINUTES);
GroupManager.logger.info("Scheduled Data Saving is set for every " + minutes + " minutes!");
}
@ -1755,7 +1755,7 @@ public class GroupManager extends JavaPlugin {
/**
* @return the config
*/
public GMConfiguration getConfig() {
public GMConfiguration getGMConfig() {
return config;
}

View File

@ -111,7 +111,7 @@ public class WorldsHolder {
@SuppressWarnings("rawtypes")
public void mirrorSetUp() {
mirrors.clear();
Map<String, Object> mirrorsMap = plugin.getConfig().getMirrorsMap();
Map<String, Object> mirrorsMap = plugin.getGMConfig().getMirrorsMap();
if (mirrorsMap != null) {
for (String source : mirrorsMap.keySet()) {
// Make sure all non mirrored worlds have a set of data files.

Binary file not shown.

Binary file not shown.