mirror of
https://github.com/AtlasMediaGroup/TotalFreedomMod.git
synced 2025-07-01 12:36:41 +00:00
Compare commits
255 Commits
Author | SHA1 | Date | |
---|---|---|---|
fadcb9ad5d | |||
49f7c6e8c3 | |||
9bcdb2bcdc | |||
ca4670ed89 | |||
adf71cb020 | |||
6e84fdad23 | |||
2ecfd9610f | |||
bb33778fc9 | |||
d4d1000c16 | |||
5a96204f1b | |||
3bd72dacda | |||
a4c8dad865 | |||
82e7a3b659 | |||
586fa98c32 | |||
a8f95bcb19 | |||
82d92565e7 | |||
533e4fe369 | |||
f8304aecd7 | |||
ac6e58ff9e | |||
4be2a1e05b | |||
59831ef1f3 | |||
54e6e2f9b1 | |||
d203772a9a | |||
55522e8191 | |||
ac3d0fca88 | |||
eb6514332e | |||
098d3e4cf1 | |||
81eb333b6a | |||
3057421d6d | |||
9cb96e81ac | |||
d67189e170 | |||
451ef8f009 | |||
7af53448be | |||
2072c89f77 | |||
43b266f17d | |||
c61f7e78fd | |||
14ab1e95b5 | |||
44fe8f6f94 | |||
1c487a6a60 | |||
6f4cc8d4b5 | |||
f98f6990ea | |||
4c81c94702 | |||
aaa495cf41 | |||
72322f2e56 | |||
04fee7d5c1 | |||
d38ddac311 | |||
d65f584707 | |||
ff42713f92 | |||
5047363f83 | |||
34a0dae305 | |||
ebc07f6259 | |||
6a7a6e74e3 | |||
1e36b484ac | |||
efae9e314f | |||
ea946fe14f | |||
fc08761e70 | |||
3f68677d99 | |||
f4007a7c9d | |||
f3a655d40d | |||
6b3a765c90 | |||
7e8a519c87 | |||
388e1fd52d | |||
cdb28afba6 | |||
24575aba88 | |||
090c445aa9 | |||
c936759b6c | |||
36fc1a00b6 | |||
7b9920dbc4 | |||
b0daf2066a | |||
ed5d18c0df | |||
04a7b633a4 | |||
7a810519f3 | |||
53038ca3b2 | |||
e77d92407c | |||
da80f1b69e | |||
4407e9e6ec | |||
e4c9ea656e | |||
63570d61d6 | |||
257a2eec33 | |||
78b73b3b63 | |||
d74846cde6 | |||
3f4d34d172 | |||
f5b5fcd5ef | |||
f42e047723 | |||
e79145ee54 | |||
6dbc99690a | |||
8628e88e3a | |||
51e1191816 | |||
e294ef8312 | |||
541abb1ba8 | |||
306c8bc8b9 | |||
9f006325b4 | |||
aab4f55b7d | |||
00f94e47f1 | |||
44b7307e4d | |||
54df0e08f5 | |||
4003db6dd9 | |||
f4f25c1590 | |||
328225fe6e | |||
087e4a0d9c | |||
2ecde80b5f | |||
075299dbd9 | |||
30d5a1d888 | |||
b6746acb44 | |||
560353e7cf | |||
86cf9dc344 | |||
877c174e2d | |||
642725252b | |||
880b78e528 | |||
7224319fae | |||
ca8758cbb1 | |||
81df3103b6 | |||
b73d1df350 | |||
299b31a75b | |||
8832d5c870 | |||
abe3b68480 | |||
5c50f8f27d | |||
4561641d2b | |||
4555a7e3f2 | |||
c826afe399 | |||
ae57573eeb | |||
073a618035 | |||
e1b514ca85 | |||
3f942613d7 | |||
bb4f8d1fc6 | |||
5401cc5dc7 | |||
1a7c14ad3e | |||
25bf79bdb1 | |||
12a4f4da84 | |||
a0b29c1d01 | |||
76bb2d08ac | |||
891e5c2f12 | |||
4de1fe454d | |||
80e39d3db1 | |||
e25e785c26 | |||
0ae835aa04 | |||
05abebea65 | |||
c04e944466 | |||
3ee80e0f70 | |||
27f7276698 | |||
9ecfe703cb | |||
ab660a7ca7 | |||
2353c728c1 | |||
106e457fa7 | |||
582acdb176 | |||
05f94920d9 | |||
ee04a456a1 | |||
8e8daa457b | |||
95e67f84ef | |||
6f2d5aa08d | |||
417a0c39dd | |||
4ad7fd874f | |||
aef85b2120 | |||
37c65a85d4 | |||
d93a2a7e7d | |||
db414164dc | |||
30085a7a52 | |||
7593fbda9e | |||
fc05003354 | |||
113350b228 | |||
a1f64ef912 | |||
e4ee3066bc | |||
2bf78bcccf | |||
8c93da758a | |||
75e50582e9 | |||
d92f661f12 | |||
22d40bd0e9 | |||
3f75712732 | |||
fc31babff3 | |||
588a2f1eba | |||
4f276ec78e | |||
2ce1a3d1d3 | |||
cef2d8cec4 | |||
12b096b0ad | |||
cb1c67e568 | |||
5a41632654 | |||
cde24b748a | |||
0e63857ae0 | |||
b8e5de2080 | |||
62aa46f856 | |||
d33f661d55 | |||
c1f0d81fcc | |||
c4124de781 | |||
30fd3ea6a1 | |||
6435078703 | |||
03b22ac326 | |||
a1418eb516 | |||
7a08152c14 | |||
bf6ef152d9 | |||
114567a302 | |||
067180d2cf | |||
4973318249 | |||
ceed8bd303 | |||
a7d386e6be | |||
6e622ad2f3 | |||
2ca57c9b39 | |||
eea17a24bc | |||
7d6370da23 | |||
cdb385dd20 | |||
cb108e0c13 | |||
f9e8a4c8ba | |||
c836838f51 | |||
6ca7f6ba24 | |||
c7c567a14f | |||
38918afe67 | |||
ba2b636e04 | |||
da1bec6cc0 | |||
4e432eeeea | |||
f6bf485c0d | |||
06d40927b0 | |||
58872e2c32 | |||
00450e5732 | |||
98f4af7fab | |||
7b7f09e457 | |||
4a297a237c | |||
d12a121300 | |||
c87e1b3d64 | |||
f6ee9271c6 | |||
4328a13eaf | |||
ed9fe87e44 | |||
8b4a91b2e6 | |||
c1a7b1c141 | |||
78349ba49e | |||
d74eeec113 | |||
c333a6ee39 | |||
3fd7147fc2 | |||
adfd55b419 | |||
2a88e05021 | |||
8a60ae2235 | |||
556dfa7233 | |||
19ed60d407 | |||
aac791d768 | |||
1357ac7e09 | |||
5421de0c2f | |||
9d7e0cdefc | |||
e4d1d6ff9e | |||
3eec04ec1c | |||
357eddf51a | |||
baf5fd42f6 | |||
9d71a7f4ae | |||
9dad7c6d05 | |||
35b4990f0c | |||
b4b1128905 | |||
4d19d44d19 | |||
eb58419a3a | |||
4ddcc3b8d7 | |||
43ee17807a | |||
d1cc694742 | |||
abbadb55ee | |||
a2a4a8a0b8 | |||
c49abd1f4a | |||
dd5e256c84 | |||
321d9f97e0 | |||
721c2dc18e | |||
a523cc313c |
9
.gitignore
vendored
9
.gitignore
vendored
@ -19,7 +19,12 @@ manifest.mf
|
|||||||
# IntelliJ excludes
|
# IntelliJ excludes
|
||||||
*.ipr
|
*.ipr
|
||||||
*.iws
|
*.iws
|
||||||
/.idea
|
/.idea/modules.xml
|
||||||
|
/.idea/discord.xml
|
||||||
|
/.idea/jarRepositories.xml
|
||||||
|
/.idea/workspace.xml
|
||||||
|
/.idea/uiDesigner.xml
|
||||||
|
/.idea/libraries
|
||||||
*.iml
|
*.iml
|
||||||
|
|
||||||
# Maven excludes
|
# Maven excludes
|
||||||
@ -32,5 +37,3 @@ manifest.mf
|
|||||||
.Trashes
|
.Trashes
|
||||||
ehthumbs.db
|
ehthumbs.db
|
||||||
Thumbs.db
|
Thumbs.db
|
||||||
|
|
||||||
TotalFreedomMod\.iml
|
|
||||||
|
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
8
.idea/artifacts/TotalFreedomMod_jar.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<component name="ArtifactManager">
|
|
||||||
<artifact type="jar" build-on-make="true" name="TotalFreedomMod:jar">
|
|
||||||
<output-path>$PROJECT_DIR$/target</output-path>
|
|
||||||
<root id="archive" name="TotalFreedomMod.jar">
|
|
||||||
<element id="module-output" name="TotalFreedomMod" />
|
|
||||||
</root>
|
|
||||||
</artifact>
|
|
||||||
</component>
|
|
18
.idea/codeStyles/Project.xml
generated
18
.idea/codeStyles/Project.xml
generated
@ -9,6 +9,24 @@
|
|||||||
</value>
|
</value>
|
||||||
</option>
|
</option>
|
||||||
</JavaCodeStyleSettings>
|
</JavaCodeStyleSettings>
|
||||||
|
<JetCodeStyleSettings>
|
||||||
|
<option name="PACKAGES_TO_USE_STAR_IMPORTS">
|
||||||
|
<value>
|
||||||
|
<package name="java.util" alias="false" withSubpackages="false" />
|
||||||
|
<package name="kotlinx.android.synthetic" alias="false" withSubpackages="true" />
|
||||||
|
<package name="io.ktor" alias="false" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="PACKAGES_IMPORT_LAYOUT">
|
||||||
|
<value>
|
||||||
|
<package name="" alias="false" withSubpackages="true" />
|
||||||
|
<package name="java" alias="false" withSubpackages="true" />
|
||||||
|
<package name="javax" alias="false" withSubpackages="true" />
|
||||||
|
<package name="kotlin" alias="false" withSubpackages="true" />
|
||||||
|
<package name="" alias="true" withSubpackages="true" />
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
</JetCodeStyleSettings>
|
||||||
<codeStyleSettings language="JAVA">
|
<codeStyleSettings language="JAVA">
|
||||||
<option name="BRACE_STYLE" value="2" />
|
<option name="BRACE_STYLE" value="2" />
|
||||||
<option name="CLASS_BRACE_STYLE" value="2" />
|
<option name="CLASS_BRACE_STYLE" value="2" />
|
||||||
|
1
.idea/compiler.xml
generated
1
.idea/compiler.xml
generated
@ -11,7 +11,6 @@
|
|||||||
</profile>
|
</profile>
|
||||||
</annotationProcessing>
|
</annotationProcessing>
|
||||||
<bytecodeTargetLevel>
|
<bytecodeTargetLevel>
|
||||||
<module name="totalfreedom" target="1.8" />
|
|
||||||
<module name="TotalFreedomMod" target="1.8" />
|
<module name="TotalFreedomMod" target="1.8" />
|
||||||
</bytecodeTargetLevel>
|
</bytecodeTargetLevel>
|
||||||
</component>
|
</component>
|
||||||
|
2
.idea/encodings.xml
generated
2
.idea/encodings.xml
generated
@ -1,8 +1,8 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
<project version="4">
|
<project version="4">
|
||||||
<component name="Encoding">
|
<component name="Encoding">
|
||||||
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
|
||||||
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
</component>
|
</component>
|
||||||
</project>
|
</project>
|
16
.idea/misc.xml
generated
Normal file
16
.idea/misc.xml
generated
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="EntryPointsManager">
|
||||||
|
<list size="1">
|
||||||
|
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
||||||
|
</list>
|
||||||
|
</component>
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="false" project-jdk-name="1.8" project-jdk-type="JavaSDK" />
|
||||||
|
</project>
|
8
.idea/modules.xml
generated
8
.idea/modules.xml
generated
@ -1,8 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="ProjectModuleManager">
|
|
||||||
<modules>
|
|
||||||
<module fileurl="file://$PROJECT_DIR$/TotalFreedomMod.iml" filepath="$PROJECT_DIR$/TotalFreedomMod.iml" />
|
|
||||||
</modules>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
generated
Normal file
6
.idea/vcs.xml
generated
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
@ -1,4 +1,4 @@
|
|||||||
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
# TotalFreedomMod [](https://travis-ci.org/TFPatches/TotalFreedomMod) [](https://codebeat.co/projects/github-com-tfpatches-totalfreedommod-tfm-1-14-fa58c58f-b1c4-4221-bf78-346e07db6961)
|
||||||
|
|
||||||
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
TotalFreedomMod is a CraftBukkit server plugin designed primarily to support the [Official TotalFreedom Minecraft Server](http://totalfreedom.me/). However, you are more than welcome to adapt the source for your own server.
|
||||||
|
|
||||||
|
@ -1,121 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
|
||||||
<component name="FacetManager">
|
|
||||||
<facet type="minecraft" name="Minecraft">
|
|
||||||
<configuration>
|
|
||||||
<autoDetectTypes>
|
|
||||||
<platformType>PAPER</platformType>
|
|
||||||
</autoDetectTypes>
|
|
||||||
</configuration>
|
|
||||||
</facet>
|
|
||||||
</component>
|
|
||||||
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
|
|
||||||
<output url="file://$MODULE_DIR$/target/classes" />
|
|
||||||
<output-test url="file://$MODULE_DIR$/target/test-classes" />
|
|
||||||
<content url="file://$MODULE_DIR$">
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
|
|
||||||
<sourceFolder url="file://$MODULE_DIR$/src/test/java" isTestSource="true" />
|
|
||||||
<excludeFolder url="file://$MODULE_DIR$/target" />
|
|
||||||
</content>
|
|
||||||
<orderEntry type="inheritedJdk" />
|
|
||||||
<orderEntry type="sourceFolder" forTests="false" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.9.4-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.6" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.14-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.13.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:Essentials:2.13.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:craftbukkit:1.13.2-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:3.8.0_423" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.json:json:20160810" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.15.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.0" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: commons-io:commons-io:2.6" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.9" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.9" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot:1.15-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.Pravian:Aero:5f82926" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.spigotmc:spigot-api:1.12-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TotalFreedom:BukkitTelnet:4.5-pre1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-core:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-api:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.TFPatches:TF-LibsDisguises:11aea9b3cd" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.5.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldguard-bukkit:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:EssentialsX:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: io.papermc:paperlib:1.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:NMSProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:UpdatedMetaProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R1Provider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:1_8_R2Provider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:LegacyProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:ReflectionProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.ess3:FlattenedProvider:2.16.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.dv8tion:JDA:4.0.0_39" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.findbugs:jsr305:3.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.jetbrains:annotations:16.0.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.slf4j:slf4j-api:1.7.25" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.neovisionaries:nv-websocket-client:2.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okhttp3:okhttp:3.13.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.squareup.okio:okio:1.17.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-api:1.0.4" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.java.dev.jna:jna:4.4.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: club.minnced:opus-java-natives:1.0.4" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.commons:commons-collections4:4.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.sf.trove4j:trove4j:3.0.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.9.8" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.9.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.fasterxml.jackson.core:jackson-core:2.9.8" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.coreprotect:coreprotect:2.16.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-bukkit:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit:worldedit-core:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:core:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: de.schlichtherle:truezip:6.8.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: rhino:js:1.7R2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldedit.worldedit-libs:bukkit:7.0.0-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.apache.logging.log4j:log4j-slf4j-impl:2.8.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-bukkit:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard:worldguard-core:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q.worldguard.worldguard-libs:core:7.0.2" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.flywaydb:flyway-core:3.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.sk89q:commandbook:2.3" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bstats:bstats-bukkit:1.5" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.destroystokyo.paper:paper-api:1.15.1-R0.1-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.13-SNAPSHOT" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-commons:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-tree:7.1" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: org.ow2.asm:asm-analysis:7.1" level="project" />
|
|
||||||
<orderEntry type="library" name="Maven: me.rayzr522:jsonmessage:1.0.0" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.vexsoftware:votifier:v1.9" level="project" />
|
|
||||||
<orderEntry type="library" scope="PROVIDED" name="Maven: com.github.ConnorLinfoot:ActionBarAPI:5b2d642d3d" level="project" />
|
|
||||||
</component>
|
|
||||||
</module>
|
|
198
pom.xml
198
pom.xml
@ -5,12 +5,12 @@
|
|||||||
|
|
||||||
<groupId>me.totalfreedom</groupId>
|
<groupId>me.totalfreedom</groupId>
|
||||||
<artifactId>TotalFreedomMod</artifactId>
|
<artifactId>TotalFreedomMod</artifactId>
|
||||||
<version>5.5</version>
|
<version>2020.11</version>
|
||||||
<packaging>jar</packaging>
|
<packaging>jar</packaging>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
<tfm.build.codename>lttstore.com</tfm.build.codename>
|
<tfm.build.codename>Antaeus</tfm.build.codename>
|
||||||
<jar.finalName>${project.name}</jar.finalName>
|
<jar.finalName>${project.name}</jar.finalName>
|
||||||
<timestamp>${maven.build.timestamp}</timestamp>
|
<timestamp>${maven.build.timestamp}</timestamp>
|
||||||
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
<maven.build.timestamp.format>MM/dd/yyyy HH:mm</maven.build.timestamp.format>
|
||||||
@ -18,7 +18,7 @@
|
|||||||
|
|
||||||
<name>TotalFreedomMod</name>
|
<name>TotalFreedomMod</name>
|
||||||
<description>Server modification for the TotalFreedom server</description>
|
<description>Server modification for the TotalFreedom server</description>
|
||||||
<url>https://github.com/TotalFreedom/TotalFreedomMod</url>
|
<url>https://github.com/TFPatches/TotalFreedomMod</url>
|
||||||
|
|
||||||
<licenses>
|
<licenses>
|
||||||
<license>
|
<license>
|
||||||
@ -44,6 +44,16 @@
|
|||||||
<url>https://jitpack.io</url>
|
<url>https://jitpack.io</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>CodeMC</id>
|
||||||
|
<url>https://repo.codemc.org/repository/maven-public/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>nms-repo</id>
|
||||||
|
<url>https://repo.codemc.org/repository/nms/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>spigot-repo</id>
|
<id>spigot-repo</id>
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
@ -90,11 +100,6 @@
|
|||||||
<url>http://maven.sk89q.com/repo/</url>
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
<repository>
|
|
||||||
<id>CodeMC</id>
|
|
||||||
<url>https://repo.codemc.org/repository/maven-public</url>
|
|
||||||
</repository>
|
|
||||||
|
|
||||||
<repository>
|
<repository>
|
||||||
<id>papermc</id>
|
<id>papermc</id>
|
||||||
<url>https://papermc.io/repo/repository/maven-public/</url>
|
<url>https://papermc.io/repo/repository/maven-public/</url>
|
||||||
@ -104,111 +109,129 @@
|
|||||||
<id>rayzr-repo</id>
|
<id>rayzr-repo</id>
|
||||||
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
<url>https://cdn.rawgit.com/Rayzr522/maven-repo/master/</url>
|
||||||
</repository>
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>ess-repo</id>
|
||||||
|
<url>https://ci.ender.zone/plugin/repository/everything/</url>
|
||||||
|
</repository>
|
||||||
|
|
||||||
|
<repository>
|
||||||
|
<id>telesphoreo-repo</id>
|
||||||
|
<url>https://telesphoreo.me/repo/maven/</url>
|
||||||
|
</repository>
|
||||||
</repositories>
|
</repositories>
|
||||||
|
|
||||||
<dependencies>
|
<dependencies>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.projectlombok</groupId>
|
<groupId>org.projectlombok</groupId>
|
||||||
<artifactId>lombok</artifactId>
|
<artifactId>lombok</artifactId>
|
||||||
<version>1.18.0</version>
|
<version>1.18.16</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-io</groupId>
|
<groupId>commons-io</groupId>
|
||||||
<artifactId>commons-io</artifactId>
|
<artifactId>commons-io</artifactId>
|
||||||
<version>2.6</version>
|
<version>2.8.0</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.apache.commons</groupId>
|
<groupId>org.apache.commons</groupId>
|
||||||
<artifactId>commons-lang3</artifactId>
|
<artifactId>commons-lang3</artifactId>
|
||||||
<version>3.9</version>
|
<version>3.11</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>commons-codec</groupId>
|
<groupId>commons-codec</groupId>
|
||||||
<artifactId>commons-codec</artifactId>
|
<artifactId>commons-codec</artifactId>
|
||||||
<version>1.9</version>
|
<version>1.15</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>me.telesphoreo</groupId>
|
||||||
|
<artifactId>mojangson</artifactId>
|
||||||
|
<version>1.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.bstats</groupId>
|
||||||
|
<artifactId>bstats-bukkit</artifactId>
|
||||||
|
<version>1.7</version>
|
||||||
<scope>compile</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.15-R0.1-SNAPSHOT</version>
|
<version>1.16.3-R0.1-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.Pravian</groupId>
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
<artifactId>Aero</artifactId>
|
|
||||||
<version>5f82926</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.github.TotalFreedom</groupId>
|
|
||||||
<artifactId>BukkitTelnet</artifactId>
|
<artifactId>BukkitTelnet</artifactId>
|
||||||
<version>4.5-pre1</version>
|
<version>541e9fdb84</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.TFPatches</groupId>
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
<artifactId>TF-LibsDisguises</artifactId>
|
<artifactId>TF-LibsDisguises</artifactId>
|
||||||
<version>11aea9b3cd</version>
|
<version>48f01cf2fe</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldedit</groupId>
|
<groupId>com.sk89q.worldedit</groupId>
|
||||||
<artifactId>worldedit-bukkit</artifactId>
|
<artifactId>worldedit-bukkit</artifactId>
|
||||||
<version>7.1.0</version>
|
<version>7.2.0-SNAPSHOT</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.ess3</groupId>
|
<groupId>net.ess3</groupId>
|
||||||
<artifactId>EssentialsX</artifactId>
|
<artifactId>EssentialsX</artifactId>
|
||||||
<version>2.16.1</version>
|
<version>2.18.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.dv8tion</groupId>
|
<groupId>net.dv8tion</groupId>
|
||||||
<artifactId>JDA</artifactId>
|
<artifactId>JDA</artifactId>
|
||||||
<version>4.0.0_39</version>
|
<version>4.2.0_168</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>net.coreprotect</groupId>
|
<groupId>net.coreprotect</groupId>
|
||||||
<artifactId>coreprotect</artifactId>
|
<artifactId>coreprotect</artifactId>
|
||||||
<version>2.16.3</version>
|
<version>19.1</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.sk89q.worldguard</groupId>
|
<groupId>com.sk89q.worldguard</groupId>
|
||||||
<artifactId>worldguard-bukkit</artifactId>
|
<artifactId>worldguard-bukkit</artifactId>
|
||||||
<version>7.0.2</version>
|
<version>7.0.4</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.destroystokyo.paper</groupId>
|
<groupId>io.papermc</groupId>
|
||||||
<artifactId>paper-api</artifactId>
|
<artifactId>paperlib</artifactId>
|
||||||
<version>1.15.1-R0.1-SNAPSHOT</version>
|
<version>1.0.5</version>
|
||||||
<scope>provided</scope>
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>me.rayzr522</groupId>
|
<groupId>me.rayzr522</groupId>
|
||||||
<artifactId>jsonmessage</artifactId>
|
<artifactId>jsonmessage</artifactId>
|
||||||
<version>1.0.0</version>
|
<version>1.0.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
@ -219,12 +242,46 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.github.ConnorLinfoot</groupId>
|
<groupId>net.goldtreeservers</groupId>
|
||||||
<artifactId>ActionBarAPI</artifactId>
|
<artifactId>worldguardextraflags</artifactId>
|
||||||
<version>5b2d642d3d</version>
|
<version>4.0.0</version>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.reflections</groupId>
|
||||||
|
<artifactId>reflections</artifactId>
|
||||||
|
<version>0.9.12</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.javassist</groupId>
|
||||||
|
<artifactId>javassist</artifactId>
|
||||||
|
<version>3.27.0-GA</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.github.TotalFreedomMC</groupId>
|
||||||
|
<artifactId>TFGuilds</artifactId>
|
||||||
|
<version>db036fb187</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
|
||||||
|
<dependency>
|
||||||
|
<groupId>net.dean.jraw</groupId>
|
||||||
|
<artifactId>JRAW</artifactId>
|
||||||
|
<version>1.1.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -241,7 +298,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-compiler-plugin</artifactId>
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
<version>3.7.0</version>
|
<version>3.8.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
<outputFileName>TotalFreedomMod.jar</outputFileName>
|
||||||
<compilerVersion>1.8</compilerVersion>
|
<compilerVersion>1.8</compilerVersion>
|
||||||
@ -254,7 +311,7 @@
|
|||||||
<plugin>
|
<plugin>
|
||||||
<groupId>pl.project13.maven</groupId>
|
<groupId>pl.project13.maven</groupId>
|
||||||
<artifactId>git-commit-id-plugin</artifactId>
|
<artifactId>git-commit-id-plugin</artifactId>
|
||||||
<version>2.2.5</version>
|
<version>4.0.2</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<id>get-the-git-infos</id>
|
<id>get-the-git-infos</id>
|
||||||
@ -309,7 +366,8 @@
|
|||||||
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
<entry key="buildCodeName" value="${tfm.build.codename}"/>
|
||||||
<entry key="buildVersion" value="${project.version}"/>
|
<entry key="buildVersion" value="${project.version}"/>
|
||||||
<entry key="buildDate" value="${timestamp}"/>
|
<entry key="buildDate" value="${timestamp}"/>
|
||||||
<!--<entry key="buildHead" value="${git.commit.id.abbrev}"/>-->
|
<!--suppress UnresolvedMavenProperty -->
|
||||||
|
<entry key="buildHead" value="${git.commit.id.abbrev}"/>
|
||||||
</propertyfile>
|
</propertyfile>
|
||||||
</target>
|
</target>
|
||||||
</configuration>
|
</configuration>
|
||||||
@ -367,28 +425,44 @@
|
|||||||
|
|
||||||
<!-- Shade -->
|
<!-- Shade -->
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<artifactId>maven-shade-plugin</artifactId>
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
<version>2.4.3</version>
|
<version>3.2.4</version>
|
||||||
<executions>
|
<executions>
|
||||||
<execution>
|
<execution>
|
||||||
<phase>package</phase>
|
<phase>package</phase>
|
||||||
<goals>
|
<goals>
|
||||||
<goal>shade</goal>
|
<goal>shade</goal>
|
||||||
</goals>
|
</goals>
|
||||||
<configuration>
|
<configuration>
|
||||||
<minimizeJar>true</minimizeJar>
|
<minimizeJar>true</minimizeJar>
|
||||||
<artifactSet>
|
<relocations>
|
||||||
<includes>
|
<relocation>
|
||||||
<include>commons-io:commons-io</include>
|
<pattern>io.papermc.lib</pattern>
|
||||||
<include>org.apache.commons:commons-lang3</include>
|
<shadedPattern>me.totalfreedom.totalfreedommod.paperlib</shadedPattern> <!-- Replace this -->
|
||||||
<include>commons-codec:commons-codec</include>
|
</relocation>
|
||||||
</includes>
|
<relocation>
|
||||||
</artifactSet>
|
<pattern>org.bstats</pattern>
|
||||||
</configuration>
|
<shadedPattern>me.totalfreedom.totalfreedommod</shadedPattern>
|
||||||
</execution>
|
</relocation>
|
||||||
</executions>
|
</relocations>
|
||||||
</plugin>
|
<artifactSet>
|
||||||
|
<includes>
|
||||||
|
<include>commons-io:commons-io</include>
|
||||||
|
<include>org.apache.commons:commons-lang3</include>
|
||||||
|
<include>commons-codec:commons-codec</include>
|
||||||
|
<include>org.reflections:reflections</include>
|
||||||
|
<include>org.javassist:javassist</include>
|
||||||
|
<include>me.rayzr522:jsonmessage</include>
|
||||||
|
<include>io.papermc:paperlib</include>
|
||||||
|
<include>me.telesphoreo:mojangson</include>
|
||||||
|
<include>org.bstats:bstats-bukkit</include>
|
||||||
|
</includes>
|
||||||
|
</artifactSet>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
</plugins>
|
</plugins>
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
@ -398,8 +472,8 @@
|
|||||||
<plugins>
|
<plugins>
|
||||||
<plugin>
|
<plugin>
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
<version>2.17</version>
|
|
||||||
<artifactId>maven-checkstyle-plugin</artifactId>
|
<artifactId>maven-checkstyle-plugin</artifactId>
|
||||||
|
<version>3.1.1</version>
|
||||||
<configuration>
|
<configuration>
|
||||||
<configLocation>checkstyle.xml</configLocation>
|
<configLocation>checkstyle.xml</configLocation>
|
||||||
<failOnViolation>true</failOnViolation>
|
<failOnViolation>true</failOnViolation>
|
||||||
|
@ -1,23 +0,0 @@
|
|||||||
package ca.momothereal.mojangson;
|
|
||||||
|
|
||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
|
||||||
import ca.momothereal.mojangson.value.MojangsonString;
|
|
||||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
|
||||||
|
|
||||||
public class MojangsonFinder
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Automatically detects the appropriate MojangsonValue from the given value.
|
|
||||||
*
|
|
||||||
* @param value The value to parse
|
|
||||||
* @return The resulting MojangsonValue. If the type couldn't be found, it falls back to MojangsonString
|
|
||||||
* @throws MojangsonParseException if the given value could not be parsed
|
|
||||||
*/
|
|
||||||
public static MojangsonValue readFromValue(String value) throws MojangsonParseException
|
|
||||||
{
|
|
||||||
MojangsonValue val = new MojangsonString();
|
|
||||||
val.read(value);
|
|
||||||
return val;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,53 +0,0 @@
|
|||||||
package ca.momothereal.mojangson;
|
|
||||||
|
|
||||||
public enum MojangsonToken
|
|
||||||
{
|
|
||||||
|
|
||||||
COMPOUND_START(0, "Compound_Start", '{'),
|
|
||||||
COMPOUND_END(1, "Compound_End", '}'),
|
|
||||||
ELEMENT_SEPERATOR(2, "Element_Seperator", ','),
|
|
||||||
ARRAY_START(3, "Array_Start", '['),
|
|
||||||
ARRAY_END(4, "Array_End", ']'),
|
|
||||||
ELEMENT_PAIR_SEPERATOR(5, "Pair_Seperator", ':'),
|
|
||||||
|
|
||||||
STRING_QUOTES(6, "String_Quotes", '\"'),
|
|
||||||
DOUBLE_SUFFIX(8, "Double_Suffix", 'd'),
|
|
||||||
BYTE_SUFFIX(9, "Byte_Suffix", 'b'),
|
|
||||||
FLOAT_SUFFIX(10, "Float_Suffix", 'f'),
|
|
||||||
SHORT_SUFFIX(11, "Short_Suffix", 's'),
|
|
||||||
LONG_SUFFIX(12, "Long_Suffix", 'l'),
|
|
||||||
|
|
||||||
WHITE_SPACE(13, "WhiteSpace", ' ');
|
|
||||||
|
|
||||||
private int id;
|
|
||||||
private String name;
|
|
||||||
private char symbol;
|
|
||||||
|
|
||||||
MojangsonToken(int id, String name, char symbol)
|
|
||||||
{
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
this.symbol = symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getId()
|
|
||||||
{
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getName()
|
|
||||||
{
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public char getSymbol()
|
|
||||||
{
|
|
||||||
return symbol;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return String.valueOf(symbol);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package ca.momothereal.mojangson.ex;
|
|
||||||
|
|
||||||
public class MojangsonParseException extends Exception
|
|
||||||
{
|
|
||||||
|
|
||||||
private ParseExceptionReason reason;
|
|
||||||
|
|
||||||
public MojangsonParseException(String message, ParseExceptionReason reason)
|
|
||||||
{
|
|
||||||
super(message);
|
|
||||||
this.reason = reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ParseExceptionReason getReason()
|
|
||||||
{
|
|
||||||
return reason;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
return reason.getMessage() + ": " + super.getMessage();
|
|
||||||
}
|
|
||||||
|
|
||||||
public enum ParseExceptionReason
|
|
||||||
{
|
|
||||||
INVALID_FORMAT_NUM("Given value is not numerical"),
|
|
||||||
UNEXPECTED_SYMBOL("Unexpected symbol in Mojangson string");
|
|
||||||
|
|
||||||
private String message;
|
|
||||||
|
|
||||||
ParseExceptionReason(String message)
|
|
||||||
{
|
|
||||||
this.message = message;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getMessage()
|
|
||||||
{
|
|
||||||
return message;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,144 +0,0 @@
|
|||||||
package ca.momothereal.mojangson.value;
|
|
||||||
|
|
||||||
import ca.momothereal.mojangson.MojangsonFinder;
|
|
||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import static ca.momothereal.mojangson.MojangsonToken.*;
|
|
||||||
|
|
||||||
public class MojangsonCompound extends HashMap<String, List<MojangsonValue>> implements MojangsonValue<Map<String, MojangsonValue>>
|
|
||||||
{
|
|
||||||
|
|
||||||
private final int C_COMPOUND_START = 0; // Parsing context
|
|
||||||
private final int C_COMPOUND_PAIR_KEY = 1; // Parsing context
|
|
||||||
private final int C_COMPOUND_PAIR_VALUE = 2; // Parsing context
|
|
||||||
|
|
||||||
public MojangsonCompound()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MojangsonCompound(Map map)
|
|
||||||
{
|
|
||||||
super(map);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(StringBuilder builder)
|
|
||||||
{
|
|
||||||
builder.append(COMPOUND_START);
|
|
||||||
boolean start = true;
|
|
||||||
|
|
||||||
for (String key : keySet())
|
|
||||||
{
|
|
||||||
if (start)
|
|
||||||
{
|
|
||||||
start = false;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
builder.append(ELEMENT_SEPERATOR);
|
|
||||||
}
|
|
||||||
|
|
||||||
builder.append(key).append(ELEMENT_PAIR_SEPERATOR);
|
|
||||||
List<MojangsonValue> value = get(key);
|
|
||||||
for (MojangsonValue val : value)
|
|
||||||
{
|
|
||||||
val.write(builder);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
builder.append(COMPOUND_END);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(String string) throws MojangsonParseException
|
|
||||||
{
|
|
||||||
int context = C_COMPOUND_START;
|
|
||||||
String tmp_key = "", tmp_val = "";
|
|
||||||
int scope = 0;
|
|
||||||
boolean inString = false;
|
|
||||||
|
|
||||||
for (int index = 0; index < string.length(); index++)
|
|
||||||
{
|
|
||||||
Character character = string.charAt(index);
|
|
||||||
|
|
||||||
if (character == STRING_QUOTES.getSymbol())
|
|
||||||
{
|
|
||||||
inString = !inString;
|
|
||||||
}
|
|
||||||
if (character == WHITE_SPACE.getSymbol())
|
|
||||||
{
|
|
||||||
if (!inString)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ((character == COMPOUND_START.getSymbol() || character == ARRAY_START.getSymbol()) && !inString)
|
|
||||||
{
|
|
||||||
scope++;
|
|
||||||
}
|
|
||||||
if ((character == COMPOUND_END.getSymbol() || character == ARRAY_END.getSymbol()) && !inString)
|
|
||||||
{
|
|
||||||
scope--;
|
|
||||||
}
|
|
||||||
if (context == C_COMPOUND_START)
|
|
||||||
{
|
|
||||||
if (character != COMPOUND_START.getSymbol())
|
|
||||||
{
|
|
||||||
parseException(index, character);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
context++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (context == C_COMPOUND_PAIR_KEY)
|
|
||||||
{
|
|
||||||
if (character == ELEMENT_PAIR_SEPERATOR.getSymbol() && scope <= 1)
|
|
||||||
{
|
|
||||||
context++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tmp_key += character;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (context == C_COMPOUND_PAIR_VALUE)
|
|
||||||
{
|
|
||||||
if ((character == ELEMENT_SEPERATOR.getSymbol() || character == COMPOUND_END.getSymbol()) && scope <= 1 && !inString)
|
|
||||||
{
|
|
||||||
context = C_COMPOUND_PAIR_KEY;
|
|
||||||
computeIfAbsent(tmp_key, k -> new ArrayList<>()).add(MojangsonFinder.readFromValue(tmp_val));
|
|
||||||
tmp_key = tmp_val = "";
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
tmp_val += character;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Map<String, MojangsonValue> getValue()
|
|
||||||
{
|
|
||||||
HashMap<String, MojangsonValue> hack = new HashMap<>();
|
|
||||||
for (String string : keySet())
|
|
||||||
{
|
|
||||||
for (MojangsonValue value : get(string))
|
|
||||||
{
|
|
||||||
hack.put(string, value);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return hack;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class getValueClass()
|
|
||||||
{
|
|
||||||
return Map.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
private void parseException(int index, char symbol) throws MojangsonParseException
|
|
||||||
{
|
|
||||||
throw new MojangsonParseException("Index: " + index + ", symbol: \'" + symbol + "\'", MojangsonParseException.ParseExceptionReason.UNEXPECTED_SYMBOL);
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,57 +0,0 @@
|
|||||||
package ca.momothereal.mojangson.value;
|
|
||||||
|
|
||||||
import ca.momothereal.mojangson.MojangsonToken;
|
|
||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
|
||||||
|
|
||||||
public class MojangsonString implements MojangsonValue<String>
|
|
||||||
{
|
|
||||||
private String value;
|
|
||||||
|
|
||||||
public MojangsonString()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public MojangsonString(String value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getValue()
|
|
||||||
{
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setValue(String value)
|
|
||||||
{
|
|
||||||
this.value = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void write(StringBuilder builder)
|
|
||||||
{
|
|
||||||
builder.append(MojangsonToken.STRING_QUOTES).append(value).append(MojangsonToken.STRING_QUOTES);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Class getValueClass()
|
|
||||||
{
|
|
||||||
return String.class;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void read(String string) throws MojangsonParseException
|
|
||||||
{
|
|
||||||
Character lastChar = string.charAt(string.length() - 1);
|
|
||||||
Character firstChar = string.charAt(0);
|
|
||||||
|
|
||||||
if (firstChar == MojangsonToken.STRING_QUOTES.getSymbol() && lastChar == MojangsonToken.STRING_QUOTES.getSymbol())
|
|
||||||
{
|
|
||||||
value = string.substring(1, string.length() - 1);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
value = string;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,42 +0,0 @@
|
|||||||
package ca.momothereal.mojangson.value;
|
|
||||||
|
|
||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Represents a value inside a compound or array.
|
|
||||||
*
|
|
||||||
* @param <T> The type of value this MojangsonValue holds
|
|
||||||
*/
|
|
||||||
public interface MojangsonValue<T>
|
|
||||||
{
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Writes the value to a StringBuilder buffer.
|
|
||||||
*
|
|
||||||
* @param builder The buffer to write to
|
|
||||||
*/
|
|
||||||
void write(StringBuilder builder);
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Parses and updates the current value to the given string representation
|
|
||||||
*
|
|
||||||
* @param string The string representation of the value
|
|
||||||
* @throws MojangsonParseException if the given value cannot be parsed
|
|
||||||
*/
|
|
||||||
void read(String string) throws MojangsonParseException;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the current literal value
|
|
||||||
*
|
|
||||||
* @return The current literal value of the MojangsonValue
|
|
||||||
*/
|
|
||||||
T getValue();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the literal value's class
|
|
||||||
*
|
|
||||||
* @return The literal value's class
|
|
||||||
*/
|
|
||||||
Class getValueClass();
|
|
||||||
|
|
||||||
}
|
|
@ -21,13 +21,8 @@ public class Announcer extends FreedomService
|
|||||||
private String prefix;
|
private String prefix;
|
||||||
private BukkitTask announcer;
|
private BukkitTask announcer;
|
||||||
|
|
||||||
public Announcer(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
enabled = ConfigEntry.ANNOUNCER_ENABLED.getBoolean();
|
||||||
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
interval = ConfigEntry.ANNOUNCER_INTERVAL.getInteger() * 20L;
|
||||||
@ -64,7 +59,7 @@ public class Announcer extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
if (announcer == null)
|
if (announcer == null)
|
||||||
{
|
{
|
||||||
|
@ -4,7 +4,6 @@ import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -13,19 +12,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
|
|
||||||
public class AntiNuke extends FreedomService
|
public class AntiNuke extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public AntiNuke(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -10,13 +12,8 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.event.player.PlayerKickEvent;
|
import org.bukkit.event.player.PlayerKickEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
|
||||||
import org.bukkit.event.player.PlayerLoginEvent.Result;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
public class AntiSpam extends FreedomService
|
public class AntiSpam extends FreedomService
|
||||||
{
|
{
|
||||||
@ -27,13 +24,8 @@ public class AntiSpam extends FreedomService
|
|||||||
//
|
//
|
||||||
public BukkitTask cycleTask = null;
|
public BukkitTask cycleTask = null;
|
||||||
|
|
||||||
public AntiSpam(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
@ -47,7 +39,7 @@ public class AntiSpam extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(cycleTask);
|
FUtil.cancel(cycleTask);
|
||||||
}
|
}
|
||||||
@ -70,7 +62,7 @@ public class AntiSpam extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -117,7 +109,7 @@ public class AntiSpam extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,6 @@ import java.util.Map;
|
|||||||
import me.totalfreedom.totalfreedommod.banning.Ban;
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
@ -19,25 +18,20 @@ public class AutoEject extends FreedomService
|
|||||||
|
|
||||||
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
private final Map<String, Integer> ejects = new HashMap<>(); // ip -> amount
|
||||||
|
|
||||||
public AutoEject(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public void autoEject(Player player, String kickMessage)
|
public void autoEject(Player player, String kickMessage)
|
||||||
{
|
{
|
||||||
EjectMethod method = EjectMethod.STRIKE_ONE;
|
EjectMethod method = EjectMethod.STRIKE_ONE;
|
||||||
final String ip = Ips.getIp(player);
|
final String ip = FUtil.getIp(player);
|
||||||
|
|
||||||
if (!ejects.containsKey(ip))
|
if (!ejects.containsKey(ip))
|
||||||
{
|
{
|
||||||
|
@ -15,13 +15,8 @@ public class AutoKick extends FreedomService
|
|||||||
private long autoKickTicks;
|
private long autoKickTicks;
|
||||||
private double autoKickThreshold;
|
private double autoKickThreshold;
|
||||||
|
|
||||||
public AutoKick(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
autoKickTicks = (long)ConfigEntry.AUTOKICK_TIME.getInteger() * 1000L;
|
||||||
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
autoKickThreshold = ConfigEntry.AUTOKICK_THRESHOLD.getDouble();
|
||||||
@ -43,7 +38,7 @@ public class AutoKick extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
FUtil.cancel(kickTask);
|
FUtil.cancel(kickTask);
|
||||||
kickTask = null;
|
kickTask = null;
|
||||||
|
@ -1,18 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.component.PluginComponent;
|
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import org.bukkit.util.FileUtil;
|
import org.bukkit.util.FileUtil;
|
||||||
|
|
||||||
public class BackupManager extends PluginComponent<TotalFreedomMod>
|
public class BackupManager extends FreedomService
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public BackupManager(TotalFreedomMod plugin)
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void createBackups(String file)
|
public void createBackups(String file)
|
||||||
@ -20,6 +26,15 @@ public class BackupManager extends PluginComponent<TotalFreedomMod>
|
|||||||
createBackups(file, false);
|
createBackups(file, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void createAllBackups()
|
||||||
|
{
|
||||||
|
createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
||||||
|
createBackups(IndefiniteBanList.CONFIG_FILENAME);
|
||||||
|
createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
||||||
|
createBackups(PunishmentList.CONFIG_FILENAME);
|
||||||
|
createBackups("database.db");
|
||||||
|
}
|
||||||
|
|
||||||
public void createBackups(String file, boolean onlyWeekly)
|
public void createBackups(String file, boolean onlyWeekly)
|
||||||
{
|
{
|
||||||
final String save = file.split("\\.")[0];
|
final String save = file.split("\\.")[0];
|
||||||
|
@ -1,47 +1,38 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import com.google.common.base.Strings;
|
import com.google.common.base.Strings;
|
||||||
import java.time.LocalDate;
|
|
||||||
import java.time.Period;
|
|
||||||
import java.util.Date;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
import me.totalfreedom.totalfreedommod.shop.ShopData;
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.SoundCategory;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
import org.bukkit.Sound;
|
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
||||||
import org.bukkit.SoundCategory;
|
|
||||||
|
|
||||||
public class ChatManager extends FreedomService
|
public class ChatManager extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public ChatManager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGHEST, ignoreCancelled = true)
|
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
|
||||||
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
public void onPlayerChatFormat(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
@ -63,35 +54,24 @@ public class ChatManager extends FreedomService
|
|||||||
message = FUtil.colorize(message);
|
message = FUtil.colorize(message);
|
||||||
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
message = message.replaceAll(ChatColor.MAGIC.toString(), "&k");
|
||||||
|
|
||||||
if (ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
if (ConfigEntry.SHOP_ENABLED.getBoolean() && ConfigEntry.SHOP_REACTIONS_ENABLED.getBoolean() && !plugin.sh.reactionString.isEmpty() && message.equals(plugin.sh.reactionString))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
ShopData data = plugin.sh.getData(player);
|
PlayerData data = plugin.pl.getData(player);
|
||||||
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
data.setCoins(data.getCoins() + plugin.sh.coinsPerReactionWin);
|
||||||
plugin.sh.save(data);
|
plugin.pl.save(data);
|
||||||
plugin.sh.reactionString = "";
|
plugin.sh.endReaction(player.getName());
|
||||||
Date currentTime = new Date();
|
|
||||||
long seconds = (currentTime.getTime() - plugin.sh.reactionStartTime.getTime()) / 1000;
|
|
||||||
String reactionMessage = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "Reaction" + ChatColor.DARK_GRAY + "] "
|
|
||||||
+ ChatColor.GREEN + player.getName() + ChatColor.AQUA + " won in " + seconds + " seconds!";
|
|
||||||
FUtil.bcastMsg(reactionMessage, false);
|
|
||||||
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
player.sendMessage(ChatColor.GREEN + "You have been given " + ChatColor.GOLD + plugin.sh.coinsPerReactionWin + ChatColor.GREEN + " coins!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.al.isAdmin(player))
|
if (!ConfigEntry.TOGGLE_CHAT.getBoolean() && !plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
playerMsg(player, "Chat is currently disabled.", ChatColor.RED);
|
playerMsg(player, "Chat is currently disabled.", org.bukkit.ChatColor.RED);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message.startsWith("Connected using PickaxeChat for "))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Truncate messages that are too long - 256 characters is vanilla client max
|
// Truncate messages that are too long - 256 characters is vanilla client max
|
||||||
if (message.length() > 256)
|
if (message.length() > 256)
|
||||||
{
|
{
|
||||||
@ -99,7 +79,6 @@ public class ChatManager extends FreedomService
|
|||||||
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
FSync.playerMsg(player, "Message was shortened because it was too long to send.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
final FPlayer fPlayer = plugin.pl.getPlayerSync(player);
|
||||||
if (fPlayer.isLockedUp())
|
if (fPlayer.isLockedUp())
|
||||||
{
|
{
|
||||||
@ -108,10 +87,10 @@ public class ChatManager extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check for adminchat
|
// Check for staffchat
|
||||||
if (fPlayer.inAdminChat())
|
if (fPlayer.inStaffChat())
|
||||||
{
|
{
|
||||||
FSync.adminChatMessage(player, message);
|
FSync.staffChatMessage(player, message);
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -144,7 +123,7 @@ public class ChatManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for mentions
|
// Check for mentions
|
||||||
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.al.isAdmin(player);
|
Boolean mentionEveryone = ChatColor.stripColor(message).toLowerCase().contains("@everyone") && plugin.sl.isStaff(player);
|
||||||
for (Player p : server.getOnlinePlayers())
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
if (ChatColor.stripColor(message).toLowerCase().contains("@" + p.getName().toLowerCase()) || mentionEveryone)
|
||||||
@ -157,76 +136,44 @@ public class ChatManager extends FreedomService
|
|||||||
event.setFormat(format);
|
event.setFormat(format);
|
||||||
|
|
||||||
// Send to discord
|
// Send to discord
|
||||||
if (!ConfigEntry.ADMIN_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist())
|
if (!ConfigEntry.STAFF_ONLY_MODE.getBoolean() && !Bukkit.hasWhitelist() && !plugin.pl.getPlayer(player).isMuted() && !plugin.tfg.inGuildChat(player))
|
||||||
{
|
{
|
||||||
plugin.dc.messageChatChannel(player.getName() + " \u00BB " + ChatColor.stripColor(message));
|
plugin.dc.messageChatChannel(plugin.dc.deformat(player.getName()) + " \u00BB " + ChatColor.stripColor(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public ChatColor getColor(Admin admin, Displayable display)
|
public ChatColor getColor(Displayable display)
|
||||||
{
|
{
|
||||||
ChatColor color = display.getColor();
|
ChatColor color = display.getColor();
|
||||||
if (admin.getOldTags())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (color.equals(ChatColor.AQUA))
|
|
||||||
{
|
|
||||||
color = ChatColor.GOLD;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.GOLD))
|
|
||||||
{
|
|
||||||
color = ChatColor.LIGHT_PURPLE;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.DARK_RED))
|
|
||||||
{
|
|
||||||
color = ChatColor.BLUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color;
|
return color;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getColoredTag(Admin admin, Displayable display)
|
public String getColoredTag(Displayable display)
|
||||||
{
|
{
|
||||||
ChatColor color = display.getColor();
|
ChatColor color = display.getColor();
|
||||||
if (admin.getOldTags())
|
|
||||||
{
|
|
||||||
|
|
||||||
if (color.equals(ChatColor.AQUA))
|
|
||||||
{
|
|
||||||
color = ChatColor.GOLD;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.GOLD))
|
|
||||||
{
|
|
||||||
color = ChatColor.LIGHT_PURPLE;
|
|
||||||
}
|
|
||||||
else if (color.equals(ChatColor.DARK_RED))
|
|
||||||
{
|
|
||||||
color = ChatColor.BLUE;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return color + display.getAbbr();
|
return color + display.getAbbr();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void adminChat(CommandSender sender, String message)
|
public void staffChat(CommandSender sender, String message)
|
||||||
{
|
{
|
||||||
Displayable display = plugin.rm.getDisplay(sender);
|
Displayable display = plugin.rm.getDisplay(sender);
|
||||||
FLog.info("[ADMIN] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
FLog.info("[STAFF] " + sender.getName() + " " + display.getTag() + ": " + message, true);
|
||||||
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
Admin admin = plugin.al.getAdmin(player);
|
StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
if (!Strings.isNullOrEmpty(admin.getAcFormat()))
|
if (!Strings.isNullOrEmpty(staffMember.getAcFormat()))
|
||||||
{
|
{
|
||||||
String format = admin.getAcFormat();
|
String format = staffMember.getAcFormat();
|
||||||
ChatColor color = getColor(admin, display);
|
ChatColor color = getColor(display);
|
||||||
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
String msg = format.replace("%name%", sender.getName()).replace("%rank%", display.getAbbr()).replace("%rankcolor%", color.toString()).replace("%msg%", message);
|
||||||
player.sendMessage(FUtil.colorize(msg));
|
player.sendMessage(FUtil.colorize(msg));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
player.sendMessage("[" + ChatColor.AQUA + "ADMIN" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(admin, display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
player.sendMessage("[" + ChatColor.AQUA + "STAFF" + ChatColor.WHITE + "] " + ChatColor.DARK_RED + sender.getName() + ChatColor.DARK_GRAY + " [" + getColoredTag(display) + ChatColor.DARK_GRAY + "]" + ChatColor.WHITE + ": " + ChatColor.GOLD + FUtil.colorize(message));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -236,11 +183,11 @@ public class ChatManager extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
playerMsg(player, ChatColor.RED + "[REPORTS] " + ChatColor.GOLD + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
FLog.info("[REPORTS] " + reporter.getName() + " has reported " + reported.getName() + " for " + report);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -5,23 +5,16 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CommandSpy extends FreedomService
|
public class CommandSpy extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public CommandSpy(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -30,9 +23,9 @@ public class CommandSpy extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) && plugin.al.getAdmin(player).getCommandSpy())
|
if (plugin.sl.isStaff(player) && plugin.sl.getAdmin(player).getCommandSpy())
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(event.getPlayer()) && !plugin.al.isSeniorAdmin(player))
|
if (plugin.sl.isStaff(event.getPlayer()) && !plugin.sl.isAdmin(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -16,21 +16,17 @@ public class EntityWiper extends FreedomService
|
|||||||
{
|
{
|
||||||
private BukkitTask wiper;
|
private BukkitTask wiper;
|
||||||
|
|
||||||
public EntityWiper(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<EntityType> BLACKLIST = Arrays.asList(
|
public List<EntityType> BLACKLIST = Arrays.asList(
|
||||||
EntityType.ARMOR_STAND,
|
EntityType.ARMOR_STAND,
|
||||||
EntityType.PAINTING,
|
EntityType.PAINTING,
|
||||||
EntityType.BOAT,
|
EntityType.BOAT,
|
||||||
EntityType.LEASH_HITCH,
|
EntityType.LEASH_HITCH,
|
||||||
EntityType.ITEM_FRAME
|
EntityType.ITEM_FRAME,
|
||||||
|
EntityType.MINECART
|
||||||
);
|
);
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
// Continuous Entity Wiper
|
// Continuous Entity Wiper
|
||||||
wiper = new BukkitRunnable()
|
wiper = new BukkitRunnable()
|
||||||
@ -44,7 +40,7 @@ public class EntityWiper extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
wiper.cancel();
|
wiper.cancel();
|
||||||
wiper = null;
|
wiper = null;
|
||||||
@ -61,7 +57,7 @@ public class EntityWiper extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!(entity instanceof Player))
|
if (!(entity instanceof Player))
|
||||||
{
|
{
|
||||||
if (!bypassBlacklist && (BLACKLIST.contains(entity.getType()) || Groups.MOB_TYPES.contains(entity.getType())))
|
if ((!bypassBlacklist && BLACKLIST.contains(entity.getType())) || Groups.MOB_TYPES.contains(entity.getType()))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1,13 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import net.pravian.aero.component.service.AbstractService;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
|
||||||
public abstract class FreedomService extends AbstractService<TotalFreedomMod>
|
public abstract class FreedomService implements Listener
|
||||||
{
|
{
|
||||||
|
protected final TotalFreedomMod plugin;
|
||||||
|
protected final Server server;
|
||||||
|
protected final FLog logger;
|
||||||
|
|
||||||
public FreedomService(TotalFreedomMod plugin)
|
public FreedomService()
|
||||||
{
|
{
|
||||||
super(plugin);
|
plugin = TotalFreedomMod.getPlugin();
|
||||||
|
server = plugin.getServer();
|
||||||
|
logger = new FLog();
|
||||||
|
plugin.getServer().getPluginManager().registerEvents(this, plugin);
|
||||||
|
plugin.fsh.add(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public abstract void onStart();
|
||||||
|
public abstract void onStop();
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,56 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public class FreedomServiceHandler
|
||||||
|
{
|
||||||
|
@Getter
|
||||||
|
private List<FreedomService> services;
|
||||||
|
|
||||||
|
public FreedomServiceHandler()
|
||||||
|
{
|
||||||
|
this.services = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void add(FreedomService service)
|
||||||
|
{
|
||||||
|
services.add(service);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getServiceAmount()
|
||||||
|
{
|
||||||
|
return services.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void startServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStart();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void stopServices()
|
||||||
|
{
|
||||||
|
for (FreedomService service : getServices())
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
service.onStop();
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,18 +9,13 @@ import org.bukkit.event.player.PlayerMoveEvent;
|
|||||||
|
|
||||||
public class Fuckoff extends FreedomService
|
public class Fuckoff extends FreedomService
|
||||||
{
|
{
|
||||||
public Fuckoff(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,7 +48,7 @@ public class Fuckoff extends FreedomService
|
|||||||
|
|
||||||
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
if (distanceSquared < (fuckoffRange * fuckoffRange))
|
||||||
{
|
{
|
||||||
event.setTo(foLocation.clone().add(opLocation.subtract(foLocation).toVector().normalize().multiply(fuckoffRange * 1.1)));
|
fuckoffPlayer.setVelocity(onlinePlayer.getLocation().toVector().add(foLocation.toVector()).normalize().multiply(fPlayer.getFuckoffRadius()));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -13,10 +13,8 @@ public class GameRuleHandler extends FreedomService
|
|||||||
|
|
||||||
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
private final Map<GameRule, Boolean> rules = new EnumMap<>(GameRule.class);
|
||||||
|
|
||||||
public GameRuleHandler(TotalFreedomMod plugin)
|
public GameRuleHandler()
|
||||||
{
|
{
|
||||||
super(plugin);
|
|
||||||
|
|
||||||
for (GameRule gameRule : GameRule.values())
|
for (GameRule gameRule : GameRule.values())
|
||||||
{
|
{
|
||||||
rules.put(gameRule, gameRule.getDefaultValue());
|
rules.put(gameRule, gameRule.getDefaultValue());
|
||||||
@ -24,7 +22,7 @@ public class GameRuleHandler extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
setGameRule(GameRule.DO_DAYLIGHT_CYCLE, !ConfigEntry.DISABLE_NIGHT.getBoolean(), false);
|
||||||
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
setGameRule(GameRule.DO_FIRE_TICK, ConfigEntry.ALLOW_FIRE_SPREAD.getBoolean(), false);
|
||||||
@ -37,11 +35,12 @@ public class GameRuleHandler extends FreedomService
|
|||||||
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
setGameRule(GameRule.KEEP_INVENTORY, true, false);
|
||||||
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
|
setGameRule(GameRule.ANNOUNCE_ADVANCEMENTS, false, false);
|
||||||
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
|
setGameRule(GameRule.SHOW_DEATH_MESSAGES, false, false);
|
||||||
|
setGameRule(GameRule.SEND_COMMAND_FEEDBACK, false, false);
|
||||||
commitGameRules();
|
commitGameRules();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +96,8 @@ public class GameRuleHandler extends FreedomService
|
|||||||
NATURAL_REGENERATION("naturalRegeneration", true),
|
NATURAL_REGENERATION("naturalRegeneration", true),
|
||||||
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
DO_DAYLIGHT_CYCLE("doDaylightCycle", true),
|
||||||
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
ANNOUNCE_ADVANCEMENTS("announceAdvancements", false),
|
||||||
SHOW_DEATH_MESSAGES("showDeathMessages", false);
|
SHOW_DEATH_MESSAGES("showDeathMessages", false),
|
||||||
|
SEND_COMMAND_FEEDBACK("sendCommandFeedback", false);
|
||||||
//
|
//
|
||||||
private final String gameRuleName;
|
private final String gameRuleName;
|
||||||
private final boolean defaultValue;
|
private final boolean defaultValue;
|
||||||
|
@ -23,19 +23,13 @@ import org.bukkit.scheduler.BukkitRunnable;
|
|||||||
|
|
||||||
public class LogViewer extends FreedomService
|
public class LogViewer extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public LogViewer(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,15 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.command.Command_vanish;
|
import me.rayzr522.jsonmessage.JSONMessage;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
@ -22,34 +22,27 @@ import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerLoginEvent;
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
import me.rayzr522.jsonmessage.JSONMessage;
|
|
||||||
|
|
||||||
public class LoginProcess extends FreedomService
|
public class LoginProcess extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final int DEFAULT_PORT = 25565;
|
public static final int DEFAULT_PORT = 25565;
|
||||||
public static final int MIN_USERNAME_LENGTH = 2;
|
public static final int MIN_USERNAME_LENGTH = 2;
|
||||||
public static final int MAX_USERNAME_LENGTH = 20;
|
public static final int MAX_USERNAME_LENGTH = 20;
|
||||||
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
public static final Pattern USERNAME_REGEX = Pattern.compile("^[\\w\\d_]{3,20}$");
|
||||||
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
public List<String> TELEPORT_ON_JOIN = new ArrayList<>();
|
||||||
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
public List<String> CLEAR_ON_JOIN = new ArrayList<>();
|
||||||
//
|
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
private static boolean lockdownEnabled = false;
|
private static boolean lockdownEnabled = false;
|
||||||
|
|
||||||
public LoginProcess(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -60,7 +53,7 @@ public class LoginProcess extends FreedomService
|
|||||||
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
public void onPlayerPreLogin(AsyncPlayerPreLoginEvent event)
|
||||||
{
|
{
|
||||||
final String ip = event.getAddress().getHostAddress().trim();
|
final String ip = event.getAddress().getHostAddress().trim();
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
// Check if the player is already online
|
// Check if the player is already online
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
@ -70,10 +63,10 @@ public class LoginProcess extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin)
|
if (isStaff)
|
||||||
{
|
{
|
||||||
event.allow();
|
event.allow();
|
||||||
FSync.playerKick(onlinePlayer, "An admin just logged in with the username you are using.");
|
FSync.playerKick(onlinePlayer, "A staff member just logged in with the username you are using.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,11 +113,11 @@ public class LoginProcess extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if player is admin
|
// Check if player is staff
|
||||||
final boolean isAdmin = plugin.al.getEntryByIp(ip) != null;
|
final boolean isStaff = plugin.sl.getEntryByIp(ip) != null;
|
||||||
|
|
||||||
// Validation below this point
|
// Validation below this point
|
||||||
if (isAdmin) // Player is admin
|
if (isStaff) // Player is staff
|
||||||
{
|
{
|
||||||
// Force-allow log in
|
// Force-allow log in
|
||||||
event.allow();
|
event.allow();
|
||||||
@ -134,9 +127,9 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
for (Player onlinePlayer : server.getOnlinePlayers())
|
for (Player onlinePlayer : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(onlinePlayer))
|
if (!plugin.sl.isStaff(onlinePlayer))
|
||||||
{
|
{
|
||||||
onlinePlayer.kickPlayer("You have been kicked to free up room for an admin.");
|
onlinePlayer.kickPlayer("You have been kicked to free up room for a staff member.");
|
||||||
count--;
|
count--;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -156,7 +149,7 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Player is not an admin
|
// Player is not a staff member
|
||||||
// Server full check
|
// Server full check
|
||||||
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
if (server.getOnlinePlayers().size() >= server.getMaxPlayers())
|
||||||
{
|
{
|
||||||
@ -164,10 +157,10 @@ public class LoginProcess extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Admin-only mode
|
// Staff-only mode
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to admins only.");
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, "Server is temporarily open to staff only.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -194,23 +187,29 @@ public class LoginProcess extends FreedomService
|
|||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
final VPlayer verificationPlayer = plugin.pv.getVerificationPlayer(player);
|
final PlayerData playerData = plugin.pl.getData(player);
|
||||||
|
|
||||||
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
player.sendTitle(FUtil.colorize(ConfigEntry.SERVER_LOGIN_TITLE.getString()), FUtil.colorize(ConfigEntry.SERVER_LOGIN_SUBTITLE.getString()), 20, 100, 60);
|
||||||
player.setOp(true);
|
player.setOp(true);
|
||||||
|
|
||||||
if (TELEPORT_ON_JOIN.contains(player.getName()))
|
if (TELEPORT_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_TP.getBoolean())
|
||||||
{
|
{
|
||||||
int x = FUtil.randomInteger(-10000, 10000);
|
int x = FUtil.randomInteger(-10000, 10000);
|
||||||
int z = FUtil.randomInteger(-10000, 10000);
|
int z = FUtil.randomInteger(-10000, 10000);
|
||||||
int y = player.getWorld().getHighestBlockYAt(x, z);
|
int y = player.getWorld().getHighestBlockYAt(x, z);
|
||||||
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
Location location = new Location(player.getLocation().getWorld(), x, y, z);
|
||||||
player.teleport(location);
|
PaperLib.teleportAsync(player, location);
|
||||||
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
player.sendMessage(ChatColor.AQUA + "You have been teleported to a random location automatically.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (CLEAR_ON_JOIN.contains(player.getName()))
|
if (!playerData.hasVerification() && !playerData.getIps().contains(FUtil.getIp(player)))
|
||||||
|
{
|
||||||
|
playerData.addIp(FUtil.getIp(player));
|
||||||
|
plugin.pl.save(playerData);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (CLEAR_ON_JOIN.contains(player.getName()) || ConfigEntry.AUTO_CLEAR.getBoolean())
|
||||||
{
|
{
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
player.sendMessage(ChatColor.AQUA + "Your inventory has been cleared automatically.");
|
||||||
@ -227,45 +226,27 @@ public class LoginProcess extends FreedomService
|
|||||||
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
player.setPlayerListFooter(FUtil.colorize(ConfigEntry.SERVER_TABLIST_FOOTER.getString()).replace("\\n", "\n"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (Player p : plugin.al.vanished)
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
String tag = playerData.getTag();
|
||||||
|
if (tag != null)
|
||||||
{
|
{
|
||||||
player.hidePlayer(plugin, p);
|
fPlayer.setTag(FUtil.colorize(tag));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
int noteCount = playerData.getNotes().size();
|
||||||
{
|
if (noteCount != 0)
|
||||||
if (plugin.mbl.isMasterBuilder(player))
|
|
||||||
{
|
{
|
||||||
MasterBuilder masterBuilder = plugin.mbl.getMasterBuilder(player);
|
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
||||||
if (masterBuilder.getTag() != null)
|
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
||||||
|
.tooltip("Click here to view them.")
|
||||||
|
.runCommand("/notes " + player.getName() + " list");
|
||||||
|
FLog.info(noteMessage);
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
fPlayer.setTag(FUtil.colorize(masterBuilder.getTag()));
|
if (plugin.sl.isStaffImpostor(p))
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
VPlayer vPlayer = plugin.pv.getVerificationPlayer(player);
|
|
||||||
if (vPlayer.getEnabled() && vPlayer.getTag() != null)
|
|
||||||
{
|
|
||||||
fPlayer.setTag(FUtil.colorize(vPlayer.getTag()));
|
|
||||||
}
|
|
||||||
int noteCount = vPlayer.getNotes().size();
|
|
||||||
if (noteCount != 0)
|
|
||||||
{
|
|
||||||
String noteMessage = "This player has " + noteCount + " staff note" + (noteCount > 1 ? "s" : "") + ".";
|
|
||||||
JSONMessage notice = JSONMessage.create(ChatColor.GOLD + noteMessage + " Click here to view them.")
|
|
||||||
.tooltip("Click here to view them.")
|
|
||||||
.runCommand("/notes " + player.getName() + " list");
|
|
||||||
FLog.info(noteMessage);
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdminImpostor(p))
|
notice.send(p);
|
||||||
{
|
|
||||||
notice.send(p);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -276,9 +257,9 @@ public class LoginProcess extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.RED + "Server is currently closed to non-admins.");
|
player.sendMessage(ChatColor.RED + "Server is currently closed to non-staff.");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (lockdownEnabled)
|
if (lockdownEnabled)
|
||||||
@ -286,7 +267,6 @@ public class LoginProcess extends FreedomService
|
|||||||
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
FUtil.playerMsg(player, "Warning: Server is currenty in lockdown-mode, new players will not be able to join!", ChatColor.RED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.runTaskLater(plugin, 20L * 1L);
|
}.runTaskLater(plugin, 20L);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -1,61 +1,86 @@
|
|||||||
package me.totalfreedom.totalfreedommod;
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
import java.text.DecimalFormat;
|
import java.util.AbstractMap;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.ThrownPotion;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
import org.bukkit.event.entity.LingeringPotionSplashEvent;
|
||||||
import org.bukkit.event.entity.PotionSplashEvent;
|
import org.bukkit.event.entity.PotionSplashEvent;
|
||||||
import org.bukkit.projectiles.ProjectileSource;
|
import org.bukkit.potion.PotionEffect;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
public class Monitors extends FreedomService
|
public class Monitors extends FreedomService
|
||||||
{
|
{
|
||||||
|
@Getter
|
||||||
|
private final List<Map.Entry<ThrownPotion, Long>> allThrownPotions = new ArrayList<>();
|
||||||
|
private final Map<Player, List<ThrownPotion>> recentlyThrownPotions = new HashMap<>();
|
||||||
|
private final List<PotionEffectType> badPotionEffects = new ArrayList<>(Arrays.asList(PotionEffectType.BLINDNESS,
|
||||||
|
PotionEffectType.LEVITATION, PotionEffectType.CONFUSION, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.HUNGER)); // A list of all effects that count as "troll".
|
||||||
|
|
||||||
private final DecimalFormat decimalFormat = new DecimalFormat("#");
|
@Override
|
||||||
private String potionSpyPrefix = ChatColor.DARK_GRAY + "[" + ChatColor.YELLOW + "PotionSpy" + ChatColor.DARK_GRAY + "] ";
|
public void onStart()
|
||||||
|
|
||||||
public Monitors(TotalFreedomMod plugin)
|
|
||||||
{
|
{
|
||||||
super(plugin);
|
Bukkit.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
|
||||||
|
{
|
||||||
|
for (Player player : recentlyThrownPotions.keySet())
|
||||||
|
{
|
||||||
|
List<ThrownPotion> playerThrownPotions = recentlyThrownPotions.get(player);
|
||||||
|
ThrownPotion latestThrownPotion = playerThrownPotions.get(playerThrownPotions.size() - 1); // Get most recently thrown potion for the position.
|
||||||
|
int potionsThrown = playerThrownPotions.size();
|
||||||
|
int trollPotions = 0;
|
||||||
|
|
||||||
|
for (ThrownPotion potion : playerThrownPotions)
|
||||||
|
{
|
||||||
|
if (isTrollPotion(potion))
|
||||||
|
{
|
||||||
|
trollPotions++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
plugin.sl.potionSpyMessage(ChatColor.translateAlternateColorCodes('&', String.format("&8[&ePotionSpy&8] &r%s splashed %s %s at X: %s Y: %s Z: %s in the world '%s'%s.",
|
||||||
|
player.getName(), potionsThrown, potionsThrown == 1 ? "potion" : "potions", latestThrownPotion.getLocation().getBlockX(), latestThrownPotion.getLocation().getBlockY(), latestThrownPotion.getLocation().getBlockZ(),
|
||||||
|
latestThrownPotion.getWorld().getName(), trollPotions > 0 ? String.format(" &c(most likely troll %s)", trollPotions == 1 ? "potion" : "potions") : "")));
|
||||||
|
}
|
||||||
|
recentlyThrownPotions.clear();
|
||||||
|
}, 0L, 40L);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStop()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
|
public void onLingeringPotionSplash(LingeringPotionSplashEvent event)
|
||||||
{
|
{
|
||||||
ProjectileSource source = event.getEntity().getShooter();
|
if (event.getEntity().getShooter() instanceof Player)
|
||||||
|
|
||||||
if (!(source instanceof Player))
|
|
||||||
{
|
{
|
||||||
return;
|
ThrownPotion potion = event.getEntity();
|
||||||
}
|
if (potion.getShooter() instanceof Player)
|
||||||
Player player = (Player)source;
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Material droppedItem = event.getEntity().getItem().getType();
|
|
||||||
final Location location = player.getLocation();
|
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
|
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'.");
|
Player player = (Player)potion.getShooter();
|
||||||
|
|
||||||
|
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
|
||||||
|
recentlyThrownPotions.get(player).add(potion);
|
||||||
|
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
|
||||||
|
|
||||||
|
if (recentlyThrownPotions.get(player).size() > 128)
|
||||||
|
{
|
||||||
|
recentlyThrownPotions.get(player).remove(0);
|
||||||
|
}
|
||||||
|
if (allThrownPotions.size() > 1024)
|
||||||
|
{
|
||||||
|
allThrownPotions.remove(0); // Remove the first element in the set.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -63,27 +88,57 @@ public class Monitors extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.MONITOR)
|
@EventHandler(priority = EventPriority.MONITOR)
|
||||||
public void onPotionSplash(PotionSplashEvent event)
|
public void onPotionSplash(PotionSplashEvent event)
|
||||||
{
|
{
|
||||||
ProjectileSource source = event.getEntity().getShooter();
|
if (event.getEntity().getShooter() instanceof Player)
|
||||||
|
|
||||||
if (!(source instanceof Player))
|
|
||||||
{
|
{
|
||||||
return;
|
ThrownPotion potion = event.getEntity();
|
||||||
}
|
if (potion.getShooter() instanceof Player)
|
||||||
Player player = (Player)source;
|
|
||||||
|
|
||||||
if (plugin.al.isAdmin((Player)event.getEntity().getShooter()))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
final Material droppedItem = event.getPotion().getItem().getType();
|
|
||||||
final Location location = player.getLocation();
|
|
||||||
|
|
||||||
for (Player p : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (plugin.al.isAdmin(p) && plugin.al.getAdmin(p).getPotionSpy())
|
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(p, potionSpyPrefix + ChatColor.WHITE + player.getName() + " splashed " + event.getEntity().getItem().getAmount() + " " + droppedItem + " at X: " + decimalFormat.format(location.getX()) + ", Y: " + decimalFormat.format(location.getY()) + ", Z: " + decimalFormat.format(location.getZ()) + ", in the world '" + location.getWorld().getName() + "'.");
|
Player player = (Player)potion.getShooter();
|
||||||
|
|
||||||
|
recentlyThrownPotions.putIfAbsent(player, new ArrayList<>());
|
||||||
|
recentlyThrownPotions.get(player).add(potion);
|
||||||
|
allThrownPotions.add(new AbstractMap.SimpleEntry<>(potion, System.currentTimeMillis()));
|
||||||
|
|
||||||
|
if (recentlyThrownPotions.get(player).size() > 128)
|
||||||
|
{
|
||||||
|
recentlyThrownPotions.get(player).remove(0);
|
||||||
|
}
|
||||||
|
if (allThrownPotions.size() > 1024)
|
||||||
|
{
|
||||||
|
allThrownPotions.remove(0); // Remove the first element in the set.
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
public List<Map.Entry<ThrownPotion, Long>> getPlayerThrownPotions(Player player)
|
||||||
|
{
|
||||||
|
List<Map.Entry<ThrownPotion, Long>> thrownPotions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Map.Entry<ThrownPotion, Long> potionEntry : allThrownPotions)
|
||||||
|
{
|
||||||
|
ThrownPotion potion = potionEntry.getKey();
|
||||||
|
if (potion.getShooter() != null && potion.getShooter().equals(player))
|
||||||
|
{
|
||||||
|
thrownPotions.add(potionEntry);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return thrownPotions;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTrollPotion(ThrownPotion potion)
|
||||||
|
{
|
||||||
|
int badEffectsDetected = 0;
|
||||||
|
|
||||||
|
for (PotionEffect effect : potion.getEffects())
|
||||||
|
{
|
||||||
|
if (badPotionEffects.contains(effect.getType()) && effect.getAmplifier() > 2 && effect.getDuration() > 200)
|
||||||
|
{
|
||||||
|
badEffectsDetected++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return badEffectsDetected > 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,14 +3,15 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
import ca.momothereal.mojangson.ex.MojangsonParseException;
|
||||||
import ca.momothereal.mojangson.value.MojangsonCompound;
|
import ca.momothereal.mojangson.value.MojangsonCompound;
|
||||||
import ca.momothereal.mojangson.value.MojangsonValue;
|
import ca.momothereal.mojangson.value.MojangsonValue;
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagList;
|
import net.minecraft.server.v1_16_R2.NBTTagList;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -19,7 +20,6 @@ import org.bukkit.event.player.PlayerLoginEvent;
|
|||||||
import org.bukkit.event.player.PlayerMoveEvent;
|
import org.bukkit.event.player.PlayerMoveEvent;
|
||||||
import org.bukkit.event.player.PlayerTeleportEvent;
|
import org.bukkit.event.player.PlayerTeleportEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.jetbrains.annotations.NotNull;
|
|
||||||
|
|
||||||
public class MovementValidator extends FreedomService
|
public class MovementValidator extends FreedomService
|
||||||
{
|
{
|
||||||
@ -27,18 +27,13 @@ public class MovementValidator extends FreedomService
|
|||||||
public static final int MAX_XYZ_COORD = 29999998;
|
public static final int MAX_XYZ_COORD = 29999998;
|
||||||
public static final int MAX_DISTANCE_TRAVELED = 100;
|
public static final int MAX_DISTANCE_TRAVELED = 100;
|
||||||
|
|
||||||
public MovementValidator(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +62,7 @@ public class MovementValidator extends FreedomService
|
|||||||
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(event.getTo().getX()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getZ()) >= MAX_XYZ_COORD || Math.abs(event.getTo().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
player.teleport(player.getWorld().getSpawnLocation());
|
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
if (exploitItem(event.getPlayer().getInventory().getHelmet()))
|
||||||
@ -116,7 +111,7 @@ public class MovementValidator extends FreedomService
|
|||||||
// Validate position
|
// Validate position
|
||||||
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
if (Math.abs(player.getLocation().getX()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getZ()) >= MAX_XYZ_COORD || Math.abs(player.getLocation().getY()) >= MAX_XYZ_COORD)
|
||||||
{
|
{
|
||||||
player.teleport(player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
PaperLib.teleportAsync(player, player.getWorld().getSpawnLocation()); // Illegal position, teleport to spawn
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +132,7 @@ public class MovementValidator extends FreedomService
|
|||||||
|
|
||||||
private Boolean exploitItem(ItemStack item)
|
private Boolean exploitItem(ItemStack item)
|
||||||
{
|
{
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
net.minecraft.server.v1_16_R2.ItemStack nmsStack = CraftItemStack.asNMSCopy(item);
|
||||||
NBTTagList modifiers = getAttributeList(nmsStack);
|
NBTTagList modifiers = getAttributeList(nmsStack);
|
||||||
MojangsonCompound compound = new MojangsonCompound();
|
MojangsonCompound compound = new MojangsonCompound();
|
||||||
boolean foundNegative = false;
|
boolean foundNegative = false;
|
||||||
@ -174,7 +169,7 @@ public class MovementValidator extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private NBTTagList getAttributeList(net.minecraft.server.v1_15_R1.ItemStack stack)
|
private NBTTagList getAttributeList(net.minecraft.server.v1_16_R2.ItemStack stack)
|
||||||
{
|
{
|
||||||
if (stack.getTag() == null)
|
if (stack.getTag() == null)
|
||||||
{
|
{
|
||||||
|
@ -21,24 +21,19 @@ public class Muter extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
public static final List<String> MUTE_COMMANDS = Arrays.asList(StringUtils.split("say,me,msg,tell,reply,mail", ","));
|
||||||
public final List<String> MUTED_PLAYERS = new ArrayList();
|
public final List<String> MUTED_PLAYERS = new ArrayList<>();
|
||||||
|
|
||||||
public Muter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event)
|
||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
@ -50,21 +45,14 @@ public class Muter extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(player))
|
if (plugin.sl.isStaffSync(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
MUTED_PLAYERS.remove(player.getName());
|
MUTED_PLAYERS.remove(player.getName());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fPlayer.isQuietMuted())
|
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted.");
|
||||||
{
|
|
||||||
FSync.playerMsg(event.getPlayer(), event.getFormat());
|
|
||||||
event.setCancelled(true);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
FSync.playerMsg(event.getPlayer(), ChatColor.RED + "You are muted, STFU! - You will be unmuted in 5 minutes.");
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -82,7 +70,7 @@ public class Muter extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
String message = event.getMessage();
|
String message = event.getMessage();
|
||||||
if (plugin.al.isAdmin(player))
|
if (plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
fPlayer.setMuted(false);
|
fPlayer.setMuted(false);
|
||||||
return;
|
return;
|
||||||
|
@ -9,19 +9,13 @@ import org.bukkit.util.Vector;
|
|||||||
|
|
||||||
public class Orbiter extends FreedomService
|
public class Orbiter extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public Orbiter(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,397 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
178
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
178
src/main/java/me/totalfreedom/totalfreedommod/Pterodactyl.java
Normal file
@ -0,0 +1,178 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import joptsimple.internal.Strings;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.Response;
|
||||||
|
import org.json.simple.JSONObject;
|
||||||
|
import org.json.simple.parser.ParseException;
|
||||||
|
|
||||||
|
public class Pterodactyl extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public final String URL = ConfigEntry.PTERO_URL.getString();
|
||||||
|
private final String SERVER_KEY = ConfigEntry.PTERO_SERVER_KEY.getString();
|
||||||
|
private final String ADMIN_KEY = ConfigEntry.PTERO_ADMIN_KEY.getString();
|
||||||
|
private final List<String> SERVER_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + SERVER_KEY);
|
||||||
|
private final List<String> ADMIN_HEADERS = Arrays.asList("Accept:Application/vnd.pterodactyl.v1+json", "Content-Type:application/json", "Authorization:Bearer " + ADMIN_KEY);
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private boolean enabled = !Strings.isNullOrEmpty(URL);
|
||||||
|
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateAccountStatus(StaffMember staffMember)
|
||||||
|
{
|
||||||
|
String id = staffMember.getPteroID();
|
||||||
|
|
||||||
|
if (Strings.isNullOrEmpty(id) || !enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!staffMember.isActive() || staffMember.getRank() != Rank.SENIOR_ADMIN)
|
||||||
|
{
|
||||||
|
FLog.debug("Disabling ptero acc");
|
||||||
|
removeAccountFromServer(id);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.debug("Enabling aptero acc");
|
||||||
|
addAccountToServer(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String createAccount(String username, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("username", username);
|
||||||
|
json.put("password", password);
|
||||||
|
json.put("email", username.toLowerCase() + "@" + ConfigEntry.PTERO_DEFAULT_EMAIL_DOMAIN.getString());
|
||||||
|
json.put("first_name", username);
|
||||||
|
json.put("last_name", "\u200E"); // required, so I made it appear empty
|
||||||
|
|
||||||
|
Response response;
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(URL + "/api/application/users", "POST", ADMIN_HEADERS, json.toJSONString());
|
||||||
|
jsonResponse = response.getJSONMessage();
|
||||||
|
}
|
||||||
|
catch (IOException | ParseException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return ((JSONObject)jsonResponse.get("attributes")).get("id").toString();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean deleteAccount(String id)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
return FUtil.sendRequest(URL + "/api/application/users/" + id, "DELETE", ADMIN_HEADERS, json.toJSONString()).getCode() == 204;
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addAccountToServer(String id)
|
||||||
|
{
|
||||||
|
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users";
|
||||||
|
|
||||||
|
JSONObject userData = getUserData(id);
|
||||||
|
if (userData == null)
|
||||||
|
{
|
||||||
|
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("email", userData.get("email").toString());
|
||||||
|
json.put("permissions", Arrays.asList("control.console", "control.start", "control.restart", "control.stop", "control.kill"));
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(url, "POST", SERVER_HEADERS, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeAccountFromServer(String id)
|
||||||
|
{
|
||||||
|
JSONObject userData = getUserData(id);
|
||||||
|
if (userData == null)
|
||||||
|
{
|
||||||
|
FLog.severe("The Pterodactyl user with the ID of " + id + " was not found");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
String url = URL + "/api/client/servers/" + ConfigEntry.PTERO_SERVER_UUID.getString() + "/users/" + userData.get("uuid");
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(url, "DELETE", SERVER_HEADERS, null);
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public JSONObject getUserData(String id)
|
||||||
|
{
|
||||||
|
Response response;
|
||||||
|
JSONObject jsonResponse;
|
||||||
|
try
|
||||||
|
{
|
||||||
|
response = FUtil.sendRequest(URL + "/api/application/users/" + id, "GET", ADMIN_HEADERS, null);
|
||||||
|
jsonResponse = response.getJSONMessage();
|
||||||
|
|
||||||
|
}
|
||||||
|
catch (IOException | ParseException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (JSONObject)jsonResponse.get("attributes");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// API patch function on users doesnt work rn, it throws 500 errors, so it's probably not written yet
|
||||||
|
public void setPassword(String id, String password)
|
||||||
|
{
|
||||||
|
JSONObject json = new JSONObject();
|
||||||
|
json.put("password", password);
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
FUtil.sendRequest(URL + "/api/application/users/" + id, "PATCH", ADMIN_HEADERS, json.toJSONString());
|
||||||
|
}
|
||||||
|
catch (IOException e)
|
||||||
|
{
|
||||||
|
FLog.severe(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
217
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
217
src/main/java/me/totalfreedom/totalfreedommod/Reddit.java
Normal file
@ -0,0 +1,217 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Displayable;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Title;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import net.dean.jraw.ApiException;
|
||||||
|
import net.dean.jraw.RedditClient;
|
||||||
|
import net.dean.jraw.http.OkHttpNetworkAdapter;
|
||||||
|
import net.dean.jraw.http.UserAgent;
|
||||||
|
import net.dean.jraw.models.CurrentFlair;
|
||||||
|
import net.dean.jraw.models.Flair;
|
||||||
|
import net.dean.jraw.oauth.Credentials;
|
||||||
|
import net.dean.jraw.oauth.OAuthHelper;
|
||||||
|
import net.dean.jraw.references.SubredditReference;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class Reddit extends FreedomService
|
||||||
|
{
|
||||||
|
private final String SUBREDDIT_NAME = ConfigEntry.REDDIT_SUBREDDIT_NAME.getString();
|
||||||
|
private final String USERNAME = ConfigEntry.REDDIT_USERNAME.getString();
|
||||||
|
private final String PASSWORD = ConfigEntry.REDDIT_PASSWORD.getString();
|
||||||
|
private final String CLIENT_ID = ConfigEntry.REDDIT_CLIENT_ID.getString();
|
||||||
|
private final String CLIENT_SECRET = ConfigEntry.REDDIT_CLIENT_SECRET.getString();
|
||||||
|
|
||||||
|
private final UserAgent userAgent = new UserAgent("bot", "me.totalfreedom.reddit", TotalFreedomMod.build.version, USERNAME);
|
||||||
|
private final Credentials credentials = Credentials.script(USERNAME, PASSWORD, CLIENT_ID, CLIENT_SECRET);
|
||||||
|
|
||||||
|
private RedditClient reddit = null;
|
||||||
|
private SubredditReference subreddit = null;
|
||||||
|
|
||||||
|
private HashMap<String, PlayerData> linkCodes = new HashMap<>();
|
||||||
|
private HashMap<PlayerData, String> pending = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairList = new HashMap<>();
|
||||||
|
|
||||||
|
private Map<Displayable, String> flairNameList = new HashMap<>();
|
||||||
|
|
||||||
|
private List<Displayable> noFlairDisplays = Arrays.asList(Title.VERIFIED_STAFF, Rank.IMPOSTOR, Rank.NON_OP, Rank.OP);
|
||||||
|
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
enabled = ConfigEntry.REDDIT_CLIENT_ID.getString() == null;
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (reddit == null)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
reddit = OAuthHelper.automatic(new OkHttpNetworkAdapter(userAgent), credentials);
|
||||||
|
reddit.setLogHttp(FUtil.inDeveloperMode());
|
||||||
|
}
|
||||||
|
catch (NoClassDefFoundError e)
|
||||||
|
{
|
||||||
|
FLog.warning("The JRAW plugin is not installed, therefore the Reddit service cannot start.");
|
||||||
|
FLog.warning("To resolve this error, please download the latest JRAW from: https://github.com/TFPatches/Minecraft-JRAW/releases");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
catch (NullPointerException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Invalid Reddit credentials specified, please double check everything in the config.");
|
||||||
|
enabled = false;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (subreddit == null)
|
||||||
|
{
|
||||||
|
subreddit = reddit.subreddit(SUBREDDIT_NAME);
|
||||||
|
}
|
||||||
|
|
||||||
|
loadFlairList();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlair(String username, String flairID)
|
||||||
|
{
|
||||||
|
List<Flair> flairs = subreddit.userFlairOptions();
|
||||||
|
Flair flair = null;
|
||||||
|
for (Flair f : flairs)
|
||||||
|
{
|
||||||
|
if (f.getId().equals(flairID))
|
||||||
|
{
|
||||||
|
flair = f;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (flair == null)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate(flair.getId(), "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void removeFlair(String username)
|
||||||
|
{
|
||||||
|
subreddit.otherUserFlair(username).updateToTemplate("", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public void sendModMessage(String username, String subject, String body) throws ApiException
|
||||||
|
{
|
||||||
|
reddit.me().inbox().compose("/r/" + SUBREDDIT_NAME, username, subject, body);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String addLinkCode(PlayerData data, String username)
|
||||||
|
{
|
||||||
|
String code = FUtil.randomAlphanumericString(10);
|
||||||
|
linkCodes.put(code, data);
|
||||||
|
pending.put(data, username);
|
||||||
|
return code;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String checkLinkCode(String code)
|
||||||
|
{
|
||||||
|
PlayerData data = linkCodes.get(code);
|
||||||
|
String username = pending.get(data);
|
||||||
|
if (data == null || username == null)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
linkCodes.remove(code);
|
||||||
|
pending.remove(data);
|
||||||
|
|
||||||
|
data.setRedditUsername(username);
|
||||||
|
plugin.pl.save(data);
|
||||||
|
|
||||||
|
return username;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean updateFlair(Player player)
|
||||||
|
{
|
||||||
|
if (!enabled)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
PlayerData data = plugin.pl.getData(player);
|
||||||
|
String username = data.getRedditUsername();
|
||||||
|
Displayable display = plugin.rm.getDisplay(player);
|
||||||
|
if (username == null)
|
||||||
|
{
|
||||||
|
FLog.debug("No Reddit account");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
CurrentFlair currentFlair = subreddit.otherUserFlair(username).current();
|
||||||
|
String currentFlairName = currentFlair.getText();
|
||||||
|
String currentFlairID = currentFlair.getId();
|
||||||
|
String neededFlairID = flairList.get(display);
|
||||||
|
String neededFlairName = flairNameList.get(display);
|
||||||
|
|
||||||
|
FLog.debug("Current ID: " + currentFlairID);
|
||||||
|
FLog.debug("Needed ID: " + neededFlairID);
|
||||||
|
|
||||||
|
FLog.debug("Current Name: " + currentFlairName);
|
||||||
|
FLog.debug("Needed Name: " + neededFlairName);
|
||||||
|
|
||||||
|
|
||||||
|
// Work around
|
||||||
|
//if (currentFlairID == null && neededFlairID != null || currentFlairID != null && neededFlairID != null && !currentFlairID.equals(neededFlairID))
|
||||||
|
if (Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null || !Strings.isNullOrEmpty(currentFlairName) && neededFlairName != null && !currentFlairName.equals(neededFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Setting flair");
|
||||||
|
setFlair(username, neededFlairID);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (noFlairDisplays.contains(display) && !Strings.isNullOrEmpty(currentFlairName))
|
||||||
|
{
|
||||||
|
FLog.debug("Removing flair");
|
||||||
|
removeFlair(username);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadFlairList()
|
||||||
|
{
|
||||||
|
flairList.put(Title.OWNER, ConfigEntry.REDDIT_SERVER_OWNER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.EXECUTIVE, ConfigEntry.REDDIT_EXECUTIVE_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.DEVELOPER, ConfigEntry.REDDIT_DEVELOPER_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.SENIOR_ADMIN, ConfigEntry.REDDIT_SENIOR_ADMIN_FLAIR_ID.getString());
|
||||||
|
flairList.put(Rank.ADMIN, ConfigEntry.REDDIT_NEW_ADMIN_FLAIR_ID.getString());
|
||||||
|
flairList.put(Title.MASTER_BUILDER, ConfigEntry.REDDIT_MASTER_BUILDER_FLAIR_ID.getString());
|
||||||
|
|
||||||
|
// Work around because the current flair ID keeps returning null, either a JRAW bug or a Reddit bug
|
||||||
|
flairNameList.put(Title.OWNER, "Server Owner");
|
||||||
|
flairNameList.put(Title.EXECUTIVE, "Executive");
|
||||||
|
flairNameList.put(Title.DEVELOPER, "Developer");
|
||||||
|
flairNameList.put(Rank.SENIOR_ADMIN, "Senior Admin");
|
||||||
|
flairNameList.put(Rank.ADMIN, "Admin");
|
||||||
|
flairNameList.put(Title.MASTER_BUILDER, "Master Builder");
|
||||||
|
}
|
||||||
|
}
|
@ -12,19 +12,13 @@ import static me.totalfreedom.totalfreedommod.util.FUtil.SAVED_FLAGS_FILENAME;
|
|||||||
|
|
||||||
public class SavedFlags extends FreedomService
|
public class SavedFlags extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public SavedFlags(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,28 +4,22 @@ import java.util.Arrays;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.minecraft.server.v1_15_R1.EntityPlayer;
|
import net.minecraft.server.v1_16_R2.EntityPlayer;
|
||||||
import net.minecraft.server.v1_15_R1.MinecraftServer;
|
import net.minecraft.server.v1_16_R2.MinecraftServer;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.CraftServer;
|
import org.bukkit.craftbukkit.v1_16_R2.CraftServer;
|
||||||
|
|
||||||
public class ServerInterface extends FreedomService
|
public class ServerInterface extends FreedomService
|
||||||
{
|
{
|
||||||
|
public static final String COMPILE_NMS_VERSION = "v1_16_R2";
|
||||||
public static final String COMPILE_NMS_VERSION = "v1_15_R1";
|
|
||||||
|
|
||||||
public ServerInterface(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,19 +9,13 @@ import org.bukkit.event.server.ServerListPingEvent;
|
|||||||
|
|
||||||
public class ServerPing extends FreedomService
|
public class ServerPing extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public ServerPing(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -36,9 +30,9 @@ public class ServerPing extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ConfigEntry.ADMIN_ONLY_MODE.getBoolean())
|
if (ConfigEntry.STAFF_ONLY_MODE.getBoolean())
|
||||||
{
|
{
|
||||||
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_ADMINMODE_MOTD.getString()));
|
event.setMotd(FUtil.colorize(ConfigEntry.SERVER_STAFFMODE_MOTD.getString()));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
34
src/main/java/me/totalfreedom/totalfreedommod/Sitter.java
Normal file
34
src/main/java/me/totalfreedom/totalfreedommod/Sitter.java
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.command.Command_sit;
|
||||||
|
import org.bukkit.entity.ArmorStand;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.spigotmc.event.entity.EntityDismountEvent;
|
||||||
|
|
||||||
|
public class Sitter extends FreedomService
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntityDismount(EntityDismountEvent e)
|
||||||
|
{
|
||||||
|
Entity dm = e.getDismounted();
|
||||||
|
if (dm instanceof ArmorStand)
|
||||||
|
{
|
||||||
|
if (Command_sit.STANDS.contains(dm))
|
||||||
|
{
|
||||||
|
Command_sit.STANDS.remove(dm);
|
||||||
|
dm.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -3,12 +3,8 @@ package me.totalfreedom.totalfreedommod;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
import me.totalfreedom.totalfreedommod.admin.ActivityLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.admin.AdminList;
|
|
||||||
import me.totalfreedom.totalfreedommod.amp.AMP;
|
|
||||||
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
import me.totalfreedom.totalfreedommod.banning.BanManager;
|
||||||
import me.totalfreedom.totalfreedommod.banning.PermbanList;
|
import me.totalfreedom.totalfreedommod.banning.IndefiniteBanList;
|
||||||
import me.totalfreedom.totalfreedommod.banning.VPNBanList;
|
|
||||||
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.BlockBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EditBlocker;
|
||||||
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
import me.totalfreedom.totalfreedommod.blocking.EventBlocker;
|
||||||
@ -21,7 +17,9 @@ import me.totalfreedom.totalfreedommod.blocking.command.CommandBlocker;
|
|||||||
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
import me.totalfreedom.totalfreedommod.bridge.BukkitTelnetBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
import me.totalfreedom.totalfreedommod.bridge.CoreProtectBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
import me.totalfreedom.totalfreedommod.bridge.EssentialsBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.FAWEBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
import me.totalfreedom.totalfreedommod.bridge.LibsDisguisesBridge;
|
||||||
|
import me.totalfreedom.totalfreedommod.bridge.TFGuildsBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldEditBridge;
|
||||||
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
import me.totalfreedom.totalfreedommod.bridge.WorldGuardBridge;
|
||||||
import me.totalfreedom.totalfreedommod.caging.Cager;
|
import me.totalfreedom.totalfreedommod.caging.Cager;
|
||||||
@ -34,37 +32,39 @@ import me.totalfreedom.totalfreedommod.fun.ItemFun;
|
|||||||
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
import me.totalfreedom.totalfreedommod.fun.Jumppads;
|
||||||
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
import me.totalfreedom.totalfreedommod.fun.Landminer;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MP44;
|
import me.totalfreedom.totalfreedommod.fun.MP44;
|
||||||
import me.totalfreedom.totalfreedommod.fun.MobStacker;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.RealTimer;
|
|
||||||
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
import me.totalfreedom.totalfreedommod.fun.Trailer;
|
||||||
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
import me.totalfreedom.totalfreedommod.httpd.HTTPDaemon;
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderList;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilderWorldRestrictions;
|
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionConfig;
|
||||||
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
import me.totalfreedom.totalfreedommod.permissions.PermissionManager;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
import me.totalfreedom.totalfreedommod.player.PlayerList;
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.PlayerVerification;
|
|
||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentList;
|
||||||
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
import me.totalfreedom.totalfreedommod.rank.RankManager;
|
||||||
import me.totalfreedom.totalfreedommod.rollback.RollbackManager;
|
|
||||||
import me.totalfreedom.totalfreedommod.shop.Shop;
|
import me.totalfreedom.totalfreedommod.shop.Shop;
|
||||||
|
import me.totalfreedom.totalfreedommod.shop.Votifier;
|
||||||
|
import me.totalfreedom.totalfreedommod.sql.SQLite;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.ActivityLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffList;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
import me.totalfreedom.totalfreedommod.util.MethodTimer;
|
||||||
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
import me.totalfreedom.totalfreedommod.world.CleanroomChunkGenerator;
|
||||||
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
import me.totalfreedom.totalfreedommod.world.WorldManager;
|
||||||
import net.pravian.aero.component.service.ServiceManager;
|
import me.totalfreedom.totalfreedommod.world.WorldRestrictions;
|
||||||
import net.pravian.aero.plugin.AeroPlugin;
|
import org.bstats.bukkit.Metrics;
|
||||||
import org.bstats.Metrics;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
import org.bukkit.generator.ChunkGenerator;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.spigotmc.SpigotConfig;
|
import org.spigotmc.SpigotConfig;
|
||||||
|
|
||||||
public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
public class TotalFreedomMod extends JavaPlugin
|
||||||
{
|
{
|
||||||
|
private static TotalFreedomMod plugin;
|
||||||
|
|
||||||
|
public static TotalFreedomMod getPlugin()
|
||||||
|
{
|
||||||
|
return plugin;
|
||||||
|
}
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "config.yml";
|
public static final String CONFIG_FILENAME = "config.yml";
|
||||||
//
|
//
|
||||||
@ -76,16 +76,18 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public MainConfig config;
|
public MainConfig config;
|
||||||
public PermissionConfig permissions;
|
public PermissionConfig permissions;
|
||||||
//
|
//
|
||||||
|
// Service Handler
|
||||||
|
public FreedomServiceHandler fsh;
|
||||||
|
// Command Loader
|
||||||
|
public CommandLoader cl;
|
||||||
// Services
|
// Services
|
||||||
public ServiceManager<TotalFreedomMod> services;
|
|
||||||
public ServerInterface si;
|
public ServerInterface si;
|
||||||
public SavedFlags sf;
|
public SavedFlags sf;
|
||||||
public WorldManager wm;
|
public WorldManager wm;
|
||||||
public LogViewer lv;
|
public LogViewer lv;
|
||||||
public AdminList al;
|
public StaffList sl;
|
||||||
public ActivityLog acl;
|
public ActivityLog acl;
|
||||||
public RankManager rm;
|
public RankManager rm;
|
||||||
public CommandLoader cl;
|
|
||||||
public CommandBlocker cb;
|
public CommandBlocker cb;
|
||||||
public EventBlocker eb;
|
public EventBlocker eb;
|
||||||
public BlockBlocker bb;
|
public BlockBlocker bb;
|
||||||
@ -97,17 +99,17 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public AntiSpam as;
|
public AntiSpam as;
|
||||||
public PlayerList pl;
|
public PlayerList pl;
|
||||||
public Shop sh;
|
public Shop sh;
|
||||||
|
public Votifier vo;
|
||||||
|
public SQLite sql;
|
||||||
public Announcer an;
|
public Announcer an;
|
||||||
public ChatManager cm;
|
public ChatManager cm;
|
||||||
public Discord dc;
|
public Discord dc;
|
||||||
public PunishmentList pul;
|
public PunishmentList pul;
|
||||||
public BanManager bm;
|
public BanManager bm;
|
||||||
public PermbanList pm;
|
public IndefiniteBanList im;
|
||||||
public PermissionManager pem;
|
public PermissionManager pem;
|
||||||
public VPNBanList vn;
|
public Reddit rd;
|
||||||
public ProtectArea pa;
|
|
||||||
public GameRuleHandler gr;
|
public GameRuleHandler gr;
|
||||||
public RollbackManager rb;
|
|
||||||
public CommandSpy cs;
|
public CommandSpy cs;
|
||||||
public Cager ca;
|
public Cager ca;
|
||||||
public Freezer fm;
|
public Freezer fm;
|
||||||
@ -124,43 +126,44 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
public CurseListener cul;
|
public CurseListener cul;
|
||||||
public ItemFun it;
|
public ItemFun it;
|
||||||
public Landminer lm;
|
public Landminer lm;
|
||||||
public MobStacker ms;
|
|
||||||
public MP44 mp;
|
public MP44 mp;
|
||||||
public Jumppads jp;
|
public Jumppads jp;
|
||||||
public Trailer tr;
|
public Trailer tr;
|
||||||
public HTTPDaemon hd;
|
public HTTPDaemon hd;
|
||||||
public MasterBuilderList mbl;
|
public WorldRestrictions wr;
|
||||||
public MasterBuilderWorldRestrictions mbwr;
|
|
||||||
public SignBlocker snp;
|
public SignBlocker snp;
|
||||||
public PlayerVerification pv;
|
|
||||||
public EntityWiper ew;
|
public EntityWiper ew;
|
||||||
public RealTimer rt;
|
public Sitter st;
|
||||||
|
public VanishHandler vh;
|
||||||
|
public Pterodactyl ptero;
|
||||||
|
|
||||||
//public HubWorldRestrictions hwr;
|
//public HubWorldRestrictions hwr;
|
||||||
//
|
//
|
||||||
// Bridges
|
// Bridges
|
||||||
public ServiceManager<TotalFreedomMod> bridges;
|
|
||||||
public BukkitTelnetBridge btb;
|
public BukkitTelnetBridge btb;
|
||||||
public EssentialsBridge esb;
|
public EssentialsBridge esb;
|
||||||
public LibsDisguisesBridge ldb;
|
public LibsDisguisesBridge ldb;
|
||||||
public CoreProtectBridge cpb;
|
public CoreProtectBridge cpb;
|
||||||
|
public TFGuildsBridge tfg;
|
||||||
public WorldEditBridge web;
|
public WorldEditBridge web;
|
||||||
|
public FAWEBridge fab;
|
||||||
public WorldGuardBridge wgb;
|
public WorldGuardBridge wgb;
|
||||||
public AMP amp;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void load()
|
public void onLoad()
|
||||||
{
|
{
|
||||||
|
plugin = this;
|
||||||
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
TotalFreedomMod.pluginName = plugin.getDescription().getName();
|
||||||
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
TotalFreedomMod.pluginVersion = plugin.getDescription().getVersion();
|
||||||
|
|
||||||
FLog.setPluginLogger(plugin.getLogger());
|
FLog.setPluginLogger(plugin.getLogger());
|
||||||
FLog.setServerLogger(server.getLogger());
|
FLog.setServerLogger(getServer().getLogger());
|
||||||
|
|
||||||
build.load(plugin);
|
build.load(plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void enable()
|
public void onEnable()
|
||||||
{
|
{
|
||||||
FLog.info("Created by Madgeek1450 and Prozza");
|
FLog.info("Created by Madgeek1450 and Prozza");
|
||||||
FLog.info("Version " + build.version);
|
FLog.info("Version " + build.version);
|
||||||
@ -176,136 +179,125 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
FUtil.deleteCoreDumps();
|
FUtil.deleteCoreDumps();
|
||||||
FUtil.deleteFolder(new File("./_deleteme"));
|
FUtil.deleteFolder(new File("./_deleteme"));
|
||||||
|
|
||||||
BackupManager backups = new BackupManager(this);
|
fsh = new FreedomServiceHandler();
|
||||||
backups.createBackups(TotalFreedomMod.CONFIG_FILENAME, true);
|
|
||||||
backups.createBackups(AdminList.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(PermbanList.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(PermissionConfig.PERMISSIONS_FILENAME, true);
|
|
||||||
backups.createBackups(VPNBanList.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(MasterBuilder.CONFIG_FILENAME);
|
|
||||||
backups.createBackups(PunishmentList.CONFIG_FILENAME);
|
|
||||||
|
|
||||||
config = new MainConfig(this);
|
config = new MainConfig();
|
||||||
config.load();
|
config.load();
|
||||||
|
|
||||||
|
if (FUtil.inDeveloperMode())
|
||||||
|
{
|
||||||
|
FLog.debug("Developer mode enabled.");
|
||||||
|
}
|
||||||
|
|
||||||
|
cl = new CommandLoader();
|
||||||
|
cl.loadCommands();
|
||||||
|
|
||||||
|
BackupManager backups = new BackupManager();
|
||||||
|
backups.createAllBackups();
|
||||||
|
|
||||||
permissions = new PermissionConfig(this);
|
permissions = new PermissionConfig(this);
|
||||||
permissions.load();
|
permissions.load();
|
||||||
|
|
||||||
// Start services
|
// Start services
|
||||||
services = new ServiceManager<>(plugin);
|
si = new ServerInterface();
|
||||||
si = services.registerService(ServerInterface.class);
|
sf = new SavedFlags();
|
||||||
sf = services.registerService(SavedFlags.class);
|
wm = new WorldManager();
|
||||||
wm = services.registerService(WorldManager.class);
|
lv = new LogViewer();
|
||||||
lv = services.registerService(LogViewer.class);
|
sql = new SQLite();
|
||||||
al = services.registerService(AdminList.class);
|
sl = new StaffList();
|
||||||
acl = services.registerService(ActivityLog.class);
|
acl = new ActivityLog();
|
||||||
rm = services.registerService(RankManager.class);
|
rm = new RankManager();
|
||||||
cl = services.registerService(CommandLoader.class);
|
cb = new CommandBlocker();
|
||||||
cb = services.registerService(CommandBlocker.class);
|
eb = new EventBlocker();
|
||||||
eb = services.registerService(EventBlocker.class);
|
bb = new BlockBlocker();
|
||||||
bb = services.registerService(BlockBlocker.class);
|
mb = new MobBlocker();
|
||||||
mb = services.registerService(MobBlocker.class);
|
ib = new InteractBlocker();
|
||||||
ib = services.registerService(InteractBlocker.class);
|
pb = new PotionBlocker();
|
||||||
pb = services.registerService(PotionBlocker.class);
|
lp = new LoginProcess();
|
||||||
lp = services.registerService(LoginProcess.class);
|
nu = new AntiNuke();
|
||||||
nu = services.registerService(AntiNuke.class);
|
as = new AntiSpam();
|
||||||
as = services.registerService(AntiSpam.class);
|
wr = new WorldRestrictions();
|
||||||
mbl = services.registerService(MasterBuilderList.class);
|
pl = new PlayerList();
|
||||||
mbwr = services.registerService(MasterBuilderWorldRestrictions.class);
|
sh = new Shop();
|
||||||
//hwr = services.registerService(HubWorldRestrictions.class);
|
vo = new Votifier();
|
||||||
pl = services.registerService(PlayerList.class);
|
an = new Announcer();
|
||||||
sh = services.registerService(Shop.class);
|
cm = new ChatManager();
|
||||||
an = services.registerService(Announcer.class);
|
dc = new Discord();
|
||||||
cm = services.registerService(ChatManager.class);
|
pul = new PunishmentList();
|
||||||
dc = services.registerService(Discord.class);
|
bm = new BanManager();
|
||||||
pul = services.registerService(PunishmentList.class);
|
im = new IndefiniteBanList();
|
||||||
bm = services.registerService(BanManager.class);
|
pem = new PermissionManager();
|
||||||
pm = services.registerService(PermbanList.class);
|
rd = new Reddit();
|
||||||
pem = services.registerService(PermissionManager.class);
|
gr = new GameRuleHandler();
|
||||||
vn = services.registerService(VPNBanList.class);
|
snp = new SignBlocker();
|
||||||
pa = services.registerService(ProtectArea.class);
|
ew = new EntityWiper();
|
||||||
gr = services.registerService(GameRuleHandler.class);
|
st = new Sitter();
|
||||||
snp = services.registerService(SignBlocker.class);
|
vh = new VanishHandler();
|
||||||
ew = services.registerService(EntityWiper.class);
|
ptero = new Pterodactyl();
|
||||||
|
|
||||||
// Single admin utils
|
// Single admin utils
|
||||||
rb = services.registerService(RollbackManager.class);
|
cs = new CommandSpy();
|
||||||
cs = services.registerService(CommandSpy.class);
|
ca = new Cager();
|
||||||
ca = services.registerService(Cager.class);
|
fm = new Freezer();
|
||||||
fm = services.registerService(Freezer.class);
|
or = new Orbiter();
|
||||||
or = services.registerService(Orbiter.class);
|
mu = new Muter();
|
||||||
mu = services.registerService(Muter.class);
|
ebl = new EditBlocker();
|
||||||
ebl = services.registerService(EditBlocker.class);
|
pbl = new PVPBlocker();
|
||||||
pbl = services.registerService(PVPBlocker.class);
|
fo = new Fuckoff();
|
||||||
fo = services.registerService(Fuckoff.class);
|
ak = new AutoKick();
|
||||||
ak = services.registerService(AutoKick.class);
|
ae = new AutoEject();
|
||||||
ae = services.registerService(AutoEject.class);
|
mo = new Monitors();
|
||||||
mo = services.registerService(Monitors.class);
|
|
||||||
|
|
||||||
|
mv = new MovementValidator();
|
||||||
mv = services.registerService(MovementValidator.class);
|
sp = new ServerPing();
|
||||||
sp = services.registerService(ServerPing.class);
|
|
||||||
pv = services.registerService(PlayerVerification.class);
|
|
||||||
|
|
||||||
// Fun
|
// Fun
|
||||||
cul = services.registerService(CurseListener.class);
|
cul = new CurseListener();
|
||||||
it = services.registerService(ItemFun.class);
|
it = new ItemFun();
|
||||||
lm = services.registerService(Landminer.class);
|
lm = new Landminer();
|
||||||
ms = services.registerService(MobStacker.class);
|
mp = new MP44();
|
||||||
mp = services.registerService(MP44.class);
|
jp = new Jumppads();
|
||||||
jp = services.registerService(Jumppads.class);
|
tr = new Trailer();
|
||||||
tr = services.registerService(Trailer.class);
|
|
||||||
rt = services.registerService(RealTimer.class);
|
|
||||||
|
|
||||||
// HTTPD
|
// HTTPD
|
||||||
hd = services.registerService(HTTPDaemon.class);
|
hd = new HTTPDaemon();
|
||||||
services.start();
|
|
||||||
|
|
||||||
// Start bridges
|
// Start bridges
|
||||||
bridges = new ServiceManager<>(plugin);
|
btb = new BukkitTelnetBridge();
|
||||||
btb = bridges.registerService(BukkitTelnetBridge.class);
|
cpb = new CoreProtectBridge();
|
||||||
cpb = bridges.registerService(CoreProtectBridge.class);
|
esb = new EssentialsBridge();
|
||||||
esb = bridges.registerService(EssentialsBridge.class);
|
ldb = new LibsDisguisesBridge();
|
||||||
ldb = bridges.registerService(LibsDisguisesBridge.class);
|
tfg = new TFGuildsBridge();
|
||||||
web = bridges.registerService(WorldEditBridge.class);
|
web = new WorldEditBridge();
|
||||||
wgb = bridges.registerService(WorldGuardBridge.class);
|
fab = new FAWEBridge();
|
||||||
amp = bridges.registerService(AMP.class);
|
wgb = new WorldGuardBridge();
|
||||||
bridges.start();
|
|
||||||
|
fsh.startServices();
|
||||||
|
|
||||||
|
FLog.info("Started " + fsh.getServiceAmount() + " services.");
|
||||||
|
|
||||||
timer.update();
|
timer.update();
|
||||||
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
FLog.info("Version " + pluginVersion + " for " + ServerInterface.COMPILE_NMS_VERSION + " enabled in " + timer.getTotal() + "ms");
|
||||||
|
|
||||||
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod
|
// Metrics @ https://bstats.org/plugin/bukkit/TotalFreedomMod/2966
|
||||||
new Metrics(this);
|
new Metrics(this, 2966);
|
||||||
|
|
||||||
// Add spawnpoints later - https://github.com/TotalFreedom/TotalFreedomMod/issues/438
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
plugin.pa.autoAddSpawnpoints();
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, 60L);
|
|
||||||
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
// little workaround to stop spigot from autorestarting - causing AMP to detach from process.
|
||||||
SpigotConfig.config.set("settings.restart-on-crash", false);
|
SpigotConfig.config.set("settings.restart-on-crash", false);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disable()
|
public void onDisable()
|
||||||
{
|
{
|
||||||
// Stop services and bridges
|
// Stop services and bridges
|
||||||
bridges.stop();
|
fsh.stopServices();
|
||||||
services.stop();
|
|
||||||
|
|
||||||
server.getScheduler().cancelTasks(plugin);
|
getServer().getScheduler().cancelTasks(plugin);
|
||||||
|
|
||||||
FLog.info("Plugin disabled");
|
FLog.info("Plugin disabled");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class BuildProperties
|
public static class BuildProperties
|
||||||
{
|
{
|
||||||
|
|
||||||
public String author;
|
public String author;
|
||||||
public String codename;
|
public String codename;
|
||||||
public String version;
|
public String version;
|
||||||
@ -363,4 +355,4 @@ public class TotalFreedomMod extends AeroPlugin<TotalFreedomMod>
|
|||||||
{
|
{
|
||||||
return new CleanroomChunkGenerator(id);
|
return new CleanroomChunkGenerator(id);
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,83 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import net.md_5.bungee.api.ChatMessageType;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class VanishHandler extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isStaff(player) && plugin.sl.isVanished(p.getName()))
|
||||||
|
{
|
||||||
|
player.hidePlayer(plugin, p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player p : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isStaff(p) && plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
p.hidePlayer(plugin, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
plugin.esb.setVanished(player.getName(), true);
|
||||||
|
FLog.info(player.getName() + " joined while still vanished.");
|
||||||
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has joined silently.");
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
new BukkitRunnable()
|
||||||
|
{
|
||||||
|
@Override
|
||||||
|
public void run()
|
||||||
|
{
|
||||||
|
if (!plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
|
|
||||||
|
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, TextComponent.fromLegacyText(ChatColor.GOLD + "You are hidden from other players."));
|
||||||
|
}
|
||||||
|
}.runTaskTimer(plugin, 0L, 4L);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerLeave(PlayerQuitEvent event)
|
||||||
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (plugin.sl.isVanished(player.getName()))
|
||||||
|
{
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
FLog.info(player.getName() + " left while still vanished.");
|
||||||
|
plugin.sl.messageAllStaff(ChatColor.YELLOW + player.getName() + " has left silently.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,237 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.admin;
|
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
|
||||||
import java.util.Collections;
|
|
||||||
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.lang.StringUtils;
|
|
||||||
import org.apache.commons.lang.Validate;
|
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
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();
|
|
||||||
private final List<String> backupCodes = Lists.newArrayList();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Date lastLogin = new Date();
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String loginMessage = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String discordID = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String tag = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean commandSpy = false;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean potionSpy = false;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String acFormat = null;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean oldTags = false;
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean logStick = false;
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "admins.yml";
|
|
||||||
|
|
||||||
public Admin(Player player)
|
|
||||||
{
|
|
||||||
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).append("\n")
|
|
||||||
.append("- Discord ID: ").append(discordID).append("\n")
|
|
||||||
.append("- Tag: ").append(tag).append("\n").append(ChatColor.GRAY)
|
|
||||||
.append("- Potion Spy: ").append(potionSpy).append("\n")
|
|
||||||
.append("- Admin Chat Format: ").append(acFormat).append("\n")
|
|
||||||
.append("- Old Tags: ").append(oldTags).append("\n")
|
|
||||||
.append("- Log Stick: ").append(logStick)
|
|
||||||
.append("- Backup Codes: ").append(backupCodes.size()).append("/10").append("\n");
|
|
||||||
|
|
||||||
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"));
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(cs.getStringList("backupCodes"));
|
|
||||||
lastLogin = FUtil.stringToDate(cs.getString("last_login"));
|
|
||||||
loginMessage = cs.getString("login_message", null);
|
|
||||||
discordID = cs.getString("discord_id", null);
|
|
||||||
tag = cs.getString("tag", null);
|
|
||||||
commandSpy = cs.getBoolean("command_spy", false);
|
|
||||||
potionSpy = cs.getBoolean("potion_spy", false);
|
|
||||||
acFormat = cs.getString("acformat", null);
|
|
||||||
oldTags = cs.getBoolean("oldtags", false);
|
|
||||||
logStick = cs.getBoolean("logstick", false);
|
|
||||||
}
|
|
||||||
|
|
||||||
@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("backupCodes", Lists.newArrayList(backupCodes));
|
|
||||||
cs.set("last_login", FUtil.dateToString(lastLogin));
|
|
||||||
cs.set("login_message", loginMessage);
|
|
||||||
cs.set("discord_id", discordID);
|
|
||||||
cs.set("tag", tag);
|
|
||||||
cs.set("command_spy", commandSpy);
|
|
||||||
cs.set("potion_spy", potionSpy);
|
|
||||||
cs.set("acformat", acFormat);
|
|
||||||
cs.set("oldtags", oldTags);
|
|
||||||
cs.set("logstick", logStick);
|
|
||||||
}
|
|
||||||
|
|
||||||
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 List<String> getBackupCodes()
|
|
||||||
{
|
|
||||||
return Collections.unmodifiableList(backupCodes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBackupCodes(List<String> codes)
|
|
||||||
{
|
|
||||||
backupCodes.clear();
|
|
||||||
backupCodes.addAll(codes);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void removeBackupCode(String code)
|
|
||||||
{
|
|
||||||
backupCodes.remove(code);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setActive(boolean active)
|
|
||||||
{
|
|
||||||
this.active = active;
|
|
||||||
|
|
||||||
final TotalFreedomMod plugin = TotalFreedomMod.plugin();
|
|
||||||
|
|
||||||
if (!active)
|
|
||||||
{
|
|
||||||
if (getRank().isAtLeast(Rank.TELNET_ADMIN))
|
|
||||||
{
|
|
||||||
if (plugin.btb != null)
|
|
||||||
{
|
|
||||||
plugin.btb.killTelnetSessions(getName());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
plugin.lv.updateLogsRegistration(null, getName(), LogsRegistrationMode.DELETE);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return configKey != null
|
|
||||||
&& name != null
|
|
||||||
&& rank != null
|
|
||||||
&& !ips.isEmpty()
|
|
||||||
&& lastLogin != null;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,389 +0,0 @@
|
|||||||
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.ArrayList;
|
|
||||||
import java.util.Date;
|
|
||||||
import java.util.List;
|
|
||||||
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();
|
|
||||||
public final List<String> verifiedNoAdmins = new ArrayList<>();
|
|
||||||
public final Map<String, List<String>> verifiedNoAdminIps = Maps.newHashMap();
|
|
||||||
public static ArrayList<Player> vanished = new ArrayList<>();
|
|
||||||
//
|
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
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 void messageAllAdmins(String message)
|
|
||||||
{
|
|
||||||
for (Player player : server.getOnlinePlayers())
|
|
||||||
{
|
|
||||||
if (isAdmin(player))
|
|
||||||
{
|
|
||||||
player.sendMessage(message);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public synchronized boolean isAdminSync(CommandSender sender)
|
|
||||||
{
|
|
||||||
return isAdmin(sender);
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getActiveAdminNames()
|
|
||||||
{
|
|
||||||
List<String> names = new ArrayList();
|
|
||||||
for (Admin admin : activeAdmins)
|
|
||||||
{
|
|
||||||
names.add(admin.getName());
|
|
||||||
}
|
|
||||||
return names;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAdmin(CommandSender sender)
|
|
||||||
{
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 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) && !isVerifiedAdmin(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isVerifiedAdmin(Player player)
|
|
||||||
{
|
|
||||||
return verifiedNoAdmins.contains(player.getName()) && verifiedNoAdminIps.get(player.getName()).contains(Ips.getIp(player));
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isIdentityMatched(Player player)
|
|
||||||
{
|
|
||||||
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 admin " + admin.getName() + ", inactive for " + lastLoginHours + " hours", true);
|
|
||||||
}
|
|
||||||
|
|
||||||
admin.setActive(false);
|
|
||||||
}
|
|
||||||
|
|
||||||
save();
|
|
||||||
updateTables();
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,48 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.amp;
|
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
|
||||||
|
|
||||||
|
|
||||||
public class AMP extends FreedomService
|
|
||||||
{
|
|
||||||
public AMPManager ampManager;
|
|
||||||
public Boolean enabled = false;
|
|
||||||
|
|
||||||
public AMP(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
if (!plugin.config.getBoolean(ConfigEntry.AMP_ENABLED))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
ampManager = new AMPManager(plugin, plugin.config.getString(ConfigEntry.AMP_URL), plugin.config.getString(ConfigEntry.AMP_USERNAME), plugin.config.getString(ConfigEntry.AMP_PASSWORD));
|
|
||||||
LoginCallback callback = new LoginCallback()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void loginDone(boolean success)
|
|
||||||
{
|
|
||||||
enabled = success;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
ampManager.connectAsync(callback);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restartServer()
|
|
||||||
{
|
|
||||||
ampManager.restartAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,28 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.amp;
|
|
||||||
|
|
||||||
|
|
||||||
public enum AMPEndpoints
|
|
||||||
{
|
|
||||||
LOGIN("/API/Core/Login", "{username:\"%s\", password:\"%s\", token:\"\", rememberMe:false}"),
|
|
||||||
RESTART("/API/Core/Restart", "{SESSIONID:\"%s\"}");
|
|
||||||
|
|
||||||
private final String text;
|
|
||||||
private final String parameters;
|
|
||||||
|
|
||||||
AMPEndpoints(String text, String parameters)
|
|
||||||
{
|
|
||||||
this.text = text;
|
|
||||||
this.parameters = parameters;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String toString()
|
|
||||||
{
|
|
||||||
return text;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getParameters()
|
|
||||||
{
|
|
||||||
return parameters;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,171 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.amp;
|
|
||||||
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import java.io.BufferedReader;
|
|
||||||
import java.io.DataOutputStream;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.InputStreamReader;
|
|
||||||
import java.net.HttpURLConnection;
|
|
||||||
import java.net.URL;
|
|
||||||
import javax.net.ssl.HttpsURLConnection;
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
public class AMPManager
|
|
||||||
{
|
|
||||||
private TotalFreedomMod plugin;
|
|
||||||
private String url, username, password;
|
|
||||||
private String sessionID;
|
|
||||||
|
|
||||||
|
|
||||||
public AMPManager(TotalFreedomMod plugin, String url, String username, String password)
|
|
||||||
{
|
|
||||||
this.plugin = plugin;
|
|
||||||
this.url = url;
|
|
||||||
this.username = username;
|
|
||||||
this.password = password;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void connectAsync(final LoginCallback callback)
|
|
||||||
{
|
|
||||||
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
String apiEndpoint = url + AMPEndpoints.LOGIN.toString();
|
|
||||||
String body = String.format(AMPEndpoints.LOGIN.getParameters(), username, password);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
LoginResult resp = new Gson().fromJson(postRequestToEndpoint(apiEndpoint, body), LoginResult.class);
|
|
||||||
if (!resp.getSuccess())
|
|
||||||
{
|
|
||||||
FLog.severe("AMP login unsuccessful. Check if login details are correct.");
|
|
||||||
sessionID = "";
|
|
||||||
callback.loginDone(false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
sessionID = resp.getSessionID();
|
|
||||||
callback.loginDone(true);
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
FLog.severe("Could not login to AMP. Check if URL is correct. Stacktrace: " + ex.getMessage());
|
|
||||||
sessionID = "";
|
|
||||||
callback.loginDone(false);
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void restartAsync()
|
|
||||||
{
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
final String apiEndpoint = url + AMPEndpoints.RESTART.toString();
|
|
||||||
final String body = String.format(AMPEndpoints.RESTART.getParameters(), sessionID);
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String resp = postRequestToEndpoint(apiEndpoint, body);
|
|
||||||
if (resp.contains("Unauthorized Access"))
|
|
||||||
{
|
|
||||||
//try connecting one more time
|
|
||||||
LoginCallback callback = new LoginCallback()
|
|
||||||
{
|
|
||||||
@Override
|
|
||||||
public void loginDone(boolean success)
|
|
||||||
{
|
|
||||||
if (!success)
|
|
||||||
{
|
|
||||||
FLog.severe("Failed to connect to AMP. Did the panel go down? Were panel user details changed/deleted? Check for more info above. Connection was successful when plugin started, but unsuccessful now." +
|
|
||||||
" Using server.shutdown() instead.");
|
|
||||||
plugin.getServer().shutdown();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try
|
|
||||||
{
|
|
||||||
String response = postRequestToEndpoint(apiEndpoint, body);
|
|
||||||
if (response.contains("Unauthorized Access"))
|
|
||||||
{
|
|
||||||
FLog.severe("Contact a developer. Panel gives Session ID but trying to use it gives a no perms error. The panel user set in config doesn't" +
|
|
||||||
" have perms to restart server. Using server.shutdown() instead. ");
|
|
||||||
plugin.getServer().shutdown();
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException e)
|
|
||||||
{
|
|
||||||
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace" + e.getMessage());
|
|
||||||
plugin.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
plugin.amp.ampManager.connectAsync(callback);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (IOException ex)
|
|
||||||
{
|
|
||||||
FLog.severe("Could not restart. Using server.shutdown() instead. Stacktrace: " + ex.getMessage());
|
|
||||||
plugin.getServer().shutdown();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskAsynchronously(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
private String postRequestToEndpoint(String endpoint, String body) throws IOException
|
|
||||||
{
|
|
||||||
URL url = new URL(endpoint);
|
|
||||||
if (endpoint.startsWith("https://"))
|
|
||||||
{
|
|
||||||
HttpsURLConnection connection = (HttpsURLConnection)url.openConnection();
|
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
|
||||||
outputStream.writeBytes(body);
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
BufferedReader in = new BufferedReader(
|
|
||||||
new InputStreamReader(connection.getInputStream()));
|
|
||||||
String inputLine;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null)
|
|
||||||
{
|
|
||||||
response.append(inputLine);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
return response.toString();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
HttpURLConnection connection = (HttpURLConnection)url.openConnection();
|
|
||||||
connection.setRequestMethod("POST");
|
|
||||||
connection.setRequestProperty("Accept", "application/json");
|
|
||||||
connection.setDoOutput(true);
|
|
||||||
DataOutputStream outputStream = new DataOutputStream(connection.getOutputStream());
|
|
||||||
outputStream.writeBytes(body);
|
|
||||||
outputStream.flush();
|
|
||||||
outputStream.close();
|
|
||||||
BufferedReader in = new BufferedReader(
|
|
||||||
new InputStreamReader(connection.getInputStream()));
|
|
||||||
String inputLine;
|
|
||||||
StringBuffer response = new StringBuffer();
|
|
||||||
|
|
||||||
while ((inputLine = in.readLine()) != null)
|
|
||||||
{
|
|
||||||
response.append(inputLine);
|
|
||||||
}
|
|
||||||
in.close();
|
|
||||||
return response.toString();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,6 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.amp;
|
|
||||||
|
|
||||||
public interface LoginCallback
|
|
||||||
{
|
|
||||||
void loginDone(boolean success);
|
|
||||||
}
|
|
@ -1,49 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.amp;
|
|
||||||
|
|
||||||
import com.google.gson.annotations.Expose;
|
|
||||||
import com.google.gson.annotations.SerializedName;
|
|
||||||
import java.util.List;
|
|
||||||
import lombok.Getter;
|
|
||||||
import lombok.Setter;
|
|
||||||
|
|
||||||
public class LoginResult
|
|
||||||
{
|
|
||||||
|
|
||||||
@SerializedName("result")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Integer result;
|
|
||||||
@SerializedName("success")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private Boolean success;
|
|
||||||
@SerializedName("permissions")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private List<String> permissions = null;
|
|
||||||
@SerializedName("sessionID")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String sessionID;
|
|
||||||
@SerializedName("rememberMeToken")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String rememberMeToken;
|
|
||||||
@SerializedName("gravatarHash")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String gravatarHash;
|
|
||||||
@SerializedName("username")
|
|
||||||
@Expose
|
|
||||||
@Getter
|
|
||||||
@Setter
|
|
||||||
private String username;
|
|
||||||
private final static long serialVersionUID = -523050232433919883L;
|
|
||||||
|
|
||||||
}
|
|
@ -1,29 +1,25 @@
|
|||||||
package me.totalfreedom.totalfreedommod.banning;
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import java.text.DateFormat;
|
|
||||||
import java.text.SimpleDateFormat;
|
import java.text.SimpleDateFormat;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.base.ConfigLoadable;
|
|
||||||
import net.pravian.aero.base.ConfigSavable;
|
|
||||||
import net.pravian.aero.base.Validatable;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.configuration.ConfigurationSection;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
public class Ban
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
public static final SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd \'at\' HH:mm:ss z");
|
||||||
@ -32,6 +28,9 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
@Setter
|
@Setter
|
||||||
private String username = null;
|
private String username = null;
|
||||||
@Getter
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
private final List<String> ips = Lists.newArrayList();
|
private final List<String> ips = Lists.newArrayList();
|
||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@ -50,29 +49,32 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String ip, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, String ip, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this(username,
|
this(username,
|
||||||
new String[]
|
uuid,
|
||||||
{
|
Arrays.asList(ip),
|
||||||
ip
|
|
||||||
},
|
|
||||||
by,
|
by,
|
||||||
at,
|
at,
|
||||||
expire,
|
expire,
|
||||||
reason);
|
reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Ban(String username, String[] ips, String by, Date at, Date expire, String reason)
|
public Ban(String username, UUID uuid, List<String> ips, String by, Date at, Date expire, String reason)
|
||||||
{
|
{
|
||||||
this.username = username;
|
this.username = username;
|
||||||
|
this.uuid = uuid;
|
||||||
if (ips != null)
|
if (ips != null)
|
||||||
{
|
{
|
||||||
this.ips.addAll(Arrays.asList(ips));
|
this.ips.addAll(ips);
|
||||||
}
|
}
|
||||||
dedupeIps();
|
dedupeIps();
|
||||||
this.by = by;
|
this.by = by;
|
||||||
this.at = at;
|
this.at = at;
|
||||||
|
if (expire == null)
|
||||||
|
{
|
||||||
|
expire = FUtil.parseDateOffset("24h");
|
||||||
|
}
|
||||||
this.expiryUnix = FUtil.getUnixTime(expire);
|
this.expiryUnix = FUtil.getUnixTime(expire);
|
||||||
this.reason = reason;
|
this.reason = reason;
|
||||||
}
|
}
|
||||||
@ -86,15 +88,12 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
|
|
||||||
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, new String[]
|
return new Ban(null, null, Arrays.asList(FUtil.getIp(player)), by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
{
|
|
||||||
Ips.getIp(player)
|
|
||||||
}, by.getName(), Date.from(Instant.now()), expiry, reason);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerIp(String ip, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
return new Ban(null, null, ip, by.getName(), Date.from(Instant.now()), expiry, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -107,7 +106,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerName(String player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player,
|
return new Ban(player,
|
||||||
(String[])null,
|
null,
|
||||||
|
new ArrayList<>(),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -124,7 +124,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayer(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
Ips.getIp(player),
|
player.getUniqueId(),
|
||||||
|
FUtil.getIp(player),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -134,7 +135,8 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
public static Ban forPlayerFuzzy(Player player, CommandSender by, Date expiry, String reason)
|
||||||
{
|
{
|
||||||
return new Ban(player.getName(),
|
return new Ban(player.getName(),
|
||||||
FUtil.getFuzzyIp(Ips.getIp(player)),
|
player.getUniqueId(),
|
||||||
|
FUtil.getFuzzyIp(FUtil.getIp(player)),
|
||||||
by.getName(),
|
by.getName(),
|
||||||
Date.from(Instant.now()),
|
Date.from(Instant.now()),
|
||||||
expiry,
|
expiry,
|
||||||
@ -146,6 +148,11 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return username != null && !username.isEmpty();
|
return username != null && !username.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean hasUUID()
|
||||||
|
{
|
||||||
|
return uuid != null;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean addIp(String ip)
|
public boolean addIp(String ip)
|
||||||
{
|
{
|
||||||
return ips.add(ip);
|
return ips.add(ip);
|
||||||
@ -171,11 +178,24 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
return hasExpiry() && expiryUnix < FUtil.getUnixTime();
|
||||||
}
|
}
|
||||||
|
|
||||||
public String bakeKickMessage(String ip)
|
public String bakeKickMessage()
|
||||||
{
|
{
|
||||||
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
final StringBuilder message = new StringBuilder(ChatColor.GOLD + "You");
|
||||||
|
|
||||||
message.append(!hasUsername() ? "r IP address is" : " are").append(" temporarily banned from this server.");
|
if (!hasUsername())
|
||||||
|
{
|
||||||
|
message.append("r IP address is");
|
||||||
|
}
|
||||||
|
else if (!hasIps())
|
||||||
|
{
|
||||||
|
message.append("r username is");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
message.append(" are");
|
||||||
|
}
|
||||||
|
|
||||||
|
message.append(" temporarily banned from this server.");
|
||||||
message.append("\nAppeal at ").append(ChatColor.BLUE)
|
message.append("\nAppeal at ").append(ChatColor.BLUE)
|
||||||
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
.append(ConfigEntry.SERVER_BAN_URL.getString());
|
||||||
|
|
||||||
@ -203,9 +223,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
.append(DATE_FORMAT.format(FUtil.getUnixDate(expiryUnix)));
|
||||||
}
|
}
|
||||||
|
|
||||||
message.append("\n").append(ChatColor.RED).append("IP Address: ").append(ChatColor.GOLD)
|
|
||||||
.append(ip);
|
|
||||||
|
|
||||||
return message.toString();
|
return message.toString();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -237,46 +254,6 @@ public class Ban implements ConfigLoadable, ConfigSavable, Validatable
|
|||||||
return !(hasUsername() && !(getUsername().equalsIgnoreCase(ban.getUsername())));
|
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.at = FUtil.stringToDate(cs.getString("at", 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("at", FUtil.dateToString(at));
|
|
||||||
cs.set("reason", reason);
|
|
||||||
cs.set("expiry_unix", expiryUnix > 0 ? expiryUnix : null);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean isValid()
|
|
||||||
{
|
|
||||||
return username != null || !ips.isEmpty();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void dedupeIps()
|
private void dedupeIps()
|
||||||
{
|
{
|
||||||
|
|
||||||
|
@ -3,20 +3,21 @@ package me.totalfreedom.totalfreedommod.banning;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
import com.google.common.collect.Sets;
|
import com.google.common.collect.Sets;
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Iterator;
|
import java.util.Date;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
import me.totalfreedom.totalfreedommod.player.PlayerData;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.config.YamlConfig;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -27,44 +28,43 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
|
|
||||||
private final Set<Ban> bans = Sets.newHashSet();
|
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 Map<String, Ban> nameBans = Maps.newHashMap();
|
||||||
|
private final Map<UUID, Ban> uuidBans = Maps.newHashMap();
|
||||||
|
private final Map<String, Ban> ipBans = Maps.newHashMap();
|
||||||
private final List<String> unbannableUsernames = Lists.newArrayList();
|
private final List<String> unbannableUsernames = Lists.newArrayList();
|
||||||
public static final String CONFIG_FILENAME = "bans.yml";
|
|
||||||
|
|
||||||
//
|
//
|
||||||
private final YamlConfig config;
|
|
||||||
|
|
||||||
public BanManager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
this.config = new YamlConfig(plugin, "bans.yml");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
config.load();
|
|
||||||
|
|
||||||
bans.clear();
|
bans.clear();
|
||||||
for (String id : config.getKeys(false))
|
try
|
||||||
{
|
{
|
||||||
if (!config.isConfigurationSection(id))
|
ResultSet banSet = plugin.sql.getBanList();
|
||||||
{
|
{
|
||||||
FLog.warning("Could not load username ban: " + id + ". Invalid format!");
|
while (banSet.next())
|
||||||
continue;
|
{
|
||||||
|
String name = banSet.getString("name");
|
||||||
|
UUID uuid = null;
|
||||||
|
String strUUID = banSet.getString("uuid");
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
uuid = UUID.fromString(strUUID);
|
||||||
|
}
|
||||||
|
List<String> ips = FUtil.stringToList(banSet.getString("ips"));
|
||||||
|
String by = banSet.getString("by");
|
||||||
|
Date at = new Date(banSet.getLong("at"));
|
||||||
|
Date expires = new Date(banSet.getLong("expires"));
|
||||||
|
String reason = banSet.getString("reason");
|
||||||
|
Ban ban = new Ban(name, uuid, ips, by, at, expires, reason);
|
||||||
|
bans.add(ban);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Ban ban = new Ban();
|
catch (SQLException e)
|
||||||
ban.loadFrom(config.getConfigurationSection(id));
|
{
|
||||||
|
FLog.severe("Failed to load ban list: " + e.getMessage());
|
||||||
if (!ban.isValid())
|
|
||||||
{
|
|
||||||
FLog.warning("Not adding username ban: " + id + ". Missing information.");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
bans.add(ban);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Remove expired bans, repopulate ipBans and nameBans,
|
// Remove expired bans, repopulate ipBans and nameBans,
|
||||||
@ -79,10 +79,8 @@ public class BanManager extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
saveAll();
|
|
||||||
logger.info("Saved " + bans.size() + " player bans");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Set<Ban> getAllBans()
|
public Set<Ban> getAllBans()
|
||||||
@ -100,21 +98,6 @@ public class BanManager extends FreedomService
|
|||||||
return Collections.unmodifiableCollection(nameBans.values());
|
return Collections.unmodifiableCollection(nameBans.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void saveAll()
|
|
||||||
{
|
|
||||||
// Remove expired
|
|
||||||
updateViews();
|
|
||||||
|
|
||||||
config.clear();
|
|
||||||
for (Ban ban : bans)
|
|
||||||
{
|
|
||||||
ban.saveTo(config.createSection(String.valueOf(ban.hashCode())));
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save config
|
|
||||||
config.save();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Ban getByIp(String ip)
|
public Ban getByIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban directBan = ipBans.get(ip);
|
final Ban directBan = ipBans.get(ip);
|
||||||
@ -138,7 +121,7 @@ public class BanManager extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Ips.fuzzyIpMatch(ip, loopIp, 4))
|
if (FUtil.fuzzyIpMatch(ip, loopIp, 4))
|
||||||
{
|
{
|
||||||
return loopBan;
|
return loopBan;
|
||||||
}
|
}
|
||||||
@ -161,6 +144,18 @@ public class BanManager extends FreedomService
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Ban getByUUID(UUID uuid)
|
||||||
|
{
|
||||||
|
final Ban directBan = uuidBans.get(uuid);
|
||||||
|
|
||||||
|
if (directBan != null && !directBan.isExpired())
|
||||||
|
{
|
||||||
|
return directBan;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public Ban unbanIp(String ip)
|
public Ban unbanIp(String ip)
|
||||||
{
|
{
|
||||||
final Ban ban = getByIp(ip);
|
final Ban ban = getByIp(ip);
|
||||||
@ -168,7 +163,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -181,7 +175,6 @@ public class BanManager extends FreedomService
|
|||||||
if (ban != null)
|
if (ban != null)
|
||||||
{
|
{
|
||||||
bans.remove(ban);
|
bans.remove(ban);
|
||||||
saveAll();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return ban;
|
return ban;
|
||||||
@ -199,9 +192,27 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public boolean addBan(Ban ban)
|
public boolean addBan(Ban ban)
|
||||||
{
|
{
|
||||||
|
if (ban.getUsername() != null && getByUsername(ban.getUsername()) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
|
||||||
|
for (String ip : ban.getIps())
|
||||||
|
{
|
||||||
|
if (getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (bans.add(ban))
|
if (bans.add(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.addBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,7 +223,8 @@ public class BanManager extends FreedomService
|
|||||||
{
|
{
|
||||||
if (bans.remove(ban))
|
if (bans.remove(ban))
|
||||||
{
|
{
|
||||||
saveAll();
|
plugin.sql.removeBan(ban);
|
||||||
|
updateViews();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -221,69 +233,79 @@ public class BanManager extends FreedomService
|
|||||||
|
|
||||||
public int purge()
|
public int purge()
|
||||||
{
|
{
|
||||||
config.clear();
|
|
||||||
config.save();
|
|
||||||
|
|
||||||
int size = bans.size();
|
int size = bans.size();
|
||||||
bans.clear();
|
bans.clear();
|
||||||
updateViews();
|
updateViews();
|
||||||
|
plugin.sql.truncate("bans");
|
||||||
return size;
|
return size;
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
{
|
{
|
||||||
final String username = event.getPlayer().getName();
|
final String username = event.getPlayer().getName();
|
||||||
final String ip = Ips.getIp(event);
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
// Regular ban
|
// Regular ban
|
||||||
Ban ban = getByUsername(username);
|
Ban ban = getByUsername(username);
|
||||||
if (ban == null)
|
if (ban == null)
|
||||||
{
|
{
|
||||||
ban = getByIp(ip);
|
ban = getByUUID(uuid);
|
||||||
|
|
||||||
|
if (ban == null)
|
||||||
|
{
|
||||||
|
ban = getByIp(ip);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ban != null && !ban.isExpired())
|
if (ban != null && !ban.isExpired())
|
||||||
{
|
{
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage(ip));
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, ban.bakeKickMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerJoin(PlayerJoinEvent event)
|
public void onPlayerJoin(PlayerJoinEvent event)
|
||||||
{
|
{
|
||||||
final Player player = event.getPlayer();
|
final Player player = event.getPlayer();
|
||||||
final PlayerData data = plugin.pl.getData(player);
|
final PlayerData data = plugin.pl.getData(player);
|
||||||
|
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Unban admins
|
// Unban admins
|
||||||
for (String storedIp : data.getIps())
|
Ban ban = getByUsername(player.getName());
|
||||||
|
if (ban != null)
|
||||||
{
|
{
|
||||||
unbanIp(storedIp);
|
removeBan(ban);
|
||||||
unbanIp(FUtil.getFuzzyIp(storedIp));
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = getByIp(FUtil.getIp(player));
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
removeBan(ban);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
unbanUsername(player.getName());
|
|
||||||
player.setOp(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateViews()
|
private void updateViews()
|
||||||
{
|
{
|
||||||
// Remove expired bans
|
// Remove expired bans
|
||||||
for (Iterator<Ban> it = bans.iterator(); it.hasNext(); )
|
for (Ban ban : new ArrayList<>(bans))
|
||||||
{
|
{
|
||||||
if (it.next().isExpired())
|
if (ban.isExpired())
|
||||||
{
|
{
|
||||||
it.remove();
|
bans.remove(ban);
|
||||||
|
plugin.sql.removeBan(ban);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
nameBans.clear();
|
nameBans.clear();
|
||||||
|
uuidBans.clear();
|
||||||
ipBans.clear();
|
ipBans.clear();
|
||||||
for (Ban ban : bans)
|
for (Ban ban : bans)
|
||||||
{
|
{
|
||||||
@ -292,6 +314,11 @@ public class BanManager extends FreedomService
|
|||||||
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
nameBans.put(ban.getUsername().toLowerCase(), ban);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ban.hasUUID())
|
||||||
|
{
|
||||||
|
uuidBans.put(ban.getUuid(), ban);
|
||||||
|
}
|
||||||
|
|
||||||
if (ban.hasIps())
|
if (ban.hasIps())
|
||||||
{
|
{
|
||||||
for (String ip : ban.getIps())
|
for (String ip : ban.getIps())
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.collect.Lists;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.IConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
|
||||||
|
public class IndefiniteBan implements IConfig
|
||||||
|
{
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String username = null;
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private UUID uuid = null;
|
||||||
|
@Getter
|
||||||
|
private final List<String> ips = Lists.newArrayList();
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
private String reason = null;
|
||||||
|
|
||||||
|
public IndefiniteBan()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void loadFrom(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
this.username = cs.getName();
|
||||||
|
try
|
||||||
|
{
|
||||||
|
String strUUID = cs.getString("uuid", null);
|
||||||
|
if (strUUID != null)
|
||||||
|
{
|
||||||
|
UUID uuid = UUID.fromString(strUUID);
|
||||||
|
this.uuid = uuid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (IllegalArgumentException e)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to load indefinite banned UUID for " + this.username + ". Make sure the UUID is in the correct format with dashes.");
|
||||||
|
}
|
||||||
|
this.ips.clear();
|
||||||
|
this.ips.addAll(cs.getStringList("ips"));
|
||||||
|
this.reason = cs.getString("reason", null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void saveTo(ConfigurationSection cs)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean isValid()
|
||||||
|
{
|
||||||
|
return username != null;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,140 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.banning;
|
||||||
|
|
||||||
|
import com.google.common.base.Strings;
|
||||||
|
import com.google.common.collect.Sets;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
|
import me.totalfreedom.totalfreedommod.config.YamlConfig;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.configuration.ConfigurationSection;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public class IndefiniteBanList extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public static final String CONFIG_FILENAME = "indefinitebans.yml";
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private final Set<IndefiniteBan> indefBans = Sets.newHashSet();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int nameBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int uuidBanCount = 0;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private int ipBanCount = 0;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
indefBans.clear();
|
||||||
|
|
||||||
|
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
||||||
|
config.load();
|
||||||
|
|
||||||
|
for (String name : config.getKeys(false))
|
||||||
|
{
|
||||||
|
if (!config.isConfigurationSection(name))
|
||||||
|
{
|
||||||
|
FLog.warning("Could not load indefinite ban for " + name + ": Invalid format!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
IndefiniteBan indefBan = new IndefiniteBan();
|
||||||
|
ConfigurationSection cs = config.getConfigurationSection(name);
|
||||||
|
indefBan.loadFrom(cs);
|
||||||
|
|
||||||
|
if (!indefBan.isValid())
|
||||||
|
{
|
||||||
|
FLog.warning("Not adding indefinite ban for " + name + ": Missing information.");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
indefBans.add(indefBan);
|
||||||
|
}
|
||||||
|
|
||||||
|
updateCount();
|
||||||
|
|
||||||
|
FLog.info("Loaded " + nameBanCount + " indefinite name bans, " + uuidBanCount + " UUID bans, and " + ipBanCount + " ip bans");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerLogin(PlayerLoginEvent event)
|
||||||
|
{
|
||||||
|
final String username = event.getPlayer().getName();
|
||||||
|
final UUID uuid = event.getPlayer().getUniqueId();
|
||||||
|
final String ip = FUtil.getIp(event);
|
||||||
|
|
||||||
|
String bannedBy = "";
|
||||||
|
IndefiniteBan ban = null;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
if (username.toLowerCase().equals(indefBan.getUsername().toLowerCase()))
|
||||||
|
{
|
||||||
|
bannedBy = "username";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getUuid() != null && indefBan.getUuid().equals(uuid))
|
||||||
|
{
|
||||||
|
bannedBy = "UUID";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
else if (indefBan.getIps().contains(ip))
|
||||||
|
{
|
||||||
|
bannedBy = "IP address";
|
||||||
|
ban = indefBan;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (ban != null)
|
||||||
|
{
|
||||||
|
String kickMessage = ChatColor.RED + "Your " + bannedBy + " is indefinitely banned from this server.";
|
||||||
|
String reason = ban.getReason();
|
||||||
|
if (!Strings.isNullOrEmpty(reason))
|
||||||
|
{
|
||||||
|
kickMessage += "\nReason: " + ChatColor.GOLD + reason;
|
||||||
|
}
|
||||||
|
String appealURL = ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
if (!Strings.isNullOrEmpty(appealURL))
|
||||||
|
{
|
||||||
|
kickMessage += ChatColor.RED + "\n\nRelease procedures are available at\n" + ChatColor.GOLD + ConfigEntry.SERVER_INDEFBAN_URL.getString();
|
||||||
|
}
|
||||||
|
event.disallow(PlayerLoginEvent.Result.KICK_OTHER, kickMessage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateCount()
|
||||||
|
{
|
||||||
|
nameBanCount = 0;
|
||||||
|
uuidBanCount = 0;
|
||||||
|
ipBanCount = 0;
|
||||||
|
|
||||||
|
for (IndefiniteBan indefBan : indefBans)
|
||||||
|
{
|
||||||
|
nameBanCount += 1;
|
||||||
|
if (indefBan.getUuid() != null)
|
||||||
|
{
|
||||||
|
uuidBanCount += 1;
|
||||||
|
}
|
||||||
|
ipBanCount += indefBan.getIps().size();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,99 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPermbannedNames()
|
|
||||||
{
|
|
||||||
return this.permbannedNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getPermbannedIps()
|
|
||||||
{
|
|
||||||
return this.permbannedIps;
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,76 +0,0 @@
|
|||||||
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 VPNBanList extends FreedomService
|
|
||||||
{
|
|
||||||
|
|
||||||
public static final String CONFIG_FILENAME = "vpnbans.yml";
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private final Set<String> vpnIps = Sets.newHashSet();
|
|
||||||
|
|
||||||
public VPNBanList(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStart()
|
|
||||||
{
|
|
||||||
vpnIps.clear();
|
|
||||||
|
|
||||||
final YamlConfig config = new YamlConfig(plugin, CONFIG_FILENAME, true);
|
|
||||||
config.load();
|
|
||||||
|
|
||||||
for (String name : config.getKeys(false))
|
|
||||||
{
|
|
||||||
vpnIps.addAll(config.getStringList(name));
|
|
||||||
}
|
|
||||||
|
|
||||||
FLog.info("Loaded " + vpnIps.size() + " VPN ips.");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOWEST)
|
|
||||||
public void onPlayerLogin(PlayerLoginEvent event)
|
|
||||||
{
|
|
||||||
final String ip = Ips.getIp(event);
|
|
||||||
|
|
||||||
// Permbanned IPs
|
|
||||||
for (String testIp : getVPNIps())
|
|
||||||
{
|
|
||||||
if (FUtil.fuzzyIpMatch(testIp, ip, 4))
|
|
||||||
{
|
|
||||||
event.disallow(PlayerLoginEvent.Result.KICK_OTHER,
|
|
||||||
ChatColor.RED + "Your IP address is detected as a VPN\n"
|
|
||||||
+ "If you believe this is an error, release procedures are available at\n"
|
|
||||||
+ ChatColor.GOLD + ConfigEntry.SERVER_PERMBAN_URL.getString());
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
public Set<String> getVPNIps()
|
|
||||||
{
|
|
||||||
return this.vpnIps;
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,15 +2,11 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Banner;
|
import org.bukkit.block.Banner;
|
||||||
import org.bukkit.block.Block;
|
|
||||||
import org.bukkit.block.Skull;
|
import org.bukkit.block.Skull;
|
||||||
import org.bukkit.block.banner.Pattern;
|
import org.bukkit.block.banner.Pattern;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
@ -23,19 +19,13 @@ import org.bukkit.inventory.meta.SkullMeta;
|
|||||||
|
|
||||||
public class BlockBlocker extends FreedomService
|
public class BlockBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public BlockBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -48,11 +38,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
case LAVA:
|
case LAVA:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed lava @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Lava placement is currently disabled.");
|
||||||
@ -62,11 +48,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
case WATER:
|
case WATER:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed water @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Water placement is currently disabled.");
|
||||||
@ -76,12 +58,9 @@ public class BlockBlocker extends FreedomService
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case FIRE:
|
case FIRE:
|
||||||
|
case SOUL_FIRE:
|
||||||
{
|
{
|
||||||
if (ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
if (!ConfigEntry.ALLOW_FIRE_PLACE.getBoolean())
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed fire @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
player.sendMessage(ChatColor.GRAY + "Fire placement is currently disabled.");
|
||||||
@ -89,14 +68,6 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case TNT:
|
|
||||||
{
|
|
||||||
if (ConfigEntry.ALLOW_EXPLOSIONS.getBoolean())
|
|
||||||
{
|
|
||||||
FLog.info(String.format("%s placed TNT @ %s", player.getName(), FUtil.formatLocation(event.getBlock().getLocation())));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case STRUCTURE_BLOCK:
|
case STRUCTURE_BLOCK:
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
if (!ConfigEntry.ALLOW_STRUCTURE_BLOCKS.getBoolean())
|
||||||
@ -152,7 +123,7 @@ public class BlockBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
if (!ConfigEntry.ALLOW_BEEHIVES.getBoolean())
|
||||||
{
|
{
|
||||||
player.sendMessage(ChatColor.GRAY + "Bee hives are disabled.");
|
player.sendMessage(ChatColor.GRAY + "Beehives are disabled.");
|
||||||
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -162,11 +133,11 @@ public class BlockBlocker extends FreedomService
|
|||||||
case PLAYER_WALL_HEAD:
|
case PLAYER_WALL_HEAD:
|
||||||
{
|
{
|
||||||
Skull skull = (Skull) event.getBlockPlaced().getState();
|
Skull skull = (Skull) event.getBlockPlaced().getState();
|
||||||
if (skull.hasOwner())
|
if (skull.getOwner() != null)
|
||||||
{
|
{
|
||||||
if (skull.getOwner().contains("§"))
|
if (skull.getOwner().contains("\u00A7"))
|
||||||
{
|
{
|
||||||
skull.setOwner(skull.getOwner().replace("§", ""));
|
skull.setOwner(skull.getOwner().replace("\u00A7", ""));
|
||||||
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
SkullMeta meta = (SkullMeta) event.getItemInHand().getItemMeta();
|
||||||
if (meta != null)
|
if (meta != null)
|
||||||
{
|
{
|
||||||
@ -188,18 +159,25 @@ public class BlockBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case RESPAWN_ANCHOR:
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_RESPAWN_ANCHORS.getBoolean())
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Respawn anchors are disabled.");
|
||||||
|
player.getInventory().setItem(player.getInventory().getHeldItemSlot(), new ItemStack(Material.COOKIE, 1));
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
if (Groups.BANNERS.contains(event.getBlockPlaced().getType()))
|
||||||
{
|
{
|
||||||
Banner banner = (Banner) event.getBlockPlaced().getState();
|
Banner banner = (Banner) event.getBlockPlaced().getState();
|
||||||
List<Pattern> patterns = banner.getPatterns();
|
List<Pattern> patterns = banner.getPatterns();;
|
||||||
Banner handBanner = (Banner) (((Block) event.getItemInHand()).getState());
|
|
||||||
List<Pattern> handPatterns = banner.getPatterns();
|
|
||||||
if (patterns.size() >= 2)
|
if (patterns.size() >= 2)
|
||||||
{
|
{
|
||||||
banner.setPatterns(patterns.subList(0, 2));
|
banner.setPatterns(patterns.subList(0, 2));
|
||||||
handBanner.setPatterns(handPatterns.subList(0, 2));
|
|
||||||
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
player.sendMessage(ChatColor.GRAY + "Your banner had too many patterns on it, so some were removed.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FSync;
|
import me.totalfreedom.totalfreedommod.util.FSync;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -12,19 +11,13 @@ import org.bukkit.event.block.BlockPlaceEvent;
|
|||||||
|
|
||||||
public class EditBlocker extends FreedomService
|
public class EditBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public EditBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -37,7 +30,7 @@ public class EditBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
@ -56,7 +49,7 @@ public class EditBlocker extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (plugin.al.isAdminSync(event.getPlayer()))
|
if (plugin.sl.isStaffSync(event.getPlayer()))
|
||||||
{
|
{
|
||||||
fPlayer.setEditBlocked(false);
|
fPlayer.setEditBlocked(false);
|
||||||
return;
|
return;
|
||||||
|
@ -1,15 +1,17 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.attribute.AttributeModifier;
|
import org.bukkit.attribute.AttributeModifier;
|
||||||
|
import org.bukkit.block.data.AnaloguePowerable;
|
||||||
|
import org.bukkit.block.data.Powerable;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Tameable;
|
import org.bukkit.entity.Tameable;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -17,12 +19,13 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.block.BlockBurnEvent;
|
import org.bukkit.event.block.BlockBurnEvent;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
import org.bukkit.event.block.BlockFromToEvent;
|
import org.bukkit.event.block.BlockFromToEvent;
|
||||||
|
import org.bukkit.event.block.BlockGrowEvent;
|
||||||
import org.bukkit.event.block.BlockIgniteEvent;
|
import org.bukkit.event.block.BlockIgniteEvent;
|
||||||
|
import org.bukkit.event.block.BlockPhysicsEvent;
|
||||||
import org.bukkit.event.block.BlockPistonExtendEvent;
|
import org.bukkit.event.block.BlockPistonExtendEvent;
|
||||||
import org.bukkit.event.block.BlockPistonRetractEvent;
|
import org.bukkit.event.block.BlockPistonRetractEvent;
|
||||||
import org.bukkit.event.block.BlockRedstoneEvent;
|
import org.bukkit.event.block.BlockRedstoneEvent;
|
||||||
import org.bukkit.event.block.LeavesDecayEvent;
|
import org.bukkit.event.block.LeavesDecayEvent;
|
||||||
import org.bukkit.event.block.BlockGrowEvent;
|
|
||||||
import org.bukkit.event.entity.EntityCombustEvent;
|
import org.bukkit.event.entity.EntityCombustEvent;
|
||||||
import org.bukkit.event.entity.EntityDamageEvent;
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
import org.bukkit.event.entity.EntityDeathEvent;
|
import org.bukkit.event.entity.EntityDeathEvent;
|
||||||
@ -35,19 +38,13 @@ import org.bukkit.event.player.PlayerRespawnEvent;
|
|||||||
|
|
||||||
public class EventBlocker extends FreedomService
|
public class EventBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public EventBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,7 +148,7 @@ public class EventBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerDropItem(PlayerDropItemEvent event)
|
public void onPlayerDropItem(PlayerDropItemEvent event)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(event.getPlayer()))
|
if (!plugin.sl.isStaff(event.getPlayer()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
@ -206,7 +203,7 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
//@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onBlockRedstone(BlockRedstoneEvent event)
|
public void onBlockRedstone(BlockRedstoneEvent event)
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
@ -215,6 +212,21 @@ public class EventBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Revert back to old redstone block system when (or if) it is fixed in Bukkit, Spigot or Paper.
|
||||||
|
private ArrayList<Material> redstoneBlocks = new ArrayList<>(Arrays.asList(Material.REDSTONE, Material.DISPENSER, Material.DROPPER, Material.REDSTONE_LAMP));
|
||||||
|
@EventHandler
|
||||||
|
public void onBlockPhysics(BlockPhysicsEvent event)
|
||||||
|
{
|
||||||
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
|
{
|
||||||
|
// Check if the block is involved with redstone.
|
||||||
|
if(event.getBlock().getBlockData() instanceof AnaloguePowerable || event.getBlock().getBlockData() instanceof Powerable || redstoneBlocks.contains(event.getBlock().getType()))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
public void onPlayerRespawn(PlayerRespawnEvent event)
|
public void onPlayerRespawn(PlayerRespawnEvent event)
|
||||||
{
|
{
|
||||||
|
@ -1,33 +1,26 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.Groups;
|
import me.totalfreedom.totalfreedommod.util.Groups;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.player.PlayerBedEnterEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class InteractBlocker extends FreedomService
|
public class InteractBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public InteractBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -55,15 +48,20 @@ public class InteractBlocker extends FreedomService
|
|||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
public void onRightClickBell(PlayerInteractEvent event)
|
public void onRightClickBell(PlayerInteractEvent event)
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock() != null)
|
if (event.getClickedBlock() != null && event.getClickedBlock().getType().equals(Material.BELL) && !ConfigEntry.ALLOW_BELLS.getBoolean())
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.BELL))
|
event.setCancelled(true);
|
||||||
{
|
}
|
||||||
if (!ConfigEntry.ALLOW_BELLS.getBoolean())
|
}
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
@EventHandler
|
||||||
}
|
public void onBedEnter(PlayerBedEnterEvent event)
|
||||||
}
|
{
|
||||||
|
Player player = event.getPlayer();
|
||||||
|
if (Groups.EXPLOSIVE_BED_BIOMES.contains(event.getBed().getBiome()))
|
||||||
|
{
|
||||||
|
player.sendMessage(ChatColor.RED + "You may not sleep here.");
|
||||||
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +71,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
|
|
||||||
if (event.getClickedBlock() != null)
|
if (event.getClickedBlock() != null)
|
||||||
{
|
{
|
||||||
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW))
|
if (event.getClickedBlock().getType().equals(Material.STRUCTURE_BLOCK) || event.getClickedBlock().getType().equals(Material.JIGSAW) || event.getClickedBlock().getType().equals(Material.RESPAWN_ANCHOR))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
event.getPlayer().closeInventory();
|
event.getPlayer().closeInventory();
|
||||||
@ -92,7 +90,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
{
|
{
|
||||||
case WATER_BUCKET:
|
case WATER_BUCKET:
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_WATER_PLACE.getBoolean())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -105,7 +103,7 @@ public class InteractBlocker extends FreedomService
|
|||||||
|
|
||||||
case LAVA_BUCKET:
|
case LAVA_BUCKET:
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
if (plugin.sl.isStaff(player) || ConfigEntry.ALLOW_LAVA_PLACE.getBoolean())
|
||||||
{
|
{
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -153,6 +151,13 @@ public class InteractBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case WRITTEN_BOOK:
|
||||||
|
{
|
||||||
|
player.getInventory().clear(player.getInventory().getHeldItemSlot());
|
||||||
|
player.sendMessage(ChatColor.GRAY + "Books are currently disabled.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
|
||||||
import org.bukkit.attribute.Attributable;
|
import org.bukkit.attribute.Attributable;
|
||||||
import org.bukkit.attribute.Attribute;
|
import org.bukkit.attribute.Attribute;
|
||||||
import org.bukkit.entity.Bat;
|
import org.bukkit.entity.Bat;
|
||||||
@ -22,19 +20,13 @@ import org.bukkit.event.entity.EntitySpawnEvent;
|
|||||||
|
|
||||||
public class MobBlocker extends FreedomService
|
public class MobBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public MobBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,32 +1,26 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.GameMode;
|
import org.bukkit.GameMode;
|
||||||
import org.bukkit.entity.Arrow;
|
import org.bukkit.entity.Arrow;
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.entity.Trident;
|
|
||||||
import org.bukkit.entity.FishHook;
|
import org.bukkit.entity.FishHook;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.SpectralArrow;
|
||||||
|
import org.bukkit.entity.Trident;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
import org.bukkit.event.entity.EntityDamageByEntityEvent;
|
||||||
|
|
||||||
public class PVPBlocker extends FreedomService
|
public class PVPBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public PVPBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -50,6 +44,14 @@ public class PVPBlocker extends FreedomService
|
|||||||
player = (Player)arrow.getShooter();
|
player = (Player)arrow.getShooter();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (event.getDamager() instanceof SpectralArrow)
|
||||||
|
{
|
||||||
|
SpectralArrow spectralArrow = (SpectralArrow)event.getDamager();
|
||||||
|
if (spectralArrow.getShooter() instanceof Player)
|
||||||
|
{
|
||||||
|
player = (Player)spectralArrow.getShooter();
|
||||||
|
}
|
||||||
|
}
|
||||||
else if (event.getDamager() instanceof Trident)
|
else if (event.getDamager() instanceof Trident)
|
||||||
{
|
{
|
||||||
Trident trident = (Trident)event.getDamager();
|
Trident trident = (Trident)event.getDamager();
|
||||||
@ -68,7 +70,7 @@ public class PVPBlocker extends FreedomService
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (player != null & !plugin.al.isAdmin(player))
|
if (player != null & !plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
if (player.getGameMode() == GameMode.CREATIVE)
|
if (player.getGameMode() == GameMode.CREATIVE)
|
||||||
{
|
{
|
||||||
@ -91,7 +93,5 @@ public class PVPBlocker extends FreedomService
|
|||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
|
@ -2,7 +2,6 @@ package me.totalfreedom.totalfreedommod.blocking;
|
|||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.entity.ThrownPotion;
|
import org.bukkit.entity.ThrownPotion;
|
||||||
@ -19,18 +18,13 @@ public class PotionBlocker extends FreedomService
|
|||||||
|
|
||||||
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
public static final int POTION_BLOCK_RADIUS_SQUARED = 20 * 20;
|
||||||
|
|
||||||
public PotionBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,12 +1,10 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking;
|
package me.totalfreedom.totalfreedommod.blocking;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import net.minecraft.server.v1_16_R2.NBTTagCompound;
|
||||||
import net.minecraft.server.v1_15_R1.NBTTagCompound;
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.Tag;
|
import org.bukkit.Tag;
|
||||||
import org.bukkit.craftbukkit.v1_15_R1.inventory.CraftItemStack;
|
import org.bukkit.craftbukkit.v1_16_R2.inventory.CraftItemStack;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
@ -19,19 +17,13 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
|
|
||||||
public class SignBlocker extends FreedomService
|
public class SignBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public SignBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,7 +35,7 @@ public class SignBlocker extends FreedomService
|
|||||||
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
if (Tag.SIGNS.getValues().contains(event.getBlock().getType()))
|
||||||
{
|
{
|
||||||
ItemStack sign = event.getItemInHand();
|
ItemStack sign = event.getItemInHand();
|
||||||
net.minecraft.server.v1_15_R1.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
net.minecraft.server.v1_16_R2.ItemStack nmsSign = CraftItemStack.asNMSCopy(sign);
|
||||||
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
NBTTagCompound compound = (nmsSign.hasTag()) ? nmsSign.getTag() : new NBTTagCompound();
|
||||||
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
NBTTagCompound bet = compound.getCompound("BlockEntityTag");
|
||||||
String line1 = bet.getString("Text1");
|
String line1 = bet.getString("Text1");
|
||||||
@ -55,16 +47,6 @@ public class SignBlocker extends FreedomService
|
|||||||
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
|
player.sendMessage(ChatColor.GRAY + "You are not allowed to place command signs.");
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
if (line1.contains("translate") || line2.contains("translate") || line3.contains("translate") || line4.contains("translate"))
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.GRAY + "You are not allowed to place broken strings that Mojang never fixed.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
if (line1.contains("translation.test.") || line2.contains("translation.test.") || line3.contains("translation.test.") || line4.contains("translation.test."))
|
|
||||||
{
|
|
||||||
player.sendMessage(ChatColor.BOLD + "No.");
|
|
||||||
event.setCancelled(true);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,24 +2,25 @@ package me.totalfreedom.totalfreedommod.blocking.command;
|
|||||||
|
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import net.pravian.aero.command.CommandReflection;
|
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandMap;
|
import org.bukkit.command.CommandMap;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.plugin.SimplePluginManager;
|
||||||
|
|
||||||
public class CommandBlocker extends FreedomService
|
public class CommandBlocker extends FreedomService
|
||||||
{
|
{
|
||||||
@ -29,34 +30,43 @@ public class CommandBlocker extends FreedomService
|
|||||||
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
private final Map<String, CommandBlockerEntry> entryList = Maps.newHashMap();
|
||||||
private final List<String> unknownCommands = Lists.newArrayList();
|
private final List<String> unknownCommands = Lists.newArrayList();
|
||||||
|
|
||||||
public CommandBlocker(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
load();
|
load();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
entryList.clear();
|
entryList.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static CommandMap getCommandMap()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
SimplePluginManager simplePluginManager = (SimplePluginManager) Bukkit.getServer().getPluginManager();
|
||||||
|
|
||||||
|
Field commandMapField = SimplePluginManager.class.getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
|
||||||
|
SimpleCommandMap simpleCommandMap = (SimpleCommandMap) commandMapField.get(simplePluginManager);
|
||||||
|
return simpleCommandMap;
|
||||||
|
}
|
||||||
|
catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e)
|
||||||
|
{
|
||||||
|
FLog.severe("Failed to get command map field (" + e.getMessage() + ")");
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
public void load()
|
public void load()
|
||||||
{
|
{
|
||||||
entryList.clear();
|
entryList.clear();
|
||||||
unknownCommands.clear();
|
unknownCommands.clear();
|
||||||
|
|
||||||
final CommandMap commandMap = CommandReflection.getCommandMap();
|
final CommandMap commandMap = getCommandMap();
|
||||||
if (commandMap == null)
|
|
||||||
{
|
|
||||||
FLog.severe("Error loading commandMap.");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("unchecked")
|
@SuppressWarnings("unchecked")
|
||||||
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
List<String> blockedCommands = (List<String>)ConfigEntry.BLOCKED_COMMANDS.getList();
|
||||||
@ -106,9 +116,9 @@ public class CommandBlocker extends FreedomService
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
|
||||||
entryList.put(blockedCommandEntry.getCommand(), blockedCommandEntry);
|
|
||||||
|
|
||||||
|
final CommandBlockerEntry blockedCommandEntry = new CommandBlockerEntry(rank, action, commandName, subCommand, message);
|
||||||
|
entryList.put(commandName, blockedCommandEntry);
|
||||||
if (command != null)
|
if (command != null)
|
||||||
{
|
{
|
||||||
for (String alias : command.getAliases())
|
for (String alias : command.getAliases())
|
||||||
@ -130,12 +140,6 @@ public class CommandBlocker extends FreedomService
|
|||||||
// CommandBlocker handles messages and broadcasts
|
// CommandBlocker handles messages and broadcasts
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event.getMessage().contains("translation.test.invalid") || event.getMessage().contains("translation.test.invalid2"))
|
|
||||||
{
|
|
||||||
event.setCancelled(true);
|
|
||||||
FUtil.playerMsg(event.getPlayer(), ChatColor.RED + "No crishy crashy faggy");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCommandBlocked(String command, CommandSender sender)
|
public boolean isCommandBlocked(String command, CommandSender sender)
|
||||||
@ -167,7 +171,7 @@ public class CommandBlocker extends FreedomService
|
|||||||
|
|
||||||
for (String part : commandParts)
|
for (String part : commandParts)
|
||||||
{
|
{
|
||||||
if (command.startsWith("/") && !plugin.al.isAdmin(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
if (command.startsWith("/") && !plugin.sl.isStaff(sender) && (part.contains("#copy") || part.contains("#clipboard")))
|
||||||
{
|
{
|
||||||
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
FUtil.playerMsg(sender, "WorldEdit copy variables are disabled.");
|
||||||
return true;
|
return true;
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
package me.totalfreedom.totalfreedommod.blocking.command;
|
package me.totalfreedom.totalfreedommod.blocking.command;
|
||||||
|
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
||||||
import me.totalfreedom.totalfreedommod.admin.Admin;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -40,10 +40,10 @@ public enum CommandBlockerRank
|
|||||||
return TELNET;
|
return TELNET;
|
||||||
}
|
}
|
||||||
|
|
||||||
Admin admin = TotalFreedomMod.plugin().al.getAdmin(sender);
|
StaffMember staffMember = TotalFreedomMod.plugin().sl.getAdmin(sender);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
if (admin.getRank() == Rank.SENIOR_ADMIN)
|
if (staffMember.getRank() == Rank.SENIOR_ADMIN)
|
||||||
{
|
{
|
||||||
return SENIOR;
|
return SENIOR;
|
||||||
}
|
}
|
||||||
|
@ -10,9 +10,8 @@ import me.totalfreedom.bukkittelnet.api.TelnetPreLoginEvent;
|
|||||||
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
import me.totalfreedom.bukkittelnet.api.TelnetRequestDataTagsEvent;
|
||||||
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
import me.totalfreedom.bukkittelnet.session.ClientSession;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
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.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.staff.StaffMember;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -24,18 +23,13 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
|
|
||||||
private BukkitTelnet bukkitTelnetPlugin = null;
|
private BukkitTelnet bukkitTelnetPlugin = null;
|
||||||
|
|
||||||
public BukkitTelnetBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -49,15 +43,15 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
final Admin admin = plugin.al.getEntryByIpFuzzy(ip);
|
final StaffMember staffMember = plugin.sl.getEntryByIpFuzzy(ip);
|
||||||
|
|
||||||
if (admin == null || !admin.isActive() || !admin.getRank().hasConsoleVariant())
|
if (staffMember == null || !staffMember.isActive() || !staffMember.getRank().hasConsoleVariant())
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setBypassPassword(true);
|
event.setBypassPassword(true);
|
||||||
event.setName(admin.getName());
|
event.setName(staffMember.getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.NORMAL)
|
@EventHandler(priority = EventPriority.NORMAL)
|
||||||
@ -83,14 +77,14 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
boolean isTelnetAdmin = false;
|
boolean isTelnetAdmin = false;
|
||||||
boolean isSeniorAdmin = false;
|
boolean isSeniorAdmin = false;
|
||||||
|
|
||||||
final Admin admin = plugin.al.getAdmin(player);
|
final StaffMember staffMember = plugin.sl.getAdmin(player);
|
||||||
if (admin != null)
|
if (staffMember != null)
|
||||||
{
|
{
|
||||||
boolean active = admin.isActive();
|
boolean active = staffMember.isActive();
|
||||||
|
|
||||||
isAdmin = active;
|
isAdmin = active;
|
||||||
isSeniorAdmin = active && admin.getRank() == Rank.SENIOR_ADMIN;
|
isSeniorAdmin = active && staffMember.getRank() == Rank.SENIOR_ADMIN;
|
||||||
isTelnetAdmin = active && (isSeniorAdmin || admin.getRank() == Rank.TELNET_ADMIN);
|
isTelnetAdmin = active && (isSeniorAdmin || staffMember.getRank() == Rank.ADMIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
playerTags.put("tfm.admin.isAdmin", isAdmin);
|
||||||
@ -127,6 +121,24 @@ public class BukkitTelnetBridge extends FreedomService
|
|||||||
return bukkitTelnetPlugin;
|
return bukkitTelnetPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public List<StaffMember> getConnectedAdmins()
|
||||||
|
{
|
||||||
|
List<StaffMember> staffMembers = new ArrayList<>();
|
||||||
|
final BukkitTelnet telnet = getBukkitTelnetPlugin();
|
||||||
|
if (telnet != null)
|
||||||
|
{
|
||||||
|
for (ClientSession session : telnet.appender.getSessions())
|
||||||
|
{
|
||||||
|
StaffMember staffMember = plugin.sl.getEntryByName(session.getUserName().toLowerCase());
|
||||||
|
if (staffMember != null && !staffMembers.contains(staffMember))
|
||||||
|
{
|
||||||
|
staffMembers.add(staffMember);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return staffMembers;
|
||||||
|
}
|
||||||
|
|
||||||
public void killTelnetSessions(final String name)
|
public void killTelnetSessions(final String name)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
|
@ -7,9 +7,9 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Statement;
|
import java.sql.Statement;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
import me.totalfreedom.totalfreedommod.config.ConfigEntry;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import net.coreprotect.CoreProtect;
|
import net.coreprotect.CoreProtect;
|
||||||
@ -28,18 +28,13 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
|
|
||||||
private BukkitTask wiper;
|
private BukkitTask wiper;
|
||||||
|
|
||||||
public CoreProtectBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -109,7 +104,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
coreProtect.performRollback(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
coreProtect.performRollback(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
@ -129,7 +124,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
@Override
|
@Override
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
coreProtect.performRestore(86400, Arrays.asList(name), null, null, null, null, 0, null);
|
coreProtect.performRestore(86400, Collections.singletonList(name), null, null, null, null, 0, null);
|
||||||
}
|
}
|
||||||
}.runTaskAsynchronously(plugin);
|
}.runTaskAsynchronously(plugin);
|
||||||
}
|
}
|
||||||
@ -183,7 +178,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
String password = ConfigEntry.COREPROTECT_MYSQL_PASSWORD.getString();
|
||||||
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
String database = ConfigEntry.COREPROTECT_MYSQL_DATABASE.getString();
|
||||||
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
String url = host + ":" + port + "/" + database + "?user=" + username + "&password=" + password + "&useSSL=false";
|
||||||
connection = DriverManager.getConnection("jdbc:mysql://" + url);
|
connection = DriverManager.getConnection("jdbc:sql://" + url);
|
||||||
final Statement statement = connection.createStatement();
|
final Statement statement = connection.createStatement();
|
||||||
statement.setQueryTimeout(30);
|
statement.setQueryTimeout(30);
|
||||||
|
|
||||||
@ -196,6 +191,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Ensure the world ID is not null
|
// Ensure the world ID is not null
|
||||||
|
|
||||||
if (worldID == null)
|
if (worldID == null)
|
||||||
{
|
{
|
||||||
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
FLog.warning("Failed to obtain the world ID for the " + world.getName());
|
||||||
@ -219,14 +215,7 @@ public class CoreProtectBridge extends FreedomService
|
|||||||
// This exits for flatlands wipes
|
// This exits for flatlands wipes
|
||||||
if (shutdown)
|
if (shutdown)
|
||||||
{
|
{
|
||||||
if (plugin.amp.enabled)
|
server.shutdown();
|
||||||
{
|
|
||||||
plugin.amp.restartServer();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
server.shutdown();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -3,7 +3,6 @@ package me.totalfreedom.totalfreedommod.bridge;
|
|||||||
import com.earth2me.essentials.Essentials;
|
import com.earth2me.essentials.Essentials;
|
||||||
import com.earth2me.essentials.User;
|
import com.earth2me.essentials.User;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
@ -26,18 +25,13 @@ public class EssentialsBridge extends FreedomService
|
|||||||
|
|
||||||
private Essentials essentialsPlugin = null;
|
private Essentials essentialsPlugin = null;
|
||||||
|
|
||||||
public EssentialsBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,176 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import com.google.gson.Gson;
|
||||||
|
import com.sk89q.worldedit.EditSession;
|
||||||
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
|
import com.sk89q.worldedit.math.BlockVector3;
|
||||||
|
import com.sk89q.worldedit.regions.Region;
|
||||||
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
|
import java.util.AbstractMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import net.coreprotect.CoreProtect;
|
||||||
|
import net.coreprotect.CoreProtectAPI;
|
||||||
|
import org.bukkit.Location;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.block.BlockState;
|
||||||
|
import org.bukkit.block.data.BlockData;
|
||||||
|
|
||||||
|
public class FAWEBridge extends FreedomService
|
||||||
|
{
|
||||||
|
private final CoreProtectAPI api = plugin.cpb.getCoreProtectAPI();;
|
||||||
|
private World world = null;
|
||||||
|
private final Map<Map.Entry<String, EditSession>, Map<BlockVector3, String>> blocksBroken = new HashMap<>();
|
||||||
|
private final Map<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> blocksPlaced = new HashMap<>();
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
/*
|
||||||
|
* Iterates over blocks placed by GenerationCommands (in the EditSession) and adds them to the CoreProtect logs.
|
||||||
|
*/
|
||||||
|
server.getScheduler().scheduleSyncRepeatingTask(plugin, () ->
|
||||||
|
{
|
||||||
|
if (!(blocksBroken.isEmpty() && blocksPlaced.isEmpty()))
|
||||||
|
{
|
||||||
|
// Send all broken blocks from the last ticks to the CoreProtect API.
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = null;
|
||||||
|
for (Map.Entry<Map.Entry<String, EditSession>, Map<BlockVector3, String>> entry : blocksBroken.entrySet())
|
||||||
|
{
|
||||||
|
playerAndSessionEntry = entry.getKey();
|
||||||
|
Map<BlockVector3, String> dataAndVectorEntry = entry.getValue();
|
||||||
|
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||||
|
blockVector3List.addAll(dataAndVectorEntry.keySet()); // Deep clone the block vector to avoid a change later in the code.
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : blockVector3List)
|
||||||
|
{
|
||||||
|
if (blockVector3 != null)
|
||||||
|
{
|
||||||
|
EditSession editSession = playerAndSessionEntry.getValue();
|
||||||
|
World world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||||
|
BlockData blockData = server.createBlockData(dataAndVectorEntry.get(blockVector3));
|
||||||
|
api.logRemoval(playerAndSessionEntry.getKey(), location, blockData.getMaterial(), blockData);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Clear after broken blocks have been updated.
|
||||||
|
blocksBroken.values().clear();
|
||||||
|
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||||
|
|
||||||
|
// Send all blocks placed to the CoreProtect API (except from the air as it's only a broken block).
|
||||||
|
for (Map.Entry<Map.Entry<String, EditSession>, Map.Entry<Pattern, List<BlockVector3>>> entry : blocksPlaced.entrySet())
|
||||||
|
{
|
||||||
|
playerAndSessionEntry = entry.getKey();
|
||||||
|
Map.Entry<Pattern, List<BlockVector3>> patternAndListEntry = entry.getValue();
|
||||||
|
Pattern pattern = patternAndListEntry.getKey();
|
||||||
|
List<BlockVector3> blockVector3List = new ArrayList<>();
|
||||||
|
blockVector3List.addAll(patternAndListEntry.getValue()); // Deep clone the block vector to avoid a change later in the code.
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : blockVector3List)
|
||||||
|
{
|
||||||
|
if (blockVector3 != null && !pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
World world = server.getWorld(playerAndSessionEntry.getValue().getWorld().getName());
|
||||||
|
Location location = new Location(world, blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
|
||||||
|
BaseBlock block = pattern.apply(blockVector3);
|
||||||
|
Material material = Material.getMaterial(block.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||||
|
api.logPlacement(playerAndSessionEntry.getKey(), location, material, material.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
blocksPlaced.values().forEach(collection -> collection.getValue().clear());
|
||||||
|
}
|
||||||
|
}, 0L, 40L);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, BlockVector3 blockVector3)
|
||||||
|
{
|
||||||
|
// Cache the world used for the next iterations to come.
|
||||||
|
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||||
|
{
|
||||||
|
world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||||
|
Block block = world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
|
||||||
|
|
||||||
|
// Add the broken block to CoreProtect if it's not air.
|
||||||
|
if (!block.getType().isAir())
|
||||||
|
{
|
||||||
|
String blockData = block.getBlockData().getAsString();
|
||||||
|
blockData = new Gson().fromJson(new Gson().toJson(blockData), blockData.getClass()); // Overwrite original with deep clones.
|
||||||
|
blockVector3 = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass()); // Overwrite original with deep clones.
|
||||||
|
blocksBroken.putIfAbsent(playerAndSessionEntry, new HashMap<>());
|
||||||
|
blocksBroken.get(playerAndSessionEntry).put(blockVector3, blockData);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the placed block to CoreProtect if it's not air.
|
||||||
|
if (!pattern.apply(blockVector3).getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
blocksPlaced.putIfAbsent(playerAndSessionEntry, new AbstractMap.SimpleEntry<>(pattern, new ArrayList<>()));
|
||||||
|
BlockVector3 vectorClone = new Gson().fromJson(new Gson().toJson(blockVector3), blockVector3.getClass());
|
||||||
|
|
||||||
|
if (!blocksPlaced.get(playerAndSessionEntry).getValue().contains(vectorClone))
|
||||||
|
{
|
||||||
|
blocksPlaced.get(playerAndSessionEntry).getValue().add(vectorClone);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockEdits(String playerName, EditSession editSession, Region region, Pattern pattern)
|
||||||
|
{
|
||||||
|
// Add the broken blocks to CoreProtect.
|
||||||
|
if (world == null || !world.getName().equals(editSession.getWorld().getName()))
|
||||||
|
{
|
||||||
|
world = server.getWorld(editSession.getWorld().getName());
|
||||||
|
}
|
||||||
|
List<BlockState> blocks = new ArrayList<>();
|
||||||
|
|
||||||
|
for (BlockVector3 blockVector3 : region)
|
||||||
|
{
|
||||||
|
blocks.add(world.getBlockAt(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()).getState());
|
||||||
|
}
|
||||||
|
|
||||||
|
logBlockEdit(playerName, editSession, pattern, blocks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void logBlockEdit(String playerName, EditSession editSession, Pattern pattern, List<BlockState> blocks)
|
||||||
|
{
|
||||||
|
Map.Entry<String, EditSession> playerAndSessionEntry = new AbstractMap.SimpleEntry(playerName, editSession);
|
||||||
|
|
||||||
|
server.getScheduler().scheduleAsyncDelayedTask(plugin, () ->
|
||||||
|
{
|
||||||
|
for (BlockState block : blocks)
|
||||||
|
{
|
||||||
|
BlockVector3 blockVector3 = BlockVector3.at(block.getX(), block.getY(), block.getZ());
|
||||||
|
|
||||||
|
// Add the broken block to CoreProtect if it's not air.
|
||||||
|
if (!block.getType().isAir())
|
||||||
|
{
|
||||||
|
api.logRemoval(playerAndSessionEntry.getKey(), block.getLocation(), block.getType(), block.getBlockData());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Add the placed block to CoreProtect if it's not air.
|
||||||
|
BaseBlock baseBlock = pattern.apply(blockVector3);
|
||||||
|
if (!baseBlock.getBlockType().getMaterial().isAir())
|
||||||
|
{
|
||||||
|
Material material = Material.getMaterial(baseBlock.getBlockType().getId().replaceFirst("minecraft:", "").toUpperCase());
|
||||||
|
api.logPlacement(playerAndSessionEntry.getKey(), block.getLocation(), material, material.createBlockData());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 0L);
|
||||||
|
}
|
||||||
|
}
|
@ -1,31 +1,24 @@
|
|||||||
package me.totalfreedom.totalfreedommod.bridge;
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.BlockedDisguises;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.LibsDisguises;
|
import me.libraryaddict.disguise.LibsDisguises;
|
||||||
import me.totalfreedom.libsdisguises.BlockedDisguises;
|
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class LibsDisguisesBridge extends FreedomService
|
public class LibsDisguisesBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
private LibsDisguises libsDisguisesPlugin = null;
|
private LibsDisguises libsDisguisesPlugin = null;
|
||||||
|
|
||||||
public LibsDisguisesBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -53,24 +46,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
return libsDisguisesPlugin;
|
return libsDisguisesPlugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isDisguised(Player player)
|
public void undisguiseAll(boolean staff)
|
||||||
{
|
|
||||||
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
|
try
|
||||||
{
|
{
|
||||||
@ -85,7 +61,7 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
if (DisguiseAPI.isDisguised(player))
|
if (DisguiseAPI.isDisguised(player))
|
||||||
{
|
{
|
||||||
if (!admins && plugin.al.isAdmin(player))
|
if (!staff && plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -120,6 +96,6 @@ public class LibsDisguisesBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
final LibsDisguises libsDisguises = getLibsDisguisesPlugin();
|
||||||
|
|
||||||
return libsDisguises != null && libsDisguises.isEnabled();
|
return libsDisguises != null;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.bridge;
|
||||||
|
|
||||||
|
import me.totalfreedom.tfguilds.Common;
|
||||||
|
import me.totalfreedom.tfguilds.TFGuilds;
|
||||||
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class TFGuildsBridge extends FreedomService
|
||||||
|
{
|
||||||
|
|
||||||
|
public boolean enabled = false;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStart()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onStop()
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isTFGuildsEnabled()
|
||||||
|
{
|
||||||
|
if (enabled)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
try
|
||||||
|
{
|
||||||
|
final Plugin tfGuilds = server.getPluginManager().getPlugin("TFGuilds");
|
||||||
|
if (tfGuilds != null && tfGuilds.isEnabled())
|
||||||
|
{
|
||||||
|
if (tfGuilds instanceof TFGuilds)
|
||||||
|
{
|
||||||
|
enabled = true;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (NoClassDefFoundError ex)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean inGuildChat(Player player)
|
||||||
|
{
|
||||||
|
if (!isTFGuildsEnabled())
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return Common.IN_GUILD_CHAT.contains(player);
|
||||||
|
}
|
||||||
|
}
|
@ -4,7 +4,6 @@ import com.sk89q.worldedit.LocalSession;
|
|||||||
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
import com.sk89q.worldedit.bukkit.BukkitPlayer;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
@ -15,18 +14,13 @@ public class WorldEditBridge extends FreedomService
|
|||||||
//
|
//
|
||||||
private WorldEditPlugin worldeditPlugin = null;
|
private WorldEditPlugin worldeditPlugin = null;
|
||||||
|
|
||||||
public WorldEditBridge(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,7 +60,7 @@ public class WorldEditBridge extends FreedomService
|
|||||||
{
|
{
|
||||||
for (int i = 0; i < count; i++)
|
for (int i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
com.sk89q.worldedit.entity.Player fuckyou = (com.sk89q.worldedit.entity.Player)bukkitPlayer;
|
com.sk89q.worldedit.entity.Player fuckyou = bukkitPlayer;
|
||||||
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
session.undo(session.getBlockBag(fuckyou), fuckyou);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,25 +7,20 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
|||||||
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
import com.sk89q.worldguard.protection.regions.RegionContainer;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
public class WorldGuardBridge extends FreedomService
|
public class WorldGuardBridge extends FreedomService
|
||||||
{
|
{
|
||||||
|
@Override
|
||||||
public WorldGuardBridge(TotalFreedomMod plugin)
|
public void onStart()
|
||||||
{
|
{
|
||||||
super(plugin);
|
plugin.wr.protectWorld(plugin.wm.hubworld.getWorld());
|
||||||
|
plugin.wr.protectWorld(plugin.wm.masterBuilderWorld.getWorld());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStop()
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected void onStop()
|
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package me.totalfreedom.totalfreedommod.caging;
|
package me.totalfreedom.totalfreedommod.caging;
|
||||||
|
|
||||||
|
import io.papermc.lib.PaperLib;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
import me.totalfreedom.totalfreedommod.player.FPlayer;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
@ -17,19 +17,13 @@ import org.bukkit.event.player.PlayerQuitEvent;
|
|||||||
|
|
||||||
public class Cager extends FreedomService
|
public class Cager extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
public Cager(TotalFreedomMod plugin)
|
|
||||||
{
|
|
||||||
super(plugin);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public void onStart()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -38,7 +32,7 @@ public class Cager extends FreedomService
|
|||||||
{
|
{
|
||||||
Player player = event.getPlayer();
|
Player player = event.getPlayer();
|
||||||
if (player == null
|
if (player == null
|
||||||
|| plugin.al.isAdmin(player))
|
|| plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -78,7 +72,7 @@ public class Cager extends FreedomService
|
|||||||
|
|
||||||
if (outOfCage)
|
if (outOfCage)
|
||||||
{
|
{
|
||||||
player.getPlayer().teleport(cageLoc.subtract(0, 0.1, 0));
|
PaperLib.teleportAsync(player.getPlayer(), cageLoc.subtract(0, 0.1, 0));
|
||||||
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
FUtil.playerMsg(player.getPlayer(), "You may not leave your cage.", ChatColor.RED);
|
||||||
cage.regenerate();
|
cage.regenerate();
|
||||||
}
|
}
|
||||||
|
@ -1,45 +1,78 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import me.totalfreedom.totalfreedommod.FreedomService;
|
import me.totalfreedom.totalfreedommod.FreedomService;
|
||||||
import me.totalfreedom.totalfreedommod.TotalFreedomMod;
|
|
||||||
import me.totalfreedom.totalfreedommod.util.FLog;
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
import net.pravian.aero.command.handler.SimpleCommandHandler;
|
import org.reflections.Reflections;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
|
|
||||||
public class CommandLoader extends FreedomService
|
public class CommandLoader extends FreedomService
|
||||||
{
|
{
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private final SimpleCommandHandler<TotalFreedomMod> handler;
|
private final List<FreedomCommand> commands;
|
||||||
|
|
||||||
public CommandLoader(TotalFreedomMod plugin)
|
public CommandLoader()
|
||||||
{
|
{
|
||||||
super(plugin);
|
commands = new ArrayList<>();
|
||||||
|
|
||||||
handler = new SimpleCommandHandler<>(plugin);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStart()
|
public 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(plugin.getDescription().getName(), true);
|
|
||||||
|
|
||||||
FLog.info("Loaded " + handler.getExecutors().size() + " commands.");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onStop()
|
public void onStop()
|
||||||
{
|
{
|
||||||
handler.clearCommands();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void add(FreedomCommand command)
|
||||||
|
{
|
||||||
|
commands.add(command);
|
||||||
|
command.register();
|
||||||
|
}
|
||||||
|
|
||||||
|
public FreedomCommand getByName(String name)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (name.equals(command.getName()))
|
||||||
|
return command;
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAlias(String alias)
|
||||||
|
{
|
||||||
|
for (FreedomCommand command : commands)
|
||||||
|
{
|
||||||
|
if (Arrays.asList(command.getAliases().split(",")).contains(alias))
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void loadCommands()
|
||||||
|
{
|
||||||
|
Reflections commandDir = new Reflections("me.totalfreedom.totalfreedommod.command");
|
||||||
|
|
||||||
|
Set<Class<? extends FreedomCommand>> commandClasses = commandDir.getSubTypesOf(FreedomCommand.class);
|
||||||
|
|
||||||
|
for (Class<? extends FreedomCommand> commandClass : commandClasses)
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
add(commandClass.newInstance());
|
||||||
|
}
|
||||||
|
catch (InstantiationException | IllegalAccessException | ExceptionInInitializerError ex)
|
||||||
|
{
|
||||||
|
FLog.warning("Failed to register command: /" + commandClass.getSimpleName().replace("Command_" , ""));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
FLog.info("Loaded " + commands.size() + " commands");
|
||||||
|
}
|
||||||
}
|
}
|
@ -8,9 +8,9 @@ import me.totalfreedom.totalfreedommod.rank.Rank;
|
|||||||
public @interface CommandPermissions
|
public @interface CommandPermissions
|
||||||
{
|
{
|
||||||
|
|
||||||
Rank level();
|
Rank level() default Rank.NON_OP;
|
||||||
|
|
||||||
SourceType source();
|
SourceType source() default SourceType.BOTH;
|
||||||
|
|
||||||
boolean blockHostConsole() default false;
|
boolean blockHostConsole() default false;
|
||||||
|
|
||||||
|
@ -1,295 +0,0 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
|
||||||
import me.totalfreedom.totalfreedommod.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 = "Allows for admins to configure guests, time, and weather of the AdminWorld, and allows for admins and guests to go to the AdminWorld.",
|
|
||||||
usage = "/<command> [guest < list | purge | add <player> | remove <player> > | time <morning | noon | evening | night> | weather <off | rain | storm>]",
|
|
||||||
aliases = "aw")
|
|
||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
|
||||||
{
|
|
||||||
if (!plugin.al.isAdmin(sender))
|
|
||||||
{
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
if (args.length == 1)
|
|
||||||
{
|
|
||||||
return Arrays.asList("guest", "time", "weather");
|
|
||||||
}
|
|
||||||
else if (args.length == 2)
|
|
||||||
{
|
|
||||||
if (args[0].equals("guest"))
|
|
||||||
{
|
|
||||||
return Arrays.asList("add", "remove", "list", "purge");
|
|
||||||
}
|
|
||||||
else if (args[0].equals("time"))
|
|
||||||
{
|
|
||||||
return Arrays.asList("morning", "noon", "evening", "night");
|
|
||||||
}
|
|
||||||
else if (args[0].equals("weather"))
|
|
||||||
{
|
|
||||||
return Arrays.asList("off", "rain", "storm");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (args.length == 3)
|
|
||||||
{
|
|
||||||
if (args[0].equals("guest"))
|
|
||||||
{
|
|
||||||
if (args[1].equals("add"))
|
|
||||||
{
|
|
||||||
return FUtil.getPlayerList();
|
|
||||||
}
|
|
||||||
else if (args[1].equals("remove"))
|
|
||||||
{
|
|
||||||
return plugin.wm.adminworld.getGuestList();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Collections.emptyList();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -28,7 +28,7 @@ public class Command_adventure extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
checkRank(Rank.SUPER_ADMIN);
|
checkRank(Rank.ADMIN);
|
||||||
|
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
@ -37,7 +37,7 @@ public class Command_adventure extends FreedomCommand
|
|||||||
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
targetPlayer.setGameMode(GameMode.ADVENTURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
FUtil.staffAction(sender.getName(), "Changing everyone's gamemode to adventure", false);
|
||||||
msg("Your gamemode has been set to adventure.");
|
msg("Your gamemode has been set to adventure.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.bukkit.entity.AreaEffectCloud;
|
|||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
@CommandParameters(description = "Clears lingering potion area effect clouds.", usage = "/<command>", aliases = "aec")
|
||||||
public class Command_aeclear extends FreedomCommand
|
public class Command_aeclear extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -17,7 +17,7 @@ public class Command_aeclear extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Removing all area effect clouds.", true);
|
FUtil.staffAction(sender.getName(), "Removing all area effect clouds.", true);
|
||||||
int removed = 0;
|
int removed = 0;
|
||||||
for (World world : server.getWorlds())
|
for (World world : server.getWorlds())
|
||||||
{
|
{
|
||||||
|
@ -6,13 +6,13 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
@CommandParameters(description = "Make an announcement anonymously to operators.", usage = "/<command> <message>")
|
||||||
public class Command_announce extends FreedomCommand
|
public class Command_announce extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player has their inventory automatically cleared when they join", usage = "/<command> <player>")
|
||||||
public class Command_autoclear extends FreedomCommand
|
public class Command_autoclear extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -5,7 +5,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
@CommandParameters(description = "Toggle whether or not a player is automatically teleported when they join", usage = "/<command> <player>")
|
||||||
public class Command_autotp extends FreedomCommand
|
public class Command_autotp extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
@ -8,8 +8,6 @@ import me.totalfreedom.totalfreedommod.punishments.Punishment;
|
|||||||
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
import me.totalfreedom.totalfreedommod.punishments.PunishmentType;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import static me.totalfreedom.totalfreedommod.util.FUtil.playerMsg;
|
|
||||||
import net.pravian.aero.util.Ips;
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
import org.apache.commons.lang.StringUtils;
|
import org.apache.commons.lang.StringUtils;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -19,14 +17,11 @@ import org.bukkit.Location;
|
|||||||
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.scheduler.BukkitRunnable;
|
|
||||||
import org.bukkit.util.Vector;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb]", aliases = "ban")
|
@CommandParameters(description = "Bans the specified player.", usage = "/<command> <username> [reason] [-nrb | -q]", aliases = "gtfo")
|
||||||
public class Command_gtfo extends FreedomCommand
|
public class Command_ban extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
@ -35,6 +30,34 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
Boolean silent = false;
|
||||||
|
Boolean cancelRollback = false;
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb") || args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
||||||
|
{
|
||||||
|
cancelRollback = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.length >= 3)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
final String username;
|
final String username;
|
||||||
final List<String> ips = new ArrayList<>();
|
final List<String> ips = new ArrayList<>();
|
||||||
|
|
||||||
@ -49,15 +72,15 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
username = entry.getUsername();
|
username = entry.getName();
|
||||||
ips.addAll(entry.getIps());
|
ips.addAll(entry.getIps());
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
final PlayerData entry = plugin.pl.getData(player);
|
final PlayerData entry = plugin.pl.getData(player);
|
||||||
username = player.getName();
|
username = player.getName();
|
||||||
//ips.addAll(entry.getIps());
|
//ips.addAll(entry.getIps());/
|
||||||
ips.add(Ips.getIp(player));
|
ips.add(FUtil.getIp(player));
|
||||||
|
|
||||||
// Deop
|
// Deop
|
||||||
player.setOp(false);
|
player.setOp(false);
|
||||||
@ -68,122 +91,79 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
// Clear inventory
|
// Clear inventory
|
||||||
player.getInventory().clear();
|
player.getInventory().clear();
|
||||||
|
|
||||||
// Strike with lightning
|
if (!silent)
|
||||||
final Location targetPos = player.getLocation();
|
|
||||||
for (int x = -1; x <= 1; x++)
|
|
||||||
{
|
{
|
||||||
for (int z = -1; z <= 1; z++)
|
// Strike with lightning
|
||||||
|
final Location targetPos = player.getLocation();
|
||||||
|
for (int x = -1; x <= 1; x++)
|
||||||
{
|
{
|
||||||
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
for (int z = -1; z <= 1; z++)
|
||||||
targetPos.getWorld().strikeLightning(strike_pos);
|
{
|
||||||
}
|
final Location strike_pos = new Location(targetPos.getWorld(), targetPos.getBlockX() + x, targetPos.getBlockY(), targetPos.getBlockZ() + z);
|
||||||
}
|
targetPos.getWorld().strikeLightning(strike_pos);
|
||||||
|
}
|
||||||
// Kill player
|
|
||||||
player.setHealth(0.0);
|
|
||||||
}
|
|
||||||
|
|
||||||
String reason = null;
|
|
||||||
Boolean cancelRollback = false;
|
|
||||||
Boolean epicFail = false;
|
|
||||||
if (args.length >= 2)
|
|
||||||
{
|
|
||||||
if (args[args.length - 1].equalsIgnoreCase("-nrb"))
|
|
||||||
{
|
|
||||||
cancelRollback = true;
|
|
||||||
if (args.length >= 3)
|
|
||||||
{
|
|
||||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (args[args.length - 1].equalsIgnoreCase("-ef"))
|
|
||||||
{
|
|
||||||
epicFail = true;
|
|
||||||
if (args.length >= 3)
|
|
||||||
{
|
|
||||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
msg("Banned " + player.getName() + " quietly.");
|
||||||
}
|
}
|
||||||
|
// Kill player
|
||||||
|
player.setHealth(0.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
// Checks if CoreProtect is loaded and installed, and skips the rollback and uses CoreProtect directly
|
||||||
if (!cancelRollback)
|
if (!cancelRollback)
|
||||||
{
|
{
|
||||||
if (!plugin.cpb.isEnabled())
|
plugin.cpb.rollback(username);
|
||||||
{
|
|
||||||
// Undo WorldEdits
|
|
||||||
try
|
|
||||||
{
|
|
||||||
plugin.web.undo(player, 15);
|
|
||||||
}
|
|
||||||
catch (NoClassDefFoundError | NullPointerException ex)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// Rollback
|
|
||||||
plugin.rb.rollback(username);
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
plugin.cpb.rollback(username);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (epicFail)
|
if (player != null && !silent)
|
||||||
{
|
|
||||||
for (int i = 0; i < 25; i++)
|
|
||||||
{
|
|
||||||
player.setVelocity(player.getVelocity().clone().add(new Vector(0, 50, 0)));
|
|
||||||
new BukkitRunnable()
|
|
||||||
{
|
|
||||||
public void run()
|
|
||||||
{
|
|
||||||
for (int i = 0; i < 8; i++)
|
|
||||||
{
|
|
||||||
player.getWorld().strikeLightning(player.getLocation());
|
|
||||||
//FUtil.
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}.runTaskLater(plugin, 2L * 20L);
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (player != null)
|
|
||||||
{
|
{
|
||||||
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
FUtil.bcastMsg(player.getName() + " has been a VERY naughty, naughty boy.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ban player
|
// Ban player
|
||||||
Ban ban = Ban.forPlayerName(username, sender, null, reason);
|
Ban ban;
|
||||||
|
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayer(player, sender, null, reason);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
ban = Ban.forPlayerName(username, sender, null, reason);
|
||||||
|
}
|
||||||
|
|
||||||
for (String ip : ips)
|
for (String ip : ips)
|
||||||
{
|
{
|
||||||
ban.addIp(ip);
|
ban.addIp(ip);
|
||||||
|
ban.addIp(FUtil.getFuzzyIp(ip));
|
||||||
}
|
}
|
||||||
plugin.bm.addBan(ban);
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
// Broadcast
|
|
||||||
final StringBuilder bcast = new StringBuilder()
|
if (!silent)
|
||||||
.append("Banning: ")
|
|
||||||
.append(username);
|
|
||||||
if (reason != null)
|
|
||||||
{
|
{
|
||||||
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
// Broadcast
|
||||||
|
final StringBuilder bcast = new StringBuilder()
|
||||||
|
.append("Banning: ")
|
||||||
|
.append(username);
|
||||||
|
if (reason != null)
|
||||||
|
{
|
||||||
|
bcast.append(" - Reason: ").append(ChatColor.YELLOW).append(reason);
|
||||||
|
}
|
||||||
|
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
||||||
|
FUtil.staffAction(sender.getName(), String.format(bcast.toString()), true);
|
||||||
}
|
}
|
||||||
msg(sender, ChatColor.GRAY + username + " has been banned and IP is: " + StringUtils.join(ips, ", "));
|
|
||||||
FUtil.adminAction(sender.getName(), String.format(bcast.toString()), true);
|
|
||||||
|
|
||||||
// Kick player and handle others on IP
|
// Kick player and handle others on IP
|
||||||
if (player != null)
|
if (player != null)
|
||||||
{
|
{
|
||||||
player.kickPlayer(ban.bakeKickMessage(Ips.getIp(player)));
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
for (Player p : Bukkit.getOnlinePlayers())
|
for (Player p : Bukkit.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (Ips.getIp(p).equals(Ips.getIp(player)))
|
if (FUtil.getIp(p).equals(FUtil.getIp(player)))
|
||||||
{
|
{
|
||||||
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
p.kickPlayer(ChatColor.RED + "You've been kicked because someone on your IP has been banned.");
|
||||||
}
|
}
|
||||||
@ -195,4 +175,4 @@ public class Command_gtfo extends FreedomCommand
|
|||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,82 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FLog;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified ip.", usage = "/<command> <ip> [reason] [-q]")
|
||||||
|
public class Command_banip extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean silent = false;
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
|
||||||
|
String ip = args[0];
|
||||||
|
|
||||||
|
if (!FUtil.isValidIPv4(ip))
|
||||||
|
{
|
||||||
|
msg(ip + " is not a valid IP address", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (plugin.bm.getByIp(ip) != null)
|
||||||
|
{
|
||||||
|
msg("The IP " + ip + " is already banned", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerIp(ip, sender, null, reason);
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
// Kick player and handle others on IP
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
|
{
|
||||||
|
if (FUtil.getIp(player).equals(ip))
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
// Broadcast
|
||||||
|
FLog.info(ChatColor.RED + sender.getName() + " - Banned the IP " + ip);
|
||||||
|
String message = ChatColor.RED + sender.getName() + " - Banned " + (plugin.sl.isStaff(player) ? "the IP " + ip : "an IP");
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Shows all banned player names. Senior Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
@CommandParameters(description = "Shows all banned player names. Admins may optionally use 'purge' to clear the list.", usage = "/<command> [purge]")
|
||||||
public class Command_banlist extends FreedomCommand
|
public class Command_banlist extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -20,21 +20,17 @@ public class Command_banlist extends FreedomCommand
|
|||||||
{
|
{
|
||||||
checkRank(Rank.SENIOR_ADMIN);
|
checkRank(Rank.SENIOR_ADMIN);
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Purging the ban list", true);
|
FUtil.staffAction(sender.getName(), "Purging the ban list", true);
|
||||||
int amount = plugin.bm.purge();
|
int amount = plugin.bm.purge();
|
||||||
msg("Purged " + amount + " player bans.");
|
msg("Purged " + amount + " player bans.");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
msg(plugin.bm.getAllBans().size() + " player bans ("
|
msg(plugin.bm.getAllBans().size() + " player bans ("
|
||||||
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
+ plugin.bm.getUsernameBans().size() + " usernames, "
|
||||||
+ plugin.bm.getIpBans().size() + " IPs)");
|
+ plugin.bm.getIpBans().size() + " IPs)");
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -0,0 +1,68 @@
|
|||||||
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
|
import me.totalfreedom.totalfreedommod.banning.Ban;
|
||||||
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
|
import org.apache.commons.lang.ArrayUtils;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH, blockHostConsole = true)
|
||||||
|
@CommandParameters(description = "Bans the specified name.", usage = "/<command> <name> [reason] [-q]")
|
||||||
|
public class Command_banname extends FreedomCommand
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
|
{
|
||||||
|
if (args.length == 0)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
boolean silent = false;
|
||||||
|
|
||||||
|
String reason = null;
|
||||||
|
|
||||||
|
String name = args[0];;
|
||||||
|
|
||||||
|
if (plugin.bm.getByUsername(name) != null)
|
||||||
|
{
|
||||||
|
msg("The name " + name + " is already banned", ChatColor.RED);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args[args.length - 1].equalsIgnoreCase("-q"))
|
||||||
|
{
|
||||||
|
silent = true;
|
||||||
|
|
||||||
|
if (args.length >= 2)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length - 1), " ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (args.length > 1)
|
||||||
|
{
|
||||||
|
reason = StringUtils.join(ArrayUtils.subarray(args, 1, args.length), " ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Ban player
|
||||||
|
Ban ban = Ban.forPlayerName(name, sender, null, reason);
|
||||||
|
plugin.bm.addBan(ban);
|
||||||
|
|
||||||
|
if (!silent)
|
||||||
|
{
|
||||||
|
FUtil.staffAction(sender.getName(), "Banned the name " + name, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = getPlayer(name);
|
||||||
|
if (player != null)
|
||||||
|
{
|
||||||
|
player.kickPlayer(ban.bakeKickMessage());
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -2,13 +2,13 @@ package me.totalfreedom.totalfreedommod.command;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
@CommandPermissions(level = Rank.OP, source = SourceType.ONLY_IN_GAME)
|
||||||
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
@CommandParameters(description = "Spawns a random type of fish at your location.", usage = "/<command>")
|
||||||
|
@ -8,7 +8,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
@CommandParameters(description = "Block all commands for everyone on the server, or a specific player.", usage = "/<command> <-a | purge | <player>>", aliases = "blockcommands,blockcommand,bc,bcmd")
|
||||||
public class Command_blockcmd extends FreedomCommand
|
public class Command_blockcmd extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -23,7 +23,7 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking commands for all players", true);
|
FUtil.staffAction(sender.getName(), "Unblocking commands for all players", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -40,18 +40,18 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("-a"))
|
if (args[0].equals("-a"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Blocking commands for all non-admins", true);
|
FUtil.staffAction(sender.getName(), "Blocking commands for all non-staff", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (isAdmin(player))
|
if (isStaff(player))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
counter += 1;
|
counter += 1;
|
||||||
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
plugin.pl.getPlayer(player).setCommandsBlocked(true);
|
||||||
msg(player, "Your commands have been blocked by an admin.", ChatColor.RED);
|
msg(player, "Your commands have been blocked by a staff member.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg("Blocked commands for " + counter + " players.");
|
msg("Blocked commands for " + counter + " players.");
|
||||||
@ -66,19 +66,23 @@ public class Command_blockcmd extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isAdmin(player))
|
if (isStaff(player))
|
||||||
{
|
{
|
||||||
msg(player.getName() + " is an admin, and cannot have their commands blocked.");
|
msg(player.getName() + " is a staff member, and cannot have their commands blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FPlayer playerdata = plugin.pl.getPlayer(player);
|
FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
|
if (!playerdata.allCommandsBlocked())
|
||||||
playerdata.setCommandsBlocked(!playerdata.allCommandsBlocked());
|
{
|
||||||
|
playerdata.setCommandsBlocked(true);
|
||||||
FUtil.adminAction(sender.getName(), (playerdata.allCommandsBlocked() ? "B" : "Unb") + "locking all commands for " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Blocking all commands for " + player.getName(), true);
|
||||||
msg((playerdata.allCommandsBlocked() ? "B" : "Unb") + "locked all commands.");
|
msg("Blocked commands for " + player.getName() + ".");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
msg("That players commands are already blocked.", ChatColor.RED);
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
@CommandParameters(description = "Restricts/unrestricts block modification abilities for everyone on the server or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]")
|
||||||
public class Command_blockedit extends FreedomCommand
|
public class Command_blockedit extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for all players.", true);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -63,11 +63,11 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for all non-admins.", true);
|
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for all non-staff.", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (final Player player : this.server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin((CommandSender)player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
playerdata.setEditBlocked(true);
|
playerdata.setEditBlocked(true);
|
||||||
@ -82,7 +82,7 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
final boolean smite = args[0].equals("-s");
|
final boolean smite = args[0].equals("-s");
|
||||||
if (smite)
|
if (smite)
|
||||||
{
|
{
|
||||||
args = (String[])ArrayUtils.subarray((Object[])args, 1, args.length);
|
args = (String[])ArrayUtils.subarray(args, 1, args.length);
|
||||||
if (args.length < 1)
|
if (args.length < 1)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
@ -99,26 +99,26 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
String reason = null;
|
String reason = null;
|
||||||
if (args.length > 1)
|
if (args.length > 1)
|
||||||
{
|
{
|
||||||
reason = StringUtils.join((Object[])args, " ", 1, args.length);
|
reason = StringUtils.join(args, " ", 1, args.length);
|
||||||
}
|
}
|
||||||
|
|
||||||
final FPlayer pd = plugin.pl.getPlayer(player2);
|
final FPlayer pd = plugin.pl.getPlayer(player2);
|
||||||
if (pd.isEditBlocked())
|
if (pd.isEditBlocked())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
FUtil.staffAction(sender.getName(), "Unblocking block modification abilities for " + player2.getName(), true);
|
||||||
pd.setEditBlocked(false);
|
pd.setEditBlocked(false);
|
||||||
msg("Unblocking block modification abilities for " + player2.getName());
|
msg("Unblocking block modification abilities for " + player2.getName());
|
||||||
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
msg(player2, "Your block modification abilities have been restored.", ChatColor.RED);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin((CommandSender)player2))
|
if (plugin.sl.isStaff(player2))
|
||||||
{
|
{
|
||||||
msg(player2.getName() + " is an admin, and cannot have their block edits blocked.");
|
msg(player2.getName() + " is a staff member, and cannot have their block edits blocked.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
FUtil.staffAction(sender.getName(), "Blocking block modification abilities for " + player2.getName(), true);
|
||||||
pd.setEditBlocked(true);
|
pd.setEditBlocked(true);
|
||||||
|
|
||||||
if (smite)
|
if (smite)
|
||||||
@ -131,4 +131,4 @@ public class Command_blockedit extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -10,7 +10,7 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
@CommandParameters(description = "Toggle PVP mode for everyone or a certain player.", usage = "/<command> [[-s] <player> [reason] | list | purge | all]", aliases = "pvpblock,pvpmode")
|
||||||
public class Command_blockpvp extends FreedomCommand
|
public class Command_blockpvp extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -46,7 +46,7 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("purge"))
|
if (args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Enabling PVP for all players.", true);
|
FUtil.staffAction(sender.getName(), "Enabling PVP for all players.", true);
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
@ -64,11 +64,11 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
|
|
||||||
if (args[0].equals("all"))
|
if (args[0].equals("all"))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Disabling PVP for all non-admins", true);
|
FUtil.staffAction(sender.getName(), "Disabling PVP for all non-staff", true);
|
||||||
int counter = 0;
|
int counter = 0;
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(player))
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
final FPlayer playerdata = plugin.pl.getPlayer(player);
|
||||||
playerdata.setPvpBlocked(true);
|
playerdata.setPvpBlocked(true);
|
||||||
@ -106,20 +106,20 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
final FPlayer pd = plugin.pl.getPlayer(p);
|
final FPlayer pd = plugin.pl.getPlayer(p);
|
||||||
if (pd.isPvpBlocked())
|
if (pd.isPvpBlocked())
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
FUtil.staffAction(sender.getName(), "Enabling PVP for " + p.getName(), true);
|
||||||
pd.setPvpBlocked(false);
|
pd.setPvpBlocked(false);
|
||||||
msg("Enabling PVP for " + p.getName());
|
msg("Enabling PVP for " + p.getName());
|
||||||
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
msg(p, "Your PVP have been enabled.", ChatColor.GREEN);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (plugin.al.isAdmin(p))
|
if (plugin.sl.isStaff(p))
|
||||||
{
|
{
|
||||||
msg(p.getName() + " is an admin, and cannot have their PVP disabled.");
|
msg(p.getName() + " is a staff member, and cannot have their PVP disabled.");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
FUtil.adminAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
FUtil.staffAction(sender.getName(), "Disabling PVP for " + p.getName(), true);
|
||||||
pd.setPvpBlocked(true);
|
pd.setPvpBlocked(true);
|
||||||
if (smite)
|
if (smite)
|
||||||
{
|
{
|
||||||
@ -131,4 +131,4 @@ public class Command_blockpvp extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -8,7 +8,7 @@ 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 = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
@CommandParameters(description = "Blocks redstone on the server.", usage = "/<command>", aliases = "bre")
|
||||||
public class Command_blockredstone extends FreedomCommand
|
public class Command_blockredstone extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -18,14 +18,14 @@ public class Command_blockredstone extends FreedomCommand
|
|||||||
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
{
|
{
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(false);
|
||||||
FUtil.adminAction(sender.getName(), "Blocking all redstone", true);
|
FUtil.staffAction(sender.getName(), "Blocking all redstone", true);
|
||||||
new BukkitRunnable()
|
new BukkitRunnable()
|
||||||
{
|
{
|
||||||
public void run()
|
public void run()
|
||||||
{
|
{
|
||||||
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
if (!ConfigEntry.ALLOW_REDSTONE.getBoolean())
|
||||||
{
|
{
|
||||||
FUtil.adminAction("TotalFreedom", "Unblocking all redstone", false);
|
FUtil.staffAction("TotalFreedom", "Unblocking all redstone", false);
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -34,7 +34,7 @@ public class Command_blockredstone extends FreedomCommand
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
ConfigEntry.ALLOW_REDSTONE.setBoolean(true);
|
||||||
FUtil.adminAction(sender.getName(), "Unblocking all redstone", true);
|
FUtil.staffAction(sender.getName(), "Unblocking all redstone", true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -15,8 +15,8 @@ import org.bukkit.command.Command;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | off | <partialname> [head | block] [playername | blockname]")
|
@CommandParameters(description = "Place a cage around someone with certain blocks, or someone's player head.", usage = "/<command> <purge | <partialname> [head | block] [playername | blockname]")
|
||||||
public class Command_cage extends FreedomCommand
|
public class Command_cage extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@ -26,17 +26,11 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
String skullName = null;
|
String skullName = null;
|
||||||
if ("off".equals(args[0]) && sender instanceof Player)
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + sender.getName(), true);
|
|
||||||
final FPlayer playerdata = plugin.pl.getPlayer(playerSender);
|
|
||||||
playerdata.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
if ("purge".equals(args[0]))
|
if ("purge".equals(args[0]))
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging all players", true);
|
FUtil.staffAction(sender.getName(), "Uncaging all players", true);
|
||||||
for (Player player : server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
@ -44,13 +38,21 @@ public class Command_cage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
Player player = getPlayer(args[0]);
|
Player player = getPlayer(args[0]);
|
||||||
if (player == null)
|
if (player == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
final FPlayer fPlayer = plugin.pl.getPlayer(player);
|
||||||
|
if (fPlayer.getCageData().isCaged())
|
||||||
|
{
|
||||||
|
sender.sendMessage(ChatColor.RED + "That player is already caged.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
Material outerMaterial = Material.GLASS;
|
Material outerMaterial = Material.GLASS;
|
||||||
Material innerMaterial = Material.AIR;
|
Material innerMaterial = Material.AIR;
|
||||||
if (args.length >= 2 && args[1] != null)
|
if (args.length >= 2 && args[1] != null)
|
||||||
@ -58,12 +60,6 @@ public class Command_cage extends FreedomCommand
|
|||||||
final String s = args[1];
|
final String s = args[1];
|
||||||
switch (s)
|
switch (s)
|
||||||
{
|
{
|
||||||
case "off":
|
|
||||||
{
|
|
||||||
FUtil.adminAction(sender.getName(), "Uncaging " + player.getName(), true);
|
|
||||||
fPlayer.getCageData().setCaged(false);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
case "head":
|
case "head":
|
||||||
{
|
{
|
||||||
outerMaterial = Material.PLAYER_HEAD;
|
outerMaterial = Material.PLAYER_HEAD;
|
||||||
@ -91,6 +87,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
}
|
}
|
||||||
|
|
||||||
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
Location location = player.getLocation().clone().add(0.0, 1.0, 0.0);
|
||||||
|
|
||||||
if (skullName != null)
|
if (skullName != null)
|
||||||
{
|
{
|
||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial, skullName);
|
||||||
@ -99,14 +96,16 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
fPlayer.getCageData().cage(location, outerMaterial, innerMaterial);
|
||||||
}
|
}
|
||||||
|
|
||||||
player.setGameMode(GameMode.SURVIVAL);
|
player.setGameMode(GameMode.SURVIVAL);
|
||||||
|
|
||||||
if (outerMaterial == Material.PLAYER_HEAD)
|
if (outerMaterial == Material.PLAYER_HEAD)
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
FUtil.staffAction(sender.getName(), "Caging " + player.getName() + " in " + skullName, true);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
FUtil.adminAction(sender.getName(), "Caging " + player.getName(), true);
|
FUtil.staffAction(sender.getName(), "Caging " + player.getName(), true);
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -114,7 +113,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
@Override
|
@Override
|
||||||
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
public List<String> getTabCompleteOptions(CommandSender sender, Command command, String alias, String[] args)
|
||||||
{
|
{
|
||||||
if (!plugin.al.isAdmin(sender))
|
if (!plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -130,7 +129,7 @@ public class Command_cage extends FreedomCommand
|
|||||||
{
|
{
|
||||||
if (!args[0].equals("purge"))
|
if (!args[0].equals("purge"))
|
||||||
{
|
{
|
||||||
return Arrays.asList("off", "head", "block");
|
return Arrays.asList("head", "block");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (args.length == 3)
|
else if (args.length == 3)
|
||||||
|
@ -10,7 +10,7 @@ import org.bukkit.entity.Player;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.inventory.meta.ItemMeta;
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.SUPER_ADMIN, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
@CommandParameters(description = "For the people that are still alive - gives a cake to everyone on the server.", usage = "/<command>")
|
||||||
public class Command_cake extends FreedomCommand
|
public class Command_cake extends FreedomCommand
|
||||||
{
|
{
|
||||||
@ -32,7 +32,7 @@ public class Command_cake extends FreedomCommand
|
|||||||
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
heldItemMeta.setDisplayName(ChatColor.WHITE + "The " + ChatColor.DARK_GRAY + "Lie");
|
||||||
heldItem.setItemMeta(heldItemMeta);
|
heldItem.setItemMeta(heldItemMeta);
|
||||||
|
|
||||||
for (final Player player : this.server.getOnlinePlayers())
|
for (Player player : server.getOnlinePlayers())
|
||||||
{
|
{
|
||||||
final int firstEmpty = player.getInventory().firstEmpty();
|
final int firstEmpty = player.getInventory().firstEmpty();
|
||||||
if (firstEmpty >= 0)
|
if (firstEmpty >= 0)
|
||||||
@ -44,4 +44,4 @@ public class Command_cake extends FreedomCommand
|
|||||||
FUtil.bcastMsg(output.toString());
|
FUtil.bcastMsg(output.toString());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -16,12 +16,12 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
{
|
{
|
||||||
Player targetPlayer = playerSender;
|
Player targetPlayer = playerSender;
|
||||||
|
|
||||||
if (args.length == 1)
|
if (args.length == 1 && plugin.sl.isStaff(sender))
|
||||||
{
|
{
|
||||||
|
|
||||||
targetPlayer = getPlayer(args[0]);
|
targetPlayer = getPlayer(args[0]);
|
||||||
|
|
||||||
if (targetPlayer == null || plugin.al.vanished.contains(targetPlayer) && !plugin.al.isAdmin(sender))
|
if (targetPlayer == null)
|
||||||
{
|
{
|
||||||
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
sender.sendMessage(FreedomCommand.PLAYER_NOT_FOUND);
|
||||||
return true;
|
return true;
|
||||||
@ -36,11 +36,6 @@ public class Command_cartsit extends FreedomCommand
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (targetPlayer != playerSender && !isAdmin(sender))
|
|
||||||
{
|
|
||||||
sender.sendMessage("Only admins can select another player as a /cartsit target.");
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (targetPlayer.isInsideVehicle())
|
if (targetPlayer.isInsideVehicle())
|
||||||
{
|
{
|
||||||
|
@ -1,218 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -1,71 +1,30 @@
|
|||||||
package me.totalfreedom.totalfreedommod.command;
|
package me.totalfreedom.totalfreedommod.command;
|
||||||
|
|
||||||
import java.util.stream.IntStream;
|
|
||||||
import me.totalfreedom.totalfreedommod.masterbuilder.MasterBuilder;
|
|
||||||
import me.totalfreedom.totalfreedommod.playerverification.VPlayer;
|
|
||||||
import me.totalfreedom.totalfreedommod.rank.Rank;
|
import me.totalfreedom.totalfreedommod.rank.Rank;
|
||||||
import me.totalfreedom.totalfreedommod.util.FUtil;
|
import me.totalfreedom.totalfreedommod.util.FUtil;
|
||||||
import org.bukkit.ChatColor;
|
|
||||||
import org.bukkit.command.Command;
|
import org.bukkit.command.Command;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@CommandPermissions(level = Rank.OP, source = SourceType.BOTH)
|
@CommandPermissions(level = Rank.ADMIN, source = SourceType.BOTH)
|
||||||
@CommandParameters(description = "Clears the chat for players who are not opt-out.", usage = "/<command>", aliases = "cc")
|
@CommandParameters(description = "Clears the chat.", usage = "/<command>", aliases = "cc")
|
||||||
public class Command_clearchat extends FreedomCommand
|
public class Command_clearchat extends FreedomCommand
|
||||||
{
|
{
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
public boolean run(CommandSender sender, Player playerSender, Command cmd, String commandLabel, String[] args, boolean senderIsConsole)
|
||||||
{
|
{
|
||||||
|
for (Player player : server.getOnlinePlayers())
|
||||||
if (plugin.al.isAdmin(playerSender))
|
|
||||||
{
|
{
|
||||||
for (Player player : server.getOnlinePlayers())
|
if (!plugin.sl.isStaff(player))
|
||||||
{
|
{
|
||||||
boolean optedOut = false;
|
for (int i = 0; i < 100; i++)
|
||||||
|
|
||||||
if (plugin.al.isAdmin(player))
|
|
||||||
{
|
{
|
||||||
optedOut = true;
|
player.sendMessage("");
|
||||||
}
|
|
||||||
else if (plugin.mbl.isMasterBuilder(player) && plugin.mbl.getMasterBuilder(player).isClearChatOptOut())
|
|
||||||
{
|
|
||||||
optedOut = true;
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(player).getEnabled() && plugin.pv.getVerificationPlayer(player).isClearChatOptOut())
|
|
||||||
{
|
|
||||||
optedOut = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!optedOut)
|
|
||||||
{
|
|
||||||
IntStream.range(0, 100).mapToObj(i -> "").forEach(player::sendMessage);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
FUtil.adminAction(sender.getName(), "Cleared chat", true);
|
|
||||||
}
|
}
|
||||||
else if (plugin.mbl.isMasterBuilder(playerSender))
|
FUtil.staffAction(sender.getName(), "Cleared chat", true);
|
||||||
{
|
|
||||||
MasterBuilder mb = plugin.mbl.getMasterBuilder(playerSender);
|
|
||||||
mb.setClearChatOptOut(!mb.isClearChatOptOut());
|
|
||||||
msg((mb.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
|
||||||
plugin.mbl.save();
|
|
||||||
plugin.mbl.updateTables();
|
|
||||||
}
|
|
||||||
else if (plugin.pv.getVerificationPlayer(playerSender).getEnabled())
|
|
||||||
{
|
|
||||||
VPlayer vp = plugin.pv.getVerificationPlayer(playerSender);
|
|
||||||
vp.setClearChatOptOut(!vp.isClearChatOptOut());
|
|
||||||
msg((vp.isClearChatOptOut() ? "Opted-out of" : "Opted-in to") + " clear chat.");
|
|
||||||
plugin.pv.saveVerificationData(vp);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
msg("Only Master Builders, admins, and players with verification enabled can opt-out of clear chat.", ChatColor.RED);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user