mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-06 12:40:45 +02:00
Compare commits
352 Commits
stable-2.3
...
stable-2.5
Author | SHA1 | Date | |
---|---|---|---|
|
621618e41f | ||
|
54559172c6 | ||
|
6ccb60813a | ||
|
2067bb8f0d | ||
|
b34119901e | ||
|
4f31d2779d | ||
|
ed29f29622 | ||
|
b8e41df0f6 | ||
|
602517473d | ||
|
cee0823db4 | ||
|
b317aef8c9 | ||
|
8b41219fcc | ||
|
61fa43a769 | ||
|
fdbc6fa94f | ||
|
28dd14d38c | ||
|
0ffe24903a | ||
|
f6e6e0042a | ||
|
e550a7cc44 | ||
|
9efc0840e3 | ||
|
82165a2af6 | ||
|
815b700eac | ||
|
fcda9f9d3b | ||
|
aa663c0c98 | ||
|
bda2f5e615 | ||
|
377f967dab | ||
|
63a4fe32c1 | ||
|
06dc9c25af | ||
|
feb1c53004 | ||
|
2530a5018f | ||
|
4bb1185bd5 | ||
|
d5c8d0c1bf | ||
|
8828fb0868 | ||
|
cc29ebbbc9 | ||
|
1c44a25a4a | ||
|
0483635a5c | ||
|
cf21ecee2e | ||
|
3b59dd0b02 | ||
|
5467e502a5 | ||
|
e805d1047f | ||
|
dc99efb0a7 | ||
|
6a156ede68 | ||
|
4a963b22f1 | ||
|
6af9ec266b | ||
|
150a0e0ddd | ||
|
d388290427 | ||
|
c8ba06f0ee | ||
|
a65390ed98 | ||
|
6b85b306ef | ||
|
faa7e0e7a9 | ||
|
fdbb6510ef | ||
|
aa3606007a | ||
|
d0bf1905a9 | ||
|
548666b79b | ||
|
6dbb5bc605 | ||
|
15687c20d0 | ||
|
81cc5b1f28 | ||
|
7aea8a3fce | ||
|
db5974970d | ||
|
d2bc7e01a2 | ||
|
3d232e13d9 | ||
|
83b71eef5e | ||
|
13e5f22c25 | ||
|
b88d0f88a1 | ||
|
d727cad2db | ||
|
fd1256b449 | ||
|
c3235b3694 | ||
|
c1c3005454 | ||
|
a3c71e4617 | ||
|
5aa2bc1706 | ||
|
277c623a77 | ||
|
e37db99c56 | ||
|
be83383fd5 | ||
|
033151a170 | ||
|
ba2539db67 | ||
|
e3a470e264 | ||
|
21d0661d79 | ||
|
1556801834 | ||
|
e0dc003464 | ||
|
81f0ad4d92 | ||
|
1ce6be5944 | ||
|
cc31fbed8e | ||
|
29a15dfe18 | ||
|
2f00865847 | ||
|
462fe18b15 | ||
|
31326d530f | ||
|
9f3eb461a9 | ||
|
48230f615d | ||
|
34b0deba29 | ||
|
088f50ce8a | ||
|
d9a93d8dff | ||
|
5ad12b52f8 | ||
|
747776344b | ||
|
f979a79081 | ||
|
e6685abe4d | ||
|
f867f675b9 | ||
|
d9bfabd652 | ||
|
d9b88a83d1 | ||
|
a8fdce257b | ||
|
c3a8958046 | ||
|
d0345e45b6 | ||
|
5ab3422b29 | ||
|
66c4a24852 | ||
|
db27a8c627 | ||
|
78c376af79 | ||
|
b749cd4e42 | ||
|
a0554f566d | ||
|
1696d7ae71 | ||
|
ad8ad8b574 | ||
|
3c28dabfad | ||
|
a38fe6acd4 | ||
|
f104c2e8f6 | ||
|
4dc92a144e | ||
|
1a7b198353 | ||
|
25c9557c59 | ||
|
963fd7cf01 | ||
|
d7080950b0 | ||
|
9c51f6e177 | ||
|
39352da929 | ||
|
ad65e66a7c | ||
|
132ddc323f | ||
|
411e96bb18 | ||
|
705f9c267c | ||
|
d2db6348d9 | ||
|
ae7275c7ad | ||
|
cecb9867d9 | ||
|
7e65038ae7 | ||
|
37d77f3e89 | ||
|
f4ef5a2094 | ||
|
af364b4bb4 | ||
|
cd4c58cfcb | ||
|
3898970bba | ||
|
fb8f89e6dc | ||
|
1b0b0b1b57 | ||
|
4c89ef5638 | ||
|
5478a47e25 | ||
|
48affa91b0 | ||
|
fa2f97760b | ||
|
557ca86ab2 | ||
|
b32d28be37 | ||
|
b9b5db8ccd | ||
|
7ec1ca651f | ||
|
8245adfd08 | ||
|
beea6879b1 | ||
|
e4ba0245be | ||
|
aefbf921fe | ||
|
8a1fb88ecd | ||
|
962b6848c4 | ||
|
2086b8c978 | ||
|
343291b210 | ||
|
7ed57bc291 | ||
|
367e9840cc | ||
|
ea590c2ed1 | ||
|
cb5ab32be6 | ||
|
244674124b | ||
|
39770cd46d | ||
|
f58fa10686 | ||
|
da8d5454d4 | ||
|
71c11d05fd | ||
|
dab37c7b5b | ||
|
ce14779d2b | ||
|
a447bc7e66 | ||
|
4d3e8332a8 | ||
|
367fcdd029 | ||
|
3b838cc23d | ||
|
f2d9b10e87 | ||
|
fc2c67ceda | ||
|
d02380edba | ||
|
3a1d0032c6 | ||
|
ef37306701 | ||
|
34568ea8fc | ||
|
56a2398d9b | ||
|
db03b3c09e | ||
|
b272374072 | ||
|
8afde1ccc0 | ||
|
674128b3f7 | ||
|
c2936186f8 | ||
|
5006c68af2 | ||
|
526df76ca9 | ||
|
e92aeee91b | ||
|
f2107047da | ||
|
f280985dd6 | ||
|
f610dd9c72 | ||
|
7e4cbd7b26 | ||
|
ffd1154ca3 | ||
|
7f4ba16388 | ||
|
66dafdca0d | ||
|
3a8b888e7c | ||
|
ed1aa2f9dc | ||
|
4eb94e7fac | ||
|
16b101b958 | ||
|
ff8564787a | ||
|
6616d9a62f | ||
|
ae053dea58 | ||
|
335c9f37ab | ||
|
914a44007d | ||
|
bbd10b90c0 | ||
|
d93120257b | ||
|
e763b362d9 | ||
|
5ae0ab745f | ||
|
e5eb1ca0cb | ||
|
ecaecc5e62 | ||
|
e596f85953 | ||
|
aef2ca3e5d | ||
|
bd7a50ad07 | ||
|
5346b112a4 | ||
|
d95d7745ad | ||
|
6c9a57d4b3 | ||
|
60235d0da4 | ||
|
995f18bb0f | ||
|
a720bf33ce | ||
|
ea2649db5e | ||
|
0f87670991 | ||
|
b53fc9cadc | ||
|
4b35e1b729 | ||
|
016defd043 | ||
|
2aa88d05cf | ||
|
c530030e5d | ||
|
48e0073b31 | ||
|
ce6d5596aa | ||
|
40e106db13 | ||
|
3dc0659f66 | ||
|
8f32d66e03 | ||
|
1c11ab0957 | ||
|
fafd9b20a9 | ||
|
a6d60dbc94 | ||
|
fa5d6fbfae | ||
|
88ded926f4 | ||
|
3b9a07e560 | ||
|
512a1b9183 | ||
|
e652ed2981 | ||
|
28db891aa5 | ||
|
b63ae9b771 | ||
|
fb834bf104 | ||
|
953ce38d63 | ||
|
ca29f18850 | ||
|
503b4fee55 | ||
|
27c84ceaac | ||
|
b7cb11cd95 | ||
|
cfa8b8e2f4 | ||
|
70621e3eff | ||
|
0731580cc9 | ||
|
8bb3a76366 | ||
|
d67ccd03ca | ||
|
5e2f4bcbb2 | ||
|
1331743ecf | ||
|
2b8d5a09a2 | ||
|
ed06b29dd7 | ||
|
209a9a2f95 | ||
|
d50d8bfee0 | ||
|
b0e606568f | ||
|
22ea5b0f8b | ||
|
6676efe029 | ||
|
6b360da8d8 | ||
|
198b205d83 | ||
|
b9e56d100c | ||
|
0a924bf226 | ||
|
2ea5e6c03b | ||
|
efaed85188 | ||
|
c378d98b0f | ||
|
9d6727daf2 | ||
|
ca9364d25b | ||
|
7fc6d73241 | ||
|
036bbbb462 | ||
|
c3a8a51ecd | ||
|
c6aa5f1e68 | ||
|
a16ced78a5 | ||
|
cdea68443a | ||
|
e24c053b95 | ||
|
798d4458d4 | ||
|
a228708138 | ||
|
5d8f5cecee | ||
|
34f650e270 | ||
|
49bdf5719e | ||
|
fd2d2456b9 | ||
|
adc7502115 | ||
|
631c7f30b6 | ||
|
46cba7a9a7 | ||
|
246383804a | ||
|
32bbe877aa | ||
|
0eee5acac7 | ||
|
7d112a957c | ||
|
76c06ce17a | ||
|
350a951e8b | ||
|
6cc742b139 | ||
|
ebc56c0e15 | ||
|
f0c503dd13 | ||
|
bfa8b26661 | ||
|
772bf4c7d0 | ||
|
edefb21142 | ||
|
01f69b3f2b | ||
|
26c9b34744 | ||
|
dfad01d558 | ||
|
b974410dd9 | ||
|
d01e2e0a3b | ||
|
5a544fd251 | ||
|
f5fac6f9f5 | ||
|
5d925aa338 | ||
|
8136179e55 | ||
|
dea44d7cbc | ||
|
e0597f2df1 | ||
|
99268b9d9e | ||
|
bcf81d9f0a | ||
|
775c8d34dd | ||
|
75973f69a5 | ||
|
f04b7133eb | ||
|
b1446154bf | ||
|
640f51564a | ||
|
5c258c03dc | ||
|
bc8aa0c77a | ||
|
cc18f95bc9 | ||
|
9e5c64ae9c | ||
|
7bbb62ce50 | ||
|
d8a81923b1 | ||
|
1321f8de5d | ||
|
4bfc8e1459 | ||
|
4f16c8b5a7 | ||
|
a45e620946 | ||
|
d877880171 | ||
|
a91aeb1a76 | ||
|
b7791caa75 | ||
|
6c862e72b5 | ||
|
710088fb13 | ||
|
198607d425 | ||
|
4bbc2aa8d5 | ||
|
c038751c0b | ||
|
f1b544a96f | ||
|
9a4ef7cd20 | ||
|
bc3d8d5ece | ||
|
1751baeed6 | ||
|
7b825cc8d5 | ||
|
a005436510 | ||
|
541fc51780 | ||
|
aef2dd35d6 | ||
|
e94a01b149 | ||
|
1a572bca2e | ||
|
5a47d18a9b | ||
|
991a5cb24c | ||
|
e8e97e86a0 | ||
|
f6cedda1e2 | ||
|
3dab3d8df8 | ||
|
3e359b5b48 | ||
|
09e17a4d6c | ||
|
651b89d97b | ||
|
0ff89abeee | ||
|
8ba3e3c2f9 | ||
|
e53ce03d36 | ||
|
aeb3b0f37c | ||
|
2d038579ba | ||
|
ba86a338c2 | ||
|
1bcc2e6e50 | ||
|
797dde94e1 | ||
|
b83bb1faa3 |
5
.gitignore
vendored
5
.gitignore
vendored
@@ -22,4 +22,7 @@
|
||||
/EssentialsXMPP/dist/
|
||||
/EssentialsXMPP/build/
|
||||
/EssentialsProtect/dist/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
@@ -636,6 +636,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
@@ -650,6 +657,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="jar"/>
|
||||
<param name="transfer.built-jar.properties" value="${built-jar.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-jar.properties}"/>
|
||||
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/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">
|
||||
@@ -1121,6 +1135,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsPermissionsCommands}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsPermissionsCommands}/build.xml" name="call.script"/>
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsProtect}" name="call.subproject"/>
|
||||
@@ -1135,6 +1156,13 @@ is divided into following sections:
|
||||
<param name="call.target" value="clean"/>
|
||||
<param name="transfer.built-clean.properties" value="${built-clean.properties}"/>
|
||||
</antcall>
|
||||
<antcall target="-maybe-call-dep">
|
||||
<param name="call.built.properties" value="${built-clean.properties}"/>
|
||||
<param location="${project.EssentialsXMPP}" name="call.subproject"/>
|
||||
<param location="${project.EssentialsXMPP}/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}"/>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=c4188209
|
||||
build.xml.data.CRC32=2bd2dd75
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.43.1.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=c4188209
|
||||
nbproject/build-impl.xml.script.CRC32=73a4865f
|
||||
nbproject/build-impl.xml.data.CRC32=2bd2dd75
|
||||
nbproject/build-impl.xml.script.CRC32=769e541b
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
|
@@ -31,11 +31,13 @@ jar.compress=false
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsPermissionsCommands.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
@@ -69,15 +71,19 @@ project.EssentialsChat=../EssentialsChat
|
||||
project.EssentialsGeoIP=../EssentialsGeoIP
|
||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsPermissionsCommands=../EssentialsPermissionsCommands
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
reference.Essentials.jar=${project.Essentials}/dist/Essentials.jar
|
||||
reference.EssentialsChat.jar=${project.EssentialsChat}/dist/EssentialsChat.jar
|
||||
reference.EssentialsGeoIP.jar=${project.EssentialsGeoIP}/dist/EssentialsGeoIP.jar
|
||||
reference.EssentialsGroupBridge.jar=${project.EssentialsGroupBridge}/dist/EssentialsGroupBridge.jar
|
||||
reference.EssentialsGroupManager.jar=${project.EssentialsGroupManager}/dist/EssentialsGroupManager.jar
|
||||
reference.EssentialsPermissionsCommands.jar=${project.EssentialsPermissionsCommands}/dist/EssentialsPermissionsCommands.jar
|
||||
reference.EssentialsProtect.jar=${project.EssentialsProtect}/dist/EssentialsProtect.jar
|
||||
reference.EssentialsSpawn.jar=${project.EssentialsSpawn}/dist/EssentialsSpawn.jar
|
||||
reference.EssentialsXMPP.jar=${project.EssentialsXMPP}/dist/EssentialsXMPP.jar
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}
|
||||
|
@@ -55,6 +55,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsPermissionsCommands</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
<script>build.xml</script>
|
||||
<target>jar</target>
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsProtect</foreign-project>
|
||||
<artifact-type>jar</artifact-type>
|
||||
@@ -71,6 +79,14 @@
|
||||
<clean-target>clean</clean-target>
|
||||
<id>jar</id>
|
||||
</reference>
|
||||
<reference>
|
||||
<foreign-project>EssentialsXMPP</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>
|
||||
|
@@ -26,20 +26,22 @@ dist.jar=${dist.dir}/Essentials.jar
|
||||
dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy.jar=../lib/BOSEconomy.jar
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.craftbukkit-0.0.1-SNAPSHOT.jar=..\\lib\\craftbukkit-0.0.1-SNAPSHOT.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
file.reference.iCo5.jar=../lib/iCo5.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.Permissions.jar=..\\lib\\Permissions.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions.jar}:\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.BOSEconomy.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
157
Essentials/src/com/earth2me/essentials/BanWorkaround.java
Normal file
157
Essentials/src/com/earth2me/essentials/BanWorkaround.java
Normal file
@@ -0,0 +1,157 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ServerConfigurationManager;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class BanWorkaround implements IConf
|
||||
{
|
||||
private transient final IEssentials ess;
|
||||
private transient final ServerConfigurationManager scm;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final Set<String> bans = new HashSet<String>();
|
||||
private transient final Set<String> bannedIps = new HashSet<String>();
|
||||
|
||||
public BanWorkaround(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
this.scm = ((CraftServer)ess.getServer()).getHandle();
|
||||
}
|
||||
|
||||
public void banByName(final String name)
|
||||
{
|
||||
scm.a(name);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void unbanByName(String name)
|
||||
{
|
||||
scm.b(name);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void banByIp(final String ip)
|
||||
{
|
||||
scm.c(ip);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public void unbanByIp(final String ip)
|
||||
{
|
||||
scm.d(ip);
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
public boolean isNameBanned(final String name)
|
||||
{
|
||||
return bans.contains(name.toLowerCase());
|
||||
}
|
||||
|
||||
public boolean isIpBanned(final String ip)
|
||||
{
|
||||
return bannedIps.contains(ip.toLowerCase());
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
//I don't like this but it needs to be done until CB fixors
|
||||
final File file = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-players.txt");
|
||||
try
|
||||
{
|
||||
if (!file.exists())
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
bans.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bans.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
|
||||
final File ipFile = new File(ess.getDataFolder().getParentFile().getParentFile(), "banned-ips.txt");
|
||||
try
|
||||
{
|
||||
if (!ipFile.exists())
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
|
||||
try
|
||||
{
|
||||
bannedIps.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bannedIps.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
}
|
@@ -0,0 +1,51 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class BukkitPermissionsHandler implements IPermissionsHandler
|
||||
{
|
||||
public String getGroup(Player base)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
|
||||
public boolean canBuild(Player base, String group)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inGroup(Player base, String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player base, String node)
|
||||
{
|
||||
if (base.hasPermission("-" + node))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final String[] parts = node.split("\\.");
|
||||
final StringBuilder sb = new StringBuilder();
|
||||
for (String part : parts)
|
||||
{
|
||||
if (base.hasPermission(sb.toString() + "*"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
sb.append(part).append(".");
|
||||
}
|
||||
return base.hasPermission(node);
|
||||
}
|
||||
|
||||
public String getPrefix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getSuffix(Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@@ -1,104 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Charge
|
||||
{
|
||||
private final String command;
|
||||
private final Double costs;
|
||||
private final ItemStack items;
|
||||
private final IEssentials ess;
|
||||
|
||||
public Charge(String command, IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
public Charge(double money, IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
public Charge(ItemStack items, IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
private Charge(String command, Double money, ItemStack item, IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.costs = money;
|
||||
this.items = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(IUser user) throws Exception
|
||||
{
|
||||
double mon = user.getMoney();
|
||||
if (costs != null)
|
||||
{
|
||||
if (mon < costs && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(costs);
|
||||
}
|
||||
if (items != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, items))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", items.getAmount(), items.getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, items);
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
if (user.isAuthorized("essentials.nocommandcost.all")
|
||||
|| user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
double cost = ess.getSettings().getCommandCost(command.startsWith("/") ? command.substring(1) : command);
|
||||
if (mon < cost && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
}
|
15
Essentials/src/com/earth2me/essentials/ChargeException.java
Normal file
15
Essentials/src/com/earth2me/essentials/ChargeException.java
Normal file
@@ -0,0 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
|
||||
public class ChargeException extends Exception
|
||||
{
|
||||
public ChargeException(final String message)
|
||||
{
|
||||
super(message);
|
||||
}
|
||||
|
||||
public ChargeException(final String message, final Throwable throwable)
|
||||
{
|
||||
super(message, throwable);
|
||||
}
|
||||
}
|
@@ -0,0 +1,46 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class ConfigPermissionsHandler implements IPermissionsHandler
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ConfigPermissionsHandler(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
final String[] cmds = node.split("\\.", 2);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1])
|
||||
&& ess.getSettings().isPlayerCommand(cmds[cmds.length - 1]);
|
||||
}
|
||||
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.Economy;
|
||||
import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import java.io.*;
|
||||
import java.util.*;
|
||||
@@ -27,10 +28,13 @@ import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
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.craftbukkit.entity.CraftPlayer;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
@@ -42,119 +46,113 @@ import org.bukkit.plugin.java.*;
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final String AUTHORS = "Zenexer, ementalo, Aelux, Brettflan, KimKandor, snowleo, ceulemans and Xeology";
|
||||
public static final int minBukkitBuildVersion = 860;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private Settings settings;
|
||||
private EssentialsPlayerListener playerListener;
|
||||
private EssentialsBlockListener blockListener;
|
||||
private EssentialsEntityListener entityListener;
|
||||
private JailPlayerListener jailPlayerListener;
|
||||
private static Essentials instance = null;
|
||||
private Spawn spawn;
|
||||
private Jail jail;
|
||||
private Warps warps;
|
||||
private Worth worth;
|
||||
private List<IConf> confList;
|
||||
public ArrayList bans = new ArrayList();
|
||||
public ArrayList bannedIps = new ArrayList();
|
||||
private Backup backup;
|
||||
private final Map<String, User> users = new HashMap<String, User>();
|
||||
private EssentialsTimer timer;
|
||||
private EssentialsUpdateTimer updateTimer;
|
||||
private boolean registerFallback = true;
|
||||
private final Methods paymentMethod = new Methods();
|
||||
private final static boolean enableErrorLogging = false;
|
||||
private final EssentialsErrorHandler errorHandler = new EssentialsErrorHandler();
|
||||
public static final int BUKKIT_VERSION = 1000;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
private transient Spawn spawn;
|
||||
private transient Jail jail;
|
||||
private transient Warps warps;
|
||||
private transient Worth worth;
|
||||
private transient List<IConf> confList;
|
||||
private transient Backup backup;
|
||||
private transient BanWorkaround bans;
|
||||
private transient ItemDb itemDb;
|
||||
private transient final Map<String, User> users = new HashMap<String, User>();
|
||||
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 IPermissionsHandler permissionsHandler;
|
||||
|
||||
public static IEssentials getStatic()
|
||||
{
|
||||
return instance;
|
||||
}
|
||||
|
||||
public Settings getSettings()
|
||||
public ISettings getSettings()
|
||||
{
|
||||
return settings;
|
||||
}
|
||||
|
||||
public void setupForTesting(Server server) throws IOException, InvalidDescriptionException
|
||||
public void setupForTesting(final Server server) throws IOException, InvalidDescriptionException
|
||||
{
|
||||
File dataFolder = File.createTempFile("essentialstest", "");
|
||||
dataFolder.delete();
|
||||
dataFolder.mkdir();
|
||||
logger.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
|
||||
logger.log(Level.INFO, dataFolder.toString());
|
||||
final File dataFolder = File.createTempFile("essentialstest", "");
|
||||
if (!dataFolder.delete())
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
if (!dataFolder.mkdir())
|
||||
{
|
||||
throw new IOException();
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("usingTempFolderForTesting"));
|
||||
LOGGER.log(Level.INFO, dataFolder.toString());
|
||||
this.initialize(null, server, new PluginDescriptionFile(new FileReader(new File("src" + File.separator + "plugin.yml"))), dataFolder, null, null);
|
||||
settings = new Settings(dataFolder);
|
||||
setStatic();
|
||||
}
|
||||
|
||||
public void setStatic()
|
||||
{
|
||||
instance = this;
|
||||
settings = new Settings(this);
|
||||
permissionsHandler = new ConfigPermissionsHandler(this);
|
||||
Economy.setEss(this);
|
||||
}
|
||||
|
||||
public void onEnable()
|
||||
{
|
||||
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);
|
||||
LOGGER.addHandler(errorHandler);
|
||||
}
|
||||
setStatic();
|
||||
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
|
||||
upgrade.beforeSettings();
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this.getDataFolder());
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
upgrade.afterSettings();
|
||||
Util.updateLocale(settings.getLocale(), this.getDataFolder());
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
spawn = new Spawn(getServer(), this.getDataFolder());
|
||||
confList.add(spawn);
|
||||
warps = new Warps(getServer(), this.getDataFolder());
|
||||
confList.add(warps);
|
||||
worth = new Worth(this.getDataFolder());
|
||||
confList.add(worth);
|
||||
bans = new BanWorkaround(this);
|
||||
confList.add(bans);
|
||||
itemDb = new ItemDb(this);
|
||||
confList.add(itemDb);
|
||||
reload();
|
||||
backup = new Backup(this);
|
||||
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
final PluginManager pm = getServer().getPluginManager();
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
if (plugin.getDescription().getName().startsWith("Essentials"))
|
||||
if (plugin.getDescription().getName().startsWith("Essentials")
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
{
|
||||
if (!plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
LOGGER.log(Level.WARNING, Util.format("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < minBukkitBuildVersion)
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < BUKKIT_VERSION)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.WARNING, Util.i18n("notRecommendedBukkit"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
logger.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
}
|
||||
|
||||
|
||||
ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
|
||||
final ServerListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
|
||||
playerListener = new EssentialsPlayerListener(this);
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_QUIT, playerListener, Priority.Monitor, this);
|
||||
pm.registerEvent(Type.PLAYER_CHAT, playerListener, Priority.Lowest, this);
|
||||
if (getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||
}
|
||||
pm.registerEvent(Type.PLAYER_COMMAND_PREPROCESS, playerListener, Priority.Lowest, this);
|
||||
pm.registerEvent(Type.PLAYER_MOVE, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_LOGIN, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.High, this);
|
||||
@@ -162,57 +160,74 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.PLAYER_BUCKET_EMPTY, playerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_ANIMATION, playerListener, Priority.High, this);
|
||||
|
||||
blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, blockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Lowest, this);
|
||||
final EssentialsBlockListener blockListener = new EssentialsBlockListener(this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Lowest, this);
|
||||
|
||||
entityListener = new EssentialsEntityListener(this);
|
||||
final SignBlockListener signBlockListener = new SignBlockListener(this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, signBlockListener, Priority.Highest, this);
|
||||
pm.registerEvent(Type.BLOCK_IGNITE, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_BURN, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_EXTEND, signBlockListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PISTON_RETRACT, signBlockListener, Priority.Low, this);
|
||||
|
||||
final SignPlayerListener signPlayerListener = new SignPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, signPlayerListener, Priority.Low, this);
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
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);
|
||||
|
||||
jail = new Jail(this);
|
||||
jailPlayerListener = new JailPlayerListener(this);
|
||||
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
|
||||
confList.add(jail);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.High, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.High, this);
|
||||
attachEcoListeners();
|
||||
pm.registerEvent(Type.BLOCK_BREAK, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_DAMAGE, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.BLOCK_PLACE, jail, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, jailPlayerListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLAYER_RESPAWN, jailPlayerListener, Priority.High, this);
|
||||
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)
|
||||
{
|
||||
logger.log(Level.WARNING, "Old nether is disabled until multiworld support in bukkit is fixed.");
|
||||
getServer().createWorld(settings.getNetherName(), World.Environment.NETHER);
|
||||
}
|
||||
|
||||
timer = new EssentialsTimer(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
Economy.setEss(this);
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
|
||||
}
|
||||
logger.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), AUTHORS));
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
}
|
||||
|
||||
public void onDisable()
|
||||
{
|
||||
instance = null;
|
||||
logger.removeHandler(errorHandler);
|
||||
Trade.closeLog();
|
||||
LOGGER.removeHandler(errorHandler);
|
||||
}
|
||||
|
||||
public void reload()
|
||||
{
|
||||
loadBanList();
|
||||
Trade.closeLog();
|
||||
|
||||
for (IConf iConf : confList)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
|
||||
Util.updateLocale(settings.getLocale(), this.getDataFolder());
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
|
||||
for (User user : users.values())
|
||||
{
|
||||
@@ -221,15 +236,6 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
// for motd
|
||||
getConfiguration().load();
|
||||
|
||||
try
|
||||
{
|
||||
ItemDb.load(getDataFolder(), "items.csv");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
public String[] getMotd(CommandSender sender, String def)
|
||||
@@ -246,7 +252,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
String[] retval = new String[lines.size()];
|
||||
|
||||
if (lines == null || lines.isEmpty() || lines.get(0) == null)
|
||||
if (lines.isEmpty() || lines.get(0) == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -260,7 +266,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (Throwable ex2)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
|
||||
LOGGER.log(Level.WARNING, Util.format("corruptNodeInConfig", node));
|
||||
return new String[0];
|
||||
}
|
||||
}
|
||||
@@ -287,15 +293,28 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
m = m.replace("{IP}", user.getAddress().toString());
|
||||
m = m.replace("{BALANCE}", Double.toString(user.getMoney()));
|
||||
m = m.replace("{MAILS}", Integer.toString(user.getMails().size()));
|
||||
m = m.replace("{WORLD}", user.getLocation().getWorld().getName());
|
||||
}
|
||||
|
||||
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length));
|
||||
int playerHidden = 0;
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(p).isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
|
||||
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
|
||||
|
||||
if (m.matches(".*\\{PLAYERLIST\\}.*"))
|
||||
{
|
||||
StringBuilder online = new StringBuilder();
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(p).isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (online.length() > 0)
|
||||
{
|
||||
online.append(", ");
|
||||
@@ -328,39 +347,14 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return retval;
|
||||
}
|
||||
|
||||
@SuppressWarnings("LoggerStringConcat")
|
||||
public static void previewCommand(CommandSender sender, Command command, String commandLabel, String[] args)
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
logger.info(ChatColor.BLUE + "[PLAYER_COMMAND] " + ((Player)sender).getName() + ": /" + commandLabel + " " + EssentialsCommand.getFinalArg(args, 0));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
|
||||
{
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command");
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
|
||||
}
|
||||
|
||||
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath)
|
||||
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)
|
||||
{
|
||||
if (("msg".equals(commandLabel.toLowerCase()) || "r".equals(commandLabel.toLowerCase()) || "mail".equals(commandLabel.toLowerCase())) && sender instanceof Player)
|
||||
{
|
||||
StringBuilder str = new StringBuilder();
|
||||
str.append(commandLabel).append(" ");
|
||||
for (String a : args)
|
||||
{
|
||||
str.append(a).append(" ");
|
||||
}
|
||||
for (Player player : getServer().getOnlinePlayers())
|
||||
{
|
||||
if (getUser(player).isSocialSpyEnabled())
|
||||
{
|
||||
player.sendMessage(getUser(sender).getDisplayName() + " : " + str);
|
||||
}
|
||||
}
|
||||
}
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
|
||||
{
|
||||
@@ -382,24 +376,22 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!(desc.getCommands() instanceof Map))
|
||||
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
continue;
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
|
||||
Map<String, Object> cmds = (Map<String, Object>)desc.getCommands();
|
||||
if (!cmds.containsKey(command.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
return p.onCommand(sender, command, commandLabel, args);
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
previewCommand(sender, command, commandLabel, args);
|
||||
User user = sender instanceof Player ? getUser(sender) : null;
|
||||
User user = null;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = getUser(sender);
|
||||
LOGGER.log(Level.INFO, String.format("[PLAYER_COMMAND] %s: /%s %s ", ((Player)sender).getName(), commandLabel, EssentialsCommand.getFinalArg(args, 0)));
|
||||
}
|
||||
|
||||
// New mail notification
|
||||
if (user != null && !getSettings().isCommandDisabled("mail") && !commandLabel.equals("mail") && user.isAuthorized("essentials.mail"))
|
||||
@@ -426,14 +418,14 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(Util.format("commandNotLoaded", commandLabel));
|
||||
logger.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("commandNotLoaded", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
|
||||
// Check authorization
|
||||
if (user != null && !user.isAuthorized(cmd))
|
||||
if (user != null && !user.isAuthorized(cmd, permissionPrefix))
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
|
||||
LOGGER.log(Level.WARNING, Util.format("deniedAccessCommand", user.getName()));
|
||||
user.sendMessage(Util.i18n("noAccessCommand"));
|
||||
return true;
|
||||
}
|
||||
@@ -459,133 +451,34 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
sender.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
LogRecord lr = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
|
||||
lr.setThrown(ex);
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
logger.log(lr);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
errorHandler.publish(lr);
|
||||
errorHandler.flush();
|
||||
}
|
||||
}
|
||||
showError(sender, ex, commandLabel);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("commandFailed", commandLabel), ex);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
public void loadBanList()
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
//I don't like this but it needs to be done until CB fixors
|
||||
File file = new File("banned-players.txt");
|
||||
File ipFile = new File("banned-ips.txt");
|
||||
try
|
||||
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
|
||||
final LogRecord logRecord = new LogRecord(Level.WARNING, Util.format("errorCallingCommand", commandLabel));
|
||||
logRecord.setThrown(exception);
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
if (!file.exists())
|
||||
LOGGER.log(logRecord);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (enableErrorLogging)
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedPlayersFileNotFound"));
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
bans.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bans.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
errorHandler.publish(logRecord);
|
||||
errorHandler.flush();
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedPlayersFileError"), ex);
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (!ipFile.exists())
|
||||
{
|
||||
throw new FileNotFoundException(Util.i18n("bannedIpsFileNotFound"));
|
||||
}
|
||||
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(ipFile));
|
||||
try
|
||||
{
|
||||
bannedIps.clear();
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
|
||||
final String line = bufferedReader.readLine().trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
continue;
|
||||
}
|
||||
bannedIps.add(line);
|
||||
|
||||
}
|
||||
}
|
||||
catch (IOException io)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), io);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
bufferedReader.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("bannedIpsFileError"), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void attachEcoListeners()
|
||||
{
|
||||
PluginManager pm = getServer().getPluginManager();
|
||||
EssentialsEcoBlockListener ecoBlockListener = new EssentialsEcoBlockListener(this);
|
||||
EssentialsEcoPlayerListener ecoPlayerListener = new EssentialsEcoPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_INTERACT, ecoPlayerListener, Priority.High, this);
|
||||
pm.registerEvent(Type.BLOCK_BREAK, ecoBlockListener, Priority.High, this);
|
||||
pm.registerEvent(Type.SIGN_CHANGE, ecoBlockListener, Priority.Monitor, this);
|
||||
}
|
||||
|
||||
public CraftScheduler getScheduler()
|
||||
@@ -649,47 +542,43 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return u;
|
||||
}
|
||||
|
||||
public Map<String, User> getAllUsers()
|
||||
{
|
||||
return users;
|
||||
}
|
||||
|
||||
public User getOfflineUser(String name)
|
||||
{
|
||||
// Don't create a new offline user, if we already have that user loaded.
|
||||
User u = users.get(name.toLowerCase());
|
||||
if (u != null)
|
||||
{
|
||||
return u;
|
||||
}
|
||||
File userFolder = new File(getDataFolder(), "userdata");
|
||||
File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
if (userFile.exists())
|
||||
{ //Users do not get offline changes saved without being reproccessed as Users! ~ Xeology :)
|
||||
return getUser((Player)new OfflinePlayer(name));
|
||||
return getUser((Player)new OfflinePlayer(name, this));
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public World getWorld(String name)
|
||||
public World getWorld(final String name)
|
||||
{
|
||||
if (name.matches("[0-9]+"))
|
||||
{
|
||||
int id = Integer.parseInt(name);
|
||||
final int id = Integer.parseInt(name);
|
||||
if (id < getServer().getWorlds().size())
|
||||
{
|
||||
return getServer().getWorlds().get(id);
|
||||
}
|
||||
}
|
||||
World w = getServer().getWorld(name);
|
||||
if (w != null)
|
||||
{
|
||||
return w;
|
||||
}
|
||||
return null;
|
||||
return getServer().getWorld(name);
|
||||
}
|
||||
|
||||
public void setRegisterFallback(boolean registerFallback)
|
||||
{
|
||||
this.registerFallback = registerFallback;
|
||||
}
|
||||
|
||||
public boolean isRegisterFallbackEnabled()
|
||||
{
|
||||
return registerFallback;
|
||||
}
|
||||
|
||||
public void addReloadListener(IConf listener)
|
||||
public void addReloadListener(final IConf listener)
|
||||
{
|
||||
confList.add(listener);
|
||||
}
|
||||
@@ -699,7 +588,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public int broadcastMessage(String name, String message)
|
||||
public int broadcastMessage(final String name, final String message)
|
||||
{
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
@@ -730,18 +619,38 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, long delay, long period)
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
public List<String> getBans()
|
||||
public TNTExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
public IPermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
public void setPermissionsHandler(IPermissionsHandler handler)
|
||||
{
|
||||
this.permissionsHandler = handler;
|
||||
}
|
||||
|
||||
public BanWorkaround getBans()
|
||||
{
|
||||
return bans;
|
||||
}
|
||||
|
||||
public List<String> getBannedIps()
|
||||
public ItemDb getItemDb()
|
||||
{
|
||||
return bannedIps;
|
||||
return itemDb;
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -17,372 +11,99 @@ public class EssentialsBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
public final static List<Material> protectedBlocks = new ArrayList<Material>(4);
|
||||
|
||||
static
|
||||
{
|
||||
protectedBlocks.add(Material.CHEST);
|
||||
protectedBlocks.add(Material.BURNING_FURNACE);
|
||||
protectedBlocks.add(Material.FURNACE);
|
||||
protectedBlocks.add(Material.DISPENSER);
|
||||
}
|
||||
|
||||
public EssentialsBlockListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (protectedBlocks.contains(event.getBlock().getType()) && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
if (isBlockProtected(event.getBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (checkProtectionSign(event.getBlock(), user) != NOSIGN &&
|
||||
checkProtectionSign(event.getBlock(), user) != OWNER)
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noDestroyPermission", event.getBlock().getType().toString().toLowerCase()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
if (ess.getSettings().areSignsDisabled()) return;
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
|
||||
try
|
||||
{
|
||||
if (event.getLine(0).equalsIgnoreCase("[Protection]"))
|
||||
{
|
||||
Block block = event.getBlock();
|
||||
if (user.isAuthorized("essentials.signs.protection.create") && hasAdjacentChest(block) && !isBlockProtected(block, user))
|
||||
event.setLine(0, "§1[Protection]");
|
||||
else
|
||||
event.setLine(0, "§4[Protection]");
|
||||
event.setLine(3, username);
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Disposal]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.disposal.create"))
|
||||
event.setLine(0, "§1[Disposal]");
|
||||
else
|
||||
event.setLine(0, "§4[Disposal]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Heal]"))
|
||||
{
|
||||
event.setLine(0, "§4[Heal]");
|
||||
if (user.isAuthorized("essentials.signs.heal.create"))
|
||||
{
|
||||
if (!event.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (q1 < 1 || (!m1 && (int)q1 < 1)) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
event.setLine(0, "§1[Heal]");
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Free]"))
|
||||
{
|
||||
event.setLine(0, "§4[Free]");
|
||||
ItemDb.get(event.getLine(1));
|
||||
if (user.isAuthorized("essentials.signs.free.create"))
|
||||
event.setLine(0, "§1[Free]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Mail]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.mail.create"))
|
||||
event.setLine(0, "§1[Mail]");
|
||||
else
|
||||
event.setLine(0, "§4[Mail]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Balance]"))
|
||||
{
|
||||
if (user.isAuthorized("essentials.signs.balance.create"))
|
||||
event.setLine(0, "§1[Balance]");
|
||||
else
|
||||
event.setLine(0, "§4[Balance]");
|
||||
return;
|
||||
}
|
||||
if (event.getLine(0).equalsIgnoreCase("[Warp]"))
|
||||
{
|
||||
event.setLine(0, "§4[Warp]");
|
||||
if (user.isAuthorized("essentials.signs.warp.create")) {
|
||||
if (!event.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = event.getLine(3).split("[ :-]+", 2);
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
if (!m1 && l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 4));
|
||||
}
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if ((int)q1 < 1) throw new Exception(Util.i18n("moreThanZero"));
|
||||
if (!m1) ItemDb.get(l1[1]);
|
||||
event.setLine(3, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]));
|
||||
}
|
||||
if (event.getLine(1).isEmpty()) {
|
||||
event.setLine(1, "§dWarp name!");
|
||||
return;
|
||||
} else {
|
||||
ess.getWarps().getWarp(event.getLine(1));
|
||||
if (event.getLine(2).equalsIgnoreCase("Everyone")) {
|
||||
event.setLine(2, "§2Everyone");
|
||||
}
|
||||
event.setLine(0, "§1[Warp]");
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled()) return;
|
||||
Block signBlock = event.getBlockAgainst();
|
||||
if (signBlock.getType() == Material.WALL_SIGN || signBlock.getType() == Material.SIGN_POST)
|
||||
if (event.isCancelled())
|
||||
{
|
||||
Sign sign = new CraftSign(signBlock);
|
||||
if (sign.getLine(0).matches("§1\\[[a-zA-Z]+\\]"))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = new ItemStack(event.getBlockPlaced().getType(), 1, (short)0, event.getBlockPlaced().getData());
|
||||
switch(is.getType()) {
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
switch (is.getType())
|
||||
{
|
||||
case WOODEN_DOOR:
|
||||
is.setType(Material.WOOD_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case IRON_DOOR_BLOCK:
|
||||
is.setType(Material.IRON_DOOR);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case SIGN_POST:
|
||||
case WALL_SIGN:
|
||||
is.setType(Material.SIGN);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CROPS:
|
||||
is.setType(Material.SEEDS);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case CAKE_BLOCK:
|
||||
is.setType(Material.CAKE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case BED_BLOCK:
|
||||
is.setType(Material.BED);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_WIRE:
|
||||
is.setType(Material.REDSTONE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case REDSTONE_TORCH_OFF:
|
||||
case REDSTONE_TORCH_ON:
|
||||
is.setType(Material.REDSTONE_TORCH_ON);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DIODE_BLOCK_OFF:
|
||||
case DIODE_BLOCK_ON:
|
||||
is.setType(Material.DIODE);
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case DOUBLE_STEP:
|
||||
is.setType(Material.STEP);
|
||||
break;
|
||||
case TORCH:
|
||||
case RAILS:
|
||||
case LADDER:
|
||||
case WOOD_STAIRS:
|
||||
case COBBLESTONE_STAIRS:
|
||||
case LEVER:
|
||||
case STONE_BUTTON:
|
||||
case FURNACE:
|
||||
case DISPENSER:
|
||||
case PUMPKIN:
|
||||
case JACK_O_LANTERN:
|
||||
case WOOD_PLATE:
|
||||
case STONE_PLATE:
|
||||
case PISTON_STICKY_BASE:
|
||||
case PISTON_BASE:
|
||||
is.setDurability((short)0);
|
||||
break;
|
||||
case FIRE:
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser) {
|
||||
if (unlimitedForUser)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasAdjacentChest(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private static final int NOT_ALLOWED = 0;
|
||||
private static final int ALLOWED = 1;
|
||||
private static final int NOSIGN = 2;
|
||||
private static final int OWNER = 3;
|
||||
|
||||
private int checkProtectionSign(Block block, User user)
|
||||
{
|
||||
String username = user.getName().substring(0, user.getName().length() > 14 ? 14 : user.getName().length());
|
||||
if (block.getType() == Material.SIGN_POST || block.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(block);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]") && !user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
for (int i = 1; i <= 2; i++) {
|
||||
String line = sign.getLine(i);
|
||||
if (line.startsWith("(") && line.endsWith(")")) {
|
||||
line = line.substring(1, line.length() - 1);
|
||||
if (user.inGroup(line)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
} else if (line.equalsIgnoreCase(username)) {
|
||||
return ALLOWED;
|
||||
}
|
||||
}
|
||||
if (sign.getLine(3).equalsIgnoreCase(username))
|
||||
{
|
||||
return OWNER;
|
||||
}
|
||||
return NOT_ALLOWED;
|
||||
}
|
||||
}
|
||||
return NOSIGN;
|
||||
}
|
||||
|
||||
private static Block[] getAdjacentBlocks(Block block)
|
||||
{
|
||||
return new Block[]
|
||||
{
|
||||
block.getFace(BlockFace.NORTH),
|
||||
block.getFace(BlockFace.SOUTH),
|
||||
block.getFace(BlockFace.EAST),
|
||||
block.getFace(BlockFace.WEST),
|
||||
block.getFace(BlockFace.DOWN),
|
||||
block.getFace(BlockFace.UP)
|
||||
};
|
||||
}
|
||||
|
||||
public boolean isBlockProtected(Block block, User user)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
boolean protect = false;
|
||||
for (Block b : faces)
|
||||
{
|
||||
int check = checkProtectionSign(b, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
check = checkProtectionSign(a, user);
|
||||
if (check == NOT_ALLOWED)
|
||||
new Runnable()
|
||||
{
|
||||
protect = true;
|
||||
}
|
||||
if (check == ALLOWED || check == OWNER)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return protect;
|
||||
}
|
||||
|
||||
public static boolean isBlockProtected(Block block)
|
||||
{
|
||||
Block[] faces = getAdjacentBlocks(block);
|
||||
for (Block b : faces)
|
||||
{
|
||||
if (b.getType() == Material.SIGN_POST || b.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(b);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
if (protectedBlocks.contains(b.getType()))
|
||||
{
|
||||
Block[] faceChest = getAdjacentBlocks(b);
|
||||
|
||||
for (Block a : faceChest)
|
||||
{
|
||||
if (a.getType() == Material.SIGN_POST || a.getType() == Material.WALL_SIGN)
|
||||
{
|
||||
Sign sign = new CraftSign(a);
|
||||
if (sign.getLine(0).equalsIgnoreCase("§1[Protection]"))
|
||||
public void run()
|
||||
{
|
||||
return true;
|
||||
user.getInventory().addItem(is);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@@ -1,250 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockListener;
|
||||
import org.bukkit.event.block.SignChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoBlockListener extends BlockListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsEcoBlockListener(Essentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBlockBreak(BlockBreakEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getBlock().getType() != Material.WALL_SIGN && event.getBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]"))
|
||||
{
|
||||
if (!sign.getLine(3).substring(2).equals(username))
|
||||
{
|
||||
if (!user.isOp())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLines()[1].split("[ :-]+");
|
||||
String[] l2 = sign.getLines()[2].split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack i2 = m2 || r2 <= 0 ? null : ItemDb.get(l2[1], (int)r2);
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(r2);
|
||||
}
|
||||
else if (i2 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
user.updateInventory();
|
||||
|
||||
sign.setType(Material.AIR);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onSignChange(SignChangeEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Buy]") || event.getLine(0).equalsIgnoreCase("#1[Buy]")) && user.isAuthorized("essentials.signs.buy.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Buy]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Don't sell air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Buy]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Sell]") || event.getLine(0).equalsIgnoreCase("#1[Sell]")) && user.isAuthorized("essentials.signs.sell.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setLine(0, "§1[Sell]");
|
||||
event.setLine(1, "" + Math.abs(Integer.parseInt(event.getLine(1))));
|
||||
ItemStack is = ItemDb.get(event.getLine(2));
|
||||
if (is.getTypeId() == 0 || Math.abs(Integer.parseInt(event.getLine(1))) == 0)
|
||||
{
|
||||
throw new Exception("Can't buy air.");
|
||||
}
|
||||
double price = Double.parseDouble(event.getLine(3).replaceAll("[^0-9\\.]", ""));
|
||||
event.setLine(3, Util.formatCurrency(price));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Sell]");
|
||||
event.setLine(1, "#");
|
||||
event.setLine(2, "Item");
|
||||
event.setLine(3, "$Price");
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if ((event.getLine(0).equalsIgnoreCase("[Trade]") || event.getLine(0).equalsIgnoreCase("#1[Trade]")) && user.isAuthorized("essentials.signs.trade.create"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = event.getLine(1).split("[ :-]+");
|
||||
String[] l2 = event.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
if (m1 ? l1.length != 1 : l1.length != 2)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 2));
|
||||
}
|
||||
if (m2 ? l2.length != 2 : l2.length != 3)
|
||||
{
|
||||
throw new Exception(Util.format("invalidSignLine", 3));
|
||||
}
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1) || r2 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (!m1)
|
||||
{
|
||||
ItemDb.get(l1[1]);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
if (user.getMoney() < r2)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(r2);
|
||||
//user.sendMessage("r2: " + r2 + " q2: " + q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i2 = ItemDb.get(l2[1], (int)r2);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i2))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)r2, l2[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i2);
|
||||
user.updateInventory();
|
||||
}
|
||||
|
||||
event.setLine(0, "§1[Trade]");
|
||||
event.setLine(1, (m1 ? Util.formatCurrency(q1) : (int)q1 + " " + l1[1]) + ":0");
|
||||
event.setLine(2, (m2 ? Util.formatCurrency(q2) : (int)q2 + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
event.setLine(0, "§4[Trade]");
|
||||
event.setLine(1, "# ItemOr" + ess.getSettings().getCurrencySymbol());
|
||||
event.setLine(2, "# ItemOr" + ess.getSettings().getCurrencySymbol() + ":#");
|
||||
event.setLine(3, "§8" + username);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,211 +0,0 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsEcoPlayerListener extends PlayerListener
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
EssentialsEcoPlayerListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
String username = user.getName().substring(0, user.getName().length() > 13 ? 13 : user.getName().length());
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
if (sign.getLine(0).equals("§1[Buy]") && user.isAuthorized("essentials.signs.buy.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
if (user.getMoney() < cost)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(item);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Sell]") && user.isAuthorized("essentials.signs.sell.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
int amount = Integer.parseInt(sign.getLine(1));
|
||||
ItemStack item = ItemDb.get(sign.getLine(2), amount);
|
||||
double cost = Double.parseDouble(sign.getLine(3).substring(1));
|
||||
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, item))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", amount, sign.getLine(2)));
|
||||
}
|
||||
user.giveMoney(cost);
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, item);
|
||||
user.updateInventory();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
if (sign.getLine(0).equals("§1[Trade]") && user.isAuthorized("essentials.signs.trade.use"))
|
||||
{
|
||||
try
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
String[] l2 = sign.getLine(2).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
boolean m2 = l2[0].matches("[^0-9][0-9]+(\\.[0-9]+)?");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
double q2 = Double.parseDouble(m2 ? l2[0].substring(1) : l2[0]);
|
||||
double r1 = Double.parseDouble(l1[m1 ? 1 : 2]);
|
||||
double r2 = Double.parseDouble(l2[m2 ? 1 : 2]);
|
||||
r1 = m1 ? r1 : r1 - r1 % q1;
|
||||
r2 = m2 ? r2 : r2 - r2 % q2;
|
||||
if ((!m1 & q1 < 1) || (!m2 & q2 < 1))
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
|
||||
ItemStack i1 = m1 || r1 <= 0 ? null : ItemDb.get(l1[1], (int)r1);
|
||||
ItemStack qi1 = m1 ? null : ItemDb.get(l1[1], (int)q1);
|
||||
ItemStack qi2 = m2 ? null : ItemDb.get(l2[1], (int)q2);
|
||||
|
||||
if (username.equals(sign.getLine(3).substring(2)))
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
user.giveMoney(r1);
|
||||
}
|
||||
else if (i1 != null)
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(i1);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
r1 = 0;
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":0");
|
||||
sign.update();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, qi1))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
}
|
||||
|
||||
if (r2 < q2)
|
||||
{
|
||||
throw new Exception(Util.i18n("tradeSignEmpty"));
|
||||
}
|
||||
|
||||
if (m1)
|
||||
{
|
||||
user.takeMoney(q1);
|
||||
}
|
||||
else
|
||||
{
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, qi1);
|
||||
}
|
||||
|
||||
if (m2)
|
||||
{
|
||||
user.giveMoney(q2);
|
||||
}
|
||||
else
|
||||
{
|
||||
Map<Integer, ItemStack> leftOver = user.getInventory().addItem(qi2);
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
}
|
||||
|
||||
user.updateInventory();
|
||||
|
||||
r1 += q1;
|
||||
r2 -= q2;
|
||||
|
||||
|
||||
sign.setLine(0, "§1[Trade]");
|
||||
sign.setLine(1, (m1 ? Util.formatCurrency(q1) : ((int)q1) + " " + l1[1]) + ":" + (m1 ? Util.roundDouble(r1) : "" + (int)r1));
|
||||
sign.setLine(2, (m2 ? Util.formatCurrency(q2) : ((int)q2) + " " + l2[1]) + ":" + (m2 ? Util.roundDouble(r2) : "" + (int)r2));
|
||||
sign.update();
|
||||
user.sendMessage(Util.i18n("tradeCompleted"));
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,24 +1,24 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.InventoryPlayer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.Sign;
|
||||
import org.bukkit.craftbukkit.block.CraftSign;
|
||||
import org.bukkit.craftbukkit.inventory.CraftInventoryPlayer;
|
||||
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.PlayerBucketEmptyEvent;
|
||||
import org.bukkit.event.player.PlayerChatEvent;
|
||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||
import org.bukkit.event.player.PlayerEggThrowEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
@@ -34,57 +34,60 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final Server server;
|
||||
private final IEssentials ess;
|
||||
private final EssentialsBlockListener essBlockListener;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Server server;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public EssentialsPlayerListener(IEssentials parent)
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
this.server = parent.getServer();
|
||||
essBlockListener = new EssentialsBlockListener(parent);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setDisplayName(user.getNick());
|
||||
updateCompass(user);
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty()) {
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerChat(PlayerChatEvent event)
|
||||
public void onPlayerChat(final PlayerChatEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isMuted())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
logger.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
user.sendMessage(Util.i18n("playerMuted"));
|
||||
LOGGER.info(Util.format("mutedUserSpeaks", user.getName()));
|
||||
}
|
||||
Iterator<Player> it = event.getRecipients().iterator();
|
||||
final Iterator<Player> it = event.getRecipients().iterator();
|
||||
while (it.hasNext())
|
||||
{
|
||||
User u = ess.getUser(it.next());
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerMove(PlayerMoveEvent event)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
@@ -92,13 +95,19 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
final Block block = event.getPlayer().getWorld().getBlockAt(event.getTo().getBlockX(), event.getTo().getBlockY(), event.getTo().getBlockZ());
|
||||
List<World> worlds = server.getWorlds();
|
||||
final List<World> worlds = server.getWorlds();
|
||||
|
||||
if (block.getType() == Material.PORTAL && worlds.size() > 1 && user.isAuthorized("essentials.portal"))
|
||||
{
|
||||
@@ -107,17 +116,19 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
return;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
World nether = server.getWorld(ess.getSettings().getNetherName());
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
for (World world : worlds)
|
||||
{
|
||||
if (world.getEnvironment() == World.Environment.NETHER) {
|
||||
if (world.getEnvironment() == World.Environment.NETHER)
|
||||
{
|
||||
nether = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (nether == null) {
|
||||
if (nether == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -128,7 +139,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
factor = ess.getSettings().getNetherRatio();
|
||||
}
|
||||
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();
|
||||
}
|
||||
@@ -137,6 +148,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
factor = 1.0;
|
||||
}
|
||||
|
||||
Location loc = event.getTo();
|
||||
int x = loc.getBlockX();
|
||||
int y = loc.getBlockY();
|
||||
int z = loc.getBlockZ();
|
||||
@@ -161,14 +173,14 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
if (world.getEnvironment() == World.Environment.NETHER || ess.getSettings().getGenerateExitPortals())
|
||||
{
|
||||
portal = NetherPortal.createPortal(dest);
|
||||
logger.info(Util.format("userCreatedPortal", event.getPlayer().getName()));
|
||||
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()));
|
||||
LOGGER.info(Util.format("userUsedPortal", event.getPlayer().getName()));
|
||||
user.sendMessage(Util.i18n("usingPortal"));
|
||||
loc = portal.getSpawn();
|
||||
}
|
||||
@@ -177,7 +189,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.setTo(loc);
|
||||
try
|
||||
{
|
||||
user.getTeleport().now(loc, new Charge("portal", ess));
|
||||
user.getTeleport().now(loc, new Trade("portal", ess));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -194,21 +206,24 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerQuit(PlayerQuitEvent event)
|
||||
public void onPlayerQuit(final PlayerQuitEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.dispose();
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.dispose();
|
||||
Thread thread = new Thread(new Runnable()
|
||||
final Thread thread = new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
@@ -221,7 +236,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
rt.gc();
|
||||
mem = rt.freeMemory() - mem;
|
||||
mem /= 1024 * 1024;
|
||||
logger.log(Level.INFO, Util.format("freedMemory", mem));
|
||||
LOGGER.log(Level.INFO, Util.format("freedMemory", mem));
|
||||
}
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
@@ -234,20 +249,28 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(PlayerJoinEvent event)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
//we do not know the ip address on playerlogin so we need to do this here.
|
||||
if (user.isIpBanned())
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
final String banReason = user.getBanReason();
|
||||
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
user.setDisplayName(user.getNick());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
user.setAfk(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("motd") && user.isAuthorized("essentials.motd"))
|
||||
{
|
||||
@@ -263,7 +286,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
|
||||
if (!ess.getSettings().isCommandDisabled("mail") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
final List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
@@ -276,18 +299,18 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerLogin(PlayerLoginEvent event)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
if (user.isBanned())
|
||||
{
|
||||
String banReason = user.getBanReason();
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
@@ -302,7 +325,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(User user)
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -320,24 +343,16 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
return;
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
try
|
||||
{
|
||||
event.setTo(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
user.sendMessage(Util.i18n("jailMessage"));
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
@@ -347,29 +362,12 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (!ess.getSettings().areSignsDisabled() && EssentialsBlockListener.protectedBlocks.contains(event.getClickedBlock().getType()))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.signs.protection.override"))
|
||||
{
|
||||
if (essBlockListener.isBlockProtected(event.getClickedBlock(), user))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
user.sendMessage(Util.format("noAccessPermission", event.getClickedBlock().getType().toString().toLowerCase()));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getBedSetsHome() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setHome();
|
||||
user.sendMessage(Util.i18n("homeSetToBed"));
|
||||
}
|
||||
@@ -377,158 +375,13 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (ess.getSettings().areSignsDisabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getClickedBlock().getType() != Material.WALL_SIGN && event.getClickedBlock().getType() != Material.SIGN_POST)
|
||||
{
|
||||
return;
|
||||
}
|
||||
Sign sign = new CraftSign(event.getClickedBlock());
|
||||
|
||||
try
|
||||
{
|
||||
if (sign.getLine(0).equals("§1[Free]") && user.isAuthorized("essentials.signs.free.use"))
|
||||
{
|
||||
ItemStack item = ItemDb.get(sign.getLine(1));
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
item.setAmount(9 * 4 * 64);
|
||||
inv.addItem(item);
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Disposal]") && user.isAuthorized("essentials.signs.disposal.use"))
|
||||
{
|
||||
CraftInventoryPlayer inv = new CraftInventoryPlayer(new InventoryPlayer(user.getHandle()));
|
||||
inv.clear();
|
||||
user.showInventory(inv);
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Heal]") && user.isAuthorized("essentials.signs.heal.use"))
|
||||
{
|
||||
if (!sign.getLine(1).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(1).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
if (user.getMoney() < q1)
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(q1);
|
||||
user.sendMessage(Util.format("moneyTaken", Util.formatCurrency(q1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, i))
|
||||
{
|
||||
throw new Exception(Util.format("missingItems", (int)q1, l1[1]));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, i);
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("youAreHealed"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Mail]") && user.isAuthorized("essentials.signs.mail.use") && user.isAuthorized("essentials.mail"))
|
||||
{
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noNewMail"));
|
||||
return;
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("markMailAsRead"));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Balance]") && user.isAuthorized("essentials.signs.balance.use"))
|
||||
{
|
||||
user.sendMessage(Util.format("balance", user.getMoney()));
|
||||
return;
|
||||
}
|
||||
if (sign.getLine(0).equals("§1[Warp]"))
|
||||
{
|
||||
|
||||
if (!sign.getLine(2).isEmpty())
|
||||
{
|
||||
if (sign.getLine(2).equals("§2Everyone"))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
if (user.inGroup(sign.getLine(2)))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (user.isAuthorized("essentials.signs.warp.use")
|
||||
&& (!ess.getSettings().getPerWarpPermission() || user.isAuthorized("essentials.warp." + sign.getLine(1))))
|
||||
{
|
||||
Charge charge = chargeUserForWarp(sign, user);
|
||||
user.getTeleport().warp(sign.getLine(1), charge);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Charge chargeUserForWarp(Sign sign, User user) throws Exception
|
||||
{
|
||||
if (!sign.getLine(3).isEmpty())
|
||||
{
|
||||
String[] l1 = sign.getLine(3).split("[ :-]+");
|
||||
boolean m1 = l1[0].matches("^[^0-9][\\.0-9]+");
|
||||
double q1 = Double.parseDouble(m1 ? l1[0].substring(1) : l1[0]);
|
||||
if (!m1 && (int)q1 < 1)
|
||||
{
|
||||
throw new Exception(Util.i18n("moreThanZero"));
|
||||
}
|
||||
if (m1)
|
||||
{
|
||||
return new Charge(q1, ess);
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack i = ItemDb.get(l1[1], (int)q1);
|
||||
return new Charge(i, ess);
|
||||
}
|
||||
}
|
||||
return new Charge("warpsign", ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerEggThrow(PlayerEggThrowEvent event)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = new ItemStack(Material.EGG, 1);
|
||||
if (user.hasUnlimited(is))
|
||||
{
|
||||
user.getInventory().addItem(is);
|
||||
@@ -537,7 +390,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerBucketEmpty(PlayerBucketEmptyEvent event)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasUnlimited(new ItemStack(event.getBucket())))
|
||||
@@ -554,24 +407,24 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerAnimation(PlayerAnimationEvent event)
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
usePowertools(event);
|
||||
}
|
||||
|
||||
private void usePowertools(PlayerAnimationEvent event)
|
||||
private void usePowertools(final PlayerAnimationEvent event)
|
||||
{
|
||||
if (event.getAnimationType() != PlayerAnimationType.ARM_SWING)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
ItemStack is = user.getItemInHand();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
{
|
||||
return;
|
||||
}
|
||||
String command = user.getPowertool(is);
|
||||
final String command = user.getPowertool(is);
|
||||
if (command == null || command.isEmpty())
|
||||
{
|
||||
return;
|
||||
@@ -593,4 +446,31 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
|
||||
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
if (commands.contains(cmd))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (ess.getUser(player).isSocialSpyEnabled())
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -6,40 +6,76 @@ import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
{
|
||||
private final Methods methods;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsPluginListener(Methods methods)
|
||||
public EssentialsPluginListener(final IEssentials ess)
|
||||
{
|
||||
this.methods = methods;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void onPluginEnable(PluginEnableEvent event)
|
||||
public void onPluginEnable(final PluginEnableEvent event)
|
||||
{
|
||||
if (!methods.hasMethod())
|
||||
checkPermissions();
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(event.getPlugin()))
|
||||
{
|
||||
if (methods.setMethod(event.getPlugin()))
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method found (" + methods.getMethod().getName() + " version: " + methods.getMethod().getVersion() + ")");
|
||||
}
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPluginDisable(PluginDisableEvent event)
|
||||
{
|
||||
checkPermissions();
|
||||
// Check to see if the plugin thats being disabled is the one we are using
|
||||
if (methods != null && methods.hasMethod())
|
||||
if (ess.getPaymentMethod() != null && ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().checkDisabled(event.getPlugin()))
|
||||
{
|
||||
if (methods.checkDisabled(event.getPlugin()))
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
private void checkPermissions()
|
||||
{
|
||||
final PluginManager pm = ess.getServer().getPluginManager();
|
||||
final Plugin permissionsExPlugin = pm.getPlugin("PermissionsEx");
|
||||
|
||||
if (permissionsExPlugin == null || !permissionsExPlugin.isEnabled())
|
||||
{
|
||||
final Plugin permissionsPlugin = pm.getPlugin("Permissions");
|
||||
if (permissionsPlugin == null || !permissionsPlugin.isEnabled())
|
||||
{
|
||||
logger.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
if (ess.getSettings().useBukkitPermissions())
|
||||
{
|
||||
ess.setPermissionsHandler(new BukkitPermissionsHandler());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new ConfigPermissionsHandler(ess));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions3Handler(permissionsPlugin));
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new Permissions2Handler(permissionsPlugin));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.setPermissionsHandler(new PermissionsExHandler());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.earth2me.essentials;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -25,7 +24,7 @@ public class EssentialsTimer implements Runnable, IConf
|
||||
continue;
|
||||
}
|
||||
String name = string.substring(0, string.length()-4);
|
||||
User u = ess.getUser(new OfflinePlayer(name));
|
||||
User u = ess.getUser(new OfflinePlayer(name, ess));
|
||||
allUsers.add(u);
|
||||
}
|
||||
}
|
||||
@@ -43,8 +42,7 @@ public class EssentialsTimer implements Runnable, IConf
|
||||
for (User user: allUsers) {
|
||||
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
|
||||
user.setBanTimeout(0);
|
||||
((CraftServer)ess.getServer()).getHandle().b(user.getName());
|
||||
ess.loadBanList();
|
||||
ess.getBans().unbanByName(user.getName());
|
||||
}
|
||||
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
|
||||
user.setMuteTimeout(0);
|
||||
|
@@ -192,7 +192,7 @@ public class EssentialsUpgrade
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
{
|
||||
User user = new User(new OfflinePlayer(username), ess);
|
||||
User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
String nickname = usersConfig.getString(username + ".nickname");
|
||||
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
|
||||
{
|
||||
|
@@ -1,12 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.BlockChangeDelegate;
|
||||
import org.bukkit.Chunk;
|
||||
import org.bukkit.ChunkSnapshot;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.TreeType;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
@@ -171,26 +174,6 @@ public class FakeWorld implements World
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Minecart spawnMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public StorageMinecart spawnStorageMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PoweredMinecart spawnPoweredMinecart(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Boat spawnBoat(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public LivingEntity spawnCreature(Location lctn, CreatureType ct)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
@@ -355,5 +338,71 @@ public class FakeWorld implements World
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean createExplosion(double d, double d1, double d2, float f, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean createExplosion(Location lctn, float f, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public <T extends Entity> T spawn(Location lctn, Class<T> type) throws IllegalArgumentException
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public ChunkSnapshot getEmptyChunkSnapshot(int i, int i1, boolean bln, boolean bln1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setSpawnFlags(boolean bln, boolean bln1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean getAllowAnimals()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean getAllowMonsters()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public UUID getUID()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Block getHighestBlockAt(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public Block getHighestBlockAt(Location lctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
public Biome getBiome(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public double getTemperature(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public double getHumidity(int i, int i1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,68 +1,69 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.io.File;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import java.util.Map;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
public interface IEssentials
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
{
|
||||
void addReloadListener(IConf listener);
|
||||
|
||||
|
||||
void reload();
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath);
|
||||
|
||||
|
||||
boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix);
|
||||
|
||||
User getUser(Object base);
|
||||
|
||||
|
||||
User getOfflineUser(String name);
|
||||
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
|
||||
int broadcastMessage(String name, String message);
|
||||
|
||||
Settings getSettings();
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
CraftScheduler getScheduler();
|
||||
|
||||
|
||||
String[] getMotd(CommandSender sender, String def);
|
||||
|
||||
|
||||
String[] getLines(CommandSender sender, String node, String def);
|
||||
|
||||
|
||||
Jail getJail();
|
||||
|
||||
|
||||
Warps getWarps();
|
||||
|
||||
|
||||
Worth getWorth();
|
||||
|
||||
|
||||
Backup getBackup();
|
||||
|
||||
|
||||
Spawn getSpawn();
|
||||
|
||||
void loadBanList();
|
||||
|
||||
public boolean isRegisterFallbackEnabled();
|
||||
|
||||
public Methods getPaymentMethod();
|
||||
|
||||
Server getServer();
|
||||
|
||||
File getDataFolder();
|
||||
|
||||
PluginDescriptionFile getDescription();
|
||||
|
||||
|
||||
Methods getPaymentMethod();
|
||||
|
||||
int scheduleAsyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run);
|
||||
|
||||
|
||||
int scheduleSyncDelayedTask(Runnable run, long delay);
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
List<String> getBans();
|
||||
BanWorkaround getBans();
|
||||
|
||||
List<String> getBannedIps();
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
|
||||
void setPermissionsHandler(IPermissionsHandler handler);
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
Map<String, User> getAllUsers();
|
||||
|
||||
ItemDb getItemDb();
|
||||
}
|
||||
|
@@ -0,0 +1,21 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public interface IPermissionsHandler
|
||||
{
|
||||
|
||||
String getGroup(Player base);
|
||||
|
||||
boolean canBuild(Player base, String group);
|
||||
|
||||
boolean inGroup(Player base, String group);
|
||||
|
||||
boolean hasPermission(Player base, String node);
|
||||
|
||||
String getPrefix(Player base);
|
||||
|
||||
String getSuffix(Player base);
|
||||
|
||||
}
|
133
Essentials/src/com/earth2me/essentials/ISettings.java
Normal file
133
Essentials/src/com/earth2me/essentials/ISettings.java
Normal file
@@ -0,0 +1,133 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public interface ISettings extends IConf
|
||||
{
|
||||
|
||||
boolean areSignsDisabled();
|
||||
|
||||
String format(String format, IUser user);
|
||||
|
||||
String getAnnounceNewPlayerFormat(IUser user);
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
|
||||
boolean getBedSetsHome();
|
||||
|
||||
String getChatFormat(String group);
|
||||
|
||||
int getChatRadius();
|
||||
|
||||
double getCommandCost(IEssentialsCommand cmd);
|
||||
|
||||
double getCommandCost(String label);
|
||||
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
boolean getGenerateExitPortals();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
|
||||
Map<String, Object> getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
String getNetherName();
|
||||
|
||||
boolean getNetherPortalsEnabled();
|
||||
|
||||
double getNetherRatio();
|
||||
|
||||
String getNewbieSpawn();
|
||||
|
||||
String getNicknamePrefix();
|
||||
|
||||
ChatColor getOperatorColor() throws Exception;
|
||||
|
||||
boolean getPerWarpPermission();
|
||||
|
||||
boolean getProtectBoolean(final String configName, boolean def);
|
||||
|
||||
int getProtectCreeperMaxHeight();
|
||||
|
||||
List<Integer> getProtectList(final String configName);
|
||||
|
||||
boolean getProtectPreventSpawn(final String creatureName);
|
||||
|
||||
String getProtectString(final String configName);
|
||||
|
||||
boolean getReclaimSetting();
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
int getSpawnMobLimit();
|
||||
|
||||
int getStartingBalance();
|
||||
|
||||
double getTeleportCooldown();
|
||||
|
||||
double getTeleportDelay();
|
||||
|
||||
boolean hidePermissionlessHelp();
|
||||
|
||||
boolean isCommandDisabled(final IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandDisabled(String label);
|
||||
|
||||
boolean isCommandOverridden(String name);
|
||||
|
||||
boolean isCommandRestricted(IEssentialsCommand cmd);
|
||||
|
||||
boolean isCommandRestricted(String label);
|
||||
|
||||
boolean isDebug();
|
||||
|
||||
boolean isEcoDisabled();
|
||||
|
||||
boolean isNetherEnabled();
|
||||
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
|
||||
boolean use1to1RatioInNether();
|
||||
|
||||
boolean warnOnBuildDisallow();
|
||||
|
||||
boolean warnOnSmite();
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
public boolean useBukkitPermissions();
|
||||
}
|
@@ -22,6 +22,8 @@ public interface IUser
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
|
||||
@@ -33,6 +35,8 @@ public interface IUser
|
||||
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
PlayerInventory getInventory();
|
||||
|
||||
void updateInventory();
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.craftbukkit.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -17,18 +19,18 @@ public final class InventoryWorkaround
|
||||
private InventoryWorkaround()
|
||||
{
|
||||
}
|
||||
|
||||
public static int first(Inventory ci, ItemStack item, boolean forceDurability, boolean forceAmount)
|
||||
|
||||
public static int first(final Inventory inventory, final ItemStack item, final boolean forceDurability, final boolean forceAmount)
|
||||
{
|
||||
return next(ci, item, 0, forceDurability, forceAmount);
|
||||
return next(inventory, item, 0, forceDurability, forceAmount);
|
||||
}
|
||||
|
||||
public static int next(Inventory ci, ItemStack item, int start, boolean forceDurability, boolean forceAmount)
|
||||
public static int next(final Inventory cinventory, final ItemStack item, final int start, final boolean forceDurability, final boolean forceAmount)
|
||||
{
|
||||
ItemStack[] inventory = ci.getContents();
|
||||
final ItemStack[] inventory = cinventory.getContents();
|
||||
for (int i = start; i < inventory.length; i++)
|
||||
{
|
||||
ItemStack cItem = inventory[i];
|
||||
final ItemStack cItem = inventory[i];
|
||||
if (cItem == null)
|
||||
{
|
||||
continue;
|
||||
@@ -41,15 +43,138 @@ public final class InventoryWorkaround
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static HashMap<Integer, ItemStack> removeItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
public static int firstPartial(final Inventory cinventory, final ItemStack item, final boolean forceDurability)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
if (item == null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
final ItemStack[] inventory = cinventory.getContents();
|
||||
for (int i = 0; i < inventory.length; i++)
|
||||
{
|
||||
final ItemStack cItem = inventory[i];
|
||||
if (cItem == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (item.getTypeId() == cItem.getTypeId() && cItem.getAmount() < cItem.getType().getMaxStackSize() && (!forceDurability || cItem.getDurability() == item.getDurability()))
|
||||
{
|
||||
return i;
|
||||
}
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
public static Map<Integer, ItemStack> addItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
/* TODO: some optimization
|
||||
* - Create a 'firstPartial' with a 'fromIndex'
|
||||
* - Record the lastPartial per Material
|
||||
* - Cache firstEmpty result
|
||||
*/
|
||||
|
||||
// combine items
|
||||
|
||||
ItemStack[] combined = new ItemStack[items.length];
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
if (items[i] == null || items[i].getAmount() < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (int j = 0; j < combined.length; j++)
|
||||
{
|
||||
if (combined[j] == null)
|
||||
{
|
||||
combined[j] = new ItemStack(items[i].getType(), items[i].getAmount(), items[i].getDurability());
|
||||
break;
|
||||
}
|
||||
if (combined[j].getTypeId() == items[i].getTypeId() && (!forceDurability || combined[j].getDurability() == items[i].getDurability()))
|
||||
{
|
||||
combined[j].setAmount(combined[j].getAmount() + items[i].getAmount());
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (int i = 0; i < combined.length; i++)
|
||||
{
|
||||
final ItemStack item = combined[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
while (true)
|
||||
{
|
||||
// Do we already have a stack of it?
|
||||
final int firstPartial = firstPartial(cinventory, item, forceDurability);
|
||||
|
||||
// Drat! no partial stack
|
||||
if (firstPartial == -1)
|
||||
{
|
||||
// Find a free spot!
|
||||
final int firstFree = cinventory.firstEmpty();
|
||||
|
||||
if (firstFree == -1)
|
||||
{
|
||||
// No space at all!
|
||||
leftover.put(i, item);
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// More than a single stack!
|
||||
if (item.getAmount() > item.getType().getMaxStackSize())
|
||||
{
|
||||
cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
||||
}
|
||||
else
|
||||
{
|
||||
// Just store it
|
||||
cinventory.setItem(firstFree, item);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// So, apparently it might only partially fit, well lets do just that
|
||||
final ItemStack partialItem = cinventory.getItem(firstPartial);
|
||||
|
||||
final int amount = item.getAmount();
|
||||
final int partialAmount = partialItem.getAmount();
|
||||
final int maxAmount = partialItem.getType().getMaxStackSize();
|
||||
|
||||
// Check if it fully fits
|
||||
if (amount + partialAmount <= maxAmount)
|
||||
{
|
||||
partialItem.setAmount(amount + partialAmount);
|
||||
break;
|
||||
}
|
||||
|
||||
// It fits partially
|
||||
partialItem.setAmount(maxAmount);
|
||||
item.setAmount(amount + partialAmount - maxAmount);
|
||||
}
|
||||
}
|
||||
}
|
||||
return leftover;
|
||||
}
|
||||
|
||||
public static Map<Integer, ItemStack> removeItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
for (int i = 0; i < items.length; i++)
|
||||
{
|
||||
ItemStack item = items[i];
|
||||
final ItemStack item = items[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -66,7 +191,7 @@ public final class InventoryWorkaround
|
||||
}
|
||||
|
||||
// get first Item, ignore the amount
|
||||
int first = first(ci, item, forceDurability, false);
|
||||
final int first = first(cinventory, item, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (first == -1)
|
||||
@@ -77,20 +202,20 @@ public final class InventoryWorkaround
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(first);
|
||||
int amount = itemStack.getAmount();
|
||||
final ItemStack itemStack = cinventory.getItem(first);
|
||||
final int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= toDelete)
|
||||
{
|
||||
toDelete -= amount;
|
||||
// clear the slot, all used up
|
||||
ci.clear(first);
|
||||
cinventory.clear(first);
|
||||
}
|
||||
else
|
||||
{
|
||||
// split the stack and store
|
||||
itemStack.setAmount(amount - toDelete);
|
||||
ci.setItem(first, itemStack);
|
||||
cinventory.setItem(first, itemStack);
|
||||
toDelete = 0;
|
||||
}
|
||||
}
|
||||
@@ -99,9 +224,9 @@ public final class InventoryWorkaround
|
||||
return leftover;
|
||||
}
|
||||
|
||||
public static boolean containsItem(Inventory ci, boolean forceDurability, ItemStack... items)
|
||||
public static boolean containsItem(final Inventory cinventory, final boolean forceDurability, final ItemStack... items)
|
||||
{
|
||||
HashMap<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
final Map<Integer, ItemStack> leftover = new HashMap<Integer, ItemStack>();
|
||||
|
||||
// TODO: optimization
|
||||
|
||||
@@ -131,7 +256,7 @@ public final class InventoryWorkaround
|
||||
|
||||
for (int i = 0; i < combined.length; i++)
|
||||
{
|
||||
ItemStack item = combined[i];
|
||||
final ItemStack item = combined[i];
|
||||
if (item == null)
|
||||
{
|
||||
continue;
|
||||
@@ -147,7 +272,7 @@ public final class InventoryWorkaround
|
||||
break;
|
||||
}
|
||||
|
||||
int slot = next(ci, item, position, forceDurability, false);
|
||||
final int slot = next(cinventory, item, position, forceDurability, false);
|
||||
|
||||
// Drat! we don't have this type in the inventory
|
||||
if (slot == -1)
|
||||
@@ -157,8 +282,8 @@ public final class InventoryWorkaround
|
||||
}
|
||||
else
|
||||
{
|
||||
ItemStack itemStack = ci.getItem(slot);
|
||||
int amount = itemStack.getAmount();
|
||||
final ItemStack itemStack = cinventory.getItem(slot);
|
||||
final int amount = itemStack.getAmount();
|
||||
|
||||
if (amount <= mustHave)
|
||||
{
|
||||
@@ -175,17 +300,19 @@ public final class InventoryWorkaround
|
||||
return leftover.isEmpty();
|
||||
}
|
||||
|
||||
public static Item[] dropItem(Location loc, ItemStack itm)
|
||||
public static Item[] dropItem(final Location loc, final ItemStack itm)
|
||||
{
|
||||
int maxStackSize = itm.getType().getMaxStackSize();
|
||||
int stacks = itm.getAmount() / maxStackSize;
|
||||
int leftover = itm.getAmount() % maxStackSize;
|
||||
final int maxStackSize = itm.getType().getMaxStackSize();
|
||||
final int stacks = itm.getAmount() / maxStackSize;
|
||||
final int leftover = itm.getAmount() % maxStackSize;
|
||||
Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++) {
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), maxStackSize, itm.getDurability()));
|
||||
}
|
||||
if (leftover > 0) {
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
|
||||
if (leftover > 0)
|
||||
{
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, new ItemStack(itm.getType(), leftover, itm.getDurability()));
|
||||
}
|
||||
return itemStacks;
|
||||
}
|
||||
|
@@ -7,30 +7,31 @@ import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public final class ItemDb
|
||||
public class ItemDb implements IConf
|
||||
{
|
||||
private ItemDb()
|
||||
{
|
||||
}
|
||||
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private static Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private static Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public static void load(File folder, String fname) throws IOException
|
||||
public ItemDb(IEssentials ess)
|
||||
{
|
||||
folder.mkdirs();
|
||||
File file = new File(folder, fname);
|
||||
this.ess = ess;
|
||||
}
|
||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Map<String, Integer> items = new HashMap<String, Integer>();
|
||||
private final transient Map<String, Short> durabilities = new HashMap<String, Short>();
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
final File file = new File(ess.getDataFolder(), "items.csv");
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
file.createNewFile();
|
||||
InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
|
||||
final InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
|
||||
FileWriter tx = null;
|
||||
try
|
||||
{
|
||||
@@ -41,6 +42,11 @@ public final class ItemDb
|
||||
}
|
||||
tx.flush();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
@@ -63,52 +69,67 @@ public final class ItemDb
|
||||
}
|
||||
}
|
||||
|
||||
BufferedReader rx = new BufferedReader(new FileReader(file));
|
||||
BufferedReader rx = null;
|
||||
try
|
||||
{
|
||||
rx = new BufferedReader(new FileReader(file));
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (int i = 0; rx.ready(); i++)
|
||||
{
|
||||
try
|
||||
{
|
||||
String line = rx.readLine().trim().toLowerCase();
|
||||
final String line = rx.readLine().trim().toLowerCase();
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
String[] parts = line.split("[^a-z0-9]");
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
int numeric = Integer.parseInt(parts[1]);
|
||||
final int numeric = Integer.parseInt(parts[1]);
|
||||
|
||||
durabilities.put(parts[0].toLowerCase(), parts.length > 2 && !parts[2].equals("0") ? Short.parseShort(parts[2]) : 0);
|
||||
items.put(parts[0].toLowerCase(), numeric);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.warning(Util.format("parseError", fname, i));
|
||||
LOGGER.warning(Util.format("parseError", "items.csv", i));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
if (rx != null) {
|
||||
try
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack get(String id, int quantity) throws Exception
|
||||
public ItemStack get(final String id, final int quantity) throws Exception
|
||||
{
|
||||
ItemStack retval = get(id.toLowerCase());
|
||||
final ItemStack retval = get(id.toLowerCase());
|
||||
retval.setAmount(quantity);
|
||||
return retval;
|
||||
}
|
||||
|
||||
public static ItemStack get(String id) throws Exception
|
||||
public ItemStack get(final String id) throws Exception
|
||||
{
|
||||
int itemid = 0;
|
||||
String itemname = null;
|
||||
@@ -127,11 +148,11 @@ public final class ItemDb
|
||||
itemname = id.split("[:+',;.]")[0].toLowerCase();
|
||||
metaData = Short.parseShort(id.split("[:+',;.]")[1]);
|
||||
}
|
||||
else
|
||||
else
|
||||
{
|
||||
itemname = id.toLowerCase();
|
||||
}
|
||||
|
||||
|
||||
if (itemname != null)
|
||||
{
|
||||
if (items.containsKey(itemname))
|
||||
@@ -148,13 +169,13 @@ public final class ItemDb
|
||||
}
|
||||
}
|
||||
|
||||
Material mat = Material.getMaterial(itemid);
|
||||
final Material mat = Material.getMaterial(itemid);
|
||||
if (mat == null)
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemId", itemid));
|
||||
}
|
||||
ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(Essentials.getStatic().getSettings().getDefaultStackSize());
|
||||
final ItemStack retval = new ItemStack(mat);
|
||||
retval.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
retval.setDurability(metaData);
|
||||
return retval;
|
||||
}
|
||||
|
@@ -42,7 +42,10 @@ public class Jail extends BlockListener implements IConf
|
||||
|
||||
public void sendToJail(User user, String jail) throws Exception
|
||||
{
|
||||
user.getTeleport().now(getJail(jail));
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
user.getTeleport().now(getJail(jail));
|
||||
}
|
||||
user.setJail(jail);
|
||||
}
|
||||
|
||||
|
@@ -1,11 +1,17 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerListener;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
|
||||
|
||||
public class JailPlayerListener extends PlayerListener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
|
||||
public JailPlayerListener(IEssentials parent)
|
||||
@@ -16,10 +22,63 @@ public class JailPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerInteract(PlayerInteractEvent event)
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isJailed() && user.getJail() != null && !user.getJail().isEmpty())
|
||||
{
|
||||
try
|
||||
{
|
||||
event.setRespawnLocation(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (!user.isJailed() || user.getJail() == null || user.getJail().isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
event.setTo(ess.getJail().getJail(user.getJail()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
user.sendMessage(Util.i18n("jailMessage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
User u = ess.getUser(event.getPlayer());
|
||||
if (u.isJailed())
|
||||
{
|
||||
try
|
||||
{
|
||||
ess.getJail().sendToJail(u, u.getJail());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.i18n("returnPlayerToJailError"), ex);
|
||||
}
|
||||
u.sendMessage(Util.i18n("jailMessage"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,75 +1,55 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.Entity;
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY),
|
||||
COW("Cow", Enemies.FRIENDLY),
|
||||
CREEPER("Creeper", Enemies.ENEMY),
|
||||
GHAST("Ghast", Enemies.ENEMY),
|
||||
GIANT("Giant", "GiantZombie", Enemies.ENEMY),
|
||||
PIG("Pig", Enemies.FRIENDLY),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, ""),
|
||||
SKELETON("Skeleton", Enemies.ENEMY),
|
||||
SLIME("Slime", Enemies.ENEMY),
|
||||
SPIDER("Spider", Enemies.ENEMY),
|
||||
SQUID("Squid", Enemies.FRIENDLY),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY),
|
||||
MONSTER("Monster", Enemies.ENEMY),
|
||||
WOLF("Wolf", Enemies.NEUTRAL);
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
||||
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);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s)
|
||||
private Mob(String n, Enemies en, String s, CreatureType type)
|
||||
{
|
||||
this.s = s;
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en)
|
||||
private Mob(String n, Enemies en, CreatureType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = n;
|
||||
this.type = en;
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.craftClass = n;
|
||||
this.entityClass = ec;
|
||||
this.type = en;
|
||||
}
|
||||
|
||||
private Mob(String n, String ec, String cc, Enemies en)
|
||||
{
|
||||
this.name = n;
|
||||
this.entityClass = ec;
|
||||
this.craftClass = cc;
|
||||
this.type = en;
|
||||
}
|
||||
public String s = "s";
|
||||
public String name;
|
||||
public Enemies type;
|
||||
private String entityClass;
|
||||
private String craftClass;
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private CreatureType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
@@ -80,24 +60,16 @@ public enum Mob
|
||||
}
|
||||
}
|
||||
|
||||
@SuppressWarnings(
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
{
|
||||
"unchecked", "CallToThreadDumpStack"
|
||||
})
|
||||
public CraftEntity spawn(Player player, Server server) throws MobException
|
||||
{
|
||||
try
|
||||
|
||||
final LivingEntity entity = player.getWorld().spawnCreature(loc, this.bukkitType);
|
||||
if (entity == null)
|
||||
{
|
||||
WorldServer world = ((org.bukkit.craftbukkit.CraftWorld)player.getWorld()).getHandle();
|
||||
Constructor<CraftEntity> craft = (Constructor<CraftEntity>)ClassLoader.getSystemClassLoader().loadClass("org.bukkit.craftbukkit.entity.Craft" + craftClass).getConstructors()[0];
|
||||
Constructor<Entity> entity = (Constructor<Entity>)ClassLoader.getSystemClassLoader().loadClass("net.minecraft.server.Entity" + entityClass).getConstructors()[0];
|
||||
return craft.newInstance((CraftServer)server, entity.newInstance(world));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"), ex);
|
||||
throw new MobException(ex);
|
||||
logger.log(Level.WARNING, Util.i18n("unableToSpawnMob"));
|
||||
throw new MobException();
|
||||
}
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
||||
@@ -107,22 +79,17 @@ public enum Mob
|
||||
NEUTRAL("neutral"),
|
||||
ENEMY("enemy");
|
||||
|
||||
private Enemies(String t)
|
||||
private Enemies(final String t)
|
||||
{
|
||||
this.type = t;
|
||||
}
|
||||
protected String type;
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
private MobException(Exception ex)
|
||||
{
|
||||
super(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static Mob fromName(String n)
|
||||
|
@@ -3,11 +3,14 @@ package com.earth2me.essentials;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Note;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.Statistic;
|
||||
import org.bukkit.World;
|
||||
@@ -21,19 +24,26 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
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 OfflinePlayer implements Player
|
||||
{
|
||||
private final String name;
|
||||
final transient IEssentials ess;
|
||||
private Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private World world = null;
|
||||
private World world;
|
||||
private UUID uniqueId = UUID.randomUUID();
|
||||
|
||||
public OfflinePlayer(String name)
|
||||
public OfflinePlayer(String name, IEssentials ess)
|
||||
{
|
||||
this.name = name;
|
||||
this.ess = ess;
|
||||
this.world = ess.getServer().getWorlds().get(0);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
@@ -139,7 +149,7 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
return world;
|
||||
}
|
||||
|
||||
|
||||
public void setLocation(Location loc)
|
||||
{
|
||||
location = loc;
|
||||
@@ -256,7 +266,7 @@ public class OfflinePlayer implements Player
|
||||
|
||||
public Server getServer()
|
||||
{
|
||||
return Essentials.getStatic() == null ? null : Essentials.getStatic().getServer();
|
||||
return ess == null ? null : ess.getServer();
|
||||
}
|
||||
|
||||
public Vector getMomentum()
|
||||
@@ -294,7 +304,8 @@ public class OfflinePlayer implements Player
|
||||
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
|
||||
}
|
||||
|
||||
public void sendRawMessage(String string) {
|
||||
public void sendRawMessage(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException(Util.i18n("notSupportedYet"));
|
||||
}
|
||||
|
||||
@@ -477,4 +488,92 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
return uniqueId;
|
||||
}
|
||||
|
||||
public void playNote(Location lctn, Instrument i, Note note)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setPlayerTime(long l, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public long getPlayerTime()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public long getPlayerTimeOffset()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean isPlayerTimeRelative()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void resetPlayerTime()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPermissionSet(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(String string)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean hasPermission(Permission prmsn)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, String string, boolean bln, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public PermissionAttachment addAttachment(Plugin plugin, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void removeAttachment(PermissionAttachment pa)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void recalculatePermissions()
|
||||
{
|
||||
}
|
||||
|
||||
public Set<PermissionAttachmentInfo> getEffectivePermissions()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,49 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class Permissions2Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
Permissions2Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return permissionHandler.getGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canGroupBuild(base.getWorld().getName(), getGroup(base));
|
||||
}
|
||||
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.permission(base, node);
|
||||
}
|
||||
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
final String prefix = permissionHandler.getGroupPrefix(base.getWorld().getName(), getGroup(base));
|
||||
return prefix == null ? "" : prefix;
|
||||
}
|
||||
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
final String suffix = permissionHandler.getGroupSuffix(base.getWorld().getName(), getGroup(base));
|
||||
return suffix == null ? "" : suffix;
|
||||
}
|
||||
}
|
@@ -0,0 +1,48 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.nijiko.permissions.PermissionHandler;
|
||||
import com.nijikokun.bukkit.Permissions.Permissions;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
|
||||
public class Permissions3Handler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionHandler permissionHandler;
|
||||
|
||||
Permissions3Handler(final Plugin permissionsPlugin)
|
||||
{
|
||||
permissionHandler = ((Permissions)permissionsPlugin).getHandler();
|
||||
}
|
||||
|
||||
public String getGroup(final Player base)
|
||||
{
|
||||
return permissionHandler.getPrimaryGroup(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
public boolean canBuild(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.canUserBuild(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
public boolean inGroup(final Player base, final String group)
|
||||
{
|
||||
return permissionHandler.inGroup(base.getWorld().getName(), base.getName(), group);
|
||||
}
|
||||
|
||||
public boolean hasPermission(final Player base, final String node)
|
||||
{
|
||||
return permissionHandler.has(base, node);
|
||||
}
|
||||
|
||||
public String getPrefix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserPrefix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
public String getSuffix(final Player base)
|
||||
{
|
||||
return permissionHandler.getUserSuffix(base.getWorld().getName(), base.getName());
|
||||
}
|
||||
|
||||
}
|
@@ -0,0 +1,74 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import ru.tehkode.permissions.PermissionManager;
|
||||
import ru.tehkode.permissions.PermissionUser;
|
||||
import ru.tehkode.permissions.bukkit.PermissionsEx;
|
||||
|
||||
|
||||
class PermissionsExHandler implements IPermissionsHandler
|
||||
{
|
||||
private final transient PermissionManager manager;
|
||||
|
||||
public PermissionsExHandler()
|
||||
{
|
||||
manager = PermissionsEx.getPermissionManager();
|
||||
}
|
||||
|
||||
public String getGroup(Player base)
|
||||
{
|
||||
final PermissionUser user = manager.getUser(base.getName());
|
||||
if (user == null)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
return user.getGroupsNames()[0];
|
||||
}
|
||||
|
||||
public boolean canBuild(Player base, String group)
|
||||
{
|
||||
final PermissionUser user = manager.getUser(base.getName());
|
||||
if (user == null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
return user.getOptionBoolean("build", base.getWorld().getName(), true);
|
||||
}
|
||||
|
||||
public boolean inGroup(Player base, String group)
|
||||
{
|
||||
final PermissionUser user = manager.getUser(base.getName());
|
||||
if (user == null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return user.inGroup(group);
|
||||
}
|
||||
|
||||
public boolean hasPermission(Player base, String node)
|
||||
{
|
||||
return manager.has(base.getName(), node, base.getWorld().getName());
|
||||
}
|
||||
|
||||
public String getPrefix(Player base)
|
||||
{
|
||||
final PermissionUser user = manager.getUser(base.getName());
|
||||
if (user == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return user.getPrefix();
|
||||
}
|
||||
|
||||
public String getSuffix(Player base)
|
||||
{
|
||||
final PermissionUser user = manager.getUser(base.getName());
|
||||
if (user == null)
|
||||
{
|
||||
return "";
|
||||
}
|
||||
return user.getSuffix();
|
||||
}
|
||||
}
|
@@ -19,12 +19,12 @@ public class PlayerExtension extends PlayerWrapper
|
||||
|
||||
public boolean isBanned()
|
||||
{
|
||||
return ess.getBans().contains(getName());
|
||||
return ess.getBans().isNameBanned(this.getName());
|
||||
}
|
||||
|
||||
public boolean isIpBanned()
|
||||
{
|
||||
return ess.getBannedIps().contains(getAddress().getAddress().toString().replace("/", ""));
|
||||
return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
@@ -53,38 +53,17 @@ public class PlayerExtension extends PlayerWrapper
|
||||
|
||||
public String getGroup()
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.getGroup(getWorld().getName(), getName());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return "default";
|
||||
}
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
}
|
||||
|
||||
public boolean inGroup(String group)
|
||||
{
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.inGroup(getWorld().getName(), getName(), group);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ess.getPermissionsHandler().inGroup(base, group);
|
||||
}
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
try
|
||||
{
|
||||
return isOp() || com.nijikokun.bukkit.Permissions.Permissions.Security.canGroupBuild(getWorld().getName(), getGroup());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
public EntityPlayer getHandle()
|
||||
|
@@ -7,6 +7,10 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
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
|
||||
@@ -530,4 +534,94 @@ public class PlayerWrapper implements Player
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
@@ -6,65 +6,74 @@ import org.bukkit.ChatColor;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Settings implements IConf
|
||||
public class Settings implements ISettings
|
||||
{
|
||||
private final EssentialsConf config;
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Settings(File dataFolder)
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
config = new EssentialsConf(new File(dataFolder, "config.yml"));
|
||||
this.ess = ess;
|
||||
config = new EssentialsConf(new File(ess.getDataFolder(), "config.yml"));
|
||||
config.setTemplateName("/config.yml");
|
||||
config.load();
|
||||
reloadConfig();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getRespawnAtHome()
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
{
|
||||
return config.getBoolean("bed-sethome", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getChatRadius()
|
||||
{
|
||||
return config.getInt("chat.radius", config.getInt("chat-radius", 0));
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportDelay()
|
||||
{
|
||||
return config.getDouble("teleport-delay", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getDefaultStackSize()
|
||||
{
|
||||
return config.getInt("default-stack-size", 64);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getStartingBalance()
|
||||
{
|
||||
return config.getInt("starting-balance", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getNetherPortalsEnabled()
|
||||
{
|
||||
return isNetherEnabled() && config.getBoolean("nether.portals-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandDisabled(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
@@ -75,11 +84,13 @@ public class Settings implements IConf
|
||||
return config.getBoolean("disable-" + label.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(IEssentialsCommand cmd)
|
||||
{
|
||||
return isCommandRestricted(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
@@ -89,7 +100,19 @@ public class Settings implements IConf
|
||||
}
|
||||
return config.getBoolean("restrict-" + label.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label)) continue;
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
List<String> defaultList = new ArrayList<String>(1);
|
||||
@@ -103,11 +126,13 @@ public class Settings implements IConf
|
||||
return config.getBoolean("override-" + name.toLowerCase(), false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(IEssentialsCommand cmd)
|
||||
{
|
||||
return getCommandCost(cmd.getName());
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getCommandCost(String label)
|
||||
{
|
||||
double cost = config.getDouble("command-costs." + label, 0.0);
|
||||
@@ -116,26 +141,25 @@ public class Settings implements IConf
|
||||
return cost;
|
||||
}
|
||||
|
||||
public String getCommandPrefix()
|
||||
{
|
||||
return config.getString("command-prefix", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNicknamePrefix()
|
||||
{
|
||||
return config.getString("nickname-prefix", "~");
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getTeleportCooldown()
|
||||
{
|
||||
return config.getDouble("teleport-cooldown", 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getHealCooldown()
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 60);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getKit(String name)
|
||||
{
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
@@ -148,11 +172,13 @@ public class Settings implements IConf
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
{
|
||||
return (Map<String, Object>)config.getProperty("kits");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ChatColor getOperatorColor() throws Exception
|
||||
{
|
||||
String colorName = config.getString("ops-name-color", null);
|
||||
@@ -173,257 +199,123 @@ public class Settings implements IConf
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getReclaimSetting()
|
||||
{
|
||||
return config.getBoolean("reclaim-onlogout", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNetherName()
|
||||
{
|
||||
return config.getString("nether.folder", "nether");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isNetherEnabled()
|
||||
{
|
||||
return config.getBoolean("nether.enabled", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSpawnMobLimit()
|
||||
{
|
||||
return config.getInt("spawnmob-limit", 10);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean showNonEssCommandsInHelp()
|
||||
{
|
||||
return config.getBoolean("non-ess-in-help", true);
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpSettings()
|
||||
|
||||
@Override
|
||||
public boolean hidePermissionlessHelp()
|
||||
{
|
||||
Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
|
||||
return config.getBoolean("hide-permissionless-help", true);
|
||||
}
|
||||
|
||||
epSettings.put("protect.protect.signs", config.getBoolean("protect.protect.signs", true));
|
||||
epSettings.put("protect.protect.rails", config.getBoolean("protect.protect.rails", true));
|
||||
epSettings.put("protect.protect.block-below", config.getBoolean("protect.protect.block-below", true));
|
||||
epSettings.put("protect.protect.prevent-block-on-rails", config.getBoolean("protect.protect.prevent-block-on-rails", false));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public Map<String, String> getEpDBSettings()
|
||||
{
|
||||
Map<String, String> epSettings = new HashMap<String, String>();
|
||||
epSettings.put("protect.datatype", config.getString("protect.datatype", "sqlite"));
|
||||
epSettings.put("protect.username", config.getString("protect.username", "root"));
|
||||
epSettings.put("protect.password", config.getString("protect.password", "root"));
|
||||
epSettings.put("protect.mysqlDb", config.getString("protect.mysqlDb", "jdbc:mysql://localhost:3306/minecraft"));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnPlacement()
|
||||
{
|
||||
final List<Integer> epAlertPlace = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-placement", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertPlace.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-placement"));
|
||||
}
|
||||
}
|
||||
return epAlertPlace;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnUse()
|
||||
{
|
||||
final List<Integer> epAlertUse = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-use", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertUse.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-use"));
|
||||
}
|
||||
}
|
||||
return epAlertUse;
|
||||
}
|
||||
|
||||
public List<Integer> getEpAlertOnBreak()
|
||||
{
|
||||
final List<Integer> epAlertPlace = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.alert.on-break", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epAlertPlace.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "alert.on-break"));
|
||||
}
|
||||
}
|
||||
return epAlertPlace;
|
||||
}
|
||||
|
||||
public List<Integer> epBlackListPlacement()
|
||||
{
|
||||
final List<Integer> epBlacklistPlacement = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.placement", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBlacklistPlacement.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.placement"));
|
||||
}
|
||||
}
|
||||
return epBlacklistPlacement;
|
||||
}
|
||||
|
||||
public List<Integer> epBlackListUsage()
|
||||
{
|
||||
final List<Integer> epBlackListUsage = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.usage", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBlackListUsage.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.usage"));
|
||||
}
|
||||
}
|
||||
return epBlackListUsage;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpGuardSettings()
|
||||
{
|
||||
final Map<String, Boolean> epSettings = new HashMap<String, Boolean>();
|
||||
epSettings.put("protect.prevent.lava-flow", config.getBoolean("protect.prevent.lava-flow", false));
|
||||
epSettings.put("protect.prevent.water-flow", config.getBoolean("protect.prevent.water-flow", false));
|
||||
epSettings.put("protect.prevent.water-bucket-flow", config.getBoolean("protect.prevent.water-bucket-flow", false));
|
||||
epSettings.put("protect.prevent.fire-spread", config.getBoolean("protect.prevent.fire-spread", true));
|
||||
epSettings.put("protect.prevent.flint-fire", config.getBoolean("protect.prevent.flint-fire", false));
|
||||
epSettings.put("protect.prevent.portal-creation", config.getBoolean("protect.prevent.portal-creation", false));
|
||||
epSettings.put("protect.prevent.lava-fire-spread", config.getBoolean("protect.prevent.lava-fire-spread", true));
|
||||
epSettings.put("protect.prevent.tnt-explosion", config.getBoolean("protect.prevent.tnt-explosion", false));
|
||||
epSettings.put("protect.prevent.creeper-explosion", config.getBoolean("protect.prevent.creeper-explosion", false));
|
||||
epSettings.put("protect.prevent.creeper-playerdamage", config.getBoolean("protect.prevent.creeper-playerdamage", false));
|
||||
epSettings.put("protect.prevent.creeper-blockdamage", config.getBoolean("protect.prevent.creeper-blockdamage", false));
|
||||
epSettings.put("protect.prevent.entitytarget", config.getBoolean("protect.prevent.entitytarget", false));
|
||||
for (CreatureType ct : CreatureType.values()) {
|
||||
final String name = ct.toString().toLowerCase();
|
||||
epSettings.put("protect.prevent.spawn."+name, config.getBoolean("protect.prevent.spawn."+name, false));
|
||||
}
|
||||
epSettings.put("protect.prevent.lightning-fire-spread", config.getBoolean("protect.prevent.lightning-fire-spread", true));
|
||||
return epSettings;
|
||||
}
|
||||
|
||||
public Map<String, Boolean> getEpPlayerSettings()
|
||||
{
|
||||
final Map<String, Boolean> epPlayerSettings = new HashMap<String, Boolean>();
|
||||
epPlayerSettings.put("protect.disable.fall", config.getBoolean("protect.disable.fall", false));
|
||||
epPlayerSettings.put("protect.disable.pvp", config.getBoolean("protect.disable.pvp", false));
|
||||
epPlayerSettings.put("protect.disable.drown", config.getBoolean("protect.disable.drown", false));
|
||||
epPlayerSettings.put("protect.disable.suffocate", config.getBoolean("protect.disable.suffocate", false));
|
||||
epPlayerSettings.put("protect.disable.lavadmg", config.getBoolean("protect.disable.lavadmg", false));
|
||||
epPlayerSettings.put("protect.disable.projectiles", config.getBoolean("protect.disable.projectiles", false));
|
||||
epPlayerSettings.put("protect.disable.contactdmg", config.getBoolean("protect.disable.contactdmg", false));
|
||||
epPlayerSettings.put("protect.disable.firedmg", config.getBoolean("protect.disable.firedmg", false));
|
||||
epPlayerSettings.put("protect.disable.build", config.getBoolean("protect.disable.build", false));
|
||||
epPlayerSettings.put("protect.disable.lightning", config.getBoolean("protect.disable.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.lightning", config.getBoolean("protect.disable.weather.lightning", false));
|
||||
epPlayerSettings.put("protect.disable.weather.storm", config.getBoolean("protect.disable.weather.storm", false));
|
||||
epPlayerSettings.put("protect.disable.weather.thunder", config.getBoolean("protect.disable.weather.thunder", false));
|
||||
return epPlayerSettings;
|
||||
|
||||
}
|
||||
|
||||
public int getEpCreeperMaxHeight()
|
||||
@Override
|
||||
public int getProtectCreeperMaxHeight()
|
||||
{
|
||||
return config.getInt("protect.creeper.max-height", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return config.getBoolean("signs-disabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getBackupInterval()
|
||||
{
|
||||
return config.getInt("backup.interval", 1440); // 1440 = 24 * 60
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getBackupCommand()
|
||||
{
|
||||
return config.getString("backup.command", null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getChatFormat(String group)
|
||||
{
|
||||
return config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getGenerateExitPortals()
|
||||
{
|
||||
return config.getBoolean("nether.generate-exit-portals", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getAnnounceNewPlayers()
|
||||
{
|
||||
return !config.getString("newbies.announce-format", "-").isEmpty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnnounceNewPlayerFormat(IUser user)
|
||||
{
|
||||
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String format, IUser user)
|
||||
{
|
||||
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getNewbieSpawn()
|
||||
{
|
||||
return config.getString("newbies.spawnpoint", "default");
|
||||
}
|
||||
@Override
|
||||
public boolean getPerWarpPermission()
|
||||
{
|
||||
return config.getBoolean("per-warp-permission", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getSortListByGroups()
|
||||
{
|
||||
return config.getBoolean("sort-list-by-groups", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig() {
|
||||
config.load();
|
||||
}
|
||||
|
||||
public ArrayList<Integer> itemSpawnBlacklist()
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
ArrayList<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
@@ -431,7 +323,7 @@ public class Settings implements IConf
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
is = ess.getItemDb().get(itemName);
|
||||
epItemSpwn.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "item-spawn-blacklist"));
|
||||
@@ -440,40 +332,25 @@ public class Settings implements IConf
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
public ArrayList<Integer> epBlockBreakingBlacklist()
|
||||
{
|
||||
ArrayList<Integer> epBreakList = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString("protect.blacklist.break", "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack is;
|
||||
try {
|
||||
is = ItemDb.get(itemName);
|
||||
epBreakList.add(is.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, "blacklist.break"));
|
||||
}
|
||||
}
|
||||
return epBreakList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean spawnIfNoHome()
|
||||
{
|
||||
return config.getBoolean("spawn-if-no-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnBuildDisallow()
|
||||
{
|
||||
return config.getBoolean("protect.disable.warn-on-build-disallow", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean use1to1RatioInNether()
|
||||
{
|
||||
return config.getBoolean("nether.use-1to1-ratio", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getNetherRatio()
|
||||
{
|
||||
if (config.getBoolean("nether.use-1to1-ratio", false)) {
|
||||
@@ -482,38 +359,113 @@ public class Settings implements IConf
|
||||
return config.getDouble("nether.ratio", 16.0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isDebug()
|
||||
{
|
||||
return config.getBoolean("debug", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean warnOnSmite()
|
||||
{
|
||||
return config.getBoolean("warn-on-smite" ,true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissionBasedItemSpawn()
|
||||
{
|
||||
return config.getBoolean("permission-based-item-spawn", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLocale()
|
||||
{
|
||||
return config.getString("locale", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrencySymbol()
|
||||
{
|
||||
return config.getString("currency-symbol", "$").substring(0, 1).replaceAll("[0-9]", "$");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTradeInStacks(int id)
|
||||
{
|
||||
return config.getBoolean("trade-in-stacks-" + id, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoDisabled()
|
||||
{
|
||||
return config.getBoolean("disable-eco", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectPreventSpawn(final String creatureName)
|
||||
{
|
||||
return config.getBoolean("protect.prevent.spawn."+creatureName, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Integer> getProtectList(final String configName)
|
||||
{
|
||||
final List<Integer> list = new ArrayList<Integer>();
|
||||
for (String itemName : config.getString(configName, "").split(",")) {
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty()) {
|
||||
continue;
|
||||
}
|
||||
ItemStack itemStack;
|
||||
try {
|
||||
itemStack = ess.getItemDb().get(itemName);
|
||||
list.add(itemStack.getTypeId());
|
||||
} catch (Exception ex) {
|
||||
logger.log(Level.SEVERE, Util.format("unknownItemInList", itemName, configName));
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProtectString(final String configName)
|
||||
{
|
||||
return config.getString(configName, null);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getProtectBoolean(final String configName, boolean def)
|
||||
{
|
||||
return config.getBoolean(configName, def);
|
||||
}
|
||||
|
||||
private final static double MAXMONEY = 10000000000000.0;
|
||||
public double getMaxMoney()
|
||||
{
|
||||
double max = config.getDouble("max-money", MAXMONEY);
|
||||
if (Math.abs(max) > MAXMONEY) {
|
||||
max = max < 0 ? -MAXMONEY : MAXMONEY;
|
||||
}
|
||||
return max;
|
||||
}
|
||||
|
||||
public boolean isEcoLogEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
return config.getBoolean("remove-god-on-disconnect", false);
|
||||
}
|
||||
|
||||
public boolean changeDisplayName()
|
||||
{
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,82 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
|
||||
|
||||
public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private boolean enabled = false;
|
||||
private int timer = -1;
|
||||
|
||||
public TNTExplodeListener(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void enable()
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
enabled = true;
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
return;
|
||||
}
|
||||
if (timer != -1) {
|
||||
ess.getScheduler().cancelTask(timer);
|
||||
timer = ess.scheduleSyncDelayedTask(this, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEntityExplode(final EntityExplodeEvent event)
|
||||
{
|
||||
if (!enabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getEntity() instanceof LivingEntity)
|
||||
{
|
||||
return;
|
||||
}
|
||||
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)
|
||||
{
|
||||
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));
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
public void run()
|
||||
{
|
||||
enabled = false;
|
||||
}
|
||||
}
|
File diff suppressed because it is too large
Load Diff
@@ -2,7 +2,6 @@ package com.earth2me.essentials;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
@@ -10,6 +9,7 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
public class Teleport implements Runnable
|
||||
{
|
||||
private static final double MOVE_CONSTANT = 0.3;
|
||||
private static class Target
|
||||
{
|
||||
private final Location location;
|
||||
@@ -48,18 +48,18 @@ public class Teleport implements Runnable
|
||||
private long initY;
|
||||
private long initZ;
|
||||
private Target teleportTarget;
|
||||
private Charge chargeFor;
|
||||
private Trade chargeFor;
|
||||
private final IEssentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private void initTimer(long delay, Target target, Charge chargeFor)
|
||||
private void initTimer(long delay, Target target, Trade chargeFor)
|
||||
{
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
this.initX = Math.round(user.getLocation().getX() * 10000);
|
||||
this.initY = Math.round(user.getLocation().getY() * 10000);
|
||||
this.initZ = Math.round(user.getLocation().getZ() * 10000);
|
||||
this.initX = Math.round(user.getLocation().getX()*MOVE_CONSTANT);
|
||||
this.initY = Math.round(user.getLocation().getY()*MOVE_CONSTANT);
|
||||
this.initZ = Math.round(user.getLocation().getZ()*MOVE_CONSTANT);
|
||||
this.teleportTarget = target;
|
||||
this.chargeFor = chargeFor;
|
||||
}
|
||||
@@ -72,9 +72,9 @@ public class Teleport implements Runnable
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
if (Math.round(user.getLocation().getX() * 10000) != initX
|
||||
|| Math.round(user.getLocation().getY() * 10000) != initY
|
||||
|| Math.round(user.getLocation().getZ() * 10000) != initZ
|
||||
if (Math.round(user.getLocation().getX()*MOVE_CONSTANT) != initX
|
||||
|| Math.round(user.getLocation().getY()*MOVE_CONSTANT) != initY
|
||||
|| Math.round(user.getLocation().getZ()*MOVE_CONSTANT) != initZ
|
||||
|| user.getHealth() < health)
|
||||
{ // user moved, cancel teleport
|
||||
cancel(true);
|
||||
@@ -101,11 +101,7 @@ public class Teleport implements Runnable
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
user.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
ess.showError(user.getBase(), ex, "teleport");
|
||||
}
|
||||
return;
|
||||
}
|
||||
@@ -122,12 +118,12 @@ public class Teleport implements Runnable
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void respawn(Spawn spawn, Charge chargeFor) throws Exception
|
||||
public void respawn(Spawn spawn, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(spawn.getSpawn(user.getGroup())), chargeFor);
|
||||
}
|
||||
|
||||
public void warp(String warp, Charge chargeFor) throws Exception
|
||||
public void warp(String warp, Trade chargeFor) throws Exception
|
||||
{
|
||||
Location loc = ess.getWarps().getWarp(warp);
|
||||
teleport(new Target(loc), chargeFor);
|
||||
@@ -181,17 +177,17 @@ public class Teleport implements Runnable
|
||||
cancel(false);
|
||||
}
|
||||
|
||||
public void teleport(Location loc, Charge chargeFor) throws Exception
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor);
|
||||
}
|
||||
|
||||
public void teleport(Entity entity, Charge chargeFor) throws Exception
|
||||
public void teleport(Entity entity, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(entity), chargeFor);
|
||||
}
|
||||
|
||||
private void teleport(Target target, Charge chargeFor) throws Exception
|
||||
private void teleport(Target target, Trade chargeFor) throws Exception
|
||||
{
|
||||
double delay = ess.getSettings().getTeleportDelay();
|
||||
|
||||
@@ -234,20 +230,23 @@ public class Teleport implements Runnable
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
public void now(Location loc, Charge chargeFor) throws Exception
|
||||
public void now(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
chargeFor.charge(user);
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
public void now(Entity entity) throws Exception
|
||||
public void now(Entity entity, boolean cooldown) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
if (cooldown)
|
||||
{
|
||||
cooldown(false);
|
||||
}
|
||||
now(new Target(entity));
|
||||
}
|
||||
|
||||
public void back(Charge chargeFor) throws Exception
|
||||
public void back(Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(user.getLastLocation()), chargeFor);
|
||||
}
|
||||
@@ -257,12 +256,12 @@ public class Teleport implements Runnable
|
||||
back(null);
|
||||
}
|
||||
|
||||
public void home(Charge chargeFor) throws Exception
|
||||
public void home(Trade chargeFor) throws Exception
|
||||
{
|
||||
home(user, chargeFor);
|
||||
}
|
||||
|
||||
public void home(IUser user, Charge chargeFor) throws Exception
|
||||
public void home(IUser user, Trade chargeFor) throws Exception
|
||||
{
|
||||
Location loc = user.getHome(this.user.getLocation());
|
||||
if (loc == null)
|
||||
|
243
Essentials/src/com/earth2me/essentials/Trade.java
Normal file
243
Essentials/src/com/earth2me/essentials/Trade.java
Normal file
@@ -0,0 +1,243 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.text.DateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(null, money, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, items, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (getItemStack() != null
|
||||
&& !InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
|
||||
{
|
||||
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void pay(final IUser user)
|
||||
{
|
||||
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())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
}
|
||||
user.updateInventory();
|
||||
}
|
||||
}
|
||||
|
||||
public void charge(final IUser user) throws ChargeException
|
||||
{
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(getMoney());
|
||||
}
|
||||
if (getItemStack() != null)
|
||||
{
|
||||
if (!InventoryWorkaround.containsItem(user.getInventory(), true, itemStack))
|
||||
{
|
||||
throw new ChargeException(Util.format("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase().replace("_", " ")));
|
||||
}
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new ChargeException(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
user.takeMoney(cost);
|
||||
}
|
||||
}
|
||||
|
||||
public Double getMoney()
|
||||
{
|
||||
return money;
|
||||
}
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (fw == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
fw = new FileWriter(new File(ess.getDataFolder(), "trade.log"), true);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append(type).append(",").append(subtype).append(",").append(event).append(",\"");
|
||||
sb.append(DateFormat.getDateTimeInstance(DateFormat.FULL, DateFormat.FULL).format(new Date()));
|
||||
sb.append("\",\"");
|
||||
if (sender != null)
|
||||
{
|
||||
sb.append(sender);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (charge == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (charge.getItemStack() != null)
|
||||
{
|
||||
sb.append(charge.getItemStack().getAmount()).append(",");
|
||||
sb.append(charge.getItemStack().getType().toString()).append(",");
|
||||
sb.append(charge.getItemStack().getDurability());
|
||||
}
|
||||
if (charge.getMoney() != null)
|
||||
{
|
||||
sb.append(charge.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
}
|
||||
sb.append(",\"");
|
||||
if (receiver != null)
|
||||
{
|
||||
sb.append(receiver);
|
||||
}
|
||||
sb.append("\",");
|
||||
if (pay == null)
|
||||
{
|
||||
sb.append("\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
if (pay.getItemStack() != null)
|
||||
{
|
||||
sb.append(pay.getItemStack().getAmount()).append(",");
|
||||
sb.append(pay.getItemStack().getType().toString()).append(",");
|
||||
sb.append(pay.getItemStack().getDurability());
|
||||
}
|
||||
if (pay.getMoney() != null)
|
||||
{
|
||||
sb.append(pay.getMoney()).append(",");
|
||||
sb.append("money").append(",");
|
||||
sb.append(ess.getSettings().getCurrencySymbol());
|
||||
}
|
||||
}
|
||||
if (loc == null)
|
||||
{
|
||||
sb.append(",\"\",\"\",\"\",\"\"");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(",\"");
|
||||
sb.append(loc.getWorld().getName()).append("\",");
|
||||
sb.append(loc.getBlockX()).append(",");
|
||||
sb.append(loc.getBlockY()).append(",");
|
||||
sb.append(loc.getBlockZ()).append(",");
|
||||
}
|
||||
sb.append("\n");
|
||||
try
|
||||
{
|
||||
fw.write(sb.toString());
|
||||
fw.flush();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeLog()
|
||||
{
|
||||
if (fw != null) {
|
||||
try
|
||||
{
|
||||
fw.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
fw = null;
|
||||
}
|
||||
}
|
||||
}
|
@@ -19,6 +19,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private boolean teleportRequestHere;
|
||||
private final Teleport teleport;
|
||||
private long lastActivity;
|
||||
private boolean hidden = false;
|
||||
|
||||
User(Player base, IEssentials ess)
|
||||
{
|
||||
@@ -34,7 +35,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized("essentials." + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
public boolean isAuthorized(String node)
|
||||
@@ -49,15 +55,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return com.nijikokun.bukkit.Permissions.Permissions.Security.permission(base, node);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
String[] cmds = node.split("\\.", 2);
|
||||
return !ess.getSettings().isCommandRestricted(cmds[cmds.length - 1]);
|
||||
}
|
||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
@@ -79,13 +77,22 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
|
||||
public void giveMoney(double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(double value, CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value)));
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(User reciever, double value) throws Exception
|
||||
@@ -102,19 +109,28 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value), getDisplayName()));
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(double value, CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value)));
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(double cost)
|
||||
@@ -125,7 +141,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public void dispose()
|
||||
{
|
||||
this.base = new OfflinePlayer(getName());
|
||||
this.base = new OfflinePlayer(getName(), ess);
|
||||
}
|
||||
|
||||
public boolean getJustPortaled()
|
||||
@@ -160,8 +176,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User) o).getDisplayName()));
|
||||
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -208,26 +224,39 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public String getNick()
|
||||
{
|
||||
String nickname = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nickname == null || nickname.isEmpty() || nickname.equals(getName()))
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname = getName();
|
||||
nickname.append(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nickname;
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
}
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname = ess.getSettings().getOperatorColor().toString() + nickname + "§f";
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
}
|
||||
catch(Exception e)
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
return nickname;
|
||||
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(this).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(this).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("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
}
|
||||
|
||||
public Teleport getTeleport()
|
||||
@@ -248,19 +277,20 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public double getMoney()
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
{
|
||||
}
|
||||
}
|
||||
return super.getMoney();
|
||||
@@ -269,12 +299,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public void setMoney(double value)
|
||||
{
|
||||
if (ess.isRegisterFallbackEnabled() && ess.getPaymentMethod().hasMethod())
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName())) {
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
@@ -286,4 +317,29 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
super.setMoney(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
|
||||
public boolean isHidden()
|
||||
{
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
}
|
||||
|
@@ -58,18 +58,20 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
}
|
||||
|
||||
private double money;
|
||||
|
||||
private double _getMoney() {
|
||||
|
||||
private double _getMoney()
|
||||
{
|
||||
double money = ess.getSettings().getStartingBalance();
|
||||
if (config.hasProperty("money"))
|
||||
{
|
||||
return config.getDouble("money", ess.getSettings().getStartingBalance());
|
||||
money = config.getDouble("money", money);
|
||||
}
|
||||
else
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
return ess.getSettings().getStartingBalance();
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
return money;
|
||||
}
|
||||
|
||||
public double getMoney()
|
||||
@@ -80,6 +82,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
public void setMoney(double value)
|
||||
{
|
||||
money = value;
|
||||
if (Math.abs(money) > ess.getSettings().getMaxMoney())
|
||||
{
|
||||
money = money < 0 ? -ess.getSettings().getMaxMoney() : ess.getSettings().getMaxMoney();
|
||||
}
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
@@ -92,7 +98,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
@@ -324,7 +330,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || size > getInventory().getSize())
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
@@ -383,6 +389,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setTeleportEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
public boolean toggleSocialSpy()
|
||||
{
|
||||
boolean ret = !isSocialSpyEnabled();
|
||||
@@ -622,7 +629,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
setAfk(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean newplayer;
|
||||
|
||||
private boolean getNew()
|
||||
@@ -641,7 +647,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("newplayer", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@@ -668,38 +673,36 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isSocialSpyEnabled;
|
||||
|
||||
|
||||
private boolean _isSocialSpyEnabled()
|
||||
{
|
||||
return config.getBoolean("socialspy", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isSocialSpyEnabled()
|
||||
{
|
||||
return isSocialSpyEnabled;
|
||||
}
|
||||
|
||||
|
||||
public void setSocialSpyEnabled(boolean status)
|
||||
{
|
||||
isSocialSpyEnabled = status;
|
||||
config.setProperty("socialspy", status);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean isNPC;
|
||||
|
||||
|
||||
private boolean _isNPC()
|
||||
{
|
||||
return config.getBoolean("npc", false);
|
||||
}
|
||||
|
||||
|
||||
public boolean isNPC()
|
||||
{
|
||||
return isNPC;
|
||||
}
|
||||
|
||||
|
||||
public void setNPC(boolean set)
|
||||
{
|
||||
isNPC = set;
|
||||
|
@@ -218,7 +218,7 @@ public class Util
|
||||
|
||||
public static Location getSafeDestination(Location loc) throws Exception
|
||||
{
|
||||
if (loc == null)
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
}
|
||||
@@ -284,9 +284,9 @@ public class Util
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(double value)
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
String str = Essentials.getStatic().getSettings().getCurrencySymbol() + df.format(value);
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -307,19 +307,21 @@ public class Util
|
||||
|
||||
private static class ConfigClassLoader extends ClassLoader
|
||||
{
|
||||
private final File dataFolder;
|
||||
private final ClassLoader cl;
|
||||
private final transient File dataFolder;
|
||||
private final transient ClassLoader cl;
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ConfigClassLoader(File dataFolder, ClassLoader cl)
|
||||
public ConfigClassLoader(final ClassLoader cl, final IEssentials ess)
|
||||
{
|
||||
this.dataFolder = dataFolder;
|
||||
this.ess = ess;
|
||||
this.dataFolder = ess.getDataFolder();
|
||||
this.cl = cl;
|
||||
}
|
||||
|
||||
@Override
|
||||
public URL getResource(String string)
|
||||
public URL getResource(final String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
@@ -341,17 +343,18 @@ public class Util
|
||||
}
|
||||
|
||||
@Override
|
||||
public InputStream getResourceAsStream(String string)
|
||||
public InputStream getResourceAsStream(final String string)
|
||||
{
|
||||
File file = new File(dataFolder, string);
|
||||
final File file = new File(dataFolder, string);
|
||||
if (file.exists())
|
||||
{
|
||||
BufferedReader br = null;
|
||||
try
|
||||
{
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
String version = br.readLine();
|
||||
br.close();
|
||||
if (version == null || !version.equals("#version: " + Essentials.getStatic().getDescription().getVersion()))
|
||||
br = new BufferedReader(new FileReader(file));
|
||||
final String version = br.readLine();
|
||||
|
||||
if (version == null || !version.equals("#version: " + ess.getDescription().getVersion()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s is not updated for Essentials version. Will use default.", file));
|
||||
return cl.getResourceAsStream(string);
|
||||
@@ -362,36 +365,49 @@ public class Util
|
||||
{
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (br != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
br.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return cl.getResourceAsStream(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Enumeration<URL> getResources(String string) throws IOException
|
||||
public Enumeration<URL> getResources(final String string) throws IOException
|
||||
{
|
||||
return cl.getResources(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<?> loadClass(String string) throws ClassNotFoundException
|
||||
public Class<?> loadClass(final String string) throws ClassNotFoundException
|
||||
{
|
||||
return cl.loadClass(string);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setClassAssertionStatus(String string, boolean bln)
|
||||
public synchronized void setClassAssertionStatus(final String string, final boolean bln)
|
||||
{
|
||||
cl.setClassAssertionStatus(string, bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setDefaultAssertionStatus(boolean bln)
|
||||
public synchronized void setDefaultAssertionStatus(final boolean bln)
|
||||
{
|
||||
cl.setDefaultAssertionStatus(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void setPackageAssertionStatus(String string, boolean bln)
|
||||
public synchronized void setPackageAssertionStatus(final String string, final boolean bln)
|
||||
{
|
||||
cl.setPackageAssertionStatus(string, bln);
|
||||
}
|
||||
@@ -420,7 +436,7 @@ public class Util
|
||||
return mf.format(objects);
|
||||
}
|
||||
|
||||
public static void updateLocale(String loc, File dataFolder)
|
||||
public static void updateLocale(String loc, IEssentials ess)
|
||||
{
|
||||
if (loc == null || loc.isEmpty())
|
||||
{
|
||||
@@ -440,10 +456,27 @@ public class Util
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
logger.log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(dataFolder, Util.class.getClassLoader()));
|
||||
bundle = ResourceBundle.getBundle("messages", currentLocale, new ConfigClassLoader(Util.class.getClassLoader(), ess));
|
||||
if (!bundle.keySet().containsAll(defaultBundle.keySet()))
|
||||
{
|
||||
logger.log(Level.WARNING, String.format("Translation file %s does not contain all translation keys.", currentLocale.toString()));
|
||||
}
|
||||
}
|
||||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
boolean first = true;
|
||||
for (Object each : list)
|
||||
{
|
||||
if (!first)
|
||||
{
|
||||
buf.append(", ");
|
||||
|
||||
}
|
||||
first = false;
|
||||
buf.append(each);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,15 @@
|
||||
package com.earth2me.essentials.api;
|
||||
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.EssentialsConf;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.UserData;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.io.File;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
/**
|
||||
* Instead of using this api directly, we recommend to use the register plugin:
|
||||
* http://bit.ly/RegisterMethod
|
||||
@@ -20,10 +20,19 @@ public final class Economy
|
||||
{
|
||||
}
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private static IEssentials ess;
|
||||
|
||||
/**
|
||||
* @param aEss the ess to set
|
||||
*/
|
||||
public static void setEss(IEssentials aEss)
|
||||
{
|
||||
ess = aEss;
|
||||
}
|
||||
|
||||
private static void createNPCFile(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -31,13 +40,13 @@ public final class Economy
|
||||
EssentialsConf npcConfig = new EssentialsConf(new File(folder, Util.sanitizeFileName(name) + ".yml"));
|
||||
npcConfig.load();
|
||||
npcConfig.setProperty("npc", true);
|
||||
npcConfig.setProperty("money", Essentials.getStatic().getSettings().getStartingBalance());
|
||||
npcConfig.setProperty("money", ess.getSettings().getStartingBalance());
|
||||
npcConfig.save();
|
||||
}
|
||||
|
||||
|
||||
private static void deleteNPC(String name)
|
||||
{
|
||||
File folder = new File(Essentials.getStatic().getDataFolder(), "userdata");
|
||||
File folder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!folder.exists())
|
||||
{
|
||||
folder.mkdirs();
|
||||
@@ -45,24 +54,27 @@ public final class Economy
|
||||
File config = new File(folder, Util.sanitizeFileName(name) + ".yml");
|
||||
EssentialsConf npcConfig = new EssentialsConf(config);
|
||||
npcConfig.load();
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false)) {
|
||||
if (!config.delete()) {
|
||||
if (npcConfig.hasProperty("npc") && npcConfig.getBoolean("npc", false))
|
||||
{
|
||||
if (!config.delete())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("deleteFileError", config));
|
||||
}
|
||||
ess.getAllUsers().remove(name.toLowerCase());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private static User getUserByName(String name)
|
||||
{
|
||||
User user;
|
||||
Player player = Essentials.getStatic().getServer().getPlayer(name);
|
||||
Player player = ess.getServer().getPlayer(name);
|
||||
if (player != null)
|
||||
{
|
||||
user = Essentials.getStatic().getUser(player);
|
||||
user = ess.getUser(player);
|
||||
}
|
||||
else
|
||||
{
|
||||
user = Essentials.getStatic().getOfflineUser(name);
|
||||
user = ess.getOfflineUser(name);
|
||||
}
|
||||
return user;
|
||||
}
|
||||
@@ -76,11 +88,11 @@ public final class Economy
|
||||
public static double getMoney(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
return ((UserData)user).getMoney();
|
||||
return user.getMoney();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,15 +105,15 @@ public final class Economy
|
||||
public static void setMoney(String name, double balance) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
// Use UserData to avoid calls to iConomy and Register
|
||||
((UserData)user).setMoney(balance);
|
||||
user.setMoney(balance);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +128,7 @@ public final class Economy
|
||||
double result = getMoney(name) + amount;
|
||||
setMoney(name, result);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Substracts money from the balance of a user
|
||||
* @param name Name of the user
|
||||
@@ -164,7 +176,7 @@ public final class Economy
|
||||
*/
|
||||
public static void resetBalance(String name) throws UserDoesNotExistException, NoLoanPermittedException
|
||||
{
|
||||
setMoney(name, Essentials.getStatic().getSettings().getStartingBalance());
|
||||
setMoney(name, ess.getSettings().getStartingBalance());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -219,18 +231,19 @@ public final class Economy
|
||||
*/
|
||||
public static String format(double amount)
|
||||
{
|
||||
return Util.formatCurrency(amount);
|
||||
return Util.formatCurrency(amount, ess);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player exists to avoid the UserDoesNotExistException
|
||||
* @param name Name of the user
|
||||
* @return true, if the user exists
|
||||
*/
|
||||
public static boolean playerExists(String name) {
|
||||
public static boolean playerExists(String name)
|
||||
{
|
||||
return getUserByName(name) != null;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Test if a player is a npc
|
||||
* @param name Name of the player
|
||||
@@ -240,12 +253,13 @@ public final class Economy
|
||||
public static boolean isNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
return user.isNPC();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Creates dummy files for a npc, if there is no player yet with that name.
|
||||
* @param name Name of the player
|
||||
@@ -254,7 +268,8 @@ public final class Economy
|
||||
public static boolean createNPC(String name)
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
createNPCFile(name);
|
||||
return true;
|
||||
}
|
||||
@@ -269,7 +284,8 @@ public final class Economy
|
||||
public static void removeNPC(String name) throws UserDoesNotExistException
|
||||
{
|
||||
User user = getUserByName(name);
|
||||
if (user == null) {
|
||||
if (user == null)
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
deleteNPC(name);
|
||||
|
@@ -17,11 +17,29 @@ public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
charge(user);
|
||||
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
if (afkUser != null)
|
||||
{
|
||||
toggleAfk(afkUser);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
toggleAfk(user);
|
||||
}
|
||||
}
|
||||
|
||||
private final void toggleAfk(User user)
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
|
@@ -1,12 +1,10 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.EntityTNTPrimed;
|
||||
import net.minecraft.server.World;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandantioch extends EssentialsCommand
|
||||
@@ -17,17 +15,13 @@ public class Commandantioch 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
|
||||
{
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user.getName(), "who being naughty in My sight, shall snuff it.");
|
||||
|
||||
Location loc = user.getLocation();
|
||||
World world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
EntityTNTPrimed tnt = new EntityTNTPrimed(world, loc.getBlockX(), loc.getBlockY(), loc.getBlockZ());
|
||||
world.addEntity(tnt);
|
||||
world.makeSound(tnt, "random.fuse", 1.0F, 1.0F);
|
||||
final Location loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -16,7 +16,7 @@ public class Commandback extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(Util.i18n("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
|
@@ -20,7 +20,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0).getMoney())));
|
||||
sender.sendMessage(Util.format("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,7 +31,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0)).getMoney();
|
||||
user.sendMessage(Util.format("balance", Util.formatCurrency(bal)));
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(Util.format("balance", Util.formatCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,67 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.util.Map.Entry;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
public Commandbalancetop()
|
||||
{
|
||||
super("balancetop");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
int max = 10;
|
||||
if (args.length > 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (Integer.parseInt(args[0]) < 10)
|
||||
{
|
||||
max = Integer.parseInt(args[0]);
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException ex)
|
||||
{
|
||||
//catch it because they tried to enter a string not number.
|
||||
}
|
||||
}
|
||||
final Map<User, Double> balances = new HashMap<User, Double>();
|
||||
for (User u : ess.getAllUsers().values())
|
||||
{
|
||||
balances.put(u, u.getMoney());
|
||||
}
|
||||
|
||||
final List<Map.Entry<User, Double>> sortedEntries = new ArrayList<Map.Entry<User, Double>>(balances.entrySet());
|
||||
Collections.sort(sortedEntries, new Comparator<Map.Entry<User, Double>>()
|
||||
{
|
||||
public int compare(final Entry<User, Double> entry1, final Entry<User, Double> entry2)
|
||||
{
|
||||
return -entry1.getValue().compareTo(entry2.getValue());
|
||||
}
|
||||
});
|
||||
int count = 0;
|
||||
sender.sendMessage(Util.format("balanceTop", max));
|
||||
for (Map.Entry<User, Double> entry : sortedEntries)
|
||||
{
|
||||
if (count == max)
|
||||
{
|
||||
break;
|
||||
}
|
||||
sender.sendMessage(entry.getKey().getDisplayName() + ", " + Util.formatCurrency(entry.getValue(), ess));
|
||||
count++;
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,10 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandban extends EssentialsCommand
|
||||
@@ -15,31 +16,43 @@ public class Commandban 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();
|
||||
}
|
||||
|
||||
User p = null;
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
final User player = getPlayer(server, args, 0, true);
|
||||
if (player.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
((CraftServer)server).getHandle().a(args[0]);
|
||||
sender.sendMessage(Util.format("playerBanned",args[0]));
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("banExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
p = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
String banReason = Util.i18n("defaultBanReason");
|
||||
if(args.length > 1) {
|
||||
banReason = getFinalArg(args, 1);
|
||||
p.setBanReason(commandLabel);
|
||||
if (player.isAuthorized("essentials.ban.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("banExempt"));
|
||||
return;
|
||||
}
|
||||
p.kickPlayer(banReason);
|
||||
((CraftServer)server).getHandle().a(p.getName());
|
||||
sender.sendMessage(Util.format("playerBanned", p.getName()));
|
||||
}
|
||||
ess.loadBanList();
|
||||
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
player.setBanReason(commandLabel);
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = Util.i18n("defaultBanReason");
|
||||
}
|
||||
player.kickPlayer(banReason);
|
||||
ess.getBans().banByName(player.getName());
|
||||
server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason));
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class Commandbanip extends EssentialsCommand
|
||||
@@ -21,9 +20,7 @@ public class Commandbanip extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
((CraftServer)server).getHandle().c(args[0]);
|
||||
ess.getBans().banByIp(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
ess.loadBanList();
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -17,7 +17,7 @@ public class Commandbigtree extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
TreeType tree = TreeType.TREE;
|
||||
TreeType tree;
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("redwood"))
|
||||
{
|
||||
tree = TreeType.TALL_REDWOOD;
|
||||
@@ -36,7 +36,7 @@ public class Commandbigtree extends EssentialsCommand
|
||||
double z = user.getLocation().getZ();
|
||||
|
||||
// offset tree in direction player is facing
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
final int r = (int)user.getCorrectedYaw();
|
||||
if (r < 68 || r > 292) // north
|
||||
{
|
||||
x -= 3.0D;
|
||||
@@ -54,8 +54,8 @@ public class Commandbigtree extends EssentialsCommand
|
||||
z += 3.0D;
|
||||
}
|
||||
|
||||
Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
|
||||
boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
|
@@ -6,7 +6,6 @@ import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class Commandclearinventory extends EssentialsCommand
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
|
||||
@@ -56,28 +55,24 @@ public class Commandeco extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player p : server.matchPlayer(args[1]))
|
||||
User u = getPlayer(server, args, 1, true);
|
||||
switch (cmd)
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
u.giveMoney(amount);
|
||||
break;
|
||||
case GIVE:
|
||||
u.giveMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
u.takeMoney(amount);
|
||||
break;
|
||||
case TAKE:
|
||||
u.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
case RESET:
|
||||
u.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum EcoCommands
|
||||
{
|
||||
GIVE, TAKE, RESET
|
||||
|
@@ -1,8 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandessentials extends EssentialsCommand
|
||||
@@ -11,12 +17,102 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
super("essentials");
|
||||
}
|
||||
private transient int taskid;
|
||||
private final transient Map<Player, Block> noteBlocks = new HashMap<Player, Block>();
|
||||
|
||||
@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
|
||||
{
|
||||
final Map<String, Byte> noteMap = new HashMap<String, Byte>();
|
||||
noteMap.put("1F#", (byte)0x0);
|
||||
noteMap.put("1G", (byte)0x1);
|
||||
noteMap.put("1G#", (byte)0x2);
|
||||
noteMap.put("1A", (byte)0x3);
|
||||
noteMap.put("1A#", (byte)0x4);
|
||||
noteMap.put("1B", (byte)0x5);
|
||||
noteMap.put("1C", (byte)0x6);
|
||||
noteMap.put("1C#", (byte)0x7);
|
||||
noteMap.put("1D", (byte)0x8);
|
||||
noteMap.put("1D#", (byte)0x9);
|
||||
noteMap.put("1E", (byte)0xA);
|
||||
noteMap.put("1F", (byte)0xB);
|
||||
noteMap.put("2F#", (byte)(0x0 + 0xC));
|
||||
noteMap.put("2G", (byte)(0x1 + 0xC));
|
||||
noteMap.put("2G#", (byte)(0x2 + 0xC));
|
||||
noteMap.put("2A", (byte)(0x3 + 0xC));
|
||||
noteMap.put("2A#", (byte)(0x4 + 0xC));
|
||||
noteMap.put("2B", (byte)(0x5 + 0xC));
|
||||
noteMap.put("2C", (byte)(0x6 + 0xC));
|
||||
noteMap.put("2C#", (byte)(0x7 + 0xC));
|
||||
noteMap.put("2D", (byte)(0x8 + 0xC));
|
||||
noteMap.put("2D#", (byte)(0x9 + 0xC));
|
||||
noteMap.put("2E", (byte)(0xA + 0xC));
|
||||
noteMap.put("2F", (byte)(0xB + 0xC));
|
||||
if (args.length > 0 && args[0].equalsIgnoreCase("nya"))
|
||||
{
|
||||
if (!noteBlocks.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
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();
|
||||
loc.add(0, 3, 0);
|
||||
while (loc.getBlockY() < player.getLocation().getBlockY() + 10 && loc.getBlock().getTypeId() != 0)
|
||||
{
|
||||
loc.add(0, 1, 0);
|
||||
}
|
||||
if (loc.getBlock().getTypeId() == 0)
|
||||
{
|
||||
noteBlocks.put(player, loc.getBlock());
|
||||
loc.getBlock().setType(Material.NOTE_BLOCK);
|
||||
}
|
||||
}
|
||||
taskid = ess.scheduleSyncRepeatingTask(new Runnable()
|
||||
{
|
||||
int i = 0;
|
||||
|
||||
public void run()
|
||||
{
|
||||
final String note = tune[i];
|
||||
i++;
|
||||
if (i >= tune.length)
|
||||
{
|
||||
Commandessentials.this.stopTune();
|
||||
}
|
||||
if (note.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
Map<Player, Block> noteBlocks = Commandessentials.this.noteBlocks;
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
Block block = noteBlocks.get(player);
|
||||
if (block == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
player.playNote(block.getLocation(), (byte)0, noteMap.get(note));
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
return;
|
||||
}
|
||||
ess.reload();
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
private void stopTune()
|
||||
{
|
||||
ess.getScheduler().cancelTask(taskid);
|
||||
for (Block block : noteBlocks.values())
|
||||
{
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
noteBlocks.clear();
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,24 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Fireball;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class Commandfireball extends EssentialsCommand
|
||||
{
|
||||
|
||||
public Commandfireball()
|
||||
{
|
||||
super("fireball");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
final Vector direction = user.getEyeLocation().getDirection().multiply(2);
|
||||
user.getWorld().spawn(user.getEyeLocation().add(direction.getX(), direction.getY(), direction.getZ()), Fireball.class);
|
||||
}
|
||||
}
|
@@ -18,7 +18,8 @@ public class Commandgc extends EssentialsCommand
|
||||
{
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcmin", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
for (World w : server.getWorlds())
|
||||
{
|
||||
sender.sendMessage(
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -25,7 +24,7 @@ public class Commandgive extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ItemStack stack = ItemDb.get(args[1]);
|
||||
ItemStack stack = ess.getItemDb().get(args[1]);
|
||||
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||
if (sender instanceof Player
|
||||
|
@@ -43,6 +43,10 @@ public class Commandgod extends EssentialsCommand
|
||||
for (Player p : server.matchPlayer(name))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
boolean enabled = u.toggleGodModeEnabled();
|
||||
u.sendMessage(Util.format("godMode", (enabled ? Util.i18n("enabled") : Util.i18n("disabled"))));
|
||||
sender.sendMessage(Util.format("godMode",Util.format(enabled ? "godEnabledFor": "godDisabledFor", p.getDisplayName())));
|
||||
|
@@ -53,13 +53,17 @@ public class Commandheal extends EssentialsCommand
|
||||
private void healOtherPlayers(Server server, CommandSender sender, String name)
|
||||
{
|
||||
List<Player> players = server.matchPlayer(name);
|
||||
if(players.isEmpty())
|
||||
if (players.isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
for (Player p : players)
|
||||
{
|
||||
if (ess.getUser(p).isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
p.setHealth(20);
|
||||
sender.sendMessage(Util.format("healOther", p.getDisplayName()));
|
||||
}
|
||||
|
@@ -30,24 +30,44 @@ public class Commandhelp extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
int page;
|
||||
int page = 1;
|
||||
String match = "";
|
||||
try
|
||||
{
|
||||
page = args.length > 0 ? Integer.parseInt(args[0]) : 1;
|
||||
if (args.length > 0)
|
||||
{
|
||||
match = args[0].toLowerCase();
|
||||
page = Integer.parseInt(args[args.length - 1]);
|
||||
if (args.length == 1)
|
||||
{
|
||||
match = "";
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
page = 1;
|
||||
if (args.length == 1)
|
||||
{
|
||||
match = args[0].toLowerCase();
|
||||
}
|
||||
}
|
||||
|
||||
List<String> lines = getHelpLines(user);
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
user.sendMessage(Util.format("helpPages", page, pages));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
List<String> lines = getHelpLines(user, match);
|
||||
if (lines.size() > 0)
|
||||
{
|
||||
user.sendMessage(lines.get(i));
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
user.sendMessage(Util.format("helpPages", page, pages));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
user.sendMessage(lines.get(i));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("noHelpFound"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,13 +78,13 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@SuppressWarnings("CallToThreadDumpStack")
|
||||
private List<String> getHelpLines(User user) throws Exception
|
||||
private List<String> getHelpLines(User user, String match) throws Exception
|
||||
{
|
||||
List<String> retval = new ArrayList<String>();
|
||||
File helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getName()) +".txt");
|
||||
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
helpFile = new File(ess.getDataFolder(), "help_"+Util.sanitizeFileName(user.getGroup()) +".txt");
|
||||
helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getGroup()) + ".txt");
|
||||
}
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
@@ -73,8 +93,9 @@ public class Commandhelp extends EssentialsCommand
|
||||
if (helpFile.exists())
|
||||
{
|
||||
final BufferedReader bufferedReader = new BufferedReader(new FileReader(helpFile));
|
||||
try {
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
while (bufferedReader.ready())
|
||||
{
|
||||
final String line = bufferedReader.readLine();
|
||||
@@ -98,6 +119,12 @@ public class Commandhelp extends EssentialsCommand
|
||||
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
||||
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
||||
{
|
||||
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match))
|
||||
&& (!k.getValue().get("description").toLowerCase().contains(match)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p.getDescription().getName().toLowerCase().contains("essentials"))
|
||||
{
|
||||
final String node = "essentials." + k.getKey();
|
||||
@@ -119,9 +146,19 @@ public class Commandhelp extends EssentialsCommand
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey("permissions") && value.get("permissions") != null && !(value.get("permissions").equals("")))
|
||||
{
|
||||
if (user.isAuthorized(value.get("permissions")))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
if (!ess.getSettings().hidePermissionlessHelp())
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
|
||||
|
||||
public class Commandhelpop extends EssentialsCommand
|
||||
@@ -22,6 +23,8 @@ public class Commandhelpop extends EssentialsCommand
|
||||
}
|
||||
|
||||
charge(user);
|
||||
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
@@ -29,7 +32,7 @@ public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
u.sendMessage(Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0)));
|
||||
u.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -16,7 +16,7 @@ public class Commandhome extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
|
||||
{
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -23,7 +21,7 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ItemStack stack = ItemDb.get(args[0]);
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||
if (ess.getSettings().permissionBasedItemSpawn()
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
@@ -36,7 +36,7 @@ public class Commandjump extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("jumpError"), ex);
|
||||
}
|
||||
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class Commandkick extends EssentialsCommand
|
||||
@@ -13,7 +12,7 @@ public class Commandkick extends EssentialsCommand
|
||||
{
|
||||
super("kick");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
@@ -21,19 +20,16 @@ public class Commandkick extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User u;
|
||||
try
|
||||
|
||||
User u = getPlayer(server, args, 0);
|
||||
if (u.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
u = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
sender.sendMessage(Util.i18n("kickExempt"));
|
||||
return;
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
u.kickPlayer(args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault"));
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
|
||||
u.kickPlayer(kickReason);
|
||||
server.broadcastMessage(Util.format("playerKicked", u.getName(), kickReason));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import java.util.Calendar;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -109,7 +109,7 @@ public class Commandkit extends EssentialsCommand
|
||||
items = (List<String>)kit;
|
||||
}
|
||||
|
||||
Charge charge = new Charge("kit-" + kitName, ess);
|
||||
Trade charge = new Trade("kit-" + kitName, ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -25,9 +24,33 @@ public class Commandlist extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
boolean showhidden = false;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
int playerHidden = 0;
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (ess.getUser(p).isHidden())
|
||||
{
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
charge(sender);
|
||||
StringBuilder online = new StringBuilder();
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length);
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
||||
if (showhidden && playerHidden > 0)
|
||||
{
|
||||
online.append(ChatColor.GRAY).append("/").append(playerHidden);
|
||||
}
|
||||
online.append(ChatColor.BLUE).append(" out of a maximum ").append(ChatColor.RED).append(server.getMaxPlayers());
|
||||
online.append(ChatColor.BLUE).append(" players online.");
|
||||
sender.sendMessage(online.toString());
|
||||
@@ -38,6 +61,10 @@ public class Commandlist extends EssentialsCommand
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String group = u.getGroup();
|
||||
List<User> list = sort.get(group);
|
||||
if (list == null)
|
||||
@@ -70,6 +97,10 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
groupString.append("§7[AFK]§f");
|
||||
}
|
||||
if (user.isHidden())
|
||||
{
|
||||
groupString.append("§7[HIDDEN]§f");
|
||||
}
|
||||
groupString.append(user.getDisplayName());
|
||||
}
|
||||
sender.sendMessage(groupString.toString());
|
||||
@@ -80,7 +111,12 @@ public class Commandlist extends EssentialsCommand
|
||||
List<User> users = new ArrayList<User>();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
users.add(ess.getUser(p));
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
users.add(u);
|
||||
}
|
||||
Collections.sort(users);
|
||||
|
||||
@@ -101,6 +137,10 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
onlineUsers.append("§7[AFK]§f");
|
||||
}
|
||||
if (user.isHidden())
|
||||
{
|
||||
onlineUsers.append("§7[HIDDEN]§f");
|
||||
}
|
||||
onlineUsers.append(user.getDisplayName());
|
||||
}
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
|
@@ -5,6 +5,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.IReplyTo;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -47,12 +48,28 @@ public class Commandmsg extends EssentialsCommand
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (Player p : matches)
|
||||
{
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i == matches.size())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : matches)
|
||||
{
|
||||
{
|
||||
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
|
||||
if (sender instanceof Player && ess.getUser(p).isIgnoredPlayer(((Player)sender).getName()))
|
||||
final User u = ess.getUser(p);
|
||||
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -1,42 +1,52 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commandmute extends EssentialsCommand
|
||||
{
|
||||
public Commandmute()
|
||||
{
|
||||
super("mute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0);
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
charge(sender);
|
||||
|
||||
|
||||
sender.sendMessage(
|
||||
p.toggleMuted()
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||
: Util.format("mutedPlayer", p.getDisplayName()))
|
||||
: Util.format("unmutedPlayer", p.getDisplayName()));
|
||||
}
|
||||
}
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commandmute extends EssentialsCommand
|
||||
{
|
||||
public Commandmute()
|
||||
{
|
||||
super("mute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0, true);
|
||||
if (!p.isMuted() && p.isAuthorized("essentials.mute.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("muteExempt"));
|
||||
return;
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
charge(sender);
|
||||
boolean muted = p.toggleMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||
: Util.format("mutedPlayer", p.getDisplayName()))
|
||||
: Util.format("unmutedPlayer", p.getDisplayName()));
|
||||
p.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
||||
: Util.i18n("playerMuted"))
|
||||
: Util.i18n("playerUnmuted"));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,58 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
|
||||
|
||||
public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
public Commandnuke()
|
||||
{
|
||||
super("nuke");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
List<Player> targets;
|
||||
if (args.length > 0)
|
||||
{
|
||||
targets = new ArrayList<Player>();
|
||||
int pos = 0;
|
||||
for (String arg : args)
|
||||
{
|
||||
targets.add(getPlayer(server, args, pos));
|
||||
pos++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
targets = Arrays.asList(server.getOnlinePlayers());
|
||||
}
|
||||
ess.getTNTListener().enable();
|
||||
for (Player player : targets)
|
||||
{
|
||||
if (player == null) {
|
||||
continue;
|
||||
}
|
||||
player.sendMessage("May death rain upon them");
|
||||
final Location loc = player.getLocation();
|
||||
final World world = loc.getWorld();
|
||||
for (int x = -10; x <= 10; x += 5)
|
||||
{
|
||||
for (int z = -10; z <= 10; z += 5)
|
||||
{
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -25,6 +25,10 @@ public class Commandpay extends EssentialsCommand
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
user.payUser(u, amount);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,7 @@ import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
||||
public class Commandrealname extends EssentialsCommand
|
||||
@@ -20,15 +21,19 @@ public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
String whois = args[0].toLowerCase();
|
||||
final String whois = args[0].toLowerCase();
|
||||
charge(user);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
String dn = u.getDisplayName().toLowerCase();
|
||||
if (!whois.equals(dn)
|
||||
&& !whois.equals(ess.getSettings().getNicknamePrefix() + dn)
|
||||
&& !whois.equals(u.getName().toLowerCase()))
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String displayName = ChatColor.stripColor(u.getDisplayName()).toLowerCase();
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(ChatColor.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !whois.equalsIgnoreCase(u.getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -1,9 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.InventoryWorkaround;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
@@ -68,7 +67,7 @@ public class Commandsell extends EssentialsCommand
|
||||
}
|
||||
if (is == null)
|
||||
{
|
||||
is = ItemDb.get(args[0]);
|
||||
is = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
sellItem(user, is, args, false);
|
||||
}
|
||||
@@ -151,11 +150,13 @@ public class Commandsell extends EssentialsCommand
|
||||
}
|
||||
|
||||
charge(user);
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, new ItemStack(is.getType(), amount, is.getDurability()));
|
||||
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);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount), amount, Util.formatCurrency(worth)));
|
||||
logger.log(Level.INFO, Util.format("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(), Util.formatCurrency(worth * amount), amount, Util.formatCurrency(worth)));
|
||||
user.sendMessage(Util.format("itemSold", Util.formatCurrency(worth * amount, ess), amount, 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)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -11,12 +11,35 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
super("sethome");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
user.setHome(args.length > 0 && args[0].equalsIgnoreCase("default"));
|
||||
if (args.length > 0)
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
user.setHome(args[0].equalsIgnoreCase("default"));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.others"))
|
||||
{
|
||||
User usersHome = ess.getUser(ess.getServer().getPlayer(args[0]));
|
||||
if(usersHome == null)
|
||||
{
|
||||
usersHome = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
usersHome.setHome(user.getLocation(), args[1].equalsIgnoreCase("default"));
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setHome(false);
|
||||
}
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("homeSet"));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
@@ -16,6 +15,7 @@ public class Commandsetjail extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
@@ -1,8 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -23,7 +21,7 @@ public class Commandsetworth extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ItemStack stack = ItemDb.get(args[0]);
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
charge(user);
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
|
||||
user.sendMessage(Util.i18n("worthSet"));
|
||||
|
@@ -5,7 +5,7 @@ import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.craftbukkit.block.CraftCreatureSpawner;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
|
||||
|
||||
@@ -19,12 +19,12 @@ public class Commandspawner extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
if (args.length < 1 || args[0].length() < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
Block target = user.getTarget().getTargetBlock();
|
||||
final Block target = user.getTarget().getTargetBlock();
|
||||
if (target.getType() != Material.MOB_SPAWNER)
|
||||
{
|
||||
throw new Exception(Util.i18n("mobSpawnTarget"));
|
||||
@@ -33,7 +33,8 @@ public class Commandspawner extends EssentialsCommand
|
||||
charge(user);
|
||||
try
|
||||
{
|
||||
((CreatureSpawner)target).setCreatureType(CreatureType.fromName(args[0]));
|
||||
final String name = args[0].substring(0, 1).toUpperCase() + args[0].substring(1).toLowerCase();
|
||||
new CraftCreatureSpawner(target).setCreatureType(CreatureType.fromName(name));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
|
@@ -1,10 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import net.minecraft.server.WorldServer;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.craftbukkit.entity.CraftEntity;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
@@ -15,11 +12,11 @@ import net.minecraft.server.PathEntity;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.craftbukkit.CraftWorld;
|
||||
import org.bukkit.craftbukkit.entity.CraftCreeper;
|
||||
import org.bukkit.craftbukkit.entity.CraftSheep;
|
||||
import org.bukkit.craftbukkit.entity.CraftSlime;
|
||||
import org.bukkit.craftbukkit.entity.CraftWolf;
|
||||
import org.bukkit.entity.Entity;
|
||||
|
||||
|
||||
public class Commandspawnmob extends EssentialsCommand
|
||||
@@ -61,10 +58,16 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
if (ess.getSettings().getProtectPreventSpawn(mobType.toLowerCase())
|
||||
|| (mountType != null && ess.getSettings().getProtectPreventSpawn(mountType.toLowerCase())))
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
|
||||
CraftEntity spawnedMob = null;
|
||||
Entity spawnedMob = null;
|
||||
Mob mob = null;
|
||||
CraftEntity spawnedMount = null;
|
||||
Entity spawnedMount = null;
|
||||
Mob mobMount = null;
|
||||
|
||||
mob = Mob.fromName(mobType);
|
||||
@@ -74,16 +77,6 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
charge(user);
|
||||
WorldServer world = ((CraftWorld)user.getWorld()).getHandle();
|
||||
try
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
int[] ignore =
|
||||
{
|
||||
8, 9
|
||||
@@ -96,8 +89,16 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
loc.setY(loc.getY() + 1);
|
||||
block = user.getWorld().getBlockAt(loc);
|
||||
}
|
||||
spawnedMob.teleportTo(loc);
|
||||
world.addEntity(spawnedMob.getHandle());
|
||||
|
||||
try
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
{
|
||||
@@ -109,16 +110,14 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server);
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
spawnedMount.teleportTo(spawnedMob);
|
||||
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
|
||||
world.addEntity(spawnedMount.getHandle());
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
if (mobData != null)
|
||||
{
|
||||
@@ -142,23 +141,19 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
for (int i = 1; i < mobCount; i++)
|
||||
{
|
||||
spawnedMob = mob.spawn(user, server);
|
||||
spawnedMob.teleportTo(loc);
|
||||
world.addEntity(spawnedMob.getHandle());
|
||||
spawnedMob = mob.spawn(user, server, loc);
|
||||
if (mobMount != null)
|
||||
{
|
||||
try
|
||||
{
|
||||
spawnedMount = mobMount.spawn(user, server);
|
||||
spawnedMount = mobMount.spawn(user, server, loc);
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
user.sendMessage(Util.i18n("unableToSpawnMob"));
|
||||
return;
|
||||
}
|
||||
spawnedMount.teleportTo(spawnedMob);
|
||||
spawnedMount.getHandle().setPassengerOf(spawnedMob.getHandle());
|
||||
world.addEntity(spawnedMount.getHandle());
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
if (mobData != null)
|
||||
{
|
||||
@@ -169,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
changeMobData(mobMount.name, spawnedMount, mountData, user);
|
||||
}
|
||||
}
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.s + Util.i18n("spawned"));
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase() + mob.suffix + Util.i18n("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
@@ -195,7 +190,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
|
||||
}
|
||||
|
||||
private void changeMobData(String type, CraftEntity spawned, String data, User user) throws Exception
|
||||
private void changeMobData(String type, Entity spawned, String data, User user) throws Exception
|
||||
{
|
||||
if ("Slime".equalsIgnoreCase(type))
|
||||
{
|
||||
@@ -222,18 +217,19 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("tamed"))
|
||||
{
|
||||
EntityWolf wolf = ((CraftWolf)spawned).getHandle();
|
||||
wolf.d(true);
|
||||
wolf.a((PathEntity)null);
|
||||
wolf.setTamed(true);
|
||||
wolf.setPathEntity((PathEntity)null);
|
||||
wolf.setSitting(true);
|
||||
wolf.health = 20;
|
||||
wolf.a(user.getName());
|
||||
wolf.setOwnerName(user.getName());
|
||||
wolf.world.a(wolf, (byte)7);
|
||||
}
|
||||
if ("Wolf".equalsIgnoreCase(type) && data.equalsIgnoreCase("angry"))
|
||||
{
|
||||
((CraftWolf)spawned).setAngry(true);
|
||||
}
|
||||
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered")) {
|
||||
if ("Creeper".equalsIgnoreCase(type) && data.equalsIgnoreCase("powered"))
|
||||
{
|
||||
((CraftCreeper)spawned).setPowered(true);
|
||||
}
|
||||
}
|
||||
|
@@ -1,11 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandtempban extends EssentialsCommand
|
||||
@@ -16,37 +16,38 @@ public class Commandtempban 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 < 2)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = null;
|
||||
try
|
||||
final User player = getPlayer(server, args, 0, true);
|
||||
if (player.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
p = getPlayer(server, args, 0);
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("tempbanExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException ex)
|
||||
else
|
||||
{
|
||||
p = ess.getOfflineUser(args[0]);
|
||||
}
|
||||
if (p == null)
|
||||
{
|
||||
sender.sendMessage(Util.format("playerNotFound"));
|
||||
if (player.isAuthorized("essentials.tempban.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("tempbanExempt"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
final String time = getFinalArg(args, 1);
|
||||
final long banTimestamp = Util.parseDateDiff(time, true);
|
||||
|
||||
String time = getFinalArg(args, 1);
|
||||
long banTimestamp = Util.parseDateDiff(time, true);
|
||||
|
||||
p = ess.getUser(server.matchPlayer(args[0]).get(0));
|
||||
String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
|
||||
p.setBanReason(banReason);
|
||||
p.setBanTimeout(banTimestamp);
|
||||
p.kickPlayer(banReason);
|
||||
((CraftServer)server).getHandle().a(p.getName());
|
||||
sender.sendMessage(Util.format("playerBanned", p.getName()));
|
||||
Essentials.getStatic().loadBanList();
|
||||
final String banReason = Util.format("tempBanned", Util.formatDateDiff(banTimestamp));
|
||||
player.setBanReason(banReason);
|
||||
player.setBanTimeout(banTimestamp);
|
||||
player.kickPlayer(banReason);
|
||||
ess.getBans().banByName(player.getName());
|
||||
server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason));
|
||||
}
|
||||
}
|
||||
|
@@ -15,37 +15,65 @@ public class Commandtime 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();
|
||||
}
|
||||
World world = user.getWorld();
|
||||
if (args.length < 2)
|
||||
{
|
||||
if (user.isAuthorized("essentials.time.world"))
|
||||
{
|
||||
final World world = user.getWorld();
|
||||
|
||||
charge(user);
|
||||
setWorldTime(world, args[0]);
|
||||
charge(user);
|
||||
setWorldTime(world, args[0]);
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
setPlayerTime(user, args[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.isAuthorized("essentials.time.others"))
|
||||
{
|
||||
User u = getPlayer(server, args, 1);
|
||||
charge(user);
|
||||
setPlayerTime(u, 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 < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
for (World world : server.getWorlds())
|
||||
if (args.length < 2)
|
||||
{
|
||||
setWorldTime(world, args[0]);
|
||||
for (World world : server.getWorlds())
|
||||
{
|
||||
setWorldTime(world, args[0]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
User u = getPlayer(server, args, 1);
|
||||
setPlayerTime(u, args[0]);
|
||||
}
|
||||
|
||||
sender.sendMessage(Util.i18n("timeSet"));
|
||||
}
|
||||
|
||||
private void setWorldTime(World world, String timeString) throws Exception
|
||||
private void setWorldTime(final World world, final String timeString) throws Exception
|
||||
{
|
||||
long time = world.getTime();
|
||||
time = time - time % 24000;
|
||||
time -= time % 24000;
|
||||
if ("day".equalsIgnoreCase(timeString))
|
||||
{
|
||||
world.setTime(time + 24000);
|
||||
@@ -58,4 +86,28 @@ public class Commandtime extends EssentialsCommand
|
||||
}
|
||||
throw new Exception(Util.i18n("onlyDayNight"));
|
||||
}
|
||||
|
||||
private void setPlayerTime(final User user, final String timeString) throws Exception
|
||||
{
|
||||
long time = user.getPlayerTime();
|
||||
time -= time % 24000;
|
||||
if ("day".equalsIgnoreCase(timeString))
|
||||
{
|
||||
final World world = user.getWorld();
|
||||
user.setPlayerTime(time + 24000 - world.getTime(), true);
|
||||
return;
|
||||
}
|
||||
if ("night".equalsIgnoreCase(timeString))
|
||||
{
|
||||
final World world = user.getWorld();
|
||||
user.setPlayerTime(time + 37700 - world.getTime(), true);
|
||||
return;
|
||||
}
|
||||
if ("reset".equalsIgnoreCase(timeString))
|
||||
{
|
||||
user.resetPlayerTime();
|
||||
return;
|
||||
}
|
||||
throw new Exception(Util.i18n("onlyDayNight"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandtogglejail extends EssentialsCommand
|
||||
@@ -22,21 +23,40 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0);
|
||||
|
||||
if (p.isAuthorized("essentials.jail.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("mayNotJail"));
|
||||
return;
|
||||
}
|
||||
User p = getPlayer(server, args, 0, true);
|
||||
|
||||
if (args.length >= 2 && !p.isJailed())
|
||||
{
|
||||
if (p.getBase() instanceof OfflinePlayer)
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("mayNotJail"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (p.isAuthorized("essentials.jail.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("mayNotJail"));
|
||||
return;
|
||||
}
|
||||
}
|
||||
charge(sender);
|
||||
p.setJailed(true);
|
||||
p.sendMessage(Util.i18n("userJailed"));
|
||||
p.setJail(null);
|
||||
ess.getJail().sendToJail(p, args[1]);
|
||||
if (!(p.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
ess.getJail().sendToJail(p, args[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Check if jail exists
|
||||
ess.getJail().getJail(args[1]);
|
||||
}
|
||||
p.setJail(args[1]);
|
||||
long timeDiff = 0;
|
||||
if (args.length > 2)
|
||||
@@ -57,7 +77,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
if (args.length >= 2 && p.isJailed() && !args[1].equalsIgnoreCase(p.getJail()))
|
||||
if (args.length >= 2 && p.isJailed() && args[1].equalsIgnoreCase(p.getJail()))
|
||||
{
|
||||
String time = getFinalArg(args, 2);
|
||||
long timeDiff = Util.parseDateDiff(time, true);
|
||||
@@ -76,7 +96,10 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
p.setJailTimeout(0);
|
||||
p.sendMessage("§7You have been released");
|
||||
p.setJail(null);
|
||||
p.getTeleport().back();
|
||||
if (!(p.getBase() instanceof OfflinePlayer))
|
||||
{
|
||||
p.getTeleport().back();
|
||||
}
|
||||
sender.sendMessage("§7Player " + p.getName() + " unjailed.");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -21,7 +21,7 @@ public class Commandtop extends EssentialsCommand
|
||||
int topZ = user.getLocation().getBlockZ();
|
||||
int topY = user.getWorld().getHighestBlockYAt(topX, topZ);
|
||||
charge(user);
|
||||
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Charge(this.getName(), ess));
|
||||
user.getTeleport().teleport(new Location(user.getWorld(), user.getLocation().getX(), topY + 1, user.getLocation().getZ()), new Trade(this.getName(), ess));
|
||||
user.sendMessage(Util.i18n("teleportTop"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.Console;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -30,7 +30,7 @@ public class Commandtp extends EssentialsCommand
|
||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
||||
}
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(p, charge);
|
||||
break;
|
||||
@@ -44,7 +44,7 @@ public class Commandtp extends EssentialsCommand
|
||||
charge(user);
|
||||
User target = getPlayer(server, args, 0);
|
||||
User toPlayer = getPlayer(server, args, 1);
|
||||
target.getTeleport().now(toPlayer);
|
||||
target.getTeleport().now(toPlayer, false);
|
||||
target.sendMessage(Util.format("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
||||
break;
|
||||
}
|
||||
@@ -61,7 +61,7 @@ public class Commandtp extends EssentialsCommand
|
||||
sender.sendMessage(Util.i18n("teleporting"));
|
||||
User target = getPlayer(server, args, 0);
|
||||
User toPlayer = getPlayer(server, args, 1);
|
||||
target.getTeleport().now(toPlayer);
|
||||
target.getTeleport().now(toPlayer, false);
|
||||
target.sendMessage(Util.format("teleportAtoB", Console.NAME, toPlayer.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -23,7 +23,7 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
throw new Exception(Util.i18n("noPendingRequest"));
|
||||
}
|
||||
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
if (user.isTeleportRequestHere())
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@@ -46,15 +45,11 @@ public class Commandtpall extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
u.getTeleport().now(p);
|
||||
u.getTeleport().now(p, false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage(Util.format("errorWithMessage", ex.getMessage()));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.WARNING, ex.getMessage(), ex);
|
||||
}
|
||||
ess.showError(sender, ex, getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -21,7 +21,7 @@ public class Commandtphere extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(Util.format("teleportDisabled", p.getDisplayName()));
|
||||
}
|
||||
p.getTeleport().teleport(user, new Charge(this.getName(), ess));
|
||||
p.getTeleport().teleport(user, new Trade(this.getName(), ess));
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
p.sendMessage(Util.i18n("teleporting"));
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ public class Commandtpo extends EssentialsCommand
|
||||
//Just basically the old tp command
|
||||
User p = getPlayer(server, args, 0);
|
||||
charge(user);
|
||||
user.getTeleport().now(p);
|
||||
user.getTeleport().now(p, false);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
}
|
||||
}
|
||||
|
@@ -23,7 +23,7 @@ public class Commandtpohere extends EssentialsCommand
|
||||
//Just basically the old tphere command
|
||||
User p = getPlayer(server, args, 0);
|
||||
charge(user);
|
||||
p.getTeleport().now(user);
|
||||
p.getTeleport().now(user, false);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -26,7 +26,7 @@ public class Commandtppos extends EssentialsCommand
|
||||
int y = Integer.parseInt(args[1]);
|
||||
int z = Integer.parseInt(args[2]);
|
||||
Location l = new Location(user.getWorld(), x, y, z);
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(Util.i18n("teleporting"));
|
||||
user.getTeleport().teleport(l, charge);
|
||||
|
@@ -1,9 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class Commandunban extends EssentialsCommand
|
||||
@@ -14,15 +14,15 @@ public class Commandunban 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();
|
||||
}
|
||||
|
||||
((CraftServer)server).getHandle().b(args[0]);
|
||||
User u = getPlayer(server, args, 0, true);
|
||||
ess.getBans().unbanByName(u.getName());
|
||||
sender.sendMessage(Util.i18n("unbannedPlayer"));
|
||||
ess.loadBanList();
|
||||
}
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
|
||||
public class Commandunbanip extends EssentialsCommand
|
||||
@@ -14,15 +13,14 @@ public class Commandunbanip 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();
|
||||
}
|
||||
|
||||
((CraftServer)server).getHandle().d(args[0]);
|
||||
ess.getBans().unbanByIp(args[0]);
|
||||
sender.sendMessage(Util.i18n("unbannedIP"));
|
||||
ess.loadBanList();
|
||||
}
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.InventoryWorkaround;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
@@ -56,7 +55,8 @@ public class Commandunlimited extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
|
||||
ItemStack stack = ItemDb.get(args[0], 1);
|
||||
final ItemStack stack = ess.getItemDb().get(args[0], 1);
|
||||
stack.setAmount(stack.getType().getMaxStackSize());
|
||||
|
||||
String itemname = stack.getType().toString().toLowerCase().replace("_", "");
|
||||
if (!user.isAuthorized("essentials.unlimited.item-all")
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -73,7 +73,7 @@ public class Commandwarp extends EssentialsCommand
|
||||
|
||||
private void warpUser(User user, String name) throws Exception
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
if (ess.getSettings().getPerWarpPermission())
|
||||
{
|
||||
|
@@ -22,12 +22,28 @@ public class Commandwhois extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
boolean showhidden = false;
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
if (ess.getUser(sender).isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
showhidden = true;
|
||||
}
|
||||
String whois = args[0].toLowerCase();
|
||||
charge(sender);
|
||||
int prefixLength = ChatColor.stripColor(ess.getSettings().getNicknamePrefix()).length();
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if (u.isHidden() && !showhidden)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String dn = ChatColor.stripColor(u.getNick());
|
||||
if (!whois.equalsIgnoreCase(dn)
|
||||
&& !whois.equalsIgnoreCase(dn.substring(prefixLength))
|
||||
@@ -41,7 +57,7 @@ public class Commandwhois extends EssentialsCommand
|
||||
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())));
|
||||
sender.sendMessage(Util.format("whoisMoney", Util.formatCurrency(u.getMoney(), ess)));
|
||||
}
|
||||
sender.sendMessage(u.isAfk()
|
||||
? Util.i18n("whoisStatusAway")
|
||||
|
@@ -1,6 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import java.util.List;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
@@ -68,7 +68,7 @@ public class Commandworld extends EssentialsCommand
|
||||
Location loc = user.getLocation();
|
||||
loc = new Location(world, loc.getBlockX() * factor + .5, loc.getBlockY(), loc.getBlockZ() * factor + .5);
|
||||
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge);
|
||||
}
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.ItemDb;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -22,7 +21,7 @@ public class Commandworth extends EssentialsCommand
|
||||
|
||||
if (args.length > 0)
|
||||
{
|
||||
is = ItemDb.get(args[0]);
|
||||
is = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
|
||||
try
|
||||
@@ -49,13 +48,13 @@ public class Commandworth extends EssentialsCommand
|
||||
? Util.format("worthMeta",
|
||||
is.getType().toString().toLowerCase().replace("_", ""),
|
||||
is.getDurability(),
|
||||
Util.formatCurrency(worth * amount),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth))
|
||||
Util.formatCurrency(worth, ess))
|
||||
: Util.format("worth",
|
||||
is.getType().toString().toLowerCase().replace("_", ""),
|
||||
Util.formatCurrency(worth * amount),
|
||||
Util.formatCurrency(worth * amount, ess),
|
||||
amount,
|
||||
Util.formatCurrency(worth)));
|
||||
Util.formatCurrency(worth, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Charge;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import java.util.List;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.IEssentials;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
@@ -23,7 +23,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
{
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
|
||||
public void setEssentials(IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
@@ -35,18 +35,46 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
}
|
||||
|
||||
protected User getPlayer(Server server, String[] args, int pos) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
return getPlayer(server, args, pos, false);
|
||||
}
|
||||
|
||||
protected User getPlayer(Server server, String[] args, int pos, boolean getOffline) throws NoSuchFieldException, NotEnoughArgumentsException
|
||||
{
|
||||
if (args.length <= pos) throw new NotEnoughArgumentsException();
|
||||
User user = ess.getAllUsers().get(args[pos].toLowerCase());
|
||||
if (user != null)
|
||||
{
|
||||
if(!getOffline && (user.getBase() instanceof OfflinePlayer || user.isHidden()))
|
||||
{
|
||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
}
|
||||
return user;
|
||||
}
|
||||
List<Player> matches = server.matchPlayer(args[pos]);
|
||||
if (matches.size() < 1) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
|
||||
if (matches.size() < 1)
|
||||
{
|
||||
if (!getOffline) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
User u = ess.getOfflineUser(args[pos]);
|
||||
if (u == null) throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
return u;
|
||||
}
|
||||
|
||||
for (Player p : matches)
|
||||
{
|
||||
if (p.getDisplayName().startsWith(args[pos]))
|
||||
final User u = ess.getUser(p);
|
||||
if (u.getDisplayName().startsWith(args[pos]) && (getOffline || !u.isHidden()))
|
||||
{
|
||||
return ess.getUser(p);
|
||||
return u;
|
||||
}
|
||||
}
|
||||
return ess.getUser(matches.get(0));
|
||||
final User u = ess.getUser(matches.get(0));
|
||||
if (!getOffline && u.isHidden())
|
||||
{
|
||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
}
|
||||
return u;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -89,7 +117,7 @@ public abstract class EssentialsCommand implements IEssentialsCommand
|
||||
{
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
Charge charge = new Charge(this.getName(), ess);
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.charge(ess.getUser((Player)sender));
|
||||
}
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials.register.payment;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
/***
|
||||
/**
|
||||
* Methods.java
|
||||
* Controls the getting / setting of methods & the method of payment used.
|
||||
*
|
||||
@@ -17,18 +17,36 @@ import org.bukkit.plugin.PluginManager;
|
||||
public class Methods {
|
||||
private boolean self = false;
|
||||
private Method Method = null;
|
||||
private String preferred = "";
|
||||
private String preferred = "";
|
||||
private Set<Method> Methods = new HashSet<Method>();
|
||||
private Set<String> Dependencies = new HashSet<String>();
|
||||
private Set<Method> Attachables = new HashSet<Method>();
|
||||
private Set<Method> Attachables = new HashSet<Method>();
|
||||
|
||||
public Methods() {
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE());
|
||||
this._init();
|
||||
}
|
||||
|
||||
public Set<String> getDependencies() {
|
||||
/**
|
||||
* Allows you to set which economy plugin is most preferred.
|
||||
*
|
||||
* @param preferred - preferred economy plugin
|
||||
*/
|
||||
public Methods(String preferred) {
|
||||
this._init();
|
||||
|
||||
if(this.Dependencies.contains(preferred)) {
|
||||
this.preferred = preferred;
|
||||
}
|
||||
}
|
||||
|
||||
private void _init() {
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo4());
|
||||
this.addMethod("iConomy", new com.earth2me.essentials.register.payment.methods.iCo5());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE6());
|
||||
this.addMethod("BOSEconomy", new com.earth2me.essentials.register.payment.methods.BOSE7());
|
||||
}
|
||||
|
||||
public Set<String> getDependencies() {
|
||||
return Dependencies;
|
||||
}
|
||||
|
||||
@@ -58,7 +76,7 @@ public class Methods {
|
||||
|
||||
int count = 0;
|
||||
boolean match = false;
|
||||
Plugin plugin = null;
|
||||
Plugin plugin;
|
||||
PluginManager manager = method.getServer().getPluginManager();
|
||||
|
||||
for(String name: this.getDependencies()) {
|
||||
@@ -66,13 +84,6 @@ public class Methods {
|
||||
if(method.getDescription().getName().equals(name)) plugin = method; else plugin = manager.getPlugin(name);
|
||||
if(plugin == null) continue;
|
||||
|
||||
if(!plugin.isEnabled()) {
|
||||
this.self = true;
|
||||
manager.enablePlugin(plugin);
|
||||
}
|
||||
|
||||
if(plugin == null) continue;
|
||||
|
||||
Method current = this.createMethod(plugin);
|
||||
if(current == null) continue;
|
||||
|
||||
@@ -83,7 +94,7 @@ public class Methods {
|
||||
}
|
||||
}
|
||||
|
||||
if(!this.preferred.isEmpty()) {
|
||||
if(!this.preferred.isEmpty()) {
|
||||
do {
|
||||
if(hasMethod()) {
|
||||
match = true;
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user