Added Support for Register.

git-svn-id: https://svn.java.net/svn/essentials~svn/trunk@1438 e251c2fe-e539-e718-e476-b85c1f46cddb
This commit is contained in:
snowleo 2011-05-13 20:36:41 +00:00
parent de4046e81c
commit 0f72b94724
7 changed files with 39 additions and 16 deletions

View file

@ -72,4 +72,13 @@
nbproject/build-impl.xml file.
-->
<target name="-post-jar">
<jar jarfile="${dist.dir}/Essentials.jar">
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
<zipfileset src="../lib/register.jar" excludes="META-INF/*" />
<manifest>
<attribute name="Classpath" value="Essentials.jar"/>
</manifest>
</jar>
</target>
</project>

View file

@ -22,20 +22,20 @@ debug.test.classpath=\
${run.test.classpath}
# This directory is removed when the project is cleaned:
dist.dir=dist
dist.jar=${dist.dir}/Essentials.jar
dist.jar=${dist.dir}/original-Essentials.jar
dist.javadoc.dir=${dist.dir}/javadoc
endorsed.classpath=
excludes=
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
file.reference.iConomy.jar=../lib/iConomy.jar
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
file.reference.Permissions.jar=..\\lib\\Permissions.jar
file.reference.Register.jar=../lib/Register.jar
includes=**
jar.compress=false
javac.classpath=\
${file.reference.Permissions.jar}:\
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
${file.reference.iConomy.jar}
${file.reference.Register.jar}
# Space-separated list of extra javac options
javac.compilerargs=
javac.deprecation=false

View file

@ -26,6 +26,7 @@ import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import com.earth2me.essentials.commands.IEssentialsCommand;
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
import com.nijikokun.register.payment.Methods;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import org.bukkit.command.PluginCommand;
@ -60,6 +61,7 @@ public class Essentials extends JavaPlugin
private Map<String, User> users = new HashMap<String, User>();
private EssentialsTimer timer;
private boolean iConomyFallback = true;
private Methods paymentMethod = new Methods();
public Essentials()
{
@ -131,6 +133,12 @@ public class Essentials extends JavaPlugin
logger.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
}
}
if (!paymentMethod.hasMethod() && plugin != this)
{
if (getPaymentMethod().setMethod(plugin)) {
logger.log(Level.INFO, "Payment method found (" + getPaymentMethod().getMethod().getName() + " version: " + getPaymentMethod().getMethod().getVersion() + ")");
}
}
}
Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
if (versionMatch.matches())
@ -205,12 +213,12 @@ public class Essentials extends JavaPlugin
{
iConf.reloadConfig();
}
for (User user : users.values())
{
user.reloadConfig();
}
// for motd
getConfiguration().load();
@ -334,10 +342,10 @@ public class Essentials extends JavaPlugin
{
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command");
}
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath)
{
if ("msg".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase()) & sender instanceof CraftPlayer)
if ("msg".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase()) & sender instanceof CraftPlayer)
{
StringBuilder str = new StringBuilder();
str.append(commandLabel + " ");
@ -625,8 +633,8 @@ public class Essentials extends JavaPlugin
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
if (userFile.exists())
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
return getUser((Player) new OfflinePlayer(name));
return getUser((Player)new OfflinePlayer(name));
}
return null;
}
@ -666,13 +674,18 @@ public class Essentials extends JavaPlugin
this.iConomyFallback = iConomyFallback;
}
public boolean isIConomyFallbackEnabled()
public boolean isRegisterFallbackEnabled()
{
return iConomyFallback;
}
public void addReloadListener(IConf listener)
{
confList.add(listener);
}
public Methods getPaymentMethod()
{
return paymentMethod;
}
}

View file

@ -273,11 +273,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo
@Override
public double getMoney()
{
if (ess.isIConomyFallbackEnabled())
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
{
try
{
return com.iConomy.iConomy.getAccount(getName()).getHoldings().balance();
return ess.getPaymentMethod().getMethod().getAccount(this.getName()).balance();
}
catch (Throwable ex)
{
@ -289,11 +289,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo
@Override
public void setMoney(double value)
{
if (ess.isIConomyFallbackEnabled())
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
{
try
{
com.iConomy.iConomy.getAccount(getName()).getHoldings().set(value);
double amount = value - ess.getPaymentMethod().getMethod().getAccount(this.getName()).balance();
ess.getPaymentMethod().getMethod().getAccount(this.getName()).add(amount);
}
catch (Throwable ex)
{

View file

@ -6,7 +6,7 @@ version: TeamCity
website: http://www.earth2me.net:8001/
description: Provides an essential, core set of commands for Bukkit.
authors: [Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans, Xeology]
softdepend: [Permissions]
softdepend: [Permissions, iConomy, BOSEconomy]
commands:
afk:
description: Marks you as away-from-keyboard.

BIN
lib/Register.jar Normal file

Binary file not shown.

Binary file not shown.