mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-06 12:40:45 +02:00
Compare commits
342 Commits
stable-2.5
...
stable-2.6
Author | SHA1 | Date | |
---|---|---|---|
|
066f3fd726 | ||
|
e9c0bb2133 | ||
|
f0acf733a5 | ||
|
33c6fc1f1f | ||
|
91b504cc66 | ||
|
6ea57bcd2f | ||
|
c92c066a3a | ||
|
caff3c115b | ||
|
517961b26a | ||
|
85f63d0afe | ||
|
ecc56351ec | ||
|
9b04705ec9 | ||
|
e786653364 | ||
|
e5613d43cc | ||
|
ce8f05cd94 | ||
|
e52a9c1f6b | ||
|
de744fe9e2 | ||
|
a0031d1d45 | ||
|
d60dd01f0f | ||
|
ad3bc2ad98 | ||
|
cf69a6d72c | ||
|
1a65a31a7e | ||
|
9c998eac2f | ||
|
2bdc00dc14 | ||
|
83e8dac6a0 | ||
|
3879d582d3 | ||
|
1fd5222d40 | ||
|
fe15bab05f | ||
|
f2dd51cf57 | ||
|
ac1f2badc7 | ||
|
d3f6e82474 | ||
|
676f941bb8 | ||
|
bd74bd1286 | ||
|
5831cde90e | ||
|
b2394048fa | ||
|
4811e46dd6 | ||
|
8d266a3440 | ||
|
f680fb1b76 | ||
|
a845f351f8 | ||
|
997a409b5a | ||
|
a6673c5157 | ||
|
5ef7135fc8 | ||
|
4c698762c3 | ||
|
82e389be8f | ||
|
1df79bc9f4 | ||
|
ab590af927 | ||
|
002e4a2772 | ||
|
0e9b971280 | ||
|
73b5fe971f | ||
|
6398626559 | ||
|
828f97c9a8 | ||
|
d6d4752383 | ||
|
d2bf35dac2 | ||
|
8d6e3e7c18 | ||
|
0b057d8e29 | ||
|
4c6cc5ced0 | ||
|
b828222176 | ||
|
bbab993ef1 | ||
|
b110ce79cc | ||
|
ab530f35d0 | ||
|
0654a76ccc | ||
|
e8fbdef38b | ||
|
96c4dd2ab9 | ||
|
998d097d7d | ||
|
df3b9a7ef9 | ||
|
fd6f768cca | ||
|
aa085de3e7 | ||
|
2e1c880502 | ||
|
e3756623a1 | ||
|
8f28073b29 | ||
|
e2024ca2b6 | ||
|
80491513a2 | ||
|
f67e13122d | ||
|
16e19a7775 | ||
|
a220b267d4 | ||
|
1153a0eee4 | ||
|
7d8b0c102c | ||
|
4abbbcb82b | ||
|
248e4e2ae2 | ||
|
fb211d722c | ||
|
1b3698283e | ||
|
cccddc3311 | ||
|
70a3a5919e | ||
|
fc7a3e091d | ||
|
f6b4daebb5 | ||
|
688d37ee60 | ||
|
382bd24046 | ||
|
e0d913dbaf | ||
|
bb1cad1bc1 | ||
|
d7af679243 | ||
|
c8f6ea7f8e | ||
|
d3dd4980a4 | ||
|
b140f606b4 | ||
|
057c9cb3f5 | ||
|
3dcf8bc8fc | ||
|
ecc1a0acea | ||
|
afb951461c | ||
|
e9a14b204f | ||
|
1cbdbc40a5 | ||
|
5d4aa95fc3 | ||
|
17e11adf9a | ||
|
3454db3e2b | ||
|
7039d613ee | ||
|
12e3eb1a23 | ||
|
a60f040f7e | ||
|
22c277f9ab | ||
|
fa423b3dd2 | ||
|
0c37e091c0 | ||
|
3dd3fa4519 | ||
|
b559809bfa | ||
|
59e45592cf | ||
|
1fb57cb678 | ||
|
fba4dd2d9a | ||
|
3ec0dbd404 | ||
|
5a5dc933ad | ||
|
6427a93d14 | ||
|
610a713997 | ||
|
347be03b25 | ||
|
322ecdb9fc | ||
|
033babd586 | ||
|
d3302dea00 | ||
|
8249a961f6 | ||
|
41344ce1b0 | ||
|
65be2dba99 | ||
|
087e600d6d | ||
|
f18c3c7e1d | ||
|
394a786044 | ||
|
14030deb16 | ||
|
0543a8f8ba | ||
|
34987d6e07 | ||
|
631583aef0 | ||
|
8998168ec2 | ||
|
00050d08d4 | ||
|
aa47499656 | ||
|
bc93bc6ae7 | ||
|
dfd283d998 | ||
|
016dd10060 | ||
|
8281908306 | ||
|
01861e5a64 | ||
|
3d913f9fcc | ||
|
6c738294d1 | ||
|
30f0f78efc | ||
|
8cc249c2d3 | ||
|
6946488e0d | ||
|
53a73998a2 | ||
|
f12a14d7f7 | ||
|
089c2210bd | ||
|
1a2fc307fd | ||
|
38aa85dd0c | ||
|
c374f474ed | ||
|
2a1b19a8a8 | ||
|
325889c466 | ||
|
216cc7f681 | ||
|
7df5098bf6 | ||
|
27adc21446 | ||
|
5de354af86 | ||
|
bb32ec9567 | ||
|
6ee7017603 | ||
|
9dc54340f8 | ||
|
0592c1fe11 | ||
|
90419cdbf5 | ||
|
91393e3180 | ||
|
dfdf49ac35 | ||
|
d2a3240905 | ||
|
1138e32292 | ||
|
256c963370 | ||
|
d818f705ad | ||
|
1ac033a60e | ||
|
af248a1d2e | ||
|
c0d21b6044 | ||
|
e10675dfdc | ||
|
7b8c2a4575 | ||
|
812a357361 | ||
|
ac20207ea1 | ||
|
43d7fb367b | ||
|
040e2bee86 | ||
|
6f88e7bb98 | ||
|
45f88016fc | ||
|
5a1ea77019 | ||
|
83fc7de01a | ||
|
d14f278ecf | ||
|
69b76b810c | ||
|
2c787e07ec | ||
|
3e9b27e3ef | ||
|
4bc3d5efad | ||
|
9791dcc0bc | ||
|
84068c18b1 | ||
|
a32b55e28f | ||
|
8d1262fc91 | ||
|
a2f727bebc | ||
|
7f1ba0d6ae | ||
|
2b48045a8f | ||
|
7e5b79aa14 | ||
|
a53d8ddef1 | ||
|
2690696712 | ||
|
086343ee48 | ||
|
c79ac59bc0 | ||
|
a1ad512a80 | ||
|
6a9865cd67 | ||
|
5d95d1fca6 | ||
|
2541efb682 | ||
|
8ff405f2fe | ||
|
376d206d2b | ||
|
6295127589 | ||
|
1c381fc203 | ||
|
b93d289176 | ||
|
a2fa666fd5 | ||
|
76eb00575b | ||
|
81d7be4f77 | ||
|
b776362be7 | ||
|
65df249510 | ||
|
6fa2b14d65 | ||
|
6ec674d0a3 | ||
|
93883cfc12 | ||
|
2e565f8881 | ||
|
b851cd10f2 | ||
|
576b48c08c | ||
|
5ca9927987 | ||
|
a753f322df | ||
|
300ee9c729 | ||
|
1fbed62c1d | ||
|
a21d80ecd8 | ||
|
1e7bf9a46c | ||
|
19595c5847 | ||
|
47c8217511 | ||
|
db50d455df | ||
|
ec5746dbe6 | ||
|
05ba5c00e6 | ||
|
bb2b504d7a | ||
|
5bb86309f6 | ||
|
abbeb0a212 | ||
|
d9d781a33a | ||
|
327c15c5be | ||
|
858e2a8b89 | ||
|
33d37a2f96 | ||
|
a8f6014a42 | ||
|
a117080b32 | ||
|
f75390bd3f | ||
|
b07ba21659 | ||
|
a109134b92 | ||
|
69d3921a6a | ||
|
ca3369938d | ||
|
fbd9ee9453 | ||
|
8185b05b5d | ||
|
b9fc6a0b2b | ||
|
62ebf3db41 | ||
|
a90b16be36 | ||
|
d07ecde47d | ||
|
5db35458e8 | ||
|
cf4752dad6 | ||
|
a085503c84 | ||
|
9a893f65fe | ||
|
cc273e919c | ||
|
65702ea0bf | ||
|
614b7b84f7 | ||
|
a04e0533d6 | ||
|
b85a5e9e0d | ||
|
bb6b2c9374 | ||
|
df47aad478 | ||
|
9eb73cf854 | ||
|
12777af61a | ||
|
acb50786c4 | ||
|
33f48eae0d | ||
|
7b18343e75 | ||
|
9bb2ef9cbe | ||
|
beb34a7651 | ||
|
0ac26265e2 | ||
|
d6dc6d1d39 | ||
|
0ab8a2760d | ||
|
8bb4067f06 | ||
|
fe1820134b | ||
|
7d7c686e6a | ||
|
0b681c3654 | ||
|
23eeb82ac4 | ||
|
edd6adc78f | ||
|
c9028623ac | ||
|
dd5bcb8762 | ||
|
bc1c252dca | ||
|
19ba6e5195 | ||
|
864e608582 | ||
|
b84785cc82 | ||
|
832910d480 | ||
|
164541794e | ||
|
13da2b2924 | ||
|
84ac520353 | ||
|
7aea9e71e8 | ||
|
5613975314 | ||
|
dc0ca35017 | ||
|
662d30ae45 | ||
|
4099755b9b | ||
|
57bee443b1 | ||
|
0f3c0e82f2 | ||
|
0e21d3287e | ||
|
3cedfeef2c | ||
|
a20f2b71da | ||
|
b2e3290038 | ||
|
979592c8ba | ||
|
7001798874 | ||
|
40a2bccf2d | ||
|
ee13d33b66 | ||
|
fdb46f60fd | ||
|
5027198010 | ||
|
90a5a4a470 | ||
|
85cab9533e | ||
|
304b13ca5e | ||
|
6a1c53dd01 | ||
|
d7b2ac97aa | ||
|
7b7289db4c | ||
|
ba2b827d7c | ||
|
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 |
8
.classpath
Normal file
8
.classpath
Normal file
@@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="src" path="src"/>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/>
|
||||
<classpathentry kind="lib" path="lib/bukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/craftbukkit-0.0.1-SNAPSHOT.jar"/>
|
||||
<classpathentry kind="lib" path="lib/Permissions3.jar"/>
|
||||
</classpath>
|
9
.gitignore
vendored
9
.gitignore
vendored
@@ -25,4 +25,11 @@
|
||||
/EssentialsProtect/build/
|
||||
/EssentialsPermissionsCommands/nbproject/private/
|
||||
/EssentialsPermissionsCommands/build/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/EssentialsPermissionsCommands/dist/
|
||||
/Essentials/nbproject/private/
|
||||
/Essentials/dist/
|
||||
/Essentials/build/
|
||||
/YamlAnnotations/
|
||||
/EssentialsUpdate/nbproject/private/
|
||||
/EssentialsRelease/
|
||||
/EssentialsUpdate/
|
17
.project
Normal file
17
.project
Normal file
@@ -0,0 +1,17 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Essentials</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
@@ -636,13 +636,6 @@ 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"/>
|
||||
@@ -931,11 +924,12 @@ is divided into following sections:
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
@@ -1135,13 +1129,6 @@ 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"/>
|
||||
|
@@ -1,8 +1,8 @@
|
||||
build.xml.data.CRC32=2bd2dd75
|
||||
build.xml.data.CRC32=51b33957
|
||||
build.xml.script.CRC32=7a797370
|
||||
build.xml.stylesheet.CRC32=28e38971@1.43.1.45
|
||||
build.xml.stylesheet.CRC32=28e38971@1.44.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=2bd2dd75
|
||||
nbproject/build-impl.xml.script.CRC32=769e541b
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.data.CRC32=51b33957
|
||||
nbproject/build-impl.xml.script.CRC32=66b89647
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
|
||||
|
@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=BuildAll
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -27,24 +62,23 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.compress=true
|
||||
javac.classpath=\
|
||||
${reference.Essentials.jar}:\
|
||||
${reference.EssentialsChat.jar}:\
|
||||
${reference.EssentialsProtect.jar}:\
|
||||
${reference.EssentialsPermissionsCommands.jar}:\
|
||||
${reference.EssentialsSpawn.jar}:\
|
||||
${reference.EssentialsGeoIP.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupBridge.jar}:\
|
||||
${reference.EssentialsXMPP.jar}:\
|
||||
${reference.EssentialsGroupManager.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
@@ -71,7 +105,6 @@ project.EssentialsChat=../EssentialsChat
|
||||
project.EssentialsGeoIP=../EssentialsGeoIP
|
||||
project.EssentialsGroupBridge=../EssentialsGroupBridge
|
||||
project.EssentialsGroupManager=../EssentialsGroupManager
|
||||
project.EssentialsPermissionsCommands=../EssentialsPermissionsCommands
|
||||
project.EssentialsProtect=../EssentialsProtect
|
||||
project.EssentialsSpawn=../EssentialsSpawn
|
||||
project.EssentialsXMPP=../EssentialsXMPP
|
||||
@@ -80,7 +113,6 @@ 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
|
||||
|
@@ -55,14 +55,6 @@
|
||||
<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>
|
||||
|
7
Essentials/.gitignore
vendored
7
Essentials/.gitignore
vendored
@@ -1,7 +0,0 @@
|
||||
# NetBeans cruft
|
||||
/build
|
||||
/dist
|
||||
/nbproject/private
|
||||
|
||||
# Mac cruft
|
||||
.DS_Store
|
@@ -1,84 +1,84 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!-- You may freely edit this file. See commented blocks below for -->
|
||||
<!-- some examples of how to customize the build. -->
|
||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
||||
<!-- the Compile on Save feature is turned off for the project. -->
|
||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
||||
<!-- in the project's Project Properties dialog box.-->
|
||||
<project name="Essentials" default="default" basedir=".">
|
||||
|
||||
<description>Builds, tests, and runs the project Essentials.</description>
|
||||
<import file="nbproject/build-impl.xml"/>
|
||||
<!--
|
||||
|
||||
There exist several targets which are by default empty and which can be
|
||||
used for execution of your tasks. These targets are usually executed
|
||||
before and after some main targets. They are:
|
||||
|
||||
-pre-init: called before initialization of project properties
|
||||
-post-init: called after initialization of project properties
|
||||
-pre-compile: called before javac compilation
|
||||
-post-compile: called after javac compilation
|
||||
-pre-compile-single: called before javac compilation of single file
|
||||
-post-compile-single: called after javac compilation of single file
|
||||
-pre-compile-test: called before javac compilation of JUnit tests
|
||||
-post-compile-test: called after javac compilation of JUnit tests
|
||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
||||
-pre-jar: called before JAR building
|
||||
-post-jar: called after JAR building
|
||||
-post-clean: called after cleaning build products
|
||||
|
||||
(Targets beginning with '-' are not intended to be called on their own.)
|
||||
|
||||
Example of inserting an obfuscator after compilation could look like this:
|
||||
|
||||
<target name="-post-compile">
|
||||
<obfuscate>
|
||||
<fileset dir="${build.classes.dir}"/>
|
||||
</obfuscate>
|
||||
</target>
|
||||
|
||||
For list of available properties check the imported
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
|
||||
Another way to customize the build is by overriding existing main targets.
|
||||
The targets of interest are:
|
||||
|
||||
-init-macrodef-javac: defines macro for javac compilation
|
||||
-init-macrodef-junit: defines macro for junit execution
|
||||
-init-macrodef-debug: defines macro for class debugging
|
||||
-init-macrodef-java: defines macro for class execution
|
||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
||||
run: execution of project
|
||||
-javadoc-build: Javadoc generation
|
||||
test-report: JUnit report generation
|
||||
|
||||
An example of overriding the target for project execution could look like this:
|
||||
|
||||
<target name="run" depends="Essentials-impl.jar">
|
||||
<exec dir="bin" executable="launcher.exe">
|
||||
<arg file="${dist.jar}"/>
|
||||
</exec>
|
||||
</target>
|
||||
|
||||
Notice that the overridden target depends on the jar target and not only on
|
||||
the compile target as the regular run target does. Again, for a list of available
|
||||
properties which you can use, check the target you are overriding in the
|
||||
nbproject/build-impl.xml file.
|
||||
|
||||
-->
|
||||
<!--target name="-post-jar">
|
||||
<jar jarfile="${dist.dir}/Essentials.jar">
|
||||
<zipfileset src="${dist.jar}" excludes="META-INF/*" />
|
||||
<zipfileset src="${dist.dir}/lib/Register.jar" excludes="META-INF/*" />
|
||||
<manifest>
|
||||
<attribute name="Classpath" value="Essentials.jar"/>
|
||||
</manifest>
|
||||
</jar>
|
||||
</target-->
|
||||
</project>
|
||||
|
@@ -868,11 +868,12 @@ is divided into following sections:
|
||||
<classpath>
|
||||
<path path="${javac.classpath}"/>
|
||||
</classpath>
|
||||
<fileset dir="${src.dir}" excludes="${excludes}" includes="${includes}">
|
||||
<fileset dir="${src.dir}" excludes="*.java,${excludes}" includes="${includes}">
|
||||
<filename name="**/*.java"/>
|
||||
</fileset>
|
||||
<fileset dir="${build.generated.sources.dir}" erroronmissingdir="false">
|
||||
<include name="**/*.java"/>
|
||||
<exclude name="*.java"/>
|
||||
</fileset>
|
||||
</javadoc>
|
||||
<copy todir="${dist.javadoc.dir}">
|
||||
|
@@ -4,8 +4,8 @@ build.xml.stylesheet.CRC32=28e38971@1.38.2.45
|
||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
||||
nbproject/build-impl.xml.data.CRC32=4b596d89
|
||||
nbproject/build-impl.xml.script.CRC32=4926001b
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0c01fd8e@1.43.1.45
|
||||
nbproject/build-impl.xml.script.CRC32=dbc81ee1
|
||||
nbproject/build-impl.xml.stylesheet.CRC32=0ae3a408@1.44.1.45
|
||||
nbproject/profiler-build-impl.xml.data.CRC32=ab78ce15
|
||||
nbproject/profiler-build-impl.xml.script.CRC32=abda56ed
|
||||
nbproject/profiler-build-impl.xml.stylesheet.CRC32=f10cf54c@1.11.1
|
||||
|
@@ -1 +1,2 @@
|
||||
DoNotUseThreads
|
||||
SignatureDeclareThrowsException
|
||||
|
@@ -3,7 +3,42 @@ annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.run.all.processors=true
|
||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
||||
application.title=Essentials
|
||||
application.vendor=Paul
|
||||
application.vendor=
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.expand-tabs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.indent-shift-width=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.spaces-per-tab=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.tab-size=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-limit-width=120
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.project.text-line-wrap=none
|
||||
auxiliary.org-netbeans-modules-editor-indent.CodeStyle.usedProfile=project
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineArrayInit=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAssignment=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineBinaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineDisjunctiveCatchTypes=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineFor=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineParenthesized=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTernaryOp=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineTryResources=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesAfterClassHeader=0
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLinesBeforeClass=2
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.classDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.expand-tabs=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indentCasesFromSwitch=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.methodDeclBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.otherBracePlacement=NEW_LINE
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeCatchOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeElseOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeFinallyOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.placeWhileOnNewLine=true
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaceAfterTypeCast=false
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.spaces-per-tab=4
|
||||
auxiliary.org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.tab-size=4
|
||||
build.classes.dir=${build.dir}/classes
|
||||
build.classes.excludes=**/*.java,**/*.form
|
||||
# This directory is removed when the project is cleaned:
|
||||
@@ -27,26 +62,38 @@ dist.javadoc.dir=${dist.dir}/javadoc
|
||||
endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.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.iCo6.jar=../lib/iCo6.jar
|
||||
file.reference.junit-4.5.jar=..\\lib\\junit_4\\junit-4.5.jar
|
||||
file.reference.MultiCurrency.jar=../lib/MultiCurrency.jar
|
||||
file.reference.Permissions3.jar=../lib/Permissions3.jar
|
||||
file.reference.PermissionsBukkit-1.2.jar=../lib/PermissionsBukkit-1.2.jar
|
||||
file.reference.PermissionsEx.jar=../lib/PermissionsEx.jar
|
||||
includes=**
|
||||
jar.compress=false
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
jar.compress=true
|
||||
jar.index=${jnlp.enabled}
|
||||
javac.classpath=\
|
||||
${file.reference.Permissions3.jar}:\
|
||||
${file.reference.craftbukkit-0.0.1-SNAPSHOT.jar}:\
|
||||
${file.reference.iCo4.jar}:\
|
||||
${file.reference.iCo5.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}
|
||||
${file.reference.iCo6.jar}:\
|
||||
${file.reference.MultiCurrency.jar}:\
|
||||
${file.reference.BOSEconomy7.jar}:\
|
||||
${file.reference.PermissionsEx.jar}:\
|
||||
${file.reference.bPermissions.jar}:\
|
||||
${file.reference.PermissionsBukkit-1.2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
javac.processorpath=\
|
||||
${javac.classpath}
|
||||
javac.source=1.5
|
||||
javac.target=1.5
|
||||
javac.source=1.6
|
||||
javac.target=1.6
|
||||
javac.test.classpath=\
|
||||
${javac.classpath}:\
|
||||
${build.classes.dir}:\
|
||||
@@ -64,8 +111,17 @@ javadoc.splitindex=true
|
||||
javadoc.use=true
|
||||
javadoc.version=false
|
||||
javadoc.windowtitle=
|
||||
jnlp.codebase.type=no.codebase
|
||||
jnlp.descriptor=application
|
||||
jnlp.enabled=false
|
||||
jnlp.mixed.code=default
|
||||
jnlp.offline-allowed=false
|
||||
jnlp.signed=false
|
||||
jnlp.signing=
|
||||
jnlp.signing.alias=
|
||||
jnlp.signing.keystore=
|
||||
meta.inf.dir=${src.dir}/META-INF
|
||||
mkdist.disabled=false
|
||||
mkdist.disabled=true
|
||||
platform.active=default_platform
|
||||
run.classpath=\
|
||||
${javac.classpath}:\
|
||||
|
@@ -1,35 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.craftbukkit.CraftServer;
|
||||
|
||||
public class Backup implements Runnable {
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private final CraftServer server;
|
||||
private final IEssentials ess;
|
||||
private boolean running = false;
|
||||
private int taskId = -1;
|
||||
private boolean active = false;
|
||||
|
||||
public Backup(IEssentials ess) {
|
||||
public class Backup implements Runnable
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient final CraftServer server;
|
||||
private transient final IEssentials ess;
|
||||
private transient boolean running = false;
|
||||
private transient int taskId = -1;
|
||||
private transient boolean active = false;
|
||||
|
||||
public Backup(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
server = (CraftServer)ess.getServer();
|
||||
if (server.getOnlinePlayers().length > 0) {
|
||||
if (server.getOnlinePlayers().length > 0)
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void onPlayerJoin() {
|
||||
void onPlayerJoin()
|
||||
{
|
||||
startTask();
|
||||
}
|
||||
|
||||
private void startTask() {
|
||||
if (!running) {
|
||||
long interval = ess.getSettings().getBackupInterval()*1200; // minutes -> ticks
|
||||
if (interval < 1200) {
|
||||
|
||||
private void startTask()
|
||||
{
|
||||
if (!running)
|
||||
{
|
||||
final long interval = ess.getSettings().getBackupInterval() * 1200; // minutes -> ticks
|
||||
if (interval < 1200)
|
||||
{
|
||||
return;
|
||||
}
|
||||
taskId = ess.scheduleSyncRepeatingTask(this, interval, interval);
|
||||
@@ -37,48 +47,84 @@ public class Backup implements Runnable {
|
||||
}
|
||||
}
|
||||
|
||||
public void run() {
|
||||
if (active) return;
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command)) {
|
||||
public void run()
|
||||
{
|
||||
if (active)
|
||||
{
|
||||
return;
|
||||
}
|
||||
logger.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
active = true;
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command))
|
||||
{
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupStarted"));
|
||||
final CommandSender cs = server.getServer().console;
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
server.dispatchCommand(cs, "save-off");
|
||||
|
||||
|
||||
ess.scheduleAsyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
try {
|
||||
Process child = Runtime.getRuntime().exec(command);
|
||||
child.waitFor();
|
||||
} catch (InterruptedException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} catch (IOException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
} finally {
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable() {
|
||||
|
||||
public void run() {
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0) {
|
||||
running = false;
|
||||
if (taskId != -1) {
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
final ProcessBuilder childBuilder = new ProcessBuilder(command);
|
||||
childBuilder.redirectErrorStream(true);
|
||||
childBuilder.directory(ess.getDataFolder().getParentFile().getParentFile());
|
||||
final Process child = childBuilder.start();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(child.getInputStream()));
|
||||
try
|
||||
{
|
||||
child.waitFor();
|
||||
String line;
|
||||
do
|
||||
{
|
||||
line = reader.readLine();
|
||||
if (line != null)
|
||||
{
|
||||
LOGGER.log(Level.INFO, line);
|
||||
}
|
||||
}
|
||||
while (line != null);
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
active = false;
|
||||
logger.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
catch (InterruptedException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
server.dispatchCommand(cs, "save-on");
|
||||
if (server.getOnlinePlayers().length == 0)
|
||||
{
|
||||
running = false;
|
||||
if (taskId != -1)
|
||||
{
|
||||
server.getScheduler().cancelTask(taskId);
|
||||
}
|
||||
}
|
||||
active = false;
|
||||
LOGGER.log(Level.INFO, Util.i18n("backupFinished"));
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,157 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
@@ -1,51 +0,0 @@
|
||||
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 "";
|
||||
}
|
||||
}
|
298
Essentials/src/com/earth2me/essentials/DescParseTickFormat.java
Executable file
298
Essentials/src/com/earth2me/essentials/DescParseTickFormat.java
Executable file
@@ -0,0 +1,298 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.Commandtime;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
|
||||
/**
|
||||
* This utility class is used for converting between the ingame
|
||||
* time in ticks to ingame time as a friendly string.
|
||||
* Note that the time is INGAME.
|
||||
*
|
||||
* http://www.minecraftwiki.net/wiki/Day/night_cycle
|
||||
*
|
||||
* @author Olof Larsson
|
||||
*/
|
||||
public final class DescParseTickFormat
|
||||
{
|
||||
// ============================================
|
||||
// First some information vars. TODO: Should this be in a config file?
|
||||
// --------------------------------------------
|
||||
public static final Map<String, Integer> nameToTicks = new LinkedHashMap<String, Integer>();
|
||||
public static final Set<String> resetAliases = new HashSet<String>();
|
||||
public static final int ticksAtMidnight = 18000;
|
||||
public static final int ticksPerDay = 24000;
|
||||
public static final int ticksPerHour = 1000;
|
||||
public static final double ticksPerMinute = 1000d / 60d;
|
||||
public static final double ticksPerSecond = 1000d / 60d / 60d;
|
||||
private static final SimpleDateFormat SDFTwentyFour = new SimpleDateFormat("HH:mm", Locale.ENGLISH);
|
||||
private static final SimpleDateFormat SDFTwelve = new SimpleDateFormat("h:mmaa", Locale.ENGLISH);
|
||||
|
||||
static
|
||||
{
|
||||
SDFTwentyFour.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
SDFTwelve.setTimeZone(TimeZone.getTimeZone("GMT"));
|
||||
|
||||
nameToTicks.put("sunrise", 23000);
|
||||
nameToTicks.put("dawn", 23000);
|
||||
|
||||
nameToTicks.put("daystart", 0);
|
||||
nameToTicks.put("day", 0);
|
||||
|
||||
nameToTicks.put("morning", 1000);
|
||||
|
||||
nameToTicks.put("midday", 6000);
|
||||
nameToTicks.put("noon", 6000);
|
||||
|
||||
nameToTicks.put("afternoon", 9000);
|
||||
|
||||
nameToTicks.put("sunset", 12000);
|
||||
nameToTicks.put("dusk", 12000);
|
||||
nameToTicks.put("sundown", 12000);
|
||||
nameToTicks.put("nightfall", 12000);
|
||||
|
||||
nameToTicks.put("nightstart", 14000);
|
||||
nameToTicks.put("night", 14000);
|
||||
|
||||
nameToTicks.put("midnight", 18000);
|
||||
|
||||
resetAliases.add("reset");
|
||||
resetAliases.add("normal");
|
||||
resetAliases.add("default");
|
||||
}
|
||||
|
||||
private DescParseTickFormat()
|
||||
{
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// PARSE. From describing String to int
|
||||
// --------------------------------------------
|
||||
public static long parse(String desc) throws NumberFormatException
|
||||
{
|
||||
// Only look at alphanumeric and lowercase and : for 24:00
|
||||
desc = desc.toLowerCase().replaceAll("[^A-Za-z0-9:]", "");
|
||||
|
||||
// Detect ticks format
|
||||
try
|
||||
{
|
||||
return parseTicks(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 24-hour format
|
||||
try
|
||||
{
|
||||
return parse24(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect 12-hour format
|
||||
try
|
||||
{
|
||||
return parse12(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Detect aliases
|
||||
try
|
||||
{
|
||||
return parseAlias(desc);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
|
||||
// Well we failed to understand...
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
public static long parseTicks(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]+ti?c?k?s?$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.replaceAll("[^0-9]", "");
|
||||
|
||||
return Long.parseLong(desc) % 24000;
|
||||
}
|
||||
|
||||
public static long parse24(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{2}[^0-9]?[0-9]{2}$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() != 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
final int hours = Integer.parseInt(desc.substring(0, 2));
|
||||
final int minutes = Integer.parseInt(desc.substring(2, 4));
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long parse12(String desc) throws NumberFormatException
|
||||
{
|
||||
if (!desc.matches("^[0-9]{1,2}([^0-9]?[0-9]{2})?(pm|am)$"))
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
desc = desc.toLowerCase().replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() > 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.length() == 4)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
minutes += Integer.parseInt(desc.substring(2, 4));
|
||||
}
|
||||
else if (desc.length() == 3)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
minutes += Integer.parseInt(desc.substring(1, 3));
|
||||
}
|
||||
else if (desc.length() == 2)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
}
|
||||
else if (desc.length() == 1)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.endsWith("pm") && hours != 12)
|
||||
{
|
||||
hours += 12;
|
||||
}
|
||||
|
||||
if (desc.endsWith("am") && hours == 12)
|
||||
{
|
||||
hours -= 12;
|
||||
}
|
||||
|
||||
return hoursMinutesToTicks(hours, minutes);
|
||||
}
|
||||
|
||||
public static long hoursMinutesToTicks(final int hours, final int minutes)
|
||||
{
|
||||
long ret = ticksAtMidnight;
|
||||
ret += (hours) * ticksPerHour;
|
||||
|
||||
ret += (minutes / 60.0) * ticksPerHour;
|
||||
|
||||
ret %= ticksPerDay;
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static long parseAlias(final String desc) throws NumberFormatException
|
||||
{
|
||||
final Integer ret = nameToTicks.get(desc);
|
||||
if (ret == null)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static boolean meansReset(final String desc)
|
||||
{
|
||||
return resetAliases.contains(desc);
|
||||
}
|
||||
|
||||
// ============================================
|
||||
// FORMAT. From int to describing String
|
||||
// --------------------------------------------
|
||||
public static String format(final long ticks)
|
||||
{
|
||||
return Util.format("timeFormat", format24(ticks), format12(ticks), formatTicks(ticks));
|
||||
}
|
||||
|
||||
public static String formatTicks(final long ticks)
|
||||
{
|
||||
return (ticks % ticksPerDay) + "ticks";
|
||||
}
|
||||
|
||||
public static String format24(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwentyFour)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwentyFour);
|
||||
}
|
||||
}
|
||||
|
||||
public static String format12(final long ticks)
|
||||
{
|
||||
synchronized (SDFTwelve)
|
||||
{
|
||||
return formatDateFormat(ticks, SDFTwelve);
|
||||
}
|
||||
}
|
||||
|
||||
public static String formatDateFormat(final long ticks, final SimpleDateFormat format)
|
||||
{
|
||||
final Date date = ticksToDate(ticks);
|
||||
return format.format(date);
|
||||
}
|
||||
|
||||
public static Date ticksToDate(long ticks)
|
||||
{
|
||||
// Assume the server time starts at 0. It would start on a day.
|
||||
// But we will simulate that the server started with 0 at midnight.
|
||||
ticks = ticks - ticksAtMidnight + ticksPerDay;
|
||||
|
||||
// How many ingame days have passed since the server start?
|
||||
final long days = ticks / ticksPerDay;
|
||||
ticks = ticks - days * ticksPerDay;
|
||||
|
||||
// How many hours on the last day?
|
||||
final long hours = ticks / ticksPerHour;
|
||||
ticks = ticks - hours * ticksPerHour;
|
||||
|
||||
// How many minutes on the last day?
|
||||
final long minutes = (long)Math.floor(ticks / ticksPerMinute);
|
||||
final double dticks = ticks - minutes * ticksPerMinute;
|
||||
|
||||
// How many seconds on the last day?
|
||||
final long seconds = (long)Math.floor(dticks / ticksPerSecond);
|
||||
|
||||
// Now we create an english GMT calendar (We wan't no daylight savings)
|
||||
final Calendar cal = Calendar.getInstance(TimeZone.getTimeZone("GMT"), Locale.ENGLISH);
|
||||
cal.setLenient(true);
|
||||
|
||||
// And we set the time to 0! And append the time that passed!
|
||||
cal.set(0, Calendar.JANUARY, 1, 0, 0, 0);
|
||||
cal.add(Calendar.DAY_OF_YEAR, (int)days);
|
||||
cal.add(Calendar.HOUR_OF_DAY, (int)hours);
|
||||
cal.add(Calendar.MINUTE, (int)minutes);
|
||||
cal.add(Calendar.SECOND, (int)seconds + 1); // To solve rounding errors.
|
||||
|
||||
return cal.getTime();
|
||||
}
|
||||
}
|
@@ -26,7 +26,9 @@ import org.bukkit.*;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
import com.earth2me.essentials.signs.SignEntityListener;
|
||||
@@ -35,18 +37,17 @@ import java.math.BigInteger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
import org.bukkit.craftbukkit.scheduler.CraftScheduler;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
import org.bukkit.plugin.*;
|
||||
import org.bukkit.plugin.java.*;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1000;
|
||||
public static final int BUKKIT_VERSION = 1060;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
@@ -56,15 +57,15 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
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;
|
||||
private transient PermissionsHandler permissionsHandler;
|
||||
private transient UserMap userMap;
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
{
|
||||
return settings;
|
||||
@@ -85,10 +86,12 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
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(this);
|
||||
permissionsHandler = new ConfigPermissionsHandler(this);
|
||||
userMap = new UserMap(this);
|
||||
permissionsHandler = new PermissionsHandler(this, false);
|
||||
Economy.setEss(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
final String[] javaversion = System.getProperty("java.version").split("\\.", 3);
|
||||
@@ -100,21 +103,21 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
LOGGER.addHandler(errorHandler);
|
||||
}
|
||||
EssentialsUpgrade upgrade = new EssentialsUpgrade(this.getDescription().getVersion(), this);
|
||||
final EssentialsUpgrade upgrade = new EssentialsUpgrade(this);
|
||||
upgrade.beforeSettings();
|
||||
confList = new ArrayList<IConf>();
|
||||
settings = new Settings(this);
|
||||
confList.add(settings);
|
||||
upgrade.afterSettings();
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
userMap = new UserMap(this);
|
||||
confList.add(userMap);
|
||||
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();
|
||||
@@ -143,34 +146,11 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
LOGGER.log(Level.INFO, Util.i18n("bukkitFormatChanged"));
|
||||
}
|
||||
|
||||
final Plugin permissionsPlugin = pm.getPlugin("Permissions");
|
||||
|
||||
if (permissionsPlugin != null)
|
||||
{
|
||||
if (permissionsPlugin.getDescription().getVersion().charAt(0) == '3')
|
||||
{
|
||||
this.permissionsHandler = new Permissions3Handler(permissionsPlugin);
|
||||
}
|
||||
else
|
||||
{
|
||||
this.permissionsHandler = new Permissions2Handler(permissionsPlugin);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this.getSettings().useBukkitPermissions())
|
||||
{
|
||||
this.permissionsHandler = new BukkitPermissionsHandler();
|
||||
}
|
||||
else
|
||||
{
|
||||
this.permissionsHandler = new ConfigPermissionsHandler(this);
|
||||
}
|
||||
}
|
||||
|
||||
final ServerListener serverListener = new EssentialsPluginListener(paymentMethod);
|
||||
permissionsHandler = new PermissionsHandler(this, settings.useBukkitPermissions());
|
||||
final EssentialsPluginListener serverListener = new EssentialsPluginListener(this);
|
||||
pm.registerEvent(Type.PLUGIN_ENABLE, serverListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.PLUGIN_DISABLE, serverListener, Priority.Low, this);
|
||||
confList.add(serverListener);
|
||||
|
||||
final EssentialsPlayerListener playerListener = new EssentialsPlayerListener(this);
|
||||
pm.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.Monitor, this);
|
||||
@@ -202,11 +182,13 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
final SignEntityListener signEntityListener = new SignEntityListener(this);
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, signEntityListener, Priority.Low, this);
|
||||
pm.registerEvent(Type.ENDERMAN_PICKUP, 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);
|
||||
pm.registerEvent(Type.FOOD_LEVEL_CHANGE, entityListener, Priority.Lowest, this);
|
||||
|
||||
jail = new Jail(this);
|
||||
final JailPlayerListener jailPlayerListener = new JailPlayerListener(this);
|
||||
@@ -227,22 +209,24 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
pm.registerEvent(Type.ENTITY_EXPLODE, tntListener, Priority.High, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 50);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
Economy.setEss(this);
|
||||
if (enableErrorLogging)
|
||||
if (getSettings().isUpdateEnabled())
|
||||
{
|
||||
updateTimer = new EssentialsUpdateTimer(this);
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 50, 50 * 60 * (this.getDescription().getVersion().startsWith("Dev") ? 60 : 360));
|
||||
getScheduler().scheduleAsyncRepeatingTask(this, updateTimer, 20 * 60 * 10, 20 * 3600 * 6);
|
||||
}
|
||||
LOGGER.info(Util.format("loadinfo", this.getDescription().getName(), this.getDescription().getVersion(), Util.joinList(this.getDescription().getAuthors())));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
Trade.closeLog();
|
||||
LOGGER.removeHandler(errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reload()
|
||||
{
|
||||
Trade.closeLog();
|
||||
@@ -254,21 +238,18 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
Util.updateLocale(settings.getLocale(), this);
|
||||
|
||||
for (User user : users.values())
|
||||
{
|
||||
user.reloadConfig();
|
||||
}
|
||||
|
||||
// for motd
|
||||
getConfiguration().load();
|
||||
}
|
||||
|
||||
public String[] getMotd(CommandSender sender, String def)
|
||||
@Override
|
||||
public String[] getMotd(final CommandSender sender, final String def)
|
||||
{
|
||||
return getLines(sender, "motd", def);
|
||||
}
|
||||
|
||||
public String[] getLines(CommandSender sender, String node, String def)
|
||||
@Override
|
||||
public String[] getLines(final CommandSender sender, final String node, final String def)
|
||||
{
|
||||
List<String> lines = (List<String>)getConfiguration().getProperty(node);
|
||||
if (lines == null)
|
||||
@@ -329,7 +310,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
}
|
||||
m = m.replace("{ONLINE}", Integer.toString(getServer().getOnlinePlayers().length - playerHidden));
|
||||
m = m.replace("{UNIQUE}", Integer.toString(users.size()));
|
||||
m = m.replace("{UNIQUE}", Integer.toString(userMap.getUniqueUsers()));
|
||||
|
||||
if (m.matches(".*\\{PLAYERLIST\\}.*"))
|
||||
{
|
||||
@@ -373,12 +354,13 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String commandLabel, String[] args)
|
||||
public boolean onCommand(final CommandSender sender, final Command command, final String commandLabel, final String[] args)
|
||||
{
|
||||
return onCommandEssentials(sender, command, commandLabel, args, Essentials.class.getClassLoader(), "com.earth2me.essentials.commands.Command", "essentials.");
|
||||
}
|
||||
|
||||
public boolean onCommandEssentials(CommandSender sender, Command command, String commandLabel, String[] args, ClassLoader classLoader, String commandPath, String permissionPrefix)
|
||||
@Override
|
||||
public boolean onCommandEssentials(final CommandSender sender, final Command command, final String commandLabel, final String[] args, final ClassLoader classLoader, final String commandPath, final String permissionPrefix)
|
||||
{
|
||||
// Allow plugins to override the command via onCommand
|
||||
if (!getSettings().isCommandOverridden(command.getName()) && !commandLabel.startsWith("e"))
|
||||
@@ -390,7 +372,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginDescriptionFile desc = p.getDescription();
|
||||
final PluginDescriptionFile desc = p.getDescription();
|
||||
if (desc == null)
|
||||
{
|
||||
continue;
|
||||
@@ -401,7 +383,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
continue;
|
||||
}
|
||||
|
||||
PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
|
||||
final PluginCommand pc = getServer().getPluginCommand(desc.getName() + ":" + commandLabel);
|
||||
if (pc != null)
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
@@ -468,6 +450,10 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (NoChargeException ex)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
catch (NotEnoughArgumentsException ex)
|
||||
{
|
||||
sender.sendMessage(command.getDescription());
|
||||
@@ -487,6 +473,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showError(final CommandSender sender, final Throwable exception, final String commandLabel)
|
||||
{
|
||||
sender.sendMessage(Util.format("errorWithMessage", exception.getMessage()));
|
||||
@@ -506,46 +493,64 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
}
|
||||
}
|
||||
|
||||
public CraftScheduler getScheduler()
|
||||
@Override
|
||||
public BukkitScheduler getScheduler()
|
||||
{
|
||||
return (CraftScheduler)this.getServer().getScheduler();
|
||||
return this.getServer().getScheduler();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Jail getJail()
|
||||
{
|
||||
return jail;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Warps getWarps()
|
||||
{
|
||||
return warps;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Worth getWorth()
|
||||
{
|
||||
return worth;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Backup getBackup()
|
||||
{
|
||||
return backup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Spawn getSpawn()
|
||||
{
|
||||
return spawn;
|
||||
}
|
||||
|
||||
public User getUser(Object base)
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
{
|
||||
if (base instanceof Player)
|
||||
{
|
||||
return getUser((Player)base);
|
||||
}
|
||||
if (base instanceof String)
|
||||
{
|
||||
try
|
||||
{
|
||||
return userMap.getUser((String)base);
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private <T extends Player> User getUser(T base)
|
||||
private <T extends Player> User getUser(final T base)
|
||||
{
|
||||
if (base == null)
|
||||
{
|
||||
@@ -556,71 +561,70 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return (User)base;
|
||||
}
|
||||
|
||||
if (users.containsKey(base.getName().toLowerCase()))
|
||||
try
|
||||
{
|
||||
return users.get(base.getName().toLowerCase()).update(base);
|
||||
return userMap.getUser(base.getName()).update(base);
|
||||
}
|
||||
|
||||
User u = new User(base, this);
|
||||
users.put(u.getName().toLowerCase(), u);
|
||||
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)
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return u;
|
||||
return new User(base, this);
|
||||
}
|
||||
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, this));
|
||||
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getOfflineUser(final String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
return userMap.getUser(name);
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public World getWorld(final String name)
|
||||
{
|
||||
if (name.matches("[0-9]+"))
|
||||
{
|
||||
final int id = Integer.parseInt(name);
|
||||
if (id < getServer().getWorlds().size())
|
||||
final int worldId = Integer.parseInt(name);
|
||||
if (worldId < getServer().getWorlds().size())
|
||||
{
|
||||
return getServer().getWorlds().get(id);
|
||||
return getServer().getWorlds().get(worldId);
|
||||
}
|
||||
}
|
||||
return getServer().getWorld(name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addReloadListener(final IConf listener)
|
||||
{
|
||||
confList.add(listener);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Methods getPaymentMethod()
|
||||
{
|
||||
return paymentMethod;
|
||||
}
|
||||
|
||||
public int broadcastMessage(final String name, final String message)
|
||||
@Override
|
||||
public int broadcastMessage(final IUser sender, final String message)
|
||||
{
|
||||
Player[] players = getServer().getOnlinePlayers();
|
||||
if (sender == null) {
|
||||
return getServer().broadcastMessage(message);
|
||||
}
|
||||
if (sender.isHidden()) {
|
||||
return 0;
|
||||
}
|
||||
final Player[] players = getServer().getOnlinePlayers();
|
||||
|
||||
for (Player player : players)
|
||||
{
|
||||
User u = getUser(player);
|
||||
if (!u.isIgnoredPlayer(name))
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -634,43 +638,51 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return errorHandler.getErrors();
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleAsyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleAsyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncDelayedTask(final Runnable run, final long delay)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncDelayedTask(this, run, delay);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int scheduleSyncRepeatingTask(final Runnable run, final long delay, final long period)
|
||||
{
|
||||
return this.getScheduler().scheduleSyncRepeatingTask(this, run, delay, period);
|
||||
}
|
||||
|
||||
@Override
|
||||
public TNTExplodeListener getTNTListener()
|
||||
{
|
||||
return tntListener;
|
||||
}
|
||||
|
||||
public IPermissionsHandler getPermissionsHandler()
|
||||
@Override
|
||||
public PermissionsHandler getPermissionsHandler()
|
||||
{
|
||||
return permissionsHandler;
|
||||
}
|
||||
|
||||
public BanWorkaround getBans()
|
||||
{
|
||||
return bans;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemDb getItemDb()
|
||||
{
|
||||
return itemDb;
|
||||
}
|
||||
|
||||
@Override
|
||||
public UserMap getUserMap()
|
||||
{
|
||||
return userMap;
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
@@ -19,12 +21,12 @@ import org.bukkit.util.config.Configuration;
|
||||
|
||||
public class EssentialsConf extends Configuration
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private File configFile;
|
||||
private String templateName = null;
|
||||
private Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
|
||||
public EssentialsConf(File configFile)
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super(configFile);
|
||||
this.configFile = configFile;
|
||||
@@ -42,33 +44,79 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
if (!configFile.getParentFile().mkdirs())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
// This will delete files where the first character is 0. In most cases they are broken.
|
||||
if (configFile.exists() && configFile.length() != 0)
|
||||
{
|
||||
try
|
||||
{
|
||||
final InputStream input = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
if (input.read() == 0)
|
||||
{
|
||||
input.close();
|
||||
configFile.delete();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
input.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (FileNotFoundException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!configFile.exists())
|
||||
{
|
||||
if (templateName != null)
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingConfigFromTemplate", configFile.toString()));
|
||||
createFromTemplate();
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
logger.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
LOGGER.log(Level.INFO, Util.format("creatingEmptyConfig", configFile.toString()));
|
||||
if (!configFile.createNewFile())
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()));
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCreateConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
super.load();
|
||||
|
||||
try
|
||||
{
|
||||
super.load();
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + configFile.toString());
|
||||
throw e;
|
||||
}
|
||||
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
@@ -84,7 +132,7 @@ public class EssentialsConf extends Configuration
|
||||
istr = resourceClass.getResourceAsStream(templateName);
|
||||
if (istr == null)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
LOGGER.log(Level.SEVERE, Util.format("couldNotFindTemplate", templateName));
|
||||
return;
|
||||
}
|
||||
ostr = new FileOutputStream(configFile);
|
||||
@@ -99,7 +147,7 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToWriteConfig", configFile.toString()), ex);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
@@ -124,12 +172,12 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
LOGGER.log(Level.SEVERE, Util.format("failedToCloseConfig", configFile.toString()), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName)
|
||||
public void setTemplateName(final String templateName)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
}
|
||||
@@ -139,48 +187,48 @@ public class EssentialsConf extends Configuration
|
||||
return configFile;
|
||||
}
|
||||
|
||||
public void setTemplateName(String templateName, Class<?> resClass)
|
||||
public void setTemplateName(final String templateName, final Class<?> resClass)
|
||||
{
|
||||
this.templateName = templateName;
|
||||
this.resourceClass = resClass;
|
||||
}
|
||||
|
||||
public boolean hasProperty(String path)
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
}
|
||||
|
||||
public Location getLocation(String path, Server server)
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
{
|
||||
String worldName = getString((path != null ? path + "." : "") + "world");
|
||||
final String worldName = getString((path == null ? "" : path + ".") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = server.getWorld(worldName);
|
||||
final World world = server.getWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
throw new Exception(Util.i18n("invalidWorld"));
|
||||
}
|
||||
return new Location(world,
|
||||
getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
getDouble((path == null ? "" : path + ".") + "x", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "y", 0),
|
||||
getDouble((path == null ? "" : path + ".") + "z", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "yaw", 0),
|
||||
(float)getDouble((path == null ? "" : path + ".") + "pitch", 0));
|
||||
}
|
||||
|
||||
public void setProperty(String path, Location loc)
|
||||
public void setProperty(final String path, final Location loc)
|
||||
{
|
||||
setProperty((path != null ? path + "." : "") + "world", loc.getWorld().getName());
|
||||
setProperty((path != null ? path + "." : "") + "x", loc.getX());
|
||||
setProperty((path != null ? path + "." : "") + "y", loc.getY());
|
||||
setProperty((path != null ? path + "." : "") + "z", loc.getZ());
|
||||
setProperty((path != null ? path + "." : "") + "yaw", loc.getYaw());
|
||||
setProperty((path != null ? path + "." : "") + "pitch", loc.getPitch());
|
||||
setProperty((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
setProperty((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
setProperty((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
setProperty((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
setProperty((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
setProperty((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
public ItemStack getItemStack(String path)
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
return new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
@@ -189,9 +237,9 @@ public class EssentialsConf extends Configuration
|
||||
(byte)getInt(path + ".data", 0)*/);
|
||||
}
|
||||
|
||||
public void setProperty(String path, ItemStack stack)
|
||||
public void setProperty(final String path, final ItemStack stack)
|
||||
{
|
||||
Map<String, Object> map = new HashMap<String, Object>();
|
||||
final Map<String, Object> map = new HashMap<String, Object>();
|
||||
map.put("type", stack.getType().toString());
|
||||
map.put("amount", stack.getAmount());
|
||||
map.put("damage", stack.getDurability());
|
||||
@@ -200,40 +248,30 @@ public class EssentialsConf extends Configuration
|
||||
setProperty(path, map);
|
||||
}
|
||||
|
||||
public long getLong(String path, long def)
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
final Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.longValue();
|
||||
}
|
||||
|
||||
@Override
|
||||
public double getDouble(String path, double def)
|
||||
public double getDouble(final String path, final double def)
|
||||
{
|
||||
Number num;
|
||||
try
|
||||
{
|
||||
num = (Number)getProperty(path);
|
||||
Number num = (Number)getProperty(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch(ClassCastException ex)
|
||||
catch (ClassCastException ex)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
if (num == null)
|
||||
{
|
||||
return def;
|
||||
}
|
||||
return num.doubleValue();
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import org.bukkit.craftbukkit.entity.CraftPlayer;
|
||||
import java.util.List;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.entity.EntityCombustEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByBlockEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByProjectileEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.entity.EntityListener;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -35,25 +34,28 @@ public class EssentialsEntityListener extends EntityListener
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
String command = attacker.getPowertool(is);
|
||||
if (command != null && !command.isEmpty())
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
for (String command : commandList)
|
||||
{
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (event instanceof EntityDamageEvent || event instanceof EntityDamageByBlockEvent || event instanceof EntityDamageByProjectileEvent)
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
CraftPlayer player = (CraftPlayer)event.getEntity();
|
||||
player.getHandle().fireTicks = 0;
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
final Player player = (Player)event.getEntity();
|
||||
player.setFireTicks(0);
|
||||
player.setRemainingAir(player.getMaximumAir());
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,4 +81,13 @@ public class EssentialsEntityListener extends EntityListener
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
event.setFoodLevel(20);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
@@ -72,11 +73,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
@@ -92,10 +89,27 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (user.isAfk())
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
final Location from = event.getFrom();
|
||||
final Location to = event.getTo().clone();
|
||||
to.setX(from.getX());
|
||||
to.setY(from.getY());
|
||||
to.setZ(from.getZ());
|
||||
try
|
||||
{
|
||||
event.setTo(Util.getSafeDestination(to));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
event.setTo(to);
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9) {
|
||||
user.updateActivity(true);
|
||||
}
|
||||
|
||||
if (!ess.getSettings().getNetherPortalsEnabled())
|
||||
@@ -215,6 +229,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
}
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
if (!ess.getSettings().getReclaimSetting())
|
||||
{
|
||||
@@ -251,19 +266,11 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
ess.getBackup().onPlayerJoin();
|
||||
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())
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
user.kickPlayer(banReason != null && !banReason.isEmpty() ? banReason : Util.i18n("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayName(user.getNick());
|
||||
}
|
||||
user.setAfk(false);
|
||||
user.updateActivity(false);
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
@@ -298,13 +305,18 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
@Override
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED)
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (user.isBanned())
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
@@ -317,6 +329,7 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
event.disallow(Result.KICK_FULL, Util.i18n("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
@@ -417,30 +430,35 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
if (is == null || is.getType() == Material.AIR || !user.arePowerToolsEnabled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final String command = user.getPowertool(is);
|
||||
if (command == null || command.isEmpty())
|
||||
final List<String> commandList = user.getPowertool(is);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
p.sendMessage(user.getDisplayName() + ":" + command.substring(2));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(event.getPlayer(), command);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user, command);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -453,20 +471,21 @@ public class EssentialsPlayerListener extends PlayerListener
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String cmd = event.getMessage().toLowerCase().split(" ")[0].replace("/", "").toLowerCase();
|
||||
if (("msg".equals(cmd) || "r".equals(cmd) || "mail".equals(cmd)))
|
||||
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())
|
||||
User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (user.isAfk())
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
user.setAfk(false);
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.event.server.PluginDisableEvent;
|
||||
@@ -8,38 +7,42 @@ import org.bukkit.event.server.PluginEnableEvent;
|
||||
import org.bukkit.event.server.ServerListener;
|
||||
|
||||
|
||||
public class EssentialsPluginListener extends ServerListener
|
||||
public class EssentialsPluginListener extends ServerListener implements IConf
|
||||
{
|
||||
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())
|
||||
ess.getPermissionsHandler().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)
|
||||
public void onPluginDisable(final PluginDisableEvent event)
|
||||
{
|
||||
ess.getPermissionsHandler().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.");
|
||||
}
|
||||
LOGGER.log(Level.INFO, "[Essentials] Payment method was disabled. No longer accepting payments.");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
ess.getPermissionsHandler().setUseSuperperms(ess.getSettings().useBukkitPermissions());
|
||||
ess.getPermissionsHandler().checkPermissions();
|
||||
}
|
||||
}
|
||||
|
@@ -1,79 +1,45 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.Set;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class EssentialsTimer implements Runnable, IConf
|
||||
public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final IEssentials ess;
|
||||
private final Set<User> allUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(IEssentials ess)
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists()) {
|
||||
return;
|
||||
}
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml")) {
|
||||
continue;
|
||||
}
|
||||
String name = string.substring(0, string.length()-4);
|
||||
User u = ess.getUser(new OfflinePlayer(name, ess));
|
||||
allUsers.add(u);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
long currentTime = System.currentTimeMillis();
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(player);
|
||||
allUsers.add(u);
|
||||
u.setLastActivity(currentTime);
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
|
||||
for (User user: allUsers) {
|
||||
if (user.getBanTimeout() > 0 && user.getBanTimeout() < currentTime) {
|
||||
user.setBanTimeout(0);
|
||||
ess.getBans().unbanByName(user.getName());
|
||||
}
|
||||
if (user.getMuteTimeout() > 0 && user.getMuteTimeout() < currentTime && user.isMuted()) {
|
||||
user.setMuteTimeout(0);
|
||||
user.sendMessage(Util.i18n("canTalkAgain"));
|
||||
user.setMuted(false);
|
||||
}
|
||||
if (user.getJailTimeout() > 0 && user.getJailTimeout() < currentTime && user.isJailed()) {
|
||||
user.setJailTimeout(0);
|
||||
user.setJailed(false);
|
||||
user.sendMessage(Util.i18n("haveBeenReleased"));
|
||||
user.setJail(null);
|
||||
try
|
||||
{
|
||||
user.getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (user.getLastActivity() < currentTime && user.getLastActivity() > user.getLastLogout()) {
|
||||
user.setLastLogout(user.getLastActivity());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void reloadConfig()
|
||||
{
|
||||
for (User user : allUsers)
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
while (iterator.hasNext())
|
||||
{
|
||||
user.reloadConfig();
|
||||
final User user = iterator.next();
|
||||
if (user.getLastOnlineActivity() < currentTime && user.getLastOnlineActivity() > user.getLastLogout())
|
||||
{
|
||||
user.setLastLogout(user.getLastOnlineActivity());
|
||||
iterator.remove();
|
||||
continue;
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -4,65 +4,81 @@ import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.net.MalformedURLException;
|
||||
import java.net.URL;
|
||||
import java.net.URLConnection;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
class EssentialsUpdateTimer implements Runnable
|
||||
{
|
||||
private URL url;
|
||||
private final Essentials ess;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
public EssentialsUpdateTimer(Essentials ess)
|
||||
private transient URL url;
|
||||
private final transient IEssentials ess;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Pattern pattern = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-[0-9]+-[0-9a-z]+-b([0-9]+)jnks.*");
|
||||
|
||||
public EssentialsUpdateTimer(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
try
|
||||
{
|
||||
url = new URL("http://127.0.0.1:8080/check");
|
||||
url = new URL("http://essentialsupdate.appspot.com/check");
|
||||
}
|
||||
catch (MalformedURLException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Invalid url!", ex);
|
||||
LOGGER.log(Level.SEVERE, "Invalid url!", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
try
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(),"UTF-8"));
|
||||
sb.append("&b=").append(URLEncoder.encode(ess.getServer().getVersion(),"UTF-8"));
|
||||
sb.append("&jv=").append(URLEncoder.encode(System.getProperty("java.version"),"UTF-8"));
|
||||
sb.append("&l=").append(URLEncoder.encode(Util.getCurrentLocale().toString(),"UTF-8"));
|
||||
sb.append("&on=").append(URLEncoder.encode(System.getProperty("os.name"),"UTF-8"));
|
||||
sb.append("&ov=").append(URLEncoder.encode(System.getProperty("os.version"),"UTF-8"));
|
||||
for (BigInteger bigInteger : ess.getErrors().keySet())
|
||||
final StringBuilder builder = new StringBuilder();
|
||||
String bukkitVersion = ess.getServer().getVersion();
|
||||
final Matcher versionMatch = pattern.matcher(bukkitVersion);
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
sb.append("&e[]=").append(bigInteger.toString(36));
|
||||
bukkitVersion = versionMatch.group(4);
|
||||
}
|
||||
URLConnection conn = url.openConnection();
|
||||
builder.append("v=").append(URLEncoder.encode(ess.getDescription().getVersion(), "UTF-8"));
|
||||
builder.append("&b=").append(URLEncoder.encode(bukkitVersion, "UTF-8"));
|
||||
final URLConnection conn = url.openConnection();
|
||||
conn.setConnectTimeout(10000);
|
||||
conn.setDoOutput(true);
|
||||
conn.connect();
|
||||
OutputStreamWriter wr = new OutputStreamWriter(conn.getOutputStream());
|
||||
wr.write(sb.toString());
|
||||
wr.flush();
|
||||
BufferedReader br = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
String ret = br.readLine();
|
||||
wr.close();
|
||||
br.close();
|
||||
logger.log(Level.INFO, ret);
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(conn.getOutputStream());
|
||||
writer.write(builder.toString());
|
||||
writer.flush();
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(conn.getInputStream()));
|
||||
final String ret = reader.readLine();
|
||||
writer.close();
|
||||
reader.close();
|
||||
if (!ret.isEmpty() && !ret.equalsIgnoreCase("OK"))
|
||||
{
|
||||
LOGGER.log(Level.INFO, "Essentials Update-Check: " + ret);
|
||||
if (ret.startsWith("New Version"))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.admin.notices.update"))
|
||||
{
|
||||
user.sendMessage(ret);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
LOGGER.log(Level.SEVERE, "Failed to open connection", ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,13 +1,24 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.BufferedWriter;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
@@ -16,63 +27,70 @@ import org.bukkit.inventory.ItemStack;
|
||||
|
||||
public class EssentialsUpgrade
|
||||
{
|
||||
private static boolean alreadyRun = false;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final IEssentials ess;
|
||||
private final static Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private final transient EssentialsConf doneFile;
|
||||
|
||||
EssentialsUpgrade(String version, IEssentials essentials)
|
||||
EssentialsUpgrade(final IEssentials essentials)
|
||||
{
|
||||
ess = essentials;
|
||||
if (alreadyRun)
|
||||
if (!ess.getDataFolder().exists())
|
||||
{
|
||||
return;
|
||||
ess.getDataFolder().mkdirs();
|
||||
}
|
||||
alreadyRun = true;
|
||||
doneFile = new EssentialsConf(new File(ess.getDataFolder(), "upgrades-done.yml"));
|
||||
doneFile.load();
|
||||
}
|
||||
|
||||
private void moveWorthValuesToWorthYml()
|
||||
{
|
||||
if (doneFile.getBoolean("moveWorthValuesToWorthYml", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
try
|
||||
{
|
||||
File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
final File configFile = new File(ess.getDataFolder(), "config.yml");
|
||||
if (!configFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf conf = new EssentialsConf(configFile);
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
Worth w = new Worth(ess.getDataFolder());
|
||||
final Worth worth = new Worth(ess.getDataFolder());
|
||||
boolean found = false;
|
||||
for (Material mat : Material.values())
|
||||
{
|
||||
int id = mat.getId();
|
||||
double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
final int id = mat.getId();
|
||||
final double value = conf.getDouble("worth-" + id, Double.NaN);
|
||||
if (!Double.isNaN(value))
|
||||
{
|
||||
found = true;
|
||||
w.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
worth.setPrice(new ItemStack(mat, 1, (short)0, (byte)0), value);
|
||||
}
|
||||
}
|
||||
if (found)
|
||||
{
|
||||
removeLinesFromConfig(configFile, "\\s*#?\\s*worth-[0-9]+.*", "# Worth values have been moved to worth.yml");
|
||||
}
|
||||
doneFile.setProperty("moveWorthValuesToWorthYml", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (Throwable e)
|
||||
{
|
||||
logger.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("upgradingFilesError"), e);
|
||||
}
|
||||
}
|
||||
|
||||
private void removeLinesFromConfig(File file, String regex, String info) throws Exception
|
||||
{
|
||||
boolean needUpdate = false;
|
||||
BufferedReader br = new BufferedReader(new FileReader(file));
|
||||
File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
BufferedWriter bw = new BufferedWriter(new FileWriter(tempFile));
|
||||
final BufferedReader bReader = new BufferedReader(new FileReader(file));
|
||||
final File tempFile = File.createTempFile("essentialsupgrade", ".tmp.yml", ess.getDataFolder());
|
||||
final BufferedWriter bWriter = new BufferedWriter(new FileWriter(tempFile));
|
||||
do
|
||||
{
|
||||
String line = br.readLine();
|
||||
final String line = bReader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
@@ -81,8 +99,8 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (!needUpdate && info != null)
|
||||
{
|
||||
bw.write(info, 0, info.length());
|
||||
bw.newLine();
|
||||
bWriter.write(info, 0, info.length());
|
||||
bWriter.newLine();
|
||||
}
|
||||
needUpdate = true;
|
||||
}
|
||||
@@ -90,22 +108,22 @@ public class EssentialsUpgrade
|
||||
{
|
||||
if (line.endsWith("\r\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 2);
|
||||
bWriter.write(line, 0, line.length() - 2);
|
||||
}
|
||||
else if (line.endsWith("\r") || line.endsWith("\n"))
|
||||
{
|
||||
bw.write(line, 0, line.length() - 1);
|
||||
bWriter.write(line, 0, line.length() - 1);
|
||||
}
|
||||
else
|
||||
{
|
||||
bw.write(line, 0, line.length());
|
||||
bWriter.write(line, 0, line.length());
|
||||
}
|
||||
bw.newLine();
|
||||
bWriter.newLine();
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
br.close();
|
||||
bw.close();
|
||||
bReader.close();
|
||||
bWriter.close();
|
||||
if (needUpdate)
|
||||
{
|
||||
if (!file.renameTo(new File(file.getParentFile(), file.getName().concat("." + System.currentTimeMillis() + ".upgradebackup"))))
|
||||
@@ -116,19 +134,25 @@ public class EssentialsUpgrade
|
||||
{
|
||||
throw new Exception(Util.i18n("configFileRenameError"));
|
||||
}
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
tempFile.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateUsersToNewDefaultHome()
|
||||
{
|
||||
File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("updateUsersToNewDefaultHome", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] userFiles = userdataFolder.listFiles();
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
@@ -136,15 +160,16 @@ public class EssentialsUpgrade
|
||||
{
|
||||
continue;
|
||||
}
|
||||
EssentialsConf config = new EssentialsConf(file);
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("home") && !config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null) {
|
||||
final List<Object> vals = (List<Object>)config.getProperty("home");
|
||||
if (vals == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
@@ -154,7 +179,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
Location loc = new Location(
|
||||
final Location loc = new Location(
|
||||
world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
@@ -162,7 +187,7 @@ public class EssentialsUpgrade
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue());
|
||||
|
||||
String worldName = world.getName().toLowerCase();
|
||||
final String worldName = world.getName().toLowerCase();
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.removeProperty("home");
|
||||
@@ -175,30 +200,159 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
logger.log(Level.INFO, "File: "+file.toString());
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersToNewDefaultHome", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersPowerToolsFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersPowerToolsFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
config.load();
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
|
||||
{
|
||||
if (entry.getValue() instanceof String)
|
||||
{
|
||||
List<String> temp = new ArrayList<String>();
|
||||
temp.add((String)entry.getValue());
|
||||
((Map<Integer, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersPowerToolsFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void updateUsersHomesFormat()
|
||||
{
|
||||
if (doneFile.getBoolean("updateUsersHomesFormat", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File userdataFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdataFolder.exists() || !userdataFolder.isDirectory())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File[] userFiles = userdataFolder.listFiles();
|
||||
|
||||
for (File file : userFiles)
|
||||
{
|
||||
if (!file.isFile() || !file.getName().endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final EssentialsConf config = new EssentialsConf(file);
|
||||
try
|
||||
{
|
||||
|
||||
config.load();
|
||||
if (config.hasProperty("home") && config.hasProperty("home.default"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final String defworld = (String)config.getProperty("home.default");
|
||||
final Location defloc = getFakeLocation(config, "home.worlds." + defworld);
|
||||
if (defloc != null)
|
||||
{
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
List<String> worlds = config.getKeys("home.worlds");
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
if (worlds == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (String world : worlds)
|
||||
{
|
||||
if (defworld.equalsIgnoreCase(world))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
loc = getFakeLocation(config, "home.worlds." + world);
|
||||
if (loc == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName != null && !worldName.isEmpty())
|
||||
{
|
||||
config.setProperty("homes." + worldName, loc);
|
||||
}
|
||||
}
|
||||
config.removeProperty("home");
|
||||
config.save();
|
||||
}
|
||||
|
||||
}
|
||||
catch (RuntimeException ex)
|
||||
{
|
||||
LOGGER.log(Level.INFO, "File: " + file.toString());
|
||||
throw ex;
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("updateUsersHomesFormat", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void moveUsersDataToUserdataFolder()
|
||||
{
|
||||
File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
final File usersFile = new File(ess.getDataFolder(), "users.yml");
|
||||
if (!usersFile.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
{
|
||||
User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
String nickname = usersConfig.getString(username + ".nickname");
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
if (nickname != null && !nickname.isEmpty() && !nickname.equals(username))
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
@@ -206,8 +360,9 @@ public class EssentialsUpgrade
|
||||
if (!user.hasHome())
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null) {
|
||||
final List<Object> vals = (List<Object>)usersConfig.getProperty(username + ".home");
|
||||
if (vals != null)
|
||||
{
|
||||
World world = ess.getServer().getWorlds().get(0);
|
||||
if (vals.size() > 5)
|
||||
{
|
||||
@@ -215,12 +370,12 @@ public class EssentialsUpgrade
|
||||
}
|
||||
if (world != null)
|
||||
{
|
||||
user.setHome(new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()), true);
|
||||
user.setHome("home", new Location(world,
|
||||
((Number)vals.get(0)).doubleValue(),
|
||||
((Number)vals.get(1)).doubleValue(),
|
||||
((Number)vals.get(2)).doubleValue(),
|
||||
((Number)vals.get(3)).floatValue(),
|
||||
((Number)vals.get(4)).floatValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -230,40 +385,56 @@ public class EssentialsUpgrade
|
||||
|
||||
private void convertWarps()
|
||||
{
|
||||
File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
final File warpsFolder = new File(ess.getDataFolder(), "warps");
|
||||
if (!warpsFolder.exists())
|
||||
{
|
||||
warpsFolder.mkdirs();
|
||||
}
|
||||
File[] listOfFiles = warpsFolder.listFiles();
|
||||
final File[] listOfFiles = warpsFolder.listFiles();
|
||||
if (listOfFiles.length >= 1)
|
||||
{
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (listOfFiles[i].isFile() && filename.endsWith(".dat"))
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(listOfFiles[i]));
|
||||
double x, y, z;
|
||||
float yaw, pitch;
|
||||
String worldName;
|
||||
try
|
||||
{
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
x = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
y = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
z = Double.parseDouble(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
yaw = Float.parseFloat(rx.readLine().trim());
|
||||
if (!rx.ready()) continue;
|
||||
if (!rx.ready())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
pitch = Float.parseFloat(rx.readLine().trim());
|
||||
worldName = rx.readLine();
|
||||
}
|
||||
finally {
|
||||
finally
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
World w = null;
|
||||
@@ -285,7 +456,7 @@ public class EssentialsUpgrade
|
||||
w = w1;
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(filename.substring(0, filename.length() - 4), loc);
|
||||
if (!listOfFiles[i].renameTo(new File(warpsFolder, filename + ".old")))
|
||||
{
|
||||
@@ -294,52 +465,52 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
final File warpFile = new File(ess.getDataFolder(), "warps.txt");
|
||||
if (warpFile.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
final BufferedReader rx = new BufferedReader(new FileReader(warpFile));
|
||||
try
|
||||
{
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
if (parts.length < 6)
|
||||
for (String[] parts = new String[0]; rx.ready(); parts = rx.readLine().split(":"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String name = parts[0];
|
||||
double x = Double.parseDouble(parts[1].trim());
|
||||
double y = Double.parseDouble(parts[2].trim());
|
||||
double z = Double.parseDouble(parts[3].trim());
|
||||
float yaw = Float.parseFloat(parts[4].trim());
|
||||
float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
if (parts.length < 6)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
continue;
|
||||
}
|
||||
final String name = parts[0];
|
||||
final double x = Double.parseDouble(parts[1].trim());
|
||||
final double y = Double.parseDouble(parts[2].trim());
|
||||
final double z = Double.parseDouble(parts[3].trim());
|
||||
final float yaw = Float.parseFloat(parts[4].trim());
|
||||
final float pitch = Float.parseFloat(parts[5].trim());
|
||||
if (name.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
World w = null;
|
||||
for (World world : ess.getServer().getWorlds())
|
||||
{
|
||||
if (world.getEnvironment() != World.Environment.NETHER)
|
||||
{
|
||||
w = world;
|
||||
break;
|
||||
}
|
||||
}
|
||||
final Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
Location loc = new Location(w, x, y, z, yaw, pitch);
|
||||
ess.getWarps().setWarp(name, loc);
|
||||
if (!warpFile.renameTo(new File(ess.getDataFolder(), "warps.txt.old")))
|
||||
{
|
||||
throw new Exception(Util.format("fileRenameError", "warps.txt"));
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
@@ -348,52 +519,60 @@ public class EssentialsUpgrade
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
LOGGER.log(Level.SEVERE, null, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void sanitizeAllUserFilenames()
|
||||
{
|
||||
File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (doneFile.getBoolean("sanitizeAllUserFilenames", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File usersFolder = new File(ess.getDataFolder(), "userdata");
|
||||
if (!usersFolder.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
File[] listOfFiles = usersFolder.listFiles();
|
||||
final File[] listOfFiles = usersFolder.listFiles();
|
||||
for (int i = 0; i < listOfFiles.length; i++)
|
||||
{
|
||||
String filename = listOfFiles[i].getName();
|
||||
final String filename = listOfFiles[i].getName();
|
||||
if (!listOfFiles[i].isFile() || !filename.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
final String sanitizedFilename = Util.sanitizeFileName(filename.substring(0, filename.length() - 4)) + ".yml";
|
||||
if (sanitizedFilename.equals(filename))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
|
||||
final File tmpFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename + ".tmp");
|
||||
final File newFile = new File(listOfFiles[i].getParentFile(), sanitizedFilename);
|
||||
if (!listOfFiles[i].renameTo(tmpFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.format("userdataMoveError", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (newFile.exists())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
|
||||
LOGGER.log(Level.WARNING, Util.format("duplicatedUserdata", filename, sanitizedFilename));
|
||||
continue;
|
||||
}
|
||||
if (!tmpFile.renameTo(newFile)) {
|
||||
logger.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
if (!tmpFile.renameTo(newFile))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, Util.format("userdataMoveBackError", sanitizedFilename, sanitizedFilename));
|
||||
}
|
||||
}
|
||||
doneFile.setProperty("sanitizeAllUserFilenames", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private World getFakeWorld(String name)
|
||||
|
||||
private World getFakeWorld(final String name)
|
||||
{
|
||||
File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
File worldDirectory = new File(bukkitDirectory, name);
|
||||
final File bukkitDirectory = ess.getDataFolder().getParentFile().getParentFile();
|
||||
final File worldDirectory = new File(bukkitDirectory, name);
|
||||
if (worldDirectory.exists() && worldDirectory.isDirectory())
|
||||
{
|
||||
return new FakeWorld(worldDirectory.getName(), World.Environment.NORMAL);
|
||||
@@ -401,6 +580,73 @@ public class EssentialsUpgrade
|
||||
return null;
|
||||
}
|
||||
|
||||
public Location getFakeLocation(EssentialsConf config, String path)
|
||||
{
|
||||
String worldName = config.getString((path != null ? path + "." : "") + "world");
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = getFakeWorld(worldName);
|
||||
if (world == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return new Location(world,
|
||||
config.getDouble((path != null ? path + "." : "") + "x", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "y", 0),
|
||||
config.getDouble((path != null ? path + "." : "") + "z", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "yaw", 0),
|
||||
(float)config.getDouble((path != null ? path + "." : "") + "pitch", 0));
|
||||
}
|
||||
|
||||
private void deleteOldItemsCsv()
|
||||
{
|
||||
if (doneFile.getBoolean("deleteOldItemsCsv", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
final File file = new File(ess.getDataFolder(), "items.csv");
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
final Set<BigInteger> oldconfigs = new HashSet<BigInteger>();
|
||||
oldconfigs.add(new BigInteger("66ec40b09ac167079f558d1099e39f10", 16)); // sep 1
|
||||
oldconfigs.add(new BigInteger("34284de1ead43b0bee2aae85e75c041d", 16)); // crlf
|
||||
oldconfigs.add(new BigInteger("c33bc9b8ee003861611bbc2f48eb6f4f", 16)); // jul 24
|
||||
oldconfigs.add(new BigInteger("6ff17925430735129fc2a02f830c1daa", 16)); // crlf
|
||||
|
||||
MessageDigest digest = ManagedFile.getDigest();
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
final DigestInputStream dis = new DigestInputStream(bis, digest);
|
||||
final byte[] buffer = new byte[1024];
|
||||
try
|
||||
{
|
||||
while (dis.read(buffer) != -1)
|
||||
{
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
dis.close();
|
||||
}
|
||||
|
||||
BigInteger hash = new BigInteger(1, digest.digest());
|
||||
if (oldconfigs.contains(hash) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
doneFile.setProperty("deleteOldItemsCsv", true);
|
||||
doneFile.save();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
if (!ess.getDataFolder().exists())
|
||||
@@ -416,5 +662,8 @@ public class EssentialsUpgrade
|
||||
updateUsersToNewDefaultHome();
|
||||
moveUsersDataToUserdataFolder();
|
||||
convertWarps();
|
||||
updateUsersPowerToolsFormat();
|
||||
updateUsersHomesFormat();
|
||||
deleteOldItemsCsv();
|
||||
}
|
||||
}
|
||||
|
@@ -12,16 +12,12 @@ import org.bukkit.World;
|
||||
import org.bukkit.block.Biome;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.LightningStrike;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Minecart;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.PoweredMinecart;
|
||||
import org.bukkit.entity.StorageMinecart;
|
||||
import org.bukkit.generator.BlockPopulator;
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -404,5 +400,41 @@ public class FakeWorld implements World
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean unloadChunk(Chunk chunk)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMaxHeight()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getKeepSpawnInMemory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setKeepSpawnInMemory(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAutoSave()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAutoSave(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,12 +1,12 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
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.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
public interface IEssentials extends Plugin
|
||||
@@ -23,11 +23,11 @@ public interface IEssentials extends Plugin
|
||||
|
||||
World getWorld(String name);
|
||||
|
||||
int broadcastMessage(String name, String message);
|
||||
int broadcastMessage(IUser sender, String message);
|
||||
|
||||
ISettings getSettings();
|
||||
|
||||
CraftScheduler getScheduler();
|
||||
BukkitScheduler getScheduler();
|
||||
|
||||
String[] getMotd(CommandSender sender, String def);
|
||||
|
||||
@@ -53,15 +53,13 @@ public interface IEssentials extends Plugin
|
||||
|
||||
int scheduleSyncRepeatingTask(final Runnable run, long delay, long period);
|
||||
|
||||
BanWorkaround getBans();
|
||||
|
||||
TNTExplodeListener getTNTListener();
|
||||
|
||||
IPermissionsHandler getPermissionsHandler();
|
||||
PermissionsHandler getPermissionsHandler();
|
||||
|
||||
void showError(final CommandSender sender, final Throwable exception, final String commandLabel);
|
||||
|
||||
Map<String, User> getAllUsers();
|
||||
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
}
|
||||
|
@@ -72,6 +72,8 @@ public interface ISettings extends IConf
|
||||
boolean getReclaimSetting();
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
int getMultipleHomes();
|
||||
|
||||
boolean getSortListByGroups();
|
||||
|
||||
@@ -107,8 +109,6 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
boolean showNonEssCommandsInHelp();
|
||||
|
||||
boolean spawnIfNoHome();
|
||||
@@ -129,5 +129,15 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
public boolean useBukkitPermissions();
|
||||
boolean useBukkitPermissions();
|
||||
|
||||
boolean addPrefixSuffix();
|
||||
|
||||
boolean isUpdateEnabled();
|
||||
|
||||
long getAutoAfk();
|
||||
|
||||
long getAutoAfkKick();
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
}
|
||||
|
@@ -22,7 +22,7 @@ public interface IUser
|
||||
boolean isAuthorized(String node);
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd);
|
||||
|
||||
|
||||
boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix);
|
||||
|
||||
void setLastTeleportTimestamp(long time);
|
||||
@@ -45,11 +45,15 @@ public interface IUser
|
||||
|
||||
void setLastLocation();
|
||||
|
||||
Location getHome(Location location);
|
||||
Location getHome(String name) throws Exception;
|
||||
|
||||
Location getHome(Location loc) throws Exception;
|
||||
|
||||
String getName();
|
||||
|
||||
InetSocketAddress getAddress();
|
||||
|
||||
String getDisplayName();
|
||||
|
||||
boolean isHidden();
|
||||
}
|
||||
|
@@ -3,7 +3,6 @@ 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;
|
||||
@@ -130,7 +129,7 @@ public final class InventoryWorkaround
|
||||
// More than a single stack!
|
||||
if (item.getAmount() > item.getType().getMaxStackSize())
|
||||
{
|
||||
cinventory.setItem(firstFree, new CraftItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
cinventory.setItem(firstFree, new ItemStack(item.getTypeId(), item.getType().getMaxStackSize(), item.getDurability()));
|
||||
item.setAmount(item.getAmount() - item.getType().getMaxStackSize());
|
||||
}
|
||||
else
|
||||
|
@@ -1,14 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileReader;
|
||||
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 java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -17,108 +11,45 @@ public class ItemDb implements IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
|
||||
public ItemDb(IEssentials ess)
|
||||
public ItemDb(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
file = new ManagedFile("items.csv", 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>();
|
||||
private final transient ManagedFile file;
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
final File file = new File(ess.getDataFolder(), "items.csv");
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
final InputStream res = ItemDb.class.getResourceAsStream("/items.csv");
|
||||
FileWriter tx = null;
|
||||
try
|
||||
{
|
||||
tx = new FileWriter(file);
|
||||
for (int i = 0; (i = res.read()) > 0;)
|
||||
{
|
||||
tx.write(i);
|
||||
}
|
||||
tx.flush();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
return;
|
||||
}
|
||||
finally
|
||||
{
|
||||
try
|
||||
{
|
||||
res.close();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
try
|
||||
{
|
||||
if (tx != null)
|
||||
{
|
||||
tx.close();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
final List<String> lines = file.getLines();
|
||||
|
||||
if (lines.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
BufferedReader rx = null;
|
||||
try
|
||||
{
|
||||
rx = new BufferedReader(new FileReader(file));
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
durabilities.clear();
|
||||
items.clear();
|
||||
|
||||
for (int i = 0; rx.ready(); i++)
|
||||
for (String line : lines)
|
||||
{
|
||||
line = line.trim().toLowerCase();
|
||||
if (line.length() > 0 && line.charAt(0) == '#')
|
||||
{
|
||||
try
|
||||
{
|
||||
final String line = rx.readLine().trim().toLowerCase();
|
||||
if (line.startsWith("#"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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", "items.csv", i));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (rx != null) {
|
||||
try
|
||||
{
|
||||
rx.close();
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
final String[] parts = line.split("[^a-z0-9]");
|
||||
if (parts.length < 2)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -163,6 +94,11 @@ public class ItemDb implements IConf
|
||||
metaData = durabilities.get(itemname);
|
||||
}
|
||||
}
|
||||
else if (Material.getMaterial(itemname) != null)
|
||||
{
|
||||
itemid = Material.getMaterial(itemname).getId();
|
||||
metaData = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.format("unknownItemName", id));
|
||||
|
@@ -31,7 +31,7 @@ public class Jail extends BlockListener implements IConf
|
||||
|
||||
public Location getJail(String jailName) throws Exception
|
||||
{
|
||||
if (config.getProperty(jailName.toLowerCase()) == null)
|
||||
if (jailName == null || config.getProperty(jailName.toLowerCase()) == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("jailNotExist"));
|
||||
}
|
||||
|
235
Essentials/src/com/earth2me/essentials/ManagedFile.java
Normal file
235
Essentials/src/com/earth2me/essentials/ManagedFile.java
Normal file
@@ -0,0 +1,235 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import java.io.BufferedInputStream;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStreamWriter;
|
||||
import java.math.BigInteger;
|
||||
import java.security.DigestInputStream;
|
||||
import java.security.DigestOutputStream;
|
||||
import java.security.MessageDigest;
|
||||
import java.security.NoSuchAlgorithmException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
|
||||
|
||||
public class ManagedFile
|
||||
{
|
||||
private final static int BUFFERSIZE = 1024 * 8;
|
||||
private final transient File file;
|
||||
|
||||
public ManagedFile(final String filename, final IEssentials ess)
|
||||
{
|
||||
file = new File(ess.getDataFolder(), filename);
|
||||
|
||||
if (file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
if (checkForVersion(file, ess.getDescription().getVersion()) && !file.delete())
|
||||
{
|
||||
throw new IOException("Could not delete file " + file.toString());
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
if (!file.exists())
|
||||
{
|
||||
try
|
||||
{
|
||||
copyResourceAscii("/" + filename, file);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, Util.i18n("itemsCsvNotLoaded"), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void copyResourceAscii(final String resourceName, final File file) throws IOException
|
||||
{
|
||||
final InputStreamReader reader = new InputStreamReader(ManagedFile.class.getResourceAsStream(resourceName));
|
||||
try
|
||||
{
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestOutputStream digestStream = new DigestOutputStream(new FileOutputStream(file), digest);
|
||||
try
|
||||
{
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(digestStream);
|
||||
try
|
||||
{
|
||||
final char[] buffer = new char[BUFFERSIZE];
|
||||
do
|
||||
{
|
||||
final int length = reader.read(buffer);
|
||||
if (length >= 0)
|
||||
{
|
||||
writer.write(buffer, 0, length);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
writer.write("\n");
|
||||
writer.flush();
|
||||
final BigInteger hashInt = new BigInteger(1, digest.digest());
|
||||
digestStream.on(false);
|
||||
digestStream.write('#');
|
||||
digestStream.write(hashInt.toString(16).getBytes());
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean checkForVersion(final File file, final String version) throws IOException
|
||||
{
|
||||
if (file.length() < 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedInputStream bis = new BufferedInputStream(new FileInputStream(file));
|
||||
try
|
||||
{
|
||||
final byte[] buffer = new byte[(int)file.length()];
|
||||
int position = 0;
|
||||
do
|
||||
{
|
||||
final int length = bis.read(buffer, position, Math.min((int)file.length() - position, BUFFERSIZE));
|
||||
if (length < 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
position += length;
|
||||
}
|
||||
while (position < file.length());
|
||||
final ByteArrayInputStream bais = new ByteArrayInputStream(buffer);
|
||||
if (bais.skip(file.length() - 33) != file.length() - 33)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
final BufferedReader reader = new BufferedReader(new InputStreamReader(bais));
|
||||
try
|
||||
{
|
||||
String hash = reader.readLine();
|
||||
if (hash.matches("#[a-f0-9]{32}"))
|
||||
{
|
||||
hash = hash.substring(1);
|
||||
bais.reset();
|
||||
final String versionline = reader.readLine();
|
||||
if (versionline.matches("#version: .+"))
|
||||
{
|
||||
final String versioncheck = versionline.substring(10);
|
||||
if (!versioncheck.equalsIgnoreCase(version))
|
||||
{
|
||||
bais.reset();
|
||||
final MessageDigest digest = getDigest();
|
||||
final DigestInputStream digestStream = new DigestInputStream(bais, digest);
|
||||
try
|
||||
{
|
||||
final byte[] bytes = new byte[(int)file.length() - 33];
|
||||
digestStream.read(bytes);
|
||||
final BigInteger correct = new BigInteger(hash, 16);
|
||||
final BigInteger test = new BigInteger(1, digest.digest());
|
||||
if (correct.equals(test))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Bukkit.getLogger().warning("File " + file.toString() + " has been modified by user and file version differs, please update the file manually.");
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
digestStream.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
finally
|
||||
{
|
||||
bis.close();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static MessageDigest getDigest() throws IOException
|
||||
{
|
||||
try
|
||||
{
|
||||
return MessageDigest.getInstance("MD5");
|
||||
}
|
||||
catch (NoSuchAlgorithmException ex)
|
||||
{
|
||||
throw new IOException(ex);
|
||||
}
|
||||
}
|
||||
|
||||
public List<String> getLines()
|
||||
{
|
||||
try
|
||||
{
|
||||
final BufferedReader reader = new BufferedReader(new FileReader(file));
|
||||
try
|
||||
{
|
||||
final List<String> lines = new ArrayList<String>();
|
||||
do
|
||||
{
|
||||
final String line = reader.readLine();
|
||||
if (line == null)
|
||||
{
|
||||
break;
|
||||
}
|
||||
else
|
||||
{
|
||||
lines.add(line);
|
||||
}
|
||||
}
|
||||
while (true);
|
||||
return lines;
|
||||
}
|
||||
finally
|
||||
{
|
||||
reader.close();
|
||||
}
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
}
|
@@ -27,7 +27,10 @@ public enum Mob
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
MONSTER("Monster", Enemies.ENEMY, CreatureType.MONSTER),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF);
|
||||
WOLF("Wolf", Enemies.NEUTRAL, CreatureType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, CreatureType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, CreatureType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, CreatureType.SILVERFISH);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
@@ -86,6 +89,9 @@ public enum Mob
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public CreatureType getType () {
|
||||
return bukkitType;
|
||||
}
|
||||
|
||||
public static class MobException extends Exception
|
||||
{
|
||||
|
@@ -7,6 +7,7 @@ import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import org.bukkit.Achievement;
|
||||
import org.bukkit.Effect;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Instrument;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
@@ -24,6 +25,7 @@ import org.bukkit.entity.Vehicle;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
@@ -38,22 +40,24 @@ public class OfflinePlayer implements Player
|
||||
private Location location = new Location(null, 0, 0, 0, 0, 0);
|
||||
private World world;
|
||||
private UUID uniqueId = UUID.randomUUID();
|
||||
private org.bukkit.OfflinePlayer base;
|
||||
|
||||
public OfflinePlayer(String name, IEssentials ess)
|
||||
{
|
||||
this.name = name;
|
||||
this.ess = ess;
|
||||
this.world = ess.getServer().getWorlds().get(0);
|
||||
this.base = ess.getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public boolean isOnline()
|
||||
{
|
||||
return false;
|
||||
return base.isOnline();
|
||||
}
|
||||
|
||||
public boolean isOp()
|
||||
{
|
||||
return false;
|
||||
return base.isOp();
|
||||
}
|
||||
|
||||
public void sendMessage(String string)
|
||||
@@ -575,5 +579,139 @@ public class OfflinePlayer implements Player
|
||||
|
||||
public void setOp(boolean bln)
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -17,16 +17,6 @@ public class PlayerExtension extends PlayerWrapper
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
public boolean isBanned()
|
||||
{
|
||||
return ess.getBans().isNameBanned(this.getName());
|
||||
}
|
||||
|
||||
public boolean isIpBanned()
|
||||
{
|
||||
return ess.getBans().isIpBanned(getAddress().getAddress().getHostAddress());
|
||||
}
|
||||
|
||||
public float getCorrectedYaw()
|
||||
{
|
||||
float angle = (getLocation().getYaw() - 90.0f) % 360.0f;
|
||||
|
@@ -7,6 +7,7 @@ import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.inventory.*;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
@@ -405,20 +406,6 @@ public class PlayerWrapper implements Player
|
||||
return base.eject();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Location lctn)
|
||||
{
|
||||
base.teleportTo(lctn);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Deprecated
|
||||
public void teleportTo(Entity entity)
|
||||
{
|
||||
base.teleportTo(entity);
|
||||
}
|
||||
|
||||
public void saveData()
|
||||
{
|
||||
base.saveData();
|
||||
@@ -624,4 +611,137 @@ public class PlayerWrapper implements Player
|
||||
{
|
||||
base.setOp(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMap(MapView mv)
|
||||
{
|
||||
base.sendMap(mv);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBanned()
|
||||
{
|
||||
return base.isBanned();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBanned(boolean bln)
|
||||
{
|
||||
base.setBanned(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWhitelisted()
|
||||
{
|
||||
return base.isWhitelisted();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setWhitelisted(boolean bln)
|
||||
{
|
||||
base.setWhitelisted(bln);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameMode getGameMode()
|
||||
{
|
||||
return base.getGameMode();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setGameMode(GameMode gm)
|
||||
{
|
||||
base.setGameMode(gm);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getExperience()
|
||||
{
|
||||
return base.getExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExperience(int i)
|
||||
{
|
||||
base.setExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getLevel()
|
||||
{
|
||||
return base.getLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLevel(int i)
|
||||
{
|
||||
base.setLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getTotalExperience()
|
||||
{
|
||||
return base.getTotalExperience();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setTotalExperience(int i)
|
||||
{
|
||||
base.setTotalExperience(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getExhaustion()
|
||||
{
|
||||
return base.getExhaustion();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setExhaustion(float f)
|
||||
{
|
||||
base.setExhaustion(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public float getSaturation()
|
||||
{
|
||||
return base.getSaturation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSaturation(float f)
|
||||
{
|
||||
base.setSaturation(f);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getFoodLevel()
|
||||
{
|
||||
return base.getFoodLevel();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFoodLevel(int i)
|
||||
{
|
||||
base.setFoodLevel(i);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getBedSpawnLocation()
|
||||
{
|
||||
return base.getBedSpawnLocation();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSprinting()
|
||||
{
|
||||
return base.isSprinting();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setSprinting(boolean bln)
|
||||
{
|
||||
base.setSprinting(bln);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -30,6 +30,12 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("respawn-at-home", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getMultipleHomes()
|
||||
{
|
||||
return config.getInt("multiple-homes", 5);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getBedSetsHome()
|
||||
@@ -468,4 +474,33 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getBoolean("use-bukkit-permissions", false);
|
||||
}
|
||||
|
||||
public boolean addPrefixSuffix()
|
||||
{
|
||||
return config.getBoolean("add-prefix-suffix", ess.getServer().getPluginManager().isPluginEnabled("EssentialsChat"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("update-check", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfk()
|
||||
{
|
||||
return config.getLong("auto-afk", 300);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getAutoAfkKick()
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
}
|
||||
|
@@ -4,6 +4,8 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import net.minecraft.server.ChunkPosition;
|
||||
import net.minecraft.server.Packet60Explosion;
|
||||
import org.bukkit.Location;
|
||||
@@ -52,6 +54,7 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
try {
|
||||
final Set<ChunkPosition> set = new HashSet<ChunkPosition>(event.blockList().size());
|
||||
final Player[] players = ess.getServer().getOnlinePlayers();
|
||||
final List<ChunkPosition> blocksUnderPlayers = new ArrayList<ChunkPosition>(players.length);
|
||||
@@ -72,6 +75,9 @@ public class TNTExplodeListener extends EntityListener implements Runnable
|
||||
}
|
||||
}
|
||||
((CraftServer)ess.getServer()).getHandle().sendPacketNearby(loc.getX(), loc.getY(), loc.getZ(), 64.0, ((CraftWorld)loc.getWorld()).getHandle().worldProvider.dimension, new Packet60Explosion(loc.getX(), loc.getY(), loc.getZ(), 3.0F, set));
|
||||
} catch (Throwable ex) {
|
||||
Logger.getLogger("Minecraft").log(Level.SEVERE, null, ex);
|
||||
}
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@@ -10,6 +11,8 @@ 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;
|
||||
@@ -57,9 +60,9 @@ public class Teleport implements Runnable
|
||||
this.started = System.currentTimeMillis();
|
||||
this.delay = delay;
|
||||
this.health = user.getHealth();
|
||||
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.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 +75,9 @@ public class Teleport implements Runnable
|
||||
cancel();
|
||||
return;
|
||||
}
|
||||
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
|
||||
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);
|
||||
@@ -92,7 +95,7 @@ public class Teleport implements Runnable
|
||||
user.sendMessage(Util.i18n("teleportationCommencing"));
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
now(teleportTarget);
|
||||
if (chargeFor != null)
|
||||
{
|
||||
@@ -229,7 +232,7 @@ public class Teleport implements Runnable
|
||||
cooldown(false);
|
||||
now(new Target(loc));
|
||||
}
|
||||
|
||||
|
||||
public void now(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
cooldown(false);
|
||||
@@ -256,24 +259,12 @@ public class Teleport implements Runnable
|
||||
back(null);
|
||||
}
|
||||
|
||||
public void home(Trade chargeFor) throws Exception
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
{
|
||||
home(user, chargeFor);
|
||||
}
|
||||
|
||||
public void home(IUser user, Trade chargeFor) throws Exception
|
||||
{
|
||||
Location loc = user.getHome(this.user.getLocation());
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
respawn(ess.getSpawn(), chargeFor);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(user == this.user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor);
|
||||
}
|
||||
|
@@ -4,47 +4,59 @@ import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.register.payment.Method;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
private boolean justPortaled = false;
|
||||
private CommandSender replyTo = null;
|
||||
private User teleportRequester;
|
||||
private boolean teleportRequestHere;
|
||||
private final Teleport teleport;
|
||||
private long lastActivity;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient final Teleport teleport;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient boolean godStateBeforeAfk;
|
||||
private transient Location afkPosition;
|
||||
|
||||
User(Player base, IEssentials ess)
|
||||
User(final Player base, final IEssentials ess)
|
||||
{
|
||||
super(base, ess);
|
||||
teleport = new Teleport(this, ess);
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
|
||||
User update(Player base)
|
||||
User update(final Player base)
|
||||
{
|
||||
setBase(base);
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd)
|
||||
{
|
||||
return isAuthorized(cmd, "essentials.");
|
||||
}
|
||||
|
||||
public boolean isAuthorized(IEssentialsCommand cmd, String permissionPrefix)
|
||||
@Override
|
||||
public boolean isAuthorized(final IEssentialsCommand cmd, final String permissionPrefix)
|
||||
{
|
||||
return isAuthorized(permissionPrefix + (cmd.getName().equals("r") ? "msg" : cmd.getName()));
|
||||
}
|
||||
|
||||
public boolean isAuthorized(String node)
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
@@ -55,16 +67,16 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(this, node);
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar now = new GregorianCalendar();
|
||||
if (getLastHealTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getHealCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
final double cooldown = ess.getSettings().getHealCooldown();
|
||||
final Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(getLastHealTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
@@ -76,12 +88,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setLastHealTimestamp(now.getTimeInMillis());
|
||||
}
|
||||
|
||||
public void giveMoney(double value)
|
||||
@Override
|
||||
public void giveMoney(final double value)
|
||||
{
|
||||
giveMoney(value, null);
|
||||
}
|
||||
|
||||
public void giveMoney(double value, CommandSender initiator)
|
||||
public void giveMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
@@ -91,35 +104,36 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
sendMessage(Util.format("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
initiator.sendMessage(Util.format("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public void payUser(User reciever, double value) throws Exception
|
||||
public void payUser(final User reciever, final double value) throws Exception
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (!canAfford(value))
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
else
|
||||
if (canAfford(value))
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(Util.format("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(Util.format("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("notEnoughMoney"));
|
||||
}
|
||||
}
|
||||
|
||||
public void takeMoney(double value)
|
||||
@Override
|
||||
public void takeMoney(final double value)
|
||||
{
|
||||
takeMoney(value, null);
|
||||
}
|
||||
|
||||
public void takeMoney(double value, CommandSender initiator)
|
||||
public void takeMoney(final double value, final CommandSender initiator)
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
@@ -129,13 +143,13 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
sendMessage(Util.format("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage((Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName())));
|
||||
initiator.sendMessage(Util.format("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
||||
public boolean canAfford(double cost)
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
double mon = getMoney();
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
}
|
||||
|
||||
@@ -149,34 +163,37 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return justPortaled;
|
||||
}
|
||||
|
||||
public void setJustPortaled(boolean value)
|
||||
public void setJustPortaled(final boolean value)
|
||||
{
|
||||
justPortaled = value;
|
||||
}
|
||||
|
||||
public void setReplyTo(CommandSender user)
|
||||
@Override
|
||||
public void setReplyTo(final CommandSender user)
|
||||
{
|
||||
replyTo = user;
|
||||
}
|
||||
|
||||
@Override
|
||||
public CommandSender getReplyTo()
|
||||
{
|
||||
return replyTo;
|
||||
}
|
||||
|
||||
public int compareTo(User t)
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(t.getDisplayName()));
|
||||
return ChatColor.stripColor(this.getDisplayName()).compareToIgnoreCase(ChatColor.stripColor(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o)
|
||||
public boolean equals(final Object object)
|
||||
{
|
||||
if (!(o instanceof User))
|
||||
if (!(object instanceof User))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)o).getDisplayName()));
|
||||
return ChatColor.stripColor(this.getDisplayName()).equalsIgnoreCase(ChatColor.stripColor(((User)object).getDisplayName()));
|
||||
|
||||
}
|
||||
|
||||
@@ -186,27 +203,33 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return ChatColor.stripColor(this.getDisplayName()).hashCode();
|
||||
}
|
||||
|
||||
public Boolean canSpawnItem(int itemId)
|
||||
public Boolean canSpawnItem(final int itemId)
|
||||
{
|
||||
return !ess.getSettings().itemSpawnBlacklist().contains(itemId);
|
||||
}
|
||||
|
||||
public Location getHome() throws Exception
|
||||
{
|
||||
return getHome(getHomes().get(0));
|
||||
}
|
||||
|
||||
public void setHome()
|
||||
{
|
||||
setHome(getLocation(), true);
|
||||
setHome("home", getLocation());
|
||||
}
|
||||
|
||||
public void setHome(boolean defaultHome)
|
||||
public void setHome(final String name)
|
||||
{
|
||||
setHome(getLocation(), defaultHome);
|
||||
setHome(name, getLocation());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setLastLocation()
|
||||
{
|
||||
setLastLocation(getLocation());
|
||||
}
|
||||
|
||||
public void requestTeleport(User player, boolean here)
|
||||
public void requestTeleport(final User player, final boolean here)
|
||||
{
|
||||
teleportRequester = player;
|
||||
teleportRequestHere = here;
|
||||
@@ -246,11 +269,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
|
||||
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());
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
|
||||
nickname.insert(0, prefix);
|
||||
nickname.append(suffix);
|
||||
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();
|
||||
}
|
||||
@@ -260,14 +290,14 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return teleport;
|
||||
}
|
||||
|
||||
public long getLastActivity()
|
||||
public long getLastOnlineActivity()
|
||||
{
|
||||
return lastActivity;
|
||||
return lastOnlineActivity;
|
||||
}
|
||||
|
||||
public void setLastActivity(long timestamp)
|
||||
public void setLastOnlineActivity(final long timestamp)
|
||||
{
|
||||
lastActivity = timestamp;
|
||||
lastOnlineActivity = timestamp;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -277,12 +307,12 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
return account.balance();
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@@ -293,18 +323,18 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMoney(double value)
|
||||
public void setMoney(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod())
|
||||
{
|
||||
try
|
||||
{
|
||||
Method method = ess.getPaymentMethod().getMethod();
|
||||
final Method method = ess.getPaymentMethod().getMethod();
|
||||
if (!method.hasAccount(this.getName()))
|
||||
{
|
||||
throw new Exception();
|
||||
}
|
||||
Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
final Method.MethodAccount account = ess.getPaymentMethod().getMethod().getAccount(this.getName());
|
||||
account.set(value);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
@@ -315,16 +345,28 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAfk(boolean set)
|
||||
public void setAfk(final boolean set)
|
||||
{
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : set);
|
||||
if (set && !isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
godStateBeforeAfk = isGodModeEnabled();
|
||||
setGodModeEnabled(true);
|
||||
}
|
||||
if (!set && isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
setGodModeEnabled(godStateBeforeAfk);
|
||||
}
|
||||
if (set && !isAfk()) {
|
||||
afkPosition = getLocation();
|
||||
}
|
||||
super.setAfk(set);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleAfk()
|
||||
{
|
||||
boolean now = super.toggleAfk();
|
||||
final boolean now = super.toggleAfk();
|
||||
this.setSleepingIgnored(this.isAuthorized("essentials.sleepingignored") ? true : now);
|
||||
return now;
|
||||
}
|
||||
@@ -334,8 +376,101 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return hidden;
|
||||
}
|
||||
|
||||
public void setHidden(boolean hidden)
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public void checkJailTimeout(final long currentTime)
|
||||
{
|
||||
if (getJailTimeout() > 0 && getJailTimeout() < currentTime && isJailed())
|
||||
{
|
||||
setJailTimeout(0);
|
||||
setJailed(false);
|
||||
sendMessage(Util.i18n("haveBeenReleased"));
|
||||
setJail(null);
|
||||
try
|
||||
{
|
||||
getTeleport().back();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void checkMuteTimeout(final long currentTime)
|
||||
{
|
||||
if (getMuteTimeout() > 0 && getMuteTimeout() < currentTime && isMuted())
|
||||
{
|
||||
setMuteTimeout(0);
|
||||
sendMessage(Util.i18n("canTalkAgain"));
|
||||
setMuted(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void checkBanTimeout(final long currentTime)
|
||||
{
|
||||
if (getBanTimeout() > 0 && getBanTimeout() < currentTime && isBanned())
|
||||
{
|
||||
setBanTimeout(0);
|
||||
setBanned(false);
|
||||
}
|
||||
}
|
||||
|
||||
public void updateActivity(final boolean broadcast)
|
||||
{
|
||||
if (isAfk())
|
||||
{
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
ess.broadcastMessage(this, Util.format("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
lastActivity = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public void checkActivity()
|
||||
{
|
||||
final long autoafkkick = ess.getSettings().getAutoAfkKick();
|
||||
if (autoafkkick > 0 && lastActivity + autoafkkick * 1000 < System.currentTimeMillis()
|
||||
&& !isHidden() && !isAuthorized("essentials.kick.exempt") && !isAuthorized("essentials.afk.kickexempt"))
|
||||
{
|
||||
final String kickReason = Util.format("autoAfkKickReason", autoafkkick / 60.0);
|
||||
kickPlayer(kickReason);
|
||||
|
||||
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
if (user.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
player.sendMessage(Util.format("playerKicked", Console.NAME, getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
final long autoafk = ess.getSettings().getAutoAfk();
|
||||
if (!isAfk() && autoafk > 0 && lastActivity + autoafk * 1000 < System.currentTimeMillis())
|
||||
{
|
||||
setAfk(true);
|
||||
if (!isHidden()) {
|
||||
ess.broadcastMessage(this, Util.format("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Location getAfkPosition()
|
||||
{
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled()) {
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
}
|
||||
|
@@ -1,15 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -36,7 +35,8 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.load();
|
||||
money = _getMoney();
|
||||
unlimited = _getUnlimited();
|
||||
powertools = getPowertools();
|
||||
powertools = _getPowertools();
|
||||
homes = _getHomes();
|
||||
lastLocation = _getLastLocation();
|
||||
lastTeleportTimestamp = _getLastTeleportTimestamp();
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
@@ -57,6 +57,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
geolocation = _getGeoLocation();
|
||||
isSocialSpyEnabled = _isSocialSpyEnabled();
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -89,6 +90,89 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("money", value);
|
||||
config.save();
|
||||
}
|
||||
private Map<String, Object> homes;
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
{
|
||||
Location loc = config.getLocation("homes." + name, getServer());
|
||||
if (loc == null)
|
||||
{
|
||||
try
|
||||
{
|
||||
loc = config.getLocation("homes." + getHomes().get(Integer.parseInt(name) - 1), getServer());
|
||||
}
|
||||
catch (IndexOutOfBoundsException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
return loc;
|
||||
}
|
||||
|
||||
public Location getHome(Location world) throws Exception
|
||||
{
|
||||
Location loc;
|
||||
for (String home : getHomes())
|
||||
{
|
||||
loc = config.getLocation("homes." + home, getServer());
|
||||
if (world.getWorld() == loc.getWorld())
|
||||
{
|
||||
return loc;
|
||||
}
|
||||
|
||||
}
|
||||
loc = config.getLocation("homes." + getHomes().get(0), getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
List<String> list = new ArrayList(homes.keySet());
|
||||
return list;
|
||||
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
{
|
||||
homes.put(name, loc);
|
||||
config.setProperty("homes." + name, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public void delHome(String name) throws Exception
|
||||
{
|
||||
if (getHome(name) != null)
|
||||
{
|
||||
homes.remove(name);
|
||||
config.removeProperty("homes." + name);
|
||||
config.save();
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasHome()
|
||||
{
|
||||
@@ -99,40 +183,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return false;
|
||||
}
|
||||
|
||||
public Location getHome(Location location)
|
||||
{
|
||||
if (!hasHome())
|
||||
{
|
||||
return null;
|
||||
}
|
||||
World world = location.getWorld();
|
||||
String worldHome = "home.worlds." + world.getName().toLowerCase();
|
||||
if (!config.hasProperty(worldHome))
|
||||
{
|
||||
String defaultWorld = config.getString("home.default");
|
||||
worldHome = "home.worlds." + defaultWorld;
|
||||
}
|
||||
Location loc = config.getLocation(worldHome, getServer());
|
||||
return loc;
|
||||
}
|
||||
|
||||
public void setHome(Location loc, boolean b)
|
||||
{
|
||||
String worldName = loc.getWorld().getName().toLowerCase();
|
||||
if (worldName == null || worldName.isEmpty())
|
||||
{
|
||||
logger.log(Level.WARNING, Util.i18n("emptyWorldName"));
|
||||
return;
|
||||
}
|
||||
if (b || !config.hasProperty("home.default"))
|
||||
{
|
||||
config.setProperty("home.default", worldName);
|
||||
}
|
||||
|
||||
config.setProperty("home.worlds." + worldName, loc);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
@@ -173,46 +223,66 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, String> powertools;
|
||||
private Map<Integer, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, String> getPowertools()
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
{
|
||||
return (Map<Integer, String>)o;
|
||||
return (Map<Integer, Object>)o;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, String>();
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public String getPowertool(ItemStack stack)
|
||||
public void clearAllPowertools() {
|
||||
powertools.clear();
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return powertools.get(stack.getTypeId());
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, String command)
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (command == null || command.isEmpty())
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), command);
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean hasPowerTools()
|
||||
{
|
||||
return powertools.size() > 0;
|
||||
}
|
||||
|
||||
private Location lastLocation;
|
||||
|
||||
private Location _getLastLocation()
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
try
|
||||
{
|
||||
return config.getLocation("lastlocation", getServer());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Location getLastLocation()
|
||||
@@ -709,4 +779,31 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("npc", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
private boolean arePowerToolsEnabled;
|
||||
|
||||
public boolean arePowerToolsEnabled()
|
||||
{
|
||||
return arePowerToolsEnabled;
|
||||
}
|
||||
|
||||
public void setPowerToolsEnabled(boolean set)
|
||||
{
|
||||
arePowerToolsEnabled = set;
|
||||
config.setProperty("powertoolsenabled", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean togglePowerToolsEnabled()
|
||||
{
|
||||
boolean ret = !arePowerToolsEnabled();
|
||||
setPowerToolsEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
private boolean _arePowerToolsEnabled()
|
||||
{
|
||||
return config.getBoolean("powertoolsenabled", true);
|
||||
}
|
||||
|
||||
}
|
||||
|
119
Essentials/src/com/earth2me/essentials/UserMap.java
Normal file
119
Essentials/src/com/earth2me/essentials/UserMap.java
Normal file
@@ -0,0 +1,119 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.google.common.base.Function;
|
||||
import com.google.common.collect.ComputationException;
|
||||
import com.google.common.collect.MapMaker;
|
||||
import java.io.File;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentMap;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class UserMap implements Function<String, User>, IConf
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient ConcurrentMap<String, User> users = new MapMaker().softValues().makeComputingMap(this);
|
||||
|
||||
public UserMap(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
loadAllUsersAsync(ess);
|
||||
}
|
||||
|
||||
private void loadAllUsersAsync(final IEssentials ess)
|
||||
{
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final File userdir = new File(ess.getDataFolder(), "userdata");
|
||||
if (!userdir.exists())
|
||||
{
|
||||
return;
|
||||
}
|
||||
for (String string : userdir.list())
|
||||
{
|
||||
if (!string.endsWith(".yml"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String name = string.substring(0, string.length() - 4);
|
||||
try
|
||||
{
|
||||
users.get(name.toLowerCase());
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
// Ignore these
|
||||
}
|
||||
catch (ComputationException ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.INFO, "Failed to preload user "+name, ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean userExists(final String name)
|
||||
{
|
||||
return users.containsKey(name.toLowerCase());
|
||||
}
|
||||
|
||||
public User getUser(final String name) throws NullPointerException
|
||||
{
|
||||
return users.get(name.toLowerCase());
|
||||
}
|
||||
|
||||
@Override
|
||||
public User apply(final String name)
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
final File userFile = new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
if (userFile.exists())
|
||||
{
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reloadConfig()
|
||||
{
|
||||
for (User user : users.values())
|
||||
{
|
||||
user.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
||||
public void removeUser(final String name)
|
||||
{
|
||||
users.remove(name.toLowerCase());
|
||||
}
|
||||
|
||||
public Set<User> getAllUsers()
|
||||
{
|
||||
final Set<User> userSet = new HashSet<User>();
|
||||
for (String name : users.keySet())
|
||||
{
|
||||
userSet.add(users.get(name));
|
||||
}
|
||||
return userSet;
|
||||
}
|
||||
|
||||
public int getUniqueUsers()
|
||||
{
|
||||
return users.size();
|
||||
}
|
||||
}
|
@@ -14,9 +14,12 @@ import java.text.MessageFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Enumeration;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.MissingResourceException;
|
||||
import java.util.ResourceBundle;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
@@ -216,55 +219,93 @@ public class Util
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(Location loc) throws Exception
|
||||
// The player can stand inside these materials
|
||||
private static final Set<Integer> AIR_MATERIALS = new HashSet<Integer>();
|
||||
|
||||
static {
|
||||
AIR_MATERIALS.add(Material.AIR.getId());
|
||||
AIR_MATERIALS.add(Material.SAPLING.getId());
|
||||
AIR_MATERIALS.add(Material.POWERED_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DETECTOR_RAIL.getId());
|
||||
AIR_MATERIALS.add(Material.DEAD_BUSH.getId());
|
||||
AIR_MATERIALS.add(Material.RAILS.getId());
|
||||
AIR_MATERIALS.add(Material.YELLOW_FLOWER.getId());
|
||||
AIR_MATERIALS.add(Material.RED_ROSE.getId());
|
||||
AIR_MATERIALS.add(Material.RED_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.BROWN_MUSHROOM.getId());
|
||||
AIR_MATERIALS.add(Material.SEEDS.getId());
|
||||
AIR_MATERIALS.add(Material.SIGN_POST.getId());
|
||||
AIR_MATERIALS.add(Material.WALL_SIGN.getId());
|
||||
AIR_MATERIALS.add(Material.LADDER.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_WIRE.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TORCH.getId());
|
||||
AIR_MATERIALS.add(Material.SOIL.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
AIR_MATERIALS.add(Material.TRAP_DOOR.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.WOOD_PLATE.getId());
|
||||
AIR_MATERIALS.add(Material.IRON_DOOR_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.WOODEN_DOOR.getId());
|
||||
}
|
||||
|
||||
public static Location getSafeDestination(final Location loc) throws Exception
|
||||
{
|
||||
if (loc == null)
|
||||
if (loc == null || loc.getWorld() == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("destinationNotSet"));
|
||||
}
|
||||
World world = loc.getWorld();
|
||||
double x = Math.floor(loc.getX()) + 0.5;
|
||||
double y = Math.floor(loc.getY());
|
||||
double z = Math.floor(loc.getZ()) + 0.5;
|
||||
|
||||
final World world = loc.getWorld();
|
||||
int x = (int)Math.round(loc.getX());
|
||||
int y = (int)Math.round(loc.getY());
|
||||
int z = (int)Math.round(loc.getZ());
|
||||
|
||||
while (isBlockAboveAir(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y < 0.0D)
|
||||
y -= 1;
|
||||
if (y < 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("holeInFloor"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1.0D;
|
||||
if (y >= 110.0D)
|
||||
y += 1;
|
||||
if (y >= 127)
|
||||
{
|
||||
x += 1.0D;
|
||||
x += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y -= 1.0D;
|
||||
if (y <= 1.0D)
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
y = 110.0D;
|
||||
x += 1.0D;
|
||||
y = 127;
|
||||
x += 1;
|
||||
if (x - 32 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(Util.i18n("holeInFloor"));
|
||||
}
|
||||
}
|
||||
}
|
||||
return new Location(world, x, y, z, loc.getYaw(), loc.getPitch());
|
||||
return new Location(world, x + 0.5D, y, z + 0.5D, loc.getYaw(), loc.getPitch());
|
||||
}
|
||||
|
||||
private static boolean isBlockAboveAir(World world, double x, double y, double z)
|
||||
private static boolean isBlockAboveAir(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
return world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z)).getType() == Material.AIR;
|
||||
return AIR_MATERIALS.contains(world.getBlockAt(x, y - 1, z).getType().getId());
|
||||
}
|
||||
|
||||
public static boolean isBlockUnsafe(World world, double x, double y, double z)
|
||||
public static boolean isBlockUnsafe(final World world, final int x, final int y, final int z)
|
||||
{
|
||||
Block below = world.getBlockAt((int)Math.floor(x), (int)Math.floor(y - 1.0D), (int)Math.floor(z));
|
||||
final Block below = world.getBlockAt(x, y - 1, z);
|
||||
if (below.getType() == Material.LAVA || below.getType() == Material.STATIONARY_LAVA)
|
||||
{
|
||||
return true;
|
||||
@@ -275,8 +316,8 @@ public class Util
|
||||
return true;
|
||||
}
|
||||
|
||||
if ((world.getBlockAt((int)Math.floor(x), (int)Math.floor(y), (int)Math.floor(z)).getType() != Material.AIR)
|
||||
|| (world.getBlockAt((int)Math.floor(x), (int)Math.floor(y + 1.0D), (int)Math.floor(z)).getType() != Material.AIR))
|
||||
if ((!AIR_MATERIALS.contains(world.getBlockAt(x, y, z).getType().getId()))
|
||||
|| (!AIR_MATERIALS.contains(world.getBlockAt(x, y + 1, z).getType().getId())))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
@@ -294,7 +335,7 @@ public class Util
|
||||
return str;
|
||||
}
|
||||
|
||||
public static double roundDouble(double d)
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
}
|
||||
@@ -465,18 +506,40 @@ public class Util
|
||||
|
||||
public static String joinList(Object... list)
|
||||
{
|
||||
final StringBuilder buf = new StringBuilder();
|
||||
boolean first = true;
|
||||
return joinList(", ", list);
|
||||
}
|
||||
|
||||
public static String joinList(String seperator, Object... list)
|
||||
{
|
||||
StringBuilder buf = new StringBuilder();
|
||||
for (Object each : list)
|
||||
{
|
||||
if (!first)
|
||||
if (buf.length() > 0)
|
||||
{
|
||||
buf.append(", ");
|
||||
|
||||
buf.append(seperator);
|
||||
}
|
||||
|
||||
if(each instanceof List)
|
||||
{
|
||||
buf.append(joinList(seperator, ((List)each).toArray()));
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
buf.append(each.toString());
|
||||
}
|
||||
}
|
||||
first = false;
|
||||
buf.append(each);
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
|
||||
public static String capitalCase(String s)
|
||||
{
|
||||
return s.toUpperCase().charAt(0) + s.toLowerCase().substring(1);
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -35,9 +36,9 @@ public class Warps implements IConf
|
||||
return warpPoints.isEmpty();
|
||||
}
|
||||
|
||||
public Iterable<String> getWarpNames()
|
||||
public Collection<String> getWarpNames()
|
||||
{
|
||||
List<String> keys = new ArrayList<String>();
|
||||
final List<String> keys = new ArrayList<String>();
|
||||
for (StringIgnoreCase stringIgnoreCase : warpPoints.keySet())
|
||||
{
|
||||
keys.add(stringIgnoreCase.getString());
|
||||
|
@@ -60,7 +60,7 @@ public final class Economy
|
||||
{
|
||||
logger.log(Level.WARNING, Util.format("deleteFileError", config));
|
||||
}
|
||||
ess.getAllUsers().remove(name.toLowerCase());
|
||||
ess.getUserMap().removeUser(name);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -15,8 +15,6 @@ public class Commandafk extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
|
||||
if (args.length > 0 && user.isAuthorized("essentials.afk.others"))
|
||||
{
|
||||
User afkUser = ess.getUser(ess.getServer().matchPlayer(args[0]));
|
||||
@@ -35,13 +33,20 @@ public class Commandafk extends EssentialsCommand
|
||||
{
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsNotAway", user.getDisplayName()));
|
||||
//user.sendMessage(Util.i18n("markedAsNotAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsNotAway", user.getDisplayName()));
|
||||
}
|
||||
user.updateActivity(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("markedAsAway"));
|
||||
ess.broadcastMessage(user.getName(), Util.format("userIsAway", user.getDisplayName()));
|
||||
//user.sendMessage(Util.i18n("markedAsAway"));
|
||||
if (!user.isHidden())
|
||||
{
|
||||
ess.broadcastMessage(user, Util.format("userIsAway", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -17,9 +17,8 @@ public class Commandantioch extends EssentialsCommand
|
||||
@Override
|
||||
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.");
|
||||
ess.broadcastMessage(user, "...lobbest thou thy Holy Hand Grenade of Antioch towards thy foe,");
|
||||
ess.broadcastMessage(user, "who being naughty in My sight, shall snuff it.");
|
||||
|
||||
final Location loc = new TargetBlock(user).getTargetBlock().getLocation();
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
|
@@ -19,9 +19,8 @@ public class Commandbackup extends EssentialsCommand
|
||||
Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
return;
|
||||
throw new Exception();
|
||||
}
|
||||
charge(sender);
|
||||
backup.run();
|
||||
sender.sendMessage(Util.i18n("backupStarted"));
|
||||
}
|
||||
|
@@ -26,7 +26,6 @@ public class Commandbalance extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
double bal = (args.length < 1
|
||||
|| !(user.isAuthorized("essentials.balance.others")
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
|
@@ -39,7 +39,7 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
final Map<User, Double> balances = new HashMap<User, Double>();
|
||||
for (User u : ess.getAllUsers().values())
|
||||
for (User u : ess.getUserMap().getAllUsers())
|
||||
{
|
||||
balances.put(u, u.getMoney());
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -51,8 +52,17 @@ public class Commandban extends EssentialsCommand
|
||||
{
|
||||
banReason = Util.i18n("defaultBanReason");
|
||||
}
|
||||
player.setBanned(true);
|
||||
player.kickPlayer(banReason);
|
||||
ess.getBans().banByName(player.getName());
|
||||
server.broadcastMessage(Util.format("playerBanned", player.getName(), banReason));
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for(Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if(u.isAuthorized("essentials.ban.notify"))
|
||||
{
|
||||
p.sendMessage(Util.format("playerBanned", senderName, player.getName(), banReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -20,7 +20,7 @@ public class Commandbanip extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.getBans().banByIp(args[0]);
|
||||
ess.getServer().banIP(args[0]);
|
||||
sender.sendMessage(Util.i18n("banIpAddress"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.TargetBlock;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.TreeType;
|
||||
import com.earth2me.essentials.User;
|
||||
@@ -31,39 +32,20 @@ public class Commandbigtree extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
double x = user.getLocation().getX();
|
||||
double y = user.getLocation().getY();
|
||||
double z = user.getLocation().getZ();
|
||||
|
||||
// offset tree in direction player is facing
|
||||
final int r = (int)user.getCorrectedYaw();
|
||||
if (r < 68 || r > 292) // north
|
||||
final int[] ignore =
|
||||
{
|
||||
x -= 3.0D;
|
||||
}
|
||||
else if (r > 112 && r < 248) // south
|
||||
{
|
||||
x += 3.0D;
|
||||
}
|
||||
if (r > 22 && r < 158) // east
|
||||
{
|
||||
z -= 3.0D;
|
||||
}
|
||||
else if (r > 202 && r < 338) // west
|
||||
{
|
||||
z += 3.0D;
|
||||
}
|
||||
|
||||
final Location safeLocation = Util.getSafeDestination(new Location(user.getWorld(), x, y, z));
|
||||
8, 9
|
||||
};
|
||||
final Location loc = (new TargetBlock(user, 300, 0.2, ignore)).getTargetBlock().getLocation();
|
||||
final Location safeLocation = Util.getSafeDestination(loc);
|
||||
final boolean success = user.getWorld().generateTree(safeLocation, (TreeType)tree);
|
||||
if (success)
|
||||
{
|
||||
charge(user);
|
||||
user.sendMessage(Util.i18n("bigTreeSuccess"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.i18n("bigTreeFailure"));
|
||||
throw new Exception(Util.i18n("bigTreeFailure"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -15,15 +14,14 @@ public class Commandbroadcast 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();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
ess.broadcastMessage(sender instanceof Player ? ((Player)sender).getName() : Console.NAME,
|
||||
ess.broadcastMessage(null,
|
||||
Util.format("broadcast", getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
|
@@ -21,7 +21,6 @@ public class Commandburn extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setFireTicks(Integer.parseInt(args[1]) * 20);
|
||||
|
@@ -20,13 +20,13 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.clearinventory.others"))
|
||||
{
|
||||
//TODO: Fix fringe user match case.
|
||||
if (args[0].length() >= 3)
|
||||
{
|
||||
List<Player> online = server.matchPlayer(args[0]);
|
||||
|
||||
if (!online.isEmpty())
|
||||
{
|
||||
charge(user);
|
||||
for (Player p : online)
|
||||
{
|
||||
p.getInventory().clear();
|
||||
@@ -41,7 +41,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
Player p = server.getPlayer(args[0]);
|
||||
if (p != null)
|
||||
{
|
||||
charge(user);
|
||||
p.getInventory().clear();
|
||||
user.sendMessage(Util.format("inventoryClearedOthers", p.getDisplayName()));
|
||||
}
|
||||
@@ -53,7 +52,6 @@ public class Commandclearinventory extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
charge(user);
|
||||
user.getInventory().clear();
|
||||
user.sendMessage(Util.i18n("inventoryCleared"));
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ public class Commandcompass extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int r = (int)user.getCorrectedYaw();
|
||||
String dir;
|
||||
if (r < 23) dir = "N";
|
||||
|
@@ -0,0 +1,48 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commanddelhome extends EssentialsCommand
|
||||
{
|
||||
public Commanddelhome()
|
||||
{
|
||||
super("delhome");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
//Allowing both formats /delhome khobbits house | /delhome khobbits:house
|
||||
final String[] nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() != args[0].length())
|
||||
{
|
||||
args = nameParts;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
String name;
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else if (args.length > 1 && (user == null || user.isAuthorized("essentials.delhome.others")))
|
||||
{
|
||||
user = getPlayer(server, args, 0);
|
||||
name = args[1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
name = args[0];
|
||||
}
|
||||
user.delHome(name.toLowerCase());
|
||||
sender.sendMessage(Util.format("deleteHome", name));
|
||||
}
|
||||
}
|
@@ -16,7 +16,6 @@ public class Commanddeljail extends EssentialsCommand {
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getJail().delJail(args[0]);
|
||||
sender.sendMessage(Util.format("deleteJail", args[0]));
|
||||
}
|
||||
|
@@ -19,7 +19,6 @@ public class Commanddelwarp extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
charge(sender);
|
||||
ess.getWarps().delWarp(args[0]);
|
||||
sender.sendMessage(Util.format("deleteWarp", args[0]));
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ public class Commanddepth extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
int y = user.getLocation().getBlockY() - 63;
|
||||
if (y > 0)
|
||||
{
|
||||
|
@@ -102,7 +102,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
ess.reload();
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("essentialsReload", ess.getDescription().getVersion()));
|
||||
}
|
||||
|
||||
|
@@ -30,7 +30,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
charge(user);
|
||||
user.setFireTicks(0);
|
||||
user.sendMessage(Util.i18n("extinguish"));
|
||||
return;
|
||||
@@ -43,7 +42,6 @@ public class Commandext extends EssentialsCommand
|
||||
{
|
||||
for (Player p : server.matchPlayer(name))
|
||||
{
|
||||
charge(sender);
|
||||
p.setFireTicks(0);
|
||||
sender.sendMessage(Util.format("extinguishOthers", p.getDisplayName()));
|
||||
}
|
||||
|
@@ -17,7 +17,6 @@ public class Commandfireball extends EssentialsCommand
|
||||
@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);
|
||||
}
|
||||
|
@@ -16,7 +16,6 @@ public class Commandgc extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(Util.format("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
|
@@ -15,7 +15,6 @@ public class Commandgetpos extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
Location coords = user.getLocation();
|
||||
user.sendMessage("§7X: " + coords.getBlockX() + " (-North <-> +South)");
|
||||
user.sendMessage("§7Y: " + coords.getBlockY() + " (+Up <-> -Down)");
|
||||
|
@@ -16,6 +16,7 @@ public class Commandgive extends EssentialsCommand
|
||||
super("give");
|
||||
}
|
||||
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
@@ -35,8 +36,7 @@ public class Commandgive extends EssentialsCommand
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
}
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
@@ -45,13 +45,11 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
sender.sendMessage(ChatColor.RED + "You can't give air.");
|
||||
return;
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
}
|
||||
|
||||
User giveTo = getPlayer(server, args, 0);
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
charge(sender);
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
giveTo.getInventory().addItem(stack);
|
||||
giveTo.updateInventory();
|
||||
|
@@ -28,7 +28,6 @@ public class Commandgod extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(user);
|
||||
if (args.length > 0 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
|
@@ -25,7 +25,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
healOtherPlayers(server, user, args[0]);
|
||||
return;
|
||||
}
|
||||
@@ -34,7 +33,6 @@ public class Commandheal extends EssentialsCommand
|
||||
{
|
||||
user.healCooldown();
|
||||
}
|
||||
charge(user);
|
||||
user.setHealth(20);
|
||||
user.sendMessage(Util.i18n("heal"));
|
||||
}
|
||||
|
@@ -20,6 +20,9 @@ import java.util.logging.Level;
|
||||
|
||||
public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
private static final String DESCRIPTION = "description";
|
||||
private static final String PERMISSION = "permission";
|
||||
private static final String PERMISSIONS = "permissions";
|
||||
public final Yaml yaml = new Yaml(new SafeConstructor());
|
||||
|
||||
public Commandhelp()
|
||||
@@ -28,7 +31,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
int page = 1;
|
||||
String match = "";
|
||||
@@ -53,34 +56,32 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
List<String> lines = getHelpLines(user, match);
|
||||
if (lines.size() > 0)
|
||||
final List<String> lines = getHelpLines(user, match);
|
||||
if (lines.isEmpty())
|
||||
{
|
||||
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));
|
||||
}
|
||||
throw new Exception(Util.i18n("noHelpFound"));
|
||||
}
|
||||
else
|
||||
|
||||
final int start = (page - 1) * 9;
|
||||
final 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(Util.i18n("noHelpFound"));
|
||||
user.sendMessage(lines.get(i));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
sender.sendMessage(Util.i18n("helpConsole"));
|
||||
}
|
||||
|
||||
@SuppressWarnings("CallToThreadDumpStack")
|
||||
private List<String> getHelpLines(User user, String match) throws Exception
|
||||
private List<String> getHelpLines(final User user, final String match) throws Exception
|
||||
{
|
||||
List<String> retval = new ArrayList<String>();
|
||||
final List<String> retval = new ArrayList<String>();
|
||||
File helpFile = new File(ess.getDataFolder(), "help_" + Util.sanitizeFileName(user.getName()) + ".txt");
|
||||
if (!helpFile.exists())
|
||||
{
|
||||
@@ -116,53 +117,98 @@ public class Commandhelp extends EssentialsCommand
|
||||
try
|
||||
{
|
||||
final PluginDescriptionFile desc = p.getDescription();
|
||||
final HashMap<String, HashMap<String, String>> cmds = (HashMap<String, HashMap<String, String>>)desc.getCommands();
|
||||
for (Entry<String, HashMap<String, String>> k : cmds.entrySet())
|
||||
final HashMap<String, HashMap<String, Object>> cmds = (HashMap<String, HashMap<String, Object>>)desc.getCommands();
|
||||
pluginName = p.getDescription().getName().toLowerCase();
|
||||
for (Entry<String, HashMap<String, Object>> k : cmds.entrySet())
|
||||
{
|
||||
if ((!match.equalsIgnoreCase("")) && (!k.getKey().toLowerCase().contains(match))
|
||||
&& (!k.getValue().get("description").toLowerCase().contains(match)))
|
||||
try
|
||||
{
|
||||
if ((!match.equalsIgnoreCase(""))
|
||||
&& (!k.getKey().toLowerCase().contains(match))
|
||||
&& (!(k.getValue().get(DESCRIPTION) instanceof String
|
||||
&& ((String)k.getValue().get(DESCRIPTION)).toLowerCase().contains(match)))
|
||||
&& (!pluginName.contains(match)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (pluginName.contains("essentials"))
|
||||
{
|
||||
final String node = "essentials." + k.getKey();
|
||||
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().showNonEssCommandsInHelp())
|
||||
{
|
||||
final HashMap<String, Object> value = k.getValue();
|
||||
if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof String && !(value.get(PERMISSION).equals("")))
|
||||
{
|
||||
if (user.isAuthorized((String)value.get(PERMISSION)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSION) && value.get(PERMISSION) instanceof List && !((List<Object>)value.get(PERMISSION)).isEmpty())
|
||||
{
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSION))
|
||||
{
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof String && !(value.get(PERMISSIONS).equals("")))
|
||||
{
|
||||
if (user.isAuthorized((String)value.get(PERMISSIONS)))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (value.containsKey(PERMISSIONS) && value.get(PERMISSIONS) instanceof List && !((List<Object>)value.get(PERMISSIONS)).isEmpty())
|
||||
{
|
||||
boolean enabled = false;
|
||||
for (Object o : (List<Object>)value.get(PERMISSIONS))
|
||||
{
|
||||
if (o instanceof String && user.isAuthorized((String)o))
|
||||
{
|
||||
enabled = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (enabled)
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
else if (user.isAuthorized("essentials.help." + pluginName))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!ess.getSettings().hidePermissionlessHelp())
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get(DESCRIPTION));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (p.getDescription().getName().toLowerCase().contains("essentials"))
|
||||
{
|
||||
final String node = "essentials." + k.getKey();
|
||||
if (!ess.getSettings().isCommandDisabled(k.getKey()) && user.isAuthorized(node))
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + k.getValue().get("description"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (ess.getSettings().showNonEssCommandsInHelp())
|
||||
{
|
||||
pluginName = p.getDescription().getName();
|
||||
final HashMap<String, String> value = k.getValue();
|
||||
if (value.containsKey("permission") && value.get("permission") != null && !(value.get("permission").equals("")))
|
||||
{
|
||||
if (user.isAuthorized(value.get("permission")))
|
||||
{
|
||||
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
|
||||
{
|
||||
if (!ess.getSettings().hidePermissionlessHelp())
|
||||
{
|
||||
retval.add("§c" + k.getKey() + "§7: " + value.get("description"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NullPointerException ex)
|
||||
@@ -173,7 +219,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
{
|
||||
if (!reported)
|
||||
{
|
||||
logger.log(Level.WARNING, "Error getting help for:" + pluginName, ex);
|
||||
logger.log(Level.WARNING, Util.format("commandHelpFailedForPlugin", pluginName), ex);
|
||||
}
|
||||
reported = true;
|
||||
continue;
|
||||
|
@@ -22,7 +22,6 @@ public class Commandhelpop extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(user);
|
||||
final String message = Util.format("helpOp", user.getDisplayName(), getFinalArg(args, 0));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
|
@@ -4,6 +4,7 @@ import com.earth2me.essentials.Trade;
|
||||
import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
public class Commandhome extends EssentialsCommand
|
||||
@@ -18,24 +19,49 @@ public class Commandhome extends EssentialsCommand
|
||||
{
|
||||
Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
if(args.length > 0 && user.isAuthorized("essentials.home.others"))
|
||||
User u = user;
|
||||
String homeName = "";
|
||||
String[] nameParts;
|
||||
if (args.length > 0)
|
||||
{
|
||||
User u;
|
||||
try
|
||||
nameParts = args[0].split(":");
|
||||
if (nameParts[0].length() == args[0].length() || !user.isAuthorized("essentials.home.others"))
|
||||
{
|
||||
u = getPlayer(server, args, 0);
|
||||
homeName = nameParts[0];
|
||||
}
|
||||
catch(NoSuchFieldException ex)
|
||||
else
|
||||
{
|
||||
u = ess.getOfflineUser(args[0]);
|
||||
u = getPlayer(server, nameParts[0].split(" "), 0, true);
|
||||
if (nameParts.length > 1)
|
||||
{
|
||||
homeName = nameParts[1];
|
||||
}
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
user.getTeleport().home(u, charge);
|
||||
return;
|
||||
}
|
||||
user.getTeleport().home(charge);
|
||||
try
|
||||
{
|
||||
user.getTeleport().home(u, homeName.toLowerCase(), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
List<String> homes = u.getHomes();
|
||||
if (homes.isEmpty())
|
||||
{
|
||||
throw new Exception(u == user ? Util.i18n("noHomeSet") : Util.i18n("noHomeSetPlayer"));
|
||||
}
|
||||
else if ((homes.size() == 1) && u == user)
|
||||
{
|
||||
user.getTeleport().home(u, homes.get(0), charge);
|
||||
}
|
||||
else if (ess.getSettings().spawnIfNoHome())
|
||||
{
|
||||
user.getTeleport().respawn(ess.getSpawn(), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("homes", Util.joinList(homes)));
|
||||
}
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -68,9 +68,8 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.i18n("infoFileDoesNotExist"));
|
||||
file.createNewFile();
|
||||
return;
|
||||
throw new Exception(Util.i18n("infoFileDoesNotExist"));
|
||||
}
|
||||
|
||||
if (bookmarks.isEmpty())
|
||||
@@ -88,7 +87,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int start = (page - 1) * 9;
|
||||
int pages = lines.size() / 9 + (lines.size() % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < lines.size() && i < start + 9; i++)
|
||||
{
|
||||
@@ -140,7 +138,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
}
|
||||
int pages = end / 9 + (end % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoPages", page, pages ));
|
||||
for (int i = start; i < end && i < start + 9; i++)
|
||||
{
|
||||
@@ -182,7 +179,6 @@ public class Commandinfo extends EssentialsCommand
|
||||
int page = chapterpage + 1;
|
||||
int pages = (chapterend - chapterstart) / 9 + ((chapterend - chapterstart) % 9 > 0 ? 1 : 0);
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("infoChapterPages", pageStr, page , pages));
|
||||
for (int i = start; i < chapterend && i < start + 9; i++)
|
||||
{
|
||||
|
@@ -31,11 +31,9 @@ public class Commandinvsee extends EssentialsCommand
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.sendMessage(Util.i18n("invRestored"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("invRestored"));
|
||||
}
|
||||
|
||||
charge(user);
|
||||
if (user.getSavedInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
|
@@ -31,8 +31,7 @@ public class Commanditem extends EssentialsCommand
|
||||
: (!user.isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !user.canSpawnItem(stack.getTypeId())))
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", itemname));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
@@ -42,12 +41,10 @@ public class Commanditem extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(Util.format("cantSpawnItem", "Air"));
|
||||
return;
|
||||
throw new Exception(Util.format("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
String itemName = stack.getType().name().toLowerCase().replace('_', ' ');
|
||||
charge(user);
|
||||
String itemName = stack.getType().toString().toLowerCase().replace('_', ' ');
|
||||
user.sendMessage(Util.format("itemSpawn", stack.getAmount(), itemName));
|
||||
user.getInventory().addItem(stack);
|
||||
user.updateInventory();
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -14,12 +15,6 @@ public class Commandjails extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
StringBuilder jailList = new StringBuilder();
|
||||
for (String j : ess.getJail().getJails())
|
||||
{
|
||||
jailList.append(j);
|
||||
jailList.append(' ');
|
||||
}
|
||||
sender.sendMessage("§7" + jailList);
|
||||
sender.sendMessage("§7" + Util.joinList(" ", ess.getJail().getJails()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,9 +1,11 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandkick extends EssentialsCommand
|
||||
@@ -21,15 +23,22 @@ public class Commandkick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User u = getPlayer(server, args, 0);
|
||||
if (u.isAuthorized("essentials.kick.exempt"))
|
||||
User player = getPlayer(server, args, 0);
|
||||
if (player.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("kickExempt"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("kickExempt"));
|
||||
}
|
||||
charge(sender);
|
||||
final String kickReason = args.length > 1 ? getFinalArg(args, 1) : Util.i18n("kickDefault");
|
||||
u.kickPlayer(kickReason);
|
||||
server.broadcastMessage(Util.format("playerKicked", u.getName(), kickReason));
|
||||
player.kickPlayer(kickReason);
|
||||
String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for(Player p : server.getOnlinePlayers())
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
if(u.isAuthorized("essentials.kick.notify"))
|
||||
{
|
||||
p.sendMessage(Util.format("playerKicked", senderName, player.getName(), kickReason));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -16,8 +16,6 @@ public class Commandkickall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
if (sender instanceof Player && p.getName().equalsIgnoreCase(((Player)sender).getName()))
|
||||
|
@@ -21,7 +21,6 @@ public class Commandkill extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
p.setHealth(0);
|
||||
|
@@ -9,6 +9,7 @@ import org.bukkit.Server;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.GregorianCalendar;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -124,7 +125,7 @@ public class Commandkit extends EssentialsCommand
|
||||
for (String d : items)
|
||||
{
|
||||
String[] parts = d.split("[^0-9]+", 3);
|
||||
int id = Integer.parseInt(parts[0]);
|
||||
int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
HashMap<Integer,ItemStack> overfilled = user.getInventory().addItem(new ItemStack(id, amount, data));
|
||||
@@ -140,7 +141,6 @@ public class Commandkit extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
charge(user);
|
||||
charge.charge(user);
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@@ -26,20 +26,14 @@ public class Commandlightning extends EssentialsCommand
|
||||
if (args.length < 1 & user != null)
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
charge(user);
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
charge(user);
|
||||
}
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
sender.sendMessage(Util.format("lightningUse", p.getDisplayName()));
|
||||
|
@@ -44,7 +44,7 @@ public class Commandlist extends EssentialsCommand
|
||||
playerHidden++;
|
||||
}
|
||||
}
|
||||
charge(sender);
|
||||
//TODO: move these to messages file
|
||||
StringBuilder online = new StringBuilder();
|
||||
online.append(ChatColor.BLUE).append("There are ").append(ChatColor.RED).append(server.getOnlinePlayers().length - playerHidden);
|
||||
if (showhidden && playerHidden > 0)
|
||||
@@ -102,6 +102,7 @@ public class Commandlist extends EssentialsCommand
|
||||
groupString.append("§7[HIDDEN]§f");
|
||||
}
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append("§f");
|
||||
}
|
||||
sender.sendMessage(groupString.toString());
|
||||
}
|
||||
@@ -142,6 +143,7 @@ public class Commandlist extends EssentialsCommand
|
||||
onlineUsers.append("§7[HIDDEN]§f");
|
||||
}
|
||||
onlineUsers.append(user.getDisplayName());
|
||||
onlineUsers.append("§f");
|
||||
}
|
||||
sender.sendMessage(onlineUsers.toString());
|
||||
}
|
||||
|
@@ -23,22 +23,19 @@ public class Commandmail extends EssentialsCommand
|
||||
List<String> mail = user.getMails();
|
||||
if (mail.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMail"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMail"));
|
||||
}
|
||||
for (String s : mail)
|
||||
{
|
||||
user.sendMessage(s);
|
||||
}
|
||||
user.sendMessage(Util.i18n("mailClear"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailClear"));
|
||||
}
|
||||
if (args.length >= 3 && "send".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.send"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("noMailSendPerm"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("noMailSendPerm"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
@@ -53,10 +50,8 @@ public class Commandmail extends EssentialsCommand
|
||||
}
|
||||
if (u == null)
|
||||
{
|
||||
user.sendMessage(Util.format("playerNeverOnServer", args[1]));
|
||||
return;
|
||||
throw new Exception(Util.format("playerNeverOnServer", args[1]));
|
||||
}
|
||||
charge(user);
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
{
|
||||
u.addMail(ChatColor.stripColor(user.getDisplayName()) + ": " + getFinalArg(args, 2));
|
||||
@@ -67,8 +62,7 @@ public class Commandmail extends EssentialsCommand
|
||||
if (args.length >= 1 && "clear".equalsIgnoreCase(args[0]))
|
||||
{
|
||||
user.setMails(null);
|
||||
user.sendMessage(Util.i18n("mailCleared"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("mailCleared"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
@@ -17,21 +17,22 @@ public class Commandme extends EssentialsCommand
|
||||
{
|
||||
if (user.isMuted())
|
||||
{
|
||||
user.sendMessage(Util.i18n("voiceSilenced"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
StringBuilder message = new StringBuilder();
|
||||
final StringBuilder message = new StringBuilder();
|
||||
message.append("* ");
|
||||
message.append(user.getDisplayName());
|
||||
message.append(' ');
|
||||
for (int i = 0; i < args.length; i++)
|
||||
{
|
||||
message.append(args[i]);
|
||||
message.append(' ');
|
||||
}
|
||||
charge(user);
|
||||
ess.broadcastMessage(user.getName(), "* " + user.getDisplayName() + " " + message);
|
||||
ess.broadcastMessage(user, message.toString());
|
||||
}
|
||||
}
|
||||
|
@@ -15,7 +15,6 @@ public class Commandmotd extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
for (String m : ess.getMotd(sender, Util.i18n("noMotd")))
|
||||
{
|
||||
sender.sendMessage(m);
|
||||
|
@@ -25,6 +25,15 @@ public class Commandmsg extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isMuted())
|
||||
{
|
||||
throw new Exception(Util.i18n("voiceSilenced"));
|
||||
}
|
||||
}
|
||||
|
||||
String message = getFinalArg(args, 1);
|
||||
String translatedMe = Util.i18n("me");
|
||||
|
||||
@@ -45,13 +54,25 @@ public class Commandmsg extends EssentialsCommand
|
||||
|
||||
if (matches.isEmpty())
|
||||
{
|
||||
sender.sendMessage(Util.i18n("playerNotFound"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
int i = 0;
|
||||
for (Player p : matches)
|
||||
{
|
||||
{
|
||||
final User u = ess.getUser(p);
|
||||
if (u.isHidden())
|
||||
{
|
||||
i++;
|
||||
}
|
||||
}
|
||||
if (i == matches.size())
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
for (Player p : matches)
|
||||
{
|
||||
sender.sendMessage(Util.format("msgFormat", translatedMe, p.getDisplayName(), message));
|
||||
final User u = ess.getUser(p);
|
||||
if (sender instanceof Player && (u.isIgnoredPlayer(((Player)sender).getName()) || u.isHidden()))
|
||||
|
@@ -1,52 +1,50 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commandmute extends EssentialsCommand
|
||||
{
|
||||
public Commandmute()
|
||||
{
|
||||
super("mute");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
User p = getPlayer(server, args, 0, true);
|
||||
if (p.isAuthorized("essentials.mute.exempt"))
|
||||
{
|
||||
sender.sendMessage(Util.i18n("muteExempt"));
|
||||
return;
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
charge(sender);
|
||||
boolean muted = p.toggleMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("mutedPlayerFor", p.getDisplayName(), Util.formatDateDiff(muteTimestamp))
|
||||
: Util.format("mutedPlayer", p.getDisplayName()))
|
||||
: Util.format("unmutedPlayer", p.getDisplayName()));
|
||||
p.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
? Util.format("playerMutedFor", Util.formatDateDiff(muteTimestamp))
|
||||
: Util.i18n("playerMuted"))
|
||||
: Util.i18n("playerUnmuted"));
|
||||
}
|
||||
}
|
||||
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"))
|
||||
{
|
||||
throw new Exception(Util.i18n("muteExempt"));
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
}
|
||||
p.setMuteTimeout(muteTimestamp);
|
||||
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"));
|
||||
}
|
||||
}
|
||||
|
@@ -21,13 +21,16 @@ public class Commandnick extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
throw new Exception(Util.i18n("nickDisplayName"));
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (!user.isAuthorized("essentials.nick.others"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickOthersPermission"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickOthersPermission"));
|
||||
}
|
||||
|
||||
setOthersNickname(server, user, args);
|
||||
@@ -46,8 +49,7 @@ public class Commandnick extends EssentialsCommand
|
||||
|
||||
if (nick.matches("[^a-zA-Z_0-9]"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickNamesAlpha"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickNamesAlpha"));
|
||||
}
|
||||
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
@@ -61,12 +63,10 @@ public class Commandnick extends EssentialsCommand
|
||||
String nk = nick.toLowerCase();
|
||||
if (nk.equals(dn) || nk.equals(n))
|
||||
{
|
||||
user.sendMessage(Util.i18n("nickInUse"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("nickInUse"));
|
||||
}
|
||||
}
|
||||
|
||||
charge(user);
|
||||
user.setDisplayName(ess.getSettings().getNicknamePrefix() + nick);
|
||||
user.setNickname(nick);
|
||||
user.sendMessage(Util.format("nickSet", user.getDisplayName() + "§7."));
|
||||
@@ -80,6 +80,11 @@ public class Commandnick extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (!ess.getSettings().changeDisplayName()) {
|
||||
sender.sendMessage(Util.i18n("nickDisplayName"));
|
||||
return;
|
||||
}
|
||||
|
||||
setOthersNickname(server, sender, args);
|
||||
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
|
||||
|
||||
public class Commandpay extends EssentialsCommand
|
||||
@@ -22,6 +23,7 @@ public class Commandpay extends EssentialsCommand
|
||||
|
||||
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
|
||||
|
||||
Boolean foundUser = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
@@ -30,6 +32,11 @@ public class Commandpay extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
user.payUser(u, amount);
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
if(foundUser == false) {
|
||||
throw new NoSuchFieldException(Util.i18n("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,173 +0,0 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import java.io.File;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
|
||||
public class Commandplugin extends EssentialsCommand
|
||||
{
|
||||
private Server server;
|
||||
|
||||
public Commandplugin()
|
||||
{
|
||||
super("plugin");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
this.server = server;
|
||||
|
||||
PluginCommands sub = null;
|
||||
try
|
||||
{
|
||||
sub = PluginCommands.valueOf(args[0].toUpperCase());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
sender.sendMessage("§cUsage: /plugin [load|reload|enable|disable|list] [PluginName]");
|
||||
return;
|
||||
}
|
||||
|
||||
switch (sub)
|
||||
{
|
||||
case LOAD: // All disable functions are broken until
|
||||
// http://leaky.bukkit.org/issues/641 is fixed.
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
loadPlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case RELOAD:
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
reloadPlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case ENABLE:
|
||||
sender.sendMessage("This function is broken. Performing /reload now.");
|
||||
server.reload();
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
enablePlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case DISABLE:
|
||||
sender.sendMessage("This function is broken.");
|
||||
/*if (args.length < 2) return;
|
||||
User.charge(sender, this);
|
||||
disablePlugin(args[1], sender);*/
|
||||
return;
|
||||
|
||||
case LIST:
|
||||
charge(sender);
|
||||
listPlugins(sender);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void listPlugins(CommandSender player)
|
||||
{
|
||||
StringBuilder plugins = new StringBuilder();
|
||||
for (Plugin p : server.getPluginManager().getPlugins())
|
||||
{
|
||||
plugins.append(p.isEnabled() ? " §a" : " §c");
|
||||
plugins.append(p.getDescription().getName());
|
||||
}
|
||||
|
||||
plugins.insert(0, "§7Plugins:§f");
|
||||
player.sendMessage(plugins.toString());
|
||||
}
|
||||
|
||||
private boolean reloadPlugin(String name, CommandSender player)
|
||||
{
|
||||
return disablePlugin(name, player) && enablePlugin(name, player);
|
||||
}
|
||||
|
||||
private boolean loadPlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
PluginManager pm = server.getPluginManager();
|
||||
pm.loadPlugin(new File("plugins", name + ".jar"));
|
||||
sender.sendMessage("§7Plugin loaded.");
|
||||
return enablePlugin(name, sender);
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
sender.sendMessage("§cCould not load plugin. Is the file named properly?");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean enablePlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
final Plugin plugin = pm.getPlugin(name);
|
||||
if (!plugin.isEnabled())
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (pm)
|
||||
{
|
||||
pm.enablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
sender.sendMessage("§7Plugin enabled.");
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
listPlugins(sender);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean disablePlugin(String name, CommandSender sender)
|
||||
{
|
||||
try
|
||||
{
|
||||
final PluginManager pm = server.getPluginManager();
|
||||
final Plugin plugin = pm.getPlugin(name);
|
||||
if (plugin.isEnabled())
|
||||
{
|
||||
new Thread(new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
synchronized (pm)
|
||||
{
|
||||
pm.disablePlugin(plugin);
|
||||
}
|
||||
}
|
||||
}).start();
|
||||
}
|
||||
sender.sendMessage("§7Plugin disabled.");
|
||||
return true;
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
listPlugins(sender);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private enum PluginCommands
|
||||
{
|
||||
LOAD, RELOAD, LIST, ENABLE, DISABLE
|
||||
}
|
||||
}
|
@@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
@@ -15,25 +17,92 @@ public class Commandpowertool extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(Server server, User user, String commandLabel, String[] args) throws Exception
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
String command = getFinalArg(args, 0);
|
||||
|
||||
ItemStack is = user.getItemInHand();
|
||||
if (is == null || is.getType() == Material.AIR)
|
||||
// check to see if this is a clear all command
|
||||
if(command != null && command.equalsIgnoreCase("clearall"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("powerToolAir"));
|
||||
user.clearAllPowertools();
|
||||
user.sendMessage(Util.i18n("powerToolClearAll"));
|
||||
return;
|
||||
}
|
||||
String command = getFinalArg(args, 0);
|
||||
|
||||
final ItemStack itemStack = user.getItemInHand();
|
||||
if (itemStack == null || itemStack.getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(Util.i18n("powerToolAir"));
|
||||
}
|
||||
|
||||
final String itemName = itemStack.getType().toString().toLowerCase().replaceAll("_", " ");
|
||||
List<String> powertools = user.getPowertool(itemStack);
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolAttach",is.getType().toString().toLowerCase().replaceAll("_", " ")));
|
||||
if (command.equalsIgnoreCase("l:"))
|
||||
{
|
||||
if (powertools == null || powertools.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.format("powerToolListEmpty", itemName));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolList", Util.joinList(powertools), itemName));
|
||||
}
|
||||
return;
|
||||
}
|
||||
if (command.startsWith("r:"))
|
||||
{
|
||||
try
|
||||
{
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
throw new Exception(Util.format("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
|
||||
powertools.remove(command);
|
||||
user.sendMessage(Util.format("powerToolRemove", command, itemName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (command.startsWith("a:"))
|
||||
{
|
||||
command = command.substring(2);
|
||||
if (powertools.contains(command))
|
||||
{
|
||||
throw new Exception(Util.format("powerToolAlreadySet", command, itemName));
|
||||
}
|
||||
}
|
||||
else if (powertools != null && !powertools.isEmpty())
|
||||
{
|
||||
// Replace all commands with this one
|
||||
powertools.clear();
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools = new ArrayList<String>();
|
||||
}
|
||||
|
||||
powertools.add(command);
|
||||
user.sendMessage(Util.format("powerToolAttach", Util.joinList(powertools), itemName));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("powerToolRemove", is.getType().toString().toLowerCase().replaceAll("_", " ")));
|
||||
if (powertools != null)
|
||||
{
|
||||
powertools.clear();
|
||||
}
|
||||
user.sendMessage(Util.format("powerToolRemoveAll", itemName));
|
||||
}
|
||||
charge(user);
|
||||
user.setPowertool(is, command);
|
||||
|
||||
user.setPowertool(itemStack, powertools);
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,29 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
public class Commandpowertooltoggle extends EssentialsCommand
|
||||
{
|
||||
public Commandpowertooltoggle()
|
||||
{
|
||||
super("powertooltoggle");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if(!user.hasPowerTools())
|
||||
{
|
||||
user.sendMessage(Util.i18n("noPowerTools"));
|
||||
return;
|
||||
}
|
||||
user.sendMessage(user.togglePowerToolsEnabled()
|
||||
? Util.i18n("powerToolsEnabled")
|
||||
: Util.i18n("powerToolsDisabled"));
|
||||
}
|
||||
|
||||
|
||||
}
|
247
Essentials/src/com/earth2me/essentials/commands/Commandptime.java
Executable file
247
Essentials/src/com/earth2me/essentials/commands/Commandptime.java
Executable file
@@ -0,0 +1,247 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.DescParseTickFormat;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Collection;
|
||||
import java.util.Comparator;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.TreeSet;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandptime extends EssentialsCommand
|
||||
{
|
||||
public static final Set<String> getAliases = new HashSet<String>();
|
||||
|
||||
static
|
||||
{
|
||||
getAliases.add("get");
|
||||
getAliases.add("list");
|
||||
getAliases.add("show");
|
||||
getAliases.add("display");
|
||||
}
|
||||
|
||||
public Commandptime()
|
||||
{
|
||||
super("ptime");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
// Which Players(s) / Users(s) are we interested in?
|
||||
String userSelector = null;
|
||||
if (args.length == 2)
|
||||
{
|
||||
userSelector = args[1];
|
||||
}
|
||||
Set<User> users = getUsers(server, sender, userSelector);
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (args.length == 0)
|
||||
{
|
||||
getUsersTime(sender, users);
|
||||
return;
|
||||
}
|
||||
|
||||
User user = ess.getUser(sender);
|
||||
if ((!users.contains(user) || users.size() > 1) && user != null && !user.isAuthorized("essentials.ptime.others"))
|
||||
{
|
||||
user.sendMessage(Util.i18n("pTimeOthersPermission"));
|
||||
return;
|
||||
}
|
||||
|
||||
Long ticks;
|
||||
// Parse the target time int ticks from args[0]
|
||||
String timeParam = args[0];
|
||||
Boolean relative = true;
|
||||
if (timeParam.startsWith("@"))
|
||||
{
|
||||
relative = false;
|
||||
timeParam = timeParam.substring(1);
|
||||
}
|
||||
|
||||
if (getAliases.contains(timeParam))
|
||||
{
|
||||
getUsersTime(sender, users);
|
||||
return;
|
||||
}
|
||||
else if (DescParseTickFormat.meansReset(timeParam))
|
||||
{
|
||||
ticks = null;
|
||||
}
|
||||
else
|
||||
{
|
||||
try
|
||||
{
|
||||
ticks = DescParseTickFormat.parse(timeParam);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
setUsersTime(sender, users, ticks, relative);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the time and inform
|
||||
*/
|
||||
private void getUsersTime(final CommandSender sender, final Collection<User> users)
|
||||
{
|
||||
if (users.size() > 1)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimePlayers"));
|
||||
}
|
||||
|
||||
for (User user : users)
|
||||
{
|
||||
if(user.getPlayerTimeOffset() == 0)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeNormal", user.getName()));
|
||||
}
|
||||
else {
|
||||
String time = DescParseTickFormat.format(user.getPlayerTime());
|
||||
if(!user.isPlayerTimeRelative())
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeCurrentFixed", user.getName(), time));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(Util.format("pTimeCurrent", user.getName(), time));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to set the time and inform of the change
|
||||
*/
|
||||
private void setUsersTime(final CommandSender sender, final Collection<User> users, final Long ticks, Boolean relative)
|
||||
{
|
||||
// Update the time
|
||||
if (ticks == null)
|
||||
{
|
||||
// Reset
|
||||
for (User user : users)
|
||||
{
|
||||
user.resetPlayerTime();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// Set
|
||||
for (User user : users)
|
||||
{
|
||||
final World world = user.getWorld();
|
||||
long time = user.getPlayerTime();
|
||||
time -= time % 24000;
|
||||
time += 24000 + ticks;
|
||||
if (relative)
|
||||
{
|
||||
time -= world.getTime();
|
||||
}
|
||||
user.setPlayerTime(time, relative);
|
||||
}
|
||||
}
|
||||
|
||||
final StringBuilder msg = new StringBuilder();
|
||||
for (User user : users)
|
||||
{
|
||||
if (msg.length() > 0)
|
||||
{
|
||||
msg.append(", ");
|
||||
}
|
||||
|
||||
msg.append(user.getName());
|
||||
}
|
||||
|
||||
// Inform the sender of the change
|
||||
if (ticks == null)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeReset", msg.toString()));
|
||||
}
|
||||
else
|
||||
{
|
||||
String time = DescParseTickFormat.format(ticks);
|
||||
if (!relative)
|
||||
{
|
||||
sender.sendMessage(Util.format("pTimeSetFixed", time, msg.toString()));
|
||||
}
|
||||
else {
|
||||
sender.sendMessage(Util.format("pTimeSet", time, msg.toString()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to parse an argument of the type "users(s) selector"
|
||||
*/
|
||||
private Set<User> getUsers(final Server server, final CommandSender sender, final String selector) throws Exception
|
||||
{
|
||||
final Set<User> users = new TreeSet<User>(new UserNameComparator());
|
||||
// If there is no selector we want the sender itself. Or all users if sender isn't a user.
|
||||
if (selector == null)
|
||||
{
|
||||
final User user = ess.getUser(sender);
|
||||
if (user == null)
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
users.add(ess.getUser(player));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
users.add(user);
|
||||
}
|
||||
return users;
|
||||
}
|
||||
|
||||
// Try to find the user with name = selector
|
||||
User user = null;
|
||||
final List<Player> matchedPlayers = server.matchPlayer(selector);
|
||||
if (!matchedPlayers.isEmpty())
|
||||
{
|
||||
user = ess.getUser(matchedPlayers.get(0));
|
||||
}
|
||||
|
||||
if (user != null)
|
||||
{
|
||||
users.add(user);
|
||||
}
|
||||
// If that fails, Is the argument something like "*" or "all"?
|
||||
else if (selector.equalsIgnoreCase("*") || selector.equalsIgnoreCase("all"))
|
||||
{
|
||||
for (Player player : server.getOnlinePlayers())
|
||||
{
|
||||
users.add(ess.getUser(player));
|
||||
}
|
||||
}
|
||||
// We failed to understand the world target...
|
||||
else
|
||||
{
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
|
||||
return users;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
class UserNameComparator implements Comparator<User>
|
||||
{
|
||||
public int compare(User a, User b)
|
||||
{
|
||||
return a.getName().compareTo(b.getName());
|
||||
}
|
||||
}
|
@@ -32,11 +32,9 @@ public class Commandr extends EssentialsCommand
|
||||
|
||||
if (target == null)
|
||||
{
|
||||
sender.sendMessage(Util.i18n("foreverAlone"));
|
||||
return;
|
||||
throw new Exception(Util.i18n("foreverAlone"));
|
||||
}
|
||||
|
||||
charge(sender);
|
||||
sender.sendMessage(Util.format("msgFormat", Util.i18n("me"), targetName, message));
|
||||
if (target instanceof Player)
|
||||
{
|
||||
|
@@ -22,7 +22,6 @@ public class Commandrealname extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final String whois = args[0].toLowerCase();
|
||||
charge(user);
|
||||
for (Player p : server.getOnlinePlayers())
|
||||
{
|
||||
final User u = ess.getUser(p);
|
||||
|
@@ -15,7 +15,6 @@ public class Commandreloadall extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
server.reload();
|
||||
sender.sendMessage(Util.i18n("reloadAllPlugins"));
|
||||
}
|
||||
|
@@ -0,0 +1,118 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.ChargeException;
|
||||
import com.earth2me.essentials.IUser;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
public Commandrepair()
|
||||
{
|
||||
super("repair");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0].equalsIgnoreCase("hand"))
|
||||
{
|
||||
final ItemStack item = user.getItemInHand();
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
repairItem(item);
|
||||
|
||||
charge.charge(user);
|
||||
|
||||
user.sendMessage(Util.format("repair", itemName.replace('_', ' ')));
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
repairItems(user.getInventory().getArmorContents(), user, repaired);
|
||||
|
||||
if (repaired.isEmpty())
|
||||
{
|
||||
throw new Exception(Util.format("repairNone"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(Util.format("repair", Util.joinList(repaired)));
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
}
|
||||
|
||||
private void repairItem(final ItemStack item) throws Exception
|
||||
{
|
||||
final Material material = Material.getMaterial(item.getTypeId());
|
||||
if (material.isBlock() || material.getMaxDurability() < 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("repairInvalidType"));
|
||||
}
|
||||
|
||||
if (item.getDurability() == 0)
|
||||
{
|
||||
throw new Exception(Util.i18n("repairAlreadyFixed"));
|
||||
}
|
||||
|
||||
item.setDurability((short)0);
|
||||
}
|
||||
|
||||
private void repairItems(final ItemStack[] items, final IUser user, final List<String> repaired)
|
||||
{
|
||||
for (ItemStack item : items)
|
||||
{
|
||||
final String itemName = item.getType().toString().toLowerCase();
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
catch (ChargeException ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
repairItem(item);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
charge.charge(user);
|
||||
}
|
||||
catch (ChargeException ex)
|
||||
{
|
||||
user.sendMessage(ex.getMessage());
|
||||
}
|
||||
repaired.add(itemName.replace('_', ' '));
|
||||
}
|
||||
}
|
||||
}
|
@@ -15,7 +15,6 @@ public class Commandrules extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
charge(sender);
|
||||
for (String m : ess.getLines(sender, "rules", Util.i18n("noRules")))
|
||||
{
|
||||
sender.sendMessage(m);
|
||||
|
@@ -30,7 +30,7 @@ public class Commandseen extends EssentialsCommand
|
||||
User u = ess.getOfflineUser(args[0]);
|
||||
if (u == null)
|
||||
{
|
||||
return;
|
||||
throw new Exception(Util.i18n("playerNotFound"));
|
||||
}
|
||||
sender.sendMessage(Util.format("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
|
||||
}
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user