mirror of
https://github.com/essentials/Essentials.git
synced 2025-09-23 12:51:33 +02:00
Compare commits
603 Commits
stable-2.8
...
stable-2.9
Author | SHA1 | Date | |
---|---|---|---|
|
4d0ce90787 | ||
|
4d17b73291 | ||
|
f7a34c49fb | ||
|
d0a8dc4812 | ||
|
0466a60093 | ||
|
2c6a81a916 | ||
|
329f93a4f6 | ||
|
b70f950479 | ||
|
38a2e2bcfd | ||
|
d9b91e0c34 | ||
|
4ae5579068 | ||
|
622d710aa9 | ||
|
f1a7be09c2 | ||
|
0742ca23c1 | ||
|
8823ce070e | ||
|
d77f6cbbf1 | ||
|
909c8b3cb5 | ||
|
5b7d29fa55 | ||
|
8dfb3c03c7 | ||
|
6e8031f477 | ||
|
81c545f45b | ||
|
65025d47c5 | ||
|
4f23e8aaeb | ||
|
aea2c00a95 | ||
|
eafe0380e1 | ||
|
3975ceb2a0 | ||
|
0a3ecbcd0e | ||
|
9679a90d88 | ||
|
c4a704b1a2 | ||
|
776900bd7b | ||
|
5683ea35fc | ||
|
78d4987d5d | ||
|
9f852b3a41 | ||
|
edca2cbdff | ||
|
c578302d7c | ||
|
dfce4b31f3 | ||
|
669edfc048 | ||
|
0a9c88a990 | ||
|
4e5e5a9684 | ||
|
97eada7dd6 | ||
|
a764f8c929 | ||
|
5da886593b | ||
|
4c5a88929c | ||
|
af7e427545 | ||
|
4638c5ab55 | ||
|
0c2e63baad | ||
|
ee61ce35c8 | ||
|
6ec5b4a5da | ||
|
d63ad6fc0c | ||
|
641a4b9dff | ||
|
31001d6b1a | ||
|
d1a1559dca | ||
|
0d56b700bf | ||
|
cafdb919e4 | ||
|
808f448399 | ||
|
10d902e730 | ||
|
0436962ee7 | ||
|
2bebb0bd61 | ||
|
1e04e3f80d | ||
|
c32e10caac | ||
|
120440d45b | ||
|
61b85901a3 | ||
|
f0b3acf491 | ||
|
f2d624a795 | ||
|
9e1d7aca92 | ||
|
3b43f7bf03 | ||
|
2f18c6edf1 | ||
|
79f8699174 | ||
|
602681dcc2 | ||
|
3e63047c38 | ||
|
4f2f166824 | ||
|
fc782f286d | ||
|
425c548611 | ||
|
593f1dd67f | ||
|
8cff4348a6 | ||
|
40271f2ddf | ||
|
aa1205f42d | ||
|
2e15de483d | ||
|
77b0415c1b | ||
|
43b3a9df23 | ||
|
8b47b80b0b | ||
|
13da8c3adc | ||
|
a10190df51 | ||
|
ecfa745484 | ||
|
20d439578b | ||
|
dd7f1bcf25 | ||
|
3b855255cf | ||
|
23283426e0 | ||
|
c958bc78dd | ||
|
24ec242ecf | ||
|
9068c13e39 | ||
|
024aff0af5 | ||
|
57c1d75779 | ||
|
8c434783a2 | ||
|
85ae839211 | ||
|
b218d33a24 | ||
|
6e0f4674d5 | ||
|
62812e1e3a | ||
|
63680b4911 | ||
|
071254ed8d | ||
|
93980629d3 | ||
|
f299771044 | ||
|
8c013b7680 | ||
|
78fe659677 | ||
|
98de950ae2 | ||
|
96eb9c5db7 | ||
|
45c1e347b0 | ||
|
0559b935e9 | ||
|
409f337973 | ||
|
7f5f6b6ac9 | ||
|
dc36a50d85 | ||
|
74f0babc7d | ||
|
5eeaeaee5d | ||
|
fa58503c9f | ||
|
9fca3728c3 | ||
|
56fccb9645 | ||
|
cab40d7893 | ||
|
faa3a5e027 | ||
|
1c0838aa5d | ||
|
32fa834f3f | ||
|
051af644a7 | ||
|
9b9a6a3148 | ||
|
711426fe69 | ||
|
18c9c812d7 | ||
|
bc798977b5 | ||
|
853d7cb668 | ||
|
3eac027ddb | ||
|
1247401a5f | ||
|
9846362836 | ||
|
16fc88b50c | ||
|
fee3d7c0d3 | ||
|
5020f6b990 | ||
|
a48f6c8c30 | ||
|
8d6b864b5b | ||
|
deca5e5e73 | ||
|
9b731cc39c | ||
|
78cd64c388 | ||
|
d9e15729fd | ||
|
0fbe2da9cb | ||
|
d3397279f6 | ||
|
705efc6002 | ||
|
3a60191a9d | ||
|
95e6db6797 | ||
|
e37b1946f5 | ||
|
6d1e2dd10e | ||
|
0668c4214e | ||
|
1b4c803ce3 | ||
|
8d00da9e98 | ||
|
1524a06ac6 | ||
|
9ca820d45e | ||
|
27102d1c38 | ||
|
18b5405c76 | ||
|
de541f6654 | ||
|
9d398b1d2e | ||
|
caeb3279cb | ||
|
06247732da | ||
|
fc7689354f | ||
|
a50b74bb36 | ||
|
a21b5fac76 | ||
|
3d9022d8fa | ||
|
4e10470acd | ||
|
3cc1a462f5 | ||
|
cd7bf5eff2 | ||
|
8da3b490d9 | ||
|
00c87c0e60 | ||
|
507ecc47b6 | ||
|
6ac8abdac8 | ||
|
4a29dd4c9c | ||
|
6d06636bc2 | ||
|
da857895fc | ||
|
425a2184c6 | ||
|
6919b52f61 | ||
|
8eb7428ad1 | ||
|
327a57de3c | ||
|
01ba8dbc3f | ||
|
a97b3abca3 | ||
|
d927d04765 | ||
|
6dc2e96509 | ||
|
26a0cd0761 | ||
|
75b7f7ac22 | ||
|
d08ea5a650 | ||
|
1bd1665faa | ||
|
b3847270fa | ||
|
055603b09e | ||
|
34f5c19f99 | ||
|
602bd5b0d4 | ||
|
45de85dae2 | ||
|
8b9ff2c58a | ||
|
1599a36642 | ||
|
1e30f23ca6 | ||
|
2f74510cce | ||
|
08bff3ea5f | ||
|
90d2451ce2 | ||
|
5b5df254d5 | ||
|
a028abe036 | ||
|
677534c0b7 | ||
|
2d319fe5aa | ||
|
bbd2c53dd8 | ||
|
d1eb7e5614 | ||
|
d9ee666770 | ||
|
9f744beb13 | ||
|
62a297ec6d | ||
|
3f9e19d279 | ||
|
c9e64d9e46 | ||
|
25759064ff | ||
|
cd24ffbada | ||
|
cdae0898c7 | ||
|
f02691863b | ||
|
4c8d0ea2d9 | ||
|
ec4f5cc34d | ||
|
e8a42e3947 | ||
|
e8dd963545 | ||
|
1c0a5c49a5 | ||
|
bb83dcc828 | ||
|
0eefb7f5a1 | ||
|
fe95cfe03b | ||
|
7a6368a980 | ||
|
9e86681722 | ||
|
25bd91eb80 | ||
|
6504c88bf7 | ||
|
6a75d6fe86 | ||
|
bc876611d0 | ||
|
798ea77736 | ||
|
21ef83c0ff | ||
|
bd7af593e7 | ||
|
f73a5d0e8d | ||
|
f7bc04bc34 | ||
|
aa43703094 | ||
|
381886245b | ||
|
08642ada20 | ||
|
10cb4c03b7 | ||
|
e7d1cb8bb6 | ||
|
5a7d733cbf | ||
|
e23f491500 | ||
|
98b716dfbf | ||
|
2ddd31a37d | ||
|
2b99ed9a2a | ||
|
eeea16a99a | ||
|
e52996609a | ||
|
932de33349 | ||
|
195604997b | ||
|
a3a3f81e11 | ||
|
d0f3fb4417 | ||
|
183602ac28 | ||
|
37370f722c | ||
|
e2e51c9c95 | ||
|
bf1e073ef4 | ||
|
767703bfc9 | ||
|
0e0a96b6d8 | ||
|
3f73272524 | ||
|
d72f831519 | ||
|
c6f25c0df6 | ||
|
17058c220c | ||
|
0e99b35ab2 | ||
|
e795c6ed0b | ||
|
f3345247ed | ||
|
1101a3243d | ||
|
c7638efc7e | ||
|
d90053c8c4 | ||
|
6235983ddd | ||
|
7a249abc67 | ||
|
c2c613b652 | ||
|
590357004d | ||
|
9dbeb1407c | ||
|
1ef8ab70d1 | ||
|
c09ada201c | ||
|
d7139cb16c | ||
|
10f82a6723 | ||
|
2aed3af3c4 | ||
|
c45d38ca69 | ||
|
576642a573 | ||
|
9d545dcbf1 | ||
|
71d8744840 | ||
|
32c689e0f5 | ||
|
5b62661404 | ||
|
a7df8a1a0a | ||
|
b14e7c197f | ||
|
97eed50ccc | ||
|
b8453ac792 | ||
|
fe7f479e63 | ||
|
50ea442bf0 | ||
|
5d45495371 | ||
|
e30d900289 | ||
|
2cc96e995b | ||
|
47cf1289d7 | ||
|
d2506cd928 | ||
|
1dbb11ea55 | ||
|
b60363b6bd | ||
|
00033c11bc | ||
|
c588b78adb | ||
|
7bd7992b24 | ||
|
6f86b7400a | ||
|
e13a2c371d | ||
|
0cbded9fca | ||
|
3e6e71ca41 | ||
|
1b2e3b1951 | ||
|
e53a480c22 | ||
|
7280c1c468 | ||
|
b7221516dc | ||
|
71aaf81bba | ||
|
160c3f428c | ||
|
3c3e8d167f | ||
|
7ca2b65c4f | ||
|
a8cbb5c8f5 | ||
|
72028086c0 | ||
|
dddf529ff5 | ||
|
b3de0aabae | ||
|
77c6a3b730 | ||
|
bb54dbb688 | ||
|
0a74da88d6 | ||
|
d0b94938e0 | ||
|
a0cba8e63d | ||
|
a4d7b5dcf8 | ||
|
c503adabc5 | ||
|
8a22258945 | ||
|
29a190f93a | ||
|
5c0b522026 | ||
|
c46f14665c | ||
|
20c973dab2 | ||
|
49cb482ca5 | ||
|
033c2e22cd | ||
|
2f434291cb | ||
|
42d01471d3 | ||
|
c5eb1bb105 | ||
|
3c9057f68e | ||
|
96f0dd5824 | ||
|
71358629f4 | ||
|
284fef00e7 | ||
|
d20519ef8b | ||
|
0dc1270aed | ||
|
cd0d37f73c | ||
|
56fce34539 | ||
|
165a76d492 | ||
|
9570e5cfd9 | ||
|
c6bb10489e | ||
|
3d7d4a47d9 | ||
|
968c849b13 | ||
|
1746569e1a | ||
|
209c91d3de | ||
|
7d7c1d34cf | ||
|
c3ad486f65 | ||
|
7bcec32134 | ||
|
b19b08dc6e | ||
|
264e175d6c | ||
|
bcd4fd9bff | ||
|
3e88fb44f4 | ||
|
518b013a63 | ||
|
e752538568 | ||
|
970364886c | ||
|
07f859e38b | ||
|
c806059958 | ||
|
14bce8fd82 | ||
|
17be04cd99 | ||
|
b93847f077 | ||
|
6476158462 | ||
|
6dd73ff9d0 | ||
|
b72083fb18 | ||
|
ca11d4d98b | ||
|
12cb4fd5f8 | ||
|
4df4eba2a5 | ||
|
762105d692 | ||
|
e4ce814c2f | ||
|
87cd693020 | ||
|
baadd4b1cb | ||
|
adf3755abb | ||
|
5c280e7cb7 | ||
|
4a149855ab | ||
|
cf000b04e4 | ||
|
79cd8d6065 | ||
|
5b930cdc3b | ||
|
c09329e5be | ||
|
c513014732 | ||
|
bada36be68 | ||
|
e5e81eda72 | ||
|
45cf2ae960 | ||
|
d0d0117411 | ||
|
5d79863cfc | ||
|
b85756f8b1 | ||
|
8776f4c1c0 | ||
|
5e8fd3993d | ||
|
d3033716ca | ||
|
6cf2bb5cd9 | ||
|
267495a406 | ||
|
a8937f7bf0 | ||
|
dfd63a81ac | ||
|
dfbc1956c9 | ||
|
c0490c0890 | ||
|
2da802d4b7 | ||
|
adffbab678 | ||
|
e11525ab64 | ||
|
8dcd591beb | ||
|
a40c936bcf | ||
|
5c2622b390 | ||
|
c7046b696a | ||
|
9ac5ce8a75 | ||
|
5c55e18d33 | ||
|
19d233454e | ||
|
1f761ee1cb | ||
|
1db5d61945 | ||
|
1e34a396cd | ||
|
ba96117f55 | ||
|
96b217cbe8 | ||
|
0dd5c0370e | ||
|
bdf32cde9e | ||
|
e91ed60441 | ||
|
8577202f48 | ||
|
7819b9d2f0 | ||
|
15c0565923 | ||
|
2b25ca2932 | ||
|
c7a6677d52 | ||
|
c3d5b32986 | ||
|
cbfb524195 | ||
|
b16a1f7237 | ||
|
e28f1b1be3 | ||
|
b512a243e7 | ||
|
873c9880dd | ||
|
e6736e48a5 | ||
|
caf598f55b | ||
|
619e099a04 | ||
|
faba1e3604 | ||
|
7cb728b15f | ||
|
3e3c7f0d54 | ||
|
a45c19a08b | ||
|
eb74a1de9c | ||
|
8450734cf1 | ||
|
016299a1dd | ||
|
d27ff9abb6 | ||
|
cdf5d45483 | ||
|
0b60d4efe2 | ||
|
d31e434e4d | ||
|
fabc1c3dd9 | ||
|
68fbc40605 | ||
|
8b7c5cf2ed | ||
|
1811631b93 | ||
|
7cec1564b9 | ||
|
a75eefcdd4 | ||
|
6a9027da6d | ||
|
e55aa3cea7 | ||
|
1ce2c60bf4 | ||
|
7ba49afa0b | ||
|
6da705c86f | ||
|
c3fa56322b | ||
|
53cfab229b | ||
|
b62217f301 | ||
|
d9a8453995 | ||
|
e6181928e8 | ||
|
c33499797e | ||
|
860f6a41ac | ||
|
8aa7b1f301 | ||
|
6efd3eaa27 | ||
|
d2d8d191da | ||
|
cea5c81d44 | ||
|
504f28df1a | ||
|
74a57553f6 | ||
|
35576ab64a | ||
|
33605517ff | ||
|
6da6e4d2e8 | ||
|
c0fa03ede2 | ||
|
301b609e93 | ||
|
b6bbe237ea | ||
|
de7ab13c03 | ||
|
7a0f4da860 | ||
|
1bbbfe1c96 | ||
|
25ebe68389 | ||
|
7737d19c5a | ||
|
622ca4bf8a | ||
|
b090afbeb3 | ||
|
dce149511e | ||
|
21a248e94d | ||
|
f1aed4b521 | ||
|
7564ebf79e | ||
|
b9aecbe1d4 | ||
|
49eb451a76 | ||
|
64d866a77d | ||
|
f75779aa7a | ||
|
5622882602 | ||
|
b3d3928db8 | ||
|
6df3b9008a | ||
|
c36ca65e09 | ||
|
2e788802fe | ||
|
b0552019f5 | ||
|
dae69622a5 | ||
|
696b930fb2 | ||
|
e43a62f992 | ||
|
02c1cb05c7 | ||
|
b44d738867 | ||
|
e1818f7e62 | ||
|
e5081db7e4 | ||
|
ba346bd797 | ||
|
0670ece7f3 | ||
|
a8da3eebd7 | ||
|
056303b53c | ||
|
454f7d30de | ||
|
6d1c270976 | ||
|
d1001274bb | ||
|
3099855562 | ||
|
3f26d4ad98 | ||
|
bae337cc49 | ||
|
3823e7a108 | ||
|
1c2221f52f | ||
|
1b780a4364 | ||
|
ac3e65a829 | ||
|
332f19177e | ||
|
6ab57b9abe | ||
|
862f3aad59 | ||
|
e277acf80e | ||
|
9f893e68e9 | ||
|
833a5b2b55 | ||
|
340f0c68eb | ||
|
a5e3182dad | ||
|
10ae9c3aa2 | ||
|
bcf903de92 | ||
|
ad08d27504 | ||
|
d24f77dbd5 | ||
|
a5b38ce1a4 | ||
|
5d048d2c1d | ||
|
13d3cc3306 | ||
|
9f02fb4dd4 | ||
|
07baa6e611 | ||
|
50bd5869bf | ||
|
fa49fc91d2 | ||
|
28f478dd04 | ||
|
6fb8dad0ec | ||
|
9f605e9a88 | ||
|
e5b91dae73 | ||
|
e1749fecd1 | ||
|
358edff798 | ||
|
34f13ba89c | ||
|
945ba6f8ab | ||
|
46f05ee92f | ||
|
6d46fc66ce | ||
|
ed7fe9213f | ||
|
9c68cbae72 | ||
|
c0df771539 | ||
|
9bd0c33fef | ||
|
cf7da7a83f | ||
|
f46948249e | ||
|
3b81593ebb | ||
|
8042cefd3d | ||
|
514f07ce57 | ||
|
4f4d9f6209 | ||
|
3077ea4ef1 | ||
|
945ae71480 | ||
|
3d1c0fd157 | ||
|
fab9688abb | ||
|
b2dbb3f9e3 | ||
|
16a0f44b4d | ||
|
7633b136e3 | ||
|
0252d756f6 | ||
|
ad05516fd5 | ||
|
6d127012d8 | ||
|
c064da9af8 | ||
|
d05f2d7a32 | ||
|
3fc6bb4e4f | ||
|
59679e0423 | ||
|
1a2acb43ae | ||
|
f0c0ee1a8d | ||
|
3c98718387 | ||
|
cfdb2a36c1 | ||
|
3b7d194902 | ||
|
72d514d52f | ||
|
9fe119e720 | ||
|
4a5c431163 | ||
|
a6ac333a74 | ||
|
bc2578b788 | ||
|
36d07cb539 | ||
|
effe0d5ec5 | ||
|
0ab2e745cf | ||
|
57a2ef08d4 | ||
|
2699e02f96 | ||
|
62cd219b4e | ||
|
2d56de1483 | ||
|
bbc6da5106 | ||
|
b0d06ce6ed | ||
|
de1554cb68 | ||
|
c890ea8f87 | ||
|
c0517c1203 | ||
|
9efd0eb6f9 | ||
|
f0ee026fb9 | ||
|
b3fc790000 | ||
|
83f9209bcc | ||
|
691a0ef4ce | ||
|
97bd49e598 | ||
|
e93e50f6d2 | ||
|
76ba5caeec | ||
|
6ca1cdec4f | ||
|
86a1dda46c | ||
|
4326ce0d4a | ||
|
3ff1f4adbb | ||
|
492c4e8521 | ||
|
e3f3fe84ea | ||
|
6e2ac3b56e | ||
|
5c19e71858 | ||
|
a0103afde3 | ||
|
dbf30740fb | ||
|
92fa415848 | ||
|
2942ef40f3 | ||
|
3f02bcd702 | ||
|
fe050dd725 | ||
|
5b4966c888 | ||
|
e2abf05a27 | ||
|
8500542e93 | ||
|
2c8aa20542 |
@@ -3,6 +3,5 @@
|
||||
<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>
|
||||
|
@@ -66,6 +66,7 @@ endorsed.classpath=
|
||||
excludes=
|
||||
file.reference.BOSEconomy7.jar=../lib/BOSEconomy7.jar
|
||||
file.reference.bPermissions.jar=../lib/bPermissions.jar
|
||||
file.reference.bpermissions2.jar=../lib/bpermissions2.jar
|
||||
file.reference.bukkit.jar=../lib/bukkit.jar
|
||||
file.reference.craftbukkit.jar=../lib/craftbukkit.jar
|
||||
file.reference.iCo4.jar=../lib/iCo4.jar
|
||||
@@ -76,6 +77,7 @@ 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
|
||||
file.reference.Privileges.jar=..\\lib\\Privileges.jar
|
||||
file.reference.Vault.jar=../lib/Vault.jar
|
||||
includes=**
|
||||
jar.archive.disabled=${jnlp.enabled}
|
||||
@@ -95,7 +97,9 @@ javac.classpath=\
|
||||
${reference.EssentialsGroupManager.jar}:\
|
||||
${file.reference.bukkit.jar}:\
|
||||
${file.reference.craftbukkit.jar}:\
|
||||
${file.reference.Vault.jar}
|
||||
${file.reference.Vault.jar}:\
|
||||
${file.reference.Privileges.jar}:\
|
||||
${file.reference.bpermissions2.jar}
|
||||
# Space-separated list of extra javac options
|
||||
javac.compilerargs=
|
||||
javac.deprecation=false
|
||||
|
@@ -61,6 +61,12 @@ public class Backup implements Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
if ("save-all".equalsIgnoreCase(command)) {
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
active = false;
|
||||
return;
|
||||
}
|
||||
LOGGER.log(Level.INFO, _("backupStarted"));
|
||||
final CommandSender cs = server.getConsoleSender();
|
||||
server.dispatchCommand(cs, "save-all");
|
||||
|
@@ -6,12 +6,11 @@ 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.
|
||||
*
|
||||
* 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
|
||||
@@ -156,30 +155,31 @@ public final class DescParseTickFormat
|
||||
int hours = 0;
|
||||
int minutes = 0;
|
||||
|
||||
desc = desc.toLowerCase(Locale.ENGLISH).replaceAll("[^0-9]", "");
|
||||
desc = desc.toLowerCase(Locale.ENGLISH);
|
||||
String parsetime = desc.replaceAll("[^0-9]", "");
|
||||
|
||||
if (desc.length() > 4)
|
||||
if (parsetime.length() > 4)
|
||||
{
|
||||
throw new NumberFormatException();
|
||||
}
|
||||
|
||||
if (desc.length() == 4)
|
||||
if (parsetime.length() == 4)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
minutes += Integer.parseInt(desc.substring(2, 4));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 2));
|
||||
minutes += Integer.parseInt(parsetime.substring(2, 4));
|
||||
}
|
||||
else if (desc.length() == 3)
|
||||
else if (parsetime.length() == 3)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
minutes += Integer.parseInt(desc.substring(1, 3));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 1));
|
||||
minutes += Integer.parseInt(parsetime.substring(1, 3));
|
||||
}
|
||||
else if (desc.length() == 2)
|
||||
else if (parsetime.length() == 2)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 2));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 2));
|
||||
}
|
||||
else if (desc.length() == 1)
|
||||
else if (parsetime.length() == 1)
|
||||
{
|
||||
hours += Integer.parseInt(desc.substring(0, 1));
|
||||
hours += Integer.parseInt(parsetime.substring(0, 1));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@@ -19,47 +19,93 @@ public class Enchantments
|
||||
ENCHANTMENTS.put("alldamage", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("alldmg", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharpness", Enchantment.DAMAGE_ALL);
|
||||
ENCHANTMENTS.put("sharp", Enchantment.DAMAGE_ALL);
|
||||
|
||||
ENCHANTMENTS.put("arthropodsdamage", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("ardmg", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropods", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("baneofarthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
ENCHANTMENTS.put("arthropod", Enchantment.DAMAGE_ARTHROPODS);
|
||||
|
||||
ENCHANTMENTS.put("undeaddamage", Enchantment.DAMAGE_UNDEAD);
|
||||
ENCHANTMENTS.put("smite", Enchantment.DAMAGE_UNDEAD);
|
||||
|
||||
ENCHANTMENTS.put("digspeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("efficiency", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("minespeed", Enchantment.DIG_SPEED);
|
||||
ENCHANTMENTS.put("cutspeed", Enchantment.DIG_SPEED);
|
||||
|
||||
ENCHANTMENTS.put("durability", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("dura", Enchantment.DURABILITY);
|
||||
ENCHANTMENTS.put("unbreaking", Enchantment.DURABILITY);
|
||||
|
||||
ENCHANTMENTS.put("fireaspect", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("fire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleefire", Enchantment.FIRE_ASPECT);
|
||||
ENCHANTMENTS.put("meleeflame", Enchantment.FIRE_ASPECT);
|
||||
|
||||
ENCHANTMENTS.put("knockback", Enchantment.KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("blockslootbonus", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
ENCHANTMENTS.put("fortune", Enchantment.LOOT_BONUS_BLOCKS);
|
||||
|
||||
ENCHANTMENTS.put("mobslootbonus", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("mobloot", Enchantment.LOOT_BONUS_MOBS);
|
||||
ENCHANTMENTS.put("looting", Enchantment.LOOT_BONUS_MOBS);
|
||||
|
||||
ENCHANTMENTS.put("oxygen", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("respiration", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breathing", Enchantment.OXYGEN);
|
||||
ENCHANTMENTS.put("breath", Enchantment.OXYGEN);
|
||||
|
||||
ENCHANTMENTS.put("protection", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("prot", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
ENCHANTMENTS.put("protect", Enchantment.PROTECTION_ENVIRONMENTAL);
|
||||
|
||||
ENCHANTMENTS.put("explosionsprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("explosionprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("expprot", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotection", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
ENCHANTMENTS.put("blastprotect", Enchantment.PROTECTION_EXPLOSIONS);
|
||||
|
||||
ENCHANTMENTS.put("fallprotection", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("fallprot", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfall", Enchantment.PROTECTION_FALL);
|
||||
ENCHANTMENTS.put("featherfalling", Enchantment.PROTECTION_FALL);
|
||||
|
||||
ENCHANTMENTS.put("fireprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprot", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprotection", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("fireprotect", Enchantment.PROTECTION_FIRE);
|
||||
ENCHANTMENTS.put("flameprotect", Enchantment.PROTECTION_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("projectileprotection", Enchantment.PROTECTION_PROJECTILE);
|
||||
ENCHANTMENTS.put("projprot", Enchantment.PROTECTION_PROJECTILE);
|
||||
|
||||
ENCHANTMENTS.put("silktouch", Enchantment.SILK_TOUCH);
|
||||
ENCHANTMENTS.put("softtouch", Enchantment.SILK_TOUCH);
|
||||
|
||||
ENCHANTMENTS.put("waterworker", Enchantment.WATER_WORKER);
|
||||
ENCHANTMENTS.put("aquaaffinity", Enchantment.WATER_WORKER);
|
||||
|
||||
ENCHANTMENTS.put("firearrow", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flame", Enchantment.ARROW_FIRE);
|
||||
ENCHANTMENTS.put("flamearrow", Enchantment.ARROW_FIRE);
|
||||
|
||||
ENCHANTMENTS.put("arrowdamage", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("power", Enchantment.ARROW_DAMAGE);
|
||||
ENCHANTMENTS.put("arrowpower", Enchantment.ARROW_DAMAGE);
|
||||
|
||||
ENCHANTMENTS.put("arrowknockback", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowkb", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("punch", Enchantment.ARROW_KNOCKBACK);
|
||||
ENCHANTMENTS.put("arrowpunch", Enchantment.ARROW_KNOCKBACK);
|
||||
|
||||
ENCHANTMENTS.put("infinitearrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infarrows", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinity", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("infinite", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimited", Enchantment.ARROW_INFINITE);
|
||||
ENCHANTMENTS.put("unlimitedarrows", Enchantment.ARROW_INFINITE);
|
||||
}
|
||||
|
||||
public static Enchantment getByName(String name) {
|
||||
|
@@ -24,6 +24,9 @@ import com.earth2me.essentials.commands.EssentialsCommand;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.metrics.MetricsListener;
|
||||
import com.earth2me.essentials.metrics.MetricsStarter;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import com.earth2me.essentials.signs.SignBlockListener;
|
||||
@@ -33,11 +36,14 @@ import java.io.File;
|
||||
import java.io.FileReader;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
@@ -61,7 +67,7 @@ import org.yaml.snakeyaml.error.YAMLException;
|
||||
|
||||
public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
public static final int BUKKIT_VERSION = 1818;
|
||||
public static final int BUKKIT_VERSION = 2149;
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient ISettings settings;
|
||||
private final transient TNTExplodeListener tntListener = new TNTExplodeListener(this);
|
||||
@@ -77,6 +83,9 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
private transient UserMap userMap;
|
||||
private transient ExecuteTimer execTimer;
|
||||
private transient I18n i18n;
|
||||
private transient Metrics metrics;
|
||||
private transient EssentialsTimer timer;
|
||||
private transient List<String> vanishedPlayers = new ArrayList<String>();
|
||||
|
||||
@Override
|
||||
public ISettings getSettings()
|
||||
@@ -119,19 +128,22 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
for (Plugin plugin : pm.getPlugins())
|
||||
{
|
||||
if (plugin.getDescription().getName().startsWith("Essentials")
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion()))
|
||||
&& !plugin.getDescription().getVersion().equals(this.getDescription().getVersion())
|
||||
&& !plugin.getDescription().getName().equals("EssentialsAntiCheat"))
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("versionMismatch", plugin.getDescription().getName()));
|
||||
}
|
||||
}
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-([0-9]+).([0-9]+).([0-9]+)-R[0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(4));
|
||||
if (versionNumber < BUKKIT_VERSION)
|
||||
final int versionNumber = Integer.parseInt(versionMatch.group(1));
|
||||
if (versionNumber < BUKKIT_VERSION && versionNumber > 100)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
|
||||
LOGGER.log(Level.SEVERE, _("notRecommendedBukkit"));
|
||||
LOGGER.log(Level.SEVERE, _("requiredBukkit", Integer.toString(BUKKIT_VERSION)));
|
||||
LOGGER.log(Level.SEVERE, " * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! * ! *");
|
||||
this.setEnabled(false);
|
||||
return;
|
||||
}
|
||||
@@ -218,7 +230,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
final EssentialsEntityListener entityListener = new EssentialsEntityListener(this);
|
||||
pm.registerEvents(entityListener, this);
|
||||
|
||||
|
||||
final EssentialsWorldListener worldListener = new EssentialsWorldListener(this);
|
||||
pm.registerEvents(worldListener, this);
|
||||
|
||||
@@ -228,10 +240,23 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
|
||||
pm.registerEvents(tntListener, this);
|
||||
|
||||
final EssentialsTimer timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 1, 100);
|
||||
timer = new EssentialsTimer(this);
|
||||
getScheduler().scheduleSyncRepeatingTask(this, timer, 100, 100);
|
||||
|
||||
Economy.setEss(this);
|
||||
execTimer.mark("RegListeners");
|
||||
|
||||
final MetricsStarter metricsStarter = new MetricsStarter(this);
|
||||
if (metricsStarter.getStart() != null && metricsStarter.getStart() == true)
|
||||
{
|
||||
getScheduler().scheduleAsyncDelayedTask(this, metricsStarter, 1);
|
||||
}
|
||||
else if (metricsStarter.getStart() != null && metricsStarter.getStart() == false)
|
||||
{
|
||||
final MetricsListener metricsListener = new MetricsListener(this, metricsStarter);
|
||||
pm.registerEvents(metricsListener, this);
|
||||
}
|
||||
|
||||
final String timeroutput = execTimer.end();
|
||||
if (getSettings().isDebug())
|
||||
{
|
||||
@@ -242,6 +267,15 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
@Override
|
||||
public void onDisable()
|
||||
{
|
||||
for (Player p : getServer().getOnlinePlayers())
|
||||
{
|
||||
User user = getUser(p);
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.toggleVanished();
|
||||
p.sendMessage(_("unvanishedReload"));
|
||||
}
|
||||
}
|
||||
i18n.onDisable();
|
||||
Economy.setEss(null);
|
||||
Trade.closeLog();
|
||||
@@ -277,7 +311,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
if (pc != null)
|
||||
{
|
||||
alternativeCommandsHandler.executed(commandLabel, pc.getLabel());
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
try
|
||||
{
|
||||
return pc.execute(sender, commandLabel, args);
|
||||
}
|
||||
catch (final Exception ex)
|
||||
{
|
||||
Bukkit.getLogger().log(Level.SEVERE, ex.getMessage(), ex);
|
||||
sender.sendMessage(ChatColor.RED + "An internal error occurred while attempting to perform this command");
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -408,6 +451,16 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
return backup;
|
||||
}
|
||||
|
||||
public Metrics getMetrics()
|
||||
{
|
||||
return metrics;
|
||||
}
|
||||
|
||||
public void setMetrics(Metrics metrics)
|
||||
{
|
||||
this.metrics = metrics;
|
||||
}
|
||||
|
||||
@Override
|
||||
public User getUser(final Object base)
|
||||
{
|
||||
@@ -504,7 +557,7 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
for (Player player : players)
|
||||
{
|
||||
final User user = getUser(player);
|
||||
if (!user.isIgnoredPlayer(sender.getName()))
|
||||
if (!user.isIgnoredPlayer(sender))
|
||||
{
|
||||
player.sendMessage(message);
|
||||
}
|
||||
@@ -572,15 +625,27 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
{
|
||||
return i18n;
|
||||
}
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable {
|
||||
|
||||
@Override
|
||||
public EssentialsTimer getTimer()
|
||||
{
|
||||
return timer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getVanishedPlayers()
|
||||
{
|
||||
return vanishedPlayers;
|
||||
}
|
||||
|
||||
private static class EssentialsWorldListener implements Listener, Runnable
|
||||
{
|
||||
private transient final IEssentials ess;
|
||||
|
||||
public EssentialsWorldListener(final IEssentials ess)
|
||||
{
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onWorldLoad(final WorldLoadEvent event)
|
||||
@@ -589,7 +654,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule) {
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
@@ -602,7 +668,8 @@ public class Essentials extends JavaPlugin implements IEssentials
|
||||
ess.getWarps().reloadConfig();
|
||||
for (IConf iConf : ((Essentials)ess).confList)
|
||||
{
|
||||
if (iConf instanceof IEssentialsModule) {
|
||||
if (iConf instanceof IEssentialsModule)
|
||||
{
|
||||
iConf.reloadConfig();
|
||||
}
|
||||
}
|
||||
|
@@ -17,22 +17,18 @@ public class EssentialsBlockListener implements Listener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
// Do not rely on getItemInHand();
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
// http://leaky.bukkit.org/issues/663
|
||||
final ItemStack is = Util.convertBlockToItem(event.getBlockPlaced());
|
||||
if (is == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final boolean unlimitedForUser = user.hasUnlimited(is);
|
||||
if (unlimitedForUser && user.getGameMode() == GameMode.SURVIVAL)
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
|
@@ -1,9 +1,15 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.google.common.io.Files;
|
||||
import java.io.*;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.CharBuffer;
|
||||
import java.nio.channels.FileChannel;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.CharsetDecoder;
|
||||
import java.nio.charset.CoderResult;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
@@ -12,30 +18,28 @@ import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.InvalidConfigurationException;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.util.config.Configuration;
|
||||
|
||||
|
||||
public class EssentialsConf extends Configuration
|
||||
public class EssentialsConf extends YamlConfiguration
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private transient File configFile;
|
||||
private transient String templateName = null;
|
||||
private transient Class<?> resourceClass = EssentialsConf.class;
|
||||
private static final Charset UTF8 = Charset.forName("UTF-8");
|
||||
|
||||
public EssentialsConf(final File configFile)
|
||||
{
|
||||
super(configFile);
|
||||
super();
|
||||
this.configFile = configFile;
|
||||
if (this.root == null)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void load()
|
||||
public synchronized void load()
|
||||
{
|
||||
configFile = configFile.getAbsoluteFile();
|
||||
if (!configFile.getParentFile().exists())
|
||||
@@ -105,19 +109,57 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
try
|
||||
{
|
||||
super.load();
|
||||
final FileInputStream inputStream = new FileInputStream(configFile);
|
||||
try
|
||||
{
|
||||
final FileChannel channel = inputStream.getChannel();
|
||||
final ByteBuffer buffer = ByteBuffer.allocate((int)configFile.length());
|
||||
channel.read(buffer);
|
||||
buffer.rewind();
|
||||
final CharBuffer data = CharBuffer.allocate((int)configFile.length());
|
||||
CharsetDecoder decoder = UTF8.newDecoder();
|
||||
CoderResult result = decoder.decode(buffer, data, true);
|
||||
if (result.isError())
|
||||
{
|
||||
buffer.rewind();
|
||||
data.clear();
|
||||
LOGGER.log(Level.INFO, "File " + configFile.getAbsolutePath().toString() + " is not utf-8 encoded, trying " + Charset.defaultCharset().displayName());
|
||||
decoder = Charset.defaultCharset().newDecoder();
|
||||
result = decoder.decode(buffer, data, true);
|
||||
if (result.isError())
|
||||
{
|
||||
throw new InvalidConfigurationException("Invalid Characters in file " + configFile.getAbsolutePath().toString());
|
||||
}
|
||||
else
|
||||
{
|
||||
decoder.flush(data);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
decoder.flush(data);
|
||||
}
|
||||
final int end = data.position();
|
||||
data.rewind();
|
||||
super.loadFromString(data.subSequence(0, end).toString());
|
||||
}
|
||||
finally
|
||||
{
|
||||
inputStream.close();
|
||||
}
|
||||
}
|
||||
catch (RuntimeException e)
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, "File broken: " + configFile.toString());
|
||||
throw e;
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
|
||||
if (this.root == null)
|
||||
catch (InvalidConfigurationException ex)
|
||||
{
|
||||
this.root = new HashMap<String, Object>();
|
||||
File broken = new File(configFile.getAbsolutePath() + ".broken." + System.currentTimeMillis());
|
||||
configFile.renameTo(broken);
|
||||
LOGGER.log(Level.SEVERE, "The file " + configFile.toString() + " is broken, it has been renamed to " + broken.toString(), ex.getCause());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -192,7 +234,7 @@ public class EssentialsConf extends Configuration
|
||||
|
||||
public boolean hasProperty(final String path)
|
||||
{
|
||||
return getProperty(path) != null;
|
||||
return isSet(path);
|
||||
}
|
||||
|
||||
public Location getLocation(final String path, final Server server) throws Exception
|
||||
@@ -217,24 +259,25 @@ public class EssentialsConf extends Configuration
|
||||
|
||||
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());
|
||||
set((path == null ? "" : path + ".") + "world", loc.getWorld().getName());
|
||||
set((path == null ? "" : path + ".") + "x", loc.getX());
|
||||
set((path == null ? "" : path + ".") + "y", loc.getY());
|
||||
set((path == null ? "" : path + ".") + "z", loc.getZ());
|
||||
set((path == null ? "" : path + ".") + "yaw", loc.getYaw());
|
||||
set((path == null ? "" : path + ".") + "pitch", loc.getPitch());
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemStack(final String path)
|
||||
{
|
||||
final ItemStack stack = new ItemStack(
|
||||
Material.valueOf(getString(path + ".type", "AIR")),
|
||||
getInt(path + ".amount", 1),
|
||||
(short)getInt(path + ".damage", 0));
|
||||
final List<String> enchants = getKeys(path + ".enchant");
|
||||
final ConfigurationSection enchants = getConfigurationSection(path + ".enchant");
|
||||
if (enchants != null)
|
||||
{
|
||||
for (String enchant : enchants)
|
||||
for (String enchant : enchants.getKeys(false))
|
||||
{
|
||||
final Enchantment enchantment = Enchantment.getByName(enchant.toUpperCase(Locale.ENGLISH));
|
||||
if (enchantment == null)
|
||||
@@ -270,14 +313,14 @@ public class EssentialsConf extends Configuration
|
||||
}
|
||||
// getData().getData() is broken
|
||||
//map.put("data", stack.getDurability());
|
||||
setProperty(path, map);
|
||||
set(path, map);
|
||||
}
|
||||
|
||||
public long getLong(final String path, final long def)
|
||||
{
|
||||
try
|
||||
{
|
||||
final Number num = (Number)getProperty(path);
|
||||
final Number num = (Number)get(path);
|
||||
return num == null ? def : num.longValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
@@ -291,7 +334,7 @@ public class EssentialsConf extends Configuration
|
||||
{
|
||||
try
|
||||
{
|
||||
Number num = (Number)getProperty(path);
|
||||
Number num = (Number)get(path);
|
||||
return num == null ? def : num.doubleValue();
|
||||
}
|
||||
catch (ClassCastException ex)
|
||||
@@ -299,4 +342,55 @@ public class EssentialsConf extends Configuration
|
||||
return def;
|
||||
}
|
||||
}
|
||||
|
||||
public void save()
|
||||
{
|
||||
try
|
||||
{
|
||||
save(configFile);
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
LOGGER.log(Level.SEVERE, ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public synchronized void save(final File file) throws IOException
|
||||
{
|
||||
if (file == null)
|
||||
{
|
||||
throw new IllegalArgumentException("File cannot be null");
|
||||
}
|
||||
|
||||
Files.createParentDirs(file);
|
||||
|
||||
final String data = saveToString();
|
||||
|
||||
final OutputStreamWriter writer = new OutputStreamWriter(new FileOutputStream(file), UTF8);
|
||||
|
||||
try
|
||||
{
|
||||
writer.write(data);
|
||||
}
|
||||
finally
|
||||
{
|
||||
writer.close();
|
||||
}
|
||||
}
|
||||
|
||||
public Object getProperty(String path)
|
||||
{
|
||||
return get(path);
|
||||
}
|
||||
|
||||
public void setProperty(String path, Object object)
|
||||
{
|
||||
set(path, object);
|
||||
}
|
||||
|
||||
public void removeProperty(String path)
|
||||
{
|
||||
set(path, null);
|
||||
}
|
||||
}
|
||||
|
@@ -3,14 +3,14 @@ package com.earth2me.essentials;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.event.entity.*;
|
||||
import org.bukkit.event.entity.EntityRegainHealthEvent.RegainReason;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -23,49 +23,69 @@ public class EssentialsEntityListener implements Listener
|
||||
this.ess = ess;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDamage(EntityDamageEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onEntityDamage(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (event instanceof EntityDamageByEntityEvent)
|
||||
final Entity eAttack = event.getDamager();
|
||||
final Entity eDefend = event.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
EntityDamageByEntityEvent edEvent = (EntityDamageByEntityEvent)event;
|
||||
Entity eAttack = edEvent.getDamager();
|
||||
Entity eDefend = edEvent.getEntity();
|
||||
if (eDefend instanceof Player && eAttack instanceof Player)
|
||||
{
|
||||
User defender = ess.getUser(eDefend);
|
||||
User attacker = ess.getUser(eAttack);
|
||||
attacker.updateActivity(true);
|
||||
ItemStack is = attacker.getItemInHand();
|
||||
List<String> commandList = attacker.getPowertool(is);
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (String command : commandList)
|
||||
{
|
||||
final User defender = ess.getUser(eDefend);
|
||||
final User attacker = ess.getUser(eAttack);
|
||||
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker, command.replaceAll("\\{player\\}", defender.getName()));
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().getLoginAttackDelay() > 0 && !attacker.isAuthorized("essentials.pvpdelay.exempt")
|
||||
&& (System.currentTimeMillis() < (attacker.getLastLogin() + ess.getSettings().getLoginAttackDelay())))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
if (attacker.hasInvulnerabilityAfterTeleport() || defender.hasInvulnerabilityAfterTeleport())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
attacker.updateActivity(true);
|
||||
final List<String> commandList = attacker.getPowertool(attacker.getItemInHand());
|
||||
if (commandList != null && !commandList.isEmpty())
|
||||
{
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command != null && !command.isEmpty())
|
||||
{
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
attacker.getServer().dispatchCommand(attacker.getBase(), command.replaceAll("\\{player\\}", defender.getName()));
|
||||
}
|
||||
});
|
||||
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (eDefend instanceof Animals && eAttack instanceof Player)
|
||||
}
|
||||
else if (eDefend instanceof Ageable && eAttack instanceof Player)
|
||||
{
|
||||
final Player player = (Player)eAttack;
|
||||
final ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
User player = ess.getUser(eAttack);
|
||||
ItemStack hand = player.getItemInHand();
|
||||
if (hand != null && hand.getType() == Material.MILK_BUCKET)
|
||||
{
|
||||
((Animals)eDefend).setAge(-24000);
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
((Ageable)eDefend).setBaby();
|
||||
hand.setType(Material.BUCKET);
|
||||
player.setItemInHand(hand);
|
||||
player.updateInventory();
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamage(final EntityDamageEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
final Player player = (Player)event.getEntity();
|
||||
@@ -75,8 +95,8 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityCombust(EntityCombustEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityCombust(final EntityCombustEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
@@ -85,26 +105,22 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityDeath(final EntityDeathEvent event)
|
||||
public void onPlayerDeathEvent(final PlayerDeathEvent event)
|
||||
{
|
||||
if (event instanceof PlayerDeathEvent)
|
||||
final User user = ess.getUser(event.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
final PlayerDeathEvent pdevent = (PlayerDeathEvent)event;
|
||||
final User user = ess.getUser(pdevent.getEntity());
|
||||
if (user.isAuthorized("essentials.back.ondeath") && !ess.getSettings().isCommandDisabled("back"))
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
pdevent.setDeathMessage("");
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.sendMessage(_("backAfterDeath"));
|
||||
}
|
||||
if (!ess.getSettings().areDeathMessagesEnabled())
|
||||
{
|
||||
event.setDeathMessage("");
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onFoodLevelChange(FoodLevelChangeEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onFoodLevelChange(final FoodLevelChangeEvent event)
|
||||
{
|
||||
if (event.getEntity() instanceof Player && ess.getUser(event.getEntity()).isGodModeEnabled())
|
||||
{
|
||||
@@ -112,8 +128,8 @@ public class EssentialsEntityListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onEntityRegainHealth(EntityRegainHealthEvent event)
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityRegainHealth(final EntityRegainHealthEvent event)
|
||||
{
|
||||
if (event.getRegainReason() == RegainReason.SATIATED && event.getEntity() instanceof Player
|
||||
&& ess.getUser(event.getEntity()).isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
|
@@ -14,28 +14,31 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||
import org.bukkit.event.inventory.InventoryType;
|
||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.InventoryHolder;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
private static final Logger LOGGER = Logger.getLogger("Minecraft");
|
||||
private final transient Server server;
|
||||
private final transient IEssentials ess;
|
||||
private static final int AIR = Material.AIR.getId();
|
||||
private static final int BED = Material.BED_BLOCK.getId();
|
||||
|
||||
public EssentialsPlayerListener(final IEssentials parent)
|
||||
{
|
||||
this.ess = parent;
|
||||
this.server = parent.getServer();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
@@ -43,10 +46,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
@@ -63,27 +63,27 @@ public class EssentialsPlayerListener implements Listener
|
||||
while (it.hasNext())
|
||||
{
|
||||
final User u = ess.getUser(it.next());
|
||||
if (u.isIgnoredPlayer(user.getName()))
|
||||
if (u.isIgnoredPlayer(user))
|
||||
{
|
||||
it.remove();
|
||||
}
|
||||
}
|
||||
user.updateActivity(true);
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
{
|
||||
user.setDisplayNick();
|
||||
}
|
||||
user.setDisplayNick();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerMove(final PlayerMoveEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
if ((!ess.getSettings().cancelAfkOnMove() && !ess.getSettings().getFreezeAfkPlayers())
|
||||
|| event.getFrom().getBlockX() == event.getTo().getBlockX()
|
||||
&& event.getFrom().getBlockZ() == event.getTo().getBlockZ()
|
||||
&& event.getFrom().getBlockY() == event.getTo().getBlockY())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk() && ess.getSettings().getFreezeAfkPlayers())
|
||||
{
|
||||
final Location from = event.getFrom();
|
||||
@@ -101,7 +101,6 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
final Location afk = user.getAfkPosition();
|
||||
if (afk == null || !event.getTo().getWorld().equals(afk.getWorld()) || afk.distanceSquared(event.getTo()) > 9)
|
||||
{
|
||||
@@ -115,13 +114,13 @@ public class EssentialsPlayerListener implements Listener
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (ess.getSettings().removeGodOnDisconnect() && user.isGodModeEnabled())
|
||||
{
|
||||
user.toggleGodModeEnabled();
|
||||
user.setGodModeEnabled(false);
|
||||
}
|
||||
if (user.getSavedInventory() != null)
|
||||
if (user.isVanished())
|
||||
{
|
||||
user.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.toggleVanished();
|
||||
}
|
||||
user.setLastLocation();
|
||||
user.updateActivity(false);
|
||||
user.dispose();
|
||||
}
|
||||
@@ -129,15 +128,37 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
ess.scheduleAsyncDelayedTask(new Runnable()
|
||||
{
|
||||
user.setDisplayNick();
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
delayedJoin(event.getPlayer());
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void delayedJoin(final Player player)
|
||||
{
|
||||
if (!player.isOnline())
|
||||
{
|
||||
return;
|
||||
}
|
||||
user.setLastLoginAddress(user.getAddress().getAddress().getHostAddress());
|
||||
ess.getBackup().onPlayerJoin();
|
||||
final User user = ess.getUser(player);
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
user.updateActivity(false);
|
||||
|
||||
for (String p : ess.getVanishedPlayers())
|
||||
{
|
||||
if (!user.isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
user.hidePlayer(ess.getUser(p).getBase());
|
||||
}
|
||||
}
|
||||
|
||||
if (user.isAuthorized("essentials.sleepingignored"))
|
||||
{
|
||||
user.setSleepingIgnored(true);
|
||||
@@ -179,39 +200,6 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.getResult() != Result.ALLOWED && event.getResult() != Result.KICK_FULL && event.getResult() != Result.KICK_BANNED)
|
||||
{
|
||||
return;
|
||||
}
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
user.setNPC(false);
|
||||
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (banExpired == false && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
|
||||
if (server.getOnlinePlayers().length >= server.getMaxPlayers() && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
|
||||
user.setLastLogin(System.currentTimeMillis());
|
||||
updateCompass(user);
|
||||
}
|
||||
|
||||
private void updateCompass(final User user)
|
||||
{
|
||||
Location loc = user.getHome(user.getLocation());
|
||||
@@ -221,33 +209,78 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
if (loc != null)
|
||||
{
|
||||
user.setCompassTarget(loc);
|
||||
final Location updateLoc = loc;
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.setCompassTarget(updateLoc);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
public void onPlayerLogin(final PlayerLoginEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
switch (event.getResult())
|
||||
{
|
||||
case ALLOWED:
|
||||
case KICK_FULL:
|
||||
case KICK_BANNED:
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if ((event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND) && ess.getSettings().registerBackInListener())
|
||||
if (user.isNPC())
|
||||
{
|
||||
user.setLastLocation();
|
||||
user.setNPC(false);
|
||||
}
|
||||
|
||||
if (ess.getSettings().changeDisplayName())
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
final boolean banExpired = user.checkBanTimeout(currentTime);
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
|
||||
if (!banExpired && (user.isBanned() || event.getResult() == Result.KICK_BANNED))
|
||||
{
|
||||
user.setDisplayNick();
|
||||
final String banReason = user.getBanReason();
|
||||
event.disallow(Result.KICK_BANNED, banReason != null && !banReason.isEmpty() && !banReason.equalsIgnoreCase("ban") ? banReason : _("defaultBanReason"));
|
||||
return;
|
||||
}
|
||||
updateCompass(user);
|
||||
|
||||
if (event.getResult() == Result.KICK_FULL && !user.isAuthorized("essentials.joinfullserver"))
|
||||
{
|
||||
event.disallow(Result.KICK_FULL, _("serverFull"));
|
||||
return;
|
||||
}
|
||||
event.allow();
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final boolean backListener = ess.getSettings().registerBackInListener();
|
||||
final boolean teleportInvulnerability = ess.getSettings().isTeleportInvulnerability();
|
||||
if (backListener || teleportInvulnerability)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
//There is TeleportCause.COMMMAND but plugins have to actively pass the cause in on their teleports.
|
||||
if (backListener && (event.getCause() == TeleportCause.PLUGIN || event.getCause() == TeleportCause.COMMAND))
|
||||
{
|
||||
user.setLastLocation();
|
||||
}
|
||||
if (teleportInvulnerability)
|
||||
{
|
||||
user.enableInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerEggThrow(final PlayerEggThrowEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -259,7 +292,7 @@ public class EssentialsPlayerListener implements Listener
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||
public void onPlayerBucketEmpty(final PlayerBucketEmptyEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -276,75 +309,27 @@ public class EssentialsPlayerListener implements Listener
|
||||
});
|
||||
}
|
||||
}
|
||||
private final static List<String> COMMANDS = Arrays.asList("msg", "r", "mail", "m", "t", "whisper", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerAnimation(final PlayerAnimationEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.updateActivity(true);
|
||||
if (event.getAnimationType() == PlayerAnimationType.ARM_SWING
|
||||
&& user.hasPowerTools() && user.arePowerToolsEnabled())
|
||||
{
|
||||
usePowertools(user);
|
||||
}
|
||||
}
|
||||
|
||||
private void usePowertools(final User user)
|
||||
{
|
||||
final ItemStack is = user.getItemInHand();
|
||||
int id;
|
||||
if (is == null || (id = is.getTypeId()) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// We need to loop through each command and execute
|
||||
for (String command : commandList)
|
||||
{
|
||||
if (command.matches(".*\\{player\\}.*"))
|
||||
{
|
||||
//user.sendMessage("Click a player to use this command");
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||
public void onPlayerCommandPreprocess(final PlayerCommandPreprocessEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final Player player = event.getPlayer();
|
||||
final String cmd = event.getMessage().toLowerCase(Locale.ENGLISH).split(" ")[0].replace("/", "").toLowerCase(Locale.ENGLISH);
|
||||
final List<String> commands = Arrays.asList("msg", "r", "mail", "m", "t", "emsg", "tell", "er", "reply", "ereply", "email");
|
||||
if (commands.contains(cmd))
|
||||
if (COMMANDS.contains(cmd))
|
||||
{
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
for (Player onlinePlayer : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
User spyer = ess.getUser(player);
|
||||
if (spyer.isSocialSpyEnabled() && !user.equals(spyer))
|
||||
final User spyer = ess.getUser(onlinePlayer);
|
||||
if (spyer.isSocialSpyEnabled() && !player.equals(onlinePlayer))
|
||||
{
|
||||
player.sendMessage(user.getDisplayName() + " : " + event.getMessage());
|
||||
onlinePlayer.sendMessage(player.getDisplayName() + " : " + event.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
if (!cmd.equalsIgnoreCase("afk"))
|
||||
else if (!cmd.equalsIgnoreCase("afk"))
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
user.updateActivity(true);
|
||||
}
|
||||
}
|
||||
@@ -352,45 +337,126 @@ public class EssentialsPlayerListener implements Listener
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerChangedWorld(final PlayerChangedWorldEvent event)
|
||||
{
|
||||
if (ess.getSettings().getNoGodWorlds().contains(event.getPlayer().getLocation().getWorld().getName()))
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
final String newWorld = event.getPlayer().getLocation().getWorld().getName();
|
||||
user.setDisplayNick();
|
||||
updateCompass(user);
|
||||
if (ess.getSettings().getNoGodWorlds().contains(newWorld) && user.isGodModeEnabledRaw())
|
||||
{
|
||||
User user = ess.getUser(event.getPlayer());
|
||||
if (user.isGodModeEnabledRaw())
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
}
|
||||
|
||||
if (!event.getPlayer().getWorld().getName().equals(newWorld))
|
||||
{
|
||||
user.sendMessage(_("currentWorld", newWorld));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.NORMAL)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
switch (event.getAction())
|
||||
{
|
||||
case RIGHT_CLICK_BLOCK:
|
||||
if (!event.isCancelled() && event.getClickedBlock().getTypeId() == BED && ess.getSettings().getUpdateBedAtDaytime())
|
||||
{
|
||||
user.sendMessage(_("noGodWorldWarning"));
|
||||
Player player = event.getPlayer();
|
||||
player.setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
player.sendMessage(_("homeSet", player.getLocation().getWorld().getName(), player.getLocation().getBlockX(), player.getLocation().getBlockY(), player.getLocation().getBlockZ()));
|
||||
}
|
||||
break;
|
||||
case LEFT_CLICK_AIR:
|
||||
case LEFT_CLICK_BLOCK:
|
||||
if (event.getItem() != null && event.getItem().getTypeId() != AIR)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.hasPowerTools() && user.arePowerToolsEnabled() && usePowertools(user, event.getItem().getTypeId()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private boolean usePowertools(final User user, final int id)
|
||||
{
|
||||
final List<String> commandList = user.getPowertool(id);
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
boolean used = false;
|
||||
// We need to loop through each command and execute
|
||||
for (final String command : commandList)
|
||||
{
|
||||
if (command.contains("{player}"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else if (command.startsWith("c:"))
|
||||
{
|
||||
used = true;
|
||||
user.chat(command.substring(2));
|
||||
}
|
||||
else
|
||||
{
|
||||
used = true;
|
||||
ess.scheduleSyncDelayedTask(
|
||||
new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
user.getServer().dispatchCommand(user.getBase(), command);
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
return used;
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerPickupItem(final PlayerPickupItemEvent event)
|
||||
{
|
||||
if (ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
if (ess.getUser(event.getPlayer()).isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOWEST)
|
||||
public void onInventoryClickEvent(final InventoryClickEvent event)
|
||||
{
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(event.getWhoClicked());
|
||||
final InventoryHolder invHolder = event.getView().getTopInventory().getHolder();
|
||||
if (invHolder != null && invHolder instanceof HumanEntity)
|
||||
{
|
||||
final User invOwner = ess.getUser((HumanEntity)invHolder);
|
||||
if (user.isInvSee() && (!user.isAuthorized("essentials.invsee.modify")
|
||||
|| invOwner.isAuthorized("essentials.invsee.preventmodify")
|
||||
|| !invOwner.isOnline()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.MONITOR)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
public void onInventoryCloseEvent(final InventoryCloseEvent event)
|
||||
{
|
||||
if (event.isCancelled())
|
||||
if (event.getView().getTopInventory().getType() == InventoryType.PLAYER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (ess.getSettings().getUpdateBedAtDaytime() && event.getClickedBlock().getType() == Material.BED_BLOCK)
|
||||
{
|
||||
event.getPlayer().setBedSpawnLocation(event.getClickedBlock().getLocation());
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onPlayerPickupItem(PlayerPickupItemEvent event)
|
||||
{
|
||||
if (event.isCancelled() || !ess.getSettings().getDisableItemPickupWhileAfk())
|
||||
{
|
||||
return;
|
||||
}
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
if (user.isAfk())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
user.setInvSee(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class EssentialsPluginListener implements Listener, IConf
|
||||
ess.getAlternativeCommandsHandler().addPlugin(event.getPlugin());
|
||||
if (!ess.getPaymentMethod().hasMethod() && ess.getPaymentMethod().setMethod(ess.getServer().getPluginManager()))
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
ess.getLogger().log(Level.INFO, "Payment method found (" + ess.getPaymentMethod().getMethod().getLongName() + " version: " + ess.getPaymentMethod().getMethod().getVersion() + ")");
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -2,7 +2,9 @@ package com.earth2me.essentials;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.LinkedList;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -10,6 +12,8 @@ public class EssentialsTimer implements Runnable
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
private final transient Set<User> onlineUsers = new HashSet<User>();
|
||||
private transient long lastPoll = System.currentTimeMillis();
|
||||
private final transient LinkedList<Float> history = new LinkedList<Float>();
|
||||
|
||||
EssentialsTimer(final IEssentials ess)
|
||||
{
|
||||
@@ -20,12 +24,34 @@ public class EssentialsTimer implements Runnable
|
||||
public void run()
|
||||
{
|
||||
final long currentTime = System.currentTimeMillis();
|
||||
long timeSpent = (currentTime - lastPoll) / 1000;
|
||||
if (timeSpent == 0)
|
||||
{
|
||||
timeSpent = 1;
|
||||
}
|
||||
if (history.size() > 10)
|
||||
{
|
||||
history.remove();
|
||||
}
|
||||
float tps = 100f / timeSpent;
|
||||
if (tps <= 20)
|
||||
{
|
||||
history.add(tps);
|
||||
}
|
||||
lastPoll = currentTime;
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
try
|
||||
{
|
||||
final User user = ess.getUser(player);
|
||||
onlineUsers.add(user);
|
||||
user.setLastOnlineActivity(currentTime);
|
||||
user.checkActivity();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, "EssentialsTimer Error:", e);
|
||||
}
|
||||
}
|
||||
|
||||
final Iterator<User> iterator = onlineUsers.iterator();
|
||||
@@ -40,6 +66,20 @@ public class EssentialsTimer implements Runnable
|
||||
}
|
||||
user.checkMuteTimeout(currentTime);
|
||||
user.checkJailTimeout(currentTime);
|
||||
user.resetInvulnerabilityAfterTeleport();
|
||||
}
|
||||
}
|
||||
|
||||
public float getAverageTPS()
|
||||
{
|
||||
float avg = 0;
|
||||
for (Float f : history)
|
||||
{
|
||||
if (f != null)
|
||||
{
|
||||
avg += f;
|
||||
}
|
||||
}
|
||||
return avg / history.size();
|
||||
}
|
||||
}
|
||||
|
@@ -95,7 +95,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
final EssentialsConf conf = new EssentialsConf(configFile);
|
||||
conf.load();
|
||||
List<String> lines = conf.getStringList(name, null);
|
||||
List<String> lines = conf.getStringList(name);
|
||||
if (lines != null && !lines.isEmpty())
|
||||
{
|
||||
if (!file.createNewFile())
|
||||
@@ -271,18 +271,18 @@ public class EssentialsUpgrade
|
||||
if (config.hasProperty("powertools"))
|
||||
{
|
||||
@SuppressWarnings("unchecked")
|
||||
final Map<Integer, Object> powertools = (Map<Integer, Object>)config.getProperty("powertools");
|
||||
final Map<String, Object> powertools = config.getConfigurationSection("powertools").getValues(false);
|
||||
if (powertools == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
for (Map.Entry<Integer, Object> entry : powertools.entrySet())
|
||||
for (Map.Entry<String, 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);
|
||||
((Map<String, Object>)powertools).put(entry.getKey(), temp);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
@@ -332,7 +332,7 @@ public class EssentialsUpgrade
|
||||
config.setProperty("homes.home", defloc);
|
||||
}
|
||||
|
||||
List<String> worlds = config.getKeys("home.worlds");
|
||||
Set<String> worlds = config.getConfigurationSection("home.worlds").getKeys(false);
|
||||
Location loc;
|
||||
String worldName;
|
||||
|
||||
@@ -381,7 +381,7 @@ public class EssentialsUpgrade
|
||||
}
|
||||
final EssentialsConf usersConfig = new EssentialsConf(usersFile);
|
||||
usersConfig.load();
|
||||
for (String username : usersConfig.getKeys(null))
|
||||
for (String username : usersConfig.getKeys(false))
|
||||
{
|
||||
final User user = new User(new OfflinePlayer(username, ess), ess);
|
||||
final String nickname = usersConfig.getString(username + ".nickname");
|
||||
@@ -389,7 +389,7 @@ public class EssentialsUpgrade
|
||||
{
|
||||
user.setNickname(nickname);
|
||||
}
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail", null);
|
||||
final List<String> mails = usersConfig.getStringList(username + ".mail");
|
||||
if (mails != null && !mails.isEmpty())
|
||||
{
|
||||
user.setMails(mails);
|
||||
@@ -701,7 +701,7 @@ public class EssentialsUpgrade
|
||||
if (!config.hasProperty("spawns"))
|
||||
{
|
||||
final Spawns spawns = new Spawns();
|
||||
List<String> keys = config.getKeys();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String group : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, group);
|
||||
@@ -730,7 +730,7 @@ public class EssentialsUpgrade
|
||||
doneFile.setProperty("updateSpawnsToNewSpawnsConfig", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
|
||||
private void updateJailsToNewJailsConfig()
|
||||
{
|
||||
if (doneFile.getBoolean("updateJailsToNewJailsConfig", false))
|
||||
@@ -748,7 +748,7 @@ public class EssentialsUpgrade
|
||||
if (!config.hasProperty("jails"))
|
||||
{
|
||||
final com.earth2me.essentials.settings.Jails jails = new com.earth2me.essentials.settings.Jails();
|
||||
List<String> keys = config.getKeys();
|
||||
Set<String> keys = config.getKeys(false);
|
||||
for (String jailName : keys)
|
||||
{
|
||||
Location loc = getFakeLocation(config, jailName);
|
||||
@@ -778,6 +778,17 @@ public class EssentialsUpgrade
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
private void warnMetrics()
|
||||
{
|
||||
if (doneFile.getBoolean("warnMetrics", false))
|
||||
{
|
||||
return;
|
||||
}
|
||||
ess.getSettings().setMetricsEnabled(false);
|
||||
doneFile.setProperty("warnMetrics", true);
|
||||
doneFile.save();
|
||||
}
|
||||
|
||||
public void beforeSettings()
|
||||
{
|
||||
if (!ess.getDataFolder().exists())
|
||||
@@ -800,5 +811,6 @@ public class EssentialsUpgrade
|
||||
deleteOldItemsCsv();
|
||||
updateSpawnsToNewSpawnsConfig();
|
||||
updateJailsToNewJailsConfig();
|
||||
warnMetrics();
|
||||
}
|
||||
}
|
||||
|
@@ -114,6 +114,7 @@ public class I18n implements II18n
|
||||
{
|
||||
currentLocale = new Locale(parts[0], parts[1], parts[2]);
|
||||
}
|
||||
ResourceBundle.clearCache();
|
||||
Logger.getLogger("Minecraft").log(Level.INFO, String.format("Using locale %s", currentLocale.toString()));
|
||||
customBundle = ResourceBundle.getBundle(MESSAGES, currentLocale, new FileResClassLoader(I18n.class.getClassLoader(), ess));
|
||||
localeBundle = ResourceBundle.getBundle(MESSAGES, currentLocale);
|
||||
|
@@ -1,14 +1,17 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import com.earth2me.essentials.perm.PermissionsHandler;
|
||||
import com.earth2me.essentials.register.payment.Methods;
|
||||
import java.util.List;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.scheduler.BukkitScheduler;
|
||||
|
||||
|
||||
/**
|
||||
* @deprecated This will be moved to the api package soon
|
||||
*/
|
||||
@@ -64,4 +67,12 @@ public interface IEssentials extends Plugin
|
||||
ItemDb getItemDb();
|
||||
|
||||
UserMap getUserMap();
|
||||
|
||||
Metrics getMetrics();
|
||||
|
||||
void setMetrics(Metrics metrics);
|
||||
|
||||
EssentialsTimer getTimer();
|
||||
|
||||
List<String> getVanishedPlayers();
|
||||
}
|
||||
|
@@ -2,11 +2,13 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.event.EventPriority;
|
||||
|
||||
|
||||
@@ -14,12 +16,12 @@ public interface ISettings extends IConf
|
||||
{
|
||||
boolean areSignsDisabled();
|
||||
|
||||
String format(String format, IUser user);
|
||||
|
||||
String getAnnounceNewPlayerFormat(IUser user);
|
||||
IText getAnnounceNewPlayerFormat();
|
||||
|
||||
boolean getAnnounceNewPlayers();
|
||||
|
||||
String getNewPlayerKit();
|
||||
|
||||
String getBackupCommand();
|
||||
|
||||
long getBackupInterval();
|
||||
@@ -35,14 +37,14 @@ public interface ISettings extends IConf
|
||||
String getCurrencySymbol();
|
||||
|
||||
int getOversizedStackSize();
|
||||
|
||||
|
||||
int getDefaultStackSize();
|
||||
|
||||
double getHealCooldown();
|
||||
|
||||
Object getKit(String name);
|
||||
Map<String, Object> getKit(String name);
|
||||
|
||||
Map<String, Object> getKits();
|
||||
ConfigurationSection getKits();
|
||||
|
||||
String getLocale();
|
||||
|
||||
@@ -66,7 +68,7 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getRespawnAtHome();
|
||||
|
||||
List getMultipleHomes();
|
||||
Set getMultipleHomes();
|
||||
|
||||
int getHomeLimit(String set);
|
||||
|
||||
@@ -101,7 +103,7 @@ public interface ISettings extends IConf
|
||||
boolean isTradeInStacks(int id);
|
||||
|
||||
List<Integer> itemSpawnBlacklist();
|
||||
|
||||
|
||||
List<EssentialsSign> enabledSigns();
|
||||
|
||||
boolean permissionBasedItemSpawn();
|
||||
@@ -116,12 +118,18 @@ public interface ISettings extends IConf
|
||||
|
||||
double getMaxMoney();
|
||||
|
||||
double getMinMoney();
|
||||
|
||||
boolean isEcoLogEnabled();
|
||||
|
||||
boolean isEcoLogUpdateEnabled();
|
||||
|
||||
boolean removeGodOnDisconnect();
|
||||
|
||||
boolean changeDisplayName();
|
||||
|
||||
boolean changePlayerListName();
|
||||
|
||||
boolean isPlayerCommand(String string);
|
||||
|
||||
boolean useBukkitPermissions();
|
||||
@@ -138,23 +146,39 @@ public interface ISettings extends IConf
|
||||
|
||||
boolean getFreezeAfkPlayers();
|
||||
|
||||
boolean cancelAfkOnMove();
|
||||
|
||||
boolean areDeathMessagesEnabled();
|
||||
|
||||
public void setDebug(boolean debug);
|
||||
|
||||
Set<String> getNoGodWorlds();
|
||||
|
||||
|
||||
boolean getUpdateBedAtDaytime();
|
||||
|
||||
|
||||
boolean getRepairEnchanted();
|
||||
|
||||
boolean isWorldTeleportPermissions();
|
||||
|
||||
boolean getIsWorldTeleportPermissions();
|
||||
|
||||
boolean isWorldHomePermissions();
|
||||
|
||||
boolean registerBackInListener();
|
||||
|
||||
boolean getDisableItemPickupWhileAfk();
|
||||
|
||||
EventPriority getRespawnPriority();
|
||||
|
||||
|
||||
long getTpaAcceptCancellation();
|
||||
|
||||
boolean isMetricsEnabled();
|
||||
|
||||
void setMetricsEnabled(boolean metricsEnabled);
|
||||
|
||||
long getTeleportInvulnerability();
|
||||
|
||||
boolean isTeleportInvulnerability();
|
||||
|
||||
long getLoginAttackDelay();
|
||||
|
||||
int getSignUsePerSecond();
|
||||
}
|
||||
|
@@ -1,10 +1,8 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import java.net.InetSocketAddress;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
/**
|
||||
@@ -32,6 +30,8 @@ public interface IUser extends Player
|
||||
void takeMoney(double value);
|
||||
|
||||
void giveMoney(double value);
|
||||
|
||||
boolean canAfford(double value);
|
||||
|
||||
String getGroup();
|
||||
|
||||
|
@@ -1,18 +1,28 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.api.IJails;
|
||||
import com.earth2me.essentials.storage.AsyncStorageObjectHolder;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.event.Event.Priority;
|
||||
import org.bukkit.event.Event.Type;
|
||||
import org.bukkit.event.block.*;
|
||||
import org.bukkit.event.player.*;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.event.block.BlockDamageEvent;
|
||||
import org.bukkit.event.block.BlockPlaceEvent;
|
||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||
import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
|
||||
@@ -20,26 +30,20 @@ import org.bukkit.plugin.PluginManager;
|
||||
public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.settings.Jails> implements IJails
|
||||
{
|
||||
private static final transient Logger LOGGER = Bukkit.getLogger();
|
||||
private static transient boolean enabled = false;
|
||||
|
||||
public Jails(final IEssentials ess)
|
||||
{
|
||||
super(ess, com.earth2me.essentials.settings.Jails.class);
|
||||
reloadConfig();
|
||||
registerListeners();
|
||||
}
|
||||
|
||||
private void registerListeners()
|
||||
{
|
||||
enabled = true;
|
||||
final PluginManager pluginManager = ess.getServer().getPluginManager();
|
||||
final JailBlockListener blockListener = new JailBlockListener();
|
||||
final JailPlayerListener playerListener = new JailPlayerListener();
|
||||
pluginManager.registerEvent(Type.BLOCK_BREAK, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.BLOCK_DAMAGE, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.BLOCK_PLACE, blockListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_INTERACT, playerListener, Priority.Low, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_RESPAWN, playerListener, Priority.High, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_TELEPORT, playerListener, Priority.High, ess);
|
||||
pluginManager.registerEvent(Type.PLAYER_JOIN, playerListener, Priority.High, ess);
|
||||
final JailListener blockListener = new JailListener();
|
||||
pluginManager.registerEvents(blockListener, ess);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -48,6 +52,24 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
return new File(ess.getDataFolder(), "jail.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishRead()
|
||||
{
|
||||
if (enabled == false && getCount() > 0)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void finishWrite()
|
||||
{
|
||||
if (enabled == false)
|
||||
{
|
||||
registerListeners();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Location getJail(final String jailName) throws Exception
|
||||
{
|
||||
@@ -114,7 +136,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
acquireReadLock();
|
||||
try
|
||||
{
|
||||
if (!(user.getBase() instanceof OfflinePlayer))
|
||||
if (user.isOnline())
|
||||
{
|
||||
Location loc = getJail(jail);
|
||||
user.getTeleport().now(loc, false, TeleportCause.COMMAND);
|
||||
@@ -145,10 +167,23 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailBlockListener extends BlockListener
|
||||
@Override
|
||||
public int getCount()
|
||||
{
|
||||
@Override
|
||||
try
|
||||
{
|
||||
return getList().size();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private class JailListener implements Listener
|
||||
{
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockBreak(final BlockBreakEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -158,7 +193,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockPlace(final BlockPlaceEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -168,7 +203,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onBlockDamage(final BlockDamageEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -177,12 +212,26 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onEntityDamageByEntity(final EntityDamageByEntityEvent event)
|
||||
{
|
||||
if (event.getCause() != DamageCause.ENTITY_ATTACK || event.getEntity().getType() != EntityType.PLAYER)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final Entity damager = event.getDamager();
|
||||
if (damager.getType() == EntityType.PLAYER)
|
||||
{
|
||||
final User user = ess.getUser(damager);
|
||||
if (user != null && user.isJailed())
|
||||
{
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private class JailPlayerListener extends PlayerListener
|
||||
{
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||
public void onPlayerInteract(final PlayerInteractEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -192,7 +241,7 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerRespawn(final PlayerRespawnEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -207,11 +256,18 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGH)
|
||||
public void onPlayerTeleport(final PlayerTeleportEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -226,12 +282,19 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onPlayerJoin(final PlayerJoinEvent event)
|
||||
{
|
||||
final User user = ess.getUser(event.getPlayer());
|
||||
@@ -246,7 +309,14 @@ public class Jails extends AsyncStorageObjectHolder<com.earth2me.essentials.sett
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOGGER.log(Level.WARNING, _("returnPlayerToJailError"), ex);
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()), ex);
|
||||
}
|
||||
else
|
||||
{
|
||||
LOGGER.log(Level.INFO, _("returnPlayerToJailError", user.getName(), ex.getLocalizedMessage()));
|
||||
}
|
||||
}
|
||||
user.sendMessage(_("jailMessage"));
|
||||
}
|
||||
|
@@ -1,10 +1,14 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import static com.earth2me.essentials.I18n.capitalCase;
|
||||
import com.earth2me.essentials.commands.NoChargeException;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -15,60 +19,74 @@ public class Kit
|
||||
{
|
||||
try
|
||||
{
|
||||
final Map<String, Object> kits = ess.getSettings().getKits();
|
||||
final ConfigurationSection kits = ess.getSettings().getKits();
|
||||
final StringBuilder list = new StringBuilder();
|
||||
for (String kiteItem : kits.keySet())
|
||||
for (String kiteItem : kits.getKeys(false))
|
||||
{
|
||||
if (user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
if (user == null || user.isAuthorized("essentials.kit." + kiteItem.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
list.append(" ").append(kiteItem);
|
||||
list.append(" ").append(capitalCase(kiteItem));
|
||||
}
|
||||
}
|
||||
return list.toString();
|
||||
return list.toString().trim();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception(_("kitError"));
|
||||
throw new Exception(_("kitError"), ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public static void checkTime(final User user, final String kitName, final Map<String, Object> els) throws NoChargeException
|
||||
{
|
||||
final Calendar time = new GregorianCalendar();
|
||||
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double delay = els.containsKey("delay") ? ((Number)els.get("delay")).doubleValue() : 0L;
|
||||
final Calendar c = new GregorianCalendar();
|
||||
c.add(Calendar.SECOND, -(int)delay);
|
||||
c.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
|
||||
final long mintime = c.getTimeInMillis();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int)delay);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int)((delay * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a kit could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last kit used?
|
||||
final Long lastTime = user.getKitTimestamp(kitName);
|
||||
if (lastTime == null || lastTime < mintime)
|
||||
|
||||
if (lastTime == null || lastTime < earliestLong)
|
||||
{
|
||||
final Calendar now = new GregorianCalendar();
|
||||
user.setKitTimestamp(kitName, now.getTimeInMillis());
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
// This is to make sure time didn't get messed up on last kit use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
user.setKitTimestamp(kitName, time.getTimeInMillis());
|
||||
}
|
||||
else
|
||||
{
|
||||
final Calendar future = new GregorianCalendar();
|
||||
future.setTimeInMillis(lastTime);
|
||||
future.add(Calendar.SECOND, (int)delay);
|
||||
future.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(future.getTimeInMillis())));
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int)delay);
|
||||
time.add(Calendar.MILLISECOND, (int)((delay * 1000.0) % 1000.0));
|
||||
user.sendMessage(_("kitTimed", Util.formatDateDiff(time.getTimeInMillis())));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
||||
public static List<String> getItems(final User user, final Map<String, Object> els) throws Exception
|
||||
public static List<String> getItems(final User user, final Map<String, Object> kit) throws Exception
|
||||
{
|
||||
if (kit == null)
|
||||
{
|
||||
throw new Exception(_("kitError2"));
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
return (List<String>)els.get("items");
|
||||
return (List<String>)kit.get("items");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(_("kitError2"));
|
||||
throw new Exception(_("kitErrorHelp"));
|
||||
throw new Exception(_("kitErrorHelp"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,18 +97,55 @@ public class Kit
|
||||
boolean spew = false;
|
||||
for (String d : items)
|
||||
{
|
||||
final String[] parts = d.split("[^0-9]+", 3);
|
||||
final int id = Material.getMaterial(Integer.parseInt(parts[0])).getId();
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[parts.length > 2 ? 2 : 1]) : 1;
|
||||
final short data = parts.length > 2 ? Short.parseShort(parts[1]) : 0;
|
||||
final String[] parts = d.split(" ");
|
||||
final String[] item = parts[0].split("[:+',;.]", 2);
|
||||
final int id = Material.getMaterial(Integer.parseInt(item[0])).getId();
|
||||
final short data = item.length > 1 ? Short.parseShort(item[1]) : 0;
|
||||
final int amount = parts.length > 1 ? Integer.parseInt(parts[1]) : 1;
|
||||
|
||||
final ItemStack stack = new ItemStack(id, amount, data);
|
||||
if (parts.length > 2)
|
||||
{
|
||||
for (int i = 2; i < parts.length; i++)
|
||||
{
|
||||
final String[] split = parts[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Enchantments.getByName(split[0]);
|
||||
if (enchantment == null)
|
||||
{
|
||||
throw new Exception("Enchantment not found: " + split[0]);
|
||||
}
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
try
|
||||
{
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
throw new Exception("Enchantment " + enchantment.getName() + ": " + ex.getMessage(), ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final Map<Integer, ItemStack> overfilled;
|
||||
if (user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), new ItemStack(id, amount, data));
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, ess.getSettings().getOversizedStackSize(), stack);
|
||||
}
|
||||
else
|
||||
{
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, new ItemStack(id, amount, data));
|
||||
overfilled = InventoryWorkaround.addItem(user.getInventory(), true, 0, stack);
|
||||
}
|
||||
for (ItemStack itemStack : overfilled.values())
|
||||
{
|
||||
@@ -107,7 +162,15 @@ public class Kit
|
||||
catch (Exception e)
|
||||
{
|
||||
user.updateInventory();
|
||||
throw new Exception(_("kitError2"));
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
else
|
||||
{
|
||||
ess.getLogger().log(Level.WARNING, e.getMessage());
|
||||
}
|
||||
throw new Exception(_("kitError2"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -9,40 +10,42 @@ import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.CreatureType;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public enum Mob
|
||||
{
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, CreatureType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, CreatureType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, CreatureType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, CreatureType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, CreatureType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, CreatureType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, CreatureType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", CreatureType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, CreatureType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, CreatureType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, CreatureType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, CreatureType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, CreatureType.ZOMBIE),
|
||||
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),
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, CreatureType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, CreatureType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, CreatureType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, CreatureType.MUSHROOM_COW),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, CreatureType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", CreatureType.SNOWMAN);
|
||||
CHICKEN("Chicken", Enemies.FRIENDLY, EntityType.CHICKEN),
|
||||
COW("Cow", Enemies.FRIENDLY, EntityType.COW),
|
||||
CREEPER("Creeper", Enemies.ENEMY, EntityType.CREEPER),
|
||||
GHAST("Ghast", Enemies.ENEMY, EntityType.GHAST),
|
||||
GIANT("Giant", Enemies.ENEMY, EntityType.GIANT),
|
||||
PIG("Pig", Enemies.FRIENDLY, EntityType.PIG),
|
||||
PIGZOMB("PigZombie", Enemies.NEUTRAL, EntityType.PIG_ZOMBIE),
|
||||
SHEEP("Sheep", Enemies.FRIENDLY, "", EntityType.SHEEP),
|
||||
SKELETON("Skeleton", Enemies.ENEMY, EntityType.SKELETON),
|
||||
SLIME("Slime", Enemies.ENEMY, EntityType.SLIME),
|
||||
SPIDER("Spider", Enemies.ENEMY, EntityType.SPIDER),
|
||||
SQUID("Squid", Enemies.FRIENDLY, EntityType.SQUID),
|
||||
ZOMBIE("Zombie", Enemies.ENEMY, EntityType.ZOMBIE),
|
||||
WOLF("Wolf", Enemies.NEUTRAL, EntityType.WOLF),
|
||||
CAVESPIDER("CaveSpider", Enemies.ENEMY, EntityType.CAVE_SPIDER),
|
||||
ENDERMAN("Enderman", Enemies.ENEMY, "", EntityType.ENDERMAN),
|
||||
SILVERFISH("Silverfish", Enemies.ENEMY, "", EntityType.SILVERFISH),
|
||||
ENDERDRAGON("EnderDragon", Enemies.ENEMY, EntityType.ENDER_DRAGON),
|
||||
VILLAGER("Villager", Enemies.FRIENDLY, EntityType.VILLAGER),
|
||||
BLAZE("Blaze", Enemies.ENEMY, EntityType.BLAZE),
|
||||
MUSHROOMCOW("MushroomCow", Enemies.FRIENDLY, EntityType.MUSHROOM_COW),
|
||||
MAGMACUBE("MagmaCube", Enemies.ENEMY, EntityType.MAGMA_CUBE),
|
||||
SNOWMAN("Snowman", Enemies.FRIENDLY, "", EntityType.SNOWMAN),
|
||||
OCELOT("Ocelot", Enemies.NEUTRAL, EntityType.OCELOT),
|
||||
IRONGOLEM("IronGolem", Enemies.NEUTRAL, EntityType.IRON_GOLEM);
|
||||
|
||||
public static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
private Mob(String n, Enemies en, String s, CreatureType type)
|
||||
private Mob(String n, Enemies en, String s, EntityType type)
|
||||
{
|
||||
this.suffix = s;
|
||||
this.name = n;
|
||||
@@ -50,7 +53,7 @@ public enum Mob
|
||||
this.bukkitType = type;
|
||||
}
|
||||
|
||||
private Mob(String n, Enemies en, CreatureType type)
|
||||
private Mob(String n, Enemies en, EntityType type)
|
||||
{
|
||||
this.name = n;
|
||||
this.type = en;
|
||||
@@ -59,7 +62,7 @@ public enum Mob
|
||||
public String suffix = "s";
|
||||
final public String name;
|
||||
final public Enemies type;
|
||||
final private CreatureType bukkitType;
|
||||
final private EntityType bukkitType;
|
||||
private static final Map<String, Mob> hashMap = new HashMap<String, Mob>();
|
||||
|
||||
static
|
||||
@@ -71,7 +74,7 @@ public enum Mob
|
||||
}
|
||||
|
||||
public static Set<String> getMobList() {
|
||||
return hashMap.keySet();
|
||||
return Collections.unmodifiableSet(hashMap.keySet());
|
||||
}
|
||||
|
||||
public LivingEntity spawn(final Player player, final Server server, final Location loc) throws MobException
|
||||
@@ -99,7 +102,7 @@ public enum Mob
|
||||
final protected String type;
|
||||
}
|
||||
|
||||
public CreatureType getType()
|
||||
public EntityType getType()
|
||||
{
|
||||
return bukkitType;
|
||||
}
|
||||
|
@@ -1,25 +1,31 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.OfflineBedLocation;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.*;
|
||||
import lombok.Delegate;
|
||||
import org.bukkit.*;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.conversations.Conversation;
|
||||
import org.bukkit.conversations.ConversationAbandonedEvent;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.player.PlayerTeleportEvent.TeleportCause;
|
||||
import org.bukkit.inventory.Inventory;
|
||||
import org.bukkit.inventory.InventoryView;
|
||||
import org.bukkit.inventory.InventoryView.Property;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.map.MapView;
|
||||
import org.bukkit.metadata.MetadataValue;
|
||||
import org.bukkit.permissions.Permission;
|
||||
import org.bukkit.permissions.PermissionAttachment;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
|
||||
public class OfflinePlayer implements Player
|
||||
{
|
||||
private final transient IEssentials ess;
|
||||
@@ -170,11 +176,6 @@ public class OfflinePlayer implements Player
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isPlayer()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getRemainingAir()
|
||||
{
|
||||
@@ -664,18 +665,6 @@ public class OfflinePlayer implements Player
|
||||
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()
|
||||
{
|
||||
@@ -857,4 +846,209 @@ public class OfflinePlayer implements Player
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void hidePlayer(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void showPlayer(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canSee(Player player)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect pe)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffect(PotionEffect pe, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPotionEffects(Collection<PotionEffect> clctn)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPotionEffect(PotionEffectType pet)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removePotionEffect(PotionEffectType pet)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<PotionEffect> getActivePotionEffects()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T extends Projectile> T launchProjectile(Class<? extends T> arg0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public EntityType getType()
|
||||
{
|
||||
return EntityType.PLAYER;
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void playEffect(Location lctn, Effect effect, T t)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setWindowProperty(Property prprt, int i)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView getOpenInventory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openInventory(Inventory invntr)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openWorkbench(Location lctn, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public InventoryView openEnchanting(Location lctn, boolean bln)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void openInventory(InventoryView iv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void closeInventory()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemOnCursor()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemOnCursor(ItemStack is)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetadata(String string, MetadataValue mv)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<MetadataValue> getMetadata(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasMetadata(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void removeMetadata(String string, Plugin plugin)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean isConversing()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void acceptConversationInput(String string)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean beginConversation(Conversation c)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation c)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(String[] strings)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isBlocking()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void abandonConversation(Conversation arg0, ConversationAbandonedEvent arg1)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isFlying()
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setFlying(boolean arg0)
|
||||
{
|
||||
throw new UnsupportedOperationException("Not supported yet.");
|
||||
}
|
||||
}
|
||||
|
@@ -4,12 +4,16 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.IEssentialsCommand;
|
||||
import com.earth2me.essentials.signs.EssentialsSign;
|
||||
import com.earth2me.essentials.signs.Signs;
|
||||
import com.earth2me.essentials.textreader.IText;
|
||||
import com.earth2me.essentials.textreader.SimpleTextInput;
|
||||
import java.io.File;
|
||||
import java.text.MessageFormat;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.configuration.ConfigurationSection;
|
||||
import org.bukkit.configuration.MemoryConfiguration;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -19,6 +23,7 @@ public class Settings implements ISettings
|
||||
private final transient EssentialsConf config;
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final transient IEssentials ess;
|
||||
private boolean metricsEnabled = true;
|
||||
|
||||
public Settings(IEssentials ess)
|
||||
{
|
||||
@@ -41,15 +46,15 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> getMultipleHomes()
|
||||
public Set<String> getMultipleHomes()
|
||||
{
|
||||
return config.getKeys("sethome-multiple");
|
||||
return config.getConfigurationSection("sethome-multiple").getKeys(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getHomeLimit(final User user)
|
||||
{
|
||||
final List<String> homeList = getMultipleHomes();
|
||||
final Set<String> homeList = getMultipleHomes();
|
||||
if (homeList == null)
|
||||
{
|
||||
//TODO: Replace this code to remove backwards compat, after settings are automatically updated
|
||||
@@ -112,7 +117,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isCommandDisabled(String label)
|
||||
{
|
||||
for (String c : config.getStringList("disabled-commands", new ArrayList<String>(0)))
|
||||
for (String c : config.getStringList("disabled-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
@@ -132,7 +137,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isCommandRestricted(String label)
|
||||
{
|
||||
for (String c : config.getStringList("restricted-commands", new ArrayList<String>(0)))
|
||||
for (String c : config.getStringList("restricted-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
@@ -146,7 +151,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isPlayerCommand(String label)
|
||||
{
|
||||
for (String c : config.getStringList("player-commands", new ArrayList<String>(0)))
|
||||
for (String c : config.getStringList("player-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(label))
|
||||
{
|
||||
@@ -160,9 +165,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean isCommandOverridden(String name)
|
||||
{
|
||||
List<String> defaultList = new ArrayList<String>(1);
|
||||
defaultList.add("god");
|
||||
for (String c : config.getStringList("overridden-commands", defaultList))
|
||||
for (String c : config.getStringList("overridden-commands"))
|
||||
{
|
||||
if (!c.equalsIgnoreCase(name))
|
||||
{
|
||||
@@ -207,25 +210,45 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getDouble("heal-cooldown", 0);
|
||||
}
|
||||
private ConfigurationSection kits;
|
||||
|
||||
@Override
|
||||
public Object getKit(String name)
|
||||
public ConfigurationSection _getKits()
|
||||
{
|
||||
Map<String, Object> kits = (Map<String, Object>)config.getProperty("kits");
|
||||
for (Map.Entry<String, Object> entry : kits.entrySet())
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
if (entry.getKey().equalsIgnoreCase(name.replace('.', '_').replace('/', '_')))
|
||||
final ConfigurationSection section = config.getConfigurationSection("kits");
|
||||
final ConfigurationSection newSection = new MemoryConfiguration();
|
||||
for (String kitItem : section.getKeys(false))
|
||||
{
|
||||
return entry.getValue();
|
||||
if (section.isConfigurationSection(kitItem))
|
||||
{
|
||||
newSection.set(kitItem.toLowerCase(Locale.ENGLISH), section.getConfigurationSection(kitItem));
|
||||
}
|
||||
}
|
||||
return newSection;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKits()
|
||||
public ConfigurationSection getKits()
|
||||
{
|
||||
return (Map<String, Object>)config.getProperty("kits");
|
||||
return kits;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getKit(String name)
|
||||
{
|
||||
name = name.replace('.', '_').replace('/', '_');
|
||||
if (config.isConfigurationSection("kits"))
|
||||
{
|
||||
final ConfigurationSection kits = getKits();
|
||||
if (kits.isConfigurationSection(name))
|
||||
{
|
||||
return kits.getConfigurationSection(name).getValues(true);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -250,7 +273,7 @@ public class Settings implements ISettings
|
||||
{
|
||||
}
|
||||
|
||||
return ChatColor.getByCode(Integer.parseInt(colorName, 16));
|
||||
return ChatColor.getByChar(colorName);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -280,7 +303,7 @@ public class Settings implements ISettings
|
||||
@Override
|
||||
public boolean areSignsDisabled()
|
||||
{
|
||||
return enabledSigns.isEmpty();
|
||||
return !signsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -304,13 +327,13 @@ public class Settings implements ISettings
|
||||
{
|
||||
String format = config.getString("chat.group-formats." + (group == null ? "Default" : group),
|
||||
config.getString("chat.format", "&7[{GROUP}]&f {DISPLAYNAME}&7:&f {MESSAGE}"));
|
||||
format = Util.replaceColor(format);
|
||||
format = Util.replaceFormat(format);
|
||||
format = format.replace("{DISPLAYNAME}", "%1$s");
|
||||
format = format.replace("{GROUP}", "{0}");
|
||||
format = format.replace("{MESSAGE}", "%2$s");
|
||||
format = format.replace("{WORLDNAME}", "{1}");
|
||||
format = format.replace("{SHORTWORLDNAME}", "{2}");
|
||||
format = format.replaceAll("\\{(\\D*)\\}", "\\[$1\\]");
|
||||
format = format.replaceAll("\\{(\\D*?)\\}", "\\[$1\\]");
|
||||
mFormat = new MessageFormat(format);
|
||||
chatFormats.put(group, mFormat);
|
||||
}
|
||||
@@ -324,15 +347,15 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getAnnounceNewPlayerFormat(IUser user)
|
||||
public IText getAnnounceNewPlayerFormat()
|
||||
{
|
||||
return format(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!"), user);
|
||||
return new SimpleTextInput(Util.replaceFormat(config.getString("newbies.announce-format", "&dWelcome {DISPLAYNAME} to the server!")));
|
||||
}
|
||||
|
||||
@Override
|
||||
public String format(String format, IUser user)
|
||||
public String getNewPlayerKit()
|
||||
{
|
||||
return format.replace('&', '§').replace("§§", "&").replace("{PLAYER}", user.getDisplayName()).replace("{DISPLAYNAME}", user.getDisplayName()).replace("{GROUP}", user.getGroup()).replace("{USERNAME}", user.getName()).replace("{ADDRESS}", user.getAddress().toString());
|
||||
return config.getString("newbies.kit", "");
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -357,30 +380,42 @@ public class Settings implements ISettings
|
||||
public void reloadConfig()
|
||||
{
|
||||
config.load();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds", Collections.<String>emptyList()));
|
||||
enabledSigns = getEnabledSigns();
|
||||
itemSpawnBl = getItemSpawnBlacklist();
|
||||
noGodWorlds = new HashSet<String>(config.getStringList("no-god-in-worlds"));
|
||||
enabledSigns = _getEnabledSigns();
|
||||
teleportInvulnerability = _isTeleportInvulnerability();
|
||||
disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk();
|
||||
registerBackInListener = _registerBackInListener();
|
||||
cancelAfkOnMove = _cancelAfkOnMove();
|
||||
getFreezeAfkPlayers = _getFreezeAfkPlayers();
|
||||
itemSpawnBl = _getItemSpawnBlacklist();
|
||||
loginAttackDelay = _getLoginAttackDelay();
|
||||
signUsePerSecond = _getSignUsePerSecond();
|
||||
kits = _getKits();
|
||||
chatFormats.clear();
|
||||
}
|
||||
|
||||
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
|
||||
|
||||
|
||||
@Override
|
||||
public List<Integer> itemSpawnBlacklist()
|
||||
{
|
||||
return itemSpawnBl;
|
||||
}
|
||||
|
||||
private List<Integer> getItemSpawnBlacklist()
|
||||
|
||||
private List<Integer> _getItemSpawnBlacklist()
|
||||
{
|
||||
final List<Integer> epItemSpwn = new ArrayList<Integer>();
|
||||
if (ess.getItemDb() == null)
|
||||
{
|
||||
logger.log(Level.FINE, "Aborting ItemSpawnBL read, itemDB not yet loaded.");
|
||||
return epItemSpwn;
|
||||
}
|
||||
for (String itemName : config.getString("item-spawn-blacklist", "").split(","))
|
||||
{
|
||||
itemName = itemName.trim();
|
||||
if (itemName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
try
|
||||
{
|
||||
final ItemStack iStack = ess.getItemDb().get(itemName);
|
||||
@@ -393,26 +428,31 @@ public class Settings implements ISettings
|
||||
}
|
||||
return epItemSpwn;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> enabledSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
private boolean signsEnabled = false;
|
||||
|
||||
@Override
|
||||
public List<EssentialsSign> enabledSigns()
|
||||
{
|
||||
return enabledSigns;
|
||||
}
|
||||
|
||||
private List<EssentialsSign> getEnabledSigns()
|
||||
|
||||
private List<EssentialsSign> _getEnabledSigns()
|
||||
{
|
||||
List<EssentialsSign> newSigns = new ArrayList<EssentialsSign>();
|
||||
|
||||
for (String signName : config.getStringList("enabledSigns", null))
|
||||
|
||||
for (String signName : config.getStringList("enabledSigns"))
|
||||
{
|
||||
signName = signName.trim().toUpperCase(Locale.ENGLISH);
|
||||
if (signName.isEmpty())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (signName.equals("COLOR") || signName.equals("COLOUR"))
|
||||
{
|
||||
signsEnabled = true;
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
newSigns.add(Signs.valueOf(signName).getSign());
|
||||
@@ -420,7 +460,9 @@ public class Settings implements ISettings
|
||||
catch (Exception ex)
|
||||
{
|
||||
logger.log(Level.SEVERE, _("unknownItemInList", signName, "enabledSigns"));
|
||||
continue;
|
||||
}
|
||||
signsEnabled = true;
|
||||
}
|
||||
return newSigns;
|
||||
}
|
||||
@@ -534,6 +576,22 @@ public class Settings implements ISettings
|
||||
}
|
||||
return max;
|
||||
}
|
||||
private final static double MINMONEY = -10000000000000.0;
|
||||
|
||||
@Override
|
||||
public double getMinMoney()
|
||||
{
|
||||
double min = config.getDouble("min-money", MINMONEY);
|
||||
if (min > 0)
|
||||
{
|
||||
min = -min;
|
||||
}
|
||||
if (min < MINMONEY)
|
||||
{
|
||||
min = MINMONEY;
|
||||
}
|
||||
return min;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogEnabled()
|
||||
@@ -541,6 +599,12 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("economy-log-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEcoLogUpdateEnabled()
|
||||
{
|
||||
return config.getBoolean("economy-log-update-enabled", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeGodOnDisconnect()
|
||||
{
|
||||
@@ -553,6 +617,12 @@ public class Settings implements ISettings
|
||||
return config.getBoolean("change-displayname", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean changePlayerListName()
|
||||
{
|
||||
return config.getBoolean("change-playerlist", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean useBukkitPermissions()
|
||||
{
|
||||
@@ -588,19 +658,36 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getLong("auto-afk-kick", -1);
|
||||
}
|
||||
private boolean getFreezeAfkPlayers;
|
||||
|
||||
@Override
|
||||
public boolean getFreezeAfkPlayers()
|
||||
{
|
||||
return getFreezeAfkPlayers;
|
||||
}
|
||||
|
||||
private boolean _getFreezeAfkPlayers()
|
||||
{
|
||||
return config.getBoolean("freeze-afk-players", false);
|
||||
}
|
||||
private boolean cancelAfkOnMove;
|
||||
|
||||
@Override
|
||||
public boolean cancelAfkOnMove()
|
||||
{
|
||||
return cancelAfkOnMove;
|
||||
}
|
||||
|
||||
private boolean _cancelAfkOnMove()
|
||||
{
|
||||
return config.getBoolean("cancel-afk-on-move", true);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean areDeathMessagesEnabled()
|
||||
{
|
||||
return config.getBoolean("death-messages", true);
|
||||
}
|
||||
|
||||
private Set<String> noGodWorlds = new HashSet<String>();
|
||||
|
||||
@Override
|
||||
@@ -622,21 +709,39 @@ public class Settings implements ISettings
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getIsWorldTeleportPermissions()
|
||||
public boolean isWorldTeleportPermissions()
|
||||
{
|
||||
return config.getBoolean("world-teleport-permissions", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isWorldHomePermissions()
|
||||
{
|
||||
return config.getBoolean("world-home-permissions", false);
|
||||
}
|
||||
private boolean registerBackInListener;
|
||||
|
||||
@Override
|
||||
public boolean registerBackInListener()
|
||||
{
|
||||
return registerBackInListener;
|
||||
}
|
||||
|
||||
private boolean _registerBackInListener()
|
||||
{
|
||||
return config.getBoolean("register-back-in-listener", false);
|
||||
}
|
||||
private boolean disableItemPickupWhileAfk;
|
||||
|
||||
@Override
|
||||
public boolean getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", true);
|
||||
return disableItemPickupWhileAfk;
|
||||
}
|
||||
|
||||
private boolean _getDisableItemPickupWhileAfk()
|
||||
{
|
||||
return config.getBoolean("disable-item-pickup-while-afk", false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -671,4 +776,62 @@ public class Settings implements ISettings
|
||||
{
|
||||
return config.getLong("tpa-accept-cancellation", 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isMetricsEnabled()
|
||||
{
|
||||
return metricsEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setMetricsEnabled(boolean metricsEnabled)
|
||||
{
|
||||
this.metricsEnabled = metricsEnabled;
|
||||
}
|
||||
private boolean teleportInvulnerability;
|
||||
|
||||
@Override
|
||||
public long getTeleportInvulnerability()
|
||||
{
|
||||
return config.getLong("teleport-invulnerability", 0) * 1000;
|
||||
}
|
||||
|
||||
private boolean _isTeleportInvulnerability()
|
||||
{
|
||||
return (config.getLong("teleport-invulnerability", 0) > 0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isTeleportInvulnerability()
|
||||
{
|
||||
return teleportInvulnerability;
|
||||
}
|
||||
|
||||
private long loginAttackDelay;
|
||||
|
||||
private long _getLoginAttackDelay()
|
||||
{
|
||||
return config.getLong("login-attack-delay", 0) * 1000;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getLoginAttackDelay()
|
||||
{
|
||||
return loginAttackDelay;
|
||||
}
|
||||
|
||||
private int signUsePerSecond;
|
||||
|
||||
private int _getSignUsePerSecond()
|
||||
{
|
||||
final int perSec = config.getInt("sign-use-per-second", 4);
|
||||
return perSec > 0 ? perSec : 1;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getSignUsePerSecond()
|
||||
{
|
||||
return signUsePerSecond;
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -1,6 +1,5 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.craftbukkit.FakeExplosion;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
@@ -46,8 +45,12 @@ public class TNTExplodeListener implements Listener, Runnable
|
||||
{
|
||||
return;
|
||||
}
|
||||
FakeExplosion.createExplosion(event, ess.getServer(), ess.getServer().getOnlinePlayers());
|
||||
if (event.blockList().size() < 1)
|
||||
{
|
||||
return;
|
||||
}
|
||||
event.setCancelled(true);
|
||||
event.getLocation().getWorld().createExplosion(event.getLocation(), 0F);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials;
|
||||
|
||||
import com.earth2me.essentials.api.ITeleport;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.NotEnoughArgumentsException;
|
||||
import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Logger;
|
||||
@@ -146,23 +145,39 @@ public class Teleport implements Runnable, ITeleport
|
||||
|
||||
public void cooldown(boolean check) throws Exception
|
||||
{
|
||||
Calendar now = new GregorianCalendar();
|
||||
final Calendar time = new GregorianCalendar();
|
||||
if (user.getLastTeleportTimestamp() > 0)
|
||||
{
|
||||
double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
Calendar cooldownTime = new GregorianCalendar();
|
||||
cooldownTime.setTimeInMillis(user.getLastTeleportTimestamp());
|
||||
cooldownTime.add(Calendar.SECOND, (int)cooldown);
|
||||
cooldownTime.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
if (cooldownTime.after(now) && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
// Take the current time, and remove the delay from it.
|
||||
final double cooldown = ess.getSettings().getTeleportCooldown();
|
||||
final Calendar earliestTime = new GregorianCalendar();
|
||||
earliestTime.add(Calendar.SECOND, -(int)cooldown);
|
||||
earliestTime.add(Calendar.MILLISECOND, -(int)((cooldown * 1000.0) % 1000.0));
|
||||
// This value contains the most recent time a teleport could have been used that would allow another use.
|
||||
final long earliestLong = earliestTime.getTimeInMillis();
|
||||
|
||||
// When was the last teleport used?
|
||||
final Long lastTime = user.getLastTeleportTimestamp();
|
||||
|
||||
if (lastTime > time.getTimeInMillis())
|
||||
{
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(cooldownTime.getTimeInMillis())));
|
||||
// This is to make sure time didn't get messed up on last kit use.
|
||||
// If this happens, let's give the user the benifit of the doubt.
|
||||
user.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
return;
|
||||
}
|
||||
else if (lastTime > earliestLong && !user.isAuthorized("essentials.teleport.cooldown.bypass"))
|
||||
{
|
||||
time.setTimeInMillis(lastTime);
|
||||
time.add(Calendar.SECOND, (int)cooldown);
|
||||
time.add(Calendar.MILLISECOND, (int)((cooldown * 1000.0) % 1000.0));
|
||||
throw new Exception(_("timeBeforeTeleport", Util.formatDateDiff(time.getTimeInMillis())));
|
||||
}
|
||||
}
|
||||
// if justCheck is set, don't update lastTeleport; we're just checking
|
||||
if (!check)
|
||||
{
|
||||
user.setLastTeleportTimestamp(now.getTimeInMillis());
|
||||
user.setLastTeleportTimestamp(time.getTimeInMillis());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -190,7 +205,7 @@ public class Teleport implements Runnable, ITeleport
|
||||
{
|
||||
cancel(false);
|
||||
}
|
||||
|
||||
|
||||
public void teleport(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.PLUGIN);
|
||||
@@ -278,13 +293,8 @@ public class Teleport implements Runnable, ITeleport
|
||||
now(new Target(user.getLastLocation()), TeleportCause.COMMAND);
|
||||
}
|
||||
|
||||
public void home(IUser user, String home, Trade chargeFor) throws Exception
|
||||
public void home(Location loc, Trade chargeFor) throws Exception
|
||||
{
|
||||
final Location loc = user.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
teleport(new Target(loc), chargeFor, TeleportCause.COMMAND);
|
||||
}
|
||||
}
|
||||
|
@@ -13,12 +13,14 @@ import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Trade
|
||||
{
|
||||
private final transient String command;
|
||||
private final transient String fallbackCommand;
|
||||
private final transient Double money;
|
||||
private final transient ItemStack itemStack;
|
||||
private final transient Integer exp;
|
||||
@@ -26,27 +28,33 @@ public class Trade
|
||||
|
||||
public Trade(final String command, final IEssentials ess)
|
||||
{
|
||||
this(command, null, null, null, ess);
|
||||
this(command, null, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final String command, final String fallback, final IEssentials ess)
|
||||
{
|
||||
this(command, fallback, null, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final double money, final IEssentials ess)
|
||||
{
|
||||
this(null, money, null, null, ess);
|
||||
this(null, null, money, null, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final ItemStack items, final IEssentials ess)
|
||||
{
|
||||
this(null, null, items, null, ess);
|
||||
}
|
||||
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, exp, ess);
|
||||
this(null, null, null, items, null, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
public Trade(final int exp, final IEssentials ess)
|
||||
{
|
||||
this(null, null, null, null, exp, ess);
|
||||
}
|
||||
|
||||
private Trade(final String command, final String fallback, final Double money, final ItemStack item, final Integer exp, final IEssentials ess)
|
||||
{
|
||||
this.command = command;
|
||||
this.fallbackCommand = fallback;
|
||||
this.money = money;
|
||||
this.itemStack = item;
|
||||
this.exp = exp;
|
||||
@@ -55,11 +63,9 @@ public class Trade
|
||||
|
||||
public void isAffordableFor(final IUser user) throws ChargeException
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (getMoney() != null
|
||||
&& mon < getMoney()
|
||||
&& getMoney() > 0
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& !user.canAfford(getMoney()))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -70,18 +76,17 @@ public class Trade
|
||||
throw new ChargeException(_("missingItems", getItemStack().getAmount(), getItemStack().getType().toString().toLowerCase(Locale.ENGLISH).replace("_", " ")));
|
||||
}
|
||||
|
||||
double money;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command)
|
||||
&& mon < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& 0 < ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command)
|
||||
&& !user.isAuthorized("essentials.eco.loan"))
|
||||
&& 0 < (money = getCommandCost(user))
|
||||
&& !user.canAfford(money))
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp) {
|
||||
|
||||
if (exp != null && exp > 0
|
||||
&& SetExpFix.getTotalExperience(user) < exp)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughExperience"));
|
||||
}
|
||||
}
|
||||
@@ -103,9 +108,25 @@ public class Trade
|
||||
if (dropItems)
|
||||
{
|
||||
final Map<Integer, ItemStack> leftOver = InventoryWorkaround.addItem(user.getInventory(), true, getItemStack());
|
||||
final Location loc = user.getLocation();
|
||||
for (ItemStack itemStack : leftOver.values())
|
||||
{
|
||||
InventoryWorkaround.dropItem(user.getLocation(), itemStack);
|
||||
final int maxStackSize = itemStack.getType().getMaxStackSize();
|
||||
final int stacks = itemStack.getAmount() / maxStackSize;
|
||||
final int leftover = itemStack.getAmount() % maxStackSize;
|
||||
final Item[] itemStacks = new Item[stacks + (leftover > 0 ? 1 : 0)];
|
||||
for (int i = 0; i < stacks; i++)
|
||||
{
|
||||
final ItemStack stack = itemStack.clone();
|
||||
stack.setAmount(maxStackSize);
|
||||
itemStacks[i] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
if (leftover > 0)
|
||||
{
|
||||
final ItemStack stack = itemStack.clone();
|
||||
stack.setAmount(leftover);
|
||||
itemStacks[stacks] = loc.getWorld().dropItem(loc, stack);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -125,8 +146,7 @@ public class Trade
|
||||
{
|
||||
if (getMoney() != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
if (mon < getMoney() && getMoney() > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
if (!user.canAfford(getMoney()) && getMoney() > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -141,13 +161,10 @@ public class Trade
|
||||
InventoryWorkaround.removeItem(user.getInventory(), true, true, getItemStack());
|
||||
user.updateInventory();
|
||||
}
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
if (command != null)
|
||||
{
|
||||
final double mon = user.getMoney();
|
||||
final double cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (mon < cost && cost > 0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
final double cost = getCommandCost(user);
|
||||
if (!user.canAfford(cost) && cost > 0)
|
||||
{
|
||||
throw new ChargeException(_("notEnoughMoney"));
|
||||
}
|
||||
@@ -173,16 +190,33 @@ public class Trade
|
||||
{
|
||||
return itemStack;
|
||||
}
|
||||
|
||||
|
||||
public Integer getExperience()
|
||||
{
|
||||
return exp;
|
||||
}
|
||||
|
||||
public Double getCommandCost(final IUser user)
|
||||
{
|
||||
double cost = 0d;
|
||||
if (command != null && !command.isEmpty()
|
||||
&& !user.isAuthorized("essentials.nocommandcost.all")
|
||||
&& !user.isAuthorized("essentials.nocommandcost." + command))
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(command.charAt(0) == '/' ? command.substring(1) : command);
|
||||
if (cost == 0.0 && fallbackCommand != null && !fallbackCommand.isEmpty())
|
||||
{
|
||||
cost = ess.getSettings().getCommandCost(fallbackCommand.charAt(0) == '/' ? fallbackCommand.substring(1) : fallbackCommand);
|
||||
}
|
||||
}
|
||||
return cost;
|
||||
}
|
||||
private static FileWriter fw = null;
|
||||
|
||||
public static void log(String type, String subtype, String event, String sender, Trade charge, String receiver, Trade pay, Location loc, IEssentials ess)
|
||||
{
|
||||
if (!ess.getSettings().isEcoLogEnabled())
|
||||
if ((loc == null && !ess.getSettings().isEcoLogUpdateEnabled())
|
||||
|| (loc != null && !ess.getSettings().isEcoLogEnabled()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -7,7 +7,6 @@ import java.util.Calendar;
|
||||
import java.util.GregorianCalendar;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -18,12 +17,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
private CommandSender replyTo = null;
|
||||
private transient User teleportRequester;
|
||||
private transient boolean teleportRequestHere;
|
||||
private transient boolean vanished;
|
||||
private transient final Teleport teleport;
|
||||
private transient long teleportRequestTime;
|
||||
private transient long lastOnlineActivity;
|
||||
private transient long lastThrottledAction;
|
||||
private transient long lastActivity = System.currentTimeMillis();
|
||||
private boolean hidden = false;
|
||||
private transient Location afkPosition = null;
|
||||
private boolean invSee = false;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
User(final Player base, final IEssentials ess)
|
||||
@@ -57,6 +59,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public boolean isAuthorized(final String node)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
ess.getLogger().log(Level.INFO, "checking if " + base.getName() + " has " + node);
|
||||
}
|
||||
if (base instanceof OfflinePlayer)
|
||||
{
|
||||
return false;
|
||||
@@ -72,7 +78,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return false;
|
||||
}
|
||||
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
try
|
||||
{
|
||||
return ess.getPermissionsHandler().hasPermission(base, node);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ess.getLogger().log(Level.SEVERE, "Permission System Error: " + ess.getPermissionsHandler().getName() + " returned: " + ex.getMessage());
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void healCooldown() throws Exception
|
||||
@@ -106,10 +120,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() + value);
|
||||
sendMessage(_("addedToAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("addedToAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
initiator.sendMessage(_("addedToOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -123,8 +137,8 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
setMoney(getMoney() - value);
|
||||
reciever.setMoney(reciever.getMoney() + value);
|
||||
sendMessage(_("moneySentTo", Util.formatCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.formatCurrency(value, ess), getDisplayName()));
|
||||
sendMessage(_("moneySentTo", Util.displayCurrency(value, ess), reciever.getDisplayName()));
|
||||
reciever.sendMessage(_("moneyRecievedFrom", Util.displayCurrency(value, ess), getDisplayName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -145,17 +159,27 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return;
|
||||
}
|
||||
setMoney(getMoney() - value);
|
||||
sendMessage(_("takenFromAccount", Util.formatCurrency(value, ess)));
|
||||
sendMessage(_("takenFromAccount", Util.displayCurrency(value, ess)));
|
||||
if (initiator != null)
|
||||
{
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.formatCurrency(value, ess), this.getDisplayName()));
|
||||
initiator.sendMessage(_("takenFromOthersAccount", Util.displayCurrency(value, ess), this.getDisplayName(), Util.displayCurrency(getMoney(), ess)));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canAfford(final double cost)
|
||||
{
|
||||
return canAfford(cost, true);
|
||||
}
|
||||
|
||||
public boolean canAfford(final double cost, final boolean permcheck)
|
||||
{
|
||||
final double mon = getMoney();
|
||||
return mon >= cost || isAuthorized("essentials.eco.loan");
|
||||
if (!permcheck || isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
return (mon - cost) >= ess.getSettings().getMinMoney();
|
||||
}
|
||||
return cost <= mon;
|
||||
}
|
||||
|
||||
public void dispose()
|
||||
@@ -178,7 +202,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
@Override
|
||||
public int compareTo(final User other)
|
||||
{
|
||||
return Util.stripColor(this.getDisplayName()).compareToIgnoreCase(Util.stripColor(other.getDisplayName()));
|
||||
return Util.stripFormat(this.getDisplayName()).compareToIgnoreCase(Util.stripFormat(other.getDisplayName()));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -236,92 +260,107 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return teleportRequester;
|
||||
}
|
||||
|
||||
public boolean isTeleportRequestHere()
|
||||
public boolean isTpRequestHere()
|
||||
{
|
||||
return teleportRequestHere;
|
||||
}
|
||||
|
||||
public String getNick(boolean addprefixsuffix)
|
||||
public String getNick(final boolean longnick)
|
||||
{
|
||||
final StringBuilder nickname = new StringBuilder();
|
||||
final StringBuilder prefix = new StringBuilder();
|
||||
String nickname;
|
||||
String suffix = "";
|
||||
final String nick = getNickname();
|
||||
if (ess.getSettings().isCommandDisabled("nick") || nick == null || nick.isEmpty() || nick.equals(getName()))
|
||||
{
|
||||
nickname.append(getName());
|
||||
nickname = getName();
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append(ess.getSettings().getNicknamePrefix()).append(nick);
|
||||
nickname = ess.getSettings().getNicknamePrefix() + nick;
|
||||
}
|
||||
|
||||
if (isOp())
|
||||
{
|
||||
try
|
||||
{
|
||||
nickname.insert(0, ess.getSettings().getOperatorColor().toString());
|
||||
nickname.append("§f");
|
||||
final String opPrefix = ess.getSettings().getOperatorColor().toString();
|
||||
if (opPrefix.length() > 0)
|
||||
{
|
||||
prefix.insert(0, opPrefix);
|
||||
suffix = "§f";
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
}
|
||||
}
|
||||
|
||||
if (addprefixsuffix && ess.getSettings().addPrefixSuffix())
|
||||
if (ess.getSettings().addPrefixSuffix())
|
||||
{
|
||||
if (!ess.getSettings().disablePrefix())
|
||||
{
|
||||
final String prefix = ess.getPermissionsHandler().getPrefix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.insert(0, prefix);
|
||||
final String ptext = ess.getPermissionsHandler().getPrefix(base).replace('&', '§');
|
||||
prefix.insert(0, ptext);
|
||||
suffix = "§f";
|
||||
}
|
||||
if (!ess.getSettings().disableSuffix())
|
||||
{
|
||||
final String suffix = ess.getPermissionsHandler().getSuffix(base).replace('&', '§').replace("{WORLDNAME}", this.getWorld().getName());
|
||||
nickname.append(suffix);
|
||||
if (suffix.length() < 2 || !suffix.substring(suffix.length() - 2, suffix.length() - 1).equals("§"))
|
||||
{
|
||||
nickname.append("§f");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
nickname.append("§f");
|
||||
final String stext = ess.getPermissionsHandler().getSuffix(base).replace('&', '§');
|
||||
suffix = stext + "§f";
|
||||
suffix = suffix.replace("§f§f", "§f");
|
||||
}
|
||||
}
|
||||
|
||||
return nickname.toString();
|
||||
final String strPrefix = prefix.toString();
|
||||
String output = strPrefix + nickname + suffix;
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = strPrefix + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname;
|
||||
}
|
||||
if (!longnick && output.length() > 16)
|
||||
{
|
||||
output = Util.lastCode(strPrefix) + nickname.substring(0, 14);
|
||||
}
|
||||
if (output.charAt(output.length() - 1) == '§') {
|
||||
output = output.substring(0, output.length() - 1);
|
||||
}
|
||||
return output;
|
||||
}
|
||||
|
||||
public void setDisplayNick()
|
||||
{
|
||||
String name = getNick(true);
|
||||
setDisplayName(name);
|
||||
if (name.length() > 16)
|
||||
if (base.isOnline() && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
name = getNick(false);
|
||||
}
|
||||
if (name.length() > 16)
|
||||
{
|
||||
name = name.substring(0, name.charAt(15) == '§' ? 15 : 16);
|
||||
}
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Use a shorter displayname prefix.");
|
||||
setDisplayName(getNick(true));
|
||||
if (ess.getSettings().changePlayerListName())
|
||||
{
|
||||
String name = getNick(false);
|
||||
try
|
||||
{
|
||||
setPlayerListName(name);
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
if (ess.getSettings().isDebug())
|
||||
{
|
||||
logger.log(Level.INFO, "Playerlist for " + name + " was not updated. Name clashed with another online player.");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDisplayName()
|
||||
{
|
||||
if (!(base instanceof OfflinePlayer) && ess.getSettings().changeDisplayName())
|
||||
{
|
||||
setDisplayNick();
|
||||
}
|
||||
return super.getDisplayName() == null ? super.getName() : super.getDisplayName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Teleport getTeleport()
|
||||
{
|
||||
return teleport;
|
||||
@@ -379,6 +418,15 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
}
|
||||
}
|
||||
super.setMoney(value);
|
||||
Trade.log("Update", "Set", "API", getName(), new Trade(value, ess), null, null, null, ess);
|
||||
}
|
||||
|
||||
public void updateMoneyCache(final double value)
|
||||
{
|
||||
if (ess.getPaymentMethod().hasMethod() && super.getMoney() != value)
|
||||
{
|
||||
super.setMoney(value);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -413,6 +461,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
public void setHidden(final boolean hidden)
|
||||
{
|
||||
this.hidden = hidden;
|
||||
if (hidden == true)
|
||||
{
|
||||
setLastLogout(getLastOnlineActivity());
|
||||
}
|
||||
}
|
||||
|
||||
//Returns true if status expired during this check
|
||||
@@ -468,6 +520,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setAfk(false);
|
||||
if (broadcast && !isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsNotAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -500,6 +553,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
setAfk(true);
|
||||
if (!isHidden())
|
||||
{
|
||||
setDisplayNick();
|
||||
ess.broadcastMessage(this, _("userIsAway", getDisplayName()));
|
||||
}
|
||||
}
|
||||
@@ -510,16 +564,6 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return afkPosition;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
if (!isGodModeEnabled())
|
||||
{
|
||||
setFoodLevel(20);
|
||||
}
|
||||
return super.toggleGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isGodModeEnabled()
|
||||
{
|
||||
@@ -532,6 +576,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
return super.isGodModeEnabled();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getGroup()
|
||||
{
|
||||
return ess.getPermissionsHandler().getGroup(base);
|
||||
@@ -544,6 +589,10 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
|
||||
public boolean canBuild()
|
||||
{
|
||||
if (isOp())
|
||||
{
|
||||
return true;
|
||||
}
|
||||
return ess.getPermissionsHandler().canBuild(base, getGroup());
|
||||
}
|
||||
|
||||
@@ -551,4 +600,94 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser
|
||||
{
|
||||
return teleportRequestTime;
|
||||
}
|
||||
|
||||
public boolean isInvSee()
|
||||
{
|
||||
return invSee;
|
||||
}
|
||||
|
||||
public void setInvSee(final boolean set)
|
||||
{
|
||||
invSee = set;
|
||||
}
|
||||
private transient long teleportInvulnerabilityTimestamp = 0;
|
||||
|
||||
public void enableInvulnerabilityAfterTeleport()
|
||||
{
|
||||
final long time = ess.getSettings().getTeleportInvulnerability();
|
||||
if (time > 0)
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = System.currentTimeMillis() + time;
|
||||
}
|
||||
}
|
||||
|
||||
public void resetInvulnerabilityAfterTeleport()
|
||||
{
|
||||
if (teleportInvulnerabilityTimestamp != 0
|
||||
&& teleportInvulnerabilityTimestamp < System.currentTimeMillis())
|
||||
{
|
||||
teleportInvulnerabilityTimestamp = 0;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean hasInvulnerabilityAfterTeleport()
|
||||
{
|
||||
return teleportInvulnerabilityTimestamp != 0 && teleportInvulnerabilityTimestamp >= System.currentTimeMillis();
|
||||
}
|
||||
|
||||
public boolean isVanished()
|
||||
{
|
||||
return vanished;
|
||||
}
|
||||
|
||||
public void setVanished(final boolean set)
|
||||
{
|
||||
vanished = set;
|
||||
if (set)
|
||||
{
|
||||
for (Player p : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (!ess.getUser(p).isAuthorized("essentials.vanish.see"))
|
||||
{
|
||||
p.hidePlayer(getBase());
|
||||
}
|
||||
}
|
||||
setHidden(true);
|
||||
ess.getVanishedPlayers().add(getName());
|
||||
}
|
||||
else
|
||||
{
|
||||
for (Player p : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
p.showPlayer(getBase());
|
||||
}
|
||||
setHidden(false);
|
||||
ess.getVanishedPlayers().remove(getName());
|
||||
}
|
||||
}
|
||||
|
||||
public void toggleVanished()
|
||||
{
|
||||
final boolean set = !vanished;
|
||||
this.setVanished(set);
|
||||
}
|
||||
|
||||
public boolean checkSignThrottle() {
|
||||
if (isSignThrottled()) {
|
||||
return true;
|
||||
}
|
||||
updateThrottle();
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isSignThrottled()
|
||||
{
|
||||
final long minTime = lastThrottledAction + (1000 / ess.getSettings().getSignUsePerSecond());
|
||||
return (System.currentTimeMillis() < minTime);
|
||||
}
|
||||
|
||||
public void updateThrottle()
|
||||
{
|
||||
lastThrottledAction = System.currentTimeMillis();;
|
||||
}
|
||||
}
|
||||
|
@@ -1,10 +1,9 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Logger;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
@@ -13,7 +12,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
{
|
||||
protected final transient IEssentials ess;
|
||||
private final EssentialsConf config;
|
||||
private static final Logger logger = Logger.getLogger("Minecraft");
|
||||
|
||||
protected UserData(Player base, IEssentials ess)
|
||||
{
|
||||
@@ -41,10 +39,9 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
lastHealTimestamp = _getLastHealTimestamp();
|
||||
jail = _getJail();
|
||||
mails = _getMails();
|
||||
savedInventory = _getSavedInventory();
|
||||
teleportEnabled = getTeleportEnabled();
|
||||
ignoredPlayers = getIgnoredPlayers();
|
||||
godmode = getGodModeEnabled();
|
||||
godmode = _getGodModeEnabled();
|
||||
muted = getMuted();
|
||||
muteTimeout = _getMuteTimeout();
|
||||
jailed = getJailed();
|
||||
@@ -58,6 +55,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
isNPC = _isNPC();
|
||||
arePowerToolsEnabled = _arePowerToolsEnabled();
|
||||
kitTimestamps = _getKitTimestamps();
|
||||
nickname = _getNickname();
|
||||
}
|
||||
private double money;
|
||||
|
||||
@@ -94,17 +92,11 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private Map<String, Object> _getHomes()
|
||||
{
|
||||
Object o = config.getProperty("homes");
|
||||
|
||||
if (o instanceof Map)
|
||||
if (config.isConfigurationSection("homes"))
|
||||
{
|
||||
return (Map<String, Object>)o;
|
||||
return config.getConfigurationSection("homes").getValues(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Location getHome(String name) throws Exception
|
||||
@@ -154,7 +146,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public List<String> getHomes()
|
||||
{
|
||||
return new ArrayList(homes.keySet());
|
||||
return new ArrayList<String>(homes.keySet());
|
||||
}
|
||||
|
||||
public void setHome(String name, Location loc)
|
||||
@@ -181,8 +173,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
else
|
||||
{
|
||||
//TODO: move this message to messages file
|
||||
throw new Exception("Home " + name + " doesn't exist");
|
||||
throw new Exception(_("invalidHome", name));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,14 +185,21 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
}
|
||||
return false;
|
||||
}
|
||||
private String nickname;
|
||||
|
||||
public String getNickname()
|
||||
public String _getNickname()
|
||||
{
|
||||
return config.getString("nickname");
|
||||
}
|
||||
|
||||
public String getNickname()
|
||||
{
|
||||
return nickname;
|
||||
}
|
||||
|
||||
public void setNickname(String nick)
|
||||
{
|
||||
nickname = nick;
|
||||
config.setProperty("nickname", nick);
|
||||
config.save();
|
||||
}
|
||||
@@ -209,7 +207,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private List<Integer> _getUnlimited()
|
||||
{
|
||||
return config.getIntList("unlimited", new ArrayList<Integer>());
|
||||
return config.getIntegerList("unlimited");
|
||||
}
|
||||
|
||||
public List<Integer> getUnlimited()
|
||||
@@ -235,22 +233,15 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("unlimited", unlimited);
|
||||
config.save();
|
||||
}
|
||||
private Map<Integer, Object> powertools;
|
||||
private Map<String, Object> powertools;
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
private Map<Integer, Object> _getPowertools()
|
||||
private Map<String, Object> _getPowertools()
|
||||
{
|
||||
Object o = config.getProperty("powertools");
|
||||
|
||||
if (o instanceof Map)
|
||||
if (config.isConfigurationSection("powertools"))
|
||||
{
|
||||
return (Map<Integer, Object>)o;
|
||||
return config.getConfigurationSection("powertools").getValues(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<Integer, Object>();
|
||||
}
|
||||
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public void clearAllPowertools()
|
||||
@@ -260,25 +251,27 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.save();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(ItemStack stack)
|
||||
{
|
||||
return (List<String>)powertools.get(stack.getTypeId());
|
||||
return (List<String>)powertools.get("" + stack.getTypeId());
|
||||
}
|
||||
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
public List<String> getPowertool(int id)
|
||||
{
|
||||
return (List<String>)powertools.get(id);
|
||||
return (List<String>)powertools.get("" + id);
|
||||
}
|
||||
|
||||
public void setPowertool(ItemStack stack, List<String> commandList)
|
||||
{
|
||||
if (commandList == null || commandList.isEmpty())
|
||||
{
|
||||
powertools.remove(stack.getTypeId());
|
||||
powertools.remove("" + stack.getTypeId());
|
||||
}
|
||||
else
|
||||
{
|
||||
powertools.put(stack.getTypeId(), commandList);
|
||||
powertools.put("" + stack.getTypeId(), commandList);
|
||||
}
|
||||
config.setProperty("powertools", powertools);
|
||||
config.save();
|
||||
@@ -383,7 +376,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private List<String> _getMails()
|
||||
{
|
||||
return config.getStringList("mail", new ArrayList<String>());
|
||||
return config.getStringList("mail");
|
||||
}
|
||||
|
||||
public List<String> getMails()
|
||||
@@ -411,50 +404,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
mails.add(mail);
|
||||
setMails(mails);
|
||||
}
|
||||
private ItemStack[] savedInventory;
|
||||
|
||||
public ItemStack[] getSavedInventory()
|
||||
{
|
||||
return savedInventory;
|
||||
}
|
||||
|
||||
private ItemStack[] _getSavedInventory()
|
||||
{
|
||||
int size = config.getInt("inventory.size", 0);
|
||||
if (size < 1 || (getInventory() != null && size > getInventory().getSize()))
|
||||
{
|
||||
return null;
|
||||
}
|
||||
ItemStack[] is = new ItemStack[size];
|
||||
for (int i = 0; i < size; i++)
|
||||
{
|
||||
is[i] = config.getItemStack("inventory." + i);
|
||||
}
|
||||
return is;
|
||||
}
|
||||
|
||||
public void setSavedInventory(ItemStack[] is)
|
||||
{
|
||||
if (is == null || is.length == 0)
|
||||
{
|
||||
savedInventory = null;
|
||||
config.removeProperty("inventory");
|
||||
}
|
||||
else
|
||||
{
|
||||
savedInventory = is;
|
||||
config.setProperty("inventory.size", is.length);
|
||||
for (int i = 0; i < is.length; i++)
|
||||
{
|
||||
if (is[i] == null || is[i].getType() == Material.AIR)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
config.setProperty("inventory." + i, is[i]);
|
||||
}
|
||||
}
|
||||
config.save();
|
||||
}
|
||||
private boolean teleportEnabled;
|
||||
|
||||
private boolean getTeleportEnabled()
|
||||
@@ -491,7 +440,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public List<String> getIgnoredPlayers()
|
||||
{
|
||||
return config.getStringList("ignore", new ArrayList<String>());
|
||||
return config.getStringList("ignore");
|
||||
}
|
||||
|
||||
public void setIgnoredPlayers(List<String> players)
|
||||
@@ -509,26 +458,37 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean isIgnoredPlayer(String name)
|
||||
@Deprecated
|
||||
public boolean isIgnoredPlayer(final String userName)
|
||||
{
|
||||
return ignoredPlayers.contains(name.toLowerCase(Locale.ENGLISH));
|
||||
final IUser user = ess.getUser(userName);
|
||||
if (user == null || !user.isOnline())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
return isIgnoredPlayer(user);
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(String name, boolean set)
|
||||
public boolean isIgnoredPlayer(IUser user)
|
||||
{
|
||||
return (ignoredPlayers.contains(user.getName().toLowerCase(Locale.ENGLISH)) && !user.isAuthorized("essentials.chat.ignoreexempt"));
|
||||
}
|
||||
|
||||
public void setIgnoredPlayer(IUser user, boolean set)
|
||||
{
|
||||
if (set)
|
||||
{
|
||||
ignoredPlayers.add(name.toLowerCase(Locale.ENGLISH));
|
||||
ignoredPlayers.add(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
else
|
||||
{
|
||||
ignoredPlayers.remove(name.toLowerCase(Locale.ENGLISH));
|
||||
ignoredPlayers.remove(user.getName().toLowerCase(Locale.ENGLISH));
|
||||
}
|
||||
setIgnoredPlayers(ignoredPlayers);
|
||||
}
|
||||
private boolean godmode;
|
||||
|
||||
private boolean getGodModeEnabled()
|
||||
private boolean _getGodModeEnabled()
|
||||
{
|
||||
return config.getBoolean("godmode", false);
|
||||
}
|
||||
@@ -544,16 +504,9 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("godmode", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleGodModeEnabled()
|
||||
{
|
||||
boolean ret = !isGodModeEnabled();
|
||||
setGodModeEnabled(ret);
|
||||
return ret;
|
||||
}
|
||||
private boolean muted;
|
||||
|
||||
private boolean getMuted()
|
||||
public boolean getMuted()
|
||||
{
|
||||
return config.getBoolean("muted", false);
|
||||
}
|
||||
@@ -569,13 +522,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
config.setProperty("muted", set);
|
||||
config.save();
|
||||
}
|
||||
|
||||
public boolean toggleMuted()
|
||||
{
|
||||
boolean ret = !isMuted();
|
||||
setMuted(ret);
|
||||
return ret;
|
||||
}
|
||||
private long muteTimeout;
|
||||
|
||||
private long _getMuteTimeout()
|
||||
@@ -645,7 +591,7 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
public void setBanReason(String reason)
|
||||
{
|
||||
config.setProperty("ban.reason", reason);
|
||||
config.setProperty("ban.reason", Util.sanitizeString(reason));
|
||||
config.save();
|
||||
}
|
||||
|
||||
@@ -671,10 +617,16 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return lastLogin;
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
private void _setLastLogin(long time)
|
||||
{
|
||||
lastLogin = time;
|
||||
config.setProperty("timestamps.login", time);
|
||||
}
|
||||
|
||||
public void setLastLogin(long time)
|
||||
{
|
||||
_setLastLogin(time);
|
||||
_setLastLoginAddress(base.getAddress().getAddress().getHostAddress());
|
||||
config.save();
|
||||
}
|
||||
private long lastLogout;
|
||||
@@ -707,11 +659,10 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return lastLoginAddress;
|
||||
}
|
||||
|
||||
public void setLastLoginAddress(String address)
|
||||
private void _setLastLoginAddress(String address)
|
||||
{
|
||||
lastLoginAddress = address;
|
||||
config.setProperty("ipAddress", address);
|
||||
config.save();
|
||||
}
|
||||
private boolean afk;
|
||||
|
||||
@@ -739,7 +690,6 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
return ret;
|
||||
}
|
||||
private boolean newplayer;
|
||||
|
||||
private String geolocation;
|
||||
|
||||
private String _getGeoLocation()
|
||||
@@ -831,16 +781,12 @@ public abstract class UserData extends PlayerExtension implements IConf
|
||||
|
||||
private Map<String, Object> _getKitTimestamps()
|
||||
{
|
||||
final Object map = config.getProperty("timestamps.kits");
|
||||
|
||||
if (map instanceof Map)
|
||||
if (config.isConfigurationSection("timestamps.kits"))
|
||||
{
|
||||
return (Map<String, Object>)map;
|
||||
}
|
||||
else
|
||||
{
|
||||
return new HashMap<String, Object>();
|
||||
return config.getConfigurationSection("timestamps.kits").getValues(false);
|
||||
}
|
||||
return new HashMap<String, Object>();
|
||||
}
|
||||
|
||||
public Long getKitTimestamp(final String name)
|
||||
|
@@ -61,7 +61,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
try
|
||||
{
|
||||
return users.get(Util.sanitizeFileName(name));
|
||||
return users.get(name);
|
||||
}
|
||||
catch (ExecutionException ex)
|
||||
{
|
||||
@@ -76,18 +76,31 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
@Override
|
||||
public User load(final String name) throws Exception
|
||||
{
|
||||
String sanitizedName = Util.sanitizeFileName(name);
|
||||
if (!sanitizedName.equals(name))
|
||||
{
|
||||
User user = getUser(sanitizedName);
|
||||
if (user == null)
|
||||
{
|
||||
throw new Exception("User not found!");
|
||||
}
|
||||
else
|
||||
{
|
||||
return user;
|
||||
}
|
||||
}
|
||||
for (Player player : ess.getServer().getOnlinePlayers())
|
||||
{
|
||||
if (player.getName().equalsIgnoreCase(name))
|
||||
{
|
||||
keys.add(Util.sanitizeFileName(name));
|
||||
keys.add(sanitizedName);
|
||||
return new User(player, ess);
|
||||
}
|
||||
}
|
||||
final File userFile = getUserFile(name);
|
||||
final File userFile = getUserFile2(sanitizedName);
|
||||
if (userFile.exists())
|
||||
{
|
||||
keys.add(Util.sanitizeFileName(name));
|
||||
keys.add(sanitizedName);
|
||||
return new User(new OfflinePlayer(name, ess), ess);
|
||||
}
|
||||
throw new Exception("User not found!");
|
||||
@@ -103,6 +116,7 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
keys.remove(Util.sanitizeFileName(name));
|
||||
users.invalidate(Util.sanitizeFileName(name));
|
||||
users.invalidate(name);
|
||||
}
|
||||
|
||||
public Set<String> getAllUniqueUsers()
|
||||
@@ -114,10 +128,15 @@ public class UserMap extends CacheLoader<String, User> implements IConf
|
||||
{
|
||||
return keys.size();
|
||||
}
|
||||
|
||||
|
||||
public File getUserFile(final String name)
|
||||
{
|
||||
return getUserFile2(Util.sanitizeFileName(name));
|
||||
}
|
||||
|
||||
private File getUserFile2(final String name)
|
||||
{
|
||||
final File userFolder = new File(ess.getDataFolder(), "userdata");
|
||||
return new File(userFolder, Util.sanitizeFileName(name) + ".yml");
|
||||
return new File(userFolder, name + ".yml");
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,18 @@ public class Util
|
||||
{
|
||||
}
|
||||
private final static Logger logger = Logger.getLogger("Minecraft");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDFILECHARS = Pattern.compile("[^a-z0-9]");
|
||||
private final static Pattern INVALIDCHARS = Pattern.compile("[^\t\n\r\u0020-\u007E\u0085\u00A0-\uD7FF\uE000-\uFFFC]");
|
||||
|
||||
public static String sanitizeFileName(final String name)
|
||||
{
|
||||
return INVALIDCHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
final String newName = INVALIDFILECHARS.matcher(name.toLowerCase(Locale.ENGLISH)).replaceAll("_");
|
||||
return newName;
|
||||
}
|
||||
|
||||
public static String sanitizeString(final String string)
|
||||
{
|
||||
return INVALIDCHARS.matcher(string).replaceAll("");
|
||||
}
|
||||
|
||||
public static String formatDateDiff(long date)
|
||||
@@ -73,11 +80,17 @@ public class Util
|
||||
_("second"),
|
||||
_("seconds")
|
||||
};
|
||||
int accuracy = 0;
|
||||
for (int i = 0; i < types.length; i++)
|
||||
{
|
||||
if (accuracy > 2)
|
||||
{
|
||||
break;
|
||||
}
|
||||
int diff = dateDiff(types[i], fromDate, toDate, future);
|
||||
if (diff > 0)
|
||||
{
|
||||
accuracy++;
|
||||
sb.append(" ").append(diff).append(" ").append(names[i * 2 + (diff > 1 ? 1 : 0)]);
|
||||
}
|
||||
}
|
||||
@@ -85,7 +98,7 @@ public class Util
|
||||
{
|
||||
return "now";
|
||||
}
|
||||
return sb.toString();
|
||||
return sb.toString().trim();
|
||||
}
|
||||
|
||||
private static int dateDiff(int type, Calendar fromDate, Calendar toDate, boolean future)
|
||||
@@ -202,6 +215,12 @@ public class Util
|
||||
{
|
||||
c.add(Calendar.SECOND, seconds * (future ? 1 : -1));
|
||||
}
|
||||
|
||||
Calendar max = new GregorianCalendar();
|
||||
max.add(Calendar.YEAR, 10);
|
||||
if (c.after(max)) {
|
||||
return max.getTimeInMillis();
|
||||
}
|
||||
return c.getTimeInMillis();
|
||||
}
|
||||
// The player can stand inside these materials
|
||||
@@ -235,6 +254,7 @@ public class Util
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.REDSTONE_TORCH_ON.getId());
|
||||
AIR_MATERIALS.add(Material.STONE_BUTTON.getId());
|
||||
AIR_MATERIALS.add(Material.SNOW.getId());
|
||||
AIR_MATERIALS.add(Material.SUGAR_CANE_BLOCK.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_OFF.getId());
|
||||
AIR_MATERIALS.add(Material.DIODE_BLOCK_ON.getId());
|
||||
@@ -242,8 +262,10 @@ public class Util
|
||||
AIR_MATERIALS.add(Material.PUMPKIN_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.MELON_STEM.getId());
|
||||
AIR_MATERIALS.add(Material.VINE.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||
AIR_MATERIALS.add(Material.FENCE_GATE.getId());
|
||||
AIR_MATERIALS.add(Material.WATER_LILY.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_FENCE.getId());
|
||||
AIR_MATERIALS.add(Material.NETHER_WARTS.getId());
|
||||
|
||||
for (Integer integer : AIR_MATERIALS)
|
||||
{
|
||||
@@ -286,7 +308,7 @@ public class Util
|
||||
while (isBlockUnsafe(world, x, y, z))
|
||||
{
|
||||
y += 1;
|
||||
if (y >= 127)
|
||||
if (y >= world.getHighestBlockYAt(x, z))
|
||||
{
|
||||
x += 1;
|
||||
break;
|
||||
@@ -297,8 +319,8 @@ public class Util
|
||||
y -= 1;
|
||||
if (y <= 1)
|
||||
{
|
||||
y = 127;
|
||||
x += 1;
|
||||
y = world.getHighestBlockYAt(x, z);
|
||||
if (x - 32 > loc.getBlockX())
|
||||
{
|
||||
throw new Exception(_("holeInFloor"));
|
||||
@@ -415,11 +437,11 @@ public class Util
|
||||
}
|
||||
return is;
|
||||
}
|
||||
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
|
||||
|
||||
public static String formatCurrency(final double value, final IEssentials ess)
|
||||
public static String formatAsCurrency(final double value)
|
||||
{
|
||||
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
|
||||
String str = dFormat.format(value);
|
||||
if (str.endsWith(".00"))
|
||||
{
|
||||
str = str.substring(0, str.length() - 3);
|
||||
@@ -427,6 +449,16 @@ public class Util
|
||||
return str;
|
||||
}
|
||||
|
||||
public static String displayCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
|
||||
}
|
||||
|
||||
public static String shortCurrency(final double value, final IEssentials ess)
|
||||
{
|
||||
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
|
||||
}
|
||||
|
||||
public static double roundDouble(final double d)
|
||||
{
|
||||
return Math.round(d * 100.0) / 100.0;
|
||||
@@ -478,26 +510,112 @@ public class Util
|
||||
}
|
||||
return buf.toString();
|
||||
}
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-FKa-fk]");
|
||||
private static transient final Pattern EASY_COLOR_PATTERN = Pattern.compile("&([0-9a-fk])");
|
||||
|
||||
public static String lastCode(final String input) {
|
||||
int pos = input.lastIndexOf("§");
|
||||
if (pos == -1 || (pos + 1) == input.length()) {
|
||||
return "";
|
||||
}
|
||||
return input.substring(pos, pos + 2);
|
||||
}
|
||||
|
||||
private static transient final Pattern URL_PATTERN = Pattern.compile("((?:(?:https?)://)?[\\w-_\\.]{2,})\\.([a-z]{2,3}(?:/\\S+)?)");
|
||||
private static transient final Pattern VANILLA_PATTERN = Pattern.compile("\u00A7+[0-9A-FK-ORa-fk-or]");
|
||||
private static transient final Pattern REPLACE_PATTERN = Pattern.compile("&([0-9a-fk-or])");
|
||||
private static transient final Pattern VANILLA_COLOR_PATTERN = Pattern.compile("\u00A7+[0-9A-Fa-f]");
|
||||
private static transient final Pattern VANILLA_MAGIC_PATTERN = Pattern.compile("\u00A7+[Kk]");
|
||||
private static transient final Pattern VANILLA_FORMAT_PATTERN = Pattern.compile("\u00A7+[L-ORl-or]");
|
||||
private static transient final Pattern REPLACE_COLOR_PATTERN = Pattern.compile("&([0-9a-f])");
|
||||
private static transient final Pattern REPLACE_MAGIC_PATTERN = Pattern.compile("&(k)");
|
||||
private static transient final Pattern REPLACE_FORMAT_PATTERN = Pattern.compile("&([l-or])");
|
||||
|
||||
public static String stripColor(final String input)
|
||||
public static String stripFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
return VANILLA_COLOR_PATTERN.matcher(input).replaceAll("");
|
||||
return VANILLA_PATTERN.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
public static String replaceColor(final String input)
|
||||
public static String replaceFormat(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return REPLACE_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
|
||||
return EASY_COLOR_PATTERN.matcher(input).replaceAll("\u00a7$1");
|
||||
public static String blockURL(final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String text = URL_PATTERN.matcher(input).replaceAll("$1 $2");
|
||||
while (URL_PATTERN.matcher(text).find())
|
||||
{
|
||||
text = URL_PATTERN.matcher(text).replaceAll("$1 $2");
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
public static String formatString(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message;
|
||||
if (user.isAuthorized(permBase + ".color"))
|
||||
{
|
||||
message = Util.replaceColor(input, REPLACE_COLOR_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(input, VANILLA_COLOR_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".magic"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_MAGIC_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_MAGIC_PATTERN);
|
||||
}
|
||||
if (user.isAuthorized(permBase + ".format"))
|
||||
{
|
||||
message = Util.replaceColor(message, REPLACE_FORMAT_PATTERN);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message, VANILLA_FORMAT_PATTERN);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
public static String formatMessage(final IUser user, final String permBase, final String input)
|
||||
{
|
||||
if (input == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
String message = formatString(user, permBase, input);
|
||||
if (!user.isAuthorized(permBase + ".url"))
|
||||
{
|
||||
message = Util.blockURL(message);
|
||||
}
|
||||
return message;
|
||||
}
|
||||
|
||||
private static String stripColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("");
|
||||
}
|
||||
|
||||
private static String replaceColor(final String input, final Pattern pattern)
|
||||
{
|
||||
return pattern.matcher(input).replaceAll("\u00a7$1");
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.commands.WarpNotFoundException;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
import java.util.logging.Level;
|
||||
@@ -48,7 +49,7 @@ public class Warps implements IConf
|
||||
EssentialsConf conf = warpPoints.get(new StringIgnoreCase(warp));
|
||||
if (conf == null)
|
||||
{
|
||||
throw new Exception(_("warpNotExist"));
|
||||
throw new WarpNotFoundException();
|
||||
}
|
||||
return conf.getLocation(null, server);
|
||||
}
|
||||
|
@@ -115,6 +115,10 @@ public final class Economy
|
||||
{
|
||||
throw new UserDoesNotExistException(name);
|
||||
}
|
||||
if (balance < ess.getSettings().getMinMoney())
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
}
|
||||
if (balance < 0.0 && !user.isAuthorized("essentials.eco.loan"))
|
||||
{
|
||||
throw new NoLoanPermittedException();
|
||||
@@ -245,7 +249,7 @@ public final class Economy
|
||||
{
|
||||
throw new RuntimeException(noCallBeforeLoad);
|
||||
}
|
||||
return Util.formatCurrency(amount, ess);
|
||||
return Util.displayCurrency(amount, ess);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@@ -10,6 +10,8 @@ public interface IJails extends IReload
|
||||
|
||||
Collection<String> getList() throws Exception;
|
||||
|
||||
int getCount();
|
||||
|
||||
void removeJail(String jail) throws Exception;
|
||||
|
||||
void sendToJail(com.earth2me.essentials.IUser user, String jail) throws Exception;
|
||||
|
@@ -31,6 +31,7 @@ public class Commandafk extends EssentialsCommand
|
||||
|
||||
private void toggleAfk(User user)
|
||||
{
|
||||
user.setDisplayNick();
|
||||
if (!user.toggleAfk())
|
||||
{
|
||||
//user.sendMessage(_("markedAsNotAway"));
|
||||
|
@@ -17,8 +17,11 @@ public class Commandantioch extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
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.");
|
||||
if (args.length > 0)
|
||||
{
|
||||
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 = Util.getTarget(user);
|
||||
loc.getWorld().spawn(loc, TNTPrimed.class);
|
||||
|
@@ -16,9 +16,15 @@ public class Commandback extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (user.getWorld() != user.getLastLocation().getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getLastLocation().getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + user.getLastLocation().getWorld().getName()));
|
||||
}
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.sendMessage(_("backUsageMsg"));
|
||||
user.getTeleport().back(charge);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -19,7 +19,12 @@ public class Commandbackup extends EssentialsCommand
|
||||
final Backup backup = ess.getBackup();
|
||||
if (backup == null)
|
||||
{
|
||||
throw new Exception();
|
||||
throw new Exception(_("backupDisabled"));
|
||||
}
|
||||
final String command = ess.getSettings().getBackupCommand();
|
||||
if (command == null || "".equals(command) || "save-all".equalsIgnoreCase(command))
|
||||
{
|
||||
throw new Exception(_("backupDisabled"));
|
||||
}
|
||||
backup.run();
|
||||
sender.sendMessage(_("backupStarted"));
|
||||
|
@@ -21,7 +21,7 @@ public class Commandbalance extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
sender.sendMessage(_("balance", Util.formatCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
sender.sendMessage(_("balance", Util.displayCurrency(getPlayer(server, args, 0, true).getMoney(), ess)));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,6 +32,6 @@ public class Commandbalance extends EssentialsCommand
|
||||
|| user.isAuthorized("essentials.balance.other"))
|
||||
? user
|
||||
: getPlayer(server, args, 0, true)).getMoney();
|
||||
user.sendMessage(_("balance", Util.formatCurrency(bal, ess)));
|
||||
user.sendMessage(_("balance", Util.displayCurrency(bal, ess)));
|
||||
}
|
||||
}
|
||||
|
@@ -105,14 +105,18 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
{
|
||||
if (force || cacheage <= System.currentTimeMillis() - CACHETIME)
|
||||
{
|
||||
cache.getLines().clear();
|
||||
cache.getLines().clear();
|
||||
final Map<String, Double> balances = new HashMap<String, Double>();
|
||||
double totalMoney = 0d;
|
||||
for (String u : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User user = ess.getUserMap().getUser(u);
|
||||
if (user != null)
|
||||
{
|
||||
balances.put(user.getDisplayName(), user.getMoney());
|
||||
final double userMoney = user.getMoney();
|
||||
user.updateMoneyCache(userMoney);
|
||||
totalMoney += userMoney;
|
||||
balances.put(user.getDisplayName(), userMoney);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -125,10 +129,12 @@ public class Commandbalancetop extends EssentialsCommand
|
||||
return -entry1.getValue().compareTo(entry2.getValue());
|
||||
}
|
||||
});
|
||||
|
||||
cache.getLines().add(_("serverTotal", Util.displayCurrency(totalMoney, ess)));
|
||||
int pos = 1;
|
||||
for (Map.Entry<String, Double> entry : sortedEntries)
|
||||
{
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.formatCurrency(entry.getValue(), ess));
|
||||
cache.getLines().add(pos + ". " + entry.getKey() + ", " + Util.displayCurrency(entry.getValue(), ess));
|
||||
pos++;
|
||||
}
|
||||
cacheage = System.currentTimeMillis();
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -24,7 +23,7 @@ public class Commandban extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.ban.offline"))
|
||||
@@ -41,20 +40,21 @@ public class Commandban extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
String banReason;
|
||||
if (args.length > 1)
|
||||
{
|
||||
banReason = getFinalArg(args, 1);
|
||||
user.setBanReason(banReason);
|
||||
banReason = _("banFormat", getFinalArg(args, 1), senderName);
|
||||
}
|
||||
else
|
||||
{
|
||||
banReason = _("defaultBanReason");
|
||||
banReason = _("banFormat", _("defaultBanReason"), senderName);
|
||||
}
|
||||
|
||||
user.setBanReason(banReason);
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -27,6 +27,10 @@ public class Commandbigtree extends EssentialsCommand
|
||||
{
|
||||
tree = TreeType.BIG_TREE;
|
||||
}
|
||||
else if (args.length > 0 && args[0].equalsIgnoreCase("jungle"))
|
||||
{
|
||||
tree = TreeType.JUNGLE;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
|
@@ -1,10 +1,14 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
public class Commandbreak extends EssentialsCommand
|
||||
@@ -29,8 +33,10 @@ public class Commandbreak extends EssentialsCommand
|
||||
}
|
||||
if (block.getType() == Material.BEDROCK && !user.isAuthorized("essentials.break.bedrock"))
|
||||
{
|
||||
throw new Exception("You are not allowed to destroy bedrock."); //TODO: Translation
|
||||
throw new Exception(_("noBreakBedrock"));
|
||||
}
|
||||
//final List<ItemStack> list = (List<ItemStack>)block.getDrops();
|
||||
//final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase(), list);
|
||||
final BlockBreakEvent event = new BlockBreakEvent(block, user.getBase());
|
||||
server.getPluginManager().callEvent(event);
|
||||
if (event.isCancelled())
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -20,6 +21,6 @@ public class Commandbroadcast extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
ess.broadcastMessage(null, _("broadcast", getFinalArg(args, 0)));
|
||||
ess.broadcastMessage(null, _("broadcast", Util.replaceFormat(getFinalArg(args, 0))));
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
@@ -33,7 +34,31 @@ public class Commandeco extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException(ex);
|
||||
}
|
||||
|
||||
if (args[1].contentEquals("*"))
|
||||
if (args[1].contentEquals("**"))
|
||||
{
|
||||
for (String sUser : ess.getUserMap().getAllUniqueUsers())
|
||||
{
|
||||
final User player = ess.getUser(sUser);
|
||||
switch (cmd)
|
||||
{
|
||||
case GIVE:
|
||||
player.giveMoney(amount);
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (player.canAfford(amount, false))
|
||||
{
|
||||
player.takeMoney(amount);
|
||||
}
|
||||
break;
|
||||
|
||||
case RESET:
|
||||
player.setMoney(amount == 0 ? ess.getSettings().getStartingBalance() : amount);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (args[1].contentEquals("*"))
|
||||
{
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
@@ -45,6 +70,10 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount);
|
||||
break;
|
||||
|
||||
@@ -64,6 +93,10 @@ public class Commandeco extends EssentialsCommand
|
||||
break;
|
||||
|
||||
case TAKE:
|
||||
if (!player.canAfford(amount, false))
|
||||
{
|
||||
throw new Exception(_("notEnoughMoney"));
|
||||
}
|
||||
player.takeMoney(amount, sender);
|
||||
break;
|
||||
|
||||
|
@@ -2,13 +2,18 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.metrics.Metrics;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
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.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
@@ -35,6 +40,14 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
run_nya(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("moo"))
|
||||
{
|
||||
run_moo(server, sender, commandLabel, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("opt-out"))
|
||||
{
|
||||
run_optout(server, sender, commandLabel, args);
|
||||
}
|
||||
else {
|
||||
run_reload(server, sender, commandLabel, args);
|
||||
}
|
||||
@@ -44,7 +57,7 @@ public class Commandessentials extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage("Essentials " + ess.getDescription().getVersion());
|
||||
sender.sendMessage("/<command> <reload/debug>");
|
||||
sender.sendMessage(_("blockList"));
|
||||
|
||||
final StringBuilder disabledCommands = new StringBuilder();
|
||||
for (Map.Entry<String, String> entry : ess.getAlternativeCommandsHandler().disabledCommands().entrySet())
|
||||
{
|
||||
@@ -53,7 +66,10 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
disabledCommands.append(entry.getKey()).append(" => ").append(entry.getValue());
|
||||
}
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
if (disabledCommands.length() > 0) {
|
||||
sender.sendMessage(_("blockList"));
|
||||
sender.sendMessage(disabledCommands.toString());
|
||||
}
|
||||
}
|
||||
|
||||
private void run_debug(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
@@ -144,7 +160,6 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
}, 20, 2);
|
||||
return;
|
||||
}
|
||||
|
||||
private void stopTune()
|
||||
@@ -159,4 +174,31 @@ public class Commandessentials extends EssentialsCommand
|
||||
}
|
||||
noteBlocks.clear();
|
||||
}
|
||||
|
||||
private void run_moo(final Server server, final CommandSender sender, final String command, final String args[])
|
||||
{
|
||||
if(sender instanceof ConsoleCommandSender)
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | ||", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
else
|
||||
sender.sendMessage(new String[]{" (__)", " (oo)", " /------\\/", " / | | |", " * /\\---/\\", " ~~ ~~", "....\"Have you mooed today?\"..." } );
|
||||
}
|
||||
|
||||
private void run_optout(final Server server, final CommandSender sender, final String command, final String args[])
|
||||
{
|
||||
final Metrics metrics = ess.getMetrics();
|
||||
try
|
||||
{
|
||||
sender.sendMessage("Essentials collects simple metrics to highlight which features to concentrate work on in the future.");
|
||||
if (metrics.isOptOut()) {
|
||||
metrics.enable();
|
||||
} else {
|
||||
metrics.disable();
|
||||
}
|
||||
sender.sendMessage("Anonymous Metrics are now: " + (metrics.isOptOut() ? "disabled" : "enabled"));
|
||||
}
|
||||
catch (IOException ex)
|
||||
{
|
||||
sender.sendMessage("Unable to modify 'plugins/PluginMetrics/config.yml': " + ex.getMessage());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
143
Essentials/src/com/earth2me/essentials/commands/Commandexp.java
Normal file
143
Essentials/src/com/earth2me/essentials/commands/Commandexp.java
Normal file
@@ -0,0 +1,143 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.craftbukkit.SetExpFix;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandexp extends EssentialsCommand
|
||||
{
|
||||
public Commandexp()
|
||||
{
|
||||
super("exp");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("set") && user.isAuthorized("essentials.exp.set"))
|
||||
{
|
||||
if (args.length == 3 && user.isAuthorized("essentials.exp.set.others"))
|
||||
{
|
||||
expMatch(server, user, args[1], args[2], false);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExp(user, user, args[1], false);
|
||||
}
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("give") && user.isAuthorized("essentials.exp.give"))
|
||||
{
|
||||
if (args.length == 3 && user.isAuthorized("essentials.exp.give.others"))
|
||||
{
|
||||
expMatch(server, user, args[1], args[2], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
setExp(user, user, args[1], true);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
{
|
||||
match = args[1].trim();
|
||||
}
|
||||
if (match.equalsIgnoreCase("show") || !user.isAuthorized("essentials.exp.others"))
|
||||
{
|
||||
showExp(user, user);
|
||||
}
|
||||
else
|
||||
{
|
||||
showMatch(server, user, match);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
else if (args.length > 2 && args[0].equalsIgnoreCase("set"))
|
||||
{
|
||||
expMatch(server, sender, args[1], args[2], false);
|
||||
}
|
||||
else if (args.length > 2 && args[0].equalsIgnoreCase("give"))
|
||||
{
|
||||
expMatch(server, sender, args[1], args[2], true);
|
||||
}
|
||||
else
|
||||
{
|
||||
String match = args[0].trim();
|
||||
if (args.length == 2)
|
||||
{
|
||||
match = args[1].trim();
|
||||
}
|
||||
showMatch(server, sender, match);
|
||||
}
|
||||
}
|
||||
|
||||
private void showMatch(final Server server, final CommandSender sender, final String match) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
{
|
||||
foundUser = true;
|
||||
final User target = ess.getUser(matchPlayer);
|
||||
showExp(sender, target);
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void expMatch(final Server server, final CommandSender sender, final String match, final String amount, final boolean toggle) throws NotEnoughArgumentsException
|
||||
{
|
||||
boolean foundUser = false;
|
||||
for (Player matchPlayer : server.matchPlayer(match))
|
||||
{
|
||||
final User target = ess.getUser(matchPlayer);
|
||||
setExp(sender, target, amount, toggle);
|
||||
foundUser = true;
|
||||
}
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
|
||||
private void showExp(final CommandSender sender, final User target)
|
||||
{
|
||||
final int totalExp = SetExpFix.getTotalExperience(target);
|
||||
final int expLeft = (int)Util.roundDouble(((((3.5 * target.getLevel()) + 6.7) - (totalExp - ((1.75 * (target.getLevel() * target.getLevel())) + (5.00 * target.getLevel())))) + 1));
|
||||
sender.sendMessage(_("exp", target.getDisplayName(), SetExpFix.getTotalExperience(target), target.getLevel(), expLeft));
|
||||
}
|
||||
|
||||
private void setExp(final CommandSender sender, final User target, final String strAmount, final boolean give)
|
||||
{
|
||||
Long amount = Long.parseLong(strAmount);
|
||||
if (give)
|
||||
{
|
||||
amount += SetExpFix.getTotalExperience(target);
|
||||
}
|
||||
if (amount > Integer.MAX_VALUE)
|
||||
{
|
||||
amount = (long)Integer.MAX_VALUE;
|
||||
}
|
||||
SetExpFix.setTotalExperience(target, amount.intValue());
|
||||
sender.sendMessage(_("expSet", target.getDisplayName(), amount));
|
||||
}
|
||||
}
|
@@ -0,0 +1,77 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
|
||||
public class Commandfly extends EssentialsCommand
|
||||
{
|
||||
public Commandfly()
|
||||
{
|
||||
super("fly");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
flyOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.fly.others"))
|
||||
{
|
||||
flyOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
user.setAllowFlight(!user.getAllowFlight());
|
||||
if (!user.getAllowFlight())
|
||||
{
|
||||
user.setFlying(false);
|
||||
}
|
||||
user.sendMessage(_("flyMode", _(user.getAllowFlight() ? "enabled" : "disabled"), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void flyOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setAllowFlight(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAllowFlight(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setAllowFlight(!player.getAllowFlight());
|
||||
}
|
||||
|
||||
if (!player.getAllowFlight())
|
||||
{
|
||||
player.setFlying(false);
|
||||
}
|
||||
sender.sendMessage(_("flyMode", _(player.getAllowFlight() ? "enabled" : "disabled"), player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
}
|
@@ -24,15 +24,15 @@ public class Commandgamemode extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
gamemodeOtherPlayers(server, sender, args[0]);
|
||||
gamemodeOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.gamemode.others"))
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.gamemode.others"))
|
||||
{
|
||||
gamemodeOtherPlayers(server, user, args[0]);
|
||||
gamemodeOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -40,9 +40,9 @@ public class Commandgamemode extends EssentialsCommand
|
||||
user.sendMessage(_("gameMode", _(user.getGameMode().toString().toLowerCase(Locale.ENGLISH)), user.getDisplayName()));
|
||||
}
|
||||
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void gamemodeOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
@@ -50,7 +50,21 @@ public class Commandgamemode extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("creat") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setGameMode(GameMode.CREATIVE);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGameMode(player.getGameMode() == GameMode.SURVIVAL ? GameMode.CREATIVE : GameMode.SURVIVAL);
|
||||
}
|
||||
sender.sendMessage(_("gameMode", _(player.getGameMode().toString().toLowerCase(Locale.ENGLISH)), player.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -16,6 +17,21 @@ public class Commandgc extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
float tps = ess.getTimer().getAverageTPS();
|
||||
ChatColor color;
|
||||
if (tps >= 18)
|
||||
{
|
||||
color = ChatColor.GREEN;
|
||||
}
|
||||
else if (tps >= 15)
|
||||
{
|
||||
color = ChatColor.YELLOW;
|
||||
}
|
||||
else
|
||||
{
|
||||
color = ChatColor.RED;
|
||||
}
|
||||
sender.sendMessage(_("tps", "" + color + tps));
|
||||
sender.sendMessage(_("gcmax", (Runtime.getRuntime().maxMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gctotal", (Runtime.getRuntime().totalMemory() / 1024 / 1024)));
|
||||
sender.sendMessage(_("gcfree", (Runtime.getRuntime().freeMemory() / 1024 / 1024)));
|
||||
|
@@ -12,21 +12,23 @@ public class Commandgetpos extends EssentialsCommand
|
||||
{
|
||||
super("getpos");
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && user.isAuthorized("essentials.getpos.others"))
|
||||
{
|
||||
final User otherUser = getPlayer(server, args, 0);
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
outputPosition(user, user.getLocation(), null);
|
||||
if (!otherUser.isHidden() || user.isAuthorized("essentials.list.hidden"))
|
||||
{
|
||||
outputPosition(user, otherUser.getLocation(), user.getLocation());
|
||||
return;
|
||||
}
|
||||
|
||||
}
|
||||
outputPosition(user, user.getLocation(), null);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@@ -37,7 +39,7 @@ public class Commandgetpos extends EssentialsCommand
|
||||
final User user = getPlayer(server, args, 0);
|
||||
outputPosition(sender, user.getLocation(), null);
|
||||
}
|
||||
|
||||
|
||||
//TODO: Translate
|
||||
private void outputPosition(final CommandSender sender, final Location coords, final Location distance)
|
||||
{
|
||||
|
@@ -1,7 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -19,7 +21,6 @@ public class Commandgive extends EssentialsCommand
|
||||
super("give");
|
||||
}
|
||||
|
||||
//TODO: move these messages to message file
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
@@ -39,12 +40,17 @@ public class Commandgive extends EssentialsCommand
|
||||
: (!ess.getUser(sender).isAuthorized("essentials.itemspawn.exempt")
|
||||
&& !ess.getUser(sender).canSpawnItem(stack.getTypeId()))))
|
||||
{
|
||||
throw new Exception(ChatColor.RED + "You are not allowed to spawn the item " + itemname);
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
final User giveTo = getPlayer(server, args, 0);
|
||||
|
||||
if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
if (args.length > 3 && Util.isInt(args[2]) && Util.isInt(args[3]))
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
stack.setDurability(Short.parseShort(args[3]));
|
||||
}
|
||||
else if (args.length > 2 && Integer.parseInt(args[2]) > 0)
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[2]));
|
||||
}
|
||||
@@ -59,7 +65,7 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (args.length > 3)
|
||||
{
|
||||
for (int i = 3; i < args.length; i++)
|
||||
for (int i = Util.isInt(args[3]) ? 4 : 3; i < args.length; i++)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
@@ -82,9 +88,10 @@ public class Commandgive extends EssentialsCommand
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
{
|
||||
throw new Exception(ChatColor.RED + "You can't give air.");
|
||||
throw new Exception(_("cantSpawnItem", "Air"));
|
||||
}
|
||||
|
||||
//TODO: TL this.
|
||||
final String itemName = stack.getType().toString().toLowerCase(Locale.ENGLISH).replace('_', ' ');
|
||||
sender.sendMessage(ChatColor.BLUE + "Giving " + stack.getAmount() + " of " + itemName + " to " + giveTo.getDisplayName() + ".");
|
||||
if (giveTo.isAuthorized("essentials.oversizedstacks"))
|
||||
|
@@ -22,31 +22,53 @@ public class Commandgod extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
godOtherPlayers(server, sender, args[0]);
|
||||
godOtherPlayers(server, sender, args);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && !args[0].trim().isEmpty() && user.isAuthorized("essentials.god.others"))
|
||||
if (args.length > 0 && args[0].trim().length() > 2 && user.isAuthorized("essentials.god.others"))
|
||||
{
|
||||
godOtherPlayers(server, user, args[0]);
|
||||
godOtherPlayers(server, user, args);
|
||||
return;
|
||||
}
|
||||
|
||||
user.sendMessage(_("godMode", (user.toggleGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
user.setGodModeEnabled(!user.isGodModeEnabled());
|
||||
user.sendMessage(_("godMode", (user.isGodModeEnabled() ? _("enabled") : _("disabled"))));
|
||||
}
|
||||
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String name)
|
||||
private void godOtherPlayers(final Server server, final CommandSender sender, final String[] args)
|
||||
{
|
||||
for (Player matchPlayer : server.matchPlayer(name))
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final User player = ess.getUser(matchPlayer);
|
||||
if (player.isHidden())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final boolean enabled = player.toggleGodModeEnabled();
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
if (args[1].contains("on") || args[1].contains("ena") || args[1].equalsIgnoreCase("1"))
|
||||
{
|
||||
player.setGodModeEnabled(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(false);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setGodModeEnabled(!player.isGodModeEnabled());
|
||||
}
|
||||
|
||||
final boolean enabled = player.isGodModeEnabled();
|
||||
if (enabled)
|
||||
{
|
||||
player.setFoodLevel(20);
|
||||
}
|
||||
|
||||
player.sendMessage(_("godMode", (enabled ? _("enabled") : _("disabled"))));
|
||||
sender.sendMessage(_("godMode", _(enabled ? "godEnabledFor" : "godDisabledFor", matchPlayer.getDisplayName())));
|
||||
}
|
||||
|
@@ -0,0 +1,63 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.craftbukkit.InventoryWorkaround;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
|
||||
|
||||
public class Commandhat extends EssentialsCommand
|
||||
{
|
||||
public Commandhat()
|
||||
{
|
||||
super("hat");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length > 0 && (args[0].contains("rem") || args[0].contains("off") || args[0].equalsIgnoreCase("0")))
|
||||
{
|
||||
final PlayerInventory inv = user.getInventory();
|
||||
final ItemStack head = inv.getHelmet();
|
||||
if (head == null || head.getType() == Material.AIR)
|
||||
{
|
||||
user.sendMessage(_("hatEmpty"));
|
||||
}
|
||||
else
|
||||
{
|
||||
final ItemStack air = new ItemStack(Material.AIR);
|
||||
inv.setHelmet(air);
|
||||
InventoryWorkaround.addItem(user.getInventory(), true, head);
|
||||
user.sendMessage(_("hatRemoved"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (user.getItemInHand().getType() != Material.AIR)
|
||||
{
|
||||
final ItemStack hand = user.getItemInHand();
|
||||
if (hand.getType().getMaxDurability() == 0)
|
||||
{
|
||||
final PlayerInventory inv = user.getInventory();
|
||||
final ItemStack head = inv.getHelmet();
|
||||
inv.removeItem(hand);
|
||||
inv.setHelmet(hand);
|
||||
inv.setItemInHand(head);
|
||||
user.sendMessage(_("hatPlaced"));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("hatArmor"));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("hatFail"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@@ -4,6 +4,7 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.textreader.*;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -21,6 +22,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
IText output;
|
||||
String pageStr = args.length > 0 ? args[0] : null;
|
||||
String chapterPageStr = args.length > 1 ? args[1] : null;
|
||||
String command = commandLabel;
|
||||
final IText input = new TextInput(user, "help", false, ess);
|
||||
|
||||
if (input.getLines().isEmpty())
|
||||
@@ -31,7 +33,12 @@ public class Commandhelp extends EssentialsCommand
|
||||
}
|
||||
else
|
||||
{
|
||||
output = new HelpInput(user, pageStr, ess);
|
||||
if (pageStr.length() > 26)
|
||||
{
|
||||
pageStr = pageStr.substring(0, 25);
|
||||
}
|
||||
output = new HelpInput(user, pageStr.toLowerCase(Locale.ENGLISH), ess);
|
||||
command = command.concat(" ").concat(pageStr);
|
||||
pageStr = chapterPageStr;
|
||||
}
|
||||
chapterPageStr = null;
|
||||
@@ -41,7 +48,7 @@ public class Commandhelp extends EssentialsCommand
|
||||
output = new KeywordReplacer(input, user, ess);
|
||||
}
|
||||
final TextPager pager = new TextPager(output);
|
||||
pager.showPage(pageStr, chapterPageStr, commandLabel, user);
|
||||
pager.showPage(pageStr, chapterPageStr, command, user);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@@ -22,8 +22,8 @@ public class Commandhelpop extends EssentialsCommand
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
final String message = _("helpOp", user.getDisplayName(), Util.stripColor(getFinalArg(args, 0)));
|
||||
user.setDisplayNick();
|
||||
final String message = _("helpOp", user.getDisplayName(), Util.stripFormat(getFinalArg(args, 0)));
|
||||
logger.log(Level.INFO, message);
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -54,7 +54,7 @@ public class Commandhome extends EssentialsCommand
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
user.getTeleport().home(player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
goHome(user, player, homeName.toLowerCase(Locale.ENGLISH), charge);
|
||||
}
|
||||
catch (NotEnoughArgumentsException e)
|
||||
{
|
||||
@@ -80,7 +80,7 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
else if (homes.size() == 1 && player.equals(user))
|
||||
{
|
||||
user.getTeleport().home(player, homes.get(0), charge);
|
||||
goHome(user, player, homes.get(0), charge);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -93,4 +93,19 @@ public class Commandhome extends EssentialsCommand
|
||||
}
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
private void goHome(final User user, final User player, final String home, final Trade charge) throws Exception
|
||||
{
|
||||
final Location loc = player.getHome(home);
|
||||
if (loc == null)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if (user.getWorld() != loc.getWorld() && ess.getSettings().isWorldHomePermissions()
|
||||
&& !user.isAuthorized("essentials.world." + loc.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + loc.getWorld().getName()));
|
||||
}
|
||||
user.getTeleport().home(loc, charge);
|
||||
}
|
||||
}
|
||||
|
@@ -32,15 +32,14 @@ public class Commandignore extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
final String name = player.getName();
|
||||
if (user.isIgnoredPlayer(name))
|
||||
if (user.isIgnoredPlayer(player))
|
||||
{
|
||||
user.setIgnoredPlayer(name, false);
|
||||
user.setIgnoredPlayer(player, false);
|
||||
user.sendMessage(_("unignorePlayer", player.getName()));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.setIgnoredPlayer(name, true);
|
||||
user.setIgnoredPlayer(player, true);
|
||||
user.sendMessage(_("ignorePlayer", player.getName()));
|
||||
}
|
||||
}
|
||||
|
@@ -17,41 +17,12 @@ public class Commandinvsee extends EssentialsCommand
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
|
||||
if (args.length < 1 && user.getSavedInventory() == null)
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
User invUser = user;
|
||||
if (args.length == 1)
|
||||
{
|
||||
invUser = getPlayer(server, args, 0);
|
||||
}
|
||||
if (invUser == user && user.getSavedInventory() != null)
|
||||
{
|
||||
invUser.getInventory().setContents(user.getSavedInventory());
|
||||
user.setSavedInventory(null);
|
||||
user.sendMessage(_("invRestored"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
|
||||
if (user.getSavedInventory() == null)
|
||||
{
|
||||
user.setSavedInventory(user.getInventory().getContents());
|
||||
}
|
||||
ItemStack[] invUserStack = invUser.getInventory().getContents();
|
||||
final int userStackLength = user.getInventory().getContents().length;
|
||||
if (invUserStack.length < userStackLength)
|
||||
{
|
||||
invUserStack = Arrays.copyOf(invUserStack, userStackLength);
|
||||
}
|
||||
if (invUserStack.length > userStackLength)
|
||||
{
|
||||
throw new Exception(_("invBigger"));
|
||||
}
|
||||
user.getInventory().setContents(invUserStack);
|
||||
user.sendMessage(_("invSee", invUser.getDisplayName()));
|
||||
user.sendMessage(_("invSeeHelp"));
|
||||
throw new NoChargeException();
|
||||
final User invUser = getPlayer(server, args, 0);
|
||||
user.setInvSee(true);
|
||||
user.openInventory(invUser.getInventory());
|
||||
}
|
||||
}
|
||||
|
@@ -36,41 +36,46 @@ public class Commanditem extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("cantSpawnItem", itemname));
|
||||
}
|
||||
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
try
|
||||
{
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
if (args.length > 1 && Integer.parseInt(args[1]) > 0)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
stack.setAmount(Integer.parseInt(args[1]));
|
||||
}
|
||||
else if (ess.getSettings().getDefaultStackSize() > 0)
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getDefaultStackSize());
|
||||
}
|
||||
else if (ess.getSettings().getOversizedStackSize() > 0 && user.isAuthorized("essentials.oversizedstacks"))
|
||||
{
|
||||
stack.setAmount(ess.getSettings().getOversizedStackSize());
|
||||
}
|
||||
if (args.length > 2)
|
||||
{
|
||||
for (int i = 2; i < args.length; i++)
|
||||
{
|
||||
final String[] split = args[i].split("[:+',;.]", 2);
|
||||
if (split.length < 1)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final Enchantment enchantment = Commandenchant.getEnchantment(split[0], user);
|
||||
int level;
|
||||
if (split.length > 1)
|
||||
{
|
||||
level = Integer.parseInt(split[1]);
|
||||
}
|
||||
else
|
||||
{
|
||||
level = enchantment.getMaxLevel();
|
||||
}
|
||||
stack.addEnchantment(enchantment, level);
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (stack.getType() == Material.AIR)
|
||||
|
@@ -1,5 +1,7 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -33,5 +35,15 @@ public class Commanditemdb extends EssentialsCommand
|
||||
itemStack = ess.getItemDb().get(args[0]);
|
||||
}
|
||||
sender.sendMessage(itemStack.getType().toString() + "- " + itemStack.getTypeId() + ":" + Integer.toString(itemStack.getData().getData()));
|
||||
|
||||
if (itemStack.getType() != Material.AIR)
|
||||
{
|
||||
int maxuses = itemStack.getType().getMaxDurability();
|
||||
int durability = ((maxuses + 1) - itemStack.getDurability());
|
||||
if (maxuses != 0)
|
||||
{
|
||||
sender.sendMessage(_("durability", Integer.toString(durability)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -37,5 +37,6 @@ public class Commandjump extends EssentialsCommand
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
user.getTeleport().teleport(loc, charge, TeleportCause.COMMAND);
|
||||
throw new NoChargeException();
|
||||
}
|
||||
}
|
||||
|
@@ -24,7 +24,7 @@ public class Commandkick extends EssentialsCommand
|
||||
}
|
||||
|
||||
final User user = getPlayer(server, args, 0);
|
||||
if (user.isAuthorized("essentials.kick.exempt"))
|
||||
if (sender instanceof Player && user.isAuthorized("essentials.kick.exempt"))
|
||||
{
|
||||
throw new Exception(_("kickExempt"));
|
||||
}
|
||||
|
@@ -27,5 +27,6 @@ public class Commandkickall extends EssentialsCommand
|
||||
onlinePlayer.kickPlayer(args.length > 0 ? getFinalArg(args, 0) : _("kickDefault"));
|
||||
}
|
||||
}
|
||||
sender.sendMessage(_("kickedAll"));
|
||||
}
|
||||
}
|
||||
|
@@ -24,15 +24,14 @@ public class Commandkill extends EssentialsCommand
|
||||
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, 1000);
|
||||
final EntityDamageEvent ede = new EntityDamageEvent(matchPlayer, sender instanceof Player && ((Player)sender).getName().equals(matchPlayer.getName()) ? EntityDamageEvent.DamageCause.SUICIDE : EntityDamageEvent.DamageCause.CUSTOM, Short.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
if (ede.isCancelled() && !sender.hasPermission("essentials.kill.force"))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
matchPlayer.damage(1000);
|
||||
matchPlayer.setHealth(0);
|
||||
matchPlayer.damage(Short.MAX_VALUE);
|
||||
sender.sendMessage(_("kill", matchPlayer.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -16,6 +16,7 @@ import org.bukkit.entity.HumanEntity;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.entity.NPC;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Slime;
|
||||
import org.bukkit.entity.Snowman;
|
||||
@@ -61,7 +62,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("numberRequired"));
|
||||
throw new Exception(_("numberRequired"), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -121,11 +122,18 @@ public class Commandkillall extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if(entity instanceof Ocelot)
|
||||
{
|
||||
if (((Ocelot)entity).isTamed())
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if (animals)
|
||||
{
|
||||
if (entity instanceof Animals || entity instanceof NPC || entity instanceof Snowman || entity instanceof WaterMob)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -135,7 +143,7 @@ public class Commandkillall extends EssentialsCommand
|
||||
{
|
||||
if (entity instanceof Monster || entity instanceof ComplexLivingEntity || entity instanceof Flying || entity instanceof Slime)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
@@ -143,14 +151,14 @@ public class Commandkillall extends EssentialsCommand
|
||||
}
|
||||
else if (all)
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
}
|
||||
else if (entityClass != null && entityClass.isAssignableFrom(entity.getClass()))
|
||||
{
|
||||
EntityDeathEvent event = new EntityDeathEvent(entity, Collections.EMPTY_LIST);
|
||||
EntityDeathEvent event = new EntityDeathEvent((LivingEntity)entity, Collections.EMPTY_LIST);
|
||||
ess.getServer().getPluginManager().callEvent(event);
|
||||
entity.remove();
|
||||
numKills++;
|
||||
|
@@ -4,6 +4,7 @@ import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandkit extends EssentialsCommand
|
||||
@@ -19,38 +20,63 @@ public class Commandkit extends EssentialsCommand
|
||||
if (args.length < 1)
|
||||
{
|
||||
final String kitList = Kit.listKits(ess, user);
|
||||
if (kitList.length() > 0)
|
||||
{
|
||||
user.sendMessage(_("kits", kitList));
|
||||
}
|
||||
else
|
||||
{
|
||||
user.sendMessage(_("noKits"));
|
||||
}
|
||||
user.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else if (args.length > 1 && user.isAuthorized("essentials.kit.others"))
|
||||
{
|
||||
final User userTo = getPlayer(server, args, 1, true);
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
giveKit(userTo, user, kitName);
|
||||
}
|
||||
else
|
||||
{
|
||||
final String kitName = Util.sanitizeString(args[0].toLowerCase(Locale.ENGLISH));
|
||||
giveKit(user, user, kitName);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
final String kitList = Kit.listKits(ess, null);
|
||||
sender.sendMessage(kitList.length() > 0 ? _("kits", kitList) : _("noKits"));
|
||||
throw new NoChargeException();
|
||||
}
|
||||
else
|
||||
{
|
||||
final User userTo = getPlayer(server, args, 1, true);
|
||||
final String kitName = args[0].toLowerCase(Locale.ENGLISH);
|
||||
final Object kit = ess.getSettings().getKit(kitName);
|
||||
|
||||
if (!user.isAuthorized("essentials.kit." + kitName))
|
||||
{
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
}
|
||||
final Map<String, Object> els = (Map<String, Object>)kit;
|
||||
final List<String> items = Kit.getItems(user, els);
|
||||
|
||||
Kit.checkTime(user, kitName, els);
|
||||
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
charge.isAffordableFor(user);
|
||||
|
||||
Kit.expandItems(ess, user, items);
|
||||
|
||||
charge.charge(user);
|
||||
user.sendMessage(_("kitGive", kitName));
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
|
||||
final List<String> items = Kit.getItems(userTo, kit);
|
||||
Kit.expandItems(ess, userTo, items);
|
||||
|
||||
sender.sendMessage(_("kitGive", kitName));
|
||||
}
|
||||
}
|
||||
|
||||
private void giveKit(User userTo, User userFrom, String kitName) throws Exception
|
||||
{
|
||||
final Map<String, Object> kit = ess.getSettings().getKit(kitName);
|
||||
|
||||
if (!userFrom.isAuthorized("essentials.kit." + kitName))
|
||||
{
|
||||
throw new Exception(_("noKitPermission", "essentials.kit." + kitName));
|
||||
}
|
||||
|
||||
final List<String> items = Kit.getItems(userTo, kit);
|
||||
|
||||
Kit.checkTime(userFrom, kitName, kit);
|
||||
|
||||
final Trade charge = new Trade("kit-" + kitName, ess);
|
||||
charge.isAffordableFor(userFrom);
|
||||
|
||||
Kit.expandItems(ess, userTo, items);
|
||||
|
||||
charge.charge(userFrom);
|
||||
userTo.sendMessage(_("kitGive", kitName));
|
||||
}
|
||||
}
|
||||
|
@@ -0,0 +1,44 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import java.util.Random;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.entity.Ocelot;
|
||||
|
||||
|
||||
public class Commandkittycannon extends EssentialsCommand
|
||||
{
|
||||
private static Random random = new Random();
|
||||
|
||||
public Commandkittycannon()
|
||||
{
|
||||
super("kittycannon");
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final Mob cat = Mob.OCELOT;
|
||||
final Ocelot ocelot = (Ocelot)cat.spawn(user, server, user.getEyeLocation());
|
||||
if (ocelot == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
final int i = random.nextInt(Ocelot.Type.values().length);
|
||||
ocelot.setCatType(Ocelot.Type.values()[i]);
|
||||
ocelot.setTamed(true);
|
||||
ocelot.setVelocity(user.getEyeLocation().getDirection().multiply(2));
|
||||
ess.scheduleSyncDelayedTask(new Runnable()
|
||||
{
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
final Location loc = ocelot.getLocation();
|
||||
ocelot.remove();
|
||||
loc.getWorld().createExplosion(loc, 0F);
|
||||
}
|
||||
}, 20);
|
||||
}
|
||||
}
|
@@ -23,11 +23,11 @@ public class Commandlightning extends EssentialsCommand
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
user = ess.getUser(((Player)sender));
|
||||
}
|
||||
if (args.length < 1 & user != null)
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
return;
|
||||
if ((args.length < 1 || user != null && !user.isAuthorized("essentials.lightning.others")))
|
||||
{
|
||||
user.getWorld().strikeLightning(user.getTargetBlock(null, 600).getLocation());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (server.matchPlayer(args[0]).isEmpty())
|
||||
@@ -35,7 +35,7 @@ public class Commandlightning extends EssentialsCommand
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
|
||||
int power = 1;
|
||||
int power = 5;
|
||||
if (args.length > 1)
|
||||
{
|
||||
try
|
||||
@@ -50,18 +50,12 @@ public class Commandlightning extends EssentialsCommand
|
||||
for (Player matchPlayer : server.matchPlayer(args[0]))
|
||||
{
|
||||
sender.sendMessage(_("lightningUse", matchPlayer.getDisplayName()));
|
||||
if (power <= 0)
|
||||
{
|
||||
matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
|
||||
}
|
||||
else
|
||||
{
|
||||
LightningStrike strike = matchPlayer.getWorld().strikeLightning(matchPlayer.getLocation());
|
||||
matchPlayer.damage(power - 1, strike);
|
||||
}
|
||||
|
||||
final LightningStrike strike = matchPlayer.getWorld().strikeLightningEffect(matchPlayer.getLocation());
|
||||
|
||||
if (!ess.getUser(matchPlayer).isGodModeEnabled())
|
||||
{
|
||||
matchPlayer.setHealth(matchPlayer.getHealth() < 5 ? 0 : matchPlayer.getHealth() - 5);
|
||||
matchPlayer.damage(power, strike);
|
||||
}
|
||||
if (ess.getSettings().warnOnSmite())
|
||||
{
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
@@ -43,8 +44,10 @@ public class Commandlist extends EssentialsCommand
|
||||
if (showhidden && playerHidden > 0)
|
||||
{
|
||||
online = _("listAmountHidden", server.getOnlinePlayers().length - playerHidden, playerHidden, server.getMaxPlayers());
|
||||
} else {
|
||||
online = _("listAmount",server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
else
|
||||
{
|
||||
online = _("listAmount", server.getOnlinePlayers().length - playerHidden, server.getMaxPlayers());
|
||||
}
|
||||
sender.sendMessage(online);
|
||||
|
||||
@@ -72,7 +75,7 @@ public class Commandlist extends EssentialsCommand
|
||||
for (String group : groups)
|
||||
{
|
||||
final StringBuilder groupString = new StringBuilder();
|
||||
groupString.append(group).append(": ");
|
||||
groupString.append(_("listGroupTag", Util.replaceFormat(group)));
|
||||
final List<User> users = sort.get(group);
|
||||
Collections.sort(users);
|
||||
boolean first = true;
|
||||
@@ -94,6 +97,7 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
groupString.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
groupString.append(user.getDisplayName());
|
||||
groupString.append("§f");
|
||||
}
|
||||
@@ -135,6 +139,7 @@ public class Commandlist extends EssentialsCommand
|
||||
{
|
||||
onlineUsers.append(_("listHiddenTag"));
|
||||
}
|
||||
user.setDisplayNick();
|
||||
onlineUsers.append(user.getDisplayName());
|
||||
onlineUsers.append("§f");
|
||||
}
|
||||
|
@@ -4,7 +4,6 @@ import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.List;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -40,7 +39,7 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.send"))
|
||||
{
|
||||
throw new Exception(_("noPerm","essentials.mail.send"));
|
||||
throw new Exception(_("noPerm", "essentials.mail.send"));
|
||||
}
|
||||
|
||||
Player player = server.getPlayer(args[1]);
|
||||
@@ -57,9 +56,10 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("playerNeverOnServer", args[1]));
|
||||
}
|
||||
if (!u.isIgnoredPlayer(user.getName()))
|
||||
if (!u.isIgnoredPlayer(user))
|
||||
{
|
||||
u.addMail(user.getName() + ": " + Util.stripColor(getFinalArg(args, 2)));
|
||||
final String mail = Util.sanitizeString(Util.stripFormat(getFinalArg(args, 2)));
|
||||
u.addMail(user.getName() + ": " + mail);
|
||||
}
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
@@ -68,9 +68,9 @@ public class Commandmail extends EssentialsCommand
|
||||
{
|
||||
if (!user.isAuthorized("essentials.mail.sendall"))
|
||||
{
|
||||
throw new Exception(_("noPerm","essentials.mail.sendall"));
|
||||
throw new Exception(_("noPerm", "essentials.mail.sendall"));
|
||||
}
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripColor(getFinalArg(args, 1))));
|
||||
ess.scheduleAsyncDelayedTask(new SendAll(user.getName() + ": " + Util.stripFormat(getFinalArg(args, 1))));
|
||||
user.sendMessage(_("mailSent"));
|
||||
return;
|
||||
}
|
||||
|
@@ -27,15 +27,9 @@ public class Commandme extends EssentialsCommand
|
||||
}
|
||||
|
||||
String message = getFinalArg(args, 0);
|
||||
if (user.isAuthorized("essentials.chat.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else {
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
|
||||
message = Util.formatMessage(user, "essentials.chat", message);
|
||||
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user, _("action", user.getDisplayName(), message));
|
||||
}
|
||||
}
|
||||
|
@@ -21,11 +21,11 @@ public class Commandmsg extends EssentialsCommand
|
||||
@Override
|
||||
public void run(Server server, CommandSender sender, String commandLabel, String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2 || args[0].trim().isEmpty() || args[1].trim().isEmpty())
|
||||
if (args.length < 2 || args[0].trim().length() < 3 || args[1].trim().isEmpty())
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
|
||||
String message = getFinalArg(args, 1);
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
@@ -34,18 +34,11 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("voiceSilenced"));
|
||||
}
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
message = Util.formatMessage(user, "essentials.msg", message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
message = Util.replaceFormat(message);
|
||||
}
|
||||
|
||||
final String translatedMe = _("me");
|
||||
@@ -88,7 +81,7 @@ public class Commandmsg extends EssentialsCommand
|
||||
{
|
||||
sender.sendMessage(_("msgFormat", translatedMe, matchedPlayer.getDisplayName(), message));
|
||||
final User matchedUser = ess.getUser(matchedPlayer);
|
||||
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(((Player)sender).getName()) || matchedUser.isHidden()))
|
||||
if (sender instanceof Player && (matchedUser.isIgnoredPlayer(ess.getUser(sender)) || matchedUser.isHidden()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
@@ -28,13 +28,19 @@ public class Commandmute extends EssentialsCommand
|
||||
throw new Exception(_("muteExempt"));
|
||||
}
|
||||
long muteTimestamp = 0;
|
||||
|
||||
if (args.length > 1)
|
||||
{
|
||||
String time = getFinalArg(args, 1);
|
||||
final String time = getFinalArg(args, 1);
|
||||
muteTimestamp = Util.parseDateDiff(time, true);
|
||||
player.setMuted(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
player.setMuted(!player.getMuted());
|
||||
}
|
||||
player.setMuteTimeout(muteTimestamp);
|
||||
final boolean muted = player.toggleMuted();
|
||||
final boolean muted = player.getMuted();
|
||||
sender.sendMessage(
|
||||
muted
|
||||
? (muteTimestamp > 0
|
||||
|
@@ -64,11 +64,13 @@ public class Commandnick extends EssentialsCommand
|
||||
|
||||
private String formatNickname(final User user, final String nick)
|
||||
{
|
||||
if (user == null || user.isAuthorized("essentials.nick.color"))
|
||||
if (user == null)
|
||||
{
|
||||
return nick.replace('&', '\u00a7').replaceAll("\u00a7+k", "");
|
||||
} else {
|
||||
return Util.stripColor(nick);
|
||||
return Util.replaceFormat(nick);
|
||||
}
|
||||
else
|
||||
{
|
||||
return Util.formatString(user, "essentials.nick", nick);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -51,7 +51,7 @@ public class Commandnuke extends EssentialsCommand
|
||||
{
|
||||
for (int z = -10; z <= 10; z += 5)
|
||||
{
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, 127, loc.getBlockZ() + z);
|
||||
final Location tntloc = new Location(world, loc.getBlockX() + x, world.getHighestBlockYAt(loc) + 64, loc.getBlockZ() + z);
|
||||
final TNTPrimed tnt = world.spawn(tntloc, TNTPrimed.class);
|
||||
}
|
||||
}
|
||||
|
@@ -22,14 +22,14 @@ public class Commandpay extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
|
||||
if (args[0] == "")
|
||||
if (args[0].trim().length() < 3)
|
||||
{
|
||||
throw new NotEnoughArgumentsException("You need to specify a player to pay.");
|
||||
}
|
||||
|
||||
double amount = Double.parseDouble(args[1].replaceAll("[^0-9\\.]", ""));
|
||||
|
||||
Boolean foundUser = false;
|
||||
boolean foundUser = false;
|
||||
for (Player p : server.matchPlayer(args[0]))
|
||||
{
|
||||
User u = ess.getUser(p);
|
||||
@@ -42,9 +42,9 @@ public class Commandpay extends EssentialsCommand
|
||||
foundUser = true;
|
||||
}
|
||||
|
||||
if (foundUser == false)
|
||||
if (!foundUser)
|
||||
{
|
||||
throw new NoSuchFieldException(_("playerNotFound"));
|
||||
throw new NotEnoughArgumentsException(_("playerNotFound"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,8 +1,9 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
|
||||
public class Commandping extends EssentialsCommand
|
||||
@@ -13,8 +14,16 @@ public class Commandping extends EssentialsCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(Server server, User player, String commandLabel, String[] args) throws Exception
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
player.sendMessage(_("pong"));
|
||||
if (args.length < 1)
|
||||
{
|
||||
|
||||
sender.sendMessage(_("pong"));
|
||||
}
|
||||
else
|
||||
{
|
||||
sender.sendMessage(Util.replaceFormat(getFinalArg(args, 0)));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -51,26 +51,18 @@ public class Commandpowertool extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(_("powerToolList", Util.joinList(powertools), itemName));
|
||||
}
|
||||
return;
|
||||
throw new NoChargeException();
|
||||
}
|
||||
if (command.startsWith("r:"))
|
||||
{
|
||||
try
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
command = command.substring(2);
|
||||
if (!powertools.contains(command))
|
||||
{
|
||||
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
throw new Exception(_("powerToolNoSuchCommandAssigned", command, itemName));
|
||||
}
|
||||
|
||||
powertools.remove(command);
|
||||
user.sendMessage(_("powerToolRemove", command, itemName));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
user.sendMessage(e.getMessage());
|
||||
return;
|
||||
}
|
||||
powertools.remove(command);
|
||||
user.sendMessage(_("powerToolRemove", command, itemName));
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -85,7 +77,6 @@ public class Commandpowertool extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("powerToolAlreadySet", command, itemName));
|
||||
}
|
||||
|
||||
}
|
||||
else if (powertools != null && !powertools.isEmpty())
|
||||
{
|
||||
@@ -110,6 +101,11 @@ public class Commandpowertool extends EssentialsCommand
|
||||
user.sendMessage(_("powerToolRemoveAll", itemName));
|
||||
}
|
||||
|
||||
if (!user.arePowerToolsEnabled())
|
||||
{
|
||||
user.setPowerToolsEnabled(true);
|
||||
user.sendMessage(_("powerToolsEnabled"));
|
||||
}
|
||||
user.setPowertool(itemStack, powertools);
|
||||
}
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public class Commandptime extends EssentialsCommand
|
||||
Long ticks;
|
||||
// Parse the target time int ticks from args[0]
|
||||
String timeParam = args[0];
|
||||
Boolean relative = true;
|
||||
boolean relative = true;
|
||||
if (timeParam.startsWith("@"))
|
||||
{
|
||||
relative = false;
|
||||
@@ -79,7 +79,7 @@ public class Commandptime extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NotEnoughArgumentsException(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -32,20 +32,13 @@ public class Commandr extends EssentialsCommand
|
||||
if (sender instanceof Player)
|
||||
{
|
||||
User user = ess.getUser(sender);
|
||||
if (user.isAuthorized("essentials.msg.color"))
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.stripColor(message);
|
||||
}
|
||||
message = Util.formatMessage(user, "essentials.msg", message);
|
||||
replyTo = user;
|
||||
senderName = user.getDisplayName();
|
||||
}
|
||||
else
|
||||
{
|
||||
message = Util.replaceColor(message);
|
||||
message = Util.replaceFormat(message);
|
||||
replyTo = Console.getConsoleReplyTo();
|
||||
senderName = Console.NAME;
|
||||
}
|
||||
@@ -62,7 +55,7 @@ public class Commandr extends EssentialsCommand
|
||||
if (target instanceof Player)
|
||||
{
|
||||
User player = ess.getUser(target);
|
||||
if (player.isIgnoredPlayer(sender instanceof Player ? ((Player)sender).getName() : Console.NAME))
|
||||
if (sender instanceof Player && player.isIgnoredPlayer(ess.getUser(sender)))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@@ -31,9 +31,10 @@ public class Commandrealname extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
final String displayName = Util.stripColor(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
u.setDisplayNick();
|
||||
final String displayName = Util.stripFormat(u.getDisplayName()).toLowerCase(Locale.ENGLISH);
|
||||
if (!whois.equals(displayName)
|
||||
&& !displayName.equals(Util.stripColor(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !displayName.equals(Util.stripFormat(ess.getSettings().getNicknamePrefix()) + whois)
|
||||
&& !whois.equalsIgnoreCase(u.getName()))
|
||||
{
|
||||
continue;
|
||||
|
@@ -9,7 +9,7 @@ import org.bukkit.World;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
|
||||
//Todo: Fix this up
|
||||
public class Commandremove extends EssentialsCommand
|
||||
{
|
||||
public Commandremove()
|
||||
@@ -47,7 +47,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new Exception(_("numberRequired"));
|
||||
throw new Exception(_("numberRequired"), e);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,7 +57,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
||||
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||
}
|
||||
|
||||
removeEntities(user, world, toRemove, radius);
|
||||
@@ -84,7 +84,7 @@ public class Commandremove extends EssentialsCommand
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(); //TODO: translate and list types
|
||||
throw new NotEnoughArgumentsException(e); //TODO: translate and list types
|
||||
}
|
||||
removeEntities(sender, world, toRemove, 0);
|
||||
}
|
||||
@@ -92,8 +92,9 @@ public class Commandremove extends EssentialsCommand
|
||||
protected void removeEntities(final CommandSender sender, final World world, final ToRemove toRemove, int radius) throws Exception
|
||||
{
|
||||
int removed = 0;
|
||||
if (radius > 0) {
|
||||
radius*=radius;
|
||||
if (radius > 0)
|
||||
{
|
||||
radius *= radius;
|
||||
}
|
||||
for (Chunk chunk : world.getLoadedChunks())
|
||||
{
|
||||
@@ -130,7 +131,7 @@ public class Commandremove extends EssentialsCommand
|
||||
removed++;
|
||||
}
|
||||
}
|
||||
else if (toRemove == ToRemove.DROPS)
|
||||
else if (toRemove == ToRemove.MINECARTS)
|
||||
{
|
||||
if (e instanceof Minecart)
|
||||
{
|
||||
|
@@ -53,6 +53,8 @@ public class Commandrepair extends EssentialsCommand
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("all"))
|
||||
{
|
||||
final Trade charge = new Trade("repair-all", ess);
|
||||
charge.isAffordableFor(user);
|
||||
final List<String> repaired = new ArrayList<String>();
|
||||
repairItems(user.getInventory().getContents(), user, repaired);
|
||||
|
||||
@@ -69,6 +71,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
{
|
||||
user.sendMessage(_("repair", Util.joinList(repaired)));
|
||||
}
|
||||
charge.charge(user);
|
||||
|
||||
}
|
||||
else
|
||||
@@ -80,7 +83,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
private void repairItem(final ItemStack item) throws Exception
|
||||
{
|
||||
final Material material = Material.getMaterial(item.getTypeId());
|
||||
if (material.isBlock() || material.getMaxDurability() < 0)
|
||||
if (material.isBlock() || material.getMaxDurability() < 1)
|
||||
{
|
||||
throw new Exception(_("repairInvalidType"));
|
||||
}
|
||||
@@ -102,7 +105,7 @@ public class Commandrepair extends EssentialsCommand
|
||||
continue;
|
||||
}
|
||||
final String itemName = item.getType().toString().toLowerCase(Locale.ENGLISH);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), ess);
|
||||
final Trade charge = new Trade("repair-" + itemName.replace('_', '-'), "repair-item", ess);
|
||||
try
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
@@ -16,6 +17,17 @@ public class Commandseen extends EssentialsCommand
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
seen(server, sender, args, true, true);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
seen(server, user, args, user.isAuthorized("essentials.seen.banreason"), user.isAuthorized("essentials.seen.extra"));
|
||||
}
|
||||
|
||||
protected void seen(final Server server, final CommandSender sender, final String[] args, final boolean showBan, final boolean extra) throws Exception
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
@@ -23,20 +35,34 @@ public class Commandseen extends EssentialsCommand
|
||||
}
|
||||
try
|
||||
{
|
||||
User u = getPlayer(server, args, 0);
|
||||
sender.sendMessage(_("seenOnline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogin())));
|
||||
User player = getPlayer(server, args, 0);
|
||||
player.setDisplayNick();
|
||||
sender.sendMessage(_("seenOnline", player.getDisplayName(), Util.formatDateDiff(player.getLastLogin())));
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getAddress().getAddress().toString()));
|
||||
}
|
||||
}
|
||||
catch (NoSuchFieldException e)
|
||||
{
|
||||
User u = ess.getOfflineUser(args[0]);
|
||||
if (u == null)
|
||||
User player = ess.getOfflineUser(args[0]);
|
||||
if (player == null)
|
||||
{
|
||||
throw new Exception(_("playerNotFound"));
|
||||
}
|
||||
sender.sendMessage(_("seenOffline", u.getDisplayName(), Util.formatDateDiff(u.getLastLogout())));
|
||||
if (u.isBanned())
|
||||
player.setDisplayNick();
|
||||
sender.sendMessage(_("seenOffline", player.getName(), Util.formatDateDiff(player.getLastLogout())));
|
||||
if (player.isBanned())
|
||||
{
|
||||
sender.sendMessage(_("whoisBanned", _("true")));
|
||||
sender.sendMessage(_("whoisBanned", showBan ? player.getBanReason() : _("true")));
|
||||
}
|
||||
if (extra)
|
||||
{
|
||||
sender.sendMessage(_("whoisIPAddress", player.getLastLoginAddress()));
|
||||
final Location loc = player.getLastLocation();
|
||||
if (loc != null) {
|
||||
sender.sendMessage(_("whoisLocation", loc.getWorld().getName(), loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -160,8 +160,8 @@ public class Commandsell extends EssentialsCommand
|
||||
user.updateInventory();
|
||||
Trade.log("Command", "Sell", "Item", user.getName(), new Trade(ris, ess), user.getName(), new Trade(worth * amount, ess), user.getLocation(), ess);
|
||||
user.giveMoney(worth * amount);
|
||||
user.sendMessage(_("itemSold", Util.formatCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.formatCurrency(worth * amount, ess), amount, Util.formatCurrency(worth, ess)));
|
||||
user.sendMessage(_("itemSold", Util.displayCurrency(worth * amount, ess), amount, is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth, ess)));
|
||||
logger.log(Level.INFO, _("itemSoldConsole", user.getDisplayName(), is.getType().toString().toLowerCase(Locale.ENGLISH), Util.displayCurrency(worth * amount, ess), amount, Util.displayCurrency(worth, ess)));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -29,7 +29,8 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
if (user.isAuthorized("essentials.sethome.multiple"))
|
||||
{
|
||||
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH))) {
|
||||
if ("bed".equals(args[0].toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
if ((user.isAuthorized("essentials.sethome.multiple.unlimited")) || (user.getHomes().size() < ess.getSettings().getHomeLimit(user))
|
||||
@@ -66,7 +67,8 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
name = "home";
|
||||
}
|
||||
if ("bed".equals(name.toLowerCase(Locale.ENGLISH))) {
|
||||
if ("bed".equals(name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
usersHome.setHome(name, user.getLocation());
|
||||
@@ -77,7 +79,7 @@ public class Commandsethome extends EssentialsCommand
|
||||
{
|
||||
user.setHome();
|
||||
}
|
||||
user.sendMessage(_("homeSet"));
|
||||
user.sendMessage(_("homeSet", user.getLocation().getWorld().getName(), user.getLocation().getBlockX(), user.getLocation().getBlockY(), user.getLocation().getBlockZ()));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,7 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
|
||||
|
||||
@@ -20,7 +21,7 @@ public class Commandsetjail extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
ess.getJails().setJail(args[0], user.getLocation());
|
||||
user.sendMessage(_("jailSet", args[0]));
|
||||
user.sendMessage(_("jailSet", Util.sanitizeString(args[0])));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -2,6 +2,8 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import com.earth2me.essentials.Warps;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
|
||||
@@ -26,7 +28,25 @@ public class Commandsetwarp extends EssentialsCommand
|
||||
}
|
||||
|
||||
final Location loc = user.getLocation();
|
||||
ess.getWarps().setWarp(args[0], loc);
|
||||
final Warps warps = ess.getWarps();
|
||||
Location warpLoc = null;
|
||||
|
||||
try
|
||||
{
|
||||
warpLoc = warps.getWarp(args[0]);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
}
|
||||
|
||||
if (warpLoc == null || user.isAuthorized("essentials.warp.overwrite." + Util.sanitizeFileName(args[0])))
|
||||
{
|
||||
warps.setWarp(args[0], loc);
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception(_("warpOverwrite"));
|
||||
}
|
||||
user.sendMessage(_("warpSet", args[0]));
|
||||
}
|
||||
}
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
|
||||
@@ -15,6 +16,32 @@ public class Commandsetworth extends EssentialsCommand
|
||||
|
||||
@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();
|
||||
}
|
||||
|
||||
ItemStack stack;
|
||||
String price;
|
||||
|
||||
if (args.length == 1)
|
||||
{
|
||||
stack = user.getInventory().getItemInHand();
|
||||
price = args[0];
|
||||
}
|
||||
else
|
||||
{
|
||||
stack = ess.getItemDb().get(args[0]);
|
||||
price = args[1];
|
||||
}
|
||||
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(price));
|
||||
user.sendMessage(_("worthSet"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
if (args.length < 2)
|
||||
{
|
||||
@@ -23,6 +50,6 @@ public class Commandsetworth extends EssentialsCommand
|
||||
|
||||
ItemStack stack = ess.getItemDb().get(args[0]);
|
||||
ess.getWorth().setPrice(stack, Double.parseDouble(args[1]));
|
||||
user.sendMessage(_("worthSet"));
|
||||
sender.sendMessage(_("worthSet"));
|
||||
}
|
||||
}
|
||||
|
@@ -1,14 +1,13 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.*;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.CreatureSpawner;
|
||||
import org.bukkit.entity.EntityType;
|
||||
|
||||
|
||||
public class Commandspawner extends EssentialsCommand
|
||||
@@ -32,31 +31,34 @@ public class Commandspawner extends EssentialsCommand
|
||||
throw new Exception(_("mobSpawnTarget"));
|
||||
}
|
||||
|
||||
String name = args[0];
|
||||
|
||||
Mob mob = null;
|
||||
mob = Mob.fromName(name);
|
||||
if (mob == null)
|
||||
{
|
||||
throw new Exception(_("invalidMob"));
|
||||
}
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("disabledToSpawnMob"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("noPermToSpawnMob"));
|
||||
}
|
||||
final Trade charge = new Trade("spawner-" + mob.name.toLowerCase(Locale.ENGLISH), ess);
|
||||
charge.isAffordableFor(user);
|
||||
try
|
||||
{
|
||||
String name = args[0];
|
||||
|
||||
Mob mob = null;
|
||||
mob = Mob.fromName(name);
|
||||
if (mob == null)
|
||||
{
|
||||
user.sendMessage(_("invalidMob"));
|
||||
return;
|
||||
}
|
||||
if (ess.getSettings().getProtectPreventSpawn(mob.getType().toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
if (!user.isAuthorized("essentials.spawner." + mob.name.toLowerCase()))
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
}
|
||||
((CreatureSpawner)target.getBlock().getState()).setCreatureType(mob.getType());
|
||||
user.sendMessage(_("setSpawner", mob.name));
|
||||
((CreatureSpawner)target.getBlock().getState()).setSpawnedType(mob.getType());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
throw new Exception(_("mobSpawnError"), ex);
|
||||
}
|
||||
charge.charge(user);
|
||||
user.sendMessage(_("setSpawner", mob.name));
|
||||
|
||||
}
|
||||
}
|
||||
|
@@ -5,13 +5,14 @@ import com.earth2me.essentials.Mob;
|
||||
import com.earth2me.essentials.Mob.MobException;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.Locale;
|
||||
import java.util.Random;
|
||||
import java.util.*;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.entity.*;
|
||||
import org.bukkit.entity.Villager.Profession;
|
||||
import org.bukkit.material.Colorable;
|
||||
|
||||
|
||||
public class Commandspawnmob extends EssentialsCommand
|
||||
@@ -26,7 +27,20 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
{
|
||||
if (args.length < 1)
|
||||
{
|
||||
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(Mob.getMobList())));
|
||||
final Set<String> mobList = Mob.getMobList();
|
||||
final Set<String> availableList = new HashSet<String>();
|
||||
for (String mob : mobList)
|
||||
{
|
||||
if (user.isAuthorized("essentials.spawnmob." + mob.toLowerCase()))
|
||||
{
|
||||
availableList.add(mob);
|
||||
}
|
||||
}
|
||||
if (availableList.isEmpty())
|
||||
{
|
||||
availableList.add(_("none"));
|
||||
}
|
||||
throw new NotEnoughArgumentsException(_("mobsAvailable", Util.joinList(availableList)));
|
||||
}
|
||||
|
||||
|
||||
@@ -79,7 +93,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
User otherUser = null;
|
||||
if (args.length >= 3)
|
||||
{
|
||||
otherUser = getPlayer(ess.getServer(), args, 2);
|
||||
otherUser = getPlayer(ess.getServer(), args, 2);
|
||||
}
|
||||
final Location loc = (otherUser == null) ? block.getLocation() : otherUser.getLocation();
|
||||
final Location sloc = Util.getSafeDestination(loc);
|
||||
@@ -89,7 +103,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
|
||||
if (mountType != null)
|
||||
@@ -115,7 +129,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -150,7 +164,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
catch (MobException e)
|
||||
{
|
||||
throw new Exception(_("unableToSpawnMob"));
|
||||
throw new Exception(_("unableToSpawnMob"), e);
|
||||
}
|
||||
spawnedMob.setPassenger(spawnedMount);
|
||||
}
|
||||
@@ -163,7 +177,7 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
changeMobData(mobMount.getType(), spawnedMount, mountData, user);
|
||||
}
|
||||
}
|
||||
user.sendMessage(args[1] + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
user.sendMessage(mobCount + " " + mob.name.toLowerCase(Locale.ENGLISH) + mob.suffix + " " + _("spawned"));
|
||||
}
|
||||
catch (MobException e1)
|
||||
{
|
||||
@@ -184,9 +198,11 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
}
|
||||
}
|
||||
|
||||
private void changeMobData(final CreatureType type, final Entity spawned, final String data, final User user) throws Exception
|
||||
private void changeMobData(final EntityType type, final Entity spawned, String data, final User user) throws Exception
|
||||
{
|
||||
if (type == CreatureType.SLIME || type == CreatureType.MAGMA_CUBE)
|
||||
data = data.toLowerCase(Locale.ENGLISH);
|
||||
|
||||
if (spawned instanceof Slime)
|
||||
{
|
||||
try
|
||||
{
|
||||
@@ -197,35 +213,24 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
throw new Exception(_("slimeMalformedSize"), e);
|
||||
}
|
||||
}
|
||||
if ((type == CreatureType.SHEEP
|
||||
|| type == CreatureType.COW
|
||||
|| type == CreatureType.MUSHROOM_COW
|
||||
|| type == CreatureType.CHICKEN
|
||||
|| type == CreatureType.PIG
|
||||
|| type == CreatureType.WOLF)
|
||||
&& data.equalsIgnoreCase("baby"))
|
||||
if (spawned instanceof Ageable && data.contains("baby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
((Ageable)spawned).setBaby();
|
||||
return;
|
||||
}
|
||||
if (type == CreatureType.SHEEP)
|
||||
if (spawned instanceof Colorable)
|
||||
{
|
||||
if (data.toLowerCase(Locale.ENGLISH).contains("baby"))
|
||||
{
|
||||
((Sheep)spawned).setAge(-24000);
|
||||
}
|
||||
final String color = data.toUpperCase(Locale.ENGLISH).replace("BABY", "");
|
||||
try
|
||||
{
|
||||
|
||||
if (color.equalsIgnoreCase("random"))
|
||||
if (color.equals("RANDOM"))
|
||||
{
|
||||
Random rand = new Random();
|
||||
((Sheep)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
final Random rand = new Random();
|
||||
((Colorable)spawned).setColor(DyeColor.values()[rand.nextInt(DyeColor.values().length)]);
|
||||
}
|
||||
else
|
||||
{
|
||||
((Sheep)spawned).setColor(DyeColor.valueOf(color));
|
||||
((Colorable)spawned).setColor(DyeColor.valueOf(color));
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
@@ -233,30 +238,45 @@ public class Commandspawnmob extends EssentialsCommand
|
||||
throw new Exception(_("sheepMalformedColor"), e);
|
||||
}
|
||||
}
|
||||
if (type == CreatureType.WOLF
|
||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("tamed"))
|
||||
if (spawned instanceof Tameable && data.contains("tamed"))
|
||||
{
|
||||
final Wolf wolf = ((Wolf)spawned);
|
||||
wolf.setTamed(true);
|
||||
wolf.setOwner(user);
|
||||
wolf.setSitting(true);
|
||||
if (data.equalsIgnoreCase("tamedbaby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
}
|
||||
final Tameable tameable = ((Tameable)spawned);
|
||||
tameable.setTamed(true);
|
||||
tameable.setOwner(user.getBase());
|
||||
}
|
||||
if (type == CreatureType.WOLF
|
||||
&& data.toLowerCase(Locale.ENGLISH).startsWith("angry"))
|
||||
if (type == EntityType.WOLF
|
||||
&& data.contains("angry"))
|
||||
{
|
||||
((Wolf)spawned).setAngry(true);
|
||||
if (data.equalsIgnoreCase("angrybaby"))
|
||||
{
|
||||
((Animals)spawned).setAge(-24000);
|
||||
}
|
||||
}
|
||||
if (type == CreatureType.CREEPER && data.equalsIgnoreCase("powered"))
|
||||
if (type == EntityType.CREEPER && data.contains("powered"))
|
||||
{
|
||||
((Creeper)spawned).setPowered(true);
|
||||
}
|
||||
if (type == EntityType.OCELOT)
|
||||
{
|
||||
if (data.contains("siamese"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.SIAMESE_CAT);
|
||||
}
|
||||
else if (data.contains("red"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.RED_CAT);
|
||||
}
|
||||
else if (data.contains("black"))
|
||||
{
|
||||
((Ocelot)spawned).setCatType(Ocelot.Type.BLACK_CAT);
|
||||
}
|
||||
}
|
||||
if (type == EntityType.VILLAGER)
|
||||
{
|
||||
for (Profession prof : Villager.Profession.values())
|
||||
{
|
||||
if (data.contains(prof.toString().toLowerCase(Locale.ENGLISH)))
|
||||
{
|
||||
((Villager)spawned).setProfession(prof);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@@ -1,6 +1,8 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.PluginCommand;
|
||||
@@ -29,8 +31,12 @@ public class Commandsudo extends EssentialsCommand
|
||||
System.arraycopy(args, 2, arguments, 0, args.length - 2);
|
||||
}
|
||||
|
||||
//TODO: Translate this.
|
||||
sender.sendMessage("Running the command as " + user.getDisplayName());
|
||||
if (user.isAuthorized("essentials.sudo.exempt"))
|
||||
{
|
||||
throw new Exception(_("sudoExempt"));
|
||||
}
|
||||
|
||||
sender.sendMessage(_("sudoRun", user.getDisplayName(), command, getFinalArg(arguments, 0)));
|
||||
|
||||
final PluginCommand execCommand = ess.getServer().getPluginCommand(command);
|
||||
if (execCommand != null)
|
||||
|
@@ -16,11 +16,11 @@ public class Commandsuicide extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final User user, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
EntityDamageEvent ede = new EntityDamageEvent(user, EntityDamageEvent.DamageCause.SUICIDE, 1000);
|
||||
EntityDamageEvent ede = new EntityDamageEvent(user.getBase(), EntityDamageEvent.DamageCause.SUICIDE, Short.MAX_VALUE);
|
||||
server.getPluginManager().callEvent(ede);
|
||||
user.damage(1000);
|
||||
user.setHealth(0);
|
||||
user.damage(Short.MAX_VALUE);
|
||||
user.sendMessage(_("suicideMessage"));
|
||||
user.setDisplayNick();
|
||||
ess.broadcastMessage(user,_("suicideSuccess", user.getDisplayName()));
|
||||
}
|
||||
}
|
||||
|
@@ -2,7 +2,6 @@ package com.earth2me.essentials.commands;
|
||||
|
||||
import com.earth2me.essentials.Console;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -25,7 +24,7 @@ public class Commandtempban extends EssentialsCommand
|
||||
throw new NotEnoughArgumentsException();
|
||||
}
|
||||
final User user = getPlayer(server, args, 0, true);
|
||||
if (user.getBase() instanceof OfflinePlayer)
|
||||
if (!user.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.tempban.offline"))
|
||||
@@ -45,12 +44,12 @@ public class Commandtempban extends EssentialsCommand
|
||||
final String time = getFinalArg(args, 1);
|
||||
final long banTimestamp = Util.parseDateDiff(time, true);
|
||||
|
||||
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp));
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
final String banReason = _("tempBanned", Util.formatDateDiff(banTimestamp), senderName);
|
||||
user.setBanReason(banReason);
|
||||
user.setBanTimeout(banTimestamp);
|
||||
user.setBanned(true);
|
||||
user.kickPlayer(banReason);
|
||||
final String senderName = sender instanceof Player ? ((Player)sender).getDisplayName() : Console.NAME;
|
||||
|
||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||
{
|
||||
|
@@ -3,6 +3,7 @@ package com.earth2me.essentials.commands;
|
||||
import com.earth2me.essentials.DescParseTickFormat;
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import java.util.*;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
@@ -19,16 +20,23 @@ public class Commandtime extends EssentialsCommand
|
||||
@Override
|
||||
public void run(final Server server, final CommandSender sender, final String commandLabel, final String[] args) throws Exception
|
||||
{
|
||||
final List<String> argList = new ArrayList<String>(Arrays.asList(args));
|
||||
if ((argList.remove("set") || argList.remove("add")) && Util.isInt(argList.get(0)))
|
||||
{
|
||||
ess.getLogger().info("debug edited 0" + argList.get(0).toString());
|
||||
}
|
||||
final String[] validArgs = argList.toArray(new String[0]);
|
||||
|
||||
// Which World(s) are we interested in?
|
||||
String worldSelector = null;
|
||||
if (args.length == 2)
|
||||
if (validArgs.length == 2)
|
||||
{
|
||||
worldSelector = args[1];
|
||||
worldSelector = validArgs[1];
|
||||
}
|
||||
final Set<World> worlds = getWorlds(server, sender, worldSelector);
|
||||
|
||||
// If no arguments we are reading the time
|
||||
if (args.length == 0)
|
||||
if (validArgs.length == 0)
|
||||
{
|
||||
getWorldsTime(sender, worlds);
|
||||
return;
|
||||
@@ -45,11 +53,11 @@ public class Commandtime extends EssentialsCommand
|
||||
long ticks;
|
||||
try
|
||||
{
|
||||
ticks = DescParseTickFormat.parse(args[0]);
|
||||
ticks = DescParseTickFormat.parse(validArgs[0]);
|
||||
}
|
||||
catch (NumberFormatException e)
|
||||
{
|
||||
throw new NotEnoughArgumentsException();
|
||||
throw new NotEnoughArgumentsException(e);
|
||||
}
|
||||
|
||||
setWorldsTime(sender, worlds, ticks);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.User;
|
||||
import com.earth2me.essentials.Util;
|
||||
import org.bukkit.Server;
|
||||
@@ -28,7 +27,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
|
||||
if (args.length >= 2 && !player.isJailed())
|
||||
{
|
||||
if (player.getBase() instanceof OfflinePlayer)
|
||||
if (!player.isOnline())
|
||||
{
|
||||
if (sender instanceof Player
|
||||
&& !ess.getUser(sender).isAuthorized("essentials.togglejail.offline"))
|
||||
@@ -45,7 +44,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
return;
|
||||
}
|
||||
}
|
||||
if (!(player.getBase() instanceof OfflinePlayer))
|
||||
if (player.isOnline())
|
||||
{
|
||||
ess.getJails().sendToJail(player, args[1]);
|
||||
}
|
||||
@@ -96,7 +95,7 @@ public class Commandtogglejail extends EssentialsCommand
|
||||
player.setJailTimeout(0);
|
||||
player.sendMessage(_("jailReleasedPlayerNotify"));
|
||||
player.setJail(null);
|
||||
if (!(player.getBase() instanceof OfflinePlayer))
|
||||
if (player.isOnline())
|
||||
{
|
||||
player.getTeleport().back();
|
||||
}
|
||||
|
@@ -30,6 +30,11 @@ public class Commandtp extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("teleportDisabled", player.getDisplayName()));
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
|
||||
}
|
||||
user.sendMessage(_("teleporting"));
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
charge.isAffordableFor(user);
|
||||
@@ -37,14 +42,26 @@ public class Commandtp extends EssentialsCommand
|
||||
throw new NoChargeException();
|
||||
|
||||
default:
|
||||
if (!user.isAuthorized("essentials.tpohere"))
|
||||
if (!user.isAuthorized("essentials.tp.others"))
|
||||
{
|
||||
//TODO: Translate this
|
||||
throw new Exception("You need access to /tpohere to teleport other players.");
|
||||
throw new Exception(_("noPerm", "essentials.tp.others"));
|
||||
}
|
||||
user.sendMessage(_("teleporting"));
|
||||
final User target = getPlayer(server, args, 0);
|
||||
final User toPlayer = getPlayer(server, args, 1);
|
||||
if (!target.isTeleportEnabled())
|
||||
{
|
||||
throw new Exception(_("teleportDisabled", target.getDisplayName()));
|
||||
}
|
||||
if (!toPlayer.isTeleportEnabled())
|
||||
{
|
||||
throw new Exception(_("teleportDisabled", toPlayer.getDisplayName()));
|
||||
}
|
||||
if (target.getWorld() != toPlayer.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + toPlayer.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + toPlayer.getWorld().getName()));
|
||||
}
|
||||
target.getTeleport().now(toPlayer, false, TeleportCause.COMMAND);
|
||||
target.sendMessage(_("teleportAtoB", user.getDisplayName(), toPlayer.getDisplayName()));
|
||||
break;
|
||||
|
@@ -25,7 +25,12 @@ public class Commandtpa extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("teleportDisabled", player.getDisplayName()));
|
||||
}
|
||||
if (!player.isIgnoredPlayer(user.getName()))
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + player.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + player.getWorld().getName()));
|
||||
}
|
||||
if (!player.isIgnoredPlayer(user))
|
||||
{
|
||||
player.requestTeleport(user, false);
|
||||
player.sendMessage(_("teleportRequest", user.getDisplayName()));
|
||||
|
@@ -45,6 +45,11 @@ public class Commandtpaall extends EssentialsCommand
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
player.requestTeleport(user, true);
|
||||
|
@@ -1,7 +1,6 @@
|
||||
package com.earth2me.essentials.commands;
|
||||
|
||||
import static com.earth2me.essentials.I18n._;
|
||||
import com.earth2me.essentials.OfflinePlayer;
|
||||
import com.earth2me.essentials.Trade;
|
||||
import com.earth2me.essentials.User;
|
||||
import org.bukkit.Server;
|
||||
@@ -20,13 +19,26 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
{
|
||||
|
||||
final User target = user.getTeleportRequest();
|
||||
if (target == null
|
||||
|| target.getBase() instanceof OfflinePlayer
|
||||
|| (user.isTeleportRequestHere() && !target.isAuthorized("essentials.tpahere")))
|
||||
|
||||
if (target == null || !target.isOnline())
|
||||
{
|
||||
throw new Exception(_("noPendingRequest"));
|
||||
}
|
||||
|
||||
|
||||
if (user.isTpRequestHere() && ((!target.isAuthorized("essentials.tpahere") && !target.isAuthorized("essentials.tpaall"))
|
||||
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))))
|
||||
{
|
||||
throw new Exception(_("noPendingRequest"));
|
||||
}
|
||||
|
||||
if (!user.isTpRequestHere() && (!target.isAuthorized("essentials.tpa")
|
||||
|| (user.getWorld() != target.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + target.getWorld().getName()))))
|
||||
{
|
||||
throw new Exception(_("noPendingRequest"));
|
||||
}
|
||||
|
||||
if (args.length > 0 && !target.getName().contains(args[0]))
|
||||
{
|
||||
throw new Exception(_("noPendingRequest"));
|
||||
@@ -40,7 +52,7 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
}
|
||||
|
||||
final Trade charge = new Trade(this.getName(), ess);
|
||||
if (user.isTeleportRequestHere())
|
||||
if (user.isTpRequestHere())
|
||||
{
|
||||
charge.isAffordableFor(user);
|
||||
}
|
||||
@@ -51,7 +63,7 @@ public class Commandtpaccept extends EssentialsCommand
|
||||
user.sendMessage(_("requestAccepted"));
|
||||
target.sendMessage(_("requestAcceptedFrom", user.getDisplayName()));
|
||||
|
||||
if (user.isTeleportRequestHere())
|
||||
if (user.isTpRequestHere())
|
||||
{
|
||||
user.getTeleport().teleport(target, charge, TeleportCause.COMMAND);
|
||||
}
|
||||
|
@@ -25,6 +25,11 @@ public class Commandtpahere extends EssentialsCommand
|
||||
{
|
||||
throw new Exception(_("teleportDisabled", player.getDisplayName()));
|
||||
}
|
||||
if (user.getWorld() != player.getWorld() && ess.getSettings().isWorldTeleportPermissions()
|
||||
&& !user.isAuthorized("essentials.world." + user.getWorld().getName()))
|
||||
{
|
||||
throw new Exception(_("noPerm", "essentials.world." + user.getWorld().getName()));
|
||||
}
|
||||
player.requestTeleport(user, true);
|
||||
player.sendMessage(_("teleportHereRequest", user.getDisplayName()));
|
||||
player.sendMessage(_("typeTpaccept"));
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user