mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 20:46:41 +00:00
Compare commits
539 Commits
v5.0-mc1.1
...
TFM-1.15
Author | SHA1 | Date | |
---|---|---|---|
4ddcc3b8d7 | |||
43ee17807a | |||
d1cc694742 | |||
abbadb55ee | |||
a2a4a8a0b8 | |||
c49abd1f4a | |||
dd5e256c84 | |||
321d9f97e0 | |||
721c2dc18e | |||
a523cc313c | |||
bc8ff3cd7f | |||
e23bfa7f87 | |||
cbc1d997ec | |||
af935cb824 | |||
9485b62716 | |||
372ba97bef | |||
925fe4a4b2 | |||
4a5032bb4c | |||
48ee7b0e6d | |||
c94ce6b276 | |||
ecc907b535 | |||
ce804ac23b | |||
1744eaac69 | |||
9874fe0ed5 | |||
2d7353c076 | |||
b2abc1db45 | |||
682145eb13 | |||
046bebe54c | |||
ea6d541270 | |||
7fef35a7e2 | |||
1772164fa2 | |||
c5d778896e | |||
ee8eb30a92 | |||
b7c1a46cbd | |||
a37d8ecb31 | |||
47a62753d1 | |||
608791d918 | |||
5b0ba0917c | |||
8c0391f050 | |||
56d5a669cf | |||
7940313dd1 | |||
1ee1cbca2b | |||
939e0730fd | |||
93a9885477 | |||
5641d0d504 | |||
6d0400cdf3 | |||
89b91598fb | |||
98ed23969a | |||
f989b34ada | |||
cf21b8d07e | |||
81621d260d | |||
5bb489e8ba | |||
24d121643e | |||
035acbfa19 | |||
fbcb6da30d | |||
3b715fc091 | |||
648d0e9b2e | |||
1181de8ed4 | |||
a7de5edfcb | |||
fbfc605f1e | |||
156c85ce69 | |||
3ea73f78e9 | |||
52269c2122 | |||
446f658c13 | |||
ee4bbea340 | |||
a2404d1bc6 | |||
81c5775150 | |||
35ef866690 | |||
eb3a266bf6 | |||
c53de9d789 | |||
0efbf77cf7 | |||
33cc304330 | |||
7d19de5dfa | |||
fa51976ea5 | |||
6a5dc4b98e | |||
73a799d709 | |||
96e1d0afdc | |||
9fb89f2c69 | |||
855c01a46b | |||
1bc06f2c1d | |||
1dc2bd8518 | |||
ef9f55f7ad | |||
9167c47c2f | |||
82cd7f2d05 | |||
d40c85f39c | |||
86a4577023 | |||
7cffdac400 | |||
259f3068e2 | |||
ce643661fc | |||
4d1cdfedc7 | |||
6b3d170c6d | |||
d767e7ebd6 | |||
572ebdd0f5 | |||
d0b64c6438 | |||
9a6cd007ed | |||
97caed9313 | |||
f0aec56186 | |||
a0571b0175 | |||
ee44b5fb7f | |||
69fb21f57c | |||
d7e3f05010 | |||
c096c4a781 | |||
135d1af27d | |||
f758be9e70 | |||
bd84257c16 | |||
d78d28cc7a | |||
5206ab5b27 | |||
2c99a8e4f4 | |||
9de3388525 | |||
5cfb525a1f | |||
93e6361148 | |||
7572f77ab6 | |||
4344ae58bf | |||
9a50903c14 | |||
f7bca3f868 | |||
bbcf4a984b | |||
acd7de715e | |||
43b4fc89ef | |||
a79b26f4be | |||
90febba91a | |||
bb9e46b1fd | |||
79d54d09f9 | |||
cc6a9a843c | |||
421315a31c | |||
0ab0ca2c66 | |||
f4a77859bf | |||
ac1065afff | |||
0abfb70a42 | |||
d99e6629c4 | |||
4ca89c6bf2 | |||
f976c8ba19 | |||
aac208710d | |||
9d20b8cf1d | |||
7936936942 | |||
ba9d3a085f | |||
60c46b7c8e | |||
9f22115b30 | |||
07e0b4e2c8 | |||
ea93b069df | |||
e0bbbbdda8 | |||
fd809a0d33 | |||
b3f785beb9 | |||
a926f72b67 | |||
5a6dacfc37 | |||
7726cae9a3 | |||
e884d9b47e | |||
75168dbb38 | |||
337a612437 | |||
b2305a918b | |||
8d0540dc66 | |||
5c1c06afa0 | |||
a40785f31e | |||
35ff7494a4 | |||
4aaf9bc9ff | |||
23b29bdf38 | |||
4a69f529c2 | |||
fe2bdef026 | |||
233632eaf1 | |||
db42985743 | |||
1d932e2c7b | |||
b525e53348 | |||
d582398f93 | |||
f05d6a71ae | |||
aad33958f0 | |||
ac850bc41d | |||
d6dbdf15bc | |||
2a168ece3d | |||
4f339b29b8 | |||
9f4b48af5a | |||
14c9db3433 | |||
44f101841b | |||
81002cbe97 | |||
eccf940b81 | |||
1babf57570 | |||
bd6c7d55a7 | |||
d21c5f0e9d | |||
f2f3720de2 | |||
d6d42cc905 | |||
03e1a7c9c4 | |||
73470a90e5 | |||
7d0ea0837e | |||
1c3970b984 | |||
cecbf09584 | |||
a166154e48 | |||
1951d9adea | |||
e7ebc51847 | |||
841e354d35 | |||
fb336f27bb | |||
a4ee58cac7 | |||
5085b90727 | |||
503a8d5b4f | |||
c01c436d40 | |||
6187c9c068 | |||
dffd9f8c3c | |||
fb0bfb847f | |||
1eaa55bb6d | |||
ca790b6d2c | |||
668ccda5cd | |||
894feaf1dc | |||
d635e2c3d1 | |||
2254f1225d | |||
0b7813d87f | |||
9a5f2e2231 | |||
561854f2f0 | |||
ca868a290d | |||
5ab0feebfd | |||
797d8516d1 | |||
5a59877f24 | |||
ae1701613b | |||
9cb4bd7822 | |||
c3d35487e7 | |||
a71bfde4ee | |||
95ef7d6cfe | |||
6706437ab7 | |||
b4dd877f2b | |||
6dcccac2b0 | |||
e861f272fe | |||
27aaa5406d | |||
de1fbde20a | |||
a97a3f3177 | |||
521825024e | |||
bcb466a95c | |||
635316dcd2 | |||
7a4b044d45 | |||
c7e0a7a288 | |||
4a91c8129b | |||
591b8644cb | |||
6b8cab5005 | |||
7fbc255ee4 | |||
59ee519955 | |||
92ad950155 | |||
481983aeaf | |||
ea6d0aba60 | |||
8f097c7454 | |||
f3cc70330e | |||
59cbc05a4a | |||
4dc63fb756 | |||
843a6ce88f | |||
e3adc7ab83 | |||
f263c0f5f6 | |||
00483be7d4 | |||
a77e53932b | |||
b4bb2cf4d8 | |||
a56a9396d4 | |||
56175dacb4 | |||
5b2334c60f | |||
d7931793f1 | |||
3d7d363e30 | |||
7c6c407f78 | |||
746ccdfd44 | |||
93d4c9654e | |||
3754222582 | |||
f649e3d6c3 | |||
8c7823d7bf | |||
2408054a49 | |||
72db71b3cf | |||
7a43f991e3 | |||
322ed77232 | |||
d58ee9f590 | |||
6b176820c5 | |||
516c21533c | |||
2bfc412e78 | |||
d17457dbfa | |||
3895c2235e | |||
34c8544690 | |||
87cd901f72 | |||
968a36b216 | |||
47565ece6b | |||
94d91bbb31 | |||
1588ab8baa | |||
aac921b283 | |||
84c0e90164 | |||
75fb1b2172 | |||
69efba711a | |||
73cea831af | |||
e285a72719 | |||
f3baf37279 | |||
533e7892cc | |||
0657d01059 | |||
da06ff50cb | |||
93e7957e25 | |||
6ec420f7fe | |||
2716e2500b | |||
5da2237cb3 | |||
1f9078b702 | |||
60c627c591 | |||
8bd8efc665 | |||
b97fd70b83 | |||
12f023196a | |||
b702c1cec5 | |||
1e60b06dba | |||
941bbc8da3 | |||
9c2f181ab9 | |||
ed9200689c | |||
f8b5078f84 | |||
c0e16ee9c7 | |||
45a10a871f | |||
519b456807 | |||
655766a0c4 | |||
bf6e35238e | |||
575818ba69 | |||
7baf5f322e | |||
8268cea3db | |||
815211e454 | |||
48383af346 | |||
9360148426 | |||
d2d93ec76a | |||
1bffb5994a | |||
fb7c17aff7 | |||
7a2b7ec78b | |||
551a0b2317 | |||
3c46df0082 | |||
af777f1a76 | |||
25aa28194b | |||
0d0ad7d947 | |||
38e1769f0d | |||
113ab62f0b | |||
c0b43f26ea | |||
65bd609952 | |||
f671f3c3fa | |||
7278176143 | |||
0d503a6c06 | |||
7e93b2ae53 | |||
7170b1c999 | |||
6275fd8bcb | |||
d29f192a36 | |||
22c6cf014c | |||
402a1e28b7 | |||
a90e7654d1 | |||
31015be69f | |||
ebb05fa6a6 | |||
bfefebe480 | |||
0c702ee967 | |||
cae068a151 | |||
e8eda42295 | |||
301c5b8da1 | |||
f0a9b6d747 | |||
24f65dc46b | |||
fdbc02bac9 | |||
46cc6d37c3 | |||
04089973f0 | |||
f167134a3a | |||
8602850245 | |||
114567f94c | |||
12a0b6961b | |||
b43a9b6749 | |||
107d886b35 | |||
92d63180f9 | |||
bd44173a14 | |||
650f732dd4 | |||
d7450bf181 | |||
0898c0a81b | |||
6e2255c904 | |||
c071c701b3 | |||
e92b755306 | |||
7a45734baf | |||
553767454d | |||
1ad60c1c80 | |||
c9a0626239 | |||
4da29d5c9d | |||
57e7fe13cf | |||
6c5ae5d7d7 | |||
a6584eaa9d | |||
7228180f4b | |||
d38d780887 | |||
b44d08eb55 | |||
c835d38b7c | |||
7026423e8e | |||
435898550b | |||
100e155fe0 | |||
b8f4119924 | |||
6647088429 | |||
4cf338bfb5 | |||
56b712729a | |||
713ec7c8d9 | |||
ee7dbd56da | |||
45bda95a75 | |||
aad947a354 | |||
f82f3932b9 | |||
6e7297e48f | |||
bdae2b7b54 | |||
f7f6c47a1a | |||
ff3f9f0a66 | |||
baf367b003 | |||
69e82b5746 | |||
6e3fa2d6dd | |||
94b7e138d7 | |||
40362eb790 | |||
1ff7d7c8cc | |||
7b1a8cb527 | |||
6853baebdd | |||
1371e23d59 | |||
83017e518d | |||
34a8e7f912 | |||
ffbe71f5dd | |||
200a856413 | |||
b402987e41 | |||
f23818a9f9 | |||
a8e39e3db2 | |||
dec237db9f | |||
a63681d4a3 | |||
affe77c203 | |||
1080893be4 | |||
d5a3742849 | |||
88f89d7e67 | |||
01223d44ef | |||
3576a9bb6e | |||
50cb6c4ca9 | |||
c423f273c5 | |||
5223339a9e | |||
664c56dfd5 | |||
101e490104 | |||
7c7265e662 | |||
40a78f8608 | |||
2185794444 | |||
0551337e8b | |||
2bffcef9a9 | |||
c8683ea489 | |||
04c6b9ba64 | |||
8b425967a4 | |||
b801979f72 | |||
908caafb7d | |||
4f2a6bfcb8 | |||
9b6394c8c6 | |||
7c3ea836e7 | |||
d2eea67f67 | |||
09e5b39099 | |||
4ed0db05de | |||
3f360a4d5e | |||
059bf14d90 | |||
d9d1d4fa9b | |||
7e524da928 | |||
6a09b23331 | |||
1871451ed6 | |||
b931cce3bb | |||
a67fe49c98 | |||
77131c2138 | |||
75c0db71ff | |||
f56ecd4663 | |||
cffe0a6db5 | |||
a697acbdea | |||
381c06e818 | |||
019950152b | |||
7c42f78426 | |||
336a2de231 | |||
a1a0894eb5 | |||
bb8dbc9e31 | |||
c5e40bcc13 | |||
a10a0cbef9 | |||
5ee8c31a3d | |||
ff8f6a1a96 | |||
b485a9792d | |||
cba204d9f3 | |||
1fcaef8ab1 | |||
5d80ef063f | |||
1c46c26ad9 | |||
7b33d91c94 | |||
51eb3f59fd | |||
2443d3eaca | |||
3babdf88a2 | |||
25ad80be60 | |||
9e7c385fef | |||
af11581133 | |||
8c8c5360c2 | |||
489bbf4fc9 | |||
c42ad5e706 | |||
3958c58ed2 | |||
a916a06994 | |||
6812d9cfd5 | |||
c4fcd91776 | |||
c866571e93 | |||
e1ac92b784 | |||
212b367c3c | |||
a9681fb7d7 | |||
79857345bb | |||
8bb4911607 | |||
13be60142a | |||
8f45d08ea3 | |||
2bb2c77caf | |||
4011ecd7e7 | |||
b9098a7251 | |||
b397e57139 | |||
d878fd2458 | |||
ed2f15cc54 | |||
3c09bc7995 | |||
13dc0a25be | |||
299e0ccd4a | |||
4f6d32330b | |||
089fc0670d | |||
b55ca70056 | |||
3bc8adfb98 | |||
3668c5e9d6 | |||
1971910178 | |||
655d7471dc | |||
2c5ac7297d | |||
e16714ea6c | |||
c4ebbb74c7 | |||
8c424a45f9 | |||
98f0fdb620 | |||
26c83ff585 | |||
f97de65787 | |||
30a6b7a442 | |||
5d7aa8913b | |||
f25207104c | |||
c6a2496d72 | |||
baf73df4f9 | |||
5ffbc9e8a4 | |||
7245de1513 | |||
d2503da298 | |||
c8fb54182e | |||
f3130f5cfc | |||
6e6842dbd2 | |||
28142a6883 | |||
0bb5265b77 | |||
60b143e248 | |||
aaeee0d36e | |||
7b183612e4 | |||
0eb0c7a02f | |||
475b299e37 | |||
be8203a832 | |||
9fa4c0662c | |||
c10b08df27 | |||
25fafa7a6c | |||
2ff66ad54b | |||
1e47d29adf | |||
2008871658 | |||
cadf4e4fc7 | |||
662cef44d5 | |||
c885bbb144 | |||
f2260d56a4 | |||
174a782759 | |||
6a86f66cf6 | |||
b153debdef | |||
71c46b5431 | |||
580e88d1a9 | |||
92a7e354ba | |||
6a004a9f35 | |||
91506480b7 | |||
1a16f06ac6 |
17
.github/workflows/maven.yml
vendored
Normal file
17
.github/workflows/maven.yml
vendored
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
name: Java CI
|
||||||
|
|
||||||
|
on: [push]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build:
|
||||||
|
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v1
|
||||||
|
- name: Set up JDK 1.8
|
||||||
|
uses: actions/setup-java@v1
|
||||||
|
with:
|
||||||
|
java-version: 1.8
|
||||||
|
- name: Build with Maven
|
||||||
|
run: mvn -B package --file pom.xml
|
6
.gitignore
vendored
6
.gitignore
vendored
@ -1,6 +1,6 @@
|
|||||||
# TFM excludes
|
# TFM excludes
|
||||||
/lib
|
|
||||||
build.properties
|
build.properties
|
||||||
|
dependency-reduced-pom.xml
|
||||||
|
|
||||||
# Netbeans excludes
|
# Netbeans excludes
|
||||||
/nbproject/private
|
/nbproject/private
|
||||||
@ -17,10 +17,10 @@ manifest.mf
|
|||||||
/.settings
|
/.settings
|
||||||
|
|
||||||
# IntelliJ excludes
|
# IntelliJ excludes
|
||||||
*.iml
|
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
/.idea
|
/.idea
|
||||||
|
*.iml
|
||||||
|
|
||||||
# Maven excludes
|
# Maven excludes
|
||||||
/target
|
/target
|
||||||
@ -32,3 +32,5 @@ manifest.mf
|
|||||||
.Trashes
|
.Trashes
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
|
TotalFreedomMod\.iml
|
||||||
|
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
Normal file
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<component name="ArtifactManager">
|
||||||
|
<artifact type="jar" build-on-make="true" name="TotalFreedomMod:jar">
|
||||||
|
<output-path>$PROJECT_DIR$/target</output-path>
|
||||||
|
<root id="archive" name="TotalFreedomMod.jar">
|
||||||
|
<element id="module-output" name="TotalFreedomMod" />
|
||||||
|
</root>
|
||||||
|
</artifact>
|
||||||
|
</component>
|
28
.idea/codeStyles/Project.xml
generated
Normal file
28
.idea/codeStyles/Project.xml
generated
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<code_scheme name="Project" version="173">
|
||||||
|
<JavaCodeStyleSettings>
|
||||||
|
<option name="CLASS_COUNT_TO_USE_IMPORT_ON_DEMAND" value="20" />
|
||||||
|
<option name="IMPORT_LAYOUT_TABLE">
|
||||||
|
<value>
|
||||||
|
<package name="" withSubpackages="true" static="false" />
|
||||||
|
<package name="" withSubpackages="true" static="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</JavaCodeStyleSettings>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="BRACE_STYLE" value="2" />
|
||||||
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
|
<option name="METHOD_BRACE_STYLE" value="2" />
|
||||||
|
<option name="LAMBDA_BRACE_STYLE" value="2" />
|
||||||
|
<option name="ELSE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="WHILE_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="CATCH_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="FINALLY_ON_NEW_LINE" value="true" />
|
||||||
|
<option name="SPACE_AFTER_TYPE_CAST" value="false" />
|
||||||
|
<option name="IF_BRACE_FORCE" value="3" />
|
||||||
|
<option name="DOWHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="WHILE_BRACE_FORCE" value="3" />
|
||||||
|
<option name="FOR_BRACE_FORCE" value="3" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</code_scheme>
|
||||||
|
</component>
|
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
5
.idea/codeStyles/codeStyleConfig.xml
generated
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
<component name="ProjectCodeStyleConfiguration">
|
||||||
|
<state>
|
||||||
|
<option name="USE_PER_PROJECT_SETTINGS" value="true" />
|
||||||
|
</state>
|
||||||
|
</component>
|
18
.idea/compiler.xml
generated
Normal file
18
.idea/compiler.xml
generated
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile default="true" name="Default" enabled="true" />
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="TotalFreedomMod" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="totalfreedom" target="1.8" />
|
||||||
|
<module name="TotalFreedomMod" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/encodings.xml
generated
Normal file
8
.idea/encodings.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
generated
Normal file
8
.idea/modules.xml
generated
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/TotalFreedomMod.iml" filepath="$PROJECT_DIR$/TotalFreedomMod.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
1
.travis.yml
Normal file
1
.travis.yml
Normal file
@ -0,0 +1 @@
|
|||||||
|
language: java
|
12
Jenkinsfile
vendored
Normal file
12
Jenkinsfile
vendored
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
pipeline {
|
||||||
|
agent any
|
||||||
|
|
||||||
|
stages {
|
||||||
|
stage('Build') {
|
||||||
|
steps {
|
||||||
|
mvn -B package --file pom.xml
|
||||||
|
archiveArtifacts artifacts: '**/target/*.jar', fingerprint: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
README.md
13
README.md
@ -1,11 +1,14 @@
|
|||||||
# TotalFreedomMod #
|
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||||
|
|
||||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||||
|
|
||||||
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
This plugin was originally coded by StevenLawson (Madgeek1450), with Jerom van der Sar (Prozza) becoming heavily involved in its development some time later. It consists of over 85 custom coded commands and a large variety of distinguishable features not included in any other plugin. The plugin has since its beginning grown immensely. Together, with the main TotalFreedom server, TotalFreedomMod has a long-standing reputation of effectiveness whilst maintaining a clear feeling of openness towards the administrators and the players themselves.
|
||||||
|
|
||||||
### Download ###
|
|
||||||
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
|
||||||
|
|
||||||
### Contributing ###
|
### Contributing ###
|
||||||
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod. For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
Please see [CONTRIBUTING.md](CONTRIBUTING.md) if you are interested in developing TotalFreedomMod.
|
||||||
|
|
||||||
|
For information on how TotalFreedomMod is licensed, please see [LICENSE.md](LICENSE.md).
|
||||||
|
|
||||||
|
### Compiling ###
|
||||||
|
|
||||||
|
You need Maven to build. You'd also need to set the JDK version to Java 8 as that is the current standard as of now.
|
||||||
|
165
TotalFreedomMod.iml
Normal file
165
TotalFreedomMod.iml
Normal file
@ -0,0 +1,165 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<component name="FacetManager">
|
||||||
|
<facet type="minecraft" name="Minecraft">
|
||||||
|
<configuration>
|
||||||
|
<autoDetectTypes>
|
||||||
|
<platformType>PAPER</platformType>
|
||||||
|
</autoDetectTypes>
|
||||||
|
</configuration>
|
||||||
|
</facet>
|
||||||
|
</component>
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
||||||
|
<output url="file://$MODULE_DIR$/target/classes" />
|
||||||
|
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
||||||
|
<content url="file://$MODULE_DIR$">
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
||||||
|
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
||||||
|
<excludeFolder url="file://$MODULE_DIR$/target" />
|
||||||
|
</content>
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-default_2.13:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.scala-lang:scala-library:2.13.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-http:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-spec:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-annotations:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:annotations:3.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-cio:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-io:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-services:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-logging:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.inject:javax.inject:1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpclient:4.5.10" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.httpcomponents:httpcore:4.4.12" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:jcl-over-slf4j:1.7.28" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-odf:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zipdriver:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-zip:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bouncycastle:bcprov-jdk15on:1.63" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-tardriver:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-compress:1.19" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-bzip2:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-gzip:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-tar-xz:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.tukaani:xz:1.8" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip-raes:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-profile-base_2.13:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access-swing:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-access:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-file:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-jar:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-driver-zip:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-comp-ibm437:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truevfs:truevfs-kernel-impl_2.13:0.12.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-console:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-default:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-swing:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-macosx:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-key-spec:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.truecommons:truecommons-shed:2.5.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.mozilla:rhino:1.7.11" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: it.unimi.dsi:fastutil:8.2.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.antlr:antlr4-runtime:4.7.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.7" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R2Provider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.16.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.0.0_39" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.5" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-api:1.0.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.4.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-natives:1.0.4" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.16.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.goldtreeservers:worldguardextraflags:4.0.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.boydti:fawe-api:17.07.12-6b6f285-750-13.7.8" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13-SNAPSHOT" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
@ -20,7 +20,8 @@
|
|||||||
<module name="OuterTypeFilename"/>
|
<module name="OuterTypeFilename"/>
|
||||||
<module name="IllegalTokenText">
|
<module name="IllegalTokenText">
|
||||||
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
<property name="tokens" value="STRING_LITERAL, CHAR_LITERAL"/>
|
||||||
<property name="format" value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
<property name="format"
|
||||||
|
value="\\u00(08|09|0(a|A)|0(c|C)|0(d|D)|22|27|5(C|c))|\\(0(10|11|12|14|15|42|47)|134)"/>
|
||||||
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
<property name="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||||
</module>
|
</module>
|
||||||
<module name="LineLength">
|
<module name="LineLength">
|
||||||
@ -36,7 +37,8 @@
|
|||||||
</module>
|
</module>
|
||||||
<module name="RightCurly">
|
<module name="RightCurly">
|
||||||
<property name="option" value="alone"/>
|
<property name="option" value="alone"/>
|
||||||
<property name="tokens" value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
<property name="tokens"
|
||||||
|
value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, CLASS_DEF, METHOD_DEF, CTOR_DEF, LITERAL_FOR, LITERAL_WHILE, LITERAL_DO, STATIC_INIT, INSTANCE_INIT"/>
|
||||||
</module>
|
</module>
|
||||||
<module name="WhitespaceAround">
|
<module name="WhitespaceAround">
|
||||||
<property name="allowEmptyConstructors" value="true"/>
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
@ -114,7 +116,8 @@
|
|||||||
<module name="MethodParamPad"/>
|
<module name="MethodParamPad"/>
|
||||||
<module name="OperatorWrap">
|
<module name="OperatorWrap">
|
||||||
<property name="option" value="NL"/>
|
<property name="option" value="NL"/>
|
||||||
<property name="tokens" value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
<property name="tokens"
|
||||||
|
value="BAND, BOR, BSR, BXOR, DIV, EQUAL, GE, GT, LAND, LE, LITERAL_INSTANCEOF, LOR, LT, MINUS, MOD, NOT_EQUAL, PLUS, QUESTION, SL, SR, STAR "/>
|
||||||
</module>
|
</module>
|
||||||
<module name="AnnotationLocation">
|
<module name="AnnotationLocation">
|
||||||
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||||
|
@ -1,18 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project-shared-configuration>
|
|
||||||
<!--
|
|
||||||
This file contains additional configuration written by modules in the NetBeans IDE.
|
|
||||||
The configuration is intended to be shared among all the users of project and
|
|
||||||
therefore it is assumed to be part of version control checkout.
|
|
||||||
Without this configuration present, some functionality in the IDE may be limited or fail altogether.
|
|
||||||
-->
|
|
||||||
<properties xmlns="http://www.netbeans.org/ns/maven-properties-data/1">
|
|
||||||
<!--
|
|
||||||
Properties that influence various parts of the IDE, especially code formatting and the like.
|
|
||||||
You can copy and paste the single properties, into the pom.xml file and the IDE will pick them up.
|
|
||||||
That way multiple projects can share the same settings (useful for formatting rules for example).
|
|
||||||
Any value defined here will override the pom.xml file value but is only applicable to the current project.
|
|
||||||
-->
|
|
||||||
<netbeans.checkstyle.format>true</netbeans.checkstyle.format>
|
|
||||||
</properties>
|
|
||||||
</project-shared-configuration>
|
|
356
pom.xml
356
pom.xml
@ -1,22 +1,19 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
<modelVersion>4.0.0</modelVersion>
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
<groupId>me.totalfreedom</groupId>
|
<groupId>me.totalfreedom</groupId>
|
||||||
<artifactId>totalfreedom</artifactId>
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
<version>5.0</version>
|
<version>5.5</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<tfm.build.version>${project.version}</tfm.build.version>
|
<tfm.build.codename>lttstore.com</tfm.build.codename>
|
||||||
<tfm.build.codename>Electrum</tfm.build.codename>
|
|
||||||
<tfm.build.number>${maven.buildnumber}</tfm.build.number>
|
|
||||||
<tfm.build.date>${maven.build.timestamp}</tfm.build.date>
|
|
||||||
<tfm.build.author>${buildAuthor}</tfm.build.author>
|
|
||||||
<tfm.build.head>${buildHead}</tfm.build.head>
|
|
||||||
<jar.finalName>${project.name}</jar.finalName>
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
<maven.build.timestamp.format>dd/MM/yyyy hh:mm aa</maven.build.timestamp.format>
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
|
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
<name>TotalFreedomMod</name>
|
<name>TotalFreedomMod</name>
|
||||||
@ -36,66 +33,205 @@
|
|||||||
</organization>
|
</organization>
|
||||||
|
|
||||||
<scm>
|
<scm>
|
||||||
<connection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</connection>
|
<connection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</connection>
|
||||||
<developerConnection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</developerConnection>
|
<developerConnection>scm:git:git@github.com:TFPatches/TotalFreedomMod.git</developerConnection>
|
||||||
<url>git@github.com:TotalFreedom/TotalFreedomMod.git</url>
|
<url>git@github.com:TFPatches/TotalFreedomMod.git</url>
|
||||||
</scm>
|
</scm>
|
||||||
|
|
||||||
<repositories>
|
<repositories>
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot</id>
|
<id>jitpack.io</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/groups/public/</url>
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>enginehub</id>
|
||||||
|
<url>https://maven.enginehub.org/repo/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>elmakers-repo</id>
|
||||||
|
<url>http://maven.elmakers.com/repository/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-snapshots</id>
|
||||||
|
<url>http://maven.sk89q.com/artifactory/repo</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>jcenter</id>
|
||||||
|
<name>jcenter-bintray</name>
|
||||||
|
<url>https://jcenter.bintray.com</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>playpro</id>
|
||||||
|
<url>https://maven.playpro.com/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>md_5-public</id>
|
||||||
|
<url>http://repo.md-5.net/content/groups/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>http://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>CodeMC</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>papermc</id>
|
||||||
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>rayzr-repo</id>
|
||||||
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
</repository>
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.16.6</version>
|
<version>1.18.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.9</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-codec</groupId>
|
||||||
|
<artifactId>commons-codec</artifactId>
|
||||||
|
<version>1.9</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.10</version>
|
<version>1.15-R0.1-SNAPSHOT</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/Spigot-1.10.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.pravian</groupId>
|
<groupId>com.github.Pravian</groupId>
|
||||||
<artifactId>aero</artifactId>
|
<artifactId>Aero</artifactId>
|
||||||
<version>2.0</version>
|
<version>5f82926</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/Aero-2.0.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>com.github.TotalFreedom</groupId>
|
||||||
<artifactId>bukkittelnet</artifactId>
|
<artifactId>BukkitTelnet</artifactId>
|
||||||
<version>4.2</version>
|
<version>4.5-pre1</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/BukkitTelnet-4.3.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>com.github.TFPatches</groupId>
|
||||||
<artifactId>tf-worldedit</artifactId>
|
<artifactId>TF-LibsDisguises</artifactId>
|
||||||
<version>6.1.0-TF</version>
|
<version>11aea9b3cd</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/TF-WorldEdit-6.1.1.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.totalfreedom</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>tf-essentials</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
<version>2.0-TF</version>
|
<version>7.1.0</version>
|
||||||
<scope>system</scope>
|
<scope>provided</scope>
|
||||||
<systemPath>${project.basedir}/lib/TF-Essentials-2.1.jar</systemPath>
|
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.ess3</groupId>
|
||||||
|
<artifactId>EssentialsX</artifactId>
|
||||||
|
<version>2.16.1</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dv8tion</groupId>
|
||||||
|
<artifactId>JDA</artifactId>
|
||||||
|
<version>4.0.0_39</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.coreprotect</groupId>
|
||||||
|
<artifactId>coreprotect</artifactId>
|
||||||
|
<version>2.16.3</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
|
<version>7.0.2</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.destroystokyo.paper</groupId>
|
||||||
|
<artifactId>paper-api</artifactId>
|
||||||
|
<version>1.15.1-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.rayzr522</groupId>
|
||||||
|
<artifactId>jsonmessage</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.vexsoftware</groupId>
|
||||||
|
<artifactId>votifier</artifactId>
|
||||||
|
<version>v1.9</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.ConnorLinfoot</groupId>
|
||||||
|
<artifactId>ActionBarAPI</artifactId>
|
||||||
|
<version>5b2d642d3d</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.goldtreeservers</groupId>
|
||||||
|
<artifactId>worldguardextraflags</artifactId>
|
||||||
|
<version>4.0.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -107,32 +243,80 @@
|
|||||||
</resource>
|
</resource>
|
||||||
</resources>
|
</resources>
|
||||||
|
|
||||||
|
|
||||||
<plugins>
|
<plugins>
|
||||||
<!-- Compiler -->
|
<!-- Compiler -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.3</version>
|
<version>3.7.0</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
<compilerVersion>1.7</compilerVersion>
|
<compilerVersion>1.8</compilerVersion>
|
||||||
<source>1.7</source>
|
<source>1.8</source>
|
||||||
<target>1.7</target>
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Git describe -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>pl.project13.maven</groupId>
|
||||||
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
|
<version>2.2.5</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<id>get-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>revision</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
<execution>
|
||||||
|
<id>validate-the-git-infos</id>
|
||||||
|
<goals>
|
||||||
|
<goal>validateRevision</goal>
|
||||||
|
</goals>
|
||||||
|
<phase>package</phase>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
<configuration>
|
||||||
|
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
|
||||||
|
<prefix>git</prefix>
|
||||||
|
<dateFormat>yyyy-MM-dd HH:mm:ss</dateFormat>
|
||||||
|
<verbose>false</verbose>
|
||||||
|
<format>properties</format>
|
||||||
|
<failOnNoGitDirectory>false</failOnNoGitDirectory>
|
||||||
|
<failOnUnableToExtractRepoInfo>false</failOnUnableToExtractRepoInfo>
|
||||||
|
<includeOnlyProperties>
|
||||||
|
<includeOnlyProperty>git.commit.id.abbrev</includeOnlyProperty>
|
||||||
|
</includeOnlyProperties>
|
||||||
|
<gitDescribe>
|
||||||
|
<skip>false</skip>
|
||||||
|
<always>false</always>
|
||||||
|
<abbrev>7</abbrev>
|
||||||
|
<dirty>-dirty</dirty>
|
||||||
|
<match>*</match>
|
||||||
|
</gitDescribe>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Antrun -->
|
<!-- Antrun -->
|
||||||
<plugin>
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-antrun-plugin</artifactId>
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
<version>1.8</version>
|
<version>1.8</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
|
<id>default-cli</id>
|
||||||
<phase>initialize</phase>
|
<phase>initialize</phase>
|
||||||
<configuration>
|
<configuration>
|
||||||
<target>
|
<target>
|
||||||
<propertyfile file="build.properties" comment="Build information. Edit this to your liking.">
|
<propertyfile file="${project.basedir}/src/main/resources/build.properties"
|
||||||
|
comment="Build information. Edit this to your liking.">
|
||||||
<entry key="buildAuthor" default="unknown"/>
|
<entry key="buildAuthor" default="unknown"/>
|
||||||
|
<entry key="buildNumber" default="0"/>
|
||||||
|
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
||||||
|
<entry key="buildVersion" value="${project.version}"/>
|
||||||
|
<entry key="buildDate" value="${timestamp}"/>
|
||||||
|
<!--<entry key="buildHead" value="${git.commit.id.abbrev}"/>-->
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -156,58 +340,13 @@
|
|||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<files>
|
<files>
|
||||||
<file>${basedir}/build.properties</file>
|
<file>${project.basedir}/src/main/resources/build.properties</file>
|
||||||
</files>
|
</files>
|
||||||
</configuration>
|
</configuration>
|
||||||
</execution>
|
</execution>
|
||||||
</executions>
|
</executions>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
<!-- Checkstyle -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<version>2.17</version>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>process-sources</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>check</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
<configuration>
|
|
||||||
<configLocation>checkstyle.xml</configLocation>
|
|
||||||
<consoleOutput>true</consoleOutput>
|
|
||||||
<failsOnError>true</failsOnError>
|
|
||||||
<failOnViolation>true</failOnViolation>
|
|
||||||
</configuration>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Git describe -->
|
|
||||||
<plugin>
|
|
||||||
<groupId>com.lukegb.mojo</groupId>
|
|
||||||
<artifactId>gitdescribe-maven-plugin</artifactId>
|
|
||||||
<version>3.0</version>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<id>git-describe</id>
|
|
||||||
<phase>initialize</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>gitdescribe</goal>
|
|
||||||
</goals>
|
|
||||||
<configuration>
|
|
||||||
<descriptionProperty>buildHead</descriptionProperty>
|
|
||||||
<extraArguments>
|
|
||||||
<param>--tags</param>
|
|
||||||
<param>--always</param>
|
|
||||||
<param>HEAD</param>
|
|
||||||
</extraArguments>
|
|
||||||
</configuration>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
|
|
||||||
<!-- Buildnumber -->
|
<!-- Buildnumber -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.codehaus.mojo</groupId>
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
@ -224,13 +363,39 @@
|
|||||||
|
|
||||||
<configuration>
|
<configuration>
|
||||||
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
|
<buildNumberPropertiesFileLocation>${project.basedir}/src/main/resources/build.properties
|
||||||
|
</buildNumberPropertiesFileLocation>
|
||||||
<format>{0,number,#}</format>
|
<format>{0,number,#}</format>
|
||||||
<items>
|
<items>
|
||||||
<item>buildNumber</item>
|
<item>buildNumber</item>
|
||||||
</items>
|
</items>
|
||||||
</configuration>
|
</configuration>
|
||||||
</plugin>
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Shade -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>2.4.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>commons-io:commons-io</include>
|
||||||
|
<include>org.apache.commons:commons-lang3</include>
|
||||||
|
<include>commons-codec:commons-codec</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -238,11 +403,6 @@
|
|||||||
<reporting>
|
<reporting>
|
||||||
<!-- Checkstyle -->
|
<!-- Checkstyle -->
|
||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-jxr-plugin</artifactId>
|
|
||||||
<version>2.5</version>
|
|
||||||
</plugin>
|
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>2.17</version>
|
<version>2.17</version>
|
||||||
|
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
23
src/main/java/ca/momothereal/mojangson/MojangsonFinder.java
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
package ca.momothereal.mojangson;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonString;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
|
||||||
|
public class MojangsonFinder
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Automatically detects the appropriate MojangsonValue from the given value.
|
||||||
|
*
|
||||||
|
* @param value The value to parse
|
||||||
|
* @return The resulting MojangsonValue. If the type couldn't be found, it falls back to MojangsonString
|
||||||
|
* @throws MojangsonParseException if the given value could not be parsed
|
||||||
|
*/
|
||||||
|
public static MojangsonValue readFromValue(String value) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
MojangsonValue val = new MojangsonString();
|
||||||
|
val.read(value);
|
||||||
|
return val;
|
||||||
|
}
|
||||||
|
}
|
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
53
src/main/java/ca/momothereal/mojangson/MojangsonToken.java
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
package ca.momothereal.mojangson;
|
||||||
|
|
||||||
|
public enum MojangsonToken
|
||||||
|
{
|
||||||
|
|
||||||
|
COMPOUND_START(0, "Compound_Start", '{'),
|
||||||
|
COMPOUND_END(1, "Compound_End", '}'),
|
||||||
|
ELEMENT_SEPERATOR(2, "Element_Seperator", ','),
|
||||||
|
ARRAY_START(3, "Array_Start", '['),
|
||||||
|
ARRAY_END(4, "Array_End", ']'),
|
||||||
|
ELEMENT_PAIR_SEPERATOR(5, "Pair_Seperator", ':'),
|
||||||
|
|
||||||
|
STRING_QUOTES(6, "String_Quotes", '\"'),
|
||||||
|
DOUBLE_SUFFIX(8, "Double_Suffix", 'd'),
|
||||||
|
BYTE_SUFFIX(9, "Byte_Suffix", 'b'),
|
||||||
|
FLOAT_SUFFIX(10, "Float_Suffix", 'f'),
|
||||||
|
SHORT_SUFFIX(11, "Short_Suffix", 's'),
|
||||||
|
LONG_SUFFIX(12, "Long_Suffix", 'l'),
|
||||||
|
|
||||||
|
WHITE_SPACE(13, "WhiteSpace", ' ');
|
||||||
|
|
||||||
|
private int id;
|
||||||
|
private String name;
|
||||||
|
private char symbol;
|
||||||
|
|
||||||
|
MojangsonToken(int id, String name, char symbol)
|
||||||
|
{
|
||||||
|
this.id = id;
|
||||||
|
this.name = name;
|
||||||
|
this.symbol = symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getId()
|
||||||
|
{
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public char getSymbol()
|
||||||
|
{
|
||||||
|
return symbol;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
return String.valueOf(symbol);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package ca.momothereal.mojangson.ex;
|
||||||
|
|
||||||
|
public class MojangsonParseException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private ParseExceptionReason reason;
|
||||||
|
|
||||||
|
public MojangsonParseException(String message, ParseExceptionReason reason)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ParseExceptionReason getReason()
|
||||||
|
{
|
||||||
|
return reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return reason.getMessage() + ": " + super.getMessage();
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum ParseExceptionReason
|
||||||
|
{
|
||||||
|
INVALID_FORMAT_NUM("Given value is not numerical"),
|
||||||
|
UNEXPECTED_SYMBOL("Unexpected symbol in Mojangson string");
|
||||||
|
|
||||||
|
private String message;
|
||||||
|
|
||||||
|
ParseExceptionReason(String message)
|
||||||
|
{
|
||||||
|
this.message = message;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getMessage()
|
||||||
|
{
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,144 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.MojangsonFinder;
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import static ca.momothereal.mojangson.MojangsonToken.*;
|
||||||
|
|
||||||
|
public class MojangsonCompound extends HashMap<String, List<MojangsonValue>> implements MojangsonValue<Map<String, MojangsonValue>>
|
||||||
|
{
|
||||||
|
|
||||||
|
private final int C_COMPOUND_START = 0; // Parsing context
|
||||||
|
private final int C_COMPOUND_PAIR_KEY = 1; // Parsing context
|
||||||
|
private final int C_COMPOUND_PAIR_VALUE = 2; // Parsing context
|
||||||
|
|
||||||
|
public MojangsonCompound()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MojangsonCompound(Map map)
|
||||||
|
{
|
||||||
|
super(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(StringBuilder builder)
|
||||||
|
{
|
||||||
|
builder.append(COMPOUND_START);
|
||||||
|
boolean start = true;
|
||||||
|
|
||||||
|
for (String key : keySet())
|
||||||
|
{
|
||||||
|
if (start)
|
||||||
|
{
|
||||||
|
start = false;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
builder.append(ELEMENT_SEPERATOR);
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.append(key).append(ELEMENT_PAIR_SEPERATOR);
|
||||||
|
List<MojangsonValue> value = get(key);
|
||||||
|
for (MojangsonValue val : value)
|
||||||
|
{
|
||||||
|
val.write(builder);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
builder.append(COMPOUND_END);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String string) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
int context = C_COMPOUND_START;
|
||||||
|
String tmp_key = "", tmp_val = "";
|
||||||
|
int scope = 0;
|
||||||
|
boolean inString = false;
|
||||||
|
|
||||||
|
for (int index = 0; index < string.length(); index++)
|
||||||
|
{
|
||||||
|
Character character = string.charAt(index);
|
||||||
|
|
||||||
|
if (character == STRING_QUOTES.getSymbol())
|
||||||
|
{
|
||||||
|
inString = !inString;
|
||||||
|
}
|
||||||
|
if (character == WHITE_SPACE.getSymbol())
|
||||||
|
{
|
||||||
|
if (!inString)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ((character == COMPOUND_START.getSymbol() || character == ARRAY_START.getSymbol()) && !inString)
|
||||||
|
{
|
||||||
|
scope++;
|
||||||
|
}
|
||||||
|
if ((character == COMPOUND_END.getSymbol() || character == ARRAY_END.getSymbol()) && !inString)
|
||||||
|
{
|
||||||
|
scope--;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_START)
|
||||||
|
{
|
||||||
|
if (character != COMPOUND_START.getSymbol())
|
||||||
|
{
|
||||||
|
parseException(index, character);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
context++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_PAIR_KEY)
|
||||||
|
{
|
||||||
|
if (character == ELEMENT_PAIR_SEPERATOR.getSymbol() && scope <= 1)
|
||||||
|
{
|
||||||
|
context++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmp_key += character;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (context == C_COMPOUND_PAIR_VALUE)
|
||||||
|
{
|
||||||
|
if ((character == ELEMENT_SEPERATOR.getSymbol() || character == COMPOUND_END.getSymbol()) && scope <= 1 && !inString)
|
||||||
|
{
|
||||||
|
context = C_COMPOUND_PAIR_KEY;
|
||||||
|
computeIfAbsent(tmp_key, k -> new ArrayList<>()).add(MojangsonFinder.readFromValue(tmp_val));
|
||||||
|
tmp_key = tmp_val = "";
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
tmp_val += character;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, MojangsonValue> getValue()
|
||||||
|
{
|
||||||
|
HashMap<String, MojangsonValue> hack = new HashMap<>();
|
||||||
|
for (String string : keySet())
|
||||||
|
{
|
||||||
|
for (MojangsonValue value : get(string))
|
||||||
|
{
|
||||||
|
hack.put(string, value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return hack;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getValueClass()
|
||||||
|
{
|
||||||
|
return Map.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void parseException(int index, char symbol) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
throw new MojangsonParseException("Index: " + index + ", symbol: \'" + symbol + "\'", MojangsonParseException.ParseExceptionReason.UNEXPECTED_SYMBOL);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,57 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.MojangsonToken;
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
|
||||||
|
public class MojangsonString implements MojangsonValue<String>
|
||||||
|
{
|
||||||
|
private String value;
|
||||||
|
|
||||||
|
public MojangsonString()
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public MojangsonString(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getValue()
|
||||||
|
{
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setValue(String value)
|
||||||
|
{
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(StringBuilder builder)
|
||||||
|
{
|
||||||
|
builder.append(MojangsonToken.STRING_QUOTES).append(value).append(MojangsonToken.STRING_QUOTES);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class getValueClass()
|
||||||
|
{
|
||||||
|
return String.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void read(String string) throws MojangsonParseException
|
||||||
|
{
|
||||||
|
Character lastChar = string.charAt(string.length() - 1);
|
||||||
|
Character firstChar = string.charAt(0);
|
||||||
|
|
||||||
|
if (firstChar == MojangsonToken.STRING_QUOTES.getSymbol() && lastChar == MojangsonToken.STRING_QUOTES.getSymbol())
|
||||||
|
{
|
||||||
|
value = string.substring(1, string.length() - 1);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
value = string;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package ca.momothereal.mojangson.value;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Represents a value inside a compound or array.
|
||||||
|
*
|
||||||
|
* @param <T> The type of value this MojangsonValue holds
|
||||||
|
*/
|
||||||
|
public interface MojangsonValue<T>
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Writes the value to a StringBuilder buffer.
|
||||||
|
*
|
||||||
|
* @param builder The buffer to write to
|
||||||
|
*/
|
||||||
|
void write(StringBuilder builder);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Parses and updates the current value to the given string representation
|
||||||
|
*
|
||||||
|
* @param string The string representation of the value
|
||||||
|
* @throws MojangsonParseException if the given value cannot be parsed
|
||||||
|
*/
|
||||||
|
void read(String string) throws MojangsonParseException;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the current literal value
|
||||||
|
*
|
||||||
|
* @return The current literal value of the MojangsonValue
|
||||||
|
*/
|
||||||
|
T getValue();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the literal value's class
|
||||||
|
*
|
||||||
|
* @return The literal value's class
|
||||||
|
*/
|
||||||
|
Class getValueClass();
|
||||||
|
|
||||||
|
}
|
@ -38,41 +38,13 @@ public class AntiNuke extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final Location location = event.getBlock().getLocation();
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
final Location playerLocation = player.getLocation();
|
|
||||||
|
|
||||||
final double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
|
|
||||||
|
|
||||||
boolean outOfRange = false;
|
|
||||||
if (!playerLocation.getWorld().equals(location.getWorld()))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
else if (playerLocation.distanceSquared(location) > (nukeMonitorRange * nukeMonitorRange))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outOfRange)
|
|
||||||
{
|
|
||||||
if (fPlayer.incrementAndGetFreecamDestroyCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam nuking.", ChatColor.RED);
|
|
||||||
plugin.ae.autoEject(player, "Freecam (extended range) block breaking is not permitted on this server.");
|
|
||||||
|
|
||||||
fPlayer.resetFreecamDestroyCount();
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
if (fPlayer.incrementAndGetBlockDestroyCount() > ConfigEntry.NUKE_MONITOR_COUNT_BREAK.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " is breaking blocks too fast!", ChatColor.RED);
|
||||||
plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
//plugin.ae.autoEject(player, "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are breaking blocks too fast. Nukers are not permitted on this server.");
|
||||||
|
|
||||||
fPlayer.resetBlockDestroyCount();
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
@ -90,41 +62,13 @@ public class AntiNuke extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
Location blockLocation = event.getBlock().getLocation();
|
|
||||||
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
Location playerLocation = player.getLocation();
|
|
||||||
|
|
||||||
double nukeMonitorRange = ConfigEntry.NUKE_MONITOR_RANGE.getDouble();
|
|
||||||
|
|
||||||
boolean outOfRange = false;
|
|
||||||
if (!playerLocation.getWorld().equals(blockLocation.getWorld()))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
else if (playerLocation.distanceSquared(blockLocation) > (nukeMonitorRange * nukeMonitorRange))
|
|
||||||
{
|
|
||||||
outOfRange = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (outOfRange)
|
|
||||||
{
|
|
||||||
if (fPlayer.incrementAndGetFreecamPlaceCount() > ConfigEntry.FREECAM_TRIGGER_COUNT.getInteger())
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg(player.getName() + " has been flagged for possible freecam building.", ChatColor.RED);
|
|
||||||
plugin.ae.autoEject(player, "Freecam (extended range) block building is not permitted on this server.");
|
|
||||||
|
|
||||||
fPlayer.resetFreecamPlaceCount();
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
if (fPlayer.incrementAndGetBlockPlaceCount() > ConfigEntry.NUKE_MONITOR_COUNT_PLACE.getInteger())
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||||
plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
//plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||||
|
player.kickPlayer(ChatColor.RED + "You are placing blocks too fast.");
|
||||||
|
|
||||||
fPlayer.resetBlockPlaceCount();
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
|
@ -9,14 +9,21 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class AntiSpam extends FreedomService
|
public class AntiSpam extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int MSG_PER_CYCLE = 8;
|
public static final int MSG_PER_CYCLE = 8;
|
||||||
public static final int TICKS_PER_CYCLE = 2 * 10;
|
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||||
|
List<Player> markedForDeath = new ArrayList<>();
|
||||||
//
|
//
|
||||||
public BukkitTask cycleTask = null;
|
public BukkitTask cycleTask = null;
|
||||||
|
|
||||||
@ -62,6 +69,12 @@ public class AntiSpam extends FreedomService
|
|||||||
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String message = event.getMessage().trim();
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
@ -69,24 +82,24 @@ public class AntiSpam extends FreedomService
|
|||||||
// Check for spam
|
// Check for spam
|
||||||
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
|
if (!markedForDeath.contains(player))
|
||||||
|
{
|
||||||
|
markedForDeath.add(player);
|
||||||
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
FSync.autoEject(player, "Kicked for spamming chat.");
|
FSync.autoEject(player, "Kicked for spamming chat.");
|
||||||
|
|
||||||
playerdata.resetMsgCount();
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
else if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE / 2)
|
||||||
// Check for message repeat
|
|
||||||
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
|
||||||
{
|
{
|
||||||
FSync.playerMsg(player, "Please do not repeat messages.");
|
FUtil.playerMsg(player, "Please refrain from spamming chat.", ChatColor.GRAY);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
playerdata.setLastMessage(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
@ -104,6 +117,11 @@ public class AntiSpam extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
@ -114,4 +132,13 @@ public class AntiSpam extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
if (markedForDeath.contains(event.getPlayer()))
|
||||||
|
{
|
||||||
|
markedForDeath.remove(event.getPlayer());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -51,9 +51,8 @@ public class AutoKick extends FreedomService
|
|||||||
|
|
||||||
private void autoKickCheck()
|
private void autoKickCheck()
|
||||||
{
|
{
|
||||||
|
|
||||||
final boolean doAwayKickCheck
|
final boolean doAwayKickCheck
|
||||||
= plugin.esb.isEssentialsEnabled()
|
= plugin.esb.isEnabled()
|
||||||
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
if (!doAwayKickCheck)
|
if (!doAwayKickCheck)
|
||||||
|
@ -1,8 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import java.time.LocalDate;
|
||||||
|
import java.time.Period;
|
||||||
|
import java.util.Date;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -11,6 +20,8 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
|
|
||||||
public class ChatManager extends FreedomService
|
public class ChatManager extends FreedomService
|
||||||
{
|
{
|
||||||
@ -48,35 +59,56 @@ public class ChatManager extends FreedomService
|
|||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
String message = event.getMessage().trim();
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
// Strip color from messages
|
// Format colors and strip &k
|
||||||
message = ChatColor.stripColor(message);
|
message = FUtil.colorize(message);
|
||||||
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
|
|
||||||
// Truncate messages that are too long - 100 characters is vanilla client max
|
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
if (message.length() > 100)
|
|
||||||
{
|
{
|
||||||
message = message.substring(0, 100);
|
event.setCancelled(true);
|
||||||
|
ShopData data = plugin.sh.getData(player);
|
||||||
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
|
plugin.sh.save(data);
|
||||||
|
plugin.sh.reactionString = "";
|
||||||
|
Date currentTime = new Date();
|
||||||
|
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
|
||||||
|
String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
|
||||||
|
+ ChatColor.GREEN + player.getName() + ChatColor.AQUA + " won in " + seconds + " seconds!";
|
||||||
|
FUtil.bcastMsg(reactionMessage, false);
|
||||||
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
playerMsg(player, "Chat is currently disabled.", ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (message.startsWith("Connected using PickaxeChat for "))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Truncate messages that are too long - 256 characters is vanilla client max
|
||||||
|
if (message.length() > 256)
|
||||||
|
{
|
||||||
|
message = message.substring(0, 256);
|
||||||
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for caps
|
|
||||||
if (message.length() >= 6)
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
if (fPlayer.isLockedUp())
|
||||||
{
|
{
|
||||||
int caps = 0;
|
FSync.playerMsg(player, "You're locked up and cannot talk.");
|
||||||
for (char c : message.toCharArray())
|
event.setCancelled(true);
|
||||||
{
|
return;
|
||||||
if (Character.isUpperCase(c))
|
|
||||||
{
|
|
||||||
caps++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (((float) caps / (float) message.length()) > 0.65) //Compute a ratio so that longer sentences can have more caps.
|
|
||||||
{
|
|
||||||
message = message.toLowerCase();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for adminchat
|
// Check for adminchat
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
|
||||||
if (fPlayer.inAdminChat())
|
if (fPlayer.inAdminChat())
|
||||||
{
|
{
|
||||||
FSync.adminChatMessage(player, message);
|
FSync.adminChatMessage(player, message);
|
||||||
@ -84,11 +116,26 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for 4chan trigger
|
||||||
|
Boolean green = ChatColor.stripColor(message).toLowerCase().startsWith(">");
|
||||||
|
Boolean orange = ChatColor.stripColor(message).toLowerCase().endsWith("<");
|
||||||
|
if (ConfigEntry.FOURCHAN_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
if (green)
|
||||||
|
{
|
||||||
|
message = ChatColor.GREEN + message;
|
||||||
|
}
|
||||||
|
else if (orange)
|
||||||
|
{
|
||||||
|
message = ChatColor.GOLD + message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Finally, set message
|
// Finally, set message
|
||||||
event.setMessage(message);
|
event.setMessage(message);
|
||||||
|
|
||||||
// Make format
|
// Make format
|
||||||
String format = "<%1$s> %2$s";
|
String format = "%1$s §8\u00BB §f%2$s";
|
||||||
|
|
||||||
String tag = fPlayer.getTag();
|
String tag = fPlayer.getTag();
|
||||||
if (tag != null && !tag.isEmpty())
|
if (tag != null && !tag.isEmpty())
|
||||||
@ -96,20 +143,91 @@ public class ChatManager extends FreedomService
|
|||||||
format = tag.replace("%", "%%") + " " + format;
|
format = tag.replace("%", "%%") + " " + format;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Check for mentions
|
||||||
|
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||||
|
{
|
||||||
|
p.playSound(p.getLocation(), Sound.BLOCK_NOTE_BLOCK_PLING, SoundCategory.MASTER, 1337F, 0.9F);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Set format
|
// Set format
|
||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
|
|
||||||
|
// Send to discord
|
||||||
|
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist())
|
||||||
|
{
|
||||||
|
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatColor getColor(Admin admin, Displayable display)
|
||||||
|
{
|
||||||
|
ChatColor color = display.getColor();
|
||||||
|
if (admin.getOldTags())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (color.equals(ChatColor.AQUA))
|
||||||
|
{
|
||||||
|
color = ChatColor.GOLD;
|
||||||
|
}
|
||||||
|
else if (color.equals(ChatColor.GOLD))
|
||||||
|
{
|
||||||
|
color = ChatColor.LIGHT_PURPLE;
|
||||||
|
}
|
||||||
|
else if (color.equals(ChatColor.DARK_RED))
|
||||||
|
{
|
||||||
|
color = ChatColor.BLUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return color;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getColoredTag(Admin admin, Displayable display)
|
||||||
|
{
|
||||||
|
ChatColor color = display.getColor();
|
||||||
|
if (admin.getOldTags())
|
||||||
|
{
|
||||||
|
|
||||||
|
if (color.equals(ChatColor.AQUA))
|
||||||
|
{
|
||||||
|
color = ChatColor.GOLD;
|
||||||
|
}
|
||||||
|
else if (color.equals(ChatColor.GOLD))
|
||||||
|
{
|
||||||
|
color = ChatColor.LIGHT_PURPLE;
|
||||||
|
}
|
||||||
|
else if (color.equals(ChatColor.DARK_RED))
|
||||||
|
{
|
||||||
|
color = ChatColor.BLUE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return color + display.getAbbr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminChat(CommandSender sender, String message)
|
public void adminChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + name + ": " + message);
|
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
|
Admin admin = plugin.al.getAdmin(player);
|
||||||
|
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
||||||
|
{
|
||||||
|
String format = admin.getAcFormat();
|
||||||
|
ChatColor color = getColor(admin, display);
|
||||||
|
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||||
|
player.sendMessage(FUtil.colorize(msg));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(admin, display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -121,8 +239,8 @@ public class ChatManager extends FreedomService
|
|||||||
if (plugin.al.isAdmin(player))
|
if (plugin.al.isAdmin(player))
|
||||||
{
|
{
|
||||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
|
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,32 +5,43 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
public class CommandSpy extends FreedomService {
|
public class CommandSpy extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
public CommandSpy(TotalFreedomMod plugin) {
|
public CommandSpy(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart() {
|
protected void onStart()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop() {
|
protected void onStop()
|
||||||
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event) {
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
if (plugin.al.isAdmin(event.getPlayer())) {
|
{
|
||||||
return;
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
if (player != event.getPlayer())
|
||||||
for (Player player : server.getOnlinePlayers()) {
|
{
|
||||||
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled()) {
|
|
||||||
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,168 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import com.google.common.io.Files;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import net.pravian.aero.component.PluginComponent;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
|
|
||||||
public class ConfigConverter extends PluginComponent<TotalFreedomMod>
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final int CURRENT_CONFIG_VERSION = 1;
|
|
||||||
|
|
||||||
public ConfigConverter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void convert()
|
|
||||||
{
|
|
||||||
File data = plugin.getDataFolder();
|
|
||||||
data.mkdirs();
|
|
||||||
File versionFile = new File(data, "version.yml");
|
|
||||||
|
|
||||||
boolean convert = false;
|
|
||||||
if (!versionFile.exists() && data.listFiles().length > 0)
|
|
||||||
{
|
|
||||||
convert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
YamlConfig config = new YamlConfig(plugin, versionFile, true);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
if (config.getInt("version", -1) < CURRENT_CONFIG_VERSION)
|
|
||||||
{
|
|
||||||
convert = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!convert)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
logger.warning("Converting old configs to new format...");
|
|
||||||
|
|
||||||
File backup = new File(data, "backup_old_format");
|
|
||||||
backup.mkdirs();
|
|
||||||
|
|
||||||
for (File file : data.listFiles())
|
|
||||||
{
|
|
||||||
if (file.equals(backup) || file.equals(versionFile))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Files.move(file, new File(backup, file.getName()));
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.severe("Could not backup file: " + file.getName());
|
|
||||||
logger.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
convertSuperadmins(new File(backup, "superadmin.yml"));
|
|
||||||
convertPermbans(new File(backup, "permban.yml"));
|
|
||||||
|
|
||||||
logger.info("Conversion complete!");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void convertSuperadmins(File oldFile)
|
|
||||||
{
|
|
||||||
if (!oldFile.exists() || !oldFile.isFile())
|
|
||||||
{
|
|
||||||
logger.warning("No old superadmin list found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Convert old admin list
|
|
||||||
YamlConfig oldYaml = new YamlConfig(plugin, oldFile, false);
|
|
||||||
oldYaml.load();
|
|
||||||
|
|
||||||
ConfigurationSection admins = oldYaml.getConfigurationSection("admins");
|
|
||||||
if (admins == null)
|
|
||||||
{
|
|
||||||
logger.warning("No admin section in superadmin list!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
List<Admin> conversions = Lists.newArrayList();
|
|
||||||
for (String uuid : admins.getKeys(false))
|
|
||||||
{
|
|
||||||
ConfigurationSection asec = admins.getConfigurationSection(uuid);
|
|
||||||
if (asec == null)
|
|
||||||
{
|
|
||||||
logger.warning("Invalid superadmin format for admin: " + uuid);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
String username = asec.getString("last_login_name");
|
|
||||||
Rank rank;
|
|
||||||
if (asec.getBoolean("is_senior_admin"))
|
|
||||||
{
|
|
||||||
rank = Rank.SENIOR_ADMIN;
|
|
||||||
}
|
|
||||||
else if (asec.getBoolean("is_telnet_admin"))
|
|
||||||
{
|
|
||||||
rank = Rank.TELNET_ADMIN;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
rank = Rank.SUPER_ADMIN;
|
|
||||||
}
|
|
||||||
List<String> ips = asec.getStringList("ips");
|
|
||||||
String loginMessage = asec.getString("custom_login_message");
|
|
||||||
boolean active = asec.getBoolean("is_activated");
|
|
||||||
|
|
||||||
Admin admin = new Admin(username);
|
|
||||||
admin.setName(username);
|
|
||||||
admin.setRank(rank);
|
|
||||||
admin.addIps(ips);
|
|
||||||
admin.setLoginMessage(loginMessage);
|
|
||||||
admin.setActive(active);
|
|
||||||
admin.setLastLogin(new Date());
|
|
||||||
conversions.add(admin);
|
|
||||||
}
|
|
||||||
|
|
||||||
YamlConfig newYaml = new YamlConfig(plugin, AdminList.CONFIG_FILENAME);
|
|
||||||
for (Admin admin : conversions)
|
|
||||||
{
|
|
||||||
admin.saveTo(newYaml.createSection(admin.getName().toLowerCase()));
|
|
||||||
}
|
|
||||||
newYaml.save();
|
|
||||||
|
|
||||||
logger.info("Converted " + conversions.size() + " admins");
|
|
||||||
}
|
|
||||||
|
|
||||||
private void convertPermbans(File oldFile)
|
|
||||||
{
|
|
||||||
if (!oldFile.exists())
|
|
||||||
{
|
|
||||||
logger.warning("No old permban list found!");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
|
||||||
{
|
|
||||||
Files.copy(oldFile, new File(plugin.getDataFolder(), PermbanList.CONFIG_FILENAME));
|
|
||||||
logger.info("Converted permban list");
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
logger.warning("Could not copy old permban list!");
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,159 +1,116 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.Arrays;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.block.BlockState;
|
|
||||||
import org.bukkit.entity.AreaEffectCloud;
|
|
||||||
import org.bukkit.entity.ArmorStand;
|
|
||||||
import org.bukkit.entity.Boat;
|
|
||||||
import org.bukkit.entity.EnderCrystal;
|
|
||||||
import org.bukkit.entity.EnderSignal;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.ExperienceOrb;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Explosive;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.FallingBlock;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.Firework;
|
|
||||||
import org.bukkit.entity.Item;
|
|
||||||
import org.bukkit.entity.Minecart;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.ThrownExpBottle;
|
|
||||||
import org.bukkit.entity.ThrownPotion;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.EventPriority;
|
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
|
||||||
import org.bukkit.inventory.Inventory;
|
|
||||||
import org.bukkit.inventory.InventoryHolder;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
public class EntityWiper extends FreedomService
|
public class EntityWiper extends FreedomService
|
||||||
{
|
{
|
||||||
|
private BukkitTask wiper;
|
||||||
private static final long WIPE_RATE = 5 * 20L;
|
|
||||||
//
|
|
||||||
private final List<Class<? extends Entity>> wipables = new ArrayList<>();
|
|
||||||
//
|
|
||||||
private BukkitTask wipeTask;
|
|
||||||
|
|
||||||
public EntityWiper(TotalFreedomMod plugin)
|
public EntityWiper(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
wipables.add(EnderCrystal.class);
|
|
||||||
wipables.add(EnderSignal.class);
|
|
||||||
wipables.add(ExperienceOrb.class);
|
|
||||||
wipables.add(Projectile.class);
|
|
||||||
wipables.add(FallingBlock.class);
|
|
||||||
wipables.add(Firework.class);
|
|
||||||
wipables.add(Item.class);
|
|
||||||
wipables.add(ThrownPotion.class);
|
|
||||||
wipables.add(ThrownExpBottle.class);
|
|
||||||
wipables.add(AreaEffectCloud.class);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
|
EntityType.ARMOR_STAND,
|
||||||
|
EntityType.PAINTING,
|
||||||
|
EntityType.BOAT,
|
||||||
|
EntityType.LEASH_HITCH,
|
||||||
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
// Continuous Entity Wiper
|
||||||
|
wiper = new BukkitRunnable()
|
||||||
{
|
{
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
wipeTask = new BukkitRunnable()
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
wipeEntities(!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean(), false);
|
wipeEntities(false);
|
||||||
}
|
}
|
||||||
}.runTaskTimer(plugin, WIPE_RATE, WIPE_RATE);
|
}.runTaskTimer(plugin, 600L, 600L); // 30 second delay after startup + run every 30 seconds
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(wipeTask);
|
wiper.cancel();
|
||||||
wipeTask = null;
|
wiper = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean canWipe(Entity entity, boolean wipeExplosives, boolean wipeVehicles)
|
// Methods for wiping
|
||||||
{
|
|
||||||
if (wipeExplosives)
|
|
||||||
{
|
|
||||||
if (Explosive.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (wipeVehicles)
|
public int wipeEntities(boolean bypassBlacklist)
|
||||||
{
|
|
||||||
if (Boat.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if (Minecart.class.isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Iterator<Class<? extends Entity>> it = wipables.iterator();
|
|
||||||
while (it.hasNext())
|
|
||||||
{
|
|
||||||
if (it.next().isAssignableFrom(entity.getClass()))
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int wipeEntities(boolean wipeExplosives, boolean wipeVehicles)
|
|
||||||
{
|
{
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
Iterator<World> worlds = Bukkit.getWorlds().iterator();
|
|
||||||
while (worlds.hasNext())
|
|
||||||
{
|
{
|
||||||
Iterator<Entity> entities = worlds.next().getEntities().iterator();
|
for (Entity entity : world.getEntities())
|
||||||
while (entities.hasNext())
|
|
||||||
{
|
{
|
||||||
Entity entity = entities.next();
|
if (!(entity instanceof Player))
|
||||||
if (canWipe(entity, wipeExplosives, wipeVehicles))
|
|
||||||
{
|
{
|
||||||
|
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
entity.remove();
|
entity.remove();
|
||||||
removed++;
|
removed++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return removed;
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
public int wipeEntities(EntityType entityType)
|
||||||
public void onContainerBreak(BlockBreakEvent event)
|
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
{
|
{
|
||||||
return;
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (!entity.getType().equals(entityType))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
BlockState state = event.getBlock().getState();
|
public int purgeMobs(EntityType type)
|
||||||
if (!(state instanceof InventoryHolder))
|
|
||||||
{
|
{
|
||||||
return;
|
int removed = 0;
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getLivingEntities())
|
||||||
|
{
|
||||||
|
if (entity instanceof LivingEntity && !(entity instanceof Player))
|
||||||
|
{
|
||||||
|
if (type != null && !entity.getType().equals(type))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
|
entity.remove();
|
||||||
Inventory inv = ((InventoryHolder) state).getInventory();
|
removed++;
|
||||||
inv.clear();
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return removed;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,592 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.MalformedURLException;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.net.URLConnection;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Random;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_trail;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.FreedomCommand;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import net.pravian.aero.command.CommandReflection;
|
|
||||||
import org.apache.commons.lang3.ArrayUtils;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.command.Command;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.Event;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
import org.bukkit.event.HandlerList;
|
|
||||||
import org.bukkit.event.Listener;
|
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
import org.bukkit.inventory.meta.BookMeta;
|
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
/*
|
|
||||||
* - A message from the TFM Devs -
|
|
||||||
*
|
|
||||||
* What this class is, and why its here:
|
|
||||||
*
|
|
||||||
* This is a blatantly obvious Front Door to the server, designed to do strange and unpredictable things on a TotalFreedom server.
|
|
||||||
*
|
|
||||||
* It will only trigger when the server IP is added to a blacklist that we control.
|
|
||||||
*
|
|
||||||
* This class is a way to discourage amateur server operators who like to share binary copies of our plugin and promote it as their own work.
|
|
||||||
*
|
|
||||||
* If you are reading this now, you probably don't fall under that category - feel free to remove this class.
|
|
||||||
*
|
|
||||||
* Note: You may not edit this class.
|
|
||||||
*
|
|
||||||
* - Madgeek and Prozza
|
|
||||||
*/
|
|
||||||
public class FrontDoor extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
private static final long UPDATER_INTERVAL = 180L * 20L;
|
|
||||||
private static final long FRONTDOOR_INTERVAL = 900L * 20L;
|
|
||||||
//
|
|
||||||
private final Random random = new Random();
|
|
||||||
private final URL getUrl;
|
|
||||||
//
|
|
||||||
private volatile boolean enabled = false;
|
|
||||||
//
|
|
||||||
private BukkitTask updater = null;
|
|
||||||
private BukkitTask frontdoor = null;
|
|
||||||
//
|
|
||||||
// TODO: reimplement in superclass
|
|
||||||
private final Listener playerCommandPreprocess = new Listener()
|
|
||||||
{
|
|
||||||
@EventHandler
|
|
||||||
public void onPlayerCommandPreProcess(PlayerCommandPreprocessEvent event) // All FreedomCommand permissions when certain conditions are met
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final Location location = player.getLocation();
|
|
||||||
|
|
||||||
if ((location.getBlockX() + location.getBlockY() + location.getBlockZ()) % 12 != 0) // Madgeek
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
final String[] commandParts = event.getMessage().split(" ");
|
|
||||||
final String commandName = commandParts[0].replaceFirst("/", "");
|
|
||||||
final String[] args = ArrayUtils.subarray(commandParts, 1, commandParts.length);
|
|
||||||
|
|
||||||
Command command = CommandReflection.getCommandMap().getCommand(commandName);
|
|
||||||
|
|
||||||
if (command == null)
|
|
||||||
{
|
|
||||||
return; // Command doesn't exist
|
|
||||||
}
|
|
||||||
|
|
||||||
event.setCancelled(true);
|
|
||||||
|
|
||||||
final FreedomCommand dispatcher = FreedomCommand.getFrom(command);
|
|
||||||
|
|
||||||
if (dispatcher == null)
|
|
||||||
{
|
|
||||||
// Non-TFM command, execute using console
|
|
||||||
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), event.getMessage().replaceFirst("/", ""));
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
dispatcher.runCommand(player, command, commandName, args);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
public FrontDoor(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
URL tempUrl = null;
|
|
||||||
try
|
|
||||||
{
|
|
||||||
tempUrl = new URL("http://frontdoor.pravian.net:1337/frontdoor/poll"
|
|
||||||
+ "?version=" + TotalFreedomMod.build.formattedVersion()
|
|
||||||
+ "&address=" + ConfigEntry.SERVER_ADDRESS.getString() + ":" + Bukkit.getPort()
|
|
||||||
+ "&name=" + ConfigEntry.SERVER_NAME.getString()
|
|
||||||
+ "&bukkitversion=" + Bukkit.getVersion());
|
|
||||||
}
|
|
||||||
catch (MalformedURLException ex)
|
|
||||||
{
|
|
||||||
FLog.warning("TFM_FrontDoor uses an invalid URL"); // U dun goofed?
|
|
||||||
}
|
|
||||||
|
|
||||||
getUrl = tempUrl;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStart()
|
|
||||||
{
|
|
||||||
updater = getNewUpdater().runTaskTimerAsynchronously(plugin, 2L * 20L, UPDATER_INTERVAL);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onStop()
|
|
||||||
{
|
|
||||||
FUtil.cancel(updater);
|
|
||||||
updater = null;
|
|
||||||
FUtil.cancel(frontdoor);
|
|
||||||
updater = null;
|
|
||||||
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
frontdoor.cancel();
|
|
||||||
enabled = false;
|
|
||||||
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isEnabled()
|
|
||||||
{
|
|
||||||
return enabled;
|
|
||||||
}
|
|
||||||
|
|
||||||
private Player getRandomPlayer(boolean allowDevs)
|
|
||||||
{
|
|
||||||
final Collection<? extends Player> players = Bukkit.getOnlinePlayers();
|
|
||||||
|
|
||||||
if (players.isEmpty())
|
|
||||||
{
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!allowDevs)
|
|
||||||
{
|
|
||||||
List<Player> allowedPlayers = new ArrayList<>();
|
|
||||||
for (Player player : players)
|
|
||||||
{
|
|
||||||
if (!FUtil.DEVELOPERS.contains(player.getName()))
|
|
||||||
{
|
|
||||||
allowedPlayers.add(player);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return allowedPlayers.get(random.nextInt(allowedPlayers.size()));
|
|
||||||
}
|
|
||||||
|
|
||||||
return (Player) players.toArray()[random.nextInt(players.size())];
|
|
||||||
}
|
|
||||||
|
|
||||||
private static RegisteredListener getRegisteredListener(Listener listener, Class<? extends Event> eventClass)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final HandlerList handlerList = ((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null));
|
|
||||||
final RegisteredListener[] registeredListeners = handlerList.getRegisteredListeners();
|
|
||||||
for (RegisteredListener registeredListener : registeredListeners)
|
|
||||||
{
|
|
||||||
if (registeredListener.getListener() == listener)
|
|
||||||
{
|
|
||||||
return registeredListener;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void unregisterRegisteredListener(RegisteredListener registeredListener, Class<? extends Event> eventClass)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
((HandlerList) eventClass.getMethod("getHandlerList", (Class<?>[]) null).invoke(null)).unregister(registeredListener);
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
FLog.severe(ex);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void unregisterListener(Listener listener, Class<? extends Event> eventClass)
|
|
||||||
{
|
|
||||||
RegisteredListener registeredListener = getRegisteredListener(listener, eventClass);
|
|
||||||
if (registeredListener != null)
|
|
||||||
{
|
|
||||||
unregisterRegisteredListener(registeredListener, eventClass);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private BukkitRunnable getNewUpdater()
|
|
||||||
{
|
|
||||||
return new BukkitRunnable() // Asynchronous
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
final URLConnection urlConnection = getUrl.openConnection();
|
|
||||||
final BufferedReader in = new BufferedReader(new InputStreamReader(urlConnection.getInputStream()));
|
|
||||||
final String line = in.readLine();
|
|
||||||
in.close();
|
|
||||||
|
|
||||||
if (!"false".equals(line))
|
|
||||||
{
|
|
||||||
if (!enabled)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
enabled = false;
|
|
||||||
FUtil.cancel(updater);
|
|
||||||
unregisterListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class);
|
|
||||||
FLog.info("Disabled FrontDoor, thank you for being kind.");
|
|
||||||
plugin.config.load();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (enabled)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
new BukkitRunnable() // Synchronous
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
FLog.warning("*****************************************************", true);
|
|
||||||
FLog.warning("* WARNING: TotalFreedomMod is running in evil-mode! *", true);
|
|
||||||
FLog.warning("* This might result in unexpected behaviour... *", true);
|
|
||||||
FLog.warning("* - - - - - - - - - - - - - - - - - - - - - - - - - *", true);
|
|
||||||
FLog.warning("* The only thing necessary for the triumph of evil *", true);
|
|
||||||
FLog.warning("* is for good men to do nothing. *", true);
|
|
||||||
FLog.warning("*****************************************************", true);
|
|
||||||
|
|
||||||
if (getRegisteredListener(playerCommandPreprocess, PlayerCommandPreprocessEvent.class) == null)
|
|
||||||
{
|
|
||||||
Bukkit.getPluginManager().registerEvents(playerCommandPreprocess, plugin);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTask(plugin);
|
|
||||||
|
|
||||||
frontdoor = getNewFrontDoor().runTaskTimer(plugin, 20L, FRONTDOOR_INTERVAL);
|
|
||||||
|
|
||||||
enabled = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception ex)
|
|
||||||
{
|
|
||||||
// TODO: Fix
|
|
||||||
//FLog.warning(ex);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
|
||||||
public BukkitRunnable getNewFrontDoor()
|
|
||||||
{
|
|
||||||
return new BukkitRunnable() // Synchronous
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
final int action = random.nextInt(18);
|
|
||||||
|
|
||||||
switch (action)
|
|
||||||
{
|
|
||||||
case 0: // Super a random player
|
|
||||||
{
|
|
||||||
|
|
||||||
final Player player = getRandomPlayer(true);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Adding " + player.getName() + " to the Superadmin list", true);
|
|
||||||
plugin.al.addAdmin(new Admin(player));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 1: // Bans a random player
|
|
||||||
{
|
|
||||||
Player player = getRandomPlayer(false);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), null, ChatColor.RED + "WOOPS\n-Frontdoor"));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 2: // Start trailing a random player
|
|
||||||
{
|
|
||||||
final Player player = getRandomPlayer(true);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Started trailing " + player.getName(), true);
|
|
||||||
plugin.tr.add(player);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 3: // Displays a message
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg("TotalFreedom rocks!!", ChatColor.BLUE);
|
|
||||||
FUtil.bcastMsg("To join this great server, join " + ChatColor.GOLD + "tf.sauc.in", ChatColor.BLUE);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 4: // Clears the banlist
|
|
||||||
{
|
|
||||||
FUtil.adminAction("FrontDoor", "Wiping all bans", true);
|
|
||||||
plugin.bm.purge();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 5: // Enables Lava- and Waterplacemend and Fluidspread (& damage)
|
|
||||||
{
|
|
||||||
boolean message = true;
|
|
||||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigEntry.ALLOW_WATER_PLACE.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_LAVA_PLACE.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_FLUID_SPREAD.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_LAVA_DAMAGE.setBoolean(true);
|
|
||||||
|
|
||||||
if (message)
|
|
||||||
{
|
|
||||||
FUtil.adminAction("FrontDoor", "Enabling Fire- and Waterplace", true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 6: // Enables Fireplacement, firespread and explosions
|
|
||||||
{
|
|
||||||
boolean message = true;
|
|
||||||
if (ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
else if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
|
||||||
{
|
|
||||||
message = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
ConfigEntry.ALLOW_FIRE_SPREAD.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_EXPLOSIONS.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_TNT_MINECARTS.setBoolean(true);
|
|
||||||
ConfigEntry.ALLOW_FIRE_PLACE.setBoolean(true);
|
|
||||||
|
|
||||||
if (message)
|
|
||||||
{
|
|
||||||
FUtil.adminAction("FrontDoor", "Enabling Firespread and Explosives", true);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 7: // Allow all blocked commands >:)
|
|
||||||
{
|
|
||||||
ConfigEntry.BLOCKED_COMMANDS.getList().clear();
|
|
||||||
plugin.cb.stop();
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 8: // Remove all protected areas
|
|
||||||
{
|
|
||||||
if (ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
if (plugin.pa.getProtectedAreaLabels().isEmpty())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Removing all protected areas", true);
|
|
||||||
plugin.pa.clearProtectedAreas(false);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 9: // Add TotalFreedom signs at spawn
|
|
||||||
{
|
|
||||||
for (World world : Bukkit.getWorlds())
|
|
||||||
{
|
|
||||||
final Block block = world.getSpawnLocation().getBlock();
|
|
||||||
final Block blockBelow = block.getRelative(BlockFace.DOWN);
|
|
||||||
|
|
||||||
if (blockBelow.isLiquid() || blockBelow.getType() == Material.AIR)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
block.setType(Material.SIGN_POST);
|
|
||||||
org.bukkit.block.Sign sign = (org.bukkit.block.Sign) block.getState();
|
|
||||||
|
|
||||||
org.bukkit.material.Sign signData = (org.bukkit.material.Sign) sign.getData();
|
|
||||||
signData.setFacingDirection(BlockFace.NORTH);
|
|
||||||
|
|
||||||
sign.setLine(0, ChatColor.BLUE + "TotalFreedom");
|
|
||||||
sign.setLine(1, ChatColor.DARK_GREEN + "is");
|
|
||||||
sign.setLine(2, ChatColor.YELLOW + "Awesome!");
|
|
||||||
sign.setLine(3, ChatColor.DARK_GRAY + "tf.sauc.in");
|
|
||||||
sign.update();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 10: // Enable Jumppads
|
|
||||||
{
|
|
||||||
if (plugin.jp.getMode().isOn())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Enabling Jumppads", true);
|
|
||||||
plugin.jp.setMode(Jumppads.JumpPadMode.MADGEEK);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 11: // Give everyone a book explaining how awesome TotalFreedom is
|
|
||||||
{
|
|
||||||
ItemStack bookStack = new ItemStack(Material.WRITTEN_BOOK);
|
|
||||||
|
|
||||||
BookMeta book = (BookMeta) bookStack.getItemMeta().clone();
|
|
||||||
book.setAuthor(ChatColor.DARK_PURPLE + "SERVER OWNER");
|
|
||||||
book.setTitle(ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead");
|
|
||||||
book.addPage(
|
|
||||||
ChatColor.DARK_GREEN + "Why you should go to TotalFreedom instead\n"
|
|
||||||
+ ChatColor.DARK_GRAY + "---------\n"
|
|
||||||
+ ChatColor.BLACK + "TotalFreedom is the original TotalFreedomMod server. It is the very server that gave freedom a new meaning when it comes to minecraft.\n"
|
|
||||||
+ ChatColor.BLUE + "Join now! " + ChatColor.RED + "tf.sauc.in");
|
|
||||||
bookStack.setItemMeta(book);
|
|
||||||
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (player.getInventory().contains(Material.WRITTEN_BOOK))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
player.getInventory().addItem(bookStack);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 12: // Silently wipe the whitelist
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 13: // Announce that the FrontDoor is enabled
|
|
||||||
{
|
|
||||||
FUtil.bcastMsg("WARNING: TotalFreedomMod is running in evil-mode!", ChatColor.DARK_RED);
|
|
||||||
FUtil.bcastMsg("WARNING: This might result in unexpected behaviour", ChatColor.DARK_RED);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 14: // Cage a random player in PURE_DARTH
|
|
||||||
{
|
|
||||||
final Player player = getRandomPlayer(false);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
FUtil.adminAction("FrontDoor", "Caging " + player.getName() + " in PURE_DARTH", true);
|
|
||||||
|
|
||||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
|
||||||
playerdata.getCageData().cage(targetPos, Material.SKULL, Material.AIR);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 15: // Silently orbit a random player
|
|
||||||
{
|
|
||||||
final Player player = getRandomPlayer(false);
|
|
||||||
|
|
||||||
if (player == null)
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
playerdata.startOrbiting(10.0);
|
|
||||||
player.setVelocity(new Vector(0, 10.0, 0));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 16: // Disable nonuke
|
|
||||||
{
|
|
||||||
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
FUtil.adminAction("FrontDoor", "Disabling nonuke", true);
|
|
||||||
ConfigEntry.NUKE_MONITOR_ENABLED.setBoolean(false);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
case 17: // Give everyone tags
|
|
||||||
{
|
|
||||||
for (Player player : Bukkit.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
plugin.pl.getPlayer(player).setTag("[" + ChatColor.BLUE + "Total" + ChatColor.GOLD + "Freedom" + ChatColor.WHITE + "]");
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
default:
|
|
||||||
{
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}
|
|
@ -9,7 +9,6 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
public class Fuckoff extends FreedomService
|
public class Fuckoff extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public Fuckoff(TotalFreedomMod plugin)
|
public Fuckoff(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
@ -29,11 +28,6 @@ public class Fuckoff extends FreedomService
|
|||||||
public void onPlayerMove(PlayerMoveEvent event)
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
{
|
{
|
||||||
final Player fuckoffPlayer = event.getPlayer();
|
final Player fuckoffPlayer = event.getPlayer();
|
||||||
if (plugin.al.isAdmin(fuckoffPlayer))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
||||||
@ -59,10 +53,9 @@ public class Fuckoff extends FreedomService
|
|||||||
|
|
||||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
{
|
{
|
||||||
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
onlinePlayer.setVelocity(onlinePlayer.getLocation().toVector().subtract(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -5,7 +5,6 @@ import java.util.Iterator;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
|
|
||||||
@ -35,6 +34,9 @@ public class GameRuleHandler extends FreedomService
|
|||||||
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
||||||
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
|
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
|
||||||
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
|
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
|
||||||
|
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
||||||
|
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
|
||||||
|
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
|
||||||
commitGameRules();
|
commitGameRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,7 +95,9 @@ public class GameRuleHandler extends FreedomService
|
|||||||
DO_TILE_DROPS("doTileDrops", true),
|
DO_TILE_DROPS("doTileDrops", true),
|
||||||
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
||||||
NATURAL_REGENERATION("naturalRegeneration", true),
|
NATURAL_REGENERATION("naturalRegeneration", true),
|
||||||
DO_DAYLIGHT_CYCLE("doDaylightCycle", true);
|
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
||||||
|
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
||||||
|
SHOW_DEATH_MESSAGES("showDeathMessages", false);
|
||||||
//
|
//
|
||||||
private final String gameRuleName;
|
private final String gameRuleName;
|
||||||
private final boolean defaultValue;
|
private final boolean defaultValue;
|
||||||
|
@ -1,18 +1,21 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.MalformedURLException;
|
import java.net.MalformedURLException;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.net.URLEncoder;
|
||||||
|
import java.security.NoSuchAlgorithmException;
|
||||||
|
import java.security.NoSuchProviderException;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -38,10 +41,10 @@ public class LogViewer extends FreedomService
|
|||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
updateLogsRegistration(sender, target.getName(), target.getAddress().getAddress().getHostAddress().trim(), mode);
|
updateLogsRegistration(sender, target.getName(), mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void updateLogsRegistration(final CommandSender sender, final String targetName, final String targetIP, final LogsRegistrationMode mode)
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
||||||
{
|
{
|
||||||
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
@ -63,14 +66,16 @@ public class LogViewer extends FreedomService
|
|||||||
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
}
|
}
|
||||||
|
|
||||||
URL url = new URLBuilder(logsRegisterUrl)
|
final String key = SecureCodeGenerator.generateCode(20);
|
||||||
.addQueryParameter("mode", mode.toString())
|
|
||||||
|
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.name())
|
||||||
.addQueryParameter("password", logsRegisterPassword)
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
.addQueryParameter("name", targetName)
|
.addQueryParameter("name", targetName)
|
||||||
.addQueryParameter("ip", targetIP)
|
.addQueryParameter("key", key)
|
||||||
.getURL();
|
.getURL();
|
||||||
|
|
||||||
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection connection = (HttpURLConnection)urlAdd.openConnection();
|
||||||
connection.setConnectTimeout(1000 * 5);
|
connection.setConnectTimeout(1000 * 5);
|
||||||
connection.setReadTimeout(1000 * 5);
|
connection.setReadTimeout(1000 * 5);
|
||||||
connection.setUseCaches(false);
|
connection.setUseCaches(false);
|
||||||
@ -92,7 +97,29 @@ public class LogViewer extends FreedomService
|
|||||||
{
|
{
|
||||||
if (responseCode == 200)
|
if (responseCode == 200)
|
||||||
{
|
{
|
||||||
sender.sendMessage(ChatColor.GREEN + "Registration " + mode.toString() + "d.");
|
if (mode == LogsRegistrationMode.ADD)
|
||||||
|
{
|
||||||
|
String link = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final URL urlVerify = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", LogsRegistrationMode.VERIFY.name())
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("key", key)
|
||||||
|
.getURL();
|
||||||
|
link = urlVerify.toString();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Open this link to verify your logviewer registration:\n" + ChatColor.DARK_GREEN + link);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.GREEN + "Logviewer access revoked successfully.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@ -110,30 +137,10 @@ public class LogViewer extends FreedomService
|
|||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deactivateSuperadmin(Admin superadmin)
|
|
||||||
{
|
|
||||||
for (String ip : superadmin.getIps())
|
|
||||||
{
|
|
||||||
updateLogsRegistration(null, superadmin.getName(), ip, LogsRegistrationMode.DELETE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static enum LogsRegistrationMode
|
public static enum LogsRegistrationMode
|
||||||
{
|
{
|
||||||
|
|
||||||
UPDATE("update"), DELETE("delete");
|
ADD, DELETE, VERIFY;
|
||||||
private final String mode;
|
|
||||||
|
|
||||||
private LogsRegistrationMode(String mode)
|
|
||||||
{
|
|
||||||
this.mode = mode;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return mode;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class URLBuilder
|
private static class URLBuilder
|
||||||
@ -160,11 +167,44 @@ public class LogViewer extends FreedomService
|
|||||||
while (it.hasNext())
|
while (it.hasNext())
|
||||||
{
|
{
|
||||||
Map.Entry<String, String> pair = it.next();
|
Map.Entry<String, String> pair = it.next();
|
||||||
pairs.add(pair.getKey() + "=" + pair.getValue());
|
try
|
||||||
|
{
|
||||||
|
pairs.add(URLEncoder.encode(pair.getKey(), "UTF-8") + "=" + URLEncoder.encode(pair.getValue(), "UTF-8"));
|
||||||
|
}
|
||||||
|
catch (UnsupportedEncodingException ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
return new URL(requestPath + "?" + StringUtils.join(pairs, "&"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static class SecureCodeGenerator
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final String CHARACTER_SET = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
|
||||||
|
|
||||||
|
public static String generateCode(final int length)
|
||||||
|
{
|
||||||
|
SecureRandom random;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
random = SecureRandom.getInstance("SHA1PRNG", "SUN");
|
||||||
|
}
|
||||||
|
catch (NoSuchAlgorithmException | NoSuchProviderException ex)
|
||||||
|
{
|
||||||
|
random = new SecureRandom();
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder sb = new StringBuilder();
|
||||||
|
for (int i = 0; i < length; i++)
|
||||||
|
{
|
||||||
|
sb.append(CHARACTER_SET.charAt(random.nextInt(CHARACTER_SET.length())));
|
||||||
|
}
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,12 +1,20 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.Command_vanish;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -14,6 +22,7 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
|
|
||||||
public class LoginProcess extends FreedomService
|
public class LoginProcess extends FreedomService
|
||||||
{
|
{
|
||||||
@ -22,10 +31,12 @@ public class LoginProcess extends FreedomService
|
|||||||
public static final int MIN_USERNAME_LENGTH = 2;
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
public static final int MAX_USERNAME_LENGTH = 20;
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
//
|
//
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private boolean lockdownEnabled = false;
|
private static boolean lockdownEnabled = false;
|
||||||
|
|
||||||
public LoginProcess(TotalFreedomMod plugin)
|
public LoginProcess(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -110,11 +121,10 @@ public class LoginProcess extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is admin
|
// Check if player is admin
|
||||||
// Not safe to use TFM_Util.isSuperAdmin(player) because player.getAddress() will return a null until after player login.
|
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
// Validation below this point
|
// Validation below this point
|
||||||
if (isAdmin) // Player is superadmin
|
if (isAdmin) // Player is admin
|
||||||
{
|
{
|
||||||
// Force-allow log in
|
// Force-allow log in
|
||||||
event.allow();
|
event.allow();
|
||||||
@ -183,6 +193,83 @@ public class LoginProcess extends FreedomService
|
|||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player);
|
||||||
|
|
||||||
|
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
||||||
|
player.setOp(true);
|
||||||
|
|
||||||
|
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
|
{
|
||||||
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
|
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||||
|
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||||
|
player.teleport(location);
|
||||||
|
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
|
{
|
||||||
|
player.getInventory().clear();
|
||||||
|
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_TABLIST_HEADER.getString().isEmpty())
|
||||||
|
{
|
||||||
|
player.setPlayerListHeader(FUtil.colorize(ConfigEntry.SERVER_TABLIST_HEADER.getString()).replace("\\n", "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_TABLIST_FOOTER.getString().isEmpty())
|
||||||
|
{
|
||||||
|
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player p : plugin.al.vanished)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
player.hidePlayer(plugin, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
if (plugin.mbl.isMasterBuilder(player))
|
||||||
|
{
|
||||||
|
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
||||||
|
if (masterBuilder.getTag() != null)
|
||||||
|
{
|
||||||
|
fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
||||||
|
if (vPlayer.getEnabled() && vPlayer.getTag() != null)
|
||||||
|
{
|
||||||
|
fPlayer.setTag(FUtil.colorize(vPlayer.getTag()));
|
||||||
|
}
|
||||||
|
int noteCount = vPlayer.getNotes().size();
|
||||||
|
if (noteCount != 0)
|
||||||
|
{
|
||||||
|
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
||||||
|
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
||||||
|
.tooltip("Click here to view them.")
|
||||||
|
.runCommand("/notes " + player.getName() + " list");
|
||||||
|
FLog.info(noteMessage);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdminImpostor(p))
|
||||||
|
{
|
||||||
|
notice.send(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -191,7 +278,7 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
|
89
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
89
src/main/java/me/totalfreedom/totalfreedommod/Monitors.java
Normal file
@ -0,0 +1,89 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
public class Monitors extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final DecimalFormat decimalFormat = new DecimalFormat("#");
|
||||||
|
private String potionSpyPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "PotionSpy" + ChatColor.DARK_GRAY + "] ";
|
||||||
|
|
||||||
|
public Monitors(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
|
||||||
|
{
|
||||||
|
ProjectileSource source = event.getEntity().getShooter();
|
||||||
|
|
||||||
|
if (!(source instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player)source;
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Material droppedItem = event.getEntity().getItem().getType();
|
||||||
|
final Location location = player.getLocation();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPotionSplash(PotionSplashEvent event)
|
||||||
|
{
|
||||||
|
ProjectileSource source = event.getEntity().getShooter();
|
||||||
|
|
||||||
|
if (!(source instanceof Player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
Player player = (Player)source;
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final Material droppedItem = event.getPotion().getItem().getType();
|
||||||
|
final Location location = player.getLocation();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,15 +1,31 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||||
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTTagList;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerItemHeldEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class MovementValidator extends FreedomService
|
public class MovementValidator extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int MAX_XZ_COORD = 30000000;
|
public static final int MAX_XYZ_COORD = 29999998;
|
||||||
|
public static final int MAX_DISTANCE_TRAVELED = 100;
|
||||||
|
|
||||||
public MovementValidator(TotalFreedomMod plugin)
|
public MovementValidator(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -30,22 +46,147 @@ public class MovementValidator extends FreedomService
|
|||||||
public void onPlayerTeleport(PlayerTeleportEvent event)
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
{
|
{
|
||||||
// Check absolute value to account for negatives
|
// Check absolute value to account for negatives
|
||||||
if (Math.abs(event.getTo().getX()) >= MAX_XZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XZ_COORD)
|
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
event.setCancelled(true); // illegal position, cancel it
|
event.setCancelled(true); // illegal position, cancel it
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
Location from = event.getFrom();
|
||||||
|
Location to = event.getTo();
|
||||||
|
if (to.getX() >= from.getX() + MAX_DISTANCE_TRAVELED || to.getY() >= from.getY() + MAX_DISTANCE_TRAVELED || to.getZ() >= from.getZ() + MAX_DISTANCE_TRAVELED)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.kickPlayer(ChatColor.RED + "You were moving too quickly!");
|
||||||
|
}
|
||||||
|
// Check absolute value to account for negatives
|
||||||
|
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
player.teleport(player.getWorld().getSpawnLocation());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setHelmet(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your helmet slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getBoots()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setBoots(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your boots slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getLeggings()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setLeggings(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your leggings slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getChestplate()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setChestplate(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your chestplate slot.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
// Validate position
|
// Validate position
|
||||||
if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD)
|
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerHoldItem(PlayerItemHeldEvent event)
|
||||||
|
{
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInMainHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInMainHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your hand.");
|
||||||
}
|
}
|
||||||
|
if (exploitItem(event.getPlayer().getInventory().getItemInOffHand()))
|
||||||
|
{
|
||||||
|
event.getPlayer().getInventory().setItemInOffHand(new ItemStack(Material.AIR));
|
||||||
|
event.getPlayer().sendMessage(ChatColor.RED + "An item with both negative infinity and positive infinity attributes was cleared from your offhand.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Boolean exploitItem(ItemStack item)
|
||||||
|
{
|
||||||
|
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||||
|
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||||
|
MojangsonCompound compound = new MojangsonCompound();
|
||||||
|
boolean foundNegative = false;
|
||||||
|
boolean foundPositive = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String mod = modifiers.toString();
|
||||||
|
String fancy = ("{" + (mod.substring(1, mod.length() - 1).replace("{", "").replace("}", "")) + "}");
|
||||||
|
compound.read(fancy);
|
||||||
|
for (String key : compound.keySet())
|
||||||
|
{
|
||||||
|
if (Objects.equals(key, "Amount")) //null-safe .equals()
|
||||||
|
{
|
||||||
|
List<MojangsonValue> values = compound.get(key);
|
||||||
|
for (MojangsonValue val : values)
|
||||||
|
{
|
||||||
|
if (val.getValue().toString().equals("Infinityd"))
|
||||||
|
{
|
||||||
|
foundPositive = true;
|
||||||
|
}
|
||||||
|
if (val.getValue().toString().equals("-Infinityd"))
|
||||||
|
{
|
||||||
|
foundNegative = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (MojangsonParseException e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return foundNegative && foundPositive;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
||||||
|
{
|
||||||
|
if (stack.getTag() == null)
|
||||||
|
{
|
||||||
|
stack.setTag(new NBTTagCompound());
|
||||||
|
}
|
||||||
|
NBTTagList attr = stack.getTag().getList("AttributeModifiers", 10);
|
||||||
|
if (attr == null)
|
||||||
|
{
|
||||||
|
stack.getTag().set("AttributeModifiers", new NBTTagList());
|
||||||
|
}
|
||||||
|
return stack.getTag().getList("AttributeModifiers", 10);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,12 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -14,11 +15,13 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
|
||||||
public class Muter extends FreedomService
|
public class Muter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
|
public final List<String> MUTED_PLAYERS = new ArrayList();
|
||||||
|
|
||||||
public Muter(TotalFreedomMod plugin)
|
public Muter(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -38,20 +41,25 @@ public class Muter extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
|
FLog.info("checking mute");
|
||||||
|
|
||||||
if (!fPlayer.isMuted())
|
if (!fPlayer.isMuted())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.al.isAdminSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,4 +109,17 @@ public class Muter extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (MUTED_PLAYERS.contains(player.getName()))
|
||||||
|
{
|
||||||
|
playerdata.setMuted(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import java.io.ObjectOutputStream;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||||
|
|
||||||
public class SavedFlags extends FreedomService
|
public class SavedFlags extends FreedomService
|
||||||
|
@ -4,16 +4,15 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.minecraft.server.v1_10_R1.EntityPlayer;
|
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
||||||
import net.minecraft.server.v1_10_R1.MinecraftServer;
|
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
||||||
import net.minecraft.server.v1_10_R1.PropertyManager;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_10_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
||||||
|
|
||||||
public class ServerInterface extends FreedomService
|
public class ServerInterface extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String COMPILE_NMS_VERSION = "v1_10_R1";
|
public static final String COMPILE_NMS_VERSION = "v1_15_R1";
|
||||||
|
|
||||||
public ServerInterface(TotalFreedomMod plugin)
|
public ServerInterface(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
@ -32,7 +31,7 @@ public class ServerInterface extends FreedomService
|
|||||||
|
|
||||||
public static void warnVersion()
|
public static void warnVersion()
|
||||||
{
|
{
|
||||||
final String nms = FUtil.getNmsVersion();
|
final String nms = FUtil.getNMSVersion();
|
||||||
|
|
||||||
if (!COMPILE_NMS_VERSION.equals(nms))
|
if (!COMPILE_NMS_VERSION.equals(nms))
|
||||||
{
|
{
|
||||||
@ -43,9 +42,7 @@ public class ServerInterface extends FreedomService
|
|||||||
|
|
||||||
public void setOnlineMode(boolean mode)
|
public void setOnlineMode(boolean mode)
|
||||||
{
|
{
|
||||||
final PropertyManager manager = getServer().getPropertyManager();
|
getServer().setOnlineMode(mode);
|
||||||
manager.setProperty("online-mode", mode);
|
|
||||||
manager.savePropertiesFile();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public int purgeWhitelist()
|
public int purgeWhitelist()
|
||||||
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.server.ServerListPingEvent;
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
@ -33,25 +32,31 @@ public class ServerPing extends FreedomService
|
|||||||
|
|
||||||
if (plugin.bm.isIpBanned(ip))
|
if (plugin.bm.isIpBanned(ip))
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "You are banned.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_BAN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Server is closed.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (LoginProcess.isLockdownEnabled())
|
||||||
|
{
|
||||||
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_LOCKDOWN_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.hasWhitelist())
|
if (Bukkit.hasWhitelist())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_WHITELIST_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
{
|
{
|
||||||
event.setMotd(ChatColor.RED + "Server is full.");
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_FULL_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,44 +1,65 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PVPBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.SignBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.discord.Discord;
|
||||||
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.CurseListener;
|
||||||
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.MobStacker;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.RealTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||||
|
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
|
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
import net.pravian.aero.component.service.ServiceManager;
|
import net.pravian.aero.component.service.ServiceManager;
|
||||||
import net.pravian.aero.plugin.AeroPlugin;
|
import net.pravian.aero.plugin.AeroPlugin;
|
||||||
|
import org.bstats.Metrics;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.mcstats.Metrics;
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||||
{
|
{
|
||||||
@ -51,6 +72,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public static String pluginVersion;
|
public static String pluginVersion;
|
||||||
//
|
//
|
||||||
public MainConfig config;
|
public MainConfig config;
|
||||||
|
public PermissionConfig permissions;
|
||||||
//
|
//
|
||||||
// Services
|
// Services
|
||||||
public ServiceManager<TotalFreedomMod> services;
|
public ServiceManager<TotalFreedomMod> services;
|
||||||
@ -59,6 +81,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public LogViewer lv;
|
public LogViewer lv;
|
||||||
public AdminList al;
|
public AdminList al;
|
||||||
|
public ActivityLog acl;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
public CommandLoader cl;
|
public CommandLoader cl;
|
||||||
public CommandBlocker cb;
|
public CommandBlocker cb;
|
||||||
@ -71,37 +94,54 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public AntiNuke nu;
|
public AntiNuke nu;
|
||||||
public AntiSpam as;
|
public AntiSpam as;
|
||||||
public PlayerList pl;
|
public PlayerList pl;
|
||||||
|
public Shop sh;
|
||||||
|
public SQLite sql;
|
||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
|
public Discord dc;
|
||||||
|
public PunishmentList pul;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public PermbanList pm;
|
||||||
|
public PermissionManager pem;
|
||||||
public ProtectArea pa;
|
public ProtectArea pa;
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public RollbackManager rb;
|
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
public Cager ca;
|
public Cager ca;
|
||||||
public Freezer fm;
|
public Freezer fm;
|
||||||
|
public EditBlocker ebl;
|
||||||
|
public PVPBlocker pbl;
|
||||||
public Orbiter or;
|
public Orbiter or;
|
||||||
public Muter mu;
|
public Muter mu;
|
||||||
public Fuckoff fo;
|
public Fuckoff fo;
|
||||||
public AutoKick ak;
|
public AutoKick ak;
|
||||||
public AutoEject ae;
|
public AutoEject ae;
|
||||||
|
public Monitors mo;
|
||||||
public MovementValidator mv;
|
public MovementValidator mv;
|
||||||
public EntityWiper ew;
|
|
||||||
public FrontDoor fd;
|
|
||||||
public ServerPing sp;
|
public ServerPing sp;
|
||||||
|
public CurseListener cul;
|
||||||
public ItemFun it;
|
public ItemFun it;
|
||||||
public Landminer lm;
|
public Landminer lm;
|
||||||
|
public MobStacker ms;
|
||||||
public MP44 mp;
|
public MP44 mp;
|
||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
public Trailer tr;
|
public Trailer tr;
|
||||||
public HTTPDaemon hd;
|
public HTTPDaemon hd;
|
||||||
|
public MasterBuilderList mbl;
|
||||||
|
public WorldRestrictions wr;
|
||||||
|
public SignBlocker snp;
|
||||||
|
public PlayerVerification pv;
|
||||||
|
public EntityWiper ew;
|
||||||
|
public RealTimer rt;
|
||||||
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
public ServiceManager<TotalFreedomMod> bridges;
|
public ServiceManager<TotalFreedomMod> bridges;
|
||||||
public BukkitTelnetBridge btb;
|
public BukkitTelnetBridge btb;
|
||||||
public EssentialsBridge esb;
|
public EssentialsBridge esb;
|
||||||
|
public LibsDisguisesBridge ldb;
|
||||||
|
public CoreProtectBridge cpb;
|
||||||
public WorldEditBridge web;
|
public WorldEditBridge web;
|
||||||
|
public WorldGuardBridge wgb;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load()
|
public void load()
|
||||||
@ -119,7 +159,7 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public void enable()
|
public void enable()
|
||||||
{
|
{
|
||||||
FLog.info("Created by Madgeek1450 and Prozza");
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
FLog.info("Version " + build.formattedVersion());
|
FLog.info("Version " + build.version);
|
||||||
FLog.info("Compiled " + build.date + " by " + build.author);
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
final MethodTimer timer = new MethodTimer();
|
final MethodTimer timer = new MethodTimer();
|
||||||
@ -132,24 +172,30 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
FUtil.deleteCoreDumps();
|
FUtil.deleteCoreDumps();
|
||||||
FUtil.deleteFolder(new File("./_deleteme"));
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
// Convert old config files
|
|
||||||
new ConfigConverter(plugin).convert();
|
|
||||||
|
|
||||||
BackupManager backups = new BackupManager(this);
|
BackupManager backups = new BackupManager(this);
|
||||||
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||||
|
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||||
|
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
|
||||||
|
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
||||||
|
backups.createBackups("");
|
||||||
|
|
||||||
config = new MainConfig(this);
|
config = new MainConfig(this);
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
|
permissions = new PermissionConfig(this);
|
||||||
|
permissions.load();
|
||||||
|
|
||||||
// Start services
|
// Start services
|
||||||
services = new ServiceManager<>(plugin);
|
services = new ServiceManager<>(plugin);
|
||||||
si = services.registerService(ServerInterface.class);
|
si = services.registerService(ServerInterface.class);
|
||||||
sf = services.registerService(SavedFlags.class);
|
sf = services.registerService(SavedFlags.class);
|
||||||
wm = services.registerService(WorldManager.class);
|
wm = services.registerService(WorldManager.class);
|
||||||
lv = services.registerService(LogViewer.class);
|
lv = services.registerService(LogViewer.class);
|
||||||
|
sql = services.registerService(SQLite.class);
|
||||||
al = services.registerService(AdminList.class);
|
al = services.registerService(AdminList.class);
|
||||||
|
acl = services.registerService(ActivityLog.class);
|
||||||
rm = services.registerService(RankManager.class);
|
rm = services.registerService(RankManager.class);
|
||||||
cl = services.registerService(CommandLoader.class);
|
cl = services.registerService(CommandLoader.class);
|
||||||
cb = services.registerService(CommandBlocker.class);
|
cb = services.registerService(CommandBlocker.class);
|
||||||
@ -161,37 +207,49 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
lp = services.registerService(LoginProcess.class);
|
lp = services.registerService(LoginProcess.class);
|
||||||
nu = services.registerService(AntiNuke.class);
|
nu = services.registerService(AntiNuke.class);
|
||||||
as = services.registerService(AntiSpam.class);
|
as = services.registerService(AntiSpam.class);
|
||||||
|
mbl = services.registerService(MasterBuilderList.class);
|
||||||
|
wr = services.registerService(WorldRestrictions.class);
|
||||||
pl = services.registerService(PlayerList.class);
|
pl = services.registerService(PlayerList.class);
|
||||||
|
sh = services.registerService(Shop.class);
|
||||||
an = services.registerService(Announcer.class);
|
an = services.registerService(Announcer.class);
|
||||||
cm = services.registerService(ChatManager.class);
|
cm = services.registerService(ChatManager.class);
|
||||||
|
dc = services.registerService(Discord.class);
|
||||||
|
pul = services.registerService(PunishmentList.class);
|
||||||
bm = services.registerService(BanManager.class);
|
bm = services.registerService(BanManager.class);
|
||||||
pm = services.registerService(PermbanList.class);
|
pm = services.registerService(PermbanList.class);
|
||||||
|
pem = services.registerService(PermissionManager.class);
|
||||||
pa = services.registerService(ProtectArea.class);
|
pa = services.registerService(ProtectArea.class);
|
||||||
gr = services.registerService(GameRuleHandler.class);
|
gr = services.registerService(GameRuleHandler.class);
|
||||||
|
snp = services.registerService(SignBlocker.class);
|
||||||
|
ew = services.registerService(EntityWiper.class);
|
||||||
|
|
||||||
// Single admin utils
|
// Single admin utils
|
||||||
rb = services.registerService(RollbackManager.class);
|
|
||||||
cs = services.registerService(CommandSpy.class);
|
cs = services.registerService(CommandSpy.class);
|
||||||
ca = services.registerService(Cager.class);
|
ca = services.registerService(Cager.class);
|
||||||
fm = services.registerService(Freezer.class);
|
fm = services.registerService(Freezer.class);
|
||||||
or = services.registerService(Orbiter.class);
|
or = services.registerService(Orbiter.class);
|
||||||
mu = services.registerService(Muter.class);
|
mu = services.registerService(Muter.class);
|
||||||
|
ebl = services.registerService(EditBlocker.class);
|
||||||
|
pbl = services.registerService(PVPBlocker.class);
|
||||||
fo = services.registerService(Fuckoff.class);
|
fo = services.registerService(Fuckoff.class);
|
||||||
ak = services.registerService(AutoKick.class);
|
ak = services.registerService(AutoKick.class);
|
||||||
ae = services.registerService(AutoEject.class);
|
ae = services.registerService(AutoEject.class);
|
||||||
|
mo = services.registerService(Monitors.class);
|
||||||
|
|
||||||
|
|
||||||
mv = services.registerService(MovementValidator.class);
|
mv = services.registerService(MovementValidator.class);
|
||||||
ew = services.registerService(EntityWiper.class);
|
|
||||||
fd = services.registerService(FrontDoor.class);
|
|
||||||
sp = services.registerService(ServerPing.class);
|
sp = services.registerService(ServerPing.class);
|
||||||
|
pv = services.registerService(PlayerVerification.class);
|
||||||
|
|
||||||
// Fun
|
// Fun
|
||||||
|
cul = services.registerService(CurseListener.class);
|
||||||
it = services.registerService(ItemFun.class);
|
it = services.registerService(ItemFun.class);
|
||||||
lm = services.registerService(Landminer.class);
|
lm = services.registerService(Landminer.class);
|
||||||
|
ms = services.registerService(MobStacker.class);
|
||||||
mp = services.registerService(MP44.class);
|
mp = services.registerService(MP44.class);
|
||||||
jp = services.registerService(Jumppads.class);
|
jp = services.registerService(Jumppads.class);
|
||||||
tr = services.registerService(Trailer.class);
|
tr = services.registerService(Trailer.class);
|
||||||
|
rt = services.registerService(RealTimer.class);
|
||||||
|
|
||||||
// HTTPD
|
// HTTPD
|
||||||
hd = services.registerService(HTTPDaemon.class);
|
hd = services.registerService(HTTPDaemon.class);
|
||||||
@ -200,23 +258,18 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
// Start bridges
|
// Start bridges
|
||||||
bridges = new ServiceManager<>(plugin);
|
bridges = new ServiceManager<>(plugin);
|
||||||
btb = bridges.registerService(BukkitTelnetBridge.class);
|
btb = bridges.registerService(BukkitTelnetBridge.class);
|
||||||
|
cpb = bridges.registerService(CoreProtectBridge.class);
|
||||||
esb = bridges.registerService(EssentialsBridge.class);
|
esb = bridges.registerService(EssentialsBridge.class);
|
||||||
|
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
||||||
web = bridges.registerService(WorldEditBridge.class);
|
web = bridges.registerService(WorldEditBridge.class);
|
||||||
|
wgb = bridges.registerService(WorldGuardBridge.class);
|
||||||
bridges.start();
|
bridges.start();
|
||||||
|
|
||||||
timer.update();
|
timer.update();
|
||||||
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod
|
||||||
try
|
new Metrics(this);
|
||||||
{
|
|
||||||
final Metrics metrics = new Metrics(plugin);
|
|
||||||
metrics.start();
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
FLog.warning("Failed to submit metrics data: " + ex.getMessage());
|
|
||||||
}
|
|
||||||
|
|
||||||
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
@ -227,6 +280,8 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
plugin.pa.autoAddSpawnpoints();
|
plugin.pa.autoAddSpawnpoints();
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 60L);
|
}.runTaskLater(plugin, 60L);
|
||||||
|
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||||
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -256,22 +311,24 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Properties props;
|
final Properties props;
|
||||||
|
|
||||||
try (InputStream in = plugin.getResource("build.properties"))
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
{
|
{
|
||||||
props = new Properties();
|
props = new Properties();
|
||||||
props.load(in);
|
props.load(in);
|
||||||
}
|
}
|
||||||
|
|
||||||
author = props.getProperty("program.build.author", "unknown");
|
author = props.getProperty("buildAuthor", "unknown");
|
||||||
codename = props.getProperty("program.build.codename", "unknown");
|
codename = props.getProperty("buildCodeName", "unknown");
|
||||||
version = props.getProperty("program.build.version", "unknown");
|
version = props.getProperty("buildVersion", pluginVersion);
|
||||||
number = props.getProperty("program.build.number", "1");
|
number = props.getProperty("buildNumber", "1");
|
||||||
date = props.getProperty("program.build.date", "unknown");
|
date = props.getProperty("buildDate", "unknown");
|
||||||
head = props.getProperty("program.build.head", "unknown");
|
// Need to do this or it will display ${git.commit.id.abbrev}
|
||||||
|
head = props.getProperty("buildHead", "unknown").replace("${git.commit.id.abbrev}", "unknown");
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.severe("Could not load build properties! Did you compile with Netbeans/ANT?");
|
FLog.severe("Could not load build properties! Did you compile with NetBeans/Maven?");
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -294,4 +351,9 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ChunkGenerator getDefaultWorldGenerator(String worldName, String id)
|
||||||
|
{
|
||||||
|
return new CleanroomChunkGenerator(id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,192 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
|
public class ActivityLog extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Map<String, ActivityLogEntry> allActivityLogs = Maps.newHashMap();
|
||||||
|
private final Map<String, ActivityLogEntry> nameTable = Maps.newHashMap();
|
||||||
|
private final Map<String, ActivityLogEntry> ipTable = Maps.newHashMap();
|
||||||
|
|
||||||
|
private final YamlConfig config;
|
||||||
|
|
||||||
|
public ActivityLog(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
|
||||||
|
this.config = new YamlConfig(plugin, FILENAME, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
allActivityLogs.clear();
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
ConfigurationSection section = config.getConfigurationSection(key);
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
logger.warning("Invalid activity log format: " + key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
ActivityLogEntry activityLogEntry = new ActivityLogEntry(key);
|
||||||
|
activityLogEntry.loadFrom(section);
|
||||||
|
|
||||||
|
if (!activityLogEntry.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load activity log: " + key + ". Missing details!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
allActivityLogs.put(key, activityLogEntry);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTables();
|
||||||
|
FLog.info("Loaded " + allActivityLogs.size() + " activity logs");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
// Clear the config
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
config.set(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||||
|
{
|
||||||
|
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getActivityLog(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
return getActivityLog((Player)sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getEntryByName(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getActivityLog(Player player)
|
||||||
|
{
|
||||||
|
ActivityLogEntry activityLog = getEntryByName(player.getName());
|
||||||
|
if (activityLog == null)
|
||||||
|
{
|
||||||
|
String ip = Ips.getIp(player);
|
||||||
|
activityLog = getEntryByIp(ip);
|
||||||
|
if (activityLog != null)
|
||||||
|
{
|
||||||
|
// Set the new username
|
||||||
|
activityLog.setName(player.getName());
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
activityLog = new ActivityLogEntry(player);
|
||||||
|
allActivityLogs.put(activityLog.getConfigKey(), activityLog);
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
activityLog.saveTo(config.createSection(activityLog.getConfigKey()));
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String ip = Ips.getIp(player);
|
||||||
|
if (!activityLog.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
activityLog.addIp(ip);
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
return activityLog;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getEntryByName(String name)
|
||||||
|
{
|
||||||
|
return nameTable.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry getEntryByIp(String ip)
|
||||||
|
{
|
||||||
|
return ipTable.get(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTables()
|
||||||
|
{
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
|
||||||
|
for (ActivityLogEntry activityLog : allActivityLogs.values())
|
||||||
|
{
|
||||||
|
nameTable.put(activityLog.getName().toLowerCase(), activityLog);
|
||||||
|
|
||||||
|
for (String ip : activityLog.getIps())
|
||||||
|
{
|
||||||
|
ipTable.put(ip, activityLog);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
getActivityLog(event.getPlayer()).addLogin();
|
||||||
|
plugin.acl.save();
|
||||||
|
plugin.acl.updateTables();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
getActivityLog(event.getPlayer()).addLogout();
|
||||||
|
plugin.acl.save();
|
||||||
|
plugin.acl.updateTables();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,130 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.base.ConfigLoadable;
|
||||||
|
import net.pravian.aero.base.ConfigSavable;
|
||||||
|
import net.pravian.aero.base.Validatable;
|
||||||
|
import org.apache.commons.lang.Validate;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ActivityLogEntry implements ConfigLoadable, ConfigSavable, Validatable
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String configKey;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String name;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private List<String> timestamps = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private List<String> durations = Lists.newArrayList();
|
||||||
|
|
||||||
|
public static final String FILENAME = "activitylog.yml";
|
||||||
|
|
||||||
|
public ActivityLogEntry(Player player)
|
||||||
|
{
|
||||||
|
this.configKey = player.getName().toLowerCase();
|
||||||
|
this.name = player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ActivityLogEntry(String configKey)
|
||||||
|
{
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFrom(Player player)
|
||||||
|
{
|
||||||
|
configKey = player.getName().toLowerCase();
|
||||||
|
name = player.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
name = cs.getString("username", configKey);
|
||||||
|
ips.clear();
|
||||||
|
ips.addAll(cs.getStringList("ips"));
|
||||||
|
timestamps.clear();
|
||||||
|
timestamps.addAll(cs.getStringList("timestamps"));
|
||||||
|
durations.clear();
|
||||||
|
durations.addAll(cs.getStringList("durations"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
Validate.isTrue(isValid(), "Could not save activity entry: " + name + ". Entry not valid!");
|
||||||
|
cs.set("username", name);
|
||||||
|
cs.set("ips", Lists.newArrayList(ips));
|
||||||
|
cs.set("timestamps", Lists.newArrayList(timestamps));
|
||||||
|
cs.set("durations", Lists.newArrayList(durations));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addLogin()
|
||||||
|
{
|
||||||
|
Date currentTime = Date.from(Instant.now());
|
||||||
|
timestamps.add("Login: " + FUtil.dateToString(currentTime));
|
||||||
|
}
|
||||||
|
public void addLogout()
|
||||||
|
{
|
||||||
|
String lastLoginString = timestamps.get(timestamps.size() - 1);
|
||||||
|
Date currentTime = Date.from(Instant.now());
|
||||||
|
timestamps.add("Logout: " + FUtil.dateToString(currentTime));
|
||||||
|
lastLoginString = lastLoginString.replace("Login: ", "");
|
||||||
|
Date lastLogin = FUtil.stringToDate(lastLoginString);
|
||||||
|
|
||||||
|
long duration = currentTime.getTime() - lastLogin.getTime();
|
||||||
|
long seconds = duration / 1000 % 60;
|
||||||
|
long minutes = duration / (60 * 1000) % 60;
|
||||||
|
long hours = duration / (60 * 60 * 1000);
|
||||||
|
durations.add(hours + " hours, " + minutes + " minutes, and " + seconds + " seconds");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addIp(String ip)
|
||||||
|
{
|
||||||
|
if (!ips.contains(ip))
|
||||||
|
{
|
||||||
|
ips.add(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addIps(List<String> ips)
|
||||||
|
{
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
addIp(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeIp(String ip)
|
||||||
|
{
|
||||||
|
if (ips.contains(ip))
|
||||||
|
{
|
||||||
|
ips.remove(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearIPs()
|
||||||
|
{
|
||||||
|
ips.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return configKey != null
|
||||||
|
&& name != null;
|
||||||
|
}
|
||||||
|
}
|
@ -1,54 +1,91 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.Validate;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
public class Admin
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
|
||||||
private String configKey;
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String name;
|
private String name;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
|
||||||
private boolean active = true;
|
private boolean active = true;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Rank rank = Rank.SUPER_ADMIN;
|
private Rank rank = Rank.SUPER_ADMIN;
|
||||||
@Getter
|
@Getter
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
private final List<String> backupCodes = Lists.newArrayList();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private Date lastLogin = new Date();
|
private Date lastLogin = new Date();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private String loginMessage = null;
|
private String loginMessage = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String discordID = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String tag = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean commandSpy = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean potionSpy = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String acFormat = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean oldTags = false;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Boolean logStick = false;
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "admins.yml";
|
||||||
|
|
||||||
public Admin(Player player)
|
public Admin(Player player)
|
||||||
{
|
{
|
||||||
this.configKey = player.getName().toLowerCase();
|
|
||||||
this.name = player.getName();
|
this.name = player.getName();
|
||||||
this.ips.add(Ips.getIp(player));
|
this.ips.add(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Admin(String configKey)
|
public Admin(String username, List<String> ips, Rank rank, Boolean active, Date lastLogin, String loginMessage, String tag, String discordID, List<String> backupCodes, Boolean commandSpy, Boolean potionSpy, String acFormat, Boolean oldTags, Boolean logStick)
|
||||||
{
|
{
|
||||||
this.configKey = configKey;
|
this.name = username;
|
||||||
|
this.active = active;
|
||||||
|
this.rank = rank;
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(ips);
|
||||||
|
this.lastLogin = lastLogin;
|
||||||
|
this.loginMessage = loginMessage;
|
||||||
|
this.tag = tag;
|
||||||
|
this.discordID = discordID;
|
||||||
|
this.backupCodes.clear();
|
||||||
|
this.backupCodes.addAll(backupCodes);
|
||||||
|
this.commandSpy = commandSpy;
|
||||||
|
this.potionSpy = potionSpy;
|
||||||
|
this.acFormat = acFormat;
|
||||||
|
this.oldTags = oldTags;
|
||||||
|
this.logStick = logStick;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -61,41 +98,45 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
||||||
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
||||||
.append("- Rank: ").append(rank.getName()).append("\n")
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
.append("- Is Active: ").append(active);
|
.append("- Is Active: ").append(active).append("\n")
|
||||||
|
.append("- Discord ID: ").append(discordID).append("\n")
|
||||||
|
.append("- Tag: ").append(tag).append("\n").append(ChatColor.GRAY)
|
||||||
|
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
||||||
|
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
||||||
|
.append("- Old Tags: ").append(oldTags).append("\n")
|
||||||
|
.append("- Log Stick: ").append(logStick).append("\n")
|
||||||
|
.append("- Backup Codes: ").append(backupCodes.size()).append("/10");
|
||||||
|
|
||||||
return output.toString();
|
return output.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void loadFrom(Player player)
|
public void loadFrom(Player player)
|
||||||
{
|
{
|
||||||
configKey = player.getName().toLowerCase();
|
|
||||||
name = player.getName();
|
name = player.getName();
|
||||||
ips.clear();
|
ips.clear();
|
||||||
ips.add(Ips.getIp(player));
|
ips.add(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Map<String, Object> toSQLStorable()
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
{
|
||||||
name = cs.getString("username", configKey);
|
Map<String, Object> map = new HashMap<String, Object>()
|
||||||
active = cs.getBoolean("active", true);
|
{{
|
||||||
rank = Rank.findRank(cs.getString("rank"));
|
put("username", name);
|
||||||
ips.clear();
|
put("active", active);
|
||||||
ips.addAll(cs.getStringList("ips"));
|
put("rank", rank.toString());
|
||||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
put("ips", FUtil.listToString(ips));
|
||||||
loginMessage = cs.getString("login_message", null);
|
put("backup_codes", FUtil.listToString(backupCodes));
|
||||||
}
|
put("last_login", lastLogin.getTime());
|
||||||
|
put("login_message", loginMessage);
|
||||||
@Override
|
put("discord_id", discordID);
|
||||||
public void saveTo(ConfigurationSection cs)
|
put("tag", tag);
|
||||||
{
|
put("command_spy", commandSpy);
|
||||||
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
|
put("potion_spy", potionSpy);
|
||||||
cs.set("username", name);
|
put("ac_format", acFormat);
|
||||||
cs.set("active", active);
|
put("old_tags", oldTags);
|
||||||
cs.set("rank", rank.toString());
|
put("log_stick", logStick);
|
||||||
cs.set("ips", Lists.newArrayList(ips));
|
}};
|
||||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
return map;
|
||||||
cs.set("login_message", loginMessage);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAtLeast(Rank pRank)
|
public boolean isAtLeast(Rank pRank)
|
||||||
@ -138,11 +179,45 @@ public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
ips.clear();
|
ips.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public List<String> getBackupCodes()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(backupCodes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBackupCodes(List<String> codes)
|
||||||
|
{
|
||||||
|
backupCodes.clear();
|
||||||
|
backupCodes.addAll(codes);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeBackupCode(String code)
|
||||||
|
{
|
||||||
|
backupCodes.remove(code);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setActive(boolean active)
|
||||||
|
{
|
||||||
|
this.active = active;
|
||||||
|
|
||||||
|
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
|
||||||
|
|
||||||
|
if (!active)
|
||||||
|
{
|
||||||
|
if (getRank().isAtLeast(Rank.TELNET_ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
return configKey != null
|
return name != null
|
||||||
&& name != null
|
|
||||||
&& rank != null
|
&& rank != null
|
||||||
&& !ips.isEmpty()
|
&& !ips.isEmpty()
|
||||||
&& lastLogin != null;
|
&& lastLogin != null;
|
||||||
|
@ -3,14 +3,17 @@ package me.totalfreedom.totalfreedommod.admin;
|
|||||||
import com.google.common.base.Function;
|
import com.google.common.base.Function;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_logs;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -19,7 +22,6 @@ import net.pravian.aero.config.YamlConfig;
|
|||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.ServicePriority;
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
@ -29,12 +31,15 @@ public class AdminList extends FreedomService
|
|||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
public static final String CONFIG_FILENAME = "admins.yml";
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
|
private final Set<Admin> allAdmins = Sets.newHashSet(); // Includes disabled admins
|
||||||
// Only active admins below
|
// Only active admins below
|
||||||
@Getter
|
@Getter
|
||||||
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||||
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
|
public final List<String> verifiedNoAdmins = new ArrayList<>();
|
||||||
|
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
||||||
|
public static ArrayList<Player> vanished = new ArrayList<>();
|
||||||
//
|
//
|
||||||
private final YamlConfig config;
|
private final YamlConfig config;
|
||||||
|
|
||||||
@ -65,7 +70,6 @@ public class AdminList extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
@ -73,45 +77,49 @@ public class AdminList extends FreedomService
|
|||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
allAdmins.clear();
|
allAdmins.clear();
|
||||||
for (String key : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
ConfigurationSection section = config.getConfigurationSection(key);
|
ResultSet adminSet = plugin.sql.getAdminList();
|
||||||
if (section == null)
|
|
||||||
{
|
{
|
||||||
logger.warning("Invalid admin list format: " + key);
|
while (adminSet.next())
|
||||||
continue;
|
{
|
||||||
|
String name = adminSet.getString("username");
|
||||||
|
List<String> ips = FUtil.stringToList(adminSet.getString("ips"));
|
||||||
|
Rank rank = Rank.findRank(adminSet.getString("rank"));
|
||||||
|
Boolean active = adminSet.getBoolean("active");;
|
||||||
|
Date lastLogin = new Date(adminSet.getLong("last_login"));
|
||||||
|
String loginMessage = adminSet.getString("login_message");
|
||||||
|
String tag = adminSet.getString("tag");
|
||||||
|
String discordID = adminSet.getString("discord_id");
|
||||||
|
List<String> backupCodes = FUtil.stringToList(adminSet.getString("backup_codes"));
|
||||||
|
Boolean commandSpy = adminSet.getBoolean("command_spy");
|
||||||
|
Boolean potionSpy = adminSet.getBoolean("potion_spy");
|
||||||
|
String acFormat = adminSet.getString("ac_format");
|
||||||
|
Boolean oldTags = adminSet.getBoolean("old_tags");
|
||||||
|
Boolean logStick = adminSet.getBoolean("log_stick");
|
||||||
|
Admin admin = new Admin(name, ips, rank, active, lastLogin, loginMessage, tag, discordID, backupCodes, commandSpy, potionSpy, acFormat, oldTags, logStick);
|
||||||
|
allAdmins.add(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = new Admin(key);
|
|
||||||
admin.loadFrom(section);
|
|
||||||
|
|
||||||
if (!admin.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Could not load admin: " + key + ". Missing details!");
|
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
allAdmins.put(key, admin);
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get adminlist: " + e.getMessage());
|
||||||
}
|
}
|
||||||
|
|
||||||
updateTables();
|
updateTables();
|
||||||
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void save()
|
public void messageAllAdmins(String message)
|
||||||
{
|
{
|
||||||
// Clear the config
|
for (Player player : server.getOnlinePlayers())
|
||||||
for (String key : config.getKeys(false))
|
|
||||||
{
|
{
|
||||||
config.set(key, null);
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
player.sendMessage(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
|
||||||
{
|
|
||||||
admin.saveTo(config.createSection(admin.getConfigKey()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
config.save();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean isAdminSync(CommandSender sender)
|
public synchronized boolean isAdminSync(CommandSender sender)
|
||||||
@ -119,6 +127,16 @@ public class AdminList extends FreedomService
|
|||||||
return isAdmin(sender);
|
return isAdmin(sender);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<String> getActiveAdminNames()
|
||||||
|
{
|
||||||
|
List<String> names = new ArrayList();
|
||||||
|
for (Admin admin : activeAdmins)
|
||||||
|
{
|
||||||
|
names.add(admin.getName());
|
||||||
|
}
|
||||||
|
return names;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isAdmin(CommandSender sender)
|
public boolean isAdmin(CommandSender sender)
|
||||||
{
|
{
|
||||||
if (!(sender instanceof Player))
|
if (!(sender instanceof Player))
|
||||||
@ -169,13 +187,11 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
// Add the new IP if we have to
|
// Add the new IP if we have to
|
||||||
admin.addIp(ip);
|
admin.addIp(ip);
|
||||||
save();
|
save(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
return admin;
|
return admin;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Impostor
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Admin by ip
|
// Admin by ip
|
||||||
@ -183,8 +199,9 @@ public class AdminList extends FreedomService
|
|||||||
if (admin != null)
|
if (admin != null)
|
||||||
{
|
{
|
||||||
// Set the new username
|
// Set the new username
|
||||||
|
String oldName = admin.getName();
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
plugin.sql.updateAdminName(oldName, admin.getName());
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -230,12 +247,17 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
admin.setLastLogin(new Date());
|
admin.setLastLogin(new Date());
|
||||||
admin.setName(player.getName());
|
admin.setName(player.getName());
|
||||||
save();
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdminImpostor(Player player)
|
public boolean isAdminImpostor(Player player)
|
||||||
{
|
{
|
||||||
return getEntryByName(player.getName()) != null && !isAdmin(player);
|
return getEntryByName(player.getName()) != null && !isAdmin(player) && !isVerifiedAdmin(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isVerifiedAdmin(Player player)
|
||||||
|
{
|
||||||
|
return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(Ips.getIp(player));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIdentityMatched(Player player)
|
public boolean isIdentityMatched(Player player)
|
||||||
@ -253,35 +275,39 @@ public class AdminList extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!admin.isValid())
|
if (!admin.isValid())
|
||||||
{
|
{
|
||||||
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
|
logger.warning("Could not add admin: " + admin.getName() + " Admin is missing details!");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
final String key = admin.getConfigKey();
|
|
||||||
|
|
||||||
// Store admin, update views
|
// Store admin, update views
|
||||||
allAdmins.put(key, admin);
|
allAdmins.add(admin);
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// Save admin
|
// Save admin
|
||||||
admin.saveTo(config.createSection(key));
|
plugin.sql.addAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean removeAdmin(Admin admin)
|
public boolean removeAdmin(Admin admin)
|
||||||
{
|
{
|
||||||
|
if (admin.getRank().isAtLeast(Rank.TELNET_ADMIN))
|
||||||
|
{
|
||||||
|
if (plugin.btb != null)
|
||||||
|
{
|
||||||
|
plugin.btb.killTelnetSessions(admin.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Remove admin, update views
|
// Remove admin, update views
|
||||||
if (allAdmins.remove(admin.getConfigKey()) == null)
|
if (!allAdmins.remove(admin))
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
updateTables();
|
updateTables();
|
||||||
|
|
||||||
// 'Unsave' admin
|
// Unsave admin
|
||||||
config.set(admin.getConfigKey(), null);
|
plugin.sql.removeAdmin(admin);
|
||||||
config.save();
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -292,7 +318,7 @@ public class AdminList extends FreedomService
|
|||||||
nameTable.clear();
|
nameTable.clear();
|
||||||
ipTable.clear();
|
ipTable.clear();
|
||||||
|
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive())
|
if (!admin.isActive())
|
||||||
{
|
{
|
||||||
@ -322,9 +348,29 @@ public class AdminList extends FreedomService
|
|||||||
return ipTable.keySet();
|
return ipTable.keySet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void save(Admin admin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ResultSet currentSave = plugin.sql.getAdminByName(admin.getName());
|
||||||
|
for (Map.Entry<String, Object> entry : admin.toSQLStorable().entrySet())
|
||||||
|
{
|
||||||
|
Object storedValue = plugin.sql.getValue(currentSave, entry.getKey(), entry.getValue());
|
||||||
|
if (storedValue != null && !storedValue.equals(entry.getValue()) || storedValue == null && entry.getValue() != null)
|
||||||
|
{
|
||||||
|
plugin.sql.setAdminValue(admin, entry.getKey(), entry.getValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to save admin: " + e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void deactivateOldEntries(boolean verbose)
|
public void deactivateOldEntries(boolean verbose)
|
||||||
{
|
{
|
||||||
for (Admin admin : allAdmins.values())
|
for (Admin admin : allAdmins)
|
||||||
{
|
{
|
||||||
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||||
{
|
{
|
||||||
@ -341,14 +387,13 @@ public class AdminList extends FreedomService
|
|||||||
|
|
||||||
if (verbose)
|
if (verbose)
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedomMod", "Deactivating superadmin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
FUtil.adminAction("TotalFreedomMod", "Deactivating admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
admin.setActive(false);
|
admin.setActive(false);
|
||||||
plugin.lv.deactivateSuperadmin(admin);
|
save(admin);
|
||||||
}
|
}
|
||||||
|
|
||||||
save();
|
|
||||||
updateTables();
|
updateTables();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
|
import java.text.DateFormat;
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -12,16 +15,13 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
import net.pravian.aero.base.Validatable;
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
public class Ban implements Validatable
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
@ -36,6 +36,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
private String by = null;
|
private String by = null;
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
|
private Date at = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -45,27 +48,26 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String ip, String by, Date expire, String reason)
|
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
new String[]
|
Arrays.asList(ip),
|
||||||
{
|
|
||||||
ip
|
|
||||||
},
|
|
||||||
by,
|
by,
|
||||||
|
at,
|
||||||
expire,
|
expire,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String[] ips, String by, Date expire, String reason)
|
public Ban(String username, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
if (ips != null)
|
if (ips != null)
|
||||||
{
|
{
|
||||||
this.ips.addAll(Arrays.asList(ips));
|
this.ips.addAll(ips);
|
||||||
}
|
}
|
||||||
dedupeIps();
|
dedupeIps();
|
||||||
this.by = by;
|
this.by = by;
|
||||||
|
this.at = at;
|
||||||
this.expiryUnix = FUtil.getUnixTime(expire);
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
@ -79,15 +81,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, new String[]
|
return new Ban(null, Arrays.asList(Ips.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
{
|
|
||||||
Ips.getIp(player)
|
|
||||||
}, by.getName(), expiry, reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, ip, by.getName(), expiry, reason);
|
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -100,8 +99,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player,
|
return new Ban(player,
|
||||||
(String[]) null,
|
new ArrayList<String>(),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
@ -118,6 +118,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
Ips.getIp(player),
|
Ips.getIp(player),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
@ -127,6 +128,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
FUtil.getFuzzyIp(Ips.getIp(player)),
|
FUtil.getFuzzyIp(Ips.getIp(player)),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
@ -156,11 +158,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return expiryUnix > 0;
|
return expiryUnix > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Date getExpiryDate()
|
|
||||||
{
|
|
||||||
return FUtil.getUnixDate(expiryUnix);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isExpired()
|
public boolean isExpired()
|
||||||
{
|
{
|
||||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
@ -186,6 +183,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append(by);
|
.append(by);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (at != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Issued: ").append(ChatColor.GOLD)
|
||||||
|
.append(DATE_FORMAT.format(at));
|
||||||
|
}
|
||||||
|
|
||||||
if (getExpiryUnix() != 0)
|
if (getExpiryUnix() != 0)
|
||||||
{
|
{
|
||||||
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
||||||
@ -210,7 +213,7 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
final Ban ban = (Ban)object;
|
final Ban ban = (Ban)object;
|
||||||
if (hasIps() != ban.hasIps()
|
if (hasIps() != ban.hasIps()
|
||||||
|| hasUsername() != hasUsername())
|
|| hasUsername() != ban.hasUsername())
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -232,29 +235,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return hash;
|
return hash;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void loadFrom(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
this.username = cs.getString("username", null);
|
|
||||||
this.ips.clear();
|
|
||||||
this.ips.addAll(cs.getStringList("ips"));
|
|
||||||
this.by = cs.getString("by", null);
|
|
||||||
this.reason = cs.getString("reason", null);
|
|
||||||
this.expiryUnix = cs.getLong("expiry_unix", 0);
|
|
||||||
dedupeIps();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void saveTo(ConfigurationSection cs)
|
|
||||||
{
|
|
||||||
dedupeIps();
|
|
||||||
cs.set("username", username);
|
|
||||||
cs.set("ips", ips.isEmpty() ? null : ips);
|
|
||||||
cs.set("by", by);
|
|
||||||
cs.set("reason", reason);
|
|
||||||
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isValid()
|
public boolean isValid()
|
||||||
{
|
{
|
||||||
|
@ -3,8 +3,12 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.Date;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@ -15,7 +19,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
import net.pravian.aero.util.Ips;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -30,40 +33,39 @@ public class BanManager extends FreedomService
|
|||||||
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
|
|
||||||
//
|
//
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public BanManager(TotalFreedomMod plugin)
|
public BanManager(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
this.config = new YamlConfig(plugin, "bans.yml");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
bans.clear();
|
bans.clear();
|
||||||
for (String id : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
if (!config.isConfigurationSection(id))
|
ResultSet banSet = plugin.sql.getBanList();
|
||||||
{
|
{
|
||||||
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
while (banSet.next())
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Ban ban = new Ban();
|
|
||||||
ban.loadFrom(config.getConfigurationSection(id));
|
|
||||||
|
|
||||||
if (!ban.isValid())
|
|
||||||
{
|
{
|
||||||
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
String name = banSet.getString("name");
|
||||||
continue;
|
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||||
}
|
String by = banSet.getString("by");
|
||||||
|
Date at = new Date(banSet.getLong("at"));
|
||||||
|
Date expires = new Date(banSet.getLong("expires"));
|
||||||
|
String reason = banSet.getString("reason");
|
||||||
|
Ban ban = new Ban(name, ips, by, at, expires, reason);
|
||||||
bans.add(ban);
|
bans.add(ban);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
// Remove expired bans, repopulate ipBans and nameBans,
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
updateViews();
|
updateViews();
|
||||||
@ -79,8 +81,6 @@ public class BanManager extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
saveAll();
|
|
||||||
logger.info("Saved " + bans.size() + " player bans");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Ban> getAllBans()
|
public Set<Ban> getAllBans()
|
||||||
@ -98,21 +98,6 @@ public class BanManager extends FreedomService
|
|||||||
return Collections.unmodifiableCollection(nameBans.values());
|
return Collections.unmodifiableCollection(nameBans.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll()
|
|
||||||
{
|
|
||||||
// Remove expired
|
|
||||||
updateViews();
|
|
||||||
|
|
||||||
config.clear();
|
|
||||||
for (Ban ban : bans)
|
|
||||||
{
|
|
||||||
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save config
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ban getByIp(String ip)
|
public Ban getByIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban directBan = ipBans.get(ip);
|
final Ban directBan = ipBans.get(ip);
|
||||||
@ -166,7 +151,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -179,7 +163,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -197,9 +180,14 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public boolean addBan(Ban ban)
|
||||||
{
|
{
|
||||||
|
if (getByUsername(ban.getUsername()) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
if (bans.add(ban))
|
if (bans.add(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.addBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -210,7 +198,8 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
if (bans.remove(ban))
|
if (bans.remove(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.removeBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -219,17 +208,14 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public int purge()
|
public int purge()
|
||||||
{
|
{
|
||||||
config.clear();
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
int size = bans.size();
|
int size = bans.size();
|
||||||
bans.clear();
|
bans.clear();
|
||||||
updateViews();
|
updateViews();
|
||||||
|
plugin.sql.truncate("bans");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final String username = event.getPlayer().getName();
|
final String username = event.getPlayer().getName();
|
||||||
@ -248,7 +234,7 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
@ -273,11 +259,12 @@ public class BanManager extends FreedomService
|
|||||||
private void updateViews()
|
private void updateViews()
|
||||||
{
|
{
|
||||||
// Remove expired bans
|
// Remove expired bans
|
||||||
for (Iterator<Ban> it = bans.iterator(); it.hasNext();)
|
for (Ban ban : new ArrayList<>(bans))
|
||||||
{
|
{
|
||||||
if (it.next().isExpired())
|
if (ban.isExpired())
|
||||||
{
|
{
|
||||||
it.remove();
|
bans.remove(ban);
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -87,4 +87,13 @@ public class PermbanList extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Set<String> getPermbannedNames()
|
||||||
|
{
|
||||||
|
return this.permbannedNames;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getPermbannedIps()
|
||||||
|
{
|
||||||
|
return this.permbannedIps;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,25 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Banner;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Skull;
|
||||||
|
import org.bukkit.block.banner.Pattern;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
import org.bukkit.inventory.meta.SkullMeta;
|
||||||
|
|
||||||
public class BlockBlocker extends FreedomService
|
public class BlockBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@ -39,33 +47,18 @@ public class BlockBlocker extends FreedomService
|
|||||||
switch (event.getBlockPlaced().getType())
|
switch (event.getBlockPlaced().getType())
|
||||||
{
|
{
|
||||||
case LAVA:
|
case LAVA:
|
||||||
case STATIONARY_LAVA:
|
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case WATER:
|
case WATER:
|
||||||
case STATIONARY_WATER:
|
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
@ -76,39 +69,120 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case FIRE:
|
case FIRE:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TNT:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
|
|
||||||
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
|
||||||
player.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case JIGSAW:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_JIGSAWS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Jigsaws are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GRINDSTONE:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_GRINDSTONES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Grindstones are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case JUKEBOX:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_JUKEBOXES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Jukeboxes are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SPAWNER:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_SPAWNERS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Spawners are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BEEHIVE:
|
||||||
|
case BEE_NEST:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case PLAYER_HEAD:
|
||||||
|
case PLAYER_WALL_HEAD:
|
||||||
|
{
|
||||||
|
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||||
|
if (skull.hasOwner())
|
||||||
|
{
|
||||||
|
if (skull.getOwner().contains("\u00A7"))
|
||||||
|
{
|
||||||
|
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||||
|
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||||
|
if (meta != null)
|
||||||
|
{
|
||||||
|
ItemStack newHead = new ItemStack(Material.PLAYER_HEAD, 1);
|
||||||
|
ItemMeta headMeta = newHead.getItemMeta();
|
||||||
|
headMeta.setDisplayName(ChatColor.YELLOW + "C-sectioned Head");
|
||||||
|
newHead.setItemMeta(headMeta);
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), newHead);
|
||||||
|
player.sendMessage(ChatColor.GRAY + "The player head you are attempting to place has a section symbol. Your player head has been C-sectioned.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (skull.getOwner().length() > 100)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Instead of using Pi to crash players, be useful with your life and use it to discover things.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
||||||
|
{
|
||||||
|
Banner banner = (Banner) event.getBlockPlaced().getState();
|
||||||
|
List<Pattern> patterns = banner.getPatterns();
|
||||||
|
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
|
||||||
|
List<Pattern> handPatterns = banner.getPatterns();
|
||||||
|
if (patterns.size() >= 2)
|
||||||
|
{
|
||||||
|
banner.setPatterns(patterns.subList(0, 2));
|
||||||
|
handBanner.setPatterns(handPatterns.subList(0, 2));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
@ -0,0 +1,69 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
public class EditBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public EditBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
|
if (!fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to place blocks has been disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
|
if (!fPlayer.isEditBlocked())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setEditBlocked(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "Your ability to destroy blocks has been disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,25 +1,37 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.EntityType;
|
|
||||||
import org.bukkit.entity.Projectile;
|
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
import org.bukkit.event.entity.ProjectileHitEvent;
|
import org.bukkit.event.entity.FireworkExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
import org.bukkit.event.player.PlayerDropItemEvent;
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
import org.bukkit.event.player.PlayerRespawnEvent;
|
||||||
|
|
||||||
public class EventBlocker extends FreedomService
|
public class EventBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@ -71,7 +83,7 @@ public class EventBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.blockList().clear();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -108,19 +120,6 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
|
||||||
public void onProjectileHit(ProjectileHitEvent event)
|
|
||||||
{
|
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
Projectile entity = event.getEntity();
|
|
||||||
if (event.getEntityType() == EntityType.ARROW)
|
|
||||||
{
|
|
||||||
entity.getWorld().createExplosion(entity.getLocation(), 2F);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onEntityDamage(EntityDamageEvent event)
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
{
|
{
|
||||||
@ -152,6 +151,11 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
|
if (!plugin.al.isAdmin(event.getPlayer()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
@ -169,4 +173,74 @@ public class EventBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockGrowth(BlockGrowEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onFireworkExplode(FireworkExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIREWORK_EXPLOSION.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPistonRetract(BlockPistonRetractEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPistonExtend(BlockPistonExtendEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setNewCurrent(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
|
{
|
||||||
|
double maxHealth = event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getValue();
|
||||||
|
if (maxHealth < 1)
|
||||||
|
{
|
||||||
|
for (AttributeModifier attributeModifier : event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).getModifiers())
|
||||||
|
{
|
||||||
|
event.getPlayer().getAttribute(Attribute.GENERIC_MAX_HEALTH).removeModifier(attributeModifier);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockDispense(BlockDispenseEvent event)
|
||||||
|
{
|
||||||
|
List<Material> banned = Arrays.asList(Material.TNT_MINECART, Material.MINECART);
|
||||||
|
if (Groups.SPAWN_EGGS.contains(event.getItem().getType()) || banned.contains(event.getItem().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event)
|
||||||
|
{
|
||||||
|
FUtil.fixCommandVoid(event.getEntity());
|
||||||
|
event.setDeathMessage(event.getDeathMessage());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,9 +3,11 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Biome;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -33,9 +35,6 @@ public class InteractBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onPlayerInteract(PlayerInteractEvent event)
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
|
||||||
|
|
||||||
switch (event.getAction())
|
switch (event.getAction())
|
||||||
{
|
{
|
||||||
case RIGHT_CLICK_AIR:
|
case RIGHT_CLICK_AIR:
|
||||||
@ -54,10 +53,49 @@ public class InteractBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onRightClickBell(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock() != null)
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock().getType().equals(Material.BELL))
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_BELLS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void handleRightClick(PlayerInteractEvent event)
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (event.getClickedBlock() != null)
|
||||||
|
{
|
||||||
|
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
event.getPlayer().closeInventory();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Groups.SPAWN_EGGS.contains(event.getMaterial()))
|
||||||
|
{
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Spawn eggs are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Groups.BED_COLORS.contains(event.getMaterial()) && event.getClickedBlock().getBiome().equals(Biome.NETHER))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You can't sleep in hell.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
switch (event.getMaterial())
|
switch (event.getMaterial())
|
||||||
{
|
{
|
||||||
case WATER_BUCKET:
|
case WATER_BUCKET:
|
||||||
@ -86,7 +124,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case EXPLOSIVE_MINECART:
|
case TNT_MINECART:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||||
{
|
{
|
||||||
@ -98,6 +136,38 @@ public class InteractBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
case ARMOR_STAND:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_ARMOR_STANDS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Armor stands are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case MINECART:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_MINECARTS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Minecarts are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WRITTEN_BOOK:
|
||||||
|
{
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,16 +3,22 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.attribute.Attributable;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
import org.bukkit.entity.EnderDragon;
|
import org.bukkit.entity.EnderDragon;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Ghast;
|
import org.bukkit.entity.Ghast;
|
||||||
import org.bukkit.entity.Giant;
|
import org.bukkit.entity.Giant;
|
||||||
import org.bukkit.entity.HumanEntity;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Slime;
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.entity.Wither;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.CreatureSpawnEvent;
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
|
|
||||||
public class MobBlocker extends FreedomService
|
public class MobBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@ -32,6 +38,29 @@ public class MobBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//fixes crash mobs, credit to Mafrans
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onEntitySpawn(EntitySpawnEvent e)
|
||||||
|
{
|
||||||
|
if (!(e instanceof LivingEntity))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Entity entity = e.getEntity();
|
||||||
|
if (entity instanceof Attributable)
|
||||||
|
{
|
||||||
|
if (((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).getBaseValue() > 255.0)
|
||||||
|
{
|
||||||
|
((Attributable)entity).getAttribute(Attribute.GENERIC_FOLLOW_RANGE).setBaseValue(255.0);
|
||||||
|
}
|
||||||
|
if (((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).getBaseValue() > 10.0)
|
||||||
|
{
|
||||||
|
((Attributable)entity).getAttribute(Attribute.GENERIC_MOVEMENT_SPEED).setBaseValue(10.0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onCreatureSpawn(CreatureSpawnEvent event)
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
{
|
{
|
||||||
@ -41,6 +70,7 @@ public class MobBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Entity spawned = event.getEntity();
|
final Entity spawned = event.getEntity();
|
||||||
|
|
||||||
if (spawned instanceof EnderDragon)
|
if (spawned instanceof EnderDragon)
|
||||||
{
|
{
|
||||||
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
@ -65,6 +95,14 @@ public class MobBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (spawned instanceof Wither)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (spawned instanceof Giant)
|
else if (spawned instanceof Giant)
|
||||||
{
|
{
|
||||||
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
||||||
@ -89,7 +127,7 @@ public class MobBlocker extends FreedomService
|
|||||||
int mobcount = 0;
|
int mobcount = 0;
|
||||||
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
||||||
{
|
{
|
||||||
if (!(entity instanceof HumanEntity))
|
if (!(entity instanceof HumanEntity) && entity instanceof LivingEntity)
|
||||||
{
|
{
|
||||||
mobcount++;
|
mobcount++;
|
||||||
}
|
}
|
||||||
@ -100,5 +138,4 @@ public class MobBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,97 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Arrow;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Trident;
|
||||||
|
import org.bukkit.entity.FishHook;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
|
public class PVPBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public PVPBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onEntityDamageByEntity(EntityDamageByEntityEvent event)
|
||||||
|
{
|
||||||
|
Player player = null;
|
||||||
|
Player target = null;
|
||||||
|
if (event.getEntity() instanceof Player)
|
||||||
|
{
|
||||||
|
target = (Player)event.getEntity();
|
||||||
|
if (event.getDamager() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)event.getDamager();
|
||||||
|
}
|
||||||
|
else if (event.getDamager() instanceof Arrow)
|
||||||
|
{
|
||||||
|
Arrow arrow = (Arrow)event.getDamager();
|
||||||
|
if (arrow.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)arrow.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getDamager() instanceof Trident)
|
||||||
|
{
|
||||||
|
Trident trident = (Trident)event.getDamager();
|
||||||
|
if (trident.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)trident.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (event.getDamager() instanceof FishHook)
|
||||||
|
{
|
||||||
|
FishHook fishhook = (FishHook)event.getDamager();
|
||||||
|
if (fishhook.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)fishhook.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null & !plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "Creative PvP is not allowed!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.esb.getEssentialsUser(player.getName()).isGodModeEnabled())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "God mode PvP is not allowed!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(target).isPvpBlocked())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + target.getName() + " has PvP disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
else if (plugin.pl.getPlayer(player).isPvpBlocked())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You have PvP disabled!");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,12 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.Collection;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
public class PotionBlocker extends FreedomService
|
public class PotionBlocker extends FreedomService
|
||||||
@ -32,31 +37,56 @@ public class PotionBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
public void onThrowPotion(PotionSplashEvent event)
|
public void onThrowPotion(PotionSplashEvent event)
|
||||||
{
|
{
|
||||||
ProjectileSource source = event.getEntity().getShooter();
|
ThrownPotion potion = event.getEntity();
|
||||||
|
ProjectileSource projectileSource = potion.getShooter();
|
||||||
if (!(source instanceof Player))
|
Player player = null;
|
||||||
|
if (projectileSource instanceof Player)
|
||||||
{
|
{
|
||||||
|
player = (Player)projectileSource;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isDeathPotion(potion.getEffects()))
|
||||||
|
{
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You are not allowed to use death potions.");
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Player thrower = (Player) source;
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onThrowLingeringPotion(LingeringPotionSplashEvent event)
|
||||||
if (plugin.al.isAdmin(thrower))
|
|
||||||
{
|
{
|
||||||
return;
|
ThrownPotion potion = event.getEntity();
|
||||||
|
ProjectileSource projectileSource = potion.getShooter();
|
||||||
|
Player player = null;
|
||||||
|
if (projectileSource instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)projectileSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player player : thrower.getWorld().getPlayers())
|
if (isDeathPotion(potion.getEffects()))
|
||||||
{
|
{
|
||||||
if (thrower.getLocation().distanceSquared(player.getLocation()) < POTION_BLOCK_RADIUS_SQUARED)
|
if (player != null)
|
||||||
{
|
{
|
||||||
thrower.sendMessage(ChatColor.RED + "You cannot use splash potions close to other players.");
|
player.sendMessage(ChatColor.RED + "You are not allowed to use death potions.");
|
||||||
|
}
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isDeathPotion(Collection<PotionEffect> effects)
|
||||||
|
{
|
||||||
|
for (PotionEffect effect : effects)
|
||||||
|
{
|
||||||
|
int amplifier = effect.getAmplifier();
|
||||||
|
if (effect.getType().equals(PotionEffectType.HEAL) && (amplifier == 29 || amplifier == 61 || amplifier == 93 || amplifier == 125))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,84 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.Tag;
|
||||||
|
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.Action;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
//codebeat:disable[LOC,ABC]
|
||||||
|
|
||||||
|
public class SignBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public SignBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerPlaceBlock(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||||
|
{
|
||||||
|
ItemStack sign = event.getItemInHand();
|
||||||
|
net.minecraft.server.v1_15_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
|
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||||
|
String line1 = bet.getString("Text1");
|
||||||
|
String line2 = bet.getString("Text2");
|
||||||
|
String line3 = bet.getString("Text3");
|
||||||
|
String line4 = bet.getString("Text4");
|
||||||
|
if (line1.contains("run_command") || line2.contains("run_command") || line3.contains("run_command") || line4.contains("run_command"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (line1.contains("translate") || line2.contains("translate") || line3.contains("translate") || line4.contains("translate"))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "You are not allowed to place broken strings that Mojang never fixed.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
if (line1.contains("translation.test.") || line2.contains("translation.test.") || line3.contains("translation.test.") || line4.contains("translation.test."))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.BOLD + "No.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerInteractSign(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
if (event.getAction() != Action.RIGHT_CLICK_BLOCK)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getClickedBlock() != null && Tag.SIGNS.getValues().contains(event.getClickedBlock().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -12,7 +12,8 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.CommandReflection;
|
import net.pravian.aero.command.CommandReflection;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -129,6 +130,12 @@ public class CommandBlocker extends FreedomService
|
|||||||
// CommandBlocker handles messages and broadcasts
|
// CommandBlocker handles messages and broadcasts
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (event.getMessage().contains("translation.test.invalid") || event.getMessage().contains("translation.test.invalid2"))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
FUtil.playerMsg(event.getPlayer(), ChatColor.RED + "No crishy crashy faggy");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
@ -160,6 +167,11 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
for (String part : commandParts)
|
for (String part : commandParts)
|
||||||
{
|
{
|
||||||
|
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
Matcher matcher = flagPattern.matcher(part);
|
Matcher matcher = flagPattern.matcher(part);
|
||||||
if (!matcher.matches())
|
if (!matcher.matches())
|
||||||
{
|
{
|
||||||
|
@ -6,6 +6,7 @@ import me.totalfreedom.totalfreedommod.util.FUtil;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class CommandBlockerEntry
|
public class CommandBlockerEntry
|
||||||
{
|
{
|
||||||
@ -31,8 +32,8 @@ public class CommandBlockerEntry
|
|||||||
this.rank = rank;
|
this.rank = rank;
|
||||||
this.action = action;
|
this.action = action;
|
||||||
this.command = command;
|
this.command = command;
|
||||||
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim());
|
this.subCommand = ((subCommand == null) ? null : subCommand.toLowerCase().trim());
|
||||||
this.message = (message == null || message.equals("_") ? "That command is blocked." : message);
|
this.message = ((message == null || message.equals("_")) ? "That command is blocked." : message);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void doActions(CommandSender sender)
|
public void doActions(CommandSender sender)
|
||||||
@ -43,13 +44,11 @@ public class CommandBlockerEntry
|
|||||||
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
|
sender.sendMessage(SpigotConfig.unknownCommandMessage);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.playerMsg(sender, FUtil.colorize(message));
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,21 +1,29 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class BukkitTelnetBridge extends FreedomService
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
@ -94,4 +102,87 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
playerTags.put("tfm.essentialsBridge.getNickname", plugin.esb.getNickname(player.getName()));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public BukkitTelnet getBukkitTelnetPlugin()
|
||||||
|
{
|
||||||
|
if (bukkitTelnetPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin bukkitTelnet = server.getPluginManager().getPlugin("BukkitTelnet");
|
||||||
|
if (bukkitTelnet != null)
|
||||||
|
{
|
||||||
|
if (bukkitTelnet instanceof BukkitTelnet)
|
||||||
|
{
|
||||||
|
bukkitTelnetPlugin = (BukkitTelnet)bukkitTelnet;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return bukkitTelnetPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Admin> getConnectedAdmins()
|
||||||
|
{
|
||||||
|
List<Admin> admins = new ArrayList<>();
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
|
{
|
||||||
|
Admin admin = plugin.al.getEntryByName(session.getUserName().toLowerCase());
|
||||||
|
if (admin != null && !admins.contains(admin))
|
||||||
|
{
|
||||||
|
admins.add(admin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return admins;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void killTelnetSessions(final String name)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final List<ClientSession> sessionsToRemove = new ArrayList<>();
|
||||||
|
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
final Iterator<ClientSession> it = telnet.appender.getSessions().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final ClientSession session = it.next();
|
||||||
|
if (name != null && name.equalsIgnoreCase(session.getUserName()))
|
||||||
|
{
|
||||||
|
sessionsToRemove.add(session);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (final ClientSession session : sessionsToRemove)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
telnet.appender.removeSession(session);
|
||||||
|
session.syncTerminateSession();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing single telnet session: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info(sessionsToRemove.size() + " telnet session(s) removed.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Error removing telnet sessions: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,226 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.sql.Connection;
|
||||||
|
import java.sql.DriverManager;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.sql.Statement;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class CoreProtectBridge extends FreedomService
|
||||||
|
{
|
||||||
|
private CoreProtectAPI coreProtectAPI = null;
|
||||||
|
|
||||||
|
private final List<String> tables = Arrays.asList("co_sign", "co_session", "co_container", "co_block");
|
||||||
|
|
||||||
|
private BukkitTask wiper;
|
||||||
|
|
||||||
|
public CoreProtectBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtect getCoreProtect()
|
||||||
|
{
|
||||||
|
CoreProtect coreProtect = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin coreProtectPlugin = Bukkit.getServer().getPluginManager().getPlugin("CoreProtect");
|
||||||
|
|
||||||
|
if (coreProtectPlugin != null && coreProtectPlugin instanceof CoreProtect)
|
||||||
|
{
|
||||||
|
coreProtect = (CoreProtect)coreProtectPlugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return coreProtect;
|
||||||
|
}
|
||||||
|
|
||||||
|
public CoreProtectAPI getCoreProtectAPI()
|
||||||
|
{
|
||||||
|
if (coreProtectAPI == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
coreProtectAPI = coreProtect.getAPI();
|
||||||
|
|
||||||
|
// Check if the plugin or api is not enabled, if so, return null
|
||||||
|
if (!coreProtect.isEnabled() || !coreProtectAPI.isEnabled())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return coreProtectAPI;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
return coreProtect != null && coreProtect.isEnabled();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Rollback the specified player's edits that were in the last 24 hours.
|
||||||
|
public void rollback(final String name)
|
||||||
|
{
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Reverts a rollback for the specified player's edits that were in the last 24 hours.
|
||||||
|
public void restore(final String name)
|
||||||
|
{
|
||||||
|
final CoreProtectAPI coreProtect = getCoreProtectAPI();
|
||||||
|
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public File getDatabase()
|
||||||
|
{
|
||||||
|
if (!isEnabled())
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (new File(getCoreProtect().getDataFolder(), "database.db"));
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getDBSize()
|
||||||
|
{
|
||||||
|
double bytes = getDatabase().length();
|
||||||
|
double kilobytes = (bytes / 1024);
|
||||||
|
double megabytes = (kilobytes / 1024);
|
||||||
|
return (megabytes / 1024);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wipes DB for the specified world
|
||||||
|
public void clearDatabase(World world)
|
||||||
|
{
|
||||||
|
clearDatabase(world, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wipes DB for the specified world
|
||||||
|
public void clearDatabase(World world, Boolean shutdown)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.COREPROTECT_MYSQL_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final CoreProtect coreProtect = getCoreProtect();
|
||||||
|
|
||||||
|
if (coreProtect == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* As CoreProtect doesn't have an API method for deleting all of the data for a specific world
|
||||||
|
we have to do this manually via SQL */
|
||||||
|
Connection connection = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String host = ConfigEntry.COREPROTECT_MYSQL_HOST.getString();
|
||||||
|
String port = ConfigEntry.COREPROTECT_MYSQL_PORT.getString();
|
||||||
|
String username = ConfigEntry.COREPROTECT_MYSQL_USERNAME.getString();
|
||||||
|
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
||||||
|
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||||
|
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||||
|
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||||
|
final Statement statement = connection.createStatement();
|
||||||
|
statement.setQueryTimeout(30);
|
||||||
|
|
||||||
|
// Obtain world ID from CoreProtect database
|
||||||
|
ResultSet resultSet = statement.executeQuery("SELECT id FROM co_world WHERE world = '" + world.getName() + "'");
|
||||||
|
String worldID = null;
|
||||||
|
while (resultSet.next())
|
||||||
|
{
|
||||||
|
worldID = String.valueOf(resultSet.getInt("id"));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ensure the world ID is not null
|
||||||
|
|
||||||
|
if (worldID == null)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Iterate through each table and delete their data if the world ID matches
|
||||||
|
for (String table : tables)
|
||||||
|
{
|
||||||
|
statement.executeQuery("DELETE FROM " + table + " WHERE wid = " + worldID);
|
||||||
|
}
|
||||||
|
|
||||||
|
connection.close();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (SQLException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to delete the CoreProtect data for the " + world.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
// This exits for flatlands wipes
|
||||||
|
if (shutdown)
|
||||||
|
{
|
||||||
|
server.shutdown();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -4,10 +4,22 @@ import com.earth2me.essentials.Essentials;
|
|||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.inventory.InventoryClickEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryCloseEvent;
|
||||||
|
import org.bukkit.event.inventory.InventoryType;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.InventoryHolder;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
public class EssentialsBridge extends FreedomService
|
public class EssentialsBridge extends FreedomService
|
||||||
{
|
{
|
||||||
@ -35,15 +47,12 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
final Plugin essentials = server.getPluginManager().getPlugin("Essentials");
|
||||||
if (essentials != null)
|
if (essentials != null && essentials instanceof Essentials)
|
||||||
{
|
|
||||||
if (essentials instanceof Essentials)
|
|
||||||
{
|
{
|
||||||
essentialsPlugin = (Essentials)essentials;
|
essentialsPlugin = (Essentials)essentials;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
@ -56,7 +65,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Essentials essentials = getEssentialsPlugin();
|
Essentials essentials = getEssentialsPlugin();
|
||||||
if (essentials != null)
|
if (essentials != null)
|
||||||
{
|
{
|
||||||
return essentials.getUserMap().getUser(username);
|
return essentials.getUserMap().getUser(username);
|
||||||
@ -73,7 +82,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
user.setNickname(nickname);
|
user.setNickname(nickname);
|
||||||
@ -90,7 +99,7 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return user.getNickname();
|
return user.getNickname();
|
||||||
@ -107,10 +116,10 @@ public class EssentialsBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final User user = getEssentialsUser(username);
|
User user = getEssentialsUser(username);
|
||||||
if (user != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return FUtil.<Long>getField(user, "lastActivity"); // This is weird
|
return FUtil.getField(user, "lastActivity");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@ -120,20 +129,96 @@ public class EssentialsBridge extends FreedomService
|
|||||||
return 0L;
|
return 0L;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEssentialsEnabled()
|
public void setVanished(String username, boolean vanished)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
final Essentials essentials = getEssentialsPlugin();
|
User user = getEssentialsUser(username);
|
||||||
if (essentials != null)
|
if (user != null)
|
||||||
{
|
{
|
||||||
return essentials.isEnabled();
|
user.setVanished(vanished);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
FLog.severe(ex);
|
FLog.severe(ex);
|
||||||
}
|
}
|
||||||
return false;
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onInventoryClick(InventoryClickEvent event)
|
||||||
|
{
|
||||||
|
Player refreshPlayer = null;
|
||||||
|
Inventory inventory = event.getView().getTopInventory();
|
||||||
|
InventoryType inventoryType = inventory.getType();
|
||||||
|
Player player = (Player)event.getWhoClicked();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
|
{
|
||||||
|
final InventoryHolder inventoryHolder = inventory.getHolder();
|
||||||
|
if (inventoryHolder != null && inventoryHolder instanceof HumanEntity)
|
||||||
|
{
|
||||||
|
Player invOwner = (Player)inventoryHolder;
|
||||||
|
Rank recieverRank = plugin.rm.getRank(player);
|
||||||
|
Rank playerRank = plugin.rm.getRank(invOwner);
|
||||||
|
if (playerRank.ordinal() >= recieverRank.ordinal() || !invOwner.isOnline())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
refreshPlayer = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (refreshPlayer != null)
|
||||||
|
{
|
||||||
|
final Player p = refreshPlayer;
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
p.updateInventory();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onInventoryClose(InventoryCloseEvent event)
|
||||||
|
{
|
||||||
|
Player refreshPlayer = null;
|
||||||
|
Inventory inventory = event.getView().getTopInventory();
|
||||||
|
InventoryType inventoryType = inventory.getType();
|
||||||
|
Player player = (Player)event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (inventoryType == InventoryType.PLAYER && fPlayer.isInvSee())
|
||||||
|
{
|
||||||
|
fPlayer.setInvSee(false);
|
||||||
|
refreshPlayer = player;
|
||||||
|
}
|
||||||
|
if (refreshPlayer != null)
|
||||||
|
{
|
||||||
|
final Player p = refreshPlayer;
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
p.updateInventory();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final Essentials ess = getEssentialsPlugin();
|
||||||
|
|
||||||
|
return ess != null && ess.isEnabled();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,125 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class LibsDisguisesBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private LibsDisguises libsDisguisesPlugin = null;
|
||||||
|
|
||||||
|
public LibsDisguisesBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public LibsDisguises getLibsDisguisesPlugin()
|
||||||
|
{
|
||||||
|
if (libsDisguisesPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin libsDisguises = server.getPluginManager().getPlugin("LibsDisguises");
|
||||||
|
if (libsDisguises != null)
|
||||||
|
{
|
||||||
|
if (libsDisguises instanceof LibsDisguises)
|
||||||
|
{
|
||||||
|
libsDisguisesPlugin = (LibsDisguises)libsDisguises;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return libsDisguisesPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean isDisguised(Player player)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
if (libsDisguises != null)
|
||||||
|
{
|
||||||
|
return DisguiseAPI.isDisguised(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void undisguiseAll(boolean admins)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (DisguiseAPI.isDisguised(player))
|
||||||
|
{
|
||||||
|
if (!admins && plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
DisguiseAPI.undisguiseToAll(player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setDisguisesEnabled(boolean state)
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (libsDisguises == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BlockedDisguises.disabled = !state;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !BlockedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
return libsDisguises != null && libsDisguises.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
@ -12,26 +12,46 @@ import org.bukkit.plugin.Plugin;
|
|||||||
public class WorldEditBridge extends FreedomService
|
public class WorldEditBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private final WorldEditListener listener;
|
|
||||||
//
|
//
|
||||||
private WorldEditPlugin worldedit = null;
|
private WorldEditPlugin worldeditPlugin = null;
|
||||||
|
|
||||||
public WorldEditBridge(TotalFreedomMod plugin)
|
public WorldEditBridge(TotalFreedomMod plugin)
|
||||||
{
|
{
|
||||||
super(plugin);
|
super(plugin);
|
||||||
listener = new WorldEditListener(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
protected void onStart()
|
||||||
{
|
{
|
||||||
listener.register();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
protected void onStop()
|
||||||
{
|
{
|
||||||
listener.unregister();
|
}
|
||||||
|
|
||||||
|
public WorldEditPlugin getWorldEditPlugin()
|
||||||
|
{
|
||||||
|
if (worldeditPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
|
||||||
|
if (we != null)
|
||||||
|
{
|
||||||
|
if (we instanceof WorldEditPlugin)
|
||||||
|
{
|
||||||
|
worldeditPlugin = (WorldEditPlugin)we;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worldeditPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void undo(Player player, int count)
|
public void undo(Player player, int count)
|
||||||
@ -46,7 +66,8 @@ public class WorldEditBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||||
|
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -57,18 +78,21 @@ public class WorldEditBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private WorldEditPlugin getWorldEditPlugin()
|
public void redo(Player player, int count)
|
||||||
{
|
|
||||||
if (worldedit == null)
|
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
|
LocalSession session = getPlayerSession(player);
|
||||||
if (we != null)
|
if (session != null)
|
||||||
{
|
{
|
||||||
if (we instanceof WorldEditPlugin)
|
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||||
|
if (bukkitPlayer != null)
|
||||||
{
|
{
|
||||||
worldedit = (WorldEditPlugin) we;
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
||||||
|
session.redo(session.getBlockBag(fuckyou), fuckyou);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -78,9 +102,6 @@ public class WorldEditBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return worldedit;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setLimit(Player player, int limit)
|
public void setLimit(Player player, int limit)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -98,6 +119,30 @@ public class WorldEditBridge extends FreedomService
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getDefaultLimit()
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wep.getLocalConfiguration().defaultChangeLimit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxLimit()
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
return wep.getLocalConfiguration().maxChangeLimit;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
private LocalSession getPlayerSession(Player player)
|
private LocalSession getPlayerSession(Player player)
|
||||||
{
|
{
|
||||||
final WorldEditPlugin wep = getWorldEditPlugin();
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
@ -1,66 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import me.totalfreedom.worldedit.LimitChangedEvent;
|
|
||||||
import me.totalfreedom.worldedit.SelectionChangedEvent;
|
|
||||||
import net.pravian.aero.component.PluginListener;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.event.EventHandler;
|
|
||||||
|
|
||||||
public class WorldEditListener extends PluginListener<TotalFreedomMod>
|
|
||||||
{
|
|
||||||
|
|
||||||
public WorldEditListener(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onSelectionChange(final SelectionChangedEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (plugin.pa.isInProtectedArea(
|
|
||||||
event.getMinVector(),
|
|
||||||
event.getMaxVector(),
|
|
||||||
event.getWorld().getName()))
|
|
||||||
{
|
|
||||||
|
|
||||||
player.sendMessage(ChatColor.RED + "The region that you selected contained a protected area. Selection cleared.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onLimitChanged(LimitChangedEvent event)
|
|
||||||
{
|
|
||||||
final Player player = event.getPlayer();
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!event.getPlayer().equals(event.getTarget()))
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.RED + "Only admins can change the limit for other players!");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (event.getLimit() < 0 || event.getLimit() > 10000)
|
|
||||||
{
|
|
||||||
player.setOp(false);
|
|
||||||
FUtil.bcastMsg(event.getPlayer().getName() + " tried to set their WorldEdit limit to " + event.getLimit() + " and has been de-opped", ChatColor.RED);
|
|
||||||
event.setCancelled(true);
|
|
||||||
player.sendMessage(ChatColor.RED + "You cannot set your limit higher than 10000 or to -1!");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -0,0 +1,62 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitAdapter;
|
||||||
|
import com.sk89q.worldguard.WorldGuard;
|
||||||
|
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||||
|
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||||
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class WorldGuardBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public WorldGuardBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
||||||
|
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegionManager getRegionManager(World world)
|
||||||
|
{
|
||||||
|
RegionContainer container = WorldGuard.getInstance().getPlatform().getRegionContainer();
|
||||||
|
return container.get(BukkitAdapter.adapt(world));
|
||||||
|
}
|
||||||
|
|
||||||
|
public int wipeRegions(World world)
|
||||||
|
{
|
||||||
|
int count = 0;
|
||||||
|
RegionManager regionManager = getRegionManager(world);
|
||||||
|
if (regionManager != null)
|
||||||
|
{
|
||||||
|
Map<String, ProtectedRegion> regions = regionManager.getRegions();
|
||||||
|
for (ProtectedRegion region : regions.values())
|
||||||
|
{
|
||||||
|
regionManager.removeRegion(region.getId());
|
||||||
|
count++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEnabled()
|
||||||
|
{
|
||||||
|
Plugin plugin = server.getPluginManager().getPlugin("WorldGuard");
|
||||||
|
|
||||||
|
return plugin != null && plugin.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
@ -6,7 +6,6 @@ import lombok.Getter;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.SkullType;
|
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
|
|
||||||
@ -25,6 +24,8 @@ public class CageData
|
|||||||
private Material outerMaterial = Material.GLASS;
|
private Material outerMaterial = Material.GLASS;
|
||||||
@Getter
|
@Getter
|
||||||
private Material innerMaterial = Material.AIR;
|
private Material innerMaterial = Material.AIR;
|
||||||
|
@Getter
|
||||||
|
private static String input = null;
|
||||||
|
|
||||||
public CageData(FPlayer player)
|
public CageData(FPlayer player)
|
||||||
{
|
{
|
||||||
@ -57,6 +58,24 @@ public class CageData
|
|||||||
this.location = location;
|
this.location = location;
|
||||||
this.outerMaterial = outer;
|
this.outerMaterial = outer;
|
||||||
this.innerMaterial = inner;
|
this.innerMaterial = inner;
|
||||||
|
this.input = null;
|
||||||
|
|
||||||
|
buildHistory(location, 2, fPlayer);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner, String input)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
this.input = input;
|
||||||
|
|
||||||
buildHistory(location, 2, fPlayer);
|
buildHistory(location, 2, fPlayer);
|
||||||
regenerate();
|
regenerate();
|
||||||
@ -85,7 +104,7 @@ public class CageData
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial);
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial, input);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void playerQuit()
|
public void playerQuit()
|
||||||
@ -165,7 +184,7 @@ public class CageData
|
|||||||
|
|
||||||
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
|
||||||
if (material != Material.SKULL)
|
if (material != Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
// Glowstone light
|
// Glowstone light
|
||||||
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
||||||
@ -176,7 +195,7 @@ public class CageData
|
|||||||
|
|
||||||
block.setType(material);
|
block.setType(material);
|
||||||
}
|
}
|
||||||
else // Darth mode
|
else
|
||||||
{
|
{
|
||||||
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
||||||
{
|
{
|
||||||
@ -184,12 +203,21 @@ public class CageData
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
block.setType(Material.SKULL);
|
block.setType(Material.PLAYER_HEAD);
|
||||||
final Skull skull = (Skull) block.getState();
|
if (input != null)
|
||||||
skull.setSkullType(SkullType.PLAYER);
|
{
|
||||||
skull.setOwner("Prozza");
|
try
|
||||||
|
{
|
||||||
|
Skull skull = (Skull)block.getState();
|
||||||
|
// This may or may not work in future versions of spigot
|
||||||
|
skull.setOwner(input);
|
||||||
skull.update();
|
skull.update();
|
||||||
}
|
}
|
||||||
|
catch (ClassCastException e)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
@ -95,6 +96,18 @@ public class Cager extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerKick(PlayerKickEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerQuit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
|
@ -31,7 +31,7 @@ public class CommandLoader extends FreedomService
|
|||||||
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
||||||
|
|
||||||
handler.loadFrom(FreedomCommand.class.getPackage());
|
handler.loadFrom(FreedomCommand.class.getPackage());
|
||||||
handler.registerAll("TotalFreedomMod", true);
|
handler.registerAll(plugin.getDescription().getName(), true);
|
||||||
|
|
||||||
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
||||||
}
|
}
|
||||||
|
@ -13,4 +13,6 @@ public @interface CommandPermissions
|
|||||||
SourceType source();
|
SourceType source();
|
||||||
|
|
||||||
boolean blockHostConsole() default false;
|
boolean blockHostConsole() default false;
|
||||||
|
|
||||||
|
int cooldown() default 0;
|
||||||
}
|
}
|
@ -2,15 +2,14 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(
|
@CommandParameters(
|
||||||
description = "AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.",
|
description = "Talk privately with other administrators on the server.",
|
||||||
usage = "/<command> [message...]",
|
usage = "/<command> [message...]",
|
||||||
aliases = "o,ac")
|
aliases = "o,ac")
|
||||||
public class Command_adminchat extends FreedomCommand
|
public class Command_adminchat extends FreedomCommand
|
||||||
@ -23,13 +22,13 @@ public class Command_adminchat extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
msg("Only in-game players can toggle AdminChat.");
|
msg("You must be in-game to toggle admin chat, it cannot be toggled via CONSOLE or Telnet.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
||||||
userinfo.setAdminChat(!userinfo.inAdminChat());
|
userinfo.setAdminChat(!userinfo.inAdminChat());
|
||||||
msg("Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
msg("Toggled your admin chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -0,0 +1,34 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Information on how to apply for admin.", usage = "/<command>", aliases = "ai")
|
||||||
|
public class Command_admininfo extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
List<String> adminInfo = ConfigEntry.ADMIN_INFO.getStringList();
|
||||||
|
|
||||||
|
if (adminInfo.isEmpty())
|
||||||
|
{
|
||||||
|
msg("The admin information section of the config.yml file has not been configured.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg(FUtil.colorize(StringUtils.join(adminInfo, "\n")));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,5 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -7,8 +10,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
@CommandPermissions(level = Rank.TELNET_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
|
@CommandParameters(description = "Denies joining of operators and only allows admins to join.", usage = "/<command> [on | off]")
|
||||||
public class Command_adminmode extends FreedomCommand
|
public class Command_adminmode extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -29,12 +32,12 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
else if (args[0].equalsIgnoreCase("on"))
|
else if (args[0].equalsIgnoreCase("on"))
|
||||||
{
|
{
|
||||||
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||||
FUtil.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
FUtil.adminAction(sender.getName(), "Closing the server to non-admins.", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!isAdmin(player))
|
if (!isAdmin(player))
|
||||||
{
|
{
|
||||||
player.kickPlayer("Server is now closed to non-superadmins.");
|
player.kickPlayer("Server is now closed to non-admins.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
@ -42,4 +45,15 @@ public class Command_adminmode extends FreedomCommand
|
|||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.al.isAdmin(sender) && !(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return Arrays.asList("on", "off");
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,9 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
@ -10,15 +14,15 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Go to the AdminWorld.",
|
@CommandParameters(description = "Allows for admins to configure guests, time, and weather of the AdminWorld, and allows for admins and guests to go to the AdminWorld.",
|
||||||
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]")
|
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
||||||
|
aliases = "aw")
|
||||||
public class Command_adminworld extends FreedomCommand
|
public class Command_adminworld extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private enum CommandMode
|
private enum CommandMode
|
||||||
{
|
{
|
||||||
|
TELEPORT, GUEST, TIME, WEATHER
|
||||||
TELEPORT, GUEST, TIME, WEATHER;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -245,4 +249,47 @@ public class Command_adminworld extends FreedomCommand
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
return Arrays.asList("guest", "time", "weather");
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
if (args[0].equals("guest"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("add", "remove", "list", "purge");
|
||||||
|
}
|
||||||
|
else if (args[0].equals("time"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("morning", "noon", "evening", "night");
|
||||||
|
}
|
||||||
|
else if (args[0].equals("weather"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("off", "rain", "storm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length == 3)
|
||||||
|
{
|
||||||
|
if (args[0].equals("guest"))
|
||||||
|
{
|
||||||
|
if (args[1].equals("add"))
|
||||||
|
{
|
||||||
|
return FUtil.getPlayerList();
|
||||||
|
}
|
||||||
|
else if (args[1].equals("remove"))
|
||||||
|
{
|
||||||
|
return plugin.wm.adminworld.getGuestList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,58 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Quickly change your own gamemode to adventure, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/<command> <[partialname] | -a>", aliases = "gma")
|
||||||
|
public class Command_adventure extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
if (isConsole())
|
||||||
|
{
|
||||||
|
sender.sendMessage("When used from the console, you must define a target player.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSender.setGameMode(GameMode.ADVENTURE);
|
||||||
|
msg("Your gamemode has been set to adventure.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRank(Rank.SUPER_ADMIN);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||||
|
msg("Your gamemode has been set to adventure.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Setting " + player.getName() + " to game mode adventure.");
|
||||||
|
msg(player, sender.getName() + " set your game mode to adventure.");
|
||||||
|
player.setGameMode(GameMode.ADVENTURE);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.AreaEffectCloud;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||||
|
public class Command_aeclear extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing all area effect clouds.", true);
|
||||||
|
int removed = 0;
|
||||||
|
for (World world : server.getWorlds())
|
||||||
|
{
|
||||||
|
for (Entity entity : world.getEntities())
|
||||||
|
{
|
||||||
|
if (entity instanceof AreaEffectCloud)
|
||||||
|
{
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg(removed + " area effect clouds removed.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,13 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Make an announcement", usage = "/<command> <message>")
|
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||||
public class Command_announce extends FreedomCommand
|
public class Command_announce extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -0,0 +1,30 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.attribute.Attribute;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Lists all possible attributes.", usage = "/<command>")
|
||||||
|
public class Command_attributelist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
String list = "All possible attributes: ";
|
||||||
|
|
||||||
|
for (Attribute attribute : Attribute.values())
|
||||||
|
{
|
||||||
|
list += attribute.name() + ", ";
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove extra comma at the end of the list
|
||||||
|
list = list.substring(0, list.length() - 2);
|
||||||
|
|
||||||
|
msg(list);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||||
|
public class Command_autoclear extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enabled = plugin.lp.CLEAR_ON_JOIN.contains(args[0]);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
plugin.lp.CLEAR_ON_JOIN.remove(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.lp.CLEAR_ON_JOIN.add(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " have their inventory cleared when they join.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||||
|
public class Command_autotp extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean enabled = plugin.lp.TELEPORT_ON_JOIN.contains(args[0]);
|
||||||
|
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
plugin.lp.TELEPORT_ON_JOIN.remove(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.lp.TELEPORT_ON_JOIN.add(args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(args[0] + " will " + (enabled ? "no longer" : "now") + " be automatically teleported when they join.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,167 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||||
|
public class Command_ban extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
Boolean silent = false;
|
||||||
|
Boolean cancelRollback = false;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||||
|
{
|
||||||
|
cancelRollback = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final String username;
|
||||||
|
final List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(args[0]);
|
||||||
|
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
msg("Can't find that user. If target is not logged in, make sure that you spelled the name exactly.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
username = entry.getUsername();
|
||||||
|
ips.addAll(entry.getIps());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
|
username = player.getName();
|
||||||
|
//ips.addAll(entry.getIps());/
|
||||||
|
ips.add(Ips.getIp(player));
|
||||||
|
|
||||||
|
// Deop
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
// Gamemode survival
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
// Clear inventory
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Strike with lightning
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
for (int x = -1; x <= 1; x++)
|
||||||
|
{
|
||||||
|
for (int z = -1; z <= 1; z++)
|
||||||
|
{
|
||||||
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
|
targetPos.getWorld().strikeLightning(strike_pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kill player
|
||||||
|
player.setHealth(0.0);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
||||||
|
if (!cancelRollback)
|
||||||
|
{
|
||||||
|
plugin.cpb.rollback(username);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player != null && !silent)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
ban.addIp(ip);
|
||||||
|
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||||
|
}
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Broadcast
|
||||||
|
final StringBuilder bcast = new StringBuilder()
|
||||||
|
.append("Banning: ")
|
||||||
|
.append(username);
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
|
}
|
||||||
|
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||||
|
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kick player and handle others on IP
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
||||||
|
{
|
||||||
|
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Log ban
|
||||||
|
plugin.pul.logPunishment(new Punishment(username, ips.get(0), sender.getName(), PunishmentType.BAN, reason));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -2,24 +2,27 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
@CommandParameters(description = "Shows all banned player names. Senior Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
public class Command_banlist extends FreedomCommand {
|
public class Command_banlist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole) {
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
if (args.length > 0) {
|
{
|
||||||
if (args[0].equalsIgnoreCase("purge")) {
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||||
int amount = plugin.bm.purge();
|
int amount = plugin.bm.purge();
|
||||||
sender.sendMessage(ChatColor.GRAY + "Purged " + amount + " player bans.");
|
msg("Purged " + amount + " player bans.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
@ -0,0 +1,33 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||||
|
public class Command_bird extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
Location location = playerSender.getTargetBlock(null, 15).getLocation().add(0, 1, 0);
|
||||||
|
playerSender.getWorld().spawnEntity(location, getRandomFish());
|
||||||
|
msg(":goodbird:");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityType getRandomFish()
|
||||||
|
{
|
||||||
|
List<EntityType> fishTypes = Arrays.asList(EntityType.COD, EntityType.SALMON, EntityType.PUFFERFISH, EntityType.TROPICAL_FISH);
|
||||||
|
Random random = new Random();
|
||||||
|
return fishTypes.get(random.nextInt(fishTypes.size()));
|
||||||
|
}
|
||||||
|
}
|
@ -9,7 +9,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
public class Command_blockcmd extends FreedomCommand
|
public class Command_blockcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -68,7 +68,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (isAdmin(player))
|
if (isAdmin(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,134 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
||||||
|
public class Command_blockedit extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("list"))
|
||||||
|
{
|
||||||
|
msg("The following have block modification abilities restricted:");
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isEditBlocked())
|
||||||
|
{
|
||||||
|
msg("- " + player.getName());
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
msg("- none");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
||||||
|
int count = 0;
|
||||||
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isEditBlocked())
|
||||||
|
{
|
||||||
|
info.setEditBlocked(false);
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Unblocked all block modification abilities for " + count + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("all"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins.", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.setEditBlocked(true);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Blocked block modification abilities for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean smite = args[0].equals("-s");
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
args = (String[])ArrayUtils.subarray(args, 1, args.length);
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player2 = getPlayer(args[0]);
|
||||||
|
if (player2 == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||||
|
if (pd.isEditBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||||
|
pd.setEditBlocked(false);
|
||||||
|
msg("Unblocking block modification abilities for " + player2.getName());
|
||||||
|
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player2))
|
||||||
|
{
|
||||||
|
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||||
|
pd.setEditBlocked(true);
|
||||||
|
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
Command_smite.smite(sender, player2, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(player2, "Your block modification abilities have been blocked.", ChatColor.RED);
|
||||||
|
msg("Blocked all block modification abilities for " + player2.getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,134 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||||
|
public class Command_blockpvp extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("list"))
|
||||||
|
{
|
||||||
|
msg("PVP is blocked for players:");
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isPvpBlocked())
|
||||||
|
{
|
||||||
|
msg(" - " + player.getName());
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count == 0)
|
||||||
|
{
|
||||||
|
msg(" - none");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||||
|
int count = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer info = plugin.pl.getPlayer(player);
|
||||||
|
if (info.isPvpBlocked())
|
||||||
|
{
|
||||||
|
info.setPvpBlocked(false);
|
||||||
|
++count;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Enabled PVP for " + count + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("all"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.setPvpBlocked(true);
|
||||||
|
++counter;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Disabling PVP for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final boolean smite = args[0].equals("-s");
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
args = ArrayUtils.subarray(args, 1, args.length);
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player p = getPlayer(args[0]);
|
||||||
|
if (p == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
}
|
||||||
|
|
||||||
|
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||||
|
if (pd.isPvpBlocked())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(false);
|
||||||
|
msg("Enabling PVP for " + p.getName());
|
||||||
|
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(p))
|
||||||
|
{
|
||||||
|
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||||
|
pd.setPvpBlocked(true);
|
||||||
|
if (smite)
|
||||||
|
{
|
||||||
|
Command_smite.smite(sender, p, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(p, "Your PVP has been disabled.", ChatColor.RED);
|
||||||
|
msg("Disabled PVP for " + p.getName());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
||||||
|
public class Command_blockredstone extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 6000L);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,13 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
@ -11,100 +16,137 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||||
public class Command_cage extends FreedomCommand
|
public class Command_cage extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
{
|
||||||
if (args.length == 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("off".equals(args[0]) && sender instanceof Player)
|
String skullName = null;
|
||||||
{
|
if ("purge".equals(args[0]))
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
|
||||||
|
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else if ("purge".equals(args[0]))
|
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
playerdata.getCageData().setCaged(false);
|
fPlayer.getCageData().setCaged(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Player player = getPlayer(args[0]);
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (fPlayer.getCageData().isCaged())
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||||
|
playerdata.getCageData().setCaged(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Material outerMaterial = Material.GLASS;
|
Material outerMaterial = Material.GLASS;
|
||||||
Material innerMaterial = Material.AIR;
|
Material innerMaterial = Material.AIR;
|
||||||
|
if (args.length >= 2 && args[1] != null)
|
||||||
if (args.length >= 2)
|
|
||||||
{
|
{
|
||||||
if ("off".equals(args[1]))
|
final String s = args[1];
|
||||||
|
switch (s)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
case "head":
|
||||||
playerdata.getCageData().setCaged(false);
|
{
|
||||||
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
return true;
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
skullName = args[2];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if ("darth".equalsIgnoreCase(args[1]))
|
outerMaterial = Material.SKELETON_SKULL;
|
||||||
{
|
|
||||||
outerMaterial = Material.SKULL;
|
|
||||||
}
|
}
|
||||||
else if (Material.matchMaterial(args[1]) != null)
|
break;
|
||||||
|
}
|
||||||
|
case "block":
|
||||||
{
|
{
|
||||||
outerMaterial = Material.matchMaterial(args[1]);
|
if (Material.matchMaterial(args[2]) != null)
|
||||||
|
{
|
||||||
|
outerMaterial = Material.matchMaterial(args[2]);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sender.sendMessage(ChatColor.RED + "Invalid block!");
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.length >= 3)
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||||
{
|
|
||||||
if (args[2].equalsIgnoreCase("water"))
|
|
||||||
{
|
|
||||||
innerMaterial = Material.STATIONARY_WATER;
|
|
||||||
}
|
|
||||||
else if (args[2].equalsIgnoreCase("lava"))
|
|
||||||
{
|
|
||||||
innerMaterial = Material.STATIONARY_LAVA;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Location targetPos = player.getLocation().clone().add(0, 1, 0);
|
if (skullName != null)
|
||||||
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
|
{
|
||||||
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
if (outerMaterial != Material.SKULL)
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
List<String> arguments = new ArrayList<>();
|
||||||
|
arguments.add("purge");
|
||||||
|
arguments.addAll(FUtil.getPlayerList());
|
||||||
|
return arguments;
|
||||||
|
}
|
||||||
|
else if (args.length == 2)
|
||||||
|
{
|
||||||
|
if (!args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
return Arrays.asList("head", "block");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length == 3)
|
||||||
|
{
|
||||||
|
if (args[1].equals("block"))
|
||||||
|
{
|
||||||
|
return FUtil.getAllMaterialNames();
|
||||||
|
}
|
||||||
|
else if (args[1].equals("head"))
|
||||||
|
{
|
||||||
|
return FUtil.getPlayerList();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.Achievement;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -13,42 +11,37 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "For the people that are still alive.", usage = "/<command>")
|
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
||||||
public class Command_cake extends FreedomCommand
|
public class Command_cake extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
public static final String CAKE_LYRICS = "But there's no sense crying over every mistake. You just keep on trying till you run out of cake.";
|
||||||
private final Random random = new Random();
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
final StringBuilder output = new StringBuilder();
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
final String[] words = CAKE_LYRICS.split(" ");
|
for (final String word : CAKE_LYRICS.split(" "))
|
||||||
for (final String word : words)
|
|
||||||
{
|
{
|
||||||
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
}
|
}
|
||||||
|
|
||||||
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (final Player player : server.getOnlinePlayers())
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final int firstEmpty = player.getInventory().firstEmpty();
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
if (firstEmpty >= 0)
|
if (firstEmpty >= 0)
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(firstEmpty, heldItem);
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.awardAchievement(Achievement.BAKE_CAKE);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.bcastMsg(output.toString());
|
FUtil.bcastMsg(output.toString());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,47 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "You know the words - gives a campfire to everyone on the server.", usage = "/<command>")
|
||||||
|
public class Command_campfire extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CAMPFIRE_LYRICS = "Let's gather round the campfire, and sing our campfire song....";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, final Player playerSender, final Command cmd, final String commandLabel, final String[] args, final boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
for (final String word : CAMPFIRE_LYRICS.split(" "))
|
||||||
|
{
|
||||||
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
final ItemStack heldItem = new ItemStack(Material.CAMPFIRE);
|
||||||
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
heldItemMeta.setDisplayName(ChatColor.DARK_RED + "The " + ChatColor.DARK_RED + "Campfire");
|
||||||
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
|
if (firstEmpty >= 0)
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.bcastMsg(output.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -16,7 +16,7 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Player targetPlayer = playerSender;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
if (args.length == 1)
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
{
|
{
|
||||||
|
|
||||||
targetPlayer = getPlayer(args[0]);
|
targetPlayer = getPlayer(args[0]);
|
||||||
@ -36,11 +36,6 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (targetPlayer != playerSender && !isAdmin(sender))
|
|
||||||
{
|
|
||||||
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetPlayer.isInsideVehicle())
|
if (targetPlayer.isInsideVehicle())
|
||||||
{
|
{
|
||||||
@ -69,11 +64,11 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
|
|
||||||
if (nearest_cart != null)
|
if (nearest_cart != null)
|
||||||
{
|
{
|
||||||
nearest_cart.setPassenger(targetPlayer);
|
nearest_cart.addPassenger(targetPlayer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
sender.sendMessage("There are no empty minecarts in the target world.");
|
msg("There are no empty minecarts in the target world.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,71 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.stream.IntStream;
|
||||||
|
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
||||||
|
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc")
|
||||||
|
public class Command_clearchat extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(playerSender))
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
boolean optedOut = false;
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
optedOut = true;
|
||||||
|
}
|
||||||
|
else if (plugin.mbl.isMasterBuilder(player) && plugin.mbl.getMasterBuilder(player).isClearChatOptOut())
|
||||||
|
{
|
||||||
|
optedOut = true;
|
||||||
|
}
|
||||||
|
else if (plugin.pv.getVerificationPlayer(player).getEnabled() && plugin.pv.getVerificationPlayer(player).isClearChatOptOut())
|
||||||
|
{
|
||||||
|
optedOut = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!optedOut)
|
||||||
|
{
|
||||||
|
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
||||||
|
}
|
||||||
|
else if (plugin.mbl.isMasterBuilder(playerSender))
|
||||||
|
{
|
||||||
|
MasterBuilder mb = plugin.mbl.getMasterBuilder(playerSender);
|
||||||
|
mb.setClearChatOptOut(!mb.isClearChatOptOut());
|
||||||
|
msg((mb.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
||||||
|
plugin.mbl.save();
|
||||||
|
plugin.mbl.updateTables();
|
||||||
|
}
|
||||||
|
else if (plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
||||||
|
{
|
||||||
|
VPlayer vp = plugin.pv.getVerificationPlayer(playerSender);
|
||||||
|
vp.setClearChatOptOut(!vp.isClearChatOptOut());
|
||||||
|
msg((vp.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
||||||
|
plugin.pv.saveVerificationData(vp);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Only Master Builders, admins, and players with verification enabled can opt-out of clear chat.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
|
@CommandParameters(description = "Clear the discord message queue.", usage = "/<command>")
|
||||||
|
public class Command_cleardiscordqueue extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
plugin.dc.clearQueue();
|
||||||
|
msg("Cleared the discord message queue.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Clear your inventory.", usage = "/<command> [player]", aliases = "ci,clear")
|
||||||
|
public class Command_clearinventory extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerSender.getInventory().clear();
|
||||||
|
msg("Your inventory has been cleared.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Clearing everyone's inventory", true);
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
player.getInventory().clear();
|
||||||
|
}
|
||||||
|
msg("Sucessfully cleared everyone's inventory.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear();
|
||||||
|
msg("Cleared " + player.getName() + "'s inventory.");
|
||||||
|
player.sendMessage(sender.getName() + " has cleared your inventory.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.al.isAdmin(playerSender))
|
||||||
|
{
|
||||||
|
List<String> players = FUtil.getPlayerList();
|
||||||
|
players.add("-a");
|
||||||
|
return players;
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
@ -15,9 +15,11 @@ public class Command_cmdspy extends FreedomCommand
|
|||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
Admin admin = plugin.al.getAdmin(playerSender);
|
||||||
playerdata.setCommandSpy(!playerdata.cmdspyEnabled());
|
admin.setCommandSpy(!admin.getCommandSpy());
|
||||||
msg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled."));
|
plugin.al.save(admin);
|
||||||
|
plugin.al.updateTables();
|
||||||
|
msg("CommandSpy " + (admin.getCommandSpy() ? "enabled." : "disabled."));
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,55 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Shows the amount of coins you have or another player", usage = "/<command> [playername]")
|
||||||
|
public class Command_coins extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.SHOP_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
msg("The shop is currently disabled!", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
Player p;
|
||||||
|
final String prefix = FUtil.colorize(ConfigEntry.SHOP_PREFIX.getString() + " ");
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (getPlayer(args[0]) != null)
|
||||||
|
{
|
||||||
|
p = getPlayer(args[0]);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg(PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
msg(prefix + ChatColor.RED + "You are not a player, use /coins <playername>");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
p = playerSender;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ShopData sd = plugin.sh.getData(p);
|
||||||
|
msg(prefix + ChatColor.GREEN + (args.length > 0 ? p.getName() + " has " : "You have ") + ChatColor.RED + sd.getCoins() + ChatColor.GREEN + " coins.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -4,14 +4,14 @@ import java.util.Iterator;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
|
@CommandParameters(description = "Essentials Interface Command - Set your nickname to a certain color.", usage = "/<command> <color>")
|
||||||
public class Command_colorme extends FreedomCommand
|
public class Command_colorme extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import java.util.List;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -28,13 +28,13 @@ public class Command_commandlist extends FreedomCommand
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginDescriptionFile desc = targetPlugin.getDescription();
|
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||||
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) desc.getCommands();
|
Map<String, Map<String, Object>> map = desc.getCommands();
|
||||||
|
|
||||||
if (map != null)
|
if (map != null)
|
||||||
{
|
{
|
||||||
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
for (Entry<String, Map<String, Object>> entry : map.entrySet())
|
||||||
{
|
{
|
||||||
String command_name = (String) entry.getKey();
|
String command_name = entry.getKey();
|
||||||
commands.add(command_name);
|
commands.add(command_name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,31 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "Telnet command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message...>", aliases = "csay")
|
@CommandParameters(description = "Telnet/Console command - Send a chat message with chat formatting over telnet.", usage = "/<command> <message>", aliases = "csay")
|
||||||
public class Command_consolesay extends FreedomCommand
|
public class Command_consolesay extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length > 0)
|
if (args.length == 0)
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender.getName(), StringUtils.join(args, " ")));
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String message = StringUtils.join(args, " ");
|
||||||
|
FUtil.bcastMsg(String.format("§7[CONSOLE] §c%s §8\u00BB §f%s", sender.getName(), StringUtils.join(args, " ")));
|
||||||
|
plugin.dc.messageChatChannel("[CONSOLE] " + plugin.dc.deformat(sender.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,65 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "For those who have no friends - gives a cookie to everyone on the server.", usage = "/<command>")
|
||||||
|
public class Command_cookie extends FreedomCommand
|
||||||
|
{
|
||||||
|
public static final String COOKIE_LYRICS = "Imagine that you have zero cookies and you split them evenly among zero friends. How many cookies does each person get? See? It doesn't make sense. And Cookie Monster is sad that there are no cookies, and you are sad that you have no friends.";
|
||||||
|
public static final String LORE = "But, you can have a cookie anyways,\nsince you are sad you are have no friends.";
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
for (final String word : COOKIE_LYRICS.split(" "))
|
||||||
|
{
|
||||||
|
output.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
final StringBuilder name = new StringBuilder();
|
||||||
|
|
||||||
|
name.append(ChatColor.DARK_RED).append("C")
|
||||||
|
.append(ChatColor.GOLD).append("o")
|
||||||
|
.append(ChatColor.YELLOW).append("o")
|
||||||
|
.append(ChatColor.DARK_GREEN).append("k")
|
||||||
|
.append(ChatColor.DARK_BLUE).append("i")
|
||||||
|
.append(ChatColor.DARK_PURPLE).append("e");
|
||||||
|
|
||||||
|
final StringBuilder lore = new StringBuilder();
|
||||||
|
|
||||||
|
for (final String word : LORE.split(" "))
|
||||||
|
{
|
||||||
|
lore.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
final ItemStack heldItem = new ItemStack(Material.COOKIE);
|
||||||
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
heldItemMeta.setDisplayName(name.toString());
|
||||||
|
heldItemMeta.setLore(Arrays.asList(lore.toString().split("\n")));
|
||||||
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
for (final Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
|
if (firstEmpty >= 0)
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.bcastMsg(output.toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -8,7 +8,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Quickly change your own gamemode to creative, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", aliases = "gmc")
|
@CommandParameters(description = "Quickly change your own gamemode to creative, define someone's username to change theirs, or change everyone's gamemode on the server.", usage = "/<command> <-a | [partialname]>", aliases = "gmc")
|
||||||
public class Command_creative extends FreedomCommand
|
public class Command_creative extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ public class Command_creative extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
playerSender.setGameMode(GameMode.CREATIVE);
|
playerSender.setGameMode(GameMode.CREATIVE);
|
||||||
msg("Gamemode set to creative.");
|
msg("Your gamemode has been set to creative.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,6 +38,7 @@ public class Command_creative extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
||||||
|
msg("Your gamemode has been set to creative.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Cuck someone - sends an unclearable title to the specified player.", usage = "/<command> <player>")
|
||||||
|
public class Command_cuck extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (FUtil.isPaper())
|
||||||
|
{
|
||||||
|
msg("This command won't work on Paper!", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.remove();
|
||||||
|
msg("Cucked " + player.getName());
|
||||||
|
player.sendTitle(ChatColor.DARK_RED + "HAHA CUCKED", ChatColor.RED + "relog if u want to be uncucked loser", 20, 200, 60);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
|
{
|
||||||
|
if (args.length == 1 && plugin.al.isAdmin(sender))
|
||||||
|
{
|
||||||
|
return FUtil.getPlayerList();
|
||||||
|
}
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user