mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-09 22:20:47 +02:00
Compare commits
293 Commits
stable-2.6
...
stable-2.6
Author | SHA1 | Date | |
---|---|---|---|
|
7ecc3c25b0 | ||
|
41c03853ab | ||
|
adcffba7cf | ||
|
2a4c26ee69 | ||
|
8143154826 | ||
|
e271e60144 | ||
|
c5c29aef4e | ||
|
7b7d1f557f | ||
|
af5a86c48c | ||
|
022f7ab1d4 | ||
|
b9daf6aaa5 | ||
|
4be1797592 | ||
|
c0d046841f | ||
|
e4c3f7b115 | ||
|
f51b92c99e | ||
|
16be86953f | ||
|
eda827b244 | ||
|
27ee7efde5 | ||
|
cccebdd62e | ||
|
d2f3bf94ae | ||
|
f4e22a17db | ||
|
b619a54105 | ||
|
cd897890be | ||
|
437d3b41b8 | ||
|
1f527cdb9e | ||
|
90c9fe7e65 | ||
|
e9f942e802 | ||
|
f40260acef | ||
|
ab2e8f94f0 | ||
|
cf9ef46182 | ||
|
cc5062828a | ||
|
165d499ef3 | ||
|
1c7e0e5b9f | ||
|
f0c49019dd | ||
|
e7234e621d | ||
|
269947bdae | ||
|
4ac5551c6b | ||
|
05242a7e8f | ||
|
fd2ec22919 | ||
|
7618754b89 | ||
|
d8f7c82e2d | ||
|
fd4c82b0eb | ||
|
70d1c7d7d7 | ||
|
894d956ba1 | ||
|
52c2110a2b | ||
|
8890284b3e | ||
|
02cc1b9fe9 | ||
|
6d6a29a99d | ||
|
1d95f1c6d2 | ||
|
6e4bf932ec | ||
|
a9a8216f4d | ||
|
f98eb4a40d | ||
|
51920420ce | ||
|
d171cce45d | ||
|
5560ab4294 | ||
|
87ccd7bf46 | ||
|
d264c26310 | ||
|
e873ebd67d | ||
|
375636cd36 | ||
|
57f9bc06b0 | ||
|
97cae6c0cb | ||
|
1fd02b8a4a | ||
|
9734274ed1 | ||
|
3f2916967d | ||
|
0731de53b4 | ||
|
0f67d42c99 | ||
|
34ba8e89bc | ||
|
b1c6173995 | ||
|
dd87dcdd3d | ||
|
ffd7ba7d5f | ||
|
4ac03ef15a | ||
|
8daa0e7a9b | ||
|
982c3fef0d | ||
|
1757badf64 | ||
|
5196237c46 | ||
|
094a747db3 | ||
|
284f48f631 | ||
|
c2c889cab9 | ||
|
a2619a6e2b | ||
|
6e16e4724d | ||
|
9afcba4739 | ||
|
c05e8085ed | ||
|
6d86f40ca3 | ||
|
cc9e7130e8 | ||
|
809d18575d | ||
|
56b5a128f5 | ||
|
8915c29b31 | ||
|
819c8f3aa9 | ||
|
6c479fceed | ||
|
04de66bc8a | ||
|
32cc1b66a4 | ||
|
65a588ea20 | ||
|
e0a29ed6a0 | ||
|
fadfc490a7 | ||
|
fd7894caae | ||
|
8200fc2a98 | ||
|
4b6fc99a62 | ||
|
60b9d4fc80 | ||
|
7622c5c510 | ||
|
76f8cb96ca | ||
|
f6e56ce0f4 | ||
|
72596decba | ||
|
e8b8d26bdb | ||
|
d5cb9ab965 | ||
|
9914e187e2 | ||
|
36fa05f3a6 | ||
|
5641b1173c | ||
|
48f8eb9788 | ||
|
7f825750f0 | ||
|
102570958e | ||
|
38b6d79f49 | ||
|
d064c68875 | ||
|
2bb45022d6 | ||
|
dc2e23c85a | ||
|
5a54ef355f | ||
|
9af6bdb1d6 | ||
|
dca88382ab | ||
|
d4a495fb52 | ||
|
a4556e8cf0 | ||
|
c79bb03d5e | ||
|
9c793208ad | ||
|
b07b3fc373 | ||
|
ff92e0bf6f | ||
|
8854b3f565 | ||
|
6974abea28 | ||
|
9433acf689 | ||
|
11e8240c5c | ||
|
aa922c5b67 | ||
|
1a020698d1 | ||
|
022b8caa18 | ||
|
14c406f7fb | ||
|
4d877741d4 | ||
|
1cbd10a38e | ||
|
358456c8ea | ||
|
1c7dcfc63d | ||
|
82b225a261 | ||
|
6ab30159fa | ||
|
a86a1990cd | ||
|
625c7d0302 | ||
|
27a0552c2a | ||
|
7c5674c294 | ||
|
f5c442aa5c | ||
|
569af0bcf0 | ||
|
238748f360 | ||
|
e049364557 | ||
|
121966436e | ||
|
d3afd7a670 | ||
|
9d121af860 | ||
|
200ef0c8e2 | ||
|
6f77a2ba07 | ||
|
db97ce99ef | ||
|
e7b790861f | ||
|
d3aaf3c14a | ||
|
d732821e06 | ||
|
e628c36172 | ||
|
9312871250 | ||
|
860d446d28 | ||
|
03adb56d25 | ||
|
4aecc034c2 | ||
|
1543bfd550 | ||
|
a111a07bca | ||
|
9ec398b39b | ||
|
eb71097546 | ||
|
1bb3eb0d07 | ||
|
5395b6f73a | ||
|
5851c5a88b | ||
|
1c1726cfa4 | ||
|
a6bafca091 | ||
|
6877f95636 | ||
|
cb41b7ac33 | ||
|
d2fa4523ce | ||
|
9129386f12 | ||
|
c7fcb72d6c | ||
|
02ee314ab1 | ||
|
04af8ef329 | ||
|
a34c92d55a | ||
|
4cdf803ab7 | ||
|
6012086fa5 | ||
|
67c0f57756 | ||
|
164070b487 | ||
|
d658c75cec | ||
|
4c69412501 | ||
|
75a0164ea0 | ||
|
9dde04e4b8 | ||
|
3496df6468 | ||
|
ac794bb2b7 | ||
|
7384991efa | ||
|
f3dc846b1b | ||
|
4595c15bee | ||
|
81994160e8 | ||
|
cf59a90c52 | ||
|
a9a87710f3 | ||
|
5984cd5835 | ||
|
8fe0887141 | ||
|
8389a59d54 | ||
|
010245e1a5 | ||
|
1e3d2fbfd2 | ||
|
313df9988d | ||
|
16384159e7 | ||
|
06900e19f0 | ||
|
57c25bf151 | ||
|
55fc8bdd57 | ||
|
ae030b227a | ||
|
aaf25d8b9a | ||
|
0645d58594 | ||
|
11d22f95cc | ||
|
4f85751694 | ||
|
65a78a6ea9 | ||
|
9f52931191 | ||
|
93d0ab7906 | ||
|
6b0d0daa2e | ||
|
9718e654ac | ||
|
4d5121c21d | ||
|
531f40ceee | ||
|
b672d38db8 | ||
|
401498a4f7 | ||
|
acdad5c6ac | ||
|
1a0aa7970b | ||
|
579b30c8f7 | ||
|
c1fa543524 | ||
|
0297d22fac | ||
|
608ebfdb4a | ||
|
da337284e5 | ||
|
0aa9f79629 | ||
|
9f4d79a756 | ||
|
aa0935c64b | ||
|
16111b56ad | ||
|
4c0fc6e52f | ||
|
7668af15b0 | ||
|
3b9aa445e9 | ||
|
b2614e363b | ||
|
49e2c38289 | ||
|
3030093907 | ||
|
0e867df195 | ||
|
bfd6049913 | ||
|
d2c02569d0 | ||
|
1f6daa7424 | ||
|
30af6f36ce | ||
|
f712b56671 | ||
|
0462026f33 | ||
|
ea76161ba5 | ||
|
629dee3a91 | ||
|
f415924811 | ||
|
4172c563d0 | ||
|
ab67d0e232 | ||
|
5ea512817a | ||
|
d4c7ea1cd1 | ||
|
4edf1ad3f5 | ||
|
6224b07215 | ||
|
a5239ef601 | ||
|
458068ae87 | ||
|
44e920e441 | ||
|
f8450e39e3 | ||
|
c6e68f72ea | ||
|
4a52cd7c98 | ||
|
9d68261bac | ||
|
8bb50189bc | ||
|
eb665a059a | ||
|
f2407bcc31 | ||
|
a8cfbe1eab | ||
|
03b73072d9 | ||
|
48049f3870 | ||
|
d2c553652f | ||
|
3dc29be083 | ||
|
ee00fb77d0 | ||
|
d890418944 | ||
|
8e0560ae1a | ||
|
82e5447526 | ||
|
8b23f8608d | ||
|
0dd5134f5a | ||
|
a39a904c8a | ||
|
1d38b72835 | ||
|
efcab71969 | ||
|
41e11a738d | ||
|
62e1710607 | ||
|
c681befdf2 | ||
|
2db256678e | ||
|
a2ca381bbd | ||
|
32f5a31ea5 | ||
|
87dc671a0d | ||
|
621f9b4f48 | ||
|
3858e1cdd6 | ||
|
ff7cc5aec9 | ||
|
d18a47a643 | ||
|
497a08940e | ||
|
bd8fe521cd | ||
|
59c93901d3 | ||
|
3177f25eb6 | ||
|
b0fe189156 | ||
|
8103e822ed | ||
|
c597653ce2 | ||
|
d9ceb727ef | ||
|
2844af0039 |
7
.gitignore
vendored
7
.gitignore
vendored
@@ -32,4 +32,9 @@
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/
|
||||
/EssentialsUpdate/dist/
|
||||
/EssentialsUpdate/build/
|
||||
/WebPush/apikey.php
|
||||
|
||||
/WebPush/apikey.php
|
||||
/WebPush/apikey.php
|
@@ -601,6 +601,13 @@ is divided into following sections:
|
||||
<propertyfile file="${built-jar.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init,-check-automatic-build,-clean-after-automatic-build" name="-verify-automatic-build"/>
|
||||
<target depends="init" name="-check-automatic-build">
|
||||
@@ -1038,6 +1045,13 @@ is divided into following sections:
|
||||
<propertyfile file="${built-clean.properties}">
|
||||
<entry key="${basedir}" value=""/>
|
||||
</propertyfile>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsGroupManager}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsGroupManager}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
</target>
|
||||
<target depends="init" name="-do-clean">
|
||||
<delete dir="${build.dir}"/>
|
||||
|
@@ -3,8 +3,8 @@ build.xml.script.CRC32=3233ee78
|
||||
build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=4b596d89
|
||||
nbproject/build-impl.xml.script.CRC32=dbc81ee1
|
||||
nbproject/build-impl.xml.data.CRC32=a830bc14
|
||||
nbproject/build-impl.xml.script.CRC32=64a00ba6
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
|
@@ -1,6 +1,7 @@
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.processors.list=lombok.core.AnnotationProcessor
|
||||
annotation.processing.run.all.processors=false
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Essentials
|
||||
application.vendor=
|
||||
@@ -67,7 +68,8 @@ file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHO
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.junit-4.5.jar=../lib/junit_4/junit-4.5.jar
|
||||
file.reference.lombok-0.10.1.jar=../lib/lombok-0.10.1.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
@@ -78,7 +80,6 @@ jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.iCo6.jar}:\
|
||||
@@ -86,7 +87,10 @@ javac.classpath=\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}
|
||||
${file.reference.PermissionsBukkit-1.2.jar}:\
|
||||
${file.reference.lombok-0.10.1.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
@@ -107,6 +111,7 @@ javadoc.noindex=false
|
||||
javadoc.nonavbar=false
|
||||
javadoc.notree=false
|
||||
javadoc.private=false
|
||||
javadoc.reference.PermissionsEx.jar=../lib/PermissionsEx-javadoc.jar
|
||||
javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
@@ -123,6 +128,8 @@ jnlp.signing.keystore=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
reference.EssentialsGroupManager.jar=../EssentialsGroupManager/dist/EssentialsGroupManager.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
@@ -14,6 +14,15 @@
|
||||
<libraries xmlns="http://www.netbeans.org/ns/ant-project-libraries/1">
|
||||
<definitions>../lib/nblibraries.properties</definitions>
|
||||
</libraries>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1"/>
|
||||
<references xmlns="http://www.netbeans.org/ns/ant-project-references/1">
|
||||
<reference>
|
||||
<foreign-project>EssentialsGroupManager</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
</references>
|
||||
</configuration>
|
||||
</project>
|
||||
|
@@ -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");
|
||||
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
0
Essentials/src/com/earth2me/essentials/DescParseTickFormat.java
Executable file → Normal file
0
Essentials/src/com/earth2me/essentials/DescParseTickFormat.java
Executable file → Normal file
@@ -33,7 +33,6 @@ import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
import com.earth2me.essentials.signs.SignPlayerListener;
|
||||
import java.math.BigInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -58,12 +57,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient ItemDb itemDb;
|
||||
private transient EssentialsUpdateTimer updateTimer;
|
||||
private transient final Methods paymentMethod = new Methods();
|
||||
private transient final static boolean enableErrorLogging = false;
|
||||
private transient final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient UserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -94,32 +91,36 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
execTimer = new ExecuteTimer();
|
||||
execTimer.start();
|
||||
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
|
||||
if (javaversion == null || javaversion.length < 2 || Integer.parseInt(javaversion[1]) < 6)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Java version not supported! Please install Java 1.6. You have " + System.getProperty("java.version"));
|
||||
}
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
LOGGER.addHandler(errorHandler);
|
||||
}
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
execTimer.mark("Upgrade");
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
execTimer.mark("Settings");
|
||||
upgrade.afterSettings();
|
||||
execTimer.mark("Upgrade2");
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
execTimer.mark("Init(Usermap)");
|
||||
spawn = new Spawn(getServer(), this.getDataFolder());
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
execTimer.mark("Init(Spawn/Warp)");
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
execTimer.mark("Init(Worth/ItemDB)");
|
||||
reload();
|
||||
backup = new Backup(this);
|
||||
|
||||
@@ -188,8 +189,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.ENTITY_DAMAGE, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_COMBUST, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_DEATH, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.ENTITY_REGAIN_HEALTH, entityListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
||||
|
||||
//TODO: Check if this should be here, and not above before reload()
|
||||
jail = new Jail(this);
|
||||
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
|
||||
confList.add(jail);
|
||||
@@ -201,29 +204,25 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, jailPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, jailPlayerListener, Priority.High, this);
|
||||
|
||||
if (settings.isNetherEnabled() && getServer().getWorlds().size() < 2)
|
||||
{
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
if (getSettings().isUpdateEnabled())
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
|
||||
}
|
||||
execTimer.mark("RegListeners");
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials load " + timeroutput);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
LOGGER.removeHandler(errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -234,6 +233,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
for (IConf iConf : confList)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
execTimer.mark("Reload(" + iConf.getClass().getSimpleName() + ")");
|
||||
}
|
||||
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
@@ -483,14 +483,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
LOGGER.log(logRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
errorHandler.publish(logRecord);
|
||||
errorHandler.flush();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -613,10 +605,12 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public int broadcastMessage(final IUser sender, final String message)
|
||||
{
|
||||
if (sender == null) {
|
||||
if (sender == null)
|
||||
{
|
||||
return getServer().broadcastMessage(message);
|
||||
}
|
||||
if (sender.isHidden()) {
|
||||
if (sender.isHidden())
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
final Player[] players = getServer().getOnlinePlayers();
|
||||
@@ -633,11 +627,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return players.length;
|
||||
}
|
||||
|
||||
public Map<BigInteger, String> getErrors()
|
||||
{
|
||||
return errorHandler.getErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
@@ -93,7 +94,7 @@ public class EssentialsBlockListener extends BlockListener
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser)
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
@@ -8,12 +10,16 @@ import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEntityListener extends EntityListener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public EssentialsEntityListener(IEssentials ess)
|
||||
@@ -33,6 +39,7 @@ public class EssentialsEntityListener extends EntityListener
|
||||
{
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
attacker.updateActivity(true);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
@@ -69,16 +76,21 @@ 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("");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -87,7 +99,17 @@ public class EssentialsEntityListener extends EntityListener
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setFoodLevel(20);
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
{
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,128 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.math.BigInteger;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Handler;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.LogRecord;
|
||||
|
||||
|
||||
class EssentialsErrorHandler extends Handler
|
||||
{
|
||||
private final Map<BigInteger, String> errors = new HashMap<BigInteger, String>();
|
||||
private final List<LogRecord> records = new LinkedList<LogRecord>();
|
||||
|
||||
public EssentialsErrorHandler()
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publish(LogRecord lr)
|
||||
{
|
||||
if (lr.getThrown() == null || lr.getLevel().intValue() < Level.WARNING.intValue())
|
||||
{
|
||||
return;
|
||||
}
|
||||
synchronized (records)
|
||||
{
|
||||
records.add(lr);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void flush()
|
||||
{
|
||||
synchronized (records)
|
||||
{
|
||||
sortRecords();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws SecurityException
|
||||
{
|
||||
synchronized (records)
|
||||
{
|
||||
sortRecords();
|
||||
}
|
||||
}
|
||||
|
||||
private void sortRecords()
|
||||
{
|
||||
for (LogRecord lr : records)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (lr.getThrown() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Throwable tr = lr.getThrown();
|
||||
StackTraceElement[] elements = tr.getStackTrace();
|
||||
if (elements == null || elements.length <= 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean essentialsFound = false;
|
||||
for (StackTraceElement stackTraceElement : elements)
|
||||
{
|
||||
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
|
||||
{
|
||||
essentialsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!essentialsFound && tr.getCause() != null)
|
||||
{
|
||||
Throwable cause = tr.getCause();
|
||||
StackTraceElement[] elements2 = cause.getStackTrace();
|
||||
if (elements2 != null)
|
||||
{
|
||||
for (StackTraceElement stackTraceElement : elements2)
|
||||
{
|
||||
if (stackTraceElement.getClassName().contains("com.earth2me.essentials"))
|
||||
{
|
||||
essentialsFound = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("[").append(lr.getLevel().getName()).append("] ").append(lr.getMessage()).append("\n");
|
||||
sb.append(tr.getMessage()).append("\n");
|
||||
for (StackTraceElement stackTraceElement : tr.getStackTrace())
|
||||
{
|
||||
sb.append(stackTraceElement.toString()).append("\n");
|
||||
}
|
||||
if (tr.getCause() != null && tr.getCause().getStackTrace() != null)
|
||||
{
|
||||
sb.append(tr.getCause().getMessage()).append("\n");
|
||||
for (StackTraceElement stackTraceElement : tr.getCause().getStackTrace())
|
||||
{
|
||||
sb.append(stackTraceElement.toString()).append("\n");
|
||||
}
|
||||
}
|
||||
String errorReport = sb.toString();
|
||||
byte[] bytesOfMessage = errorReport.getBytes("UTF-8");
|
||||
MessageDigest md = MessageDigest.getInstance("MD5");
|
||||
BigInteger bi = new BigInteger(md.digest(bytesOfMessage));
|
||||
errors.put(bi, errorReport);
|
||||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
//Ignore all exceptions inside the exception handler
|
||||
}
|
||||
}
|
||||
records.clear();
|
||||
}
|
||||
|
||||
Map<BigInteger, String> getErrors()
|
||||
{
|
||||
return errors;
|
||||
}
|
||||
}
|
@@ -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;
|
||||
@@ -46,11 +47,10 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -107,113 +107,11 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
|
||||
Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) {
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
user.updateActivity(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
|
||||
{
|
||||
if (user.getJustPortaled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
final World world = user.getWorld() == nether ? worlds.get(0) : nether;
|
||||
|
||||
double factor;
|
||||
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
}
|
||||
else
|
||||
{
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
if (user.getWorld().getBlockAt(x, y, z - 1).getType() == Material.PORTAL)
|
||||
{
|
||||
z--;
|
||||
}
|
||||
if (user.getWorld().getBlockAt(x - 1, y, z).getType() == Material.PORTAL)
|
||||
{
|
||||
x--;
|
||||
}
|
||||
|
||||
x = (int)(x * factor);
|
||||
z = (int)(z * factor);
|
||||
loc = new Location(world, x + .5, y, z + .5);
|
||||
|
||||
Block dest = world.getBlockAt(x, y, z);
|
||||
NetherPortal portal = NetherPortal.findPortal(dest);
|
||||
if (portal == null)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
|
||||
{
|
||||
portal = NetherPortal.createPortal(dest);
|
||||
LOGGER.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("generatingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("usingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
|
||||
event.setFrom(loc);
|
||||
event.setTo(loc);
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(loc, new Trade("portal", ess));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
}
|
||||
user.setJustPortaled(true);
|
||||
user.sendMessage(Util.i18n("teleportingPortal"));
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
|
||||
user.setJustPortaled(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -268,8 +166,9 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
@@ -307,20 +206,21 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Disconnecting user " + event.getPlayer().toString() + " due to " + event.getResult().toString());
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
user.checkBanTimeout(currentTime);
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (user.isBanned())
|
||||
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -356,7 +256,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
user.setDisplayNick(user.getNick());
|
||||
}
|
||||
updateCompass(user);
|
||||
}
|
||||
@@ -419,6 +319,8 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
usePowertools(event);
|
||||
}
|
||||
|
||||
|
@@ -21,10 +21,9 @@ public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,6 +34,7 @@ public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
ess.getPaymentMethod().reset();
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
@@ -1,84 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
class EssentialsUpdateTimer implements Runnable
|
||||
{
|
||||
private transient URL url;
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
|
||||
|
||||
public EssentialsUpdateTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
try
|
||||
{
|
||||
url = new URL("http://essentialsupdate.appspot.com/check");
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String bukkitVersion = ess.getServer().getVersion();
|
||||
final Matcher versionMatch = pattern.matcher(bukkitVersion);
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
bukkitVersion = versionMatch.group(4);
|
||||
}
|
||||
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
|
||||
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
|
||||
final URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
final String ret = reader.readLine();
|
||||
writer.close();
|
||||
reader.close();
|
||||
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
|
||||
if (ret.startsWith("New Version"))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.admin.notices.update"))
|
||||
{
|
||||
user.sendMessage(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
84
Essentials/src/com/earth2me/essentials/ExecuteTimer.java
Normal file
84
Essentials/src/com/earth2me/essentials/ExecuteTimer.java
Normal file
@@ -0,0 +1,84 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class ExecuteTimer
|
||||
{
|
||||
private final List<ExecuteRecord> times;
|
||||
|
||||
public ExecuteTimer()
|
||||
{
|
||||
times = new ArrayList<ExecuteRecord>();
|
||||
}
|
||||
|
||||
public void start()
|
||||
{
|
||||
times.clear();
|
||||
mark("start");
|
||||
|
||||
}
|
||||
|
||||
public void mark(final String label)
|
||||
{
|
||||
if (!times.isEmpty() || "start".equals(label))
|
||||
{
|
||||
times.add(new ExecuteRecord(label, System.currentTimeMillis()));
|
||||
}
|
||||
}
|
||||
|
||||
public String end()
|
||||
{
|
||||
final StringBuilder output = new StringBuilder();
|
||||
output.append("execution time: ");
|
||||
String mark;
|
||||
long time0 = 0;
|
||||
long time1 = 0;
|
||||
long time2 = 0;
|
||||
long duration;
|
||||
|
||||
for (ExecuteRecord pair : times)
|
||||
{
|
||||
mark = (String)pair.getMark();
|
||||
time2 = (Long)pair.getTime();
|
||||
if (time1 > 0)
|
||||
{
|
||||
duration = time2 - time1;
|
||||
output.append(mark).append(": ").append(duration).append("ms - ");
|
||||
}
|
||||
else
|
||||
{
|
||||
time0 = time2;
|
||||
}
|
||||
time1 = time2;
|
||||
}
|
||||
duration = time1 - time0;
|
||||
output.append("Total: ").append(duration).append("ms");
|
||||
times.clear();
|
||||
return output.toString();
|
||||
}
|
||||
|
||||
|
||||
static private class ExecuteRecord
|
||||
{
|
||||
private final String mark;
|
||||
private final long time;
|
||||
|
||||
public ExecuteRecord(final String mark, final long time)
|
||||
{
|
||||
this.mark = mark;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
public String getMark()
|
||||
{
|
||||
return mark;
|
||||
}
|
||||
|
||||
public long getTime()
|
||||
{
|
||||
return time;
|
||||
}
|
||||
}
|
||||
}
|
190
Essentials/src/com/earth2me/essentials/FakeInventory.java
Normal file
190
Essentials/src/com/earth2me/essentials/FakeInventory.java
Normal 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;
|
||||
}
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ import java.util.UUID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Difficulty;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
@@ -437,4 +438,21 @@ public class FakeWorld implements World
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Difficulty getDifficulty()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDifficulty(Difficulty difficulty)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSeaLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@@ -35,8 +35,6 @@ public interface ISettings extends IConf
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
boolean getGenerateExitPortals();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
@@ -45,12 +43,6 @@ public interface ISettings extends IConf
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNetherName();
|
||||
|
||||
boolean getNetherPortalsEnabled();
|
||||
|
||||
double getNetherRatio();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
@@ -73,7 +65,11 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
int getMultipleHomes();
|
||||
List getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
int getHomeLimit(User user);
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
@@ -101,8 +97,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isNetherEnabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
@@ -113,8 +107,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean use1to1RatioInNether();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
@@ -132,12 +124,18 @@ public interface ISettings extends IConf
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean isUpdateEnabled();
|
||||
|
||||
boolean disablePrefix();
|
||||
|
||||
boolean disableSuffix();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
}
|
||||
|
@@ -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?
|
||||
|
@@ -26,11 +26,10 @@ public enum Mob
|
||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH);
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", CreatureType.SILVERFISH);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
|
@@ -1,167 +0,0 @@
|
||||
/**
|
||||
* @author SpaceManiac
|
||||
* @licent MIT
|
||||
* @origin https://github.com/SpaceManiac/Nether/blob/master/org/innectis/Nether/NetherPortal.java
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import java.util.ArrayList;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
public class NetherPortal
|
||||
{
|
||||
private Block block;
|
||||
|
||||
public NetherPortal(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
public Block getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(Block b)
|
||||
{
|
||||
block = b;
|
||||
}
|
||||
|
||||
// Return a random spawnable location
|
||||
public Location getSpawn()
|
||||
{
|
||||
if (block.getWorld().getBlockAt(block.getX() + 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL)
|
||||
|| block.getWorld().getBlockAt(block.getX() - 1, block.getY(), block.getZ()).getType().equals(Material.PORTAL))
|
||||
{
|
||||
// portal is in X direction
|
||||
return new Location(block.getWorld(), block.getX() + 1,
|
||||
block.getY(), block.getZ() + 1 - 2 * Math.round(Math.random()));
|
||||
}
|
||||
else
|
||||
{
|
||||
// portal is in Z direction
|
||||
return new Location(block.getWorld(), block.getX() + 1 - 2 * Math.round(Math.random()),
|
||||
block.getY(), block.getZ() + 1);
|
||||
}
|
||||
}
|
||||
|
||||
// ==============================
|
||||
// Find a nearby portal within 16 blocks of the given block
|
||||
// Not guaranteed to be the nearest
|
||||
public static NetherPortal findPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Get list of columns in a circle around the block
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x = dest.getX() - 16; x <= dest.getX() + 16; ++x)
|
||||
{
|
||||
for (int z = dest.getZ() - 16; z <= dest.getZ() + 16; ++z)
|
||||
{
|
||||
int dx = dest.getX() - x, dz = dest.getZ() - z;
|
||||
if (dx * dx + dz * dz <= 256)
|
||||
{
|
||||
columns.add(world.getBlockAt(x, 0, z));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// For each column try to find a portal block
|
||||
for (Block col : columns)
|
||||
{
|
||||
for (int y = 127; y >= 0; --y)
|
||||
{
|
||||
Block b = world.getBlockAt(col.getX(), y, col.getZ());
|
||||
if (b.getType().equals(Material.PORTAL) && Math.abs(dest.getY() - y) <= 16)
|
||||
{
|
||||
// Huzzah!
|
||||
return new NetherPortal(b);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Nope!
|
||||
return null;
|
||||
}
|
||||
|
||||
// Create a new portal at the specified block, fudging position if needed
|
||||
// Will occasionally end up making portals in bad places, but let's hope not
|
||||
public static NetherPortal createPortal(Block dest)
|
||||
{
|
||||
World world = dest.getWorld();
|
||||
|
||||
// Try not to spawn within water or lava
|
||||
Material m = dest.getType();
|
||||
while (((m.equals(Material.LAVA) || m.equals(Material.WATER) || m.equals(Material.STATIONARY_LAVA)
|
||||
|| m.equals(Material.STATIONARY_WATER) || m.equals(Material.SAND) || m.equals(Material.GRAVEL))) &&
|
||||
dest.getY() < 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), dest.getY() + 4, dest.getZ());
|
||||
m = dest.getType();
|
||||
}
|
||||
|
||||
// Not too high or too low overall
|
||||
if (dest.getY() > 120)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 120, dest.getZ());
|
||||
}
|
||||
else if (dest.getY() < 8)
|
||||
{
|
||||
dest = world.getBlockAt(dest.getX(), 8, dest.getZ());
|
||||
}
|
||||
|
||||
// Create the physical portal
|
||||
// For now, don't worry about direction
|
||||
|
||||
int x = dest.getX(), y = dest.getY(), z = dest.getZ();
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, Util.format("creatingPortal", x, y, z));
|
||||
|
||||
// Clear area around portal
|
||||
ArrayList<Block> columns = new ArrayList<Block>();
|
||||
for (int x2 = x - 4; x2 <= x + 4; ++x2)
|
||||
{
|
||||
for (int z2 = z - 4; z2 <= z + 4; ++z2)
|
||||
{
|
||||
double dx = x + 0.5f - x2, dz = z - z2;
|
||||
if (dx * dx + dz * dz <= 13)
|
||||
{
|
||||
columns.add(world.getBlockAt(x2, 0, z2));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Clear area around portal
|
||||
for (Block col : columns)
|
||||
{
|
||||
// Stone platform
|
||||
world.getBlockAt(col.getX(), y - 1, col.getZ()).setType(Material.STONE);
|
||||
for (int yd = 0; yd < 4; ++yd)
|
||||
{
|
||||
world.getBlockAt(col.getX(), y + yd, col.getZ()).setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
// Build obsidian frame
|
||||
for (int xd = -1; xd < 3; ++xd)
|
||||
{
|
||||
for (int yd = -1; yd < 4; ++yd)
|
||||
{
|
||||
if (xd == -1 || yd == -1 || xd == 2 || yd == 3)
|
||||
{
|
||||
world.getBlockAt(x + xd, y + yd, z).setType(Material.OBSIDIAN);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Set it alight!
|
||||
dest.setType(Material.FIRE);
|
||||
|
||||
return new NetherPortal(dest);
|
||||
}
|
||||
}
|
@@ -5,6 +5,7 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -35,40 +36,32 @@ import org.bukkit.util.Vector;
|
||||
|
||||
public class OfflinePlayer implements Player
|
||||
{
|
||||
private final String name;
|
||||
final transient IEssentials ess;
|
||||
private final transient IEssentials ess;
|
||||
private Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private World world;
|
||||
private UUID uniqueId = UUID.randomUUID();
|
||||
private org.bukkit.OfflinePlayer base;
|
||||
@Delegate(types=org.bukkit.OfflinePlayer.class)
|
||||
private final org.bukkit.OfflinePlayer base;
|
||||
|
||||
public OfflinePlayer(String name, IEssentials ess)
|
||||
public OfflinePlayer(final String name, final IEssentials ess)
|
||||
{
|
||||
this.name = name;
|
||||
this.ess = ess;
|
||||
this.world = ess.getServer().getWorlds().get(0);
|
||||
this.base = ess.getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return base.isOnline();
|
||||
}
|
||||
|
||||
public boolean isOp()
|
||||
{
|
||||
return base.isOp();
|
||||
}
|
||||
|
||||
public void sendMessage(String string)
|
||||
@Override
|
||||
public void sendMessage(final String string)
|
||||
{
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
return name;
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String string)
|
||||
{
|
||||
}
|
||||
@@ -86,11 +79,6 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
}
|
||||
|
||||
public String getName()
|
||||
{
|
||||
return name;
|
||||
}
|
||||
|
||||
public PlayerInventory getInventory()
|
||||
{
|
||||
return null;
|
||||
@@ -576,42 +564,13 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
@@ -695,7 +654,7 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
@@ -713,5 +672,28 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void setPlayerListName(String name)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerListName()
|
||||
{
|
||||
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.");
|
||||
}
|
||||
}
|
||||
|
@@ -1,37 +1,53 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import net.minecraft.server.EntityPlayer;
|
||||
import net.minecraft.server.IInventory;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.serialization.ConfigurationSerializable;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.permissions.Permissible;
|
||||
import org.bukkit.permissions.ServerOperator;
|
||||
|
||||
|
||||
public class PlayerExtension extends PlayerWrapper
|
||||
public class PlayerExtension implements Player
|
||||
{
|
||||
protected final IEssentials ess;
|
||||
|
||||
public PlayerExtension(Player base, IEssentials ess)
|
||||
protected final transient IEssentials ess;
|
||||
@Delegate(types =
|
||||
{
|
||||
super(base);
|
||||
Player.class, Entity.class, CommandSender.class, ServerOperator.class,
|
||||
HumanEntity.class, ConfigurationSerializable.class, LivingEntity.class,
|
||||
Permissible.class
|
||||
})
|
||||
protected Player base;
|
||||
|
||||
public PlayerExtension(final Player base, final IEssentials ess)
|
||||
{
|
||||
this.base = base;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||
if (angle < 0) {
|
||||
angle += 360.0f;
|
||||
}
|
||||
return angle;
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(final Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
public void showInventory(IInventory inventory)
|
||||
public void showInventory(final IInventory inventory)
|
||||
{
|
||||
getHandle().a(inventory);
|
||||
}
|
||||
|
||||
public void showInventory(CraftInventoryPlayer inventory)
|
||||
public void showInventory(final CraftInventoryPlayer inventory)
|
||||
{
|
||||
showInventory((IInventory)inventory.getInventory());
|
||||
}
|
||||
@@ -46,7 +62,7 @@ public class PlayerExtension extends PlayerWrapper
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(String group)
|
||||
public boolean inGroup(final String group)
|
||||
{
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
@@ -1,747 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class PlayerWrapper implements Player
|
||||
{
|
||||
protected Player base;
|
||||
|
||||
public PlayerWrapper(Player base)
|
||||
{
|
||||
this.base = base;
|
||||
}
|
||||
|
||||
public final Player getBase()
|
||||
{
|
||||
return base;
|
||||
}
|
||||
|
||||
public final Player setBase(Player base)
|
||||
{
|
||||
return this.base = base;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDisplayName(String string)
|
||||
{
|
||||
base.setDisplayName(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setCompassTarget(Location lctn)
|
||||
{
|
||||
base.setCompassTarget(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public InetSocketAddress getAddress()
|
||||
{
|
||||
return base.getAddress();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void kickPlayer(String string)
|
||||
{
|
||||
base.kickPlayer(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getName()
|
||||
{
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public PlayerInventory getInventory()
|
||||
{
|
||||
return base.getInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInHand()
|
||||
{
|
||||
return base.getItemInHand();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInHand(ItemStack is)
|
||||
{
|
||||
base.setItemInHand(is);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHealth()
|
||||
{
|
||||
return base.getHealth();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setHealth(int i)
|
||||
{
|
||||
base.setHealth(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Egg throwEgg()
|
||||
{
|
||||
return base.throwEgg();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Snowball throwSnowball()
|
||||
{
|
||||
return base.throwSnowball();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Arrow shootArrow()
|
||||
{
|
||||
return base.shootArrow();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInsideVehicle()
|
||||
{
|
||||
return base.isInsideVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean leaveVehicle()
|
||||
{
|
||||
return base.leaveVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vehicle getVehicle()
|
||||
{
|
||||
return base.getVehicle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getLocation()
|
||||
{
|
||||
return base.getLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld()
|
||||
{
|
||||
return base.getWorld();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Server getServer()
|
||||
{
|
||||
return base.getServer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOnline()
|
||||
{
|
||||
return base.isOnline();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isOp()
|
||||
{
|
||||
return base.isOp();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Location lctn)
|
||||
{
|
||||
return base.teleport(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean teleport(Entity entity)
|
||||
{
|
||||
return base.teleport(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String string)
|
||||
{
|
||||
base.sendMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setVelocity(Vector vector)
|
||||
{
|
||||
base.setVelocity(vector);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Vector getVelocity()
|
||||
{
|
||||
return base.getVelocity();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight()
|
||||
{
|
||||
return base.getEyeHeight();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getEyeHeight(boolean bln)
|
||||
{
|
||||
return base.getEyeHeight(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLineOfSight(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getLineOfSight(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Block getTargetBlock(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getTargetBlock(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Block> getLastTwoTargetBlocks(HashSet<Byte> hs, int i)
|
||||
{
|
||||
return base.getLastTwoTargetBlocks(hs, i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFireTicks()
|
||||
{
|
||||
return base.getFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxFireTicks()
|
||||
{
|
||||
return base.getMaxFireTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFireTicks(int i)
|
||||
{
|
||||
base.setFireTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void remove()
|
||||
{
|
||||
base.remove();
|
||||
}
|
||||
|
||||
/**
|
||||
* This is not deprecated because the underlying method isn't really deprecated; rather, it's just "imperfect". By
|
||||
* We will continue to use this method even after the underlying CraftBukkit method is changed, so do not deprecate
|
||||
* it. Chances are Bukkit will also choose to un-deprecate this method at some point.
|
||||
*/
|
||||
@Override
|
||||
public void updateInventory()
|
||||
{
|
||||
base.updateInventory();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void chat(String string)
|
||||
{
|
||||
base.chat(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSneaking()
|
||||
{
|
||||
return base.isSneaking();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSneaking(boolean bln)
|
||||
{
|
||||
base.setSneaking(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getEntityId()
|
||||
{
|
||||
return base.getEntityId();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean performCommand(String string)
|
||||
{
|
||||
return base.performCommand(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir()
|
||||
{
|
||||
return base.getRemainingAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setRemainingAir(int i)
|
||||
{
|
||||
base.setRemainingAir(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumAir()
|
||||
{
|
||||
return base.getMaximumAir();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumAir(int i)
|
||||
{
|
||||
base.setMaximumAir(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (base.getDisplayName() != null)
|
||||
return base.getDisplayName();
|
||||
else
|
||||
return base.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i)
|
||||
{
|
||||
base.damage(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void damage(int i, Entity entity)
|
||||
{
|
||||
base.damage(i, entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getEyeLocation()
|
||||
{
|
||||
return base.getEyeLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendRawMessage(String string) {
|
||||
base.sendRawMessage(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getCompassTarget()
|
||||
{
|
||||
return base.getCompassTarget();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaximumNoDamageTicks()
|
||||
{
|
||||
return base.getMaximumNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMaximumNoDamageTicks(int i)
|
||||
{
|
||||
base.setMaximumNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLastDamage()
|
||||
{
|
||||
return base.getLastDamage();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastDamage(int i)
|
||||
{
|
||||
base.setLastDamage(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getNoDamageTicks()
|
||||
{
|
||||
return base.getNoDamageTicks();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setNoDamageTicks(int i)
|
||||
{
|
||||
base.setNoDamageTicks(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Entity getPassenger()
|
||||
{
|
||||
return base.getPassenger();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setPassenger(Entity entity)
|
||||
{
|
||||
return base.setPassenger(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEmpty()
|
||||
{
|
||||
return base.isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean eject()
|
||||
{
|
||||
return base.eject();
|
||||
}
|
||||
|
||||
public void saveData()
|
||||
{
|
||||
base.saveData();
|
||||
}
|
||||
|
||||
public void loadData()
|
||||
{
|
||||
base.loadData();
|
||||
}
|
||||
|
||||
public boolean isSleeping()
|
||||
{
|
||||
return base.isSleeping();
|
||||
}
|
||||
|
||||
public int getSleepTicks()
|
||||
{
|
||||
return base.getSleepTicks();
|
||||
}
|
||||
|
||||
public List<Entity> getNearbyEntities(double d, double d1, double d2)
|
||||
{
|
||||
return base.getNearbyEntities(d, d1, d2);
|
||||
}
|
||||
|
||||
public boolean isDead()
|
||||
{
|
||||
return base.isDead();
|
||||
}
|
||||
|
||||
public float getFallDistance()
|
||||
{
|
||||
return base.getFallDistance();
|
||||
}
|
||||
|
||||
public void setFallDistance(float f)
|
||||
{
|
||||
base.setFallDistance(f);
|
||||
}
|
||||
|
||||
public void setSleepingIgnored(boolean bln)
|
||||
{
|
||||
base.setSleepingIgnored(bln);
|
||||
}
|
||||
|
||||
public boolean isSleepingIgnored()
|
||||
{
|
||||
return base.isSleepingIgnored();
|
||||
}
|
||||
|
||||
public void awardAchievement(Achievement a)
|
||||
{
|
||||
base.awardAchievement(a);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc)
|
||||
{
|
||||
base.incrementStatistic(ststc);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, int i)
|
||||
{
|
||||
base.incrementStatistic(ststc, i);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl)
|
||||
{
|
||||
base.incrementStatistic(ststc, mtrl);
|
||||
}
|
||||
|
||||
public void incrementStatistic(Statistic ststc, Material mtrl, int i)
|
||||
{
|
||||
base.incrementStatistic(ststc, mtrl, i);
|
||||
}
|
||||
|
||||
public void playNote(Location lctn, byte b, byte b1)
|
||||
{
|
||||
base.playNote(lctn, b, b1);
|
||||
}
|
||||
|
||||
public void sendBlockChange(Location lctn, Material mtrl, byte b)
|
||||
{
|
||||
base.sendBlockChange(lctn, mtrl, b);
|
||||
}
|
||||
|
||||
public void sendBlockChange(Location lctn, int i, byte b)
|
||||
{
|
||||
base.sendBlockChange(lctn, i, b);
|
||||
}
|
||||
|
||||
public void setLastDamageCause(EntityDamageEvent ede)
|
||||
{
|
||||
base.setLastDamageCause(ede);
|
||||
|
||||
}
|
||||
|
||||
public EntityDamageEvent getLastDamageCause()
|
||||
{
|
||||
return base.getLastDamageCause();
|
||||
}
|
||||
|
||||
public void playEffect(Location lctn, Effect effect, int i)
|
||||
{
|
||||
base.playEffect(lctn, effect, i);
|
||||
}
|
||||
|
||||
public boolean sendChunkChange(Location lctn, int i, int i1, int i2, byte[] bytes)
|
||||
{
|
||||
return base.sendChunkChange(lctn, i, i1, i2, bytes);
|
||||
}
|
||||
|
||||
public UUID getUniqueId()
|
||||
{
|
||||
return base.getUniqueId();
|
||||
}
|
||||
|
||||
public void playNote(Location lctn, Instrument i, Note note)
|
||||
{
|
||||
base.playNote(lctn, i, note);
|
||||
}
|
||||
|
||||
public void setPlayerTime(long l, boolean bln)
|
||||
{
|
||||
base.setPlayerTime(l, bln);
|
||||
}
|
||||
|
||||
public long getPlayerTime()
|
||||
{
|
||||
return base.getPlayerTime();
|
||||
}
|
||||
|
||||
public long getPlayerTimeOffset()
|
||||
{
|
||||
return base.getPlayerTimeOffset();
|
||||
}
|
||||
|
||||
public boolean isPlayerTimeRelative()
|
||||
{
|
||||
return base.isPlayerTimeRelative();
|
||||
}
|
||||
|
||||
public void resetPlayerTime()
|
||||
{
|
||||
base.resetPlayerTime();
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(String string)
|
||||
{
|
||||
return base.isPermissionSet(string);
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(Permission prmsn)
|
||||
{
|
||||
return base.isPermissionSet(prmsn);
|
||||
}
|
||||
|
||||
public boolean hasPermission(String string)
|
||||
{
|
||||
return base.hasPermission(string);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
return base.hasPermission(prmsn);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
|
||||
{
|
||||
return base.addAttachment(plugin, string, bln);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
return base.addAttachment(plugin);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
|
||||
{
|
||||
return base.addAttachment(plugin, string, bln, i);
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int i)
|
||||
{
|
||||
return base.addAttachment(plugin, i);
|
||||
}
|
||||
|
||||
public void removeAttachment(PermissionAttachment pa)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
base.recalculatePermissions();
|
||||
}
|
||||
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
return base.getEffectivePermissions();
|
||||
}
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
base.sendMap(mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
return base.getGameMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
base.setGameMode(gm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
return base.getExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
base.setExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
return base.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
base.setLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
return base.getTotalExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
base.setTotalExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
return base.getExhaustion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
base.setExhaustion(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
return base.getSaturation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
base.setSaturation(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
return base.getFoodLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
base.setFoodLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return base.getBedSpawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
return base.isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
base.setSprinting(bln);
|
||||
}
|
||||
|
||||
}
|
@@ -30,12 +30,6 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultipleHomes()
|
||||
{
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
@@ -43,6 +37,39 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("bed-sethome", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMultipleHomes()
|
||||
{
|
||||
return config.getKeys("sethome-multiple");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final List<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
// return getHomeLimit("default");
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
int limit = getHomeLimit("default");
|
||||
for (String set : homeList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple." + set) && (limit < getHomeLimit(set)))
|
||||
{
|
||||
limit = getHomeLimit(set);
|
||||
}
|
||||
}
|
||||
return limit;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final String set)
|
||||
{
|
||||
return config.getInt("sethome-multiple." + set, config.getInt("sethome-multiple.default", 3));
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
@@ -60,19 +87,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
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)
|
||||
{
|
||||
@@ -84,7 +105,10 @@ public class Settings implements ISettings
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
||||
@@ -101,18 +125,24 @@ public class Settings implements ISettings
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
@@ -126,7 +156,9 @@ public class Settings implements ISettings
|
||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return config.getBoolean("override-" + name.toLowerCase(), false);
|
||||
@@ -143,7 +175,9 @@ public class Settings implements ISettings
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
if (cost == 0.0)
|
||||
{
|
||||
cost = config.getDouble("cost-" + label, 0.0);
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
|
||||
@@ -171,13 +205,14 @@ public class Settings implements ISettings
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||
{
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_'))) {
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||
{
|
||||
return entry.getValue();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
{
|
||||
@@ -190,9 +225,13 @@ public class Settings implements ISettings
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
|
||||
if (colorName == null)
|
||||
{
|
||||
return ChatColor.RED;
|
||||
if("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
}
|
||||
if ("none".equalsIgnoreCase(colorName) || colorName.isEmpty())
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
@@ -211,35 +250,23 @@ public class Settings implements ISettings
|
||||
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()
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
@@ -272,12 +299,6 @@ public class Settings implements ISettings
|
||||
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()
|
||||
{
|
||||
@@ -301,12 +322,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
@@ -314,7 +336,8 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
@@ -322,16 +345,21 @@ public class Settings implements ISettings
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
try
|
||||
{
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
}
|
||||
}
|
||||
@@ -350,33 +378,20 @@ public class Settings implements ISettings
|
||||
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)) {
|
||||
return 1.0;
|
||||
}
|
||||
return config.getDouble("nether.ratio", 16.0);
|
||||
}
|
||||
private boolean debug = false;
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return config.getBoolean("debug", false);
|
||||
return debug || config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite" ,true);
|
||||
return config.getBoolean("warn-on-smite", true);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
@@ -410,23 +425,28 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
|
||||
return config.getBoolean("protect.prevent.spawn." + creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(",")) {
|
||||
for (String itemName : config.getString(configName, "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try {
|
||||
try
|
||||
{
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
@@ -444,12 +464,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY) {
|
||||
if (Math.abs(max) > MAXMONEY)
|
||||
{
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
@@ -459,7 +480,7 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
@@ -479,11 +500,15 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdateEnabled()
|
||||
|
||||
public boolean disablePrefix()
|
||||
{
|
||||
return config.getBoolean("update-check", false);
|
||||
return config.getBoolean("disablePrefix", false);
|
||||
}
|
||||
|
||||
public boolean disableSuffix()
|
||||
{
|
||||
return config.getBoolean("disableSuffix", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -503,4 +528,16 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDebug(final boolean debug)
|
||||
{
|
||||
this.debug = debug;
|
||||
}
|
||||
}
|
||||
|
@@ -9,20 +9,23 @@ import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.World.Environment;
|
||||
|
||||
public class Spawn implements IConf {
|
||||
|
||||
public class Spawn implements IConf
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final EssentialsConf config;
|
||||
private final Server server;
|
||||
|
||||
public Spawn(Server server, File dataFolder) {
|
||||
public Spawn(Server server, File dataFolder)
|
||||
{
|
||||
File configFile = new File(dataFolder, "spawn.yml");
|
||||
this.server = server;
|
||||
config = new EssentialsConf(configFile);
|
||||
config.load();
|
||||
}
|
||||
|
||||
public void setSpawn(Location loc, String group) {
|
||||
public void setSpawn(Location loc, String group)
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("world", loc.getWorld().getName());
|
||||
map.put("x", loc.getX());
|
||||
@@ -33,18 +36,24 @@ public class Spawn implements IConf {
|
||||
config.setProperty(group, map);
|
||||
config.save();
|
||||
|
||||
if ("default".equals(group)) {
|
||||
if ("default".equals(group))
|
||||
{
|
||||
loc.getWorld().setSpawnLocation(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
}
|
||||
}
|
||||
|
||||
public Location getSpawn(String group) {
|
||||
if (config.getProperty(group) == null) {
|
||||
public Location getSpawn(String group)
|
||||
{
|
||||
if (config.getProperty(group) == null)
|
||||
{
|
||||
group = "default";
|
||||
}
|
||||
if (config.getProperty(group) == null) {
|
||||
for (World w : server.getWorlds()) {
|
||||
if (w.getEnvironment() != Environment.NORMAL) {
|
||||
if (config.getProperty(group) == null)
|
||||
{
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
if (w.getEnvironment() != Environment.NORMAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return w.getSpawnLocation();
|
||||
@@ -52,15 +61,19 @@ public class Spawn implements IConf {
|
||||
}
|
||||
String worldId = config.getString(group + ".world", "");
|
||||
World world = server.getWorlds().get(server.getWorlds().size() > 1 ? 1 : 0);
|
||||
for (World w : server.getWorlds()) {
|
||||
if (w.getEnvironment() != Environment.NORMAL) {
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
if (w.getEnvironment() != Environment.NORMAL)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
world = w;
|
||||
break;
|
||||
}
|
||||
for (World w : server.getWorlds()) {
|
||||
if (!w.getName().equals(worldId)) {
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
if (!w.getName().equals(worldId))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
world = w;
|
||||
@@ -70,18 +83,20 @@ public class Spawn implements IConf {
|
||||
double x = config.getDouble(group + ".x", config.getDouble("default.x", 0));
|
||||
double y = config.getDouble(group + ".y", config.getDouble("default.y", 0));
|
||||
double z = config.getDouble(group + ".z", config.getDouble("default.z", 0));
|
||||
float yaw = (float) config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
|
||||
float pitch = (float) config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
|
||||
float yaw = (float)config.getDouble(group + ".yaw", config.getDouble("default.yaw", 0));
|
||||
float pitch = (float)config.getDouble(group + ".pitch", config.getDouble("default.pitch", 0));
|
||||
Location retval = new Location(world, x, y, z, yaw, pitch);
|
||||
|
||||
if (y < 1) {
|
||||
if (y < 1)
|
||||
{
|
||||
retval.setY(world.getHighestBlockYAt(retval));
|
||||
}
|
||||
|
||||
return retval;
|
||||
}
|
||||
|
||||
public void reloadConfig() {
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
}
|
||||
|
@@ -37,7 +37,8 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1) {
|
||||
if (timer != -1)
|
||||
{
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
@@ -54,28 +55,31 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
try
|
||||
{
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
final Location loc = event.getLocation();
|
||||
for (Player player : players)
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
if (player.getWorld().equals(loc.getWorld()))
|
||||
{
|
||||
blocksUnderPlayers.add(new ChunkPosition(player.getLocation().getBlockX(), player.getLocation().getBlockY() - 1, player.getLocation().getBlockZ()));
|
||||
}
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
}
|
||||
for (Block block : event.blockList())
|
||||
catch (Throwable ex)
|
||||
{
|
||||
final ChunkPosition cp = new ChunkPosition(block.getX(), block.getY(), block.getZ());
|
||||
if (!blocksUnderPlayers.contains(cp))
|
||||
{
|
||||
set.add(cp);
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
|
@@ -10,6 +10,7 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
* Original authors: toi & Raphfrk
|
||||
*/
|
||||
@Deprecated
|
||||
public class TargetBlock
|
||||
{
|
||||
private transient final Location location;
|
||||
|
@@ -256,7 +256,7 @@ public class Teleport implements Runnable
|
||||
|
||||
public void back() throws Exception
|
||||
{
|
||||
back(null);
|
||||
now(new Target(user.getLastLocation()));
|
||||
}
|
||||
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
|
@@ -72,19 +72,33 @@ public class Trade
|
||||
|
||||
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
|
||||
@@ -228,7 +242,8 @@ public class Trade
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null) {
|
||||
if (fw != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
|
@@ -12,7 +12,6 @@ import org.bukkit.entity.Player;
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private boolean justPortaled = false;
|
||||
private CommandSender replyTo = null;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
@@ -20,14 +19,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient boolean godStateBeforeAfk;
|
||||
private transient Location afkPosition;
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
@@ -158,16 +155,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
public boolean getJustPortaled()
|
||||
{
|
||||
return justPortaled;
|
||||
}
|
||||
|
||||
public void setJustPortaled(final boolean value)
|
||||
{
|
||||
justPortaled = value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
@@ -271,12 +258,21 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.insert(0, prefix);
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
@@ -285,6 +281,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public void setDisplayNick(String name)
|
||||
{
|
||||
setDisplayName(name);
|
||||
setPlayerListName(name.length() > 16 ? name.substring(0, 16) : name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayNick(getNick());
|
||||
}
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
@@ -348,16 +360,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
if (set && !isAfk())
|
||||
{
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
super.setAfk(set);
|
||||
@@ -381,7 +385,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public void checkJailTimeout(final long currentTime)
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
@@ -396,26 +401,34 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkMuteTimeout(final long currentTime)
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(Util.i18n("canTalkAgain"));
|
||||
setMuted(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void checkBanTimeout(final long currentTime)
|
||||
//Returns true if status expired during this check
|
||||
public boolean checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
@@ -451,10 +464,11 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis() && isAuthorized("essentials.afk"))
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden()) {
|
||||
if (!isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -468,9 +482,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled()) {
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
return super.isGodModeEnabled() || (isAfk() && ess.getSettings().getFreezeAfkPlayers());
|
||||
}
|
||||
}
|
||||
|
@@ -52,12 +52,14 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
jailTimeout = _getJailTimeout();
|
||||
lastLogin = _getLastLogin();
|
||||
lastLogout = _getLastLogout();
|
||||
lastLoginAddress = _getLastLoginAddress();
|
||||
afk = getAfk();
|
||||
newplayer = getNew();
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -154,6 +156,8 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
//Invalid names will corrupt the yaml
|
||||
name = Util.sanitizeFileName(name);
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
@@ -161,7 +165,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
if (getHome(name) != null)
|
||||
String search = name;
|
||||
if (!homes.containsKey(search))
|
||||
{
|
||||
search = Util.sanitizeFileName(name);
|
||||
}
|
||||
if (homes.containsKey(search))
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
@@ -241,12 +250,13 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
}
|
||||
|
||||
public void clearAllPowertools() {
|
||||
public void clearAllPowertools()
|
||||
{
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
@@ -265,12 +275,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return powertools.size() > 0;
|
||||
}
|
||||
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
@@ -292,6 +301,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setLastLocation(Location loc)
|
||||
{
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
lastLocation = loc;
|
||||
config.setProperty("lastlocation", loc);
|
||||
config.save();
|
||||
@@ -656,6 +669,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("timestamps.login", time);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private long lastLogout;
|
||||
|
||||
private long _getLastLogout()
|
||||
@@ -674,6 +688,26 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("timestamps.logout", time);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private String lastLoginAddress;
|
||||
|
||||
private String _getLastLoginAddress()
|
||||
{
|
||||
return config.getString("ipAddress", "");
|
||||
}
|
||||
|
||||
public String getLastLoginAddress()
|
||||
{
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean afk;
|
||||
|
||||
private boolean getAfk()
|
||||
@@ -779,31 +813,57 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
|
||||
private Map<String, Object> kitTimestamps;
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
final Object map = config.getProperty("timestamps.kits");
|
||||
|
||||
if (map instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)map;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
{
|
||||
final Number num = (Number)kitTimestamps.get(name.toLowerCase());
|
||||
return num == null ? null : num.longValue();
|
||||
}
|
||||
|
||||
public void setKitTimestamp(final String name, final long time)
|
||||
{
|
||||
kitTimestamps.put(name.toLowerCase(), time);
|
||||
config.setProperty("timestamps.kits", kitTimestamps);
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
|
@@ -52,7 +52,7 @@ public class UserMap implements Function<String, User>, IConf
|
||||
}
|
||||
catch (ComputationException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex);
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user " + name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -28,6 +28,8 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Util
|
||||
@@ -221,36 +223,57 @@ public class Util
|
||||
|
||||
// The player can stand inside these materials
|
||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
||||
private static final HashSet<Byte> AIR_MATERIALS_TARGET = new HashSet<Byte>();
|
||||
|
||||
static {
|
||||
AIR_MATERIALS.add(Material.AIR.getId());
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.LONG_GRASS.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LEVER.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.SOIL.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.VINE.getId());
|
||||
//TODO: Add 1.9 materials
|
||||
|
||||
for (Integer integer : AIR_MATERIALS)
|
||||
{
|
||||
AIR_MATERIALS_TARGET.add(integer.byteValue());
|
||||
}
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.WATER.getId());
|
||||
AIR_MATERIALS_TARGET.add((byte)Material.STATIONARY_WATER.getId());
|
||||
}
|
||||
|
||||
public static Location getTarget(final LivingEntity entity) throws Exception {
|
||||
final Block block = entity.getTargetBlock(AIR_MATERIALS_TARGET, 300);
|
||||
if (block == null) {
|
||||
throw new Exception("Not targeting a block");
|
||||
}
|
||||
return block.getLocation();
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
@@ -260,9 +283,9 @@ public class Util
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
}
|
||||
final World world = loc.getWorld();
|
||||
int x = (int)Math.round(loc.getX());
|
||||
int x = loc.getBlockX();
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = (int)Math.round(loc.getZ());
|
||||
int z = loc.getBlockZ();
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
|
@@ -21,28 +21,34 @@ public class Worth implements IConf
|
||||
{
|
||||
String itemname = itemStack.getType().toString().toLowerCase().replace("_", "");
|
||||
double result;
|
||||
result = config.getDouble("worth."+itemname+"."+itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth."+itemname+".0", Double.NaN);
|
||||
result = config.getDouble("worth." + itemname + "." + itemStack.getDurability(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname + ".0", Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth."+itemname, Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth." + itemname, Double.NaN);
|
||||
}
|
||||
if (Double.isNaN(result)) {
|
||||
result = config.getDouble("worth-"+itemStack.getTypeId(), Double.NaN);
|
||||
if (Double.isNaN(result))
|
||||
{
|
||||
result = config.getDouble("worth-" + itemStack.getTypeId(), Double.NaN);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
public void setPrice(ItemStack itemStack, double price)
|
||||
{
|
||||
if (itemStack.getType().getData() == null) {
|
||||
if (itemStack.getType().getData() == null)
|
||||
{
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", ""), price);
|
||||
} else {
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "")+"."+itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-"+itemStack.getTypeId());
|
||||
else
|
||||
{
|
||||
// Bukkit-bug: getDurability still contains the correct value, while getData().getData() is 0.
|
||||
config.setProperty("worth." + itemStack.getType().toString().toLowerCase().replace("_", "") + "." + itemStack.getDurability(), price);
|
||||
}
|
||||
config.removeProperty("worth-" + itemStack.getTypeId());
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -50,5 +56,4 @@ public class Worth implements IConf
|
||||
{
|
||||
config.load();
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -46,7 +46,7 @@ public class Commandban extends EssentialsCommand
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
player.setBanReason(commandLabel);
|
||||
player.setBanReason(banReason);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -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,29 @@ 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
|
||||
{
|
||||
final String ipAddress = u.getLastLoginAddress();
|
||||
if (ipAddress.length() == 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
ess.getServer().banIP(u.getLastLoginAddress());
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -31,14 +30,10 @@ public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
};
|
||||
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
|
||||
final Location loc = Util.getTarget(user);
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, tree);
|
||||
if (success)
|
||||
{
|
||||
user.sendMessage(Util.i18n("bigTreeSuccess"));
|
||||
|
@@ -15,17 +15,44 @@ 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() + 180 + 360) % 360;
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
else if (r < 68) dir = "NE";
|
||||
else if (r < 113) dir = "E";
|
||||
else if (r < 158) dir = "SE";
|
||||
else if (r < 203) dir = "S";
|
||||
else if (r < 248) dir = "SW";
|
||||
else if (r < 293) dir = "W";
|
||||
else if (r < 338) dir = "NW";
|
||||
else dir = "N";
|
||||
if (r < 23)
|
||||
{
|
||||
dir = "N";
|
||||
}
|
||||
else if (r < 68)
|
||||
{
|
||||
dir = "NE";
|
||||
}
|
||||
else if (r < 113)
|
||||
{
|
||||
dir = "E";
|
||||
}
|
||||
else if (r < 158)
|
||||
{
|
||||
dir = "SE";
|
||||
}
|
||||
else if (r < 203)
|
||||
{
|
||||
dir = "S";
|
||||
}
|
||||
else if (r < 248)
|
||||
{
|
||||
dir = "SW";
|
||||
}
|
||||
else if (r < 293)
|
||||
{
|
||||
dir = "W";
|
||||
}
|
||||
else if (r < 338)
|
||||
{
|
||||
dir = "NW";
|
||||
}
|
||||
else
|
||||
{
|
||||
dir = "N";
|
||||
}
|
||||
user.sendMessage(Util.format("compassBearing", dir, r));
|
||||
}
|
||||
}
|
||||
|
@@ -31,7 +31,7 @@ public class Commanddelhome extends EssentialsCommand
|
||||
}
|
||||
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, args, 0);
|
||||
user = getPlayer(server, args, 0, true);
|
||||
name = args[1];
|
||||
}
|
||||
else
|
||||
|
@@ -23,6 +23,12 @@ public class Commandessentials extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("debug"))
|
||||
{
|
||||
ess.getSettings().setDebug(!ess.getSettings().isDebug());
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion() + " debug mode " + (ess.getSettings().isDebug() ? "enabled" : "disabled"));
|
||||
return;
|
||||
}
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
noteMap.put("1G", (byte)0x1);
|
||||
@@ -56,7 +62,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 +96,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 +115,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();
|
||||
}
|
||||
|
@@ -0,0 +1,43 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandgamemode extends EssentialsCommand
|
||||
{
|
||||
public Commandgamemode()
|
||||
{
|
||||
super("gamemode");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
Player player;
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
player = ess.getUser(sender); }
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player = server.getPlayer(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
}
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
sender.sendMessage(Util.format("gameMode", Util.i18n(player.getGameMode().toString().toLowerCase()), player.getDisplayName()));
|
||||
}
|
||||
}
|
@@ -16,10 +16,10 @@ public class Commandgetpos extends EssentialsCommand
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Location coords = user.getLocation();
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (+East <-> -West)");
|
||||
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+East <-> -West)");
|
||||
user.sendMessage("§7Yaw: " + user.getCorrectedYaw() + " (Rotation)");
|
||||
user.sendMessage("§7Z: " + coords.getBlockZ() + " (+South <-> -North)");
|
||||
user.sendMessage("§7Yaw: " + (coords.getYaw() + 180 + 360) % 360 + " (Rotation)");
|
||||
user.sendMessage("§7Pitch: " + coords.getPitch() + " (Head angle)");
|
||||
}
|
||||
}
|
||||
|
@@ -34,6 +34,7 @@ public class Commandheal extends EssentialsCommand
|
||||
user.healCooldown();
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.setFoodLevel(20);
|
||||
user.sendMessage(Util.i18n("heal"));
|
||||
}
|
||||
|
||||
|
@@ -45,18 +45,18 @@ public class Commandhome extends EssentialsCommand
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
List<String> homes = u.getHomes();
|
||||
if (homes.isEmpty())
|
||||
if (homes.isEmpty() && u.equals(user) && ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
else if ((homes.size() == 1) && u == user)
|
||||
else if (homes.size() == 1 && u.equals(user))
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
|
@@ -31,7 +31,8 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
throw new Exception(Util.i18n("invRestored"));
|
||||
user.sendMessage(Util.i18n("invRestored"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
if (user.getSavedInventory() == null)
|
||||
@@ -49,5 +50,6 @@ public class Commandinvsee extends EssentialsCommand
|
||||
user.getInventory().setContents(invUserStack);
|
||||
user.sendMessage(Util.format("invSee", invUser.getDisplayName()));
|
||||
user.sendMessage(Util.i18n("invSeeHelp"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -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()));
|
||||
}
|
||||
|
@@ -15,22 +15,20 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
static private final Map<User, Map<String, Long>> kitPlayers = new HashMap<User, Map<String, Long>>();
|
||||
|
||||
public Commandkit()
|
||||
{
|
||||
super("kit");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
Map<String, Object> kits = ess.getSettings().getKits();
|
||||
StringBuilder list = new StringBuilder();
|
||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String k : kits.keySet())
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + k.toLowerCase()))
|
||||
@@ -56,8 +54,8 @@ public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
try
|
||||
{
|
||||
String kitName = args[0].toLowerCase();
|
||||
Object kit = ess.getSettings().getKit(kitName);
|
||||
final String kitName = args[0].toLowerCase();
|
||||
final Object kit = ess.getSettings().getKit(kitName);
|
||||
List<String> items;
|
||||
|
||||
if (!user.isAuthorized("essentials.kit." + kitName))
|
||||
@@ -70,39 +68,26 @@ public class Commandkit extends EssentialsCommand
|
||||
{
|
||||
|
||||
//System.out.println("Kit is timed");
|
||||
Map<String, Object> els = (Map<String, Object>)kit;
|
||||
final Map<String, Object> els = (Map<String, Object>)kit;
|
||||
items = (List<String>)els.get("items");
|
||||
double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, (int)delay);
|
||||
c.add(Calendar.MILLISECOND, (int)((delay*1000.0)%1000.0));
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay*1000.0)%1000.0));
|
||||
|
||||
long time = c.getTimeInMillis();
|
||||
Calendar now = new GregorianCalendar();
|
||||
|
||||
Map<String, Long> kitTimes;
|
||||
if (!kitPlayers.containsKey(user))
|
||||
{
|
||||
kitTimes = new HashMap<String, Long>();
|
||||
kitTimes.put(kitName, time);
|
||||
kitPlayers.put(user, kitTimes);
|
||||
}
|
||||
else
|
||||
{
|
||||
kitTimes = kitPlayers.get(user);
|
||||
if (!kitTimes.containsKey(kitName))
|
||||
{
|
||||
kitTimes.put(kitName, time);
|
||||
}
|
||||
else if (kitTimes.get(kitName) < now.getTimeInMillis())
|
||||
{
|
||||
kitTimes.put(kitName, time);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("kitTimed", Util.formatDateDiff(kitTimes.get(kitName))));
|
||||
return;
|
||||
}
|
||||
final long mintime = c.getTimeInMillis();
|
||||
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime) {
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, 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(Util.format("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -110,7 +95,7 @@ public class Commandkit extends EssentialsCommand
|
||||
items = (List<String>)kit;
|
||||
}
|
||||
|
||||
Trade charge = new Trade("kit-" + kitName, ess);
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
@@ -124,11 +109,11 @@ public class Commandkit extends EssentialsCommand
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
String[] parts = d.split("[^0-9]+", 3);
|
||||
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
final String[] parts = d.split("[^0-9]+", 3);
|
||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
final HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
user.getWorld().dropItemNaturally(user.getLocation(), itemStack);
|
||||
|
@@ -5,6 +5,7 @@ import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -23,13 +24,15 @@ public class Commandmail extends EssentialsCommand
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.i18n("noMail"));
|
||||
user.sendMessage(Util.i18n("noMail"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
throw new Exception(Util.i18n("mailClear"));
|
||||
user.sendMessage(Util.i18n("mailClear"));
|
||||
return;
|
||||
}
|
||||
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
@@ -62,7 +65,63 @@ public class Commandmail extends EssentialsCommand
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
user.setMails(null);
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
user.sendMessage(Util.i18n("mailCleared"));
|
||||
return;
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length >= 1 && "read".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
throw new Exception(Util.format("onlyPlayers", commandLabel + " read"));
|
||||
}
|
||||
else if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
throw new Exception(Util.format("onlyPlayers", commandLabel + " clear"));
|
||||
}
|
||||
else if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
Player player = server.getPlayer(args[1]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[1]);
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.format("playerNeverOnServer", args[1]));
|
||||
}
|
||||
u.addMail("Server: " + getFinalArg(args, 2));
|
||||
sender.sendMessage(Util.i18n("mailSent"));
|
||||
return;
|
||||
}
|
||||
else if (args.length >= 2)
|
||||
{
|
||||
//allow sending from console without "send" argument, since it's the only thing the console can do
|
||||
Player player = server.getPlayer(args[0]);
|
||||
User u;
|
||||
if (player != null)
|
||||
{
|
||||
u = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.format("playerNeverOnServer", args[0]));
|
||||
}
|
||||
u.addMail("Server: " + getFinalArg(args, 1));
|
||||
sender.sendMessage(Util.i18n("mailSent"));
|
||||
return;
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
@@ -24,15 +24,13 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append("* ");
|
||||
message.append(user.getDisplayName());
|
||||
message.append(' ');
|
||||
for (int i = 0; i < args.length; i++)
|
||||
|
||||
String message = getFinalArg(args, 0);
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
message.append(args[i]);
|
||||
message.append(' ');
|
||||
message = message.replaceAll("&([0-9a-f])", "§$1");
|
||||
}
|
||||
ess.broadcastMessage(user, message.toString());
|
||||
|
||||
ess.broadcastMessage(user, Util.format("action", user.getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
|
@@ -15,96 +15,77 @@ public class Commandnick extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
if (!ess.getSettings().changeDisplayName())
|
||||
{
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (!user.isAuthorized("essentials.nick.others"))
|
||||
{
|
||||
throw new Exception(Util.i18n("nickOthersPermission"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, user, args);
|
||||
setNickname(server, getPlayer(server, args, 0), args[1]);
|
||||
user.sendMessage(Util.i18n("nickChanged"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
String nick = args[0];
|
||||
if ("off".equalsIgnoreCase(nick) || user.getName().equalsIgnoreCase(nick))
|
||||
{
|
||||
user.setDisplayName(user.getName());
|
||||
user.setNickname(null);
|
||||
user.sendMessage(Util.i18n("nickNoMore"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (user == p)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String dn = p.getDisplayName().toLowerCase();
|
||||
String n = p.getName().toLowerCase();
|
||||
String nk = nick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
setNickname(server, user, args[0]);
|
||||
}
|
||||
|
||||
@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 < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
sender.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
if (!ess.getSettings().changeDisplayName())
|
||||
{
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, sender, args);
|
||||
|
||||
setNickname(server, getPlayer(server, args, 0), args[1]);
|
||||
sender.sendMessage(Util.i18n("nickChanged"));
|
||||
}
|
||||
|
||||
private void setOthersNickname(Server server, CommandSender sender, String[] args) throws Exception
|
||||
private void setNickname(final Server server, final User target, final String nick) throws Exception
|
||||
{
|
||||
User target = getPlayer(server, args, 0);
|
||||
String nick = args[1];
|
||||
if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
target.setDisplayName(target.getName());
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
else if ("off".equalsIgnoreCase(nick) || target.getName().equalsIgnoreCase(nick))
|
||||
{
|
||||
target.setDisplayNick(target.getName());
|
||||
target.setNickname(null);
|
||||
target.sendMessage(Util.i18n("nickNoMore"));
|
||||
}
|
||||
else
|
||||
{
|
||||
target.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
target.setNickname(nick);
|
||||
final String formattedNick = nick.replace('&', '\u00a7').replace("\u00a7\u00a7", "&");
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (target.getBase() == p)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String dn = p.getDisplayName().toLowerCase();
|
||||
String n = p.getName().toLowerCase();
|
||||
String nk = formattedNick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
target.setDisplayNick(ess.getSettings().getNicknamePrefix() + formattedNick);
|
||||
target.setNickname(formattedNick);
|
||||
target.sendMessage(Util.format("nickSet", target.getDisplayName() + "§7."));
|
||||
}
|
||||
sender.sendMessage(Util.i18n("nickChanged"));
|
||||
}
|
||||
}
|
||||
|
@@ -22,13 +22,13 @@ public class Commandpowertool extends EssentialsCommand
|
||||
String command = getFinalArg(args, 0);
|
||||
|
||||
// check to see if this is a clear all command
|
||||
if(command != null && command.equalsIgnoreCase("clearall"))
|
||||
if(command != null && command.equalsIgnoreCase("c:"))
|
||||
{
|
||||
user.clearAllPowertools();
|
||||
user.sendMessage(Util.i18n("powerToolClearAll"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
final ItemStack itemStack = user.getItemInHand();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||
{
|
||||
|
22
Essentials/src/com/earth2me/essentials/commands/Commandptime.java
Executable file → Normal file
22
Essentials/src/com/earth2me/essentials/commands/Commandptime.java
Executable file → Normal file
@@ -11,7 +11,6 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -97,29 +96,31 @@ public class Commandptime extends EssentialsCommand
|
||||
*/
|
||||
private void getUsersTime(final CommandSender sender, final Collection<User> users)
|
||||
{
|
||||
if (users.size() > 1)
|
||||
if (users.size() > 1)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimePlayers"));
|
||||
}
|
||||
|
||||
for (User user : users)
|
||||
|
||||
for (User user : users)
|
||||
{
|
||||
if(user.getPlayerTimeOffset() == 0)
|
||||
if (user.getPlayerTimeOffset() == 0)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeNormal", user.getName()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
String time = DescParseTickFormat.format(user.getPlayerTime());
|
||||
if(!user.isPlayerTimeRelative())
|
||||
if (!user.isPlayerTimeRelative())
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -177,7 +178,8 @@ public class Commandptime extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
|
||||
}
|
||||
else {
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -15,7 +16,7 @@ public class Commandrealname extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -36,7 +37,7 @@ public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
user.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
|
||||
sender.sendMessage(u.getDisplayName() + " " + Util.i18n("is") + " " + u.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,21 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandreloadall extends EssentialsCommand
|
||||
{
|
||||
public Commandreloadall()
|
||||
{
|
||||
super("reloadall");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
server.reload();
|
||||
sender.sendMessage(Util.i18n("reloadAllPlugins"));
|
||||
}
|
||||
}
|
@@ -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);
|
||||
|
||||
@@ -46,7 +50,9 @@ public class Commandrepair extends EssentialsCommand
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
repairItems(user.getInventory().getArmorContents(), user, repaired);
|
||||
if (user.isAuthorized("essentials.repair.armor")) {
|
||||
repairItems(user.getInventory().getArmorContents(), user, repaired);
|
||||
}
|
||||
|
||||
if (repaired.isEmpty())
|
||||
{
|
||||
@@ -84,6 +90,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
|
||||
|
@@ -29,7 +29,7 @@ public class Commandsell extends EssentialsCommand
|
||||
{
|
||||
is = user.getItemInHand();
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("inventory"))
|
||||
else if (args[0].equalsIgnoreCase("inventory") || args[0].equalsIgnoreCase("invent") || args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
for (ItemStack stack : user.getInventory().getContents())
|
||||
{
|
||||
@@ -103,28 +103,21 @@ public class Commandsell extends EssentialsCommand
|
||||
|
||||
|
||||
int max = 0;
|
||||
if (!isBulkSell)
|
||||
for (ItemStack s : user.getInventory().getContents())
|
||||
{
|
||||
for (ItemStack s : user.getInventory().getContents())
|
||||
if (s == null)
|
||||
{
|
||||
if (s == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (s.getTypeId() != is.getTypeId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (s.getDurability() != is.getDurability())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
max += s.getAmount();
|
||||
continue;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
max += is.getAmount();
|
||||
if (s.getTypeId() != is.getTypeId())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (s.getDurability() != is.getDurability())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
max += s.getAmount();
|
||||
}
|
||||
|
||||
if (stack)
|
||||
@@ -140,20 +133,26 @@ public class Commandsell extends EssentialsCommand
|
||||
{
|
||||
amount -= amount % 64;
|
||||
}
|
||||
|
||||
if (amount > max || amount < 1)
|
||||
{
|
||||
user.sendMessage(Util.i18n("itemNotEnough1"));
|
||||
user.sendMessage(Util.i18n("itemNotEnough2"));
|
||||
throw new Exception(Util.i18n("itemNotEnough3"));
|
||||
if (!isBulkSell)
|
||||
{
|
||||
user.sendMessage(Util.i18n("itemNotEnough1"));
|
||||
user.sendMessage(Util.i18n("itemNotEnough2"));
|
||||
throw new Exception(Util.i18n("itemNotEnough3"));
|
||||
}
|
||||
else
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
final ItemStack ris = new ItemStack(is.getType(), amount, is.getDurability());
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, ris);
|
||||
user.updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth*amount, ess), user.getLocation(), ess);
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
|
||||
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(), Util.formatCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
|
@@ -28,14 +28,14 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getMultipleHomes())
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||
|| (user.getHomes().contains(args[0].toLowerCase())))
|
||||
{
|
||||
user.setHome(args[0].toLowerCase());
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getMultipleHomes()));
|
||||
throw new Exception(Util.format("maxHomes", ess.getSettings().getHomeLimit(user)));
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -56,11 +56,6 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|
||||
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
Entity spawnedMob = null;
|
||||
Mob mob = null;
|
||||
@@ -72,6 +67,12 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.i18n("invalidMob"));
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase()))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
@@ -79,8 +80,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
Block block = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock();
|
||||
if (block == null)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
Location loc = block.getLocation();
|
||||
Location sloc = Util.getSafeDestination(loc);
|
||||
@@ -90,8 +90,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
@@ -102,14 +101,18 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
user.sendMessage(Util.i18n("invalidMob"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobMount.getType().toString().toLowerCase()))
|
||||
{
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -144,8 +147,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("unableToSpawnMob"));
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
|
@@ -0,0 +1,41 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
|
||||
|
||||
public class Commandsudo extends EssentialsCommand
|
||||
{
|
||||
public Commandsudo()
|
||||
{
|
||||
super("sudo");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final User user = getPlayer(server, args, 0, false);
|
||||
final String command = args[1];
|
||||
final String[] arguments = new String[args.length - 2];
|
||||
if (arguments.length > 0) {
|
||||
System.arraycopy(args, 2, arguments, 0, args.length - 2);
|
||||
}
|
||||
|
||||
//TODO: Translate this.
|
||||
sender.sendMessage("Running the command as " + user.getDisplayName());
|
||||
|
||||
final PluginCommand pc = ess.getServer().getPluginCommand(command);
|
||||
if (pc != null)
|
||||
{
|
||||
pc.execute(user.getBase(), command, arguments);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
@@ -18,6 +18,6 @@ public class Commandsuicide extends EssentialsCommand
|
||||
user.setHealth(0);
|
||||
user.sendMessage(Util.i18n("suicideMessage"));
|
||||
ess.broadcastMessage(user,
|
||||
Util.format("suicideSuccess",user.getDisplayName()));
|
||||
Util.format("suicideSuccess", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
4
Essentials/src/com/earth2me/essentials/commands/Commandtime.java
Executable file → Normal file
4
Essentials/src/com/earth2me/essentials/commands/Commandtime.java
Executable file → Normal file
@@ -25,7 +25,7 @@ public class Commandtime extends EssentialsCommand
|
||||
{
|
||||
worldSelector = args[1];
|
||||
}
|
||||
Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (args.length == 0)
|
||||
@@ -34,7 +34,7 @@ public class Commandtime extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
final User user = ess.getUser(sender);
|
||||
if (user != null && !user.isAuthorized("essentials.time.set"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("timeSetPermission"));
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -14,34 +15,36 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
User p = user.getTeleportRequest();
|
||||
if (p == null)
|
||||
final User target = user.getTeleportRequest();
|
||||
if (target == null
|
||||
|| target.getBase() instanceof OfflinePlayer
|
||||
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
|
||||
{
|
||||
throw new Exception(Util.i18n("noPendingRequest"));
|
||||
}
|
||||
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
if (user.isTeleportRequestHere())
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
else
|
||||
{
|
||||
charge.isAffordableFor(p);
|
||||
charge.isAffordableFor(target);
|
||||
}
|
||||
user.sendMessage(Util.i18n("requestAccepted"));
|
||||
p.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
target.sendMessage(Util.format("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
if (user.isTeleportRequestHere())
|
||||
{
|
||||
user.getTeleport().teleport(p, charge);
|
||||
user.getTeleport().teleport(target, charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
p.getTeleport().teleport(user, charge);
|
||||
target.getTeleport().teleport(user, charge);
|
||||
}
|
||||
user.requestTeleport(null, false);
|
||||
}
|
||||
|
@@ -1,13 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
|
||||
|
||||
public class Commandtree extends EssentialsCommand
|
||||
@@ -20,7 +17,7 @@ public class Commandtree extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Object tree = new Object();
|
||||
TreeType tree;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
@@ -46,9 +43,9 @@ public class Commandtree extends EssentialsCommand
|
||||
{
|
||||
8, 9
|
||||
};
|
||||
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
final Location loc = Util.getTarget(user);
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, tree);
|
||||
if (success)
|
||||
{
|
||||
user.sendMessage(Util.i18n("treeSpawned"));
|
||||
|
@@ -20,18 +20,16 @@ public class Commandunban extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
String name;
|
||||
|
||||
try
|
||||
{
|
||||
User u = getPlayer(server, args, 0, true);
|
||||
name = u.getName();
|
||||
final User u = getPlayer(server, args, 0, true);
|
||||
u.setBanned(false);
|
||||
sender.sendMessage(Util.i18n("unbannedPlayer"));
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -8,6 +8,7 @@ import com.earth2me.essentials.Warps;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandwarp extends EssentialsCommand
|
||||
@@ -28,33 +29,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.i18n("warpListPermission"));
|
||||
}
|
||||
|
||||
Warps warps = ess.getWarps();
|
||||
if (warps.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.i18n("noWarpsDefined"));
|
||||
}
|
||||
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
|
||||
final Iterator<String> iterator = warpNameList.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final String warpName = iterator.next();
|
||||
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
int page = 1;
|
||||
if (args.length > 0)
|
||||
{
|
||||
page = Integer.parseInt(args[0]);
|
||||
}
|
||||
if (warpNameList.size() > WARPS_PER_PAGE)
|
||||
{
|
||||
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
||||
}
|
||||
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
||||
user.sendMessage(Util.joinList(warpNameList.subList(warpPage, warpPage+Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE))));
|
||||
warpList(user, args);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (args.length > 0)
|
||||
@@ -75,6 +50,63 @@ public class Commandwarp extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2 || args[0].matches("[0-9]+"))
|
||||
{
|
||||
warpList(null, args);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
User otherUser = ess.getUser(server.getPlayer(args[1]));
|
||||
if (otherUser == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
warpUser(otherUser, args[0]);
|
||||
throw new NoChargeException();
|
||||
|
||||
}
|
||||
|
||||
private void warpList(User user, String[] args) throws Exception
|
||||
{
|
||||
Warps warps = ess.getWarps();
|
||||
if (warps.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.i18n("noWarpsDefined"));
|
||||
}
|
||||
final List<String> warpNameList = new ArrayList<String>(warps.getWarpNames());
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
final Iterator<String> iterator = warpNameList.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
final String warpName = iterator.next();
|
||||
if (ess.getSettings().getPerWarpPermission() && !user.isAuthorized("essentials.warp." + warpName))
|
||||
{
|
||||
iterator.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
int page = 1;
|
||||
if (args.length > 0)
|
||||
{
|
||||
page = Integer.parseInt(args[0]);
|
||||
}
|
||||
|
||||
final int warpPage = (page - 1) * WARPS_PER_PAGE;
|
||||
final String warpList = Util.joinList(warpNameList.subList(warpPage, warpPage + Math.min(warpNameList.size() - warpPage, WARPS_PER_PAGE)));
|
||||
|
||||
if (warpNameList.size() > WARPS_PER_PAGE)
|
||||
{
|
||||
user.sendMessage(Util.format("warpsCount", warpNameList.size(), page, (int)Math.ceil(warpNameList.size() / (double)WARPS_PER_PAGE)));
|
||||
user.sendMessage(warpList);
|
||||
}
|
||||
else {
|
||||
user.sendMessage(Util.format("warps", warpList));
|
||||
}
|
||||
}
|
||||
|
||||
private void warpUser(User user, String name) throws Exception
|
||||
{
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
|
@@ -4,6 +4,7 @@ import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandweather extends EssentialsCommand
|
||||
@@ -29,16 +30,50 @@ public class Commandweather extends EssentialsCommand
|
||||
world.setStorm(isStorm ? true : false);
|
||||
world.setWeatherDuration(Integer.parseInt(args[1]) * 20);
|
||||
user.sendMessage(isStorm
|
||||
? Util.format("weatherStormFor", args[1])
|
||||
: Util.format("weatherSunFor", args[1]));
|
||||
? Util.format("weatherStormFor", world.getName(), args[1])
|
||||
: Util.format("weatherSunFor", world.getName(), args[1]));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setStorm(isStorm ? true : false);
|
||||
user.sendMessage(isStorm
|
||||
? Util.i18n("weatherStorm")
|
||||
: Util.i18n("weatherSun"));
|
||||
? Util.format("weatherStorm", world.getName())
|
||||
: Util.format("weatherSun", world.getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2) //running from console means inserting a world arg before other args
|
||||
{
|
||||
throw new Exception("When running from console, usage is: /" + commandLabel + " <world> <storm/sun> [duration]");
|
||||
}
|
||||
|
||||
boolean isStorm = args[1].equalsIgnoreCase("storm");
|
||||
World world = server.getWorld(args[0]);
|
||||
if (world == null)
|
||||
{
|
||||
throw new Exception("World named " + args[0] + " not found!");
|
||||
}
|
||||
if (args.length > 2)
|
||||
{
|
||||
|
||||
world.setStorm(isStorm ? true : false);
|
||||
world.setWeatherDuration(Integer.parseInt(args[2]) * 20);
|
||||
sender.sendMessage(isStorm
|
||||
? Util.format("weatherStormFor", world.getName(), args[2])
|
||||
: Util.format("weatherSunFor", world.getName(), args[2]));
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
world.setStorm(isStorm ? true : false);
|
||||
sender.sendMessage(isStorm
|
||||
? Util.format("weatherStorm", world.getName())
|
||||
: Util.format("weatherSun", world.getName()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@@ -53,17 +53,20 @@ public class Commandwhois extends EssentialsCommand
|
||||
sender.sendMessage("");
|
||||
sender.sendMessage(Util.format("whoisIs", u.getDisplayName(), u.getName()));
|
||||
sender.sendMessage(Util.format("whoisHealth", u.getHealth()));
|
||||
sender.sendMessage(Util.format("whoisOP", (u.isOp() ? Util.i18n("true") : Util.i18n("false"))));
|
||||
sender.sendMessage(Util.format("whoisGod", (u.isGodModeEnabled() ? Util.i18n("true") : Util.i18n("false"))));
|
||||
sender.sendMessage(Util.format("whoisGamemode", Util.i18n(u.getGameMode().toString().toLowerCase())));
|
||||
sender.sendMessage(Util.format("whoisLocation", u.getLocation().getWorld().getName(), u.getLocation().getBlockX(), u.getLocation().getBlockY(), u.getLocation().getBlockZ()));
|
||||
if (!ess.getSettings().isEcoDisabled())
|
||||
{
|
||||
sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess)));
|
||||
}
|
||||
sender.sendMessage(u.isAfk()
|
||||
? Util.i18n("whoisStatusAway")
|
||||
sender.sendMessage(u.isAfk()
|
||||
? Util.i18n("whoisStatusAway")
|
||||
: Util.i18n("whoisStatusAvailable"));
|
||||
sender.sendMessage(Util.format("whoisIPAddress", u.getAddress().getAddress().toString()));
|
||||
final String location = u.getGeoLocation();
|
||||
if (location != null
|
||||
if (location != null
|
||||
&& (sender instanceof Player ? ess.getUser(sender).isAuthorized("essentials.geoip.show") : true))
|
||||
{
|
||||
sender.sendMessage(Util.format("whoisGeoLocation", location));
|
||||
|
@@ -17,26 +17,28 @@ public class Commandworld extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
World world;
|
||||
List<World> worlds = server.getWorlds();
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
for (World world2 : worlds)
|
||||
World nether = null;
|
||||
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
for (World world2 : worlds)
|
||||
{
|
||||
if (world2.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
if (world2.getEnvironment() == World.Environment.NETHER) {
|
||||
nether = world2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
return;
|
||||
nether = world2;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
world = user.getWorld() == nether ? worlds.get(0) : nether;
|
||||
}
|
||||
else
|
||||
@@ -54,23 +56,22 @@ public class Commandworld extends EssentialsCommand
|
||||
double factor;
|
||||
if (user.getWorld().getEnvironment() == World.Environment.NETHER && world.getEnvironment() == World.Environment.NORMAL)
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
factor = 8.0;
|
||||
}
|
||||
else if (user.getWorld().getEnvironment() != world.getEnvironment())
|
||||
else if (user.getWorld().getEnvironment() == World.Environment.NORMAL && world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
factor = 1.0 / ess.getSettings().getNetherRatio();
|
||||
factor = 1.0 / 8.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = user.getLocation();
|
||||
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
final Location loc = user.getLocation();
|
||||
final Location target = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
user.getTeleport().teleport(target, charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,8 @@ package com.earth2me.essentials.commands;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -33,7 +35,7 @@ public class Commandworth extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
amount = 64;
|
||||
amount = is.getType().getMaxStackSize();
|
||||
}
|
||||
|
||||
is.setAmount(amount);
|
||||
@@ -56,4 +58,49 @@ public class Commandworth extends EssentialsCommand
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ItemStack is = ess.getItemDb().get(args[0]);
|
||||
int amount = is.getAmount();
|
||||
|
||||
try
|
||||
{
|
||||
if (args.length > 1)
|
||||
{
|
||||
amount = Integer.parseInt(args[1]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
amount = is.getType().getMaxStackSize();
|
||||
}
|
||||
|
||||
is.setAmount(amount);
|
||||
double worth = ess.getWorth().getPrice(is);
|
||||
if (Double.isNaN(worth))
|
||||
{
|
||||
throw new Exception(Util.i18n("itemCannotBeSold"));
|
||||
}
|
||||
|
||||
sender.sendMessage(is.getDurability() != 0
|
||||
? Util.format("worthMeta",
|
||||
is.getType().toString().toLowerCase().replace("_", ""),
|
||||
is.getDurability(),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess))
|
||||
: Util.format("worth",
|
||||
is.getType().toString().toLowerCase().replace("_", ""),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public class BPermissionsHandler implements IPermissionsHandler
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return hasPermission(base, "bPermissions.build");
|
||||
return hasPermission(base, "essentials.build") || hasPermission(base, "bPermissions.build");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -0,0 +1,69 @@
|
||||
package com.earth2me.essentials.perm;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import org.anjocaido.groupmanager.GroupManager;
|
||||
import org.anjocaido.groupmanager.permissions.AnjoPermissionsHandler;
|
||||
|
||||
|
||||
public class GroupManagerHandler implements IPermissionsHandler
|
||||
{
|
||||
private final transient GroupManager groupManager;
|
||||
|
||||
public GroupManagerHandler(final Plugin permissionsPlugin)
|
||||
{
|
||||
groupManager = ((GroupManager)permissionsPlugin);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.getGroup(base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getGroups(final Player base)
|
||||
{
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return Arrays.asList(handler.getGroups(base.getName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
final AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.canUserBuild(base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.inGroup(base.getName(), group);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.has(base, node);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.getUserPrefix(base.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
AnjoPermissionsHandler handler = groupManager.getWorldsHolder().getWorldPermissions(base);
|
||||
return handler.getUserSuffix(base.getName());
|
||||
}
|
||||
}
|
@@ -74,4 +74,10 @@ public class PermissionsBukkitHandler extends SuperpermsHandler
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canBuild(Player base, String group)
|
||||
{
|
||||
return base.hasPermission("essentials.build") || base.hasPermission("permissions.build");
|
||||
}
|
||||
}
|
||||
|
@@ -77,7 +77,7 @@ public class PermissionsExHandler implements IPermissionsHandler
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return user.getPrefix();
|
||||
return user.getPrefix(base.getWorld().getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -88,6 +88,7 @@ public class PermissionsExHandler implements IPermissionsHandler
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return user.getSuffix();
|
||||
|
||||
return user.getSuffix(base.getWorld().getName());
|
||||
}
|
||||
}
|
||||
|
@@ -111,17 +111,6 @@ public class PermissionsHandler implements IPermissionsHandler
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
|
||||
if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
|
||||
{
|
||||
if (!(handler instanceof PermissionsBukkitHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
|
||||
handler = new PermissionsBukkitHandler(permBukkitPlugin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin bPermPlugin = pluginManager.getPlugin("bPermissions");
|
||||
if (bPermPlugin != null && bPermPlugin.isEnabled())
|
||||
{
|
||||
@@ -132,6 +121,28 @@ public class PermissionsHandler implements IPermissionsHandler
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin GMplugin = pluginManager.getPlugin("GroupManager");
|
||||
if (GMplugin != null && GMplugin.isEnabled())
|
||||
{
|
||||
if (!(handler instanceof GroupManagerHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using GroupManager based permissions.");
|
||||
handler = new GroupManagerHandler(GMplugin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin permBukkitPlugin = pluginManager.getPlugin("PermissionsBukkit");
|
||||
if (permBukkitPlugin != null && permBukkitPlugin.isEnabled())
|
||||
{
|
||||
if (!(handler instanceof PermissionsBukkitHandler))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials: Using PermissionsBukkit based permissions.");
|
||||
handler = new PermissionsBukkitHandler(permBukkitPlugin);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Plugin permPlugin = pluginManager.getPlugin("Permissions");
|
||||
if (permPlugin != null && permPlugin.isEnabled())
|
||||
|
@@ -4,7 +4,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* Method.java
|
||||
* Interface to be implemented by a payment method.
|
||||
*
|
||||
* @author Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
* @copyright Copyright (C) 2011
|
||||
@@ -41,6 +41,14 @@ public interface Method
|
||||
*/
|
||||
public String getVersion();
|
||||
|
||||
/**
|
||||
* Returns the amount of decimal places that get stored
|
||||
* NOTE: it will return -1 if there is no rounding
|
||||
*
|
||||
* @return <code>int</code> for each decimal place
|
||||
*/
|
||||
public int fractionalDigits();
|
||||
|
||||
/**
|
||||
* Formats amounts into this payment methods style of currency display.
|
||||
*
|
||||
@@ -82,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>.
|
||||
*
|
||||
|
@@ -2,12 +2,10 @@ package com.earth2me.essentials.register.payment;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
|
||||
/**
|
||||
* The <code>Methods</code> initializes Methods that utilize the Method interface
|
||||
@@ -15,15 +13,13 @@ import java.util.Set;
|
||||
*
|
||||
* Allowing you to check whether a payment method exists or not.
|
||||
*
|
||||
* <blockquote><pre>
|
||||
* Methods methods = new Methods();
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* Methods also allows you to set a preferred method of payment before it captures
|
||||
* payment plugins in the initialization process.
|
||||
*
|
||||
* in <code>bukkit.yml</code>:
|
||||
* <blockquote><pre>
|
||||
* Methods methods = new Methods("iConomy");
|
||||
* economy:
|
||||
* preferred: "iConomy"
|
||||
* </pre></blockquote>
|
||||
*
|
||||
* @author: Nijikokun <nijikokun@shortmail.com> (@nijikokun)
|
||||
@@ -32,51 +28,62 @@ import java.util.Set;
|
||||
*/
|
||||
public class Methods
|
||||
{
|
||||
private boolean self = false;
|
||||
private Method Method = null;
|
||||
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 static String version = null;
|
||||
private static boolean self = false;
|
||||
private static Method Method = null;
|
||||
private static String preferred = "";
|
||||
private static Set<Method> Methods = new HashSet<Method>();
|
||||
private static Set<String> Dependencies = new HashSet<String>();
|
||||
private static Set<Method> Attachables = new HashSet<Method>();
|
||||
|
||||
/**
|
||||
* Initialize Method class
|
||||
*/
|
||||
public Methods()
|
||||
static
|
||||
{
|
||||
this._init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Initializes <code>Methods</code> class utilizing a "preferred" payment method check before
|
||||
* returning the first method that was initialized.
|
||||
*
|
||||
* @param preferred Payment method that is most preferred for this setup.
|
||||
*/
|
||||
public Methods(String preferred)
|
||||
{
|
||||
this._init();
|
||||
|
||||
if (this.Dependencies.contains(preferred))
|
||||
{
|
||||
this.preferred = preferred;
|
||||
}
|
||||
_init();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement all methods along with their respective name & class.
|
||||
*
|
||||
* @see #Methods()
|
||||
* @see #Methods(java.lang.String)
|
||||
*/
|
||||
private void _init()
|
||||
private static 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("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||
this.addMethod("MultiCurrency", new com.earth2me.essentials.register.payment.methods.MCUR());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo6());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
|
||||
addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
|
||||
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
|
||||
addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||
addMethod("Currency", new com.earth2me.essentials.register.payment.methods.MCUR());
|
||||
Dependencies.add("MultiCurrency");
|
||||
}
|
||||
|
||||
/**
|
||||
* Used by the plugin to setup version
|
||||
*
|
||||
* @param v version
|
||||
*/
|
||||
public static void setVersion(String v)
|
||||
{
|
||||
version = v;
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to reset methods during disable
|
||||
*/
|
||||
public static void reset()
|
||||
{
|
||||
version = null;
|
||||
self = false;
|
||||
Method = null;
|
||||
preferred = "";
|
||||
Attachables.clear();
|
||||
}
|
||||
|
||||
/**
|
||||
* Use to get version of Register plugin
|
||||
* @return version
|
||||
*/
|
||||
public static String getVersion()
|
||||
{
|
||||
return version;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +93,7 @@ public class Methods
|
||||
* @return <code>Set<String></code> - Array of payment methods that are loaded.
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
*/
|
||||
public Set<String> getDependencies()
|
||||
public static Set<String> getDependencies()
|
||||
{
|
||||
return Dependencies;
|
||||
}
|
||||
@@ -98,7 +105,7 @@ public class Methods
|
||||
* @param plugin Plugin data from bukkit, Internal Class file.
|
||||
* @return Method <em>or</em> Null
|
||||
*/
|
||||
public Method createMethod(Plugin plugin)
|
||||
public static Method createMethod(Plugin plugin)
|
||||
{
|
||||
for (Method method : Methods)
|
||||
{
|
||||
@@ -112,7 +119,7 @@ public class Methods
|
||||
return null;
|
||||
}
|
||||
|
||||
private void addMethod(String name, Method method)
|
||||
private static void addMethod(String name, Method method)
|
||||
{
|
||||
Dependencies.add(name);
|
||||
Methods.add(method);
|
||||
@@ -125,7 +132,7 @@ public class Methods
|
||||
* @see #setMethod(org.bukkit.plugin.Plugin)
|
||||
* @see #checkDisabled(org.bukkit.plugin.Plugin)
|
||||
*/
|
||||
public boolean hasMethod()
|
||||
public static boolean hasMethod()
|
||||
{
|
||||
return (Method != null);
|
||||
}
|
||||
@@ -134,15 +141,16 @@ public class Methods
|
||||
* Checks Plugin Class against a multitude of checks to verify it's usability
|
||||
* as a payment method.
|
||||
*
|
||||
* @param method Plugin data from bukkit, Internal Class file.
|
||||
* @param <code>PluginManager</code> the plugin manager for the server
|
||||
* @return <code>boolean</code> True on success, False on failure.
|
||||
*/
|
||||
public boolean setMethod(Plugin method)
|
||||
public static boolean setMethod(PluginManager manager)
|
||||
{
|
||||
if (hasMethod())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (self)
|
||||
{
|
||||
self = false;
|
||||
@@ -152,44 +160,37 @@ public class Methods
|
||||
int count = 0;
|
||||
boolean match = false;
|
||||
Plugin plugin = null;
|
||||
PluginManager manager = method.getServer().getPluginManager();
|
||||
|
||||
for (String name : this.getDependencies())
|
||||
for (String name : getDependencies())
|
||||
{
|
||||
if (hasMethod())
|
||||
{
|
||||
break;
|
||||
}
|
||||
if (method.getDescription().getName().equals(name))
|
||||
{
|
||||
plugin = method;
|
||||
}
|
||||
else
|
||||
{
|
||||
plugin = manager.getPlugin(name);
|
||||
}
|
||||
if (plugin == null)
|
||||
|
||||
plugin = manager.getPlugin(name);
|
||||
if (plugin == null || !plugin.isEnabled())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
Method current = this.createMethod(plugin);
|
||||
Method current = createMethod(plugin);
|
||||
if (current == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (this.preferred.isEmpty())
|
||||
if (preferred.isEmpty())
|
||||
{
|
||||
this.Method = current;
|
||||
Method = current;
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Attachables.add(current);
|
||||
Attachables.add(current);
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.preferred.isEmpty())
|
||||
if (!preferred.isEmpty())
|
||||
{
|
||||
do
|
||||
{
|
||||
@@ -199,7 +200,7 @@ public class Methods
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Method attached : this.Attachables)
|
||||
for (Method attached : Attachables)
|
||||
{
|
||||
if (attached == null)
|
||||
{
|
||||
@@ -212,21 +213,21 @@ public class Methods
|
||||
break;
|
||||
}
|
||||
|
||||
if (this.preferred.isEmpty())
|
||||
if (preferred.isEmpty())
|
||||
{
|
||||
this.Method = attached;
|
||||
Method = attached;
|
||||
}
|
||||
|
||||
if (count == 0)
|
||||
{
|
||||
if (this.preferred.equalsIgnoreCase(attached.getName()))
|
||||
if (preferred.equalsIgnoreCase(attached.getName()))
|
||||
{
|
||||
this.Method = attached;
|
||||
Method = attached;
|
||||
}
|
||||
else
|
||||
{
|
||||
Method = attached;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
this.Method = attached;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,12 +240,28 @@ public class Methods
|
||||
return hasMethod();
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the preferred economy
|
||||
*
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public static boolean setPreferred(String check)
|
||||
{
|
||||
if (getDependencies().contains(check))
|
||||
{
|
||||
preferred = check;
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Grab the existing and initialized (hopefully) Method Class.
|
||||
*
|
||||
* @return <code>Method</code> <em>or</em> <code>Null</code>
|
||||
*/
|
||||
public Method getMethod()
|
||||
public static Method getMethod()
|
||||
{
|
||||
return Method;
|
||||
}
|
||||
@@ -256,16 +273,18 @@ public class Methods
|
||||
* @param method Plugin data from bukkit, Internal Class file.
|
||||
* @return <code>boolean</code>
|
||||
*/
|
||||
public boolean checkDisabled(Plugin method)
|
||||
public static boolean checkDisabled(Plugin method)
|
||||
{
|
||||
if (!hasMethod())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
if (Method.isCompatible(method))
|
||||
{
|
||||
Method = null;
|
||||
}
|
||||
|
||||
return (Method == null);
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* BOSEconomy 6 Implementation of Method
|
||||
*
|
||||
@@ -11,191 +13,279 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class BOSE6 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
@SuppressWarnings("deprecation")
|
||||
public class BOSE6 implements Method
|
||||
{
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
public BOSEconomy getPlugin()
|
||||
{
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.6.2";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.6.2";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
if (amount == 1)
|
||||
{
|
||||
currency = this.BOSEconomy.getMoneyName();
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return this.BOSEconomy.isBankOwner(bank, name)
|
||||
|| this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return (double) this.BOSEconomy.getPlayerMoney(this.name);
|
||||
}
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
this.BOSEconomy.setPlayerMoney(name, balance, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
if (!hasBankAccount(bank, name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||
&& plugin instanceof BOSEconomy
|
||||
&& plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public class BOSEAccount implements MethodAccount
|
||||
{
|
||||
private final String name;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return (double)this.BOSEconomy.getPlayerMoney(this.name);
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private final String bank;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
public boolean set(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, IntAmount, false);
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - IntAmount), false);
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return (double) this.BOSEconomy.getBankMoney(bank);
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
return this.BOSEconomy.setBankMoney(bank, IntAmount, true);
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + IntAmount), false);
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - IntAmount), false);
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * IntAmount), false);
|
||||
}
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), false);
|
||||
}
|
||||
public boolean remove()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public class BOSEBankAccount implements MethodBankAccount
|
||||
{
|
||||
private final String bank;
|
||||
private final BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public String getBankName()
|
||||
{
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
public int getBankId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public double balance()
|
||||
{
|
||||
return (double)this.BOSEconomy.getBankMoney(bank);
|
||||
}
|
||||
|
||||
public boolean set(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
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(bank, (balance + IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
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(bank, (balance * IntAmount), false);
|
||||
}
|
||||
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
int IntAmount = (int)Math.ceil(amount);
|
||||
int balance = (int)this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance / IntAmount), 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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,9 +1,11 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import cosine.boseconomy.BOSEconomy;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* BOSEconomy 7 Implementation of Method
|
||||
*
|
||||
@@ -12,182 +14,267 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class BOSE7 implements Method
|
||||
{
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public class BOSE7 implements Method {
|
||||
private BOSEconomy BOSEconomy;
|
||||
public BOSEconomy getPlugin()
|
||||
{
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
|
||||
public BOSEconomy getPlugin() {
|
||||
return this.BOSEconomy;
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "BOSEconomy";
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "BOSEconomy";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.7.0";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.7.0";
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return this.BOSEconomy.getFractionalDigits();
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
if(amount == 1) currency = this.BOSEconomy.getMoneyName();
|
||||
return amount + " " + currency;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
String currency = this.BOSEconomy.getMoneyNamePlural();
|
||||
|
||||
public boolean hasBanks() {
|
||||
return true;
|
||||
}
|
||||
if (amount == 1)
|
||||
{
|
||||
currency = this.BOSEconomy.getMoneyName();
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
return amount + " " + currency;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return this.BOSEconomy.bankExists(bank);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
if(!hasAccount(name)) return null;
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.BOSEconomy.playerRegistered(name, false);
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
if(!hasBankAccount(bank, name)) return null;
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return this.BOSEconomy.isBankOwner(bank, name) || this.BOSEconomy.isBankMember(bank, name);
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy") && plugin instanceof BOSEconomy && !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
return true;
|
||||
}
|
||||
|
||||
public class BOSEAccount implements MethodAccount {
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy) {
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
this.BOSEconomy.registerPlayer(name);
|
||||
this.BOSEconomy.setPlayerMoney(name, balance, false);
|
||||
return true;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
if (!hasAccount(name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
return new BOSEAccount(name, this.BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
if (!hasBankAccount(bank, name))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
return new BOSEBankAccount(bank, BOSEconomy);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("boseconomy")
|
||||
&& plugin instanceof BOSEconomy
|
||||
&& !plugin.getDescription().getVersion().equals("0.6.2");
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
BOSEconomy = (BOSEconomy)plugin;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public class BOSEAccount implements MethodAccount
|
||||
{
|
||||
private String name;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public BOSEAccount(String name, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.name = name;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.BOSEconomy.getPlayerMoneyDouble(this.name);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public class BOSEBankAccount implements MethodBankAccount {
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
public boolean add(double amount)
|
||||
{
|
||||
return this.BOSEconomy.addPlayerMoney(this.name, amount, false);
|
||||
}
|
||||
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy) {
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance - amount), false);
|
||||
}
|
||||
|
||||
public String getBankName() {
|
||||
return this.bank;
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance * amount), false);
|
||||
}
|
||||
|
||||
public int getBankId() {
|
||||
return -1;
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setPlayerMoney(this.name, (balance / amount), false);
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.BOSEconomy.getBankMoneyDouble(bank);
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return (this.balance() >= amount);
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
return this.BOSEconomy.setBankMoney(bank, amount, true);
|
||||
}
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance + amount), false);
|
||||
}
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance - amount), false);
|
||||
}
|
||||
public boolean isNegative()
|
||||
{
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
double balance = this.balance();
|
||||
return this.BOSEconomy.setBankMoney(bank, (balance * amount), false);
|
||||
}
|
||||
public boolean remove()
|
||||
{
|
||||
return 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 class BOSEBankAccount implements MethodBankAccount
|
||||
{
|
||||
private String bank;
|
||||
private BOSEconomy BOSEconomy;
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return (this.balance() > amount);
|
||||
}
|
||||
public BOSEBankAccount(String bank, BOSEconomy bOSEconomy)
|
||||
{
|
||||
this.bank = bank;
|
||||
this.BOSEconomy = bOSEconomy;
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public String getBankName()
|
||||
{
|
||||
return this.bank;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return (this.balance() < 0);
|
||||
}
|
||||
public int getBankId()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return this.BOSEconomy.removeBank(bank);
|
||||
}
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -7,6 +7,7 @@ import me.ashtheking.currency.CurrencyList;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* MultiCurrency Method implementation.
|
||||
*
|
||||
@@ -14,107 +15,153 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class MCUR implements Method {
|
||||
private Currency currencyList;
|
||||
public class MCUR implements Method
|
||||
{
|
||||
private Currency currencyList;
|
||||
|
||||
public Object getPlugin() {
|
||||
return this.currencyList;
|
||||
}
|
||||
public Object getPlugin()
|
||||
{
|
||||
return this.currencyList;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "MultiCurrency";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "MultiCurrency";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "0.09";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "0.09";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return amount + " Currency";
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return amount + " Currency";
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return true;
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new MCurrencyAccount(name);
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, 0);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase(getName()) && plugin instanceof Currency;
|
||||
}
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, balance);
|
||||
return true;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
currencyList = (Currency) plugin;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new MCurrencyAccount(name);
|
||||
}
|
||||
|
||||
public class MCurrencyAccount implements MethodAccount{
|
||||
private String name;
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public MCurrencyAccount(String name) {
|
||||
this.name = name;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return (plugin.getDescription().getName().equalsIgnoreCase("Currency")
|
||||
|| plugin.getDescription().getName().equalsIgnoreCase("MultiCurrency"))
|
||||
&& plugin instanceof Currency;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return CurrencyList.getValue((String) CurrencyList.maxCurrency(name)[0], name);
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
currencyList = (Currency)plugin;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
CurrencyList.setValue((String) CurrencyList.maxCurrency(name)[0], name, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
return CurrencyList.add(name, amount);
|
||||
}
|
||||
public class MCurrencyAccount implements MethodAccount
|
||||
{
|
||||
private String name;
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
return CurrencyList.subtract(name, amount);
|
||||
}
|
||||
public MCurrencyAccount(String name)
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
return CurrencyList.multiply(name, amount);
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return CurrencyList.getValue((String)CurrencyList.maxCurrency(name)[0], name);
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
return CurrencyList.divide(name, amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
CurrencyList.setValue((String)CurrencyList.maxCurrency(name)[0], name, amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return CurrencyList.hasEnough(name, amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
return CurrencyList.add(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return CurrencyList.hasOver(name, amount);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
return CurrencyList.subtract(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return CurrencyList.hasUnder(name, amount);
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
return CurrencyList.multiply(name, amount);
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return CurrencyList.isNegative(name);
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
return CurrencyList.divide(name, amount);
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
return CurrencyList.remove(name);
|
||||
}
|
||||
}
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return CurrencyList.hasEnough(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return CurrencyList.hasOver(name, amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return CurrencyList.hasUnder(name, amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return CurrencyList.isNegative(name);
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
return CurrencyList.remove(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,13 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.nijiko.coelho.iConomy.iConomy;
|
||||
import com.nijiko.coelho.iConomy.system.Account;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* iConomy 4 Implementation of Method
|
||||
*
|
||||
@@ -14,122 +15,213 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo4 implements Method {
|
||||
private iConomy iConomy;
|
||||
public class iCo4 implements Method
|
||||
{
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
public iConomy getPlugin()
|
||||
{
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "4";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "4";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.getBank().format(amount);
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return com.nijiko.coelho.iConomy.iConomy.getBank().format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return this.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return com.nijiko.coelho.iConomy.iConomy.getBank().hasAccount(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount(this.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
try
|
||||
{
|
||||
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.account.getBalance();
|
||||
}
|
||||
try
|
||||
{
|
||||
com.nijiko.coelho.iConomy.iConomy.getBank().addAccount(name, balance);
|
||||
}
|
||||
catch (Exception E)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount(com.nijiko.coelho.iConomy.iConomy.getBank().getAccount(name));
|
||||
}
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.nijiko.coelho.iConomy.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.account == null) return false;
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
public class iCoAccount implements MethodAccount
|
||||
{
|
||||
private Account account;
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
public iCoAccount(Account account)
|
||||
{
|
||||
this.account = account;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.account.isNegative();
|
||||
}
|
||||
public Account getiCoAccount()
|
||||
{
|
||||
return account;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.account.getBalance();
|
||||
}
|
||||
|
||||
public boolean set(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return this.account.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return this.account.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return (this.balance() < amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return this.account.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.iConomy.iConomy;
|
||||
import com.iConomy.system.Account;
|
||||
import com.iConomy.system.BankAccount;
|
||||
import com.iConomy.system.Holdings;
|
||||
import com.iConomy.util.Constants;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
@@ -37,9 +37,14 @@ public class iCo5 implements Method
|
||||
return "5";
|
||||
}
|
||||
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public String format(double amount)
|
||||
{
|
||||
return this.iConomy.format(amount);
|
||||
return com.iConomy.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBanks()
|
||||
@@ -49,32 +54,61 @@ public class iCo5 implements Method
|
||||
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return (hasBanks()) && this.iConomy.Banks.exists(bank);
|
||||
return (hasBanks()) && com.iConomy.iConomy.Banks.exists(bank);
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return this.iConomy.hasAccount(name);
|
||||
return com.iConomy.iConomy.hasAccount(name);
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return (hasBank(bank)) && this.iConomy.getBank(bank).hasAccount(name);
|
||||
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(this.iConomy.getAccount(name));
|
||||
return new iCoAccount(com.iConomy.iConomy.getAccount(name));
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return new iCoBankAccount(this.iConomy.getBank(bank).getAccount(name));
|
||||
return new iCoBankAccount(com.iConomy.iConomy.getBank(bank).getAccount(name));
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iConomy.iConomy") && plugin instanceof iConomy;
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iConomy.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin)
|
||||
|
@@ -1,14 +1,15 @@
|
||||
package com.earth2me.essentials.register.payment.methods;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import com.iCo6.iConomy;
|
||||
import com.iCo6.system.Account;
|
||||
import com.iCo6.system.Accounts;
|
||||
import com.iCo6.system.Holdings;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
/**
|
||||
* iConomy 6 Implementation of Method
|
||||
*
|
||||
@@ -16,127 +17,197 @@ import org.bukkit.plugin.Plugin;
|
||||
* @copyright (c) 2011
|
||||
* @license AOL license <http://aol.nexua.org>
|
||||
*/
|
||||
public class iCo6 implements Method {
|
||||
private iConomy iConomy;
|
||||
public class iCo6 implements Method
|
||||
{
|
||||
private iConomy iConomy;
|
||||
|
||||
public iConomy getPlugin() {
|
||||
return this.iConomy;
|
||||
}
|
||||
public iConomy getPlugin()
|
||||
{
|
||||
return this.iConomy;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return "iConomy";
|
||||
}
|
||||
public String getName()
|
||||
{
|
||||
return "iConomy";
|
||||
}
|
||||
|
||||
public String getVersion() {
|
||||
return "6";
|
||||
}
|
||||
public String getVersion()
|
||||
{
|
||||
return "6";
|
||||
}
|
||||
|
||||
public String format(double amount) {
|
||||
return this.iConomy.format(amount);
|
||||
}
|
||||
public int fractionalDigits()
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
public boolean hasBanks() {
|
||||
return false;
|
||||
}
|
||||
public String format(double amount)
|
||||
{
|
||||
return com.iCo6.iConomy.format(amount);
|
||||
}
|
||||
|
||||
public boolean hasBank(String bank) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasBanks()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasAccount(String name) {
|
||||
return (new Accounts()).exists(name);
|
||||
}
|
||||
public boolean hasBank(String bank)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasBankAccount(String bank, String name) {
|
||||
return false;
|
||||
}
|
||||
public boolean hasAccount(String name)
|
||||
{
|
||||
return (new Accounts()).exists(name);
|
||||
}
|
||||
|
||||
public MethodAccount getAccount(String name) {
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
}
|
||||
public boolean hasBankAccount(String bank, String name)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public MethodBankAccount getBankAccount(String bank, String name) {
|
||||
return null;
|
||||
}
|
||||
public boolean createAccount(String name)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isCompatible(Plugin plugin) {
|
||||
try { Class.forName("com.iCo6.IO"); }
|
||||
catch(Exception e) { return false; }
|
||||
return (new Accounts()).create(name);
|
||||
}
|
||||
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy") && plugin.getClass().getName().equals("com.iCo6.iConomy") && plugin instanceof iConomy;
|
||||
}
|
||||
public boolean createAccount(String name, Double balance)
|
||||
{
|
||||
if (hasAccount(name))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setPlugin(Plugin plugin) {
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
return (new Accounts()).create(name, balance);
|
||||
}
|
||||
|
||||
public class iCoAccount implements MethodAccount {
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
public MethodAccount getAccount(String name)
|
||||
{
|
||||
return new iCoAccount((new Accounts()).get(name));
|
||||
}
|
||||
|
||||
public iCoAccount(Account account) {
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
public MethodBankAccount getBankAccount(String bank, String name)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
public Account getiCoAccount() {
|
||||
return account;
|
||||
}
|
||||
public boolean isCompatible(Plugin plugin)
|
||||
{
|
||||
return plugin.getDescription().getName().equalsIgnoreCase("iconomy")
|
||||
&& plugin.getClass().getName().equals("com.iCo6.iConomy")
|
||||
&& plugin instanceof iConomy;
|
||||
}
|
||||
|
||||
public double balance() {
|
||||
return this.holdings.getBalance();
|
||||
}
|
||||
public void setPlugin(Plugin plugin)
|
||||
{
|
||||
iConomy = (iConomy)plugin;
|
||||
}
|
||||
|
||||
public boolean set(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean add(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
public class iCoAccount implements MethodAccount
|
||||
{
|
||||
private Account account;
|
||||
private Holdings holdings;
|
||||
|
||||
public boolean subtract(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
public iCoAccount(Account account)
|
||||
{
|
||||
this.account = account;
|
||||
this.holdings = account.getHoldings();
|
||||
}
|
||||
|
||||
public boolean multiply(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
public Account getiCoAccount()
|
||||
{
|
||||
return account;
|
||||
}
|
||||
|
||||
public boolean divide(double amount) {
|
||||
if(this.holdings == null) return false;
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
public double balance()
|
||||
{
|
||||
return this.holdings.getBalance();
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount) {
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
public boolean set(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.setBalance(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount) {
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
public boolean add(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.add(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount) {
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
public boolean subtract(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.subtract(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isNegative() {
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
public boolean multiply(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.multiply(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean remove() {
|
||||
if(this.account == null) return false;
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
public boolean divide(double amount)
|
||||
{
|
||||
if (this.holdings == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.holdings.divide(amount);
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean hasEnough(double amount)
|
||||
{
|
||||
return this.holdings.hasEnough(amount);
|
||||
}
|
||||
|
||||
public boolean hasOver(double amount)
|
||||
{
|
||||
return this.holdings.hasOver(amount);
|
||||
}
|
||||
|
||||
public boolean hasUnder(double amount)
|
||||
{
|
||||
return this.holdings.hasUnder(amount);
|
||||
}
|
||||
|
||||
public boolean isNegative()
|
||||
{
|
||||
return this.holdings.isNegative();
|
||||
}
|
||||
|
||||
public boolean remove()
|
||||
{
|
||||
if (this.account == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
this.account.remove();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
Essentials/src/com/earth2me/essentials/settings/Backup.java
Normal file
17
Essentials/src/com/earth2me/essentials/settings/Backup.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Backup extends StorageObject
|
||||
{
|
||||
@Comment("Interval in minutes")
|
||||
private long interval = 60;
|
||||
@Comment("Add a command that backups your data, e.g. 'rdiff-backup World1 backups/World1'")
|
||||
private String command;
|
||||
}
|
32
Essentials/src/com/earth2me/essentials/settings/Chat.java
Normal file
32
Essentials/src/com/earth2me/essentials/settings/Chat.java
Normal file
@@ -0,0 +1,32 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Chat extends StorageObject
|
||||
{
|
||||
@Comment("The character(s) to prefix all nicknames, so that you know they are not true usernames.")
|
||||
private String nicknamePrefix = "~";
|
||||
|
||||
@Comment("Disable this if you have any other plugin, that modifies the displayname of a user.")
|
||||
private boolean changeDisplayname = true;
|
||||
|
||||
private String displaynameFormat = "{PREFIX}{NICKNAMEPREFIX}{NAME}{SUFFIX}";
|
||||
|
||||
@Comment({
|
||||
"If EssentialsChat is installed, this will define how far a player's voice travels, in blocks. Set to 0 to make all chat global.",
|
||||
"Note that users with the \"essentials.chat.spy\" permission will hear everything, regardless of this setting.",
|
||||
"Users with essentials.chat.shout can override this by prefixing text with an exclamation mark (!)",
|
||||
"Or with essentials.chat.question can override this by prefixing text with a question mark (?)",
|
||||
"You can add command costs for shout/question by adding chat-shout and chat-question to the command costs section."
|
||||
})
|
||||
private int localRadius = 0;
|
||||
|
||||
@Comment("Set the default chat format here, it will be overwritten by group specific chat formats.")
|
||||
private String defaultFormat = "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}";
|
||||
}
|
@@ -0,0 +1,47 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.settings.commands.Afk;
|
||||
import com.earth2me.essentials.settings.commands.God;
|
||||
import com.earth2me.essentials.settings.commands.Help;
|
||||
import com.earth2me.essentials.settings.commands.Home;
|
||||
import com.earth2me.essentials.settings.commands.Kit;
|
||||
import com.earth2me.essentials.settings.commands.Lightning;
|
||||
import com.earth2me.essentials.settings.commands.Spawnmob;
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.ListType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Commands extends StorageObject
|
||||
{
|
||||
private Afk afk = new Afk();
|
||||
private God god = new God();
|
||||
private Help help = new Help();
|
||||
private Home home = new Home();
|
||||
private Kit kit = new Kit();
|
||||
private Lightning lightning = new Lightning();
|
||||
private Spawnmob spawnmob = new Spawnmob();
|
||||
@ListType
|
||||
@Comment(
|
||||
{
|
||||
"When a command conflicts with another plugin, by default, Essentials will try to force the OTHER plugin to take",
|
||||
"priority. If a command is in this list, Essentials will try to give ITSELF priority. This does not always work:",
|
||||
"usually whichever plugin was updated most recently wins out. However, the full name of the command will always work.",
|
||||
"For example, if WorldGuard and Essentials are both enabled, and WorldGuard takes control over /god, /essentials:god",
|
||||
"will still map to Essentials, whereas it might normally get forced upon WorldGuard. Commands prefixed with an \"e\",",
|
||||
"such as /egod, will always grant Essentials priority.",
|
||||
"We should try to take priority over /god. If this doesn't work, use /essentials:god or /egod.",
|
||||
"If god is set using WorldGuard, use /ungod to remove then use whichever you see fit."
|
||||
})
|
||||
private List<String> overwritten = new ArrayList<String>();
|
||||
|
||||
@ListType
|
||||
@Comment("Disabled commands will be completelly unavailable on the server.")
|
||||
private List<String> disabled = new ArrayList<String>();
|
||||
}
|
42
Essentials/src/com/earth2me/essentials/settings/Economy.java
Normal file
42
Essentials/src/com/earth2me/essentials/settings/Economy.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.MapType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Economy extends StorageObject
|
||||
{
|
||||
@Comment("Defines the balance with which new players begin. Defaults to 0.")
|
||||
private double startingBalance = 0.0;
|
||||
@MapType(Double.class)
|
||||
@Comment("Defines the cost to use the given commands PER USE")
|
||||
private Map<String, Double> commandCosts = new HashMap<String, Double>();
|
||||
@Comment("Set this to a currency symbol you want to use.")
|
||||
private String currencySymbol = "$";
|
||||
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return currencySymbol == null || currencySymbol.isEmpty() ? "$" : currencySymbol.substring(0, 1);
|
||||
}
|
||||
private final transient static double MAXMONEY = 10000000000000.0;
|
||||
@Comment(
|
||||
{
|
||||
"Set the maximum amount of money a player can have",
|
||||
"The amount is always limited to 10 trillions because of the limitations of a java double"
|
||||
})
|
||||
private double maxMoney = MAXMONEY;
|
||||
|
||||
public double getMaxMoney()
|
||||
{
|
||||
return Math.abs(maxMoney) > MAXMONEY ? MAXMONEY : Math.abs(maxMoney);
|
||||
}
|
||||
@Comment("Enable this to log all interactions with trade/buy/sell signs and sell command")
|
||||
private boolean logEnabled = false;
|
||||
}
|
33
Essentials/src/com/earth2me/essentials/settings/General.java
Normal file
33
Essentials/src/com/earth2me/essentials/settings/General.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class General extends StorageObject
|
||||
{
|
||||
@Comment("Backup runs a command while saving is disabled")
|
||||
private Backup backup = new Backup();
|
||||
@Comment("You can disable the death messages of minecraft.")
|
||||
private boolean deathMessages = true;
|
||||
@Comment("Turn this on, if you want to see more error messages, if something goes wrong.")
|
||||
private boolean debug = false;
|
||||
@Comment(
|
||||
{
|
||||
"Set the locale here, if you want to change the language of Essentials.",
|
||||
"If this is not set, Essentials will use the language of your computer.",
|
||||
"Available locales: da, de, en, fr, nl"
|
||||
})
|
||||
private String locale;
|
||||
@Comment(
|
||||
{
|
||||
"Should we announce to the server when someone logs in for the first time?",
|
||||
"If so, use this format, replacing {DISPLAYNAME} with the player name.",
|
||||
"If not, set to ''"
|
||||
})
|
||||
private String newPlayerAnnouncement = "&dWelcome {DISPLAYNAME} to the server!";
|
||||
}
|
@@ -0,0 +1,27 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class GroupOptions extends StorageObject
|
||||
{
|
||||
@Comment("Message format of chat messages")
|
||||
private String messageFormat;
|
||||
@Comment("Prefix for name")
|
||||
private String prefix;
|
||||
@Comment("Suffix for name")
|
||||
private String suffix;
|
||||
@Comment("Amount of homes a player can have")
|
||||
private Integer homes;
|
||||
@Comment("Cooldown between teleports")
|
||||
private Integer teleportCooldown;
|
||||
@Comment("Delay before teleport")
|
||||
private Integer teleportDelay;
|
||||
@Comment("Cooldown between heals")
|
||||
private Integer healCooldown;
|
||||
}
|
27
Essentials/src/com/earth2me/essentials/settings/Groups.java
Normal file
27
Essentials/src/com/earth2me/essentials/settings/Groups.java
Normal file
@@ -0,0 +1,27 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.MapType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.LinkedHashMap;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Groups extends StorageObject
|
||||
{
|
||||
public Groups() {
|
||||
GroupOptions defaultOptions = new GroupOptions();
|
||||
groups.put("default", defaultOptions);
|
||||
}
|
||||
@Comment(
|
||||
{
|
||||
"The order of the groups matters, the groups are checked from top to bottom.",
|
||||
"All group names have to be lower case.",
|
||||
"The groups can be connected to users using the permission essentials.groups.groupname"
|
||||
})
|
||||
@MapType(GroupOptions.class)
|
||||
private LinkedHashMap<String, GroupOptions> groups = new LinkedHashMap<String, GroupOptions>();
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Location extends StorageObject
|
||||
{
|
||||
private String worldName = "Test";
|
||||
private double x;
|
||||
private double y;
|
||||
private double z;
|
||||
private Float yaw;
|
||||
private Float pitch;
|
||||
|
||||
public org.bukkit.Location getBukkit(Server server)
|
||||
{
|
||||
if (yaw == null || pitch == null)
|
||||
{
|
||||
return new org.bukkit.Location(server.getWorld(worldName), x, y, z);
|
||||
}
|
||||
return new org.bukkit.Location(server.getWorld(worldName), x, y, z, yaw, pitch);
|
||||
}
|
||||
}
|
@@ -0,0 +1,58 @@
|
||||
package com.earth2me.essentials.settings;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Settings extends StorageObject
|
||||
{
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| General Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private General general = new General();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Chat Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Chat chat = new Chat();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Economy Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Economy economy = new Economy();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Commands Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Commands commands = new Commands();
|
||||
@Comment(
|
||||
{
|
||||
"##########################################################",
|
||||
"+------------------------------------------------------+ #",
|
||||
"| Group Settings | #",
|
||||
"+------------------------------------------------------+ #",
|
||||
"##########################################################"
|
||||
})
|
||||
private Groups groups = new Groups();
|
||||
}
|
@@ -0,0 +1,36 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Afk extends StorageObject
|
||||
{
|
||||
@Comment(
|
||||
{
|
||||
"After this timeout in seconds, the user will be set as afk.",
|
||||
"Set to -1 for no timeout."
|
||||
})
|
||||
private int autoAFK = 300;
|
||||
@Comment(
|
||||
{
|
||||
"Auto-AFK Kick",
|
||||
"After this timeout in seconds, the user will be kicked from the server.",
|
||||
"Set to -1 for no timeout."
|
||||
})
|
||||
private int autoAFKKick = -1;
|
||||
@Comment(
|
||||
{
|
||||
"Set this to true, if you want to freeze the player, if he is afk.",
|
||||
"Other players or monsters can't push him out of afk mode then.",
|
||||
"This will also enable temporary god mode for the afk player.",
|
||||
"The player has to use the command /afk to leave the afk mode.",
|
||||
"You have to add a message to your welcome message or help page,",
|
||||
"since the player will not get a message, if he tries to move."
|
||||
})
|
||||
private boolean freezeAFKPlayers = false;
|
||||
}
|
@@ -0,0 +1,14 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper=false)
|
||||
public class God extends StorageObject
|
||||
{
|
||||
@Comment("Turn off god mode when people exit")
|
||||
private boolean removeOnDisconnect = false;
|
||||
}
|
@@ -0,0 +1,23 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Help extends StorageObject
|
||||
{
|
||||
@Comment("Show other plugins commands in help")
|
||||
private boolean showNonEssCommandsInHelp = true;
|
||||
@Comment(
|
||||
{
|
||||
"Hide plugins which don't give a permission in their plugin.yml for each command.",
|
||||
"You can override a true value here for a single plugin by adding a permission to a user/group.",
|
||||
"The individual permission is: essentials.help.<plugin>, anyone with essentials.* or '*' will see all help this setting reguardless.",
|
||||
"You can use negative permissions to remove access to just a single plugins help if the following is enabled."
|
||||
})
|
||||
private boolean hidePermissionlessCommands = true;
|
||||
}
|
@@ -0,0 +1,24 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.Comment;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Home extends StorageObject
|
||||
{
|
||||
@Comment("When players die, should they respawn at their homes, instead of the spawnpoint?")
|
||||
private boolean respawnAtHome = false;
|
||||
@Comment(
|
||||
{
|
||||
"When a player interacts with a bed, should their home be set to that location?",
|
||||
"If you enable this and remove default player access to the /sethome command, ",
|
||||
"you can make beds the only way for players to set their home location."
|
||||
})
|
||||
private boolean bedSetsHome = false;
|
||||
@Comment("If no home is set, should the player be send to spawn, when /home is used.")
|
||||
private boolean spawnIfNoHome = false;
|
||||
}
|
@@ -0,0 +1,28 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.MapType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class Kit extends StorageObject
|
||||
{
|
||||
|
||||
public Kit()
|
||||
{
|
||||
final KitObject kit = new KitObject();
|
||||
kit.setDelay(10.0);
|
||||
kit.setItems(Arrays.asList("277 1,278 1,279 1".split(",")));
|
||||
kits.put("tools", kit);
|
||||
}
|
||||
|
||||
|
||||
@MapType(KitObject.class)
|
||||
private Map<String,KitObject> kits = new HashMap<String, KitObject>();
|
||||
}
|
@@ -0,0 +1,18 @@
|
||||
package com.earth2me.essentials.settings.commands;
|
||||
|
||||
import com.earth2me.essentials.storage.ListType;
|
||||
import com.earth2me.essentials.storage.StorageObject;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class KitObject extends StorageObject
|
||||
{
|
||||
@ListType
|
||||
private List<String> items = new ArrayList<String>();
|
||||
private Double delay;
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user