Merge branch 'master' of github.com:essentials/Essentials

This commit is contained in:
ementalo 2011-07-17 00:08:30 +01:00
commit 462fe18b15
30 changed files with 594 additions and 180 deletions

View File

@ -26,7 +26,7 @@ dist.jar=${dist.dir}/Essentials.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
file.reference.iCo4.jar=../lib/iCo4.jar
file.reference.iCo5.jar=../lib/iCo5.jar
@ -37,9 +37,9 @@ jar.compress=false
javac.classpath=\
${file.reference.Permissions3.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.BOSEconomy.jar}:\
${file.reference.iCo4.jar}:\
${file.reference.iCo5.jar}
${file.reference.iCo5.jar}:\
${file.reference.BOSEconomy7.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View File

@ -30,7 +30,8 @@ public class ConfigPermissionsHandler implements IPermissionsHandler
public boolean hasPermission(final Player base, final String node)
{
final String[] cmds = node.split("\\.", 2);
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]);
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1])
&& ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]);
}
public String getPrefix(final Player base)

View File

@ -48,7 +48,7 @@ public class Essentials extends JavaPlugin implements IEssentials
{
public static final int BUKKIT_VERSION = 974;
private static final Logger LOGGER = Logger.getLogger("Minecraft");
private transient Settings settings;
private transient ISettings settings;
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
private transient Spawn spawn;
private transient Jail jail;
@ -65,7 +65,7 @@ public class Essentials extends JavaPlugin implements IEssentials
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
private transient IPermissionsHandler permissionsHandler;
public Settings getSettings()
public ISettings getSettings()
{
return settings;
}
@ -355,7 +355,7 @@ public class Essentials extends JavaPlugin implements IEssentials
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
return onCommandEssentials(sender, command, commandLabel, args, Thread.currentThread().getContextClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
}
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)

View File

@ -25,7 +25,7 @@ public interface IEssentials extends Plugin
int broadcastMessage(String name, String message);
Settings getSettings();
ISettings getSettings();
CraftScheduler getScheduler();

View File

@ -0,0 +1,131 @@
package com.earth2me.essentials;
import com.earth2me.essentials.commands.IEssentialsCommand;
import java.util.List;
import java.util.Map;
import org.bukkit.ChatColor;
public interface ISettings extends IConf
{
boolean areSignsDisabled();
String format(String format, IUser user);
String getAnnounceNewPlayerFormat(IUser user);
boolean getAnnounceNewPlayers();
String getBackupCommand();
long getBackupInterval();
boolean getBedSetsHome();
String getChatFormat(String group);
int getChatRadius();
double getCommandCost(IEssentialsCommand cmd);
double getCommandCost(String label);
String getCurrencySymbol();
int getDefaultStackSize();
boolean getGenerateExitPortals();
double getHealCooldown();
Object getKit(String name);
Map<String, Object> getKits();
String getLocale();
String getNetherName();
boolean getNetherPortalsEnabled();
double getNetherRatio();
String getNewbieSpawn();
String getNicknamePrefix();
ChatColor getOperatorColor() throws Exception;
boolean getPerWarpPermission();
boolean getProtectBoolean(final String configName, boolean def);
int getProtectCreeperMaxHeight();
List<Integer> getProtectList(final String configName);
boolean getProtectPreventSpawn(final String creatureName);
String getProtectString(final String configName);
boolean getReclaimSetting();
boolean getRespawnAtHome();
boolean getSortListByGroups();
int getSpawnMobLimit();
int getStartingBalance();
double getTeleportCooldown();
double getTeleportDelay();
boolean hidePermissionlessHelp();
boolean isCommandDisabled(final IEssentialsCommand cmd);
boolean isCommandDisabled(String label);
boolean isCommandOverridden(String name);
boolean isCommandRestricted(IEssentialsCommand cmd);
boolean isCommandRestricted(String label);
boolean isDebug();
boolean isEcoDisabled();
boolean isNetherEnabled();
boolean isTradeInStacks(int id);
List<Integer> itemSpawnBlacklist();
boolean permissionBasedItemSpawn();
void reloadConfig();
boolean showNonEssCommandsInHelp();
boolean spawnIfNoHome();
boolean use1to1RatioInNether();
boolean warnOnBuildDisallow();
boolean warnOnSmite();
double getMaxMoney();
boolean isEcoLogEnabled();
boolean removeGodOnDisconnect();
boolean changeDisplayName();
boolean isPlayerCommand(String string);
}

View File

@ -11,7 +11,7 @@ import java.util.Map;
import org.bukkit.inventory.ItemStack;
public class Settings implements IConf
public class Settings implements ISettings
{
private final transient EssentialsConf config;
private final static Logger logger = Logger.getLogger("Minecraft");
@ -22,49 +22,58 @@ public class Settings implements IConf
this.ess = ess;
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
config.setTemplateName("/config.yml");
config.load();
reloadConfig();
}
@Override
public boolean getRespawnAtHome()
{
return config.getBoolean("respawn-at-home", false);
}
@Override
public boolean getBedSetsHome()
{
return config.getBoolean("bed-sethome", false);
}
@Override
public int getChatRadius()
{
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
}
@Override
public double getTeleportDelay()
{
return config.getDouble("teleport-delay", 0);
}
@Override
public int getDefaultStackSize()
{
return config.getInt("default-stack-size", 64);
}
@Override
public int getStartingBalance()
{
return config.getInt("starting-balance", 0);
}
@Override
public boolean getNetherPortalsEnabled()
{
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
}
@Override
public boolean isCommandDisabled(final IEssentialsCommand cmd)
{
return isCommandDisabled(cmd.getName());
}
@Override
public boolean isCommandDisabled(String label)
{
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
@ -75,11 +84,13 @@ public class Settings implements IConf
return config.getBoolean("disable-" + label.toLowerCase(), false);
}
@Override
public boolean isCommandRestricted(IEssentialsCommand cmd)
{
return isCommandRestricted(cmd.getName());
}
@Override
public boolean isCommandRestricted(String label)
{
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
@ -89,7 +100,19 @@ public class Settings implements IConf
}
return config.getBoolean("restrict-" + label.toLowerCase(), false);
}
@Override
public boolean isPlayerCommand(String label)
{
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
{
if (!c.equalsIgnoreCase(label)) continue;
return true;
}
return false;
}
@Override
public boolean isCommandOverridden(String name)
{
List<String> defaultList = new ArrayList<String>(1);
@ -103,11 +126,13 @@ public class Settings implements IConf
return config.getBoolean("override-" + name.toLowerCase(), false);
}
@Override
public double getCommandCost(IEssentialsCommand cmd)
{
return getCommandCost(cmd.getName());
}
@Override
public double getCommandCost(String label)
{
double cost = config.getDouble("command-costs." + label, 0.0);
@ -116,26 +141,25 @@ public class Settings implements IConf
return cost;
}
public String getCommandPrefix()
{
return config.getString("command-prefix", "");
}
@Override
public String getNicknamePrefix()
{
return config.getString("nickname-prefix", "~");
}
@Override
public double getTeleportCooldown()
{
return config.getDouble("teleport-cooldown", 60);
}
@Override
public double getHealCooldown()
{
return config.getDouble("heal-cooldown", 60);
}
@Override
public Object getKit(String name)
{
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
@ -148,11 +172,13 @@ public class Settings implements IConf
return null;
}
@Override
public Map<String, Object> getKits()
{
return (Map<String, Object>)config.getProperty("kits");
}
@Override
public ChatColor getOperatorColor() throws Exception
{
String colorName = config.getString("ops-name-color", null);
@ -173,100 +199,120 @@ public class Settings implements IConf
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
}
@Override
public boolean getReclaimSetting()
{
return config.getBoolean("reclaim-onlogout", true);
}
@Override
public String getNetherName()
{
return config.getString("nether.folder", "nether");
}
@Override
public boolean isNetherEnabled()
{
return config.getBoolean("nether.enabled", true);
}
@Override
public int getSpawnMobLimit()
{
return config.getInt("spawnmob-limit", 10);
}
@Override
public boolean showNonEssCommandsInHelp()
{
return config.getBoolean("non-ess-in-help", true);
}
@Override
public boolean hidePermissionlessHelp()
{
return config.getBoolean("hide-permissionless-help", true);
}
@Override
public int getProtectCreeperMaxHeight()
{
return config.getInt("protect.creeper.max-height", -1);
}
@Override
public boolean areSignsDisabled()
{
return config.getBoolean("signs-disabled", false);
}
@Override
public long getBackupInterval()
{
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
}
@Override
public String getBackupCommand()
{
return config.getString("backup.command", null);
}
@Override
public String getChatFormat(String group)
{
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
}
@Override
public boolean getGenerateExitPortals()
{
return config.getBoolean("nether.generate-exit-portals", true);
}
@Override
public boolean getAnnounceNewPlayers()
{
return !config.getString("newbies.announce-format", "-").isEmpty();
}
@Override
public String getAnnounceNewPlayerFormat(IUser user)
{
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
}
@Override
public String format(String format, IUser user)
{
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
}
@Override
public String getNewbieSpawn()
{
return config.getString("newbies.spawnpoint", "default");
}
@Override
public boolean getPerWarpPermission()
{
return config.getBoolean("per-warp-permission", false);
}
@Override
public boolean getSortListByGroups()
{
return config.getBoolean("sort-list-by-groups", true);
}
@Override
public void reloadConfig() {
config.load();
}
@Override
public List<Integer> itemSpawnBlacklist()
{
final List<Integer> epItemSpwn = new ArrayList<Integer>();
@ -286,21 +332,25 @@ public class Settings implements IConf
return epItemSpwn;
}
@Override
public boolean spawnIfNoHome()
{
return config.getBoolean("spawn-if-no-home", false);
}
@Override
public boolean warnOnBuildDisallow()
{
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
}
@Override
public boolean use1to1RatioInNether()
{
return config.getBoolean("nether.use-1to1-ratio", false);
}
@Override
public double getNetherRatio()
{
if (config.getBoolean("nether.use-1to1-ratio", false)) {
@ -309,46 +359,55 @@ public class Settings implements IConf
return config.getDouble("nether.ratio", 16.0);
}
@Override
public boolean isDebug()
{
return config.getBoolean("debug", false);
}
@Override
public boolean warnOnSmite()
{
return config.getBoolean("warn-on-smite" ,true);
}
@Override
public boolean permissionBasedItemSpawn()
{
return config.getBoolean("permission-based-item-spawn", false);
}
@Override
public String getLocale()
{
return config.getString("locale", "");
}
@Override
public String getCurrencySymbol()
{
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
}
@Override
public boolean isTradeInStacks(int id)
{
return config.getBoolean("trade-in-stacks-" + id, false);
}
@Override
public boolean isEcoDisabled()
{
return config.getBoolean("disable-eco", false);
}
@Override
public boolean getProtectPreventSpawn(final String creatureName)
{
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
}
@Override
public List<Integer> getProtectList(final String configName)
{
final List<Integer> list = new ArrayList<Integer>();
@ -368,18 +427,20 @@ public class Settings implements IConf
return list;
}
@Override
public String getProtectString(final String configName)
{
return config.getString(configName, null);
}
@Override
public boolean getProtectBoolean(final String configName, boolean def)
{
return config.getBoolean(configName, def);
}
private final static double MAXMONEY = 10000000000000.0;
double getMaxMoney()
public double getMaxMoney()
{
double max = config.getDouble("max-money", MAXMONEY);
if (Math.abs(max) > MAXMONEY) {
@ -388,17 +449,17 @@ public class Settings implements IConf
return max;
}
boolean isEcoLogEnabled()
public boolean isEcoLogEnabled()
{
return config.getBoolean("economy-log-enabled", false);
}
boolean removeGodOnDisconnect()
public boolean removeGodOnDisconnect()
{
return config.getBoolean("remove-god-on-disconnect", false);
}
boolean changeDisplayName()
public boolean changeDisplayName()
{
return config.getBoolean("change-displayname", true);
}

View File

@ -25,6 +25,7 @@ public class Commandkick extends EssentialsCommand
if (u.isAuthorized("essentials.kick.exempt"))
{
sender.sendMessage(Util.i18n("kickExempt"));
return;
}
charge(sender);
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");

View File

@ -1,53 +1,52 @@
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandmute extends EssentialsCommand
{
public Commandmute()
{
super("mute");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0, true);
if (p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(commandLabel);
return;
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
}
p.setMuteTimeout(muteTimestamp);
charge(sender);
boolean muted = p.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}
package com.earth2me.essentials.commands;
import org.bukkit.Server;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.User;
import com.earth2me.essentials.Util;
public class Commandmute extends EssentialsCommand
{
public Commandmute()
{
super("mute");
}
@Override
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
{
if (args.length < 1)
{
throw new NotEnoughArgumentsException();
}
User p = getPlayer(server, args, 0, true);
if (p.isAuthorized("essentials.mute.exempt"))
{
sender.sendMessage(Util.i18n("muteExempt"));
return;
}
long muteTimestamp = 0;
if (args.length > 1)
{
String time = getFinalArg(args, 1);
muteTimestamp = Util.parseDateDiff(time, true);
}
p.setMuteTimeout(muteTimestamp);
charge(sender);
boolean muted = p.toggleMuted();
sender.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
: Util.format("mutedPlayer", p.getDisplayName()))
: Util.format("unmutedPlayer", p.getDisplayName()));
p.sendMessage(
muted
? (muteTimestamp > 0
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
: Util.i18n("playerMuted"))
: Util.i18n("playerUnmuted"));
}
}

View File

@ -29,7 +29,7 @@ public class Commandtempban extends EssentialsCommand
final String time = getFinalArg(args, 1);
final long banTimestamp = Util.parseDateDiff(time, true);
final String banReason = (args.length == 3 && !args[2].isEmpty()) ? args[2].toString() + " - " + Util.formatDateDiff(banTimestamp) : Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
player.setBanReason(banReason);
player.setBanTimeout(banTimestamp);
player.kickPlayer(banReason);

View File

@ -1,14 +1,12 @@
package com.earth2me.essentials.register.payment;
import java.util.HashSet;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginManager;
/***
import java.util.HashSet;
import java.util.Set;
/**
* Methods.java
* Controls the getting / setting of methods & the method of payment used.
*
@ -19,18 +17,36 @@ import org.bukkit.plugin.PluginManager;
public class Methods {
private boolean self = false;
private Method Method = null;
private String preferred = "";
private String preferred = "";
private Set<Method> Methods = new HashSet<Method>();
private Set<String> Dependencies = new HashSet<String>();
private Set<Method> Attachables = new HashSet<Method>();
private Set<Method> Attachables = new HashSet<Method>();
public Methods() {
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE());
this._init();
}
public Set<String> getDependencies() {
/**
* Allows you to set which economy plugin is most preferred.
*
* @param preferred - preferred economy plugin
*/
public Methods(String preferred) {
this._init();
if(this.Dependencies.contains(preferred)) {
this.preferred = preferred;
}
}
private void _init() {
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
}
public Set<String> getDependencies() {
return Dependencies;
}
@ -60,7 +76,7 @@ public class Methods {
int count = 0;
boolean match = false;
Plugin plugin = null;
Plugin plugin;
PluginManager manager = method.getServer().getPluginManager();
for(String name: this.getDependencies()) {
@ -68,14 +84,6 @@ public class Methods {
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
if(plugin == null) continue;
if(!plugin.isEnabled()) {
this.self = true;
Logger.getLogger("Minecraft").log(Level.SEVERE, name + " Plugin was found, but not enabled before Essentials. Read the Essentials thread for help.");
//manager.enablePlugin(plugin);
}
if(plugin == null) continue;
Method current = this.createMethod(plugin);
if(current == null) continue;
@ -86,7 +94,7 @@ public class Methods {
}
}
if(!this.preferred.isEmpty()) {
if(!this.preferred.isEmpty()) {
do {
if(hasMethod()) {
match = true;

View File

@ -4,7 +4,7 @@ import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
public class BOSE implements Method {
public class BOSE6 implements Method {
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() {
@ -38,7 +38,7 @@ public class BOSE implements Method {
}
public boolean hasBankAccount(String bank, String name) {
return this.BOSEconomy.isBankOwner(bank, name);
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public MethodAccount getAccount(String name) {
@ -47,11 +47,12 @@ public class BOSE implements Method {
}
public MethodBankAccount getBankAccount(String bank, String name) {
return new BOSEBankAccount(bank, name, BOSEconomy);
if(!hasBankAccount(bank, name)) return null;
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy;
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
}
public void setPlugin(Plugin plugin) {
@ -122,11 +123,9 @@ public class BOSE implements Method {
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
private String name;
private BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, String name, BOSEconomy bOSEconomy) {
this.name = name;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
@ -140,36 +139,36 @@ public class BOSE implements Method {
}
public double balance() {
return Double.valueOf(this.BOSEconomy.getBankMoney(name));
return Double.valueOf(this.BOSEconomy.getBankMoney(bank));
}
public boolean set(double amount) {
int IntAmount = (int)Math.ceil(amount);
return this.BOSEconomy.setBankMoney(name, IntAmount, true);
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
}
public boolean add(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(this.name, (balance + IntAmount), false);
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
}
public boolean subtract(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(this.name, (balance - IntAmount), false);
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
}
public boolean multiply(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(this.name, (balance * IntAmount), false);
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
}
public boolean divide(double amount) {
int IntAmount = (int)Math.ceil(amount);
int balance = (int)this.balance();
return this.BOSEconomy.setBankMoney(this.name, (balance / IntAmount), false);
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
}
public boolean hasEnough(double amount) {

View File

@ -0,0 +1,188 @@
package com.earth2me.essentials.register.payment.methods;
import com.earth2me.essentials.register.payment.Method;
import cosine.boseconomy.BOSEconomy;
import org.bukkit.plugin.Plugin;
/**
* @author Acrobot
*/
public class BOSE7 implements Method {
private BOSEconomy BOSEconomy;
public BOSEconomy getPlugin() {
return this.BOSEconomy;
}
public String getName() {
return "BOSEconomy";
}
public String getVersion() {
return "0.7.0";
}
public String format(double amount) {
String currency = this.BOSEconomy.getMoneyNamePlural();
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
return amount + " " + currency;
}
public boolean hasBanks() {
return true;
}
public boolean hasBank(String bank) {
return this.BOSEconomy.bankExists(bank);
}
public boolean hasAccount(String name) {
return this.BOSEconomy.playerRegistered(name, false);
}
public boolean hasBankAccount(String bank, String name) {
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
}
public MethodAccount getAccount(String name) {
if(!hasAccount(name)) return null;
return new BOSEAccount(name, this.BOSEconomy);
}
public MethodBankAccount getBankAccount(String bank, String name) {
if(!hasBankAccount(bank, name)) return null;
return new BOSEBankAccount(bank, BOSEconomy);
}
public boolean isCompatible(Plugin plugin) {
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
}
public void setPlugin(Plugin plugin) {
BOSEconomy = (BOSEconomy)plugin;
}
public class BOSEAccount implements MethodAccount {
private String name;
private BOSEconomy BOSEconomy;
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
this.name = name;
this.BOSEconomy = bOSEconomy;
}
public double balance() {
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
}
public boolean set(double amount) {
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
}
public boolean add(double amount) {
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
}
public boolean subtract(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
}
public boolean divide(double amount) {
double balance = this.balance();
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return false;
}
}
public class BOSEBankAccount implements MethodBankAccount {
private String bank;
private BOSEconomy BOSEconomy;
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
this.bank = bank;
this.BOSEconomy = bOSEconomy;
}
public String getBankName() {
return this.bank;
}
public int getBankId() {
return -1;
}
public double balance() {
return this.BOSEconomy.getBankMoneyDouble(bank);
}
public boolean set(double amount) {
return this.BOSEconomy.setBankMoney(bank, amount, true);
}
public boolean add(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
}
public boolean subtract(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
}
public boolean multiply(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
}
public boolean divide(double amount) {
double balance = this.balance();
return this.BOSEconomy.setBankMoney(bank, (balance / amount), false);
}
public boolean hasEnough(double amount) {
return (this.balance() >= amount);
}
public boolean hasOver(double amount) {
return (this.balance() > amount);
}
public boolean hasUnder(double amount) {
return (this.balance() < amount);
}
public boolean isNegative() {
return (this.balance() < 0);
}
public boolean remove() {
return this.BOSEconomy.removeBank(bank);
}
}
}

View File

@ -208,4 +208,4 @@ public class iCo5 implements Method {
return true;
}
}
}
}

View File

@ -1,6 +1,7 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.User;
import java.util.logging.Level;
import java.util.logging.Logger;
import org.bukkit.Material;
@ -100,6 +101,13 @@ public class SignBlockListener extends BlockListener
return;
}
}
User user = ess.getUser(event.getPlayer());
if (user.isAuthorized("essentials.signs.color"))
{
for (int i = 0; i < 4; i++) {
event.setLine(i, event.getLine(i).replaceAll("&([0-9a-f])", "§$1"));
}
}
}
@Override

View File

@ -1,6 +1,8 @@
package com.earth2me.essentials.signs;
import com.earth2me.essentials.IEssentials;
import com.earth2me.essentials.InventoryWorkaround;
import com.earth2me.essentials.Trade;
import com.earth2me.essentials.User;
import net.minecraft.server.InventoryPlayer;
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
@ -17,18 +19,20 @@ public class SignFree extends EssentialsSign
@Override
protected boolean onSignCreate(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
getItemStack(sign.getLine(1), 9 * 4 * 64, ess);
getItemStack(sign.getLine(1), 1, ess);
return true;
}
@Override
protected boolean onSignInteract(final ISign sign, final User player, final String username, final IEssentials ess) throws SignException
{
final ItemStack item = getItemStack(sign.getLine(1), 9 * 4 * 64, ess);
final ItemStack item = getItemStack(sign.getLine(1), 1, ess);
item.setAmount(item.getType().getMaxStackSize()*9*4);
final CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(player.getHandle()));
inv.clear();
inv.addItem(item);
InventoryWorkaround.addItem(inv, true, item);
player.showInventory(inv);
Trade.log("Sign", "Free", "Interact", username, null, username, new Trade(item, ess), ess);
return true;
}
}

View File

@ -114,52 +114,42 @@ overridden-commands:
disabled-commands:
# - nick
# Restricted commands will only be available to ops.
# Restricted commands have been removed.
# Now we have a whitelist, all commands not on this list are only available to ops.
# These will have NO EFFECT if you have Permissions installed!
# These are here only if you want something simpler than Permissions.
restricted-commands:
- bigtree
- item
- give
- heal
- plugin
- time
- top
- tp
- tphere
- tree
- setspawn
- antioch
- kick
- ban
- unban
- top
- jump
- tpo
- tppos
- tpohere
- economy
- setwarp
- delwarp
- essentials
- gc
- spawnmob
- broadcast
- burn
- ext
- kill
- ping
- banip
- unban
- mute
- kick
- kickall
- unbanip
- togglejail
- setjail
- eco.loan
- teleport.timer.bypass
- teleport.cooldown.bypass
player-commands:
- afk
- back
- back.ondeath
- balance
- clearinventory
- compass
- help
- helpop
- home
- home.others
- ignore
- info
- list
- mail
- motd
- msg
- nick
- pay
- powertool
- r
- rules
- seen
- sell
- sethome
- suicide
- tpa
- tpaccept
- tpahere
- tpdeny
- world
- worth
# Note: All items MUST be followed by a quantity!
# Times are measured in seconds.

View File

@ -168,6 +168,7 @@ month = month
months = months
moreThanZero = Quantities must be greater than 0.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Player {0} muted.
mutedPlayerFor = Player {0} muted for {1}.
mutedUserSpeaks = {0} tried to speak, but is muted.
@ -214,11 +215,11 @@ playerInJail = \u00a7cPlayer is already in jail {0}.
playerJailed = \u00a77Player {0} jailed.
playerJailedFor = \u00a77Player {0} jailed for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cPlayer {0} was never on this server.
playerNotFound = \u00a7cPlayer not found.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}.
powerToolAir = Command can''t be attached to air.

View File

@ -170,6 +170,7 @@ month = m\u00e5ned
months = m\u00e5neder
moreThanZero = M\u00e6ngder skal v\u00e6re st\u00f8rre end 0.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Spiller {0} d\u00e6mpet.
mutedPlayerFor = Spiller {0} d\u00e6mpet for {1}.
mutedUserSpeaks = {0} pr\u00f8vede at snakke, men er muted.
@ -216,11 +217,11 @@ playerInJail = \u00a7cSpiller er allerede i f\u00e6ngsel {0}.
playerJailed = \u00a77Spiller {0} f\u00e6ngslet.
playerJailedFor = \u00a77Spiller {0} f\u00e6ngslet for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cSpiller {0} var aldrig p\u00e5 denne server.
playerNotFound = \u00a7cSpiller ikke fundet.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77Mulige verdener er numrene 0 igennem {0}.
powerToolAir = Kommando kan ikke blive tildelt luft.

View File

@ -14,7 +14,7 @@ backupStarted = Backup gestartet
balance = \u00a77Geldb\u00f6rse: {0}
balanceTop = \u00a77 Top {0} Guthaben
banIpAddress = \u00a77IP-Adresse gesperrt.
banExempt = \u00a7cDu kan ikke forbyde den p\u00e5g\u00e6ldende spiller.
banExempt = \u00a7cDu kannst diesen Spieler nicht sperren.
bannedIpsFileError = Fehler beim Lesen von banned-ips.txt
bannedIpsFileNotFound = banned-ips.txt nicht gefunden
bannedPlayersFileError = Fehler beim Lesen von banned-players.txt
@ -132,7 +132,7 @@ jailNotExist = Dieses Gef\u00e4ngnis existiert nicht.
jailSet = \u00a77Gef\u00e4ngnis {0} wurde erstellt.
jumpError = Das w\u00fcrde deinen Computer \u00fcberlasten.
kickDefault = Vom Server geworfen
kickExempt = \u00a7cSie k\u00f6nnen nicht kicken, dass Spieler.
kickExempt = \u00a7cDu kannst diesen Spieler nicht rauswerfen.
kill = \u00a77{0} get\u00f6tet.
kitError = \u00a7cEs gibt keine g\u00fcltigen Ausr\u00fcstungen.
kitError2 = \u00a7cDiese Ausr\u00fcstung existiert nicht oder ist ung\u00fcltig.
@ -168,6 +168,7 @@ month = Monat
months = Monate
moreThanZero = Anzahl muss gr\u00f6sser als 0 sein.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Player {0} ist nun stumm.
mutedPlayerFor = Player {0} ist nun stumm f\u00fcr {1}.
mutedUserSpeaks = {0} versuchte zu sprechen, aber ist stumm geschalt.
@ -214,11 +215,11 @@ playerInJail = \u00a7cSpieler ist bereits in Gef\u00e4ngnis {0}.
playerJailed = \u00a77Spieler {0} eingesperrt.
playerJailedFor = \u00a77Spieler {0} eingesperrt f\u00fcr {1}.
playerKicked = \u00a7cSpieler {0} rausgeworfen: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cSpieler {0} war niemals auf diesem Server.
playerNotFound = \u00a7cSpieler nicht gefunden.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77M\u00f6gliche Welten sind nummeriet von 0 bis {0}.
powerToolAir = Befehl kann nicht mit Luft verbunden werden.
@ -260,7 +261,7 @@ teleportationEnabled = \u00a77Teleportierung aktiviert.
teleporting = \u00a77Teleportiere...
teleportingPortal = \u00a77Teleportiere durch Portal.
tempBanned = Zeitlich gesperrt vom Server f\u00fcr {0}
tempbanExempt = \u00a77You may not tempban that player
tempbanExempt = \u00a77Du kannst diesen Spieler nicht zeitlich sperren.
thunder = Du hast Donner in deiner Welt {0}.
thunderDuration = Du hast Donner in deiner Welt {0} f\u00fcr {1} Sekunden.
timeBeforeHeal = Zeit bis zur n\u00e4chsten Heilung: {0}

View File

@ -168,6 +168,7 @@ month = month
months = months
moreThanZero = Quantities must be greater than 0.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Player {0} muted.
mutedPlayerFor = Player {0} muted for {1}.
mutedUserSpeaks = {0} tried to speak, but is muted.
@ -214,11 +215,11 @@ playerInJail = \u00a7cPlayer is already in jail {0}.
playerJailed = \u00a77Player {0} jailed.
playerJailedFor = \u00a77Player {0} jailed for {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cPlayer {0} was never on this server.
playerNotFound = \u00a7cPlayer not found.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77Possible worlds are the numbers 0 through {0}.
powerToolAir = Command can''t be attached to air.

View File

@ -168,6 +168,7 @@ month = mois
months = mois
moreThanZero = Les Quantit\u00e9s doivent \u00eatre sup\u00e9rieures \u00e0 z\u00e9ro.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Le joueur {0} est d\u00e9sormais muet.
mutedPlayerFor = {0} a \u00e9t\u00e9 mute pour {1}.
mutedUserSpeaks = {0} a essay\u00e9 de parler mais est muet.
@ -214,11 +215,11 @@ playerInJail = \u00a7cLe joueur est d\u00e9j\u00e0 dans la prison {0}.
playerJailed = \u00a77Le joueur {0} a \u00e9t\u00e9 emprisonn\u00e9.
playerJailedFor = \u00a77{0} a \u00e9t\u00e9 emprisonn\u00e9 pour {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cLe joueur {0} n''a jamais \u00e9t\u00e9 sur le serveur.
playerNotFound = \u00a7cLe joueur est introuvable.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77Les mondes possibles sont les nombres 0 par {0}.
powerToolAir = La commande ne peut pas \u00eatre attach\u00e9e \u00e0 l''air.

View File

@ -169,6 +169,7 @@ month = maand
months = maanden
moreThanZero = Aantal moet groter zijn dan 0.
msgFormat = \u00a77[{0}\u00a77 -> {1}\u00a77] \u00a7f{2}
muteExempt = \u00a7cYou may not mute that player.
mutedPlayer = Speler {0} gemute.
mutedPlayerFor = Speler {0} is gemute voor {1}.
mutedUserSpeaks = {0} probeerde te praten, maar is gemute.
@ -215,11 +216,11 @@ playerInJail = \u00a7cSpeler zit al in de gevangenis {0}.
playerJailed = \u00a77Speler {0} is in de gevangenis gezet.
playerJailedFor = \u00a77Speler {0} is in de gevangenis gezet voor {1}.
playerKicked = \u00a7cPlayer {0} kicked: {1}
playerMuted = "$7You have been muted"
playerMutedFor = "$7You have been muted for {0}"
playerMuted = "\u00a77You have been muted"
playerMutedFor = "\u00a77You have been muted for {0}"
playerNeverOnServer = \u00a7cSpeler {0} is nooit op deze server geweest.
playerNotFound = \u00a7cSpeler niet gevonden.
playerUnmuted = "$7You have been unmuted"
playerUnmuted = "\u00a77You have been unmuted"
pong = Pong!
possibleWorlds = \u00a77Mogelijk zijn de werelden de nummer 0 tot en met {0}.
powerToolAir = Command kan niet worden bevestigd aan de lucht.

View File

@ -5,6 +5,7 @@ import com.earth2me.essentials.api.NoLoanPermittedException;
import com.earth2me.essentials.api.UserDoesNotExistException;
import java.io.IOException;
import junit.framework.TestCase;
import org.bukkit.World.Environment;
import org.bukkit.plugin.InvalidDescriptionException;
import org.junit.Test;
@ -20,6 +21,7 @@ public class EconomyTest extends TestCase
super(testName);
ess = new Essentials();
final FakeServer server = new FakeServer();
server.createWorld("testWorld", Environment.NORMAL);
try
{
ess.setupForTesting(server);

View File

@ -47,7 +47,7 @@ public class EssentialsPermissionsCommands extends JavaPlugin
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args)
{
return ess.onCommandEssentials(sender, command, label, args, Thread.currentThread().getContextClassLoader(), "com.earth2me.essentials.permissions.Command", "groupmanager.");
return ess.onCommandEssentials(sender, command, label, args, EssentialsPermissionsCommands.class.getClassLoader(), "com.earth2me.essentials.permissions.Command", "groupmanager.");
}
@Override

View File

@ -97,6 +97,10 @@ public class EssentialsProtectBlockListener extends BlockListener
@Override
public void onBlockIgnite(BlockIgniteEvent event)
{
if (event.isCancelled())
{
return;
}
Block block = event.getBlock();
if (block.getType() == Material.RAILS
&& prot.getSettingBool(ProtectConfig.protect_rails))
@ -185,6 +189,10 @@ public class EssentialsProtectBlockListener extends BlockListener
@Override
public void onBlockBurn(final BlockBurnEvent event)
{
if (event.isCancelled())
{
return;
}
final Block block = event.getBlock();
if (block.getType() == Material.RAILS && prot.getSettingBool(ProtectConfig.protect_rails))
{

View File

@ -292,6 +292,10 @@ public class EssentialsProtectEntityListener extends EntityListener
@Override
public void onEntityTarget(final EntityTargetEvent event)
{
if (event.isCancelled())
{
return;
}
if (!(event.getTarget() instanceof Player))
{
return;

View File

@ -24,6 +24,10 @@ public class EssentialsProtectPlayerListener extends PlayerListener
@Override
public void onPlayerInteract(final PlayerInteractEvent event)
{
if (event.isCancelled())
{
return;
}
final User user = ess.getUser(event.getPlayer());
if (prot.getSettingBool(ProtectConfig.disable_build) && !user.canBuild())

View File

@ -41,6 +41,6 @@ public class EssentialsSpawn extends JavaPlugin
@Override
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
{
return ess.onCommandEssentials(sender, command, commandLabel, args, Thread.currentThread().getContextClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.");
return ess.onCommandEssentials(sender, command, commandLabel, args, EssentialsSpawn.class.getClassLoader(), "com.earth2me.essentials.spawn.Command", "essentials.");
}
}

Binary file not shown.

BIN
lib/BOSEconomy7.jar Normal file

Binary file not shown.