I am so great you can suck my nut
This commit is contained in:
parent
af061743cc
commit
caf3b848e0
13
.idea/codeStyleSettings.xml
Normal file
13
.idea/codeStyleSettings.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectCodeStyleSettingsManager">
|
||||||
|
<option name="PER_PROJECT_SETTINGS">
|
||||||
|
<value>
|
||||||
|
<codeStyleSettings language="JAVA">
|
||||||
|
<option name="WRAP_LONG_LINES" value="true" />
|
||||||
|
</codeStyleSettings>
|
||||||
|
</value>
|
||||||
|
</option>
|
||||||
|
<option name="PREFERRED_PROJECT_CODE_STYLE" value="Default copy" />
|
||||||
|
</component>
|
||||||
|
</project>
|
16
.idea/compiler.xml
Normal file
16
.idea/compiler.xml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="Nucleus" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="Nucleus" target="1.8" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
10
.idea/dictionaries/skruf.xml
Normal file
10
.idea/dictionaries/skruf.xml
Normal file
@ -0,0 +1,10 @@
|
|||||||
|
<component name="ProjectDictionaryState">
|
||||||
|
<dictionary name="skruf">
|
||||||
|
<words>
|
||||||
|
<w>chainable</w>
|
||||||
|
<w>minecraft</w>
|
||||||
|
<w>mongo</w>
|
||||||
|
<w>scorebaord</w>
|
||||||
|
</words>
|
||||||
|
</dictionary>
|
||||||
|
</component>
|
6
.idea/encodings.xml
Normal file
6
.idea/encodings.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
13
.idea/libraries/Maven__cglib_cglib_nodep_3_2_5.xml
Normal file
13
.idea/libraries/Maven__cglib_cglib_nodep_3_2_5.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: cglib:cglib-nodep:3.2.5">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.2.5/cglib-nodep-3.2.5.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.2.5/cglib-nodep-3.2.5-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/cglib/cglib-nodep/3.2.5/cglib-nodep-3.2.5-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/executors/BukkitExecutors/1.1-SNAPSHOT/BukkitExecutors-1.1-20170429.151522-2.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/executors/BukkitExecutors/1.1-SNAPSHOT/BukkitExecutors-1.1-20170429.151522-2-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/executors/BukkitExecutors/1.1-SNAPSHOT/BukkitExecutors-1.1-20170429.151522-2-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: com.comphenix.protocol:ProtocolLib-API:4.3.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.3.0/ProtocolLib-API-4.3.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.3.0/ProtocolLib-API-4.3.0-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.3.0/ProtocolLib-API-4.3.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
Normal file
13
.idea/libraries/Maven__com_google_code_gson_gson_2_8_5.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: com.google.code.gson:gson:2.8.5">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.5/gson-2.8.5.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.5/gson-2.8.5-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/code/gson/gson/2.8.5/gson-2.8.5-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__com_google_guava_guava_17_0.xml
Normal file
13
.idea/libraries/Maven__com_google_guava_guava_17_0.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: com.google.guava:guava:17.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/17.0/guava-17.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/17.0/guava-17.0-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/17.0/guava-17.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: com.googlecode.json-simple:json-simple:1.1.1">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/com/googlecode/json-simple/json-simple/1.1.1/json-simple-1.1.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__commons_codec_commons_codec_1_10.xml
Normal file
13
.idea/libraries/Maven__commons_codec_commons_codec_1_10.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: commons-codec:commons-codec:1.10">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.10/commons-codec-1.10.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.10/commons-codec-1.10-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-codec/commons-codec/1.10/commons-codec-1.10-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__commons_io_commons_io_2_5.xml
Normal file
13
.idea/libraries/Maven__commons_io_commons_io_2_5.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: commons-io:commons-io:2.5">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-io/commons-io/2.5/commons-io-2.5-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
Normal file
13
.idea/libraries/Maven__commons_lang_commons_lang_2_6.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: commons-lang:commons-lang:2.6">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-lang/commons-lang/2.6/commons-lang-2.6-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: commons-logging:commons-logging:1.2">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/commons-logging/commons-logging/1.2/commons-logging-1.2-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: javax.persistence:persistence-api:1.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/javax/persistence/persistence-api/1.0/persistence-api-1.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/javax/persistence/persistence-api/1.0/persistence-api-1.0-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/javax/persistence/persistence-api/1.0/persistence-api-1.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__junit_junit_4_10.xml
Normal file
13
.idea/libraries/Maven__junit_junit_4_10.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: junit:junit:4.10">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/junit/junit/4.10/junit-4.10-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: net.md-5:bungeecord-chat:1.8-SNAPSHOT">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-20160221.214602-128.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-20160221.214602-128-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/net/md-5/bungeecord-chat/1.8-SNAPSHOT/bungeecord-chat-1.8-20160221.214602-128-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.apache.commons:commons-lang3:3.7">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-lang3/3.7/commons-lang3-3.7-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.apache.commons:commons-pool2:2.4.2">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.2/commons-pool2-2.4.2-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.apache.httpcomponents:httpclient:4.5.6">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.6/httpclient-4.5.6.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.6/httpclient-4.5.6-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpclient/4.5.6/httpclient-4.5.6-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.apache.httpcomponents:httpcore:4.4.10">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.10/httpcore-4.4.10.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.10/httpcore-4.4.10-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/apache/httpcomponents/httpcore/4.4.10/httpcore-4.4.10-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__org_avaje_ebean_2_8_1.xml
Normal file
13
.idea/libraries/Maven__org_avaje_ebean_2_8_1.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.avaje:ebean:2.8.1">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/avaje/ebean/2.8.1/ebean-2.8.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/avaje/ebean/2.8.1/ebean-2.8.1-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/avaje/ebean/2.8.1/ebean-2.8.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
Normal file
13
.idea/libraries/Maven__org_hamcrest_hamcrest_core_1_1.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.hamcrest:hamcrest-core:1.1">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/hamcrest/hamcrest-core/1.1/hamcrest-core-1.1-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.mongodb:mongo-java-driver:3.8.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.0/mongo-java-driver-3.8.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.0/mongo-java-driver-3.8.0-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.0/mongo-java-driver-3.8.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__org_projectlombok_lombok_1_16_16.xml
Normal file
13
.idea/libraries/Maven__org_projectlombok_lombok_1_16_16.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.projectlombok:lombok:1.16.16">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.16.16/lombok-1.16.16-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.spigotmc:spigot-api:1.8.8-R0.1-SNAPSHOT">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.8.8-R0.1-SNAPSHOT/spigot-api-1.8.8-R0.1-SNAPSHOT.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.8.8-R0.1-SNAPSHOT/spigot-api-1.8.8-R0.1-SNAPSHOT-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/spigotmc/spigot-api/1.8.8-R0.1-SNAPSHOT/spigot-api-1.8.8-R0.1-SNAPSHOT-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__org_yaml_snakeyaml_1_15.xml
Normal file
13
.idea/libraries/Maven__org_yaml_snakeyaml_1_15.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: org.yaml:snakeyaml:1.15">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.15/snakeyaml-1.15-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/libraries/Maven__redis_clients_jedis_2_9_0.xml
Normal file
13
.idea/libraries/Maven__redis_clients_jedis_2_9_0.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<component name="libraryTable">
|
||||||
|
<library name="Maven: redis.clients:jedis:2.9.0">
|
||||||
|
<CLASSES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/2.9.0/jedis-2.9.0.jar!/" />
|
||||||
|
</CLASSES>
|
||||||
|
<JAVADOC>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/2.9.0/jedis-2.9.0-javadoc.jar!/" />
|
||||||
|
</JAVADOC>
|
||||||
|
<SOURCES>
|
||||||
|
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/2.9.0/jedis-2.9.0-sources.jar!/" />
|
||||||
|
</SOURCES>
|
||||||
|
</library>
|
||||||
|
</component>
|
13
.idea/misc.xml
Normal file
13
.idea/misc.xml
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<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" project-jdk-name="1.8 (1)" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
8
.idea/modules.xml
Normal file
8
.idea/modules.xml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ProjectModuleManager">
|
||||||
|
<modules>
|
||||||
|
<module fileurl="file://$PROJECT_DIR$/Nucleus.iml" filepath="$PROJECT_DIR$/Nucleus.iml" />
|
||||||
|
</modules>
|
||||||
|
</component>
|
||||||
|
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
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
Normal file
6
.idea/vcs.xml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
1066
.idea/workspace.xml
Normal file
1066
.idea/workspace.xml
Normal file
File diff suppressed because it is too large
Load Diff
39
Nucleus.iml
Normal file
39
Nucleus.iml
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
|
||||||
|
<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.spigotmc:spigot-api:1.8.8-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:17.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.avaje:ebean:2.8.1" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: javax.persistence:persistence-api:1.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.15" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.8-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.16.16" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: redis.clients:jedis:2.9.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.commons:commons-lang3:3.7" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpclient:4.5.6" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.apache.httpcomponents:httpcore:4.4.10" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-logging:commons-logging:1.2" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-codec:commons-codec:1.10" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: commons-io:commons-io:2.5" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.8.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib-API:4.3.0" 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" />
|
||||||
|
</component>
|
||||||
|
</module>
|
123
pom.xml
Normal file
123
pom.xml
Normal file
@ -0,0 +1,123 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>me.joeleoli.nucleus</groupId>
|
||||||
|
<artifactId>nucleus</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<name>nucleus</name>
|
||||||
|
<description>A group of essential systems and libraries needed to power a spigot instance.</description>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>sk89q-repo</id>
|
||||||
|
<url>http://maven.sk89q.com/repo/</url>
|
||||||
|
</repository>
|
||||||
|
<repository>
|
||||||
|
<id>dmulloy2-repo</id>
|
||||||
|
<url>http://repo.dmulloy2.net/nexus/repository/public/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.8.8-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.projectlombok</groupId>
|
||||||
|
<artifactId>lombok</artifactId>
|
||||||
|
<version>1.16.16</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>redis.clients</groupId>
|
||||||
|
<artifactId>jedis</artifactId>
|
||||||
|
<version>2.9.0</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.code.gson</groupId>
|
||||||
|
<artifactId>gson</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.commons</groupId>
|
||||||
|
<artifactId>commons-lang3</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.apache.httpcomponents</groupId>
|
||||||
|
<artifactId>httpclient</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.5</version>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.mongodb</groupId>
|
||||||
|
<artifactId>mongo-java-driver</artifactId>
|
||||||
|
<version>LATEST</version>
|
||||||
|
<scope>compile</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.comphenix.protocol</groupId>
|
||||||
|
<artifactId>ProtocolLib-API</artifactId>
|
||||||
|
<version>4.3.0</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<defaultGoal>clean install</defaultGoal>
|
||||||
|
<resources>
|
||||||
|
<resource>
|
||||||
|
<directory>src/main/resources</directory>
|
||||||
|
<filtering>true</filtering>
|
||||||
|
</resource>
|
||||||
|
</resources>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<version>3.6.1</version>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.0.0</version>
|
||||||
|
|
||||||
|
<configuration>
|
||||||
|
<createDependencyReducedPom>false</createDependencyReducedPom>
|
||||||
|
<shadedArtifactAttached>false</shadedArtifactAttached>
|
||||||
|
</configuration>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
|
||||||
|
</project>
|
153
src/main/java/me/joeleoli/nucleus/Nucleus.java
Normal file
153
src/main/java/me/joeleoli/nucleus/Nucleus.java
Normal file
@ -0,0 +1,153 @@
|
|||||||
|
package me.joeleoli.nucleus;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import com.mongodb.client.MongoCursor;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.joeleoli.nucleus.board.BoardManager;
|
||||||
|
import me.joeleoli.nucleus.chat.ChatManager;
|
||||||
|
import me.joeleoli.nucleus.command.CommandHandler;
|
||||||
|
import me.joeleoli.nucleus.config.ConfigCursor;
|
||||||
|
import me.joeleoli.nucleus.config.FileConfig;
|
||||||
|
import me.joeleoli.nucleus.jedis.JedisSettings;
|
||||||
|
import me.joeleoli.nucleus.jedis.NucleusJedis;
|
||||||
|
import me.joeleoli.nucleus.listener.ListenerHandler;
|
||||||
|
import me.joeleoli.nucleus.mongo.NucleusMongo;
|
||||||
|
import me.joeleoli.nucleus.player.DefinedSetting;
|
||||||
|
import me.joeleoli.nucleus.settings.Settings;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.rave.Rave;
|
||||||
|
import me.joeleoli.nucleus.server.ServerType;
|
||||||
|
import me.joeleoli.nucleus.task.InsertLogsTask;
|
||||||
|
import me.joeleoli.nucleus.task.MenuUpdateTask;
|
||||||
|
import me.joeleoli.nucleus.task.ShutdownTask;
|
||||||
|
import me.joeleoli.nucleus.task.UpdateCacheTask;
|
||||||
|
import me.joeleoli.nucleus.util.ItemUtil;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import me.joeleoli.nucleus.util.TaskUtil;
|
||||||
|
import org.bson.Document;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Nucleus extends JavaPlugin {
|
||||||
|
|
||||||
|
public static final Random RANDOM = new Random();
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
private static Nucleus instance;
|
||||||
|
|
||||||
|
private FileConfig mainFileConfig;
|
||||||
|
|
||||||
|
private NucleusConfig nucleusConfig;
|
||||||
|
private NucleusMongo nucleusMongo;
|
||||||
|
private NucleusJedis nucleusJedis;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private ShutdownTask shutdownTask;
|
||||||
|
|
||||||
|
private ChatManager chatManager;
|
||||||
|
private BoardManager boardManager;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private Rave rave;
|
||||||
|
|
||||||
|
private boolean loaded;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
instance = this;
|
||||||
|
|
||||||
|
this.mainFileConfig = new FileConfig(this, "config.yml");
|
||||||
|
this.nucleusConfig = new NucleusConfig();
|
||||||
|
this.nucleusConfig.load();
|
||||||
|
|
||||||
|
final ConfigCursor cursor = new ConfigCursor(this.mainFileConfig, null);
|
||||||
|
|
||||||
|
final JedisSettings settings = new JedisSettings(
|
||||||
|
cursor.getString("redis.host"),
|
||||||
|
cursor.getInt("redis.port"),
|
||||||
|
cursor.getString("redis.password")
|
||||||
|
);
|
||||||
|
|
||||||
|
this.nucleusMongo = new NucleusMongo();
|
||||||
|
this.nucleusJedis = new NucleusJedis(settings);
|
||||||
|
|
||||||
|
this.chatManager = new ChatManager();
|
||||||
|
|
||||||
|
this.loadRanks();
|
||||||
|
|
||||||
|
Settings.register(DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES, true);
|
||||||
|
Settings.register(DefinedSetting.GlobalPlayerSetting.RECEIVE_GLOBAL_MESSAGES, true);
|
||||||
|
Settings.register(DefinedSetting.GlobalPlayerSetting.PLAY_MESSAGE_SOUNDS, true);
|
||||||
|
|
||||||
|
ItemUtil.load();
|
||||||
|
|
||||||
|
CommandHandler.init();
|
||||||
|
CommandHandler.loadCommandsFromPackage(this, "me.joeleoli.nucleus.command.commands");
|
||||||
|
ListenerHandler.loadListenersFromPackage(this, "me.joeleoli.nucleus.listener");
|
||||||
|
ListenerHandler.loadListenersFromPackage(this, "me.joeleoli.nucleus.menu");
|
||||||
|
|
||||||
|
this.getServer().getMessenger().registerOutgoingPluginChannel(this, "BungeeCord");
|
||||||
|
this.getServer().getScheduler().runTaskTimer(this, new InsertLogsTask(), 20L * 60L * 2L, 20L * 60L * 2L);
|
||||||
|
this.getServer().getScheduler().runTaskTimer(this, new UpdateCacheTask(), 0L, 20L * 60L * 2L);
|
||||||
|
this.getServer().getScheduler().runTaskTimer(this, new MenuUpdateTask(), 20L, 20L);
|
||||||
|
|
||||||
|
TaskUtil.runLater(() -> this.loaded = true, 60L);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void loadRanks() {
|
||||||
|
try (MongoCursor<Document> cursor = Nucleus.getInstance().getNucleusMongo().getRanks()) {
|
||||||
|
cursor.forEachRemaining(document -> {
|
||||||
|
List<String> permissions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (JsonElement element : new JsonParser().parse(document.getString("permissions")).getAsJsonArray()) {
|
||||||
|
permissions.add(element.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
Rank rank = new Rank(document.getString("name"));
|
||||||
|
|
||||||
|
rank.setPrefix(Style.translate(document.getString("prefix")));
|
||||||
|
rank.setColor(Style.translate(document.getString("color")));
|
||||||
|
rank.setGlobal(document.getBoolean("global"));
|
||||||
|
rank.setWeight(document.getInteger("weight"));
|
||||||
|
rank.setPermissions(permissions);
|
||||||
|
|
||||||
|
if (document.containsKey("inherits")) {
|
||||||
|
List<String> inherits = new ArrayList<>();
|
||||||
|
|
||||||
|
for (JsonElement element : new JsonParser().parse(document.getString("inherits"))
|
||||||
|
.getAsJsonArray()) {
|
||||||
|
inherits.add(element.getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
rank.setInherits(inherits);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!rank.isGlobal()) {
|
||||||
|
rank.setServerType(ServerType.valueOf(document.getString("server_type")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Rank.getDefaultRank() == null) {
|
||||||
|
Rank rank = new Rank("Default");
|
||||||
|
|
||||||
|
rank.setColor(Style.WHITE);
|
||||||
|
rank.setPrefix(Style.WHITE);
|
||||||
|
rank.setGlobal(true);
|
||||||
|
rank.setWeight(-1);
|
||||||
|
rank.setPermissions(new ArrayList<>());
|
||||||
|
rank.save();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBoardManager(BoardManager manager) {
|
||||||
|
this.boardManager = manager;
|
||||||
|
this.boardManager.runTaskTimerAsynchronously(this, manager.getAdapter().getInterval(), manager.getAdapter().getInterval());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
60
src/main/java/me/joeleoli/nucleus/NucleusAPI.java
Normal file
60
src/main/java/me/joeleoli/nucleus/NucleusAPI.java
Normal file
@ -0,0 +1,60 @@
|
|||||||
|
package me.joeleoli.nucleus;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.DefinedSetting;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class NucleusAPI {
|
||||||
|
|
||||||
|
public static String getColoredName(Player player) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
if (nucleusPlayer.getActiveRank() == null) {
|
||||||
|
return Style.RESET + player.getName();
|
||||||
|
} else {
|
||||||
|
if (player.hasPermission("nucleus.donor.color") && nucleusPlayer.getColor() != null) {
|
||||||
|
return Style.RESET + nucleusPlayer.getColor().getDisplay() + player.getName();
|
||||||
|
} else {
|
||||||
|
return Style.RESET + nucleusPlayer.getActiveRank().getColor() + player.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String getPrefixedName(Player player) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
if (nucleusPlayer.getActiveRank() == null) {
|
||||||
|
return Style.RESET + player.getName();
|
||||||
|
} else {
|
||||||
|
final String prefix = nucleusPlayer.getActiveRank().getPrefix();
|
||||||
|
String color = null;
|
||||||
|
String tag = null;
|
||||||
|
|
||||||
|
if (player.hasPermission("nucleus.donor.color") && nucleusPlayer.getColor() != null) {
|
||||||
|
color = nucleusPlayer.getColor().getDisplay();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (player.hasPermission("nucleus.donor.tag")) {
|
||||||
|
if (nucleusPlayer.getTag() != null) {
|
||||||
|
if (nucleusPlayer.getTagColor() != null) {
|
||||||
|
tag = Style.GRAY + "[" + nucleusPlayer.getTagColor().getDisplay() + nucleusPlayer.getTag().getDisplay() + Style.GRAY + "]";
|
||||||
|
} else {
|
||||||
|
tag = Style.GRAY + "[" + nucleusPlayer.getTag().getDisplay() + Style.GRAY + "]";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (tag == null ? "" : tag + " ") + prefix + (color == null ? "" : Style.BOLD + color) + player.getName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean isFrozen(Player player) {
|
||||||
|
return NucleusPlayer.getByUuid(player.getUniqueId()).isFrozen();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static <T> T getSetting(Player player, DefinedSetting definedSetting) {
|
||||||
|
return (T) NucleusPlayer.getByUuid(player.getUniqueId()).getSettings().get(definedSetting);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
25
src/main/java/me/joeleoli/nucleus/NucleusConfig.java
Normal file
25
src/main/java/me/joeleoli/nucleus/NucleusConfig.java
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
package me.joeleoli.nucleus;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.config.ConfigCursor;
|
||||||
|
import me.joeleoli.nucleus.server.ServerType;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class NucleusConfig {
|
||||||
|
|
||||||
|
private String serverId;
|
||||||
|
private ServerType serverType;
|
||||||
|
private String serverMotd;
|
||||||
|
|
||||||
|
public void load() {
|
||||||
|
ConfigCursor cursor = new ConfigCursor(Nucleus.getInstance().getMainFileConfig(), "server");
|
||||||
|
|
||||||
|
this.serverId = cursor.getString("id");
|
||||||
|
this.serverType = ServerType.valueOf(cursor.getString("type"));
|
||||||
|
this.serverMotd = Style.translate(cursor.getString("motd"));
|
||||||
|
|
||||||
|
cursor.setPath("settings");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
99
src/main/java/me/joeleoli/nucleus/board/Board.java
Normal file
99
src/main/java/me/joeleoli/nucleus/board/Board.java
Normal file
@ -0,0 +1,99 @@
|
|||||||
|
package me.joeleoli.nucleus.board;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class Board {
|
||||||
|
|
||||||
|
private final BoardAdapter adapter;
|
||||||
|
private final Player player;
|
||||||
|
private List<BoardEntry> entries = new ArrayList<>();
|
||||||
|
private Set<BoardTimer> timers = new HashSet<>();
|
||||||
|
private Set<String> keys = new HashSet<>();
|
||||||
|
private Scoreboard scoreboard;
|
||||||
|
private Objective objective;
|
||||||
|
|
||||||
|
public Board(JavaPlugin plugin, Player player, BoardAdapter adapter) {
|
||||||
|
this.adapter = adapter;
|
||||||
|
this.player = player;
|
||||||
|
|
||||||
|
this.init(plugin);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void init(JavaPlugin plugin) {
|
||||||
|
if (!this.player.getScoreboard().equals(plugin.getServer().getScoreboardManager().getMainScoreboard())) {
|
||||||
|
this.scoreboard = this.player.getScoreboard();
|
||||||
|
} else {
|
||||||
|
this.scoreboard = plugin.getServer().getScoreboardManager().getNewScoreboard();
|
||||||
|
}
|
||||||
|
|
||||||
|
this.objective = this.scoreboard.registerNewObjective("Default", "dummy");
|
||||||
|
|
||||||
|
this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
|
||||||
|
this.objective.setDisplayName(this.adapter.getTitle(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getNewKey(BoardEntry entry) {
|
||||||
|
for (ChatColor color : ChatColor.values()) {
|
||||||
|
String colorText = color + "" + ChatColor.WHITE;
|
||||||
|
|
||||||
|
if (entry.getText().length() > 16) {
|
||||||
|
String sub = entry.getText().substring(0, 16);
|
||||||
|
colorText = colorText + ChatColor.getLastColors(sub);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!keys.contains(colorText)) {
|
||||||
|
keys.add(colorText);
|
||||||
|
return colorText;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
throw new IndexOutOfBoundsException("No more keys available!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getBoardEntriesFormatted() {
|
||||||
|
List<String> toReturn = new ArrayList<>();
|
||||||
|
|
||||||
|
for (BoardEntry entry : new ArrayList<>(entries)) {
|
||||||
|
toReturn.add(entry.getText());
|
||||||
|
}
|
||||||
|
|
||||||
|
return toReturn;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardEntry getByPosition(int position) {
|
||||||
|
for (int i = 0; i < this.entries.size(); i++) {
|
||||||
|
if (i == position) {
|
||||||
|
return this.entries.get(i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardTimer getCooldown(String id) {
|
||||||
|
for (BoardTimer cooldown : getTimers()) {
|
||||||
|
if (cooldown.getId().equals(id)) {
|
||||||
|
return cooldown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<BoardTimer> getTimers() {
|
||||||
|
this.timers.removeIf(cooldown -> System.currentTimeMillis() >= cooldown.getEnd());
|
||||||
|
return this.timers;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
19
src/main/java/me/joeleoli/nucleus/board/BoardAdapter.java
Normal file
19
src/main/java/me/joeleoli/nucleus/board/BoardAdapter.java
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package me.joeleoli.nucleus.board;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
public interface BoardAdapter {
|
||||||
|
|
||||||
|
String getTitle(Player player);
|
||||||
|
|
||||||
|
List<String> getScoreboard(Player player, Board board);
|
||||||
|
|
||||||
|
long getInterval();
|
||||||
|
|
||||||
|
void onScoreboardCreate(Player player, Scoreboard board);
|
||||||
|
|
||||||
|
void preLoop();
|
||||||
|
|
||||||
|
}
|
102
src/main/java/me/joeleoli/nucleus/board/BoardEntry.java
Normal file
102
src/main/java/me/joeleoli/nucleus/board/BoardEntry.java
Normal file
@ -0,0 +1,102 @@
|
|||||||
|
package me.joeleoli.nucleus.board;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import lombok.experimental.Accessors;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
import org.bukkit.scoreboard.Team;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Accessors(chain = true)
|
||||||
|
public class BoardEntry {
|
||||||
|
|
||||||
|
private final Board board;
|
||||||
|
|
||||||
|
private final String originalText;
|
||||||
|
|
||||||
|
private Team team;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private String text;
|
||||||
|
private String key;
|
||||||
|
|
||||||
|
public BoardEntry(Board board, String text) {
|
||||||
|
this.board = board;
|
||||||
|
this.text = text;
|
||||||
|
this.originalText = text;
|
||||||
|
this.key = board.getNewKey(this);
|
||||||
|
|
||||||
|
this.setup();
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardEntry setup() {
|
||||||
|
Scoreboard scoreboard = this.board.getScoreboard();
|
||||||
|
|
||||||
|
String teamName = this.key;
|
||||||
|
if (teamName.length() > 16) {
|
||||||
|
teamName = teamName.substring(0, 16);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scoreboard.getTeam(teamName) != null) {
|
||||||
|
this.team = scoreboard.getTeam(teamName);
|
||||||
|
} else {
|
||||||
|
this.team = scoreboard.registerNewTeam(teamName);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(this.team.getEntries().contains(this.key))) {
|
||||||
|
this.team.addEntry(this.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(this.board.getEntries().contains(this))) {
|
||||||
|
this.board.getEntries().add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public BoardEntry send(int position) {
|
||||||
|
Objective objective = board.getObjective();
|
||||||
|
|
||||||
|
if (this.text.length() > 16) {
|
||||||
|
this.team.setPrefix(this.text.substring(0, 16));
|
||||||
|
|
||||||
|
boolean addOne = this.team.getPrefix().endsWith(ChatColor.COLOR_CHAR + "");
|
||||||
|
|
||||||
|
if (addOne) {
|
||||||
|
this.team.setPrefix(this.text.substring(0, 15));
|
||||||
|
}
|
||||||
|
|
||||||
|
String suffix = ChatColor.getLastColors(this.team.getPrefix())
|
||||||
|
+ this.text.substring(addOne ? 15 : 16, this.text.length());
|
||||||
|
|
||||||
|
if (suffix.length() > 16) {
|
||||||
|
if (suffix.length() - 2 <= 16) {
|
||||||
|
suffix = this.text.substring(addOne ? 15 : 16, this.text.length());
|
||||||
|
this.team.setSuffix(suffix.substring(0, suffix.length()));
|
||||||
|
} else {
|
||||||
|
this.team.setSuffix(suffix.substring(0, 16));
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
this.team.setSuffix(suffix);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
this.team.setSuffix("");
|
||||||
|
this.team.setPrefix(this.text);
|
||||||
|
}
|
||||||
|
|
||||||
|
Score score = objective.getScore(this.key);
|
||||||
|
score.setScore(position);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove() {
|
||||||
|
this.board.getKeys().remove(this.key);
|
||||||
|
this.board.getScoreboard().resetScores(this.key);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
129
src/main/java/me/joeleoli/nucleus/board/BoardManager.java
Normal file
129
src/main/java/me/joeleoli/nucleus/board/BoardManager.java
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package me.joeleoli.nucleus.board;
|
||||||
|
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.LinkedList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import org.bukkit.scoreboard.DisplaySlot;
|
||||||
|
import org.bukkit.scoreboard.Objective;
|
||||||
|
import org.bukkit.scoreboard.Score;
|
||||||
|
import org.bukkit.scoreboard.Scoreboard;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BoardManager extends BukkitRunnable {
|
||||||
|
|
||||||
|
private final JavaPlugin plugin;
|
||||||
|
private final Map<UUID, Board> playerBoards = new HashMap<>();
|
||||||
|
private final BoardAdapter adapter;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
this.adapter.preLoop();
|
||||||
|
|
||||||
|
for (Player player : plugin.getServer().getOnlinePlayers()) {
|
||||||
|
Board board = this.playerBoards.get(player.getUniqueId());
|
||||||
|
|
||||||
|
if (board == null) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
Scoreboard scoreboard = board.getScoreboard();
|
||||||
|
|
||||||
|
List<String> scores = this.adapter.getScoreboard(player, board);
|
||||||
|
|
||||||
|
if (scores != null) {
|
||||||
|
Collections.reverse(scores);
|
||||||
|
|
||||||
|
Objective objective = board.getObjective();
|
||||||
|
|
||||||
|
if (!objective.getDisplayName().equals(this.adapter.getTitle(player))) {
|
||||||
|
objective.setDisplayName(this.adapter.getTitle(player));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (scores.isEmpty()) {
|
||||||
|
Iterator<BoardEntry> iter = board.getEntries().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
BoardEntry boardEntry = iter.next();
|
||||||
|
boardEntry.remove();
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
forILoop:
|
||||||
|
for (int i = 0; i < scores.size(); i++) {
|
||||||
|
String text = scores.get(i);
|
||||||
|
int position = i + 1;
|
||||||
|
|
||||||
|
for (BoardEntry boardEntry : new LinkedList<>(board.getEntries())) {
|
||||||
|
Score score = objective.getScore(boardEntry.getKey());
|
||||||
|
|
||||||
|
if (score != null && boardEntry.getText().equals(text)) {
|
||||||
|
if (score.getScore() == position) {
|
||||||
|
continue forILoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Iterator<BoardEntry> iter = board.getEntries().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
BoardEntry boardEntry = iter.next();
|
||||||
|
int entryPosition = scoreboard.getObjective(DisplaySlot.SIDEBAR).getScore(boardEntry
|
||||||
|
.getKey()).getScore();
|
||||||
|
if (entryPosition > scores.size()) {
|
||||||
|
boardEntry.remove();
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int positionToSearch = position - 1;
|
||||||
|
|
||||||
|
BoardEntry entry = board.getByPosition(positionToSearch);
|
||||||
|
if (entry == null) {
|
||||||
|
new BoardEntry(board, text).send(position);
|
||||||
|
} else {
|
||||||
|
entry.setText(text).setup().send(position);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (board.getEntries().size() > scores.size()) {
|
||||||
|
iter = board.getEntries().iterator();
|
||||||
|
while (iter.hasNext()) {
|
||||||
|
BoardEntry boardEntry = iter.next();
|
||||||
|
if (!scores.contains(boardEntry.getText()) || Collections.frequency(board
|
||||||
|
.getBoardEntriesFormatted(), boardEntry.getText()) > 1) {
|
||||||
|
boardEntry.remove();
|
||||||
|
iter.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!board.getEntries().isEmpty()) {
|
||||||
|
board.getEntries().forEach(BoardEntry::remove);
|
||||||
|
board.getEntries().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.adapter.onScoreboardCreate(player, scoreboard);
|
||||||
|
|
||||||
|
player.setScoreboard(scoreboard);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
plugin.getLogger().severe("Something went wrong while updating " + player.getName() + "'s scoreboard " +
|
||||||
|
"" + board + " - " + board.getAdapter() + ")");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
49
src/main/java/me/joeleoli/nucleus/board/BoardTimer.java
Normal file
49
src/main/java/me/joeleoli/nucleus/board/BoardTimer.java
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
package me.joeleoli.nucleus.board;
|
||||||
|
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.apache.commons.lang.time.DurationFormatUtils;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class BoardTimer {
|
||||||
|
|
||||||
|
private static final DecimalFormat SECONDS_FORMATTER = new DecimalFormat("#0.0");
|
||||||
|
private final Board board;
|
||||||
|
private final String id;
|
||||||
|
private final double duration;
|
||||||
|
private final long end;
|
||||||
|
|
||||||
|
public BoardTimer(Board board, String id, double duration) {
|
||||||
|
this.board = board;
|
||||||
|
|
||||||
|
this.id = id;
|
||||||
|
this.duration = duration;
|
||||||
|
|
||||||
|
this.end = (long) (System.currentTimeMillis() + (duration * 1000));
|
||||||
|
|
||||||
|
if (board != null) {
|
||||||
|
board.getTimers().add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFormattedString(TimerType format) {
|
||||||
|
if (format == TimerType.SECONDS) {
|
||||||
|
return SECONDS_FORMATTER.format(((this.end - System.currentTimeMillis()) / 1000.0f));
|
||||||
|
} else {
|
||||||
|
return DurationFormatUtils.formatDuration(this.end - System.currentTimeMillis(), "mm:ss");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void cancel() {
|
||||||
|
if (this.board != null) {
|
||||||
|
this.board.getTimers().remove(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public enum TimerType {
|
||||||
|
SECONDS,
|
||||||
|
MINUTES,
|
||||||
|
HOURS
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
187
src/main/java/me/joeleoli/nucleus/chat/ChatComponentBuilder.java
Normal file
187
src/main/java/me/joeleoli/nucleus/chat/ChatComponentBuilder.java
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
package me.joeleoli.nucleus.chat;
|
||||||
|
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import net.md_5.bungee.api.ChatColor;
|
||||||
|
import net.md_5.bungee.api.chat.BaseComponent;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
|
public class ChatComponentBuilder extends ComponentBuilder {
|
||||||
|
|
||||||
|
private static Field partsField;
|
||||||
|
private static Field currField;
|
||||||
|
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
currField = ComponentBuilder.class.getDeclaredField("current");
|
||||||
|
partsField = ComponentBuilder.class.getDeclaredField("parts");
|
||||||
|
|
||||||
|
currField.setAccessible(true);
|
||||||
|
partsField.setAccessible(true);
|
||||||
|
} catch (NoSuchFieldException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder(String text) {
|
||||||
|
super("");
|
||||||
|
this.parse(text);
|
||||||
|
}
|
||||||
|
|
||||||
|
public TextComponent getCurrent() {
|
||||||
|
try {
|
||||||
|
return (TextComponent) currField.get(this);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCurrent(TextComponent tc) {
|
||||||
|
try {
|
||||||
|
currField.set(this, tc);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List getParts() {
|
||||||
|
try {
|
||||||
|
return (List) partsField.get(this);
|
||||||
|
} catch (IllegalAccessException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder setCurrentHoverEvent(HoverEvent hoverEvent) {
|
||||||
|
this.getCurrent().setHoverEvent(hoverEvent);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder setCurrentClickEvent(ClickEvent clickEvent) {
|
||||||
|
this.getCurrent().setClickEvent(clickEvent);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder attachToEachPart(HoverEvent hoverEvent) {
|
||||||
|
((List<BaseComponent>) this.getParts()).forEach(part -> {
|
||||||
|
if (part.getHoverEvent() == null) {
|
||||||
|
part.setHoverEvent(hoverEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.getCurrent().setHoverEvent(hoverEvent);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder attachToEachPart(ClickEvent clickEvent) {
|
||||||
|
((List<BaseComponent>) this.getParts()).forEach(part -> {
|
||||||
|
if (part.getClickEvent() == null) {
|
||||||
|
part.setClickEvent(clickEvent);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
this.getCurrent().setClickEvent(clickEvent);
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder parse(String text) {
|
||||||
|
String regex = "[&§]{1}([a-fA-Fl-oL-O0-9-r]){1}";
|
||||||
|
text = text.replaceAll(regex, "§$1");
|
||||||
|
|
||||||
|
if (!Pattern.compile(regex).matcher(text).find()) {
|
||||||
|
this.append(text);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
String[] words = text.split(regex);
|
||||||
|
int index = words[0].length();
|
||||||
|
|
||||||
|
for (String word : words) {
|
||||||
|
try {
|
||||||
|
if (index != words[0].length()) {
|
||||||
|
this.append(word);
|
||||||
|
|
||||||
|
final ChatColor color = ChatColor.getByChar(text.charAt(index - 1));
|
||||||
|
|
||||||
|
if (color == ChatColor.BOLD) {
|
||||||
|
this.bold(true);
|
||||||
|
} else if (color == ChatColor.STRIKETHROUGH) {
|
||||||
|
this.strikethrough(true);
|
||||||
|
} else if (color == ChatColor.MAGIC) {
|
||||||
|
this.obfuscated(true);
|
||||||
|
} else if (color == ChatColor.UNDERLINE) {
|
||||||
|
this.underlined(true);
|
||||||
|
} else if (color == ChatColor.RESET) {
|
||||||
|
this.bold(false);
|
||||||
|
this.strikethrough(false);
|
||||||
|
this.obfuscated(false);
|
||||||
|
this.underlined(false);
|
||||||
|
} else {
|
||||||
|
this.color(color);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
index += word.length() + 2;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder append(String text, BaseComponent[] hover) {
|
||||||
|
this.append(text);
|
||||||
|
|
||||||
|
if (hover != null) {
|
||||||
|
this.getCurrent().setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hover));
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ChatComponentBuilder append(TextComponent textComponent) {
|
||||||
|
if (textComponent == null) {
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
String text = textComponent.getText();
|
||||||
|
ChatColor color = textComponent.getColor();
|
||||||
|
boolean bold = textComponent.isBold();
|
||||||
|
boolean underline = textComponent.isUnderlined();
|
||||||
|
boolean italic = textComponent.isUnderlined();
|
||||||
|
boolean strike = textComponent.isStrikethrough();
|
||||||
|
HoverEvent he = textComponent.getHoverEvent();
|
||||||
|
ClickEvent ce = textComponent.getClickEvent();
|
||||||
|
|
||||||
|
append(text);
|
||||||
|
color(color);
|
||||||
|
underlined(underline);
|
||||||
|
italic(italic);
|
||||||
|
strikethrough(strike);
|
||||||
|
event(he);
|
||||||
|
event(ce);
|
||||||
|
|
||||||
|
if (textComponent.getExtra() != null) {
|
||||||
|
for (BaseComponent bc : textComponent.getExtra()) {
|
||||||
|
if (bc instanceof TextComponent) {
|
||||||
|
append((TextComponent) bc);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package me.joeleoli.nucleus.chat;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Data;
|
||||||
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Data
|
||||||
|
public class ChatComponentExtras {
|
||||||
|
|
||||||
|
private HoverEvent hoverEvent;
|
||||||
|
private ClickEvent clickEvent;
|
||||||
|
|
||||||
|
}
|
9
src/main/java/me/joeleoli/nucleus/chat/ChatFormat.java
Normal file
9
src/main/java/me/joeleoli/nucleus/chat/ChatFormat.java
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package me.joeleoli.nucleus.chat;
|
||||||
|
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface ChatFormat {
|
||||||
|
|
||||||
|
String format(Player sender, Player receiver, String message);
|
||||||
|
|
||||||
|
}
|
95
src/main/java/me/joeleoli/nucleus/chat/ChatManager.java
Normal file
95
src/main/java/me/joeleoli/nucleus/chat/ChatManager.java
Normal file
@ -0,0 +1,95 @@
|
|||||||
|
package me.joeleoli.nucleus.chat;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Optional;
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.chat.format.DefaultChatFormat;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class ChatManager {
|
||||||
|
|
||||||
|
private static final Pattern URL_REGEX = Pattern.compile(
|
||||||
|
"^(http://www\\.|https://www\\.|http://|https://)?[a-z0-9]+([\\-.][a-z0-9]+)*\\.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?$");
|
||||||
|
private static final Pattern IP_REGEX = Pattern.compile(
|
||||||
|
"^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])([.,])){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$");
|
||||||
|
private static final List<String> LINK_WHITELIST = Arrays.asList(
|
||||||
|
"minexd.com", "eu.minexd.com", "sa.minexd.com",
|
||||||
|
"youtube.com", "youtu.be", "discord.gg", "twitter.com",
|
||||||
|
"prnt.sc", "gyazo.com", "imgur.com"
|
||||||
|
);
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private ChatFormat chatFormat = new DefaultChatFormat();
|
||||||
|
private int delayTime = 3;
|
||||||
|
private boolean chatMuted = false;
|
||||||
|
@Getter
|
||||||
|
private List<String> filteredWords = Arrays.asList("nigger", "faggot", "queer", "paki", "slut");
|
||||||
|
@Getter
|
||||||
|
private List<String> filteredPhrases = Arrays.asList("adviser is fat", "adviser fat");
|
||||||
|
|
||||||
|
public void toggleMuteChat() {
|
||||||
|
this.chatMuted = !this.chatMuted;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean shouldFilter(String message) {
|
||||||
|
String msg = message.toLowerCase()
|
||||||
|
.replace("3", "e")
|
||||||
|
.replace("1", "i")
|
||||||
|
.replace("!", "i")
|
||||||
|
.replace("@", "a")
|
||||||
|
.replace("7", "t")
|
||||||
|
.replace("0", "o")
|
||||||
|
.replace("5", "s")
|
||||||
|
.replace("8", "b")
|
||||||
|
.replaceAll("\\p{Punct}|\\d", "").trim();
|
||||||
|
|
||||||
|
String[] words = msg.trim().split(" ");
|
||||||
|
|
||||||
|
for (String word : words) {
|
||||||
|
for (String filteredWord : this.filteredWords) {
|
||||||
|
if (word.contains(filteredWord)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String word : message.replace("(dot)", ".").replace("[dot]", ".").trim().split(" ")) {
|
||||||
|
boolean continueIt = false;
|
||||||
|
|
||||||
|
for (String phrase : ChatManager.LINK_WHITELIST) {
|
||||||
|
if (word.toLowerCase().contains(phrase)) {
|
||||||
|
continueIt = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (continueIt) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher matcher = ChatManager.IP_REGEX.matcher(word);
|
||||||
|
|
||||||
|
if (matcher.matches()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
matcher = ChatManager.URL_REGEX.matcher(word);
|
||||||
|
|
||||||
|
if (matcher.matches()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Optional<String> optional = this.filteredPhrases.stream().filter(msg::contains).findFirst();
|
||||||
|
|
||||||
|
return optional.isPresent();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,15 @@
|
|||||||
|
package me.joeleoli.nucleus.chat.format;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.NucleusAPI;
|
||||||
|
import me.joeleoli.nucleus.chat.ChatFormat;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DefaultChatFormat implements ChatFormat {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String format(Player sender, Player receiver, String message) {
|
||||||
|
return NucleusAPI.getPrefixedName(sender) + Style.WHITE + ": " + message;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
18
src/main/java/me/joeleoli/nucleus/command/Command.java
Normal file
18
src/main/java/me/joeleoli/nucleus/command/Command.java
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
package me.joeleoli.nucleus.command;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.METHOD)
|
||||||
|
public @interface Command {
|
||||||
|
|
||||||
|
String[] names();
|
||||||
|
|
||||||
|
String permissionNode() default "";
|
||||||
|
|
||||||
|
boolean async() default false;
|
||||||
|
|
||||||
|
}
|
129
src/main/java/me/joeleoli/nucleus/command/CommandData.java
Normal file
129
src/main/java/me/joeleoli/nucleus/command/CommandData.java
Normal file
@ -0,0 +1,129 @@
|
|||||||
|
package me.joeleoli.nucleus.command;
|
||||||
|
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterData;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
final class CommandData {
|
||||||
|
|
||||||
|
@Getter private String[] names;
|
||||||
|
@Getter private String permissionNode;
|
||||||
|
@Getter private boolean async;
|
||||||
|
@Getter private List<ParameterData> parameters = new ArrayList<>();
|
||||||
|
@Getter private Method method;
|
||||||
|
@Getter private boolean consoleAllowed;
|
||||||
|
|
||||||
|
public CommandData(Command commandAnnotation, List<ParameterData> parameters, Method method,
|
||||||
|
boolean consoleAllowed) {
|
||||||
|
this.names = commandAnnotation.names();
|
||||||
|
this.permissionNode = commandAnnotation.permissionNode();
|
||||||
|
this.async = commandAnnotation.async();
|
||||||
|
this.parameters = parameters;
|
||||||
|
this.method = method;
|
||||||
|
this.consoleAllowed = consoleAllowed;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String toString(String[] args, int start) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int arg = start; arg < args.length; arg++) {
|
||||||
|
stringBuilder.append(args[arg]).append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return (stringBuilder.toString().trim());
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getName() {
|
||||||
|
return (names[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean canAccess(CommandSender sender) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return (true);
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (permissionNode) {
|
||||||
|
case "":
|
||||||
|
return (true);
|
||||||
|
default:
|
||||||
|
return (sender.hasPermission(permissionNode));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsageString() {
|
||||||
|
return (getUsageString(getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUsageString(String aliasUsed) {
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
|
||||||
|
for (ParameterData paramHelp : getParameters()) {
|
||||||
|
boolean needed = paramHelp.getDefaultValue().isEmpty();
|
||||||
|
stringBuilder.append(needed ? "<" : "[").append(paramHelp.getName());
|
||||||
|
stringBuilder.append(needed ? ">" : "]").append(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
return ("/" + aliasUsed.toLowerCase() + " " + stringBuilder.toString().trim().toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public void execute(CommandSender sender, String[] params) {
|
||||||
|
// We start to build the parameters we call the method with here.
|
||||||
|
List<Object> transformedParameters = new ArrayList<>();
|
||||||
|
|
||||||
|
// Add the sender.
|
||||||
|
// If the method is expecting a Player or a general CommandSender will be handled by Java.
|
||||||
|
transformedParameters.add(sender);
|
||||||
|
|
||||||
|
// Fill in / validate parameters
|
||||||
|
for (int parameterIndex = 0; parameterIndex < getParameters().size(); parameterIndex++) {
|
||||||
|
ParameterData parameter = getParameters().get(parameterIndex);
|
||||||
|
String passedParameter =
|
||||||
|
(parameterIndex < params.length ? params[parameterIndex] : parameter.getDefaultValue()).trim();
|
||||||
|
|
||||||
|
// We needed a parameter where we didn't get one (where there's no default value available)
|
||||||
|
if (parameterIndex >= params.length &&
|
||||||
|
(parameter.getDefaultValue() == null || parameter.getDefaultValue().isEmpty())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "Usage: " + getUsageString());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Wildcards "capture" all strings after them
|
||||||
|
if (parameter.isWildcard() && !passedParameter.trim().equals(parameter.getDefaultValue().trim())) {
|
||||||
|
passedParameter = toString(params, parameterIndex);
|
||||||
|
}
|
||||||
|
|
||||||
|
// We try to transform the parameter given to us.
|
||||||
|
Object result = CommandHandler.transformParameter(sender, passedParameter, parameter.getParameterClass());
|
||||||
|
|
||||||
|
// If it's null that means the transformer tried (and failed) at transforming the value.
|
||||||
|
// It'll have sent them a message and such, so we can just return.
|
||||||
|
if (result == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
transformedParameters.add(result);
|
||||||
|
|
||||||
|
// If it was a wildcard we don't want to bother parsing anything else
|
||||||
|
// (even though there shouldn't have been anything else)
|
||||||
|
if (parameter.isWildcard()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// and actually execute the command.
|
||||||
|
|
||||||
|
try {
|
||||||
|
// null = static method.
|
||||||
|
method.invoke(null, transformedParameters.toArray());
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "It appears there was some issues processing your command...");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
354
src/main/java/me/joeleoli/nucleus/command/CommandHandler.java
Normal file
354
src/main/java/me/joeleoli/nucleus/command/CommandHandler.java
Normal file
@ -0,0 +1,354 @@
|
|||||||
|
package me.joeleoli.nucleus.command;
|
||||||
|
|
||||||
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.common.collect.ImmutableSet;
|
||||||
|
import java.lang.annotation.Annotation;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.lang.reflect.Modifier;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterData;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.BooleanParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.DoubleParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.FloatParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.GameModeParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.IntegerParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.ItemStackParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.LongParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.PlayerInfoParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.PlayerParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.RankParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.ServerTypeParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.UUIDParameterType;
|
||||||
|
import me.joeleoli.nucleus.command.param.defaults.WorldParameterType;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.server.ServerType;
|
||||||
|
import me.joeleoli.nucleus.util.ClassUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public final class CommandHandler implements Listener {
|
||||||
|
|
||||||
|
@Getter private static List<CommandData> commands = new ArrayList<>();
|
||||||
|
private static Map<Class<?>, ParameterType> parameterTypes = new HashMap<>();
|
||||||
|
private static boolean initiated = false;
|
||||||
|
|
||||||
|
// Static class -- cannot be created.
|
||||||
|
private CommandHandler() {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Initiates the command handler. This can only be called once, and is called automatically when Nucleus enables.
|
||||||
|
*/
|
||||||
|
public static void init() {
|
||||||
|
// Only allow the CommandHandler to be initiated once.
|
||||||
|
// Note the '!' in the .checkState call.
|
||||||
|
Preconditions.checkState(!initiated);
|
||||||
|
initiated = true;
|
||||||
|
|
||||||
|
Nucleus.getInstance().getServer().getPluginManager()
|
||||||
|
.registerEvents(new CommandHandler(), Nucleus.getInstance());
|
||||||
|
|
||||||
|
// Run this on a delay so everything is registered.
|
||||||
|
// Not really needed, but it's nice to play it safe.
|
||||||
|
new BukkitRunnable() {
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
// Command map field (we have to use reflection to get this)
|
||||||
|
Field commandMapField = Nucleus.getInstance().getServer().getClass().getDeclaredField("commandMap");
|
||||||
|
commandMapField.setAccessible(true);
|
||||||
|
|
||||||
|
Object oldCommandMap = commandMapField.get(Nucleus.getInstance().getServer());
|
||||||
|
CommandMap newCommandMap = new CommandMap(Nucleus.getInstance().getServer());
|
||||||
|
|
||||||
|
// Start copying the knownCommands field over
|
||||||
|
// (so any commands registered before we hook in are kept)
|
||||||
|
Field knownCommandsField = SimpleCommandMap.class.getDeclaredField("knownCommands");
|
||||||
|
knownCommandsField.setAccessible(true);
|
||||||
|
|
||||||
|
// The knownCommands field is final,
|
||||||
|
// so to be able to set it in the new command map we have to remove it.
|
||||||
|
Field modifiersField = Field.class.getDeclaredField("modifiers");
|
||||||
|
modifiersField.setAccessible(true);
|
||||||
|
modifiersField.setInt(knownCommandsField, knownCommandsField.getModifiers() & ~Modifier.FINAL);
|
||||||
|
|
||||||
|
knownCommandsField.set(newCommandMap, knownCommandsField.get(oldCommandMap));
|
||||||
|
// End copying the knownCommands field over
|
||||||
|
|
||||||
|
commandMapField.set(Nucleus.getInstance().getServer(), newCommandMap);
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Shouldn't happen, so we can just
|
||||||
|
// printout the exception (and do nothing else)
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}.runTaskLater(Nucleus.getInstance(), 5L);
|
||||||
|
|
||||||
|
// Register our default parameter types.
|
||||||
|
// boolean.class is the same as Boolean.TYPE,
|
||||||
|
// however using .class improves readability.
|
||||||
|
registerParameterType(UUID.class, new UUIDParameterType());
|
||||||
|
registerParameterType(boolean.class, new BooleanParameterType());
|
||||||
|
registerParameterType(float.class, new FloatParameterType());
|
||||||
|
registerParameterType(double.class, new DoubleParameterType());
|
||||||
|
registerParameterType(long.class, new LongParameterType());
|
||||||
|
registerParameterType(int.class, new IntegerParameterType());
|
||||||
|
registerParameterType(Player.class, new PlayerParameterType());
|
||||||
|
registerParameterType(World.class, new WorldParameterType());
|
||||||
|
registerParameterType(ItemStack.class, new ItemStackParameterType());
|
||||||
|
registerParameterType(Rank.class, new RankParameterType());
|
||||||
|
registerParameterType(ServerType.class, new ServerTypeParameterType());
|
||||||
|
registerParameterType(PlayerInfo.class, new PlayerInfoParameterType());
|
||||||
|
registerParameterType(GameMode.class, new GameModeParameterType());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Loads all commands from the given package into the command handler.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin responsible for these commands. This is here because the .getClassesInPackage
|
||||||
|
* method requires it (for no real reason)
|
||||||
|
* @param packageName The package to load commands from. Example: "me.joeleoli.game.commands"
|
||||||
|
*/
|
||||||
|
public static void loadCommandsFromPackage(Plugin plugin, String packageName) {
|
||||||
|
for (Class<?> clazz : ClassUtil.getClassesInPackage(plugin, packageName)) {
|
||||||
|
registerClass(clazz);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Register a custom parameter adapter.
|
||||||
|
*
|
||||||
|
* @param transforms The class this parameter type will return (IE KOTH.class, Player.class, etc.)
|
||||||
|
* @param parameterType The ParameterType object which will perform the transformation.
|
||||||
|
*/
|
||||||
|
public static void registerParameterType(Class<?> transforms, ParameterType parameterType) {
|
||||||
|
parameterTypes.put(transforms, parameterType);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a single class with the command handler.
|
||||||
|
*
|
||||||
|
* @param registeredClass The class to scan/register.
|
||||||
|
*/
|
||||||
|
protected static void registerClass(Class<?> registeredClass) {
|
||||||
|
for (Method method : registeredClass.getMethods()) {
|
||||||
|
if (method.getAnnotation(Command.class) != null) {
|
||||||
|
registerMethod(method);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers a single method with the command handler.
|
||||||
|
*
|
||||||
|
* @param method The method to register (if applicable)
|
||||||
|
*/
|
||||||
|
protected static void registerMethod(Method method) {
|
||||||
|
Command commandAnnotation = method.getAnnotation(Command.class);
|
||||||
|
List<ParameterData> parameterData = new ArrayList<>();
|
||||||
|
|
||||||
|
// Offset of 1 here for the sender parameter.
|
||||||
|
for (int parameterIndex = 1; parameterIndex < method.getParameterTypes().length; parameterIndex++) {
|
||||||
|
Parameter parameterAnnotation = null;
|
||||||
|
|
||||||
|
for (Annotation annotation : method.getParameterAnnotations()[parameterIndex]) {
|
||||||
|
if (annotation instanceof Parameter) {
|
||||||
|
parameterAnnotation = (Parameter) annotation;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (parameterAnnotation != null) {
|
||||||
|
parameterData.add(new ParameterData(parameterAnnotation, method.getParameterTypes()[parameterIndex]));
|
||||||
|
} else {
|
||||||
|
Nucleus.getInstance().getLogger()
|
||||||
|
.warning("Method '" + method.getName() + "' has a parameter without a @Parameter annotation.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
commands.add(new CommandData(commandAnnotation, parameterData, method,
|
||||||
|
method.getParameterTypes()[0].isAssignableFrom(Player.class)
|
||||||
|
));
|
||||||
|
|
||||||
|
Collections.sort(commands, new Comparator<CommandData>() {
|
||||||
|
@Override
|
||||||
|
public int compare(CommandData o1, CommandData o2) {
|
||||||
|
return (o2.getName().length() - o1.getName().length());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return the full command line input of a player before running or tab completing a Nucleus command
|
||||||
|
*/
|
||||||
|
public static String[] getParameters(Player player) {
|
||||||
|
return CommandMap.parameters.get(player.getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Process a command (permission checks, argument validation, etc.)
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender executing this command. It should be noted that any non-player sender is treated
|
||||||
|
* with full permissions.
|
||||||
|
* @param command The command to process (without a prepended '/')
|
||||||
|
*
|
||||||
|
* @return The Command executed
|
||||||
|
*/
|
||||||
|
public static CommandData evalCommand(final CommandSender sender, String command) {
|
||||||
|
String[] args = new String[]{ };
|
||||||
|
CommandData found = null;
|
||||||
|
|
||||||
|
CommandLoop:
|
||||||
|
for (CommandData commandData : commands) {
|
||||||
|
for (String alias : commandData.getNames()) {
|
||||||
|
String messageString = command.toLowerCase() + " ";
|
||||||
|
String aliasString = alias.toLowerCase() + " ";
|
||||||
|
|
||||||
|
if (messageString.startsWith(aliasString)) {
|
||||||
|
found = commandData;
|
||||||
|
|
||||||
|
if (messageString.length() > aliasString.length()) {
|
||||||
|
if (found.getParameters().size() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// If there's 'space' after the command, parse args.
|
||||||
|
// The +1 is there to account for a space after the command if there's parameters
|
||||||
|
if (command.length() > alias.length() + 1) {
|
||||||
|
// See above as to... why this works.
|
||||||
|
args = (command.substring(alias.length() + 1)).split(" ");
|
||||||
|
}
|
||||||
|
|
||||||
|
// We break to the command loop as we have 2 for loops here.
|
||||||
|
break CommandLoop;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found == null) {
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!(sender instanceof Player) && !found.isConsoleAllowed()) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "This command does not support execution from the console.");
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!found.canAccess(sender)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No permission.");
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found.isAsync()) {
|
||||||
|
final CommandData foundClone = found;
|
||||||
|
final String[] argsClone = args;
|
||||||
|
|
||||||
|
new BukkitRunnable() {
|
||||||
|
public void run() {
|
||||||
|
foundClone.execute(sender, argsClone);
|
||||||
|
}
|
||||||
|
}.runTaskAsynchronously(Nucleus.getInstance());
|
||||||
|
} else {
|
||||||
|
found.execute(sender, args);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (found);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Transforms a parameter.
|
||||||
|
*
|
||||||
|
* @param sender The CommandSender executing the command (or whoever we should transform 'for')
|
||||||
|
* @param parameter The String to transform ('' if none)
|
||||||
|
* @param transformTo The class we should use to fetch our ParameterType (which we delegate transforming down to)
|
||||||
|
*
|
||||||
|
* @return The Object that we've transformed the parameter to.
|
||||||
|
*/
|
||||||
|
protected static Object transformParameter(CommandSender sender, String parameter, Class<?> transformTo) {
|
||||||
|
// Special-case Strings as they never need transforming.
|
||||||
|
if (transformTo.equals(String.class)) {
|
||||||
|
return (parameter);
|
||||||
|
}
|
||||||
|
|
||||||
|
// This will throw a NullPointerException if there's no registered
|
||||||
|
// parameter type, but that's fine -- as that's what we'd do anyway.
|
||||||
|
return (parameterTypes.get(transformTo).transform(sender, parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Tab completes a parameter.
|
||||||
|
*
|
||||||
|
* @param sender The Player tab completing the command (not CommandSender as tab completion is for players
|
||||||
|
* only)
|
||||||
|
* @param parameter The last thing the player typed in their style box before hitting tab ('' if none)
|
||||||
|
* @param transformTo The class we should use to fetch our ParameterType (which we delegate tab completing down
|
||||||
|
* to)
|
||||||
|
* @param tabCompleteFlags The list of custom flags to use when tab completing this parameter.
|
||||||
|
*
|
||||||
|
* @return A List<String> of available tab completions. (empty if none)
|
||||||
|
*/
|
||||||
|
protected static List<String> tabCompleteParameter(Player sender, String parameter, Class<?> transformTo,
|
||||||
|
String[] tabCompleteFlags) {
|
||||||
|
if (!parameterTypes.containsKey(transformTo)) {
|
||||||
|
return (new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
return (parameterTypes.get(transformTo).tabComplete(sender, ImmutableSet.copyOf(tabCompleteFlags), parameter));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Executes a command for the given player. Use this instead of Player#performCommand as that method does not call a
|
||||||
|
* PlayerCommandPreprocess event.
|
||||||
|
*
|
||||||
|
* @param sender The player to execute the command for.
|
||||||
|
*/
|
||||||
|
public static void executeCommand(Player sender, String commandLine) {
|
||||||
|
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(sender, "/" + commandLine);
|
||||||
|
Bukkit.getPluginManager().callEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
|
||||||
|
public void onCommandPreProcess(PlayerCommandPreprocessEvent event) {
|
||||||
|
String command = event.getMessage().substring(1);
|
||||||
|
|
||||||
|
CommandMap.parameters.put(event.getPlayer().getUniqueId(), command.split(" "));
|
||||||
|
|
||||||
|
if (evalCommand(event.getPlayer(), command) != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onConsoleCommand(ServerCommandEvent event) {
|
||||||
|
if (evalCommand(event.getSender(), event.getCommand()) != null) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
15
src/main/java/me/joeleoli/nucleus/command/CommandHelp.java
Normal file
15
src/main/java/me/joeleoli/nucleus/command/CommandHelp.java
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
package me.joeleoli.nucleus.command;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class CommandHelp {
|
||||||
|
|
||||||
|
private String syntax;
|
||||||
|
private String description;
|
||||||
|
|
||||||
|
}
|
139
src/main/java/me/joeleoli/nucleus/command/CommandMap.java
Normal file
139
src/main/java/me/joeleoli/nucleus/command/CommandMap.java
Normal file
@ -0,0 +1,139 @@
|
|||||||
|
package me.joeleoli.nucleus.command;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collections;
|
||||||
|
import java.util.Comparator;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterData;
|
||||||
|
import org.bukkit.Server;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.SimpleCommandMap;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.util.StringUtil;
|
||||||
|
|
||||||
|
final class CommandMap extends SimpleCommandMap {
|
||||||
|
|
||||||
|
protected static Map<UUID, String[]> parameters = new HashMap<>();
|
||||||
|
|
||||||
|
public CommandMap(Server server) {
|
||||||
|
super(server);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(CommandSender sender, String cmdLine) {
|
||||||
|
if (!(sender instanceof Player)) {
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = (Player) sender;
|
||||||
|
parameters.put(player.getUniqueId(), cmdLine.split(" "));
|
||||||
|
|
||||||
|
try {
|
||||||
|
int spaceIndex = cmdLine.indexOf(' ');
|
||||||
|
Set<String> completions = new HashSet<>();
|
||||||
|
|
||||||
|
boolean doneHere = false;
|
||||||
|
|
||||||
|
CommandLoop:
|
||||||
|
for (CommandData command : CommandHandler.getCommands()) {
|
||||||
|
if (!command.canAccess(player)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String alias : command.getNames()) {
|
||||||
|
String split = alias.split(" ")[0];
|
||||||
|
|
||||||
|
if (spaceIndex != -1) {
|
||||||
|
split = alias;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (StringUtil.startsWithIgnoreCase(split.trim(), cmdLine.trim()) ||
|
||||||
|
StringUtil.startsWithIgnoreCase(cmdLine.trim(), split.trim())) {
|
||||||
|
if (spaceIndex == -1 && cmdLine.length() < alias.length()) {
|
||||||
|
// Complete the command
|
||||||
|
completions.add("/" + split.toLowerCase());
|
||||||
|
} else if (cmdLine.toLowerCase().startsWith(alias.toLowerCase() + " ") &&
|
||||||
|
command.getParameters().size() > 0) {
|
||||||
|
// Complete the params
|
||||||
|
int paramIndex = (cmdLine.split(" ").length - alias.split(" ").length);
|
||||||
|
|
||||||
|
// If they didn't hit space, complete the param before it.
|
||||||
|
if (paramIndex == command.getParameters().size() || !cmdLine.endsWith(" ")) {
|
||||||
|
paramIndex = paramIndex - 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (paramIndex < 0) {
|
||||||
|
paramIndex = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
ParameterData paramData = command.getParameters().get(paramIndex);
|
||||||
|
String[] params = cmdLine.split(" ");
|
||||||
|
|
||||||
|
for (String completion : CommandHandler.tabCompleteParameter(player,
|
||||||
|
cmdLine.endsWith(" ") ? "" : params[params.length - 1],
|
||||||
|
paramData.getParameterClass(), paramData.getTabCompleteFlags()
|
||||||
|
)) {
|
||||||
|
completions.add(completion);
|
||||||
|
}
|
||||||
|
|
||||||
|
doneHere = true;
|
||||||
|
|
||||||
|
break CommandLoop;
|
||||||
|
} else {
|
||||||
|
String halfSplitString =
|
||||||
|
split.toLowerCase().replaceFirst(alias.split(" ")[0].toLowerCase(), "").trim();
|
||||||
|
String[] splitString = halfSplitString.split(" ");
|
||||||
|
|
||||||
|
String fixedAlias = splitString[splitString.length - 1].trim();
|
||||||
|
String lastArg =
|
||||||
|
cmdLine.endsWith(" ") ? "" : cmdLine.split(" ")[cmdLine.split(" ").length - 1];
|
||||||
|
|
||||||
|
if (fixedAlias.length() >= lastArg.length()) {
|
||||||
|
completions.add(fixedAlias);
|
||||||
|
}
|
||||||
|
|
||||||
|
doneHere = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
List<String> completionList = new ArrayList<>(completions);
|
||||||
|
|
||||||
|
if (!doneHere) {
|
||||||
|
List<String> vanillaCompletionList = super.tabComplete(sender, cmdLine);
|
||||||
|
|
||||||
|
if (vanillaCompletionList == null) {
|
||||||
|
vanillaCompletionList = new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
for (String vanillaCompletion : vanillaCompletionList) {
|
||||||
|
completionList.add(vanillaCompletion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
Collections.sort(completionList, new Comparator<String>() {
|
||||||
|
@Override
|
||||||
|
public int compare(String o1, String o2) {
|
||||||
|
return (o2.length() - o1.length());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
completionList.remove("w");
|
||||||
|
|
||||||
|
return (completionList);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
return (new ArrayList<>());
|
||||||
|
} finally {
|
||||||
|
parameters.remove(player.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.player.cosmetic.CosmeticEditType;
|
||||||
|
import me.joeleoli.nucleus.player.gui.CosmeticTagMenu;
|
||||||
|
import me.joeleoli.nucleus.player.gui.SelectColorMenu;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class CosmeticCommands {
|
||||||
|
|
||||||
|
@Command(names = "color", permissionNode = "nucleus.donor.color")
|
||||||
|
public static void color(Player player) {
|
||||||
|
new SelectColorMenu(CosmeticEditType.COLOR).openMenu(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "tag", permissionNode = "nucleus.donor.tag")
|
||||||
|
public static void tag(Player player) {
|
||||||
|
new CosmeticTagMenu().openMenu(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,282 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.NucleusAPI;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.cooldown.Cooldown;
|
||||||
|
import me.joeleoli.nucleus.jedis.NucleusJedis;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.json.JsonChain;
|
||||||
|
import me.joeleoli.nucleus.packet.Packet;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.reflection.BukkitReflection;
|
||||||
|
import me.joeleoli.nucleus.util.PlayerUtil;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
import org.bukkit.inventory.meta.ItemMeta;
|
||||||
|
|
||||||
|
public class GeneralCommands {
|
||||||
|
|
||||||
|
@Command(names = "help")
|
||||||
|
public static void help(Player player) {
|
||||||
|
player.sendMessage(new String[]{
|
||||||
|
Style.getBorderLine(),
|
||||||
|
Style.YELLOW + "Twitter: " + Style.PINK + "@MineXD",
|
||||||
|
Style.YELLOW + "Discord: " + Style.PINK + "discord.gg/5aVjHM9",
|
||||||
|
"",
|
||||||
|
Style.YELLOW + "/report <player> <reason>" + Style.GRAY + " - " + Style.PINK + "Report a player",
|
||||||
|
Style.YELLOW + "/request <message>" + Style.GRAY + " - " + Style.PINK + "Request assistance",
|
||||||
|
Style.getBorderLine()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "night")
|
||||||
|
public static void night(Player player) {
|
||||||
|
Packet packet = new Packet(PacketType.Play.Server.UPDATE_TIME);
|
||||||
|
|
||||||
|
packet.getLongs()
|
||||||
|
.write(0, 14500L)
|
||||||
|
.write(1, 14500L);
|
||||||
|
|
||||||
|
packet.send(player);
|
||||||
|
|
||||||
|
player.sendMessage(Style.GREEN + "You set your time to night.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "day")
|
||||||
|
public static void day(Player player) {
|
||||||
|
Packet packet = new Packet(PacketType.Play.Server.UPDATE_TIME);
|
||||||
|
|
||||||
|
packet.getLongs()
|
||||||
|
.write(0, 0L)
|
||||||
|
.write(1, 0L);
|
||||||
|
|
||||||
|
packet.send(player);
|
||||||
|
|
||||||
|
player.sendMessage(Style.GREEN + "You set your time to dau.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "broadcast", "bc" }, permissionNode = "nucleus.broadcast")
|
||||||
|
public static void broadcast(CommandSender sender, @Parameter(wildcard = true, name = "message") String broadcast) {
|
||||||
|
String msg = broadcast.replaceAll("(&([a-f0-9l-or]))", "\u00A7$2");
|
||||||
|
|
||||||
|
NucleusJedis.getInstance().write(
|
||||||
|
NucleusPayload.BROADCAST_MESSAGE,
|
||||||
|
new JsonChain()
|
||||||
|
.addProperty("message", msg)
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "raw", permissionNode = "nucleus.raw")
|
||||||
|
public static void raw(CommandSender sender, @Parameter(wildcard = true, name = "message") String broadcast) {
|
||||||
|
String msg = broadcast.replaceAll("(&([a-f0-9l-or]))", "\u00A7$2");
|
||||||
|
Bukkit.broadcastMessage(msg);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "heal", permissionNode = "nucleus.heal")
|
||||||
|
public static void heal(Player player) {
|
||||||
|
player.setHealth(20.0);
|
||||||
|
player.setFoodLevel(20);
|
||||||
|
player.updateInventory();
|
||||||
|
player.sendMessage(Style.GOLD + "You have been healed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "healother", permissionNode = "nucleus.heal")
|
||||||
|
public static void healOther(Player player, @Parameter(name = "target") Player target) {
|
||||||
|
target.setHealth(20.0);
|
||||||
|
target.setFoodLevel(20);
|
||||||
|
target.updateInventory();
|
||||||
|
target.sendMessage(Style.GOLD + "You have been healed.");
|
||||||
|
player.sendMessage(Style.GOLD + "You healed " + Style.RESET + target.getDisplayName() + Style.GOLD + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "rename", permissionNode = "nucleus.rename")
|
||||||
|
public static void rename(Player player, @Parameter(name = "name", wildcard = true) String name) {
|
||||||
|
if (player.getItemInHand() == null) {
|
||||||
|
player.sendMessage(Style.RED + "There is nothing in your hand.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final ItemStack itemStack = player.getItemInHand();
|
||||||
|
final ItemMeta itemMeta = itemStack.getItemMeta();
|
||||||
|
|
||||||
|
itemMeta.setDisplayName(Style.translate(name));
|
||||||
|
itemStack.setItemMeta(itemMeta);
|
||||||
|
|
||||||
|
player.updateInventory();
|
||||||
|
player.sendMessage(Style.GREEN + "You renamed the item in your hand.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "more", permissionNode = "nucleus.more")
|
||||||
|
public static void more(Player player) {
|
||||||
|
if (player.getItemInHand() == null) {
|
||||||
|
player.sendMessage(Style.RED + "There is nothing in your hand.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getItemInHand().setAmount(64);
|
||||||
|
player.updateInventory();
|
||||||
|
player.sendMessage(Style.GREEN + "You gave yourself more of the item in your hand.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "setspawn", permissionNode = "nucleus.setspawn")
|
||||||
|
public static void setSpawn(Player player) {
|
||||||
|
player.getLocation().getWorld()
|
||||||
|
.setSpawnLocation((int) player.getLocation().getX(), (int) player.getLocation().getY(),
|
||||||
|
(int) player.getLocation().getZ()
|
||||||
|
);
|
||||||
|
player.sendMessage(Style.GREEN + "You updated the world spawn.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "spawn", permissionNode = "nucleus.spawn")
|
||||||
|
public static void spawn(Player player) {
|
||||||
|
player.teleport(player.getLocation().getWorld().getSpawnLocation());
|
||||||
|
player.sendMessage(Style.GREEN + "You teleported to the world spawn.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "updateinv", permissionNode = "nucleus.updateinv")
|
||||||
|
public static void updateInventory(Player player) {
|
||||||
|
player.updateInventory();
|
||||||
|
player.sendMessage(Style.GOLD + "Updated your inventory.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "reset" }, permissionNode = "nucleus.reset")
|
||||||
|
public static void reset(Player player) {
|
||||||
|
PlayerUtil.reset(player, false);
|
||||||
|
player.sendMessage(Style.GOLD + "Your player has been reset.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "ci", "clear", "clearinv" }, permissionNode = "nucleus.clearinv")
|
||||||
|
public static void clearInventory(Player player) {
|
||||||
|
player.getInventory().setContents(new ItemStack[36]);
|
||||||
|
player.getInventory().setArmorContents(new ItemStack[4]);
|
||||||
|
player.sendMessage(Style.GOLD + "Your inventory has been cleared.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "gamemode", "gm" }, permissionNode = "nucleus.gamemode")
|
||||||
|
public static void gamemodeSelf(Player player, @Parameter(name = "gamemode") GameMode gameMode) {
|
||||||
|
player.setGameMode(gameMode);
|
||||||
|
player.updateInventory();
|
||||||
|
player.sendMessage(Style.GOLD + "You updated your game mode to " + Style.RESET + gameMode.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "gamemodeother", "gmother" }, permissionNode = "nucleus.gamemode.other")
|
||||||
|
public static void gamemodeOther(CommandSender sender, @Parameter(name = "target") Player target,
|
||||||
|
@Parameter(name = "gamemode") GameMode gameMode) {
|
||||||
|
String senderName;
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
final Player player = (Player) sender;
|
||||||
|
|
||||||
|
senderName = NucleusAPI.getColoredName(player);
|
||||||
|
} else {
|
||||||
|
senderName = Style.DARK_RED + "Console";
|
||||||
|
}
|
||||||
|
|
||||||
|
target.setGameMode(gameMode);
|
||||||
|
target.updateInventory();
|
||||||
|
target.sendMessage(Style.GOLD + "Your game mode has been updated by " + Style.RESET + senderName);
|
||||||
|
sender.sendMessage(
|
||||||
|
Style.GOLD + "You updated " + NucleusAPI.getColoredName(target) + Style.GOLD + "'s game mode to " +
|
||||||
|
Style.RESET + gameMode.name());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "setslots", "setmaxslots" }, permissionNode = "nucleus.setslots")
|
||||||
|
public static void setSlots(CommandSender sender, @Parameter(name = "slots") int slots) {
|
||||||
|
BukkitReflection.setMaxPlayers(Nucleus.getInstance().getServer(), slots);
|
||||||
|
|
||||||
|
sender.sendMessage(Style.GREEN + "You set the max slots to " + slots + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "ping")
|
||||||
|
public static void ping(Player player, @Parameter(name = "target", defaultValue = "self") PlayerInfo targetInfo) {
|
||||||
|
final Player target = targetInfo.toPlayer();
|
||||||
|
|
||||||
|
if (target == null) {
|
||||||
|
player.sendMessage(Style.RED + "That player could not be found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int ping = BukkitReflection.getPing(target);
|
||||||
|
|
||||||
|
player.sendMessage(target.getDisplayName() + Style.YELLOW + "'s ping: " +
|
||||||
|
(ping > 100 ? Style.RED : (ping > 50 ? Style.YELLOW : Style.GREEN)) + ping);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "showplayer", permissionNode = "nucleus.util.showplayer")
|
||||||
|
public static void showPlayer(Player player, @Parameter(name = "target") Player target) {
|
||||||
|
player.showPlayer(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "hidePlayer", permissionNode = "nucleus.util.hideplayer")
|
||||||
|
public static void hidePlayer(Player player, @Parameter(name = "target") Player target) {
|
||||||
|
player.hidePlayer(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "report")
|
||||||
|
public static void reportPlayer(Player player, @Parameter(name = "target") Player target,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getChatManager().shouldFilter(reason)) {
|
||||||
|
player.sendMessage(Style.RED + "If you continue to mis-use the report feature you will be banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nucleusPlayer.getReportCooldown().hasExpired()) {
|
||||||
|
player.sendMessage(Style.RED + "You must wait before you can report another player.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(Style.GREEN + "Thanks, we will review your report.");
|
||||||
|
|
||||||
|
nucleusPlayer.setReportCooldown(new Cooldown(60_000));
|
||||||
|
|
||||||
|
NucleusJedis.getInstance().write(
|
||||||
|
NucleusPayload.PLAYER_REPORT,
|
||||||
|
new JsonChain()
|
||||||
|
.addProperty("server", Nucleus.getInstance().getNucleusConfig().getServerId())
|
||||||
|
.addProperty("sender_name", NucleusAPI.getColoredName(player))
|
||||||
|
.addProperty("reported_name", NucleusAPI.getColoredName(target))
|
||||||
|
.addProperty("report_reason", reason)
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "request", "helpop" })
|
||||||
|
public static void reportPlayer(Player player, @Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getChatManager().shouldFilter(reason)) {
|
||||||
|
player.sendMessage(Style.RED + "If you continue to mis-use the request feature you will be banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nucleusPlayer.getRequestCooldown().hasExpired()) {
|
||||||
|
player.sendMessage(Style.RED + "You must wait before you can request assistance.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(Style.GREEN + "We have received your request and will help soon. Please be patient.");
|
||||||
|
|
||||||
|
nucleusPlayer.setRequestCooldown(new Cooldown(60_000));
|
||||||
|
|
||||||
|
NucleusJedis.getInstance().write(
|
||||||
|
NucleusPayload.PLAYER_REQUEST,
|
||||||
|
new JsonChain()
|
||||||
|
.addProperty("server", Nucleus.getInstance().getNucleusConfig().getServerId())
|
||||||
|
.addProperty("sender_name", NucleusAPI.getColoredName(player))
|
||||||
|
.addProperty("request_reason", reason)
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,41 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.jedis.NucleusJedis;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.reflection.BukkitReflection;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ManagementCommands {
|
||||||
|
|
||||||
|
@Command(names = "nucleus reload", permissionNode = "nucleus.owner")
|
||||||
|
public static void reload(CommandSender sender) {
|
||||||
|
Nucleus.getInstance().getNucleusConfig().load();
|
||||||
|
sender.sendMessage(Style.GREEN + "Reloaded Nucleus configuration.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "nucleus clearpunishments", permissionNode = "nucleus.owner")
|
||||||
|
public static void clearDatabase(CommandSender sender) {
|
||||||
|
Nucleus.getInstance().getNucleusMongo().dropPunishments();
|
||||||
|
NucleusJedis.getInstance().write(NucleusPayload.CLEAR_PUNISHMENTS, null);
|
||||||
|
sender.sendMessage(Style.GREEN + "Cleared punishments database.");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "playerdebug", permissionNode = "nucleus.debug")
|
||||||
|
public static void debugPlayer(Player player) {
|
||||||
|
player.sendMessage(Style.GOLD + "Your values:");
|
||||||
|
|
||||||
|
player.sendMessage(new String[]{
|
||||||
|
Style.GRAY + " * XYZ: " + Math.round(player.getLocation().getX()) + ", " +
|
||||||
|
Math.round(player.getLocation().getY()) + ", " + Math.round(player.getLocation().getZ()),
|
||||||
|
Style.GRAY + " * Health: " + player.getHealth(),
|
||||||
|
Style.GRAY + " * Walk Speed: " + player.getWalkSpeed(),
|
||||||
|
Style.GRAY + " * Fly Speed: " + player.getFlySpeed(),
|
||||||
|
Style.GRAY + " * Ping: " + BukkitReflection.getPing(player)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,187 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.punishment.PunishmentHelper;
|
||||||
|
import me.joeleoli.nucleus.punishment.PunishmentType;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class PunishmentCommands {
|
||||||
|
|
||||||
|
@Command(names = "ban", permissionNode = "nucleus.ban", async = true)
|
||||||
|
public static void ban(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo target,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
String flags = "-p";
|
||||||
|
final String[] split = reason.split(" ");
|
||||||
|
|
||||||
|
if (split[split.length - 1].startsWith("-")) {
|
||||||
|
flags = split[split.length - 1];
|
||||||
|
reason = reason.substring(0, reason.length() - flags.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
final PunishmentHelper helper = new PunishmentHelper(PunishmentType.BAN, sender, target, null, reason, flags, false);
|
||||||
|
|
||||||
|
if (helper.isTargetNotFound()) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isBrokenProfile()) {
|
||||||
|
sender.sendMessage(Style.formatBrokenProfileMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isInvalidPunishment()) {
|
||||||
|
sender.sendMessage(helper.getTargetName() + Style.RED + " is already banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "tempban", permissionNode = "nucleus.tempban", async = true)
|
||||||
|
public static void temporaryBan(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo target,
|
||||||
|
@Parameter(name = "duration") String duration,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
String flags = "-p";
|
||||||
|
final String[] split = reason.split(" ");
|
||||||
|
|
||||||
|
if (split[split.length - 1].startsWith("-")) {
|
||||||
|
flags = split[split.length - 1];
|
||||||
|
reason = reason.substring(0, reason.length() - flags.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
final PunishmentHelper helper = new PunishmentHelper(PunishmentType.TEMPBAN, sender, target, duration, reason, flags, false);
|
||||||
|
|
||||||
|
if (helper.isTargetNotFound()) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isBrokenProfile()) {
|
||||||
|
sender.sendMessage(Style.formatBrokenProfileMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isInvalidPunishment()) {
|
||||||
|
sender.sendMessage(helper.getTargetName() + Style.RED + " is already banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.getDuration() == -1) {
|
||||||
|
sender.sendMessage(Style.RED + "Failed to parse the given duration string.");
|
||||||
|
sender.sendMessage(Style.RED + "Example syntax: 2m3w1d2h (2 months, 3 weeks, 1 day, and 2 hours)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "mute", permissionNode = "nucleus.mute", async = true)
|
||||||
|
public static void mute(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo target,
|
||||||
|
@Parameter(name = "duration") String duration,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
String flags = "-p";
|
||||||
|
final String[] split = reason.split(" ");
|
||||||
|
|
||||||
|
if (split[split.length - 1].startsWith("-")) {
|
||||||
|
flags = split[split.length - 1];
|
||||||
|
reason = reason.substring(0, reason.length() - flags.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
final PunishmentHelper helper = new PunishmentHelper(PunishmentType.MUTE, sender, target, duration, reason, flags, false);
|
||||||
|
|
||||||
|
if (helper.isTargetNotFound()) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isBrokenProfile()) {
|
||||||
|
sender.sendMessage(Style.formatBrokenProfileMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isInvalidPunishment()) {
|
||||||
|
sender.sendMessage(helper.getTargetName() + Style.RED + " is already muted.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.getDuration() == -1) {
|
||||||
|
sender.sendMessage(Style.RED + "Failed to parse the given duration string.");
|
||||||
|
sender.sendMessage(Style.RED + "Example syntax: 2m3w1d2h (2 months, 3 weeks, 1 day, and 2 hours)");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "unban", permissionNode = "nucleus.unban", async = true)
|
||||||
|
public static void unban(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo target,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
String flags = "-p";
|
||||||
|
final String[] split = reason.split(" ");
|
||||||
|
|
||||||
|
if (split[split.length - 1].startsWith("-")) {
|
||||||
|
flags = split[split.length - 1];
|
||||||
|
reason = reason.substring(0, reason.length() - flags.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
final PunishmentHelper helper = new PunishmentHelper(PunishmentType.BAN, sender, target, null, reason, flags, true);
|
||||||
|
|
||||||
|
if (helper.isTargetNotFound()) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isBrokenProfile()) {
|
||||||
|
sender.sendMessage(Style.formatBrokenProfileMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isInvalidPunishment()) {
|
||||||
|
sender.sendMessage(Style.RESET + helper.getTargetName() + Style.RED + " isn't banned.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "unmute", permissionNode = "nucleus.unmute", async = true)
|
||||||
|
public static void unmute(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo target,
|
||||||
|
@Parameter(name = "reason", wildcard = true) String reason) {
|
||||||
|
String flags = "-p";
|
||||||
|
final String[] split = reason.split(" ");
|
||||||
|
|
||||||
|
if (split[split.length - 1].startsWith("-")) {
|
||||||
|
flags = split[split.length - 1];
|
||||||
|
reason = reason.substring(0, reason.length() - flags.length());
|
||||||
|
}
|
||||||
|
|
||||||
|
final PunishmentHelper helper = new PunishmentHelper(PunishmentType.MUTE, sender, target, null, reason, flags, true);
|
||||||
|
|
||||||
|
if (helper.isTargetNotFound()) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isBrokenProfile()) {
|
||||||
|
sender.sendMessage(Style.formatBrokenProfileMessage(helper.getTargetName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (helper.isInvalidPunishment()) {
|
||||||
|
sender.sendMessage(Style.RESET + helper.getTargetName() + Style.RED + " isn't muted.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
helper.execute();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,292 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import java.util.Comparator;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.CommandHelp;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.server.ServerType;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RankCommands {
|
||||||
|
|
||||||
|
private static final CommandHelp[] HELP = new CommandHelp[]{
|
||||||
|
new CommandHelp("/rank create <global/server> <name> [server]", "Create a rank"),
|
||||||
|
new CommandHelp("/rank delete <name>", "Delete a rank"),
|
||||||
|
new CommandHelp("/rank setprefix <name> <prefix>", "Set prefix of a rank"),
|
||||||
|
new CommandHelp("/rank setcolor <name> <color>", "Set colo of a rank"),
|
||||||
|
new CommandHelp("/rank setweight <name> <number>", "Set the weight of a rank"),
|
||||||
|
new CommandHelp("/rank addperm <name> <perm>", "Add a permission to a rank"),
|
||||||
|
new CommandHelp("/rank delperm <name> <perm>", "Delete a permission from a rank"),
|
||||||
|
new CommandHelp("/rank dump <name>", "Dump a rank's permissions"),
|
||||||
|
new CommandHelp("/rank inherit <parent> <child>", "Inherit a child rank"),
|
||||||
|
new CommandHelp("/setrank <player> <rank>", "Set a player's rank")
|
||||||
|
};
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = { "rank", "rank help" },
|
||||||
|
permissionNode = "nucleus.ranks"
|
||||||
|
)
|
||||||
|
public static void help(Player player) {
|
||||||
|
for (CommandHelp help : HELP) {
|
||||||
|
player.sendMessage(Style.translate("&e" + help.getSyntax() + " &7- &d" + help.getDescription()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank list",
|
||||||
|
permissionNode = "nucleus.ranks"
|
||||||
|
)
|
||||||
|
public static void list(CommandSender sender) {
|
||||||
|
sender.sendMessage(Style.GOLD + "Ranks:");
|
||||||
|
|
||||||
|
Rank.getRanks().sort(Comparator.comparingInt(Rank::getWeight));
|
||||||
|
|
||||||
|
for (Rank rank : Rank.getRanks()) {
|
||||||
|
sender.sendMessage(Style.translate("&7 - &r" + rank.getRankInfo()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank create global",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void createGlobal(Player player,
|
||||||
|
@Parameter(name = "rankName") String rankName) {
|
||||||
|
if (Rank.getRankByName(rankName) != null) {
|
||||||
|
player.sendMessage(Style.RED + "A rank with that name already exists.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rank rank = new Rank(rankName);
|
||||||
|
|
||||||
|
rank.setGlobal(true);
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
player.sendMessage(Style.translate("&aYou created a new global rank: &r" + rank.getColoredName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank create server",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void createServer(Player player,
|
||||||
|
@Parameter(name = "rankName") String rankName,
|
||||||
|
@Parameter(name = "serverType") ServerType serverType) {
|
||||||
|
if (Rank.getRankByName(rankName) != null) {
|
||||||
|
player.sendMessage(Style.RED + "A rank with that name already exists.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Rank rank = new Rank(rankName);
|
||||||
|
|
||||||
|
rank.setServerType(serverType);
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
player.sendMessage(Style.GREEN + "Created new server rank: " + rank.getColoredName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = { "rank delete", "rank remove" },
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void delete(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank) {
|
||||||
|
rank.delete(true);
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate("&aYou deleted &r" + rank.getColoredName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank setprefix",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void setPrefix(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "prefix", wildcard = true) String prefix) {
|
||||||
|
rank.setPrefix(Style.translate(prefix));
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate(
|
||||||
|
"&aYou updated the prefix of &r" + rank.getColoredName() + " &ato: &r" + rank.getPrefix() +
|
||||||
|
sender.getName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank setcolor",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void setColor(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "color") String color) {
|
||||||
|
if (!Style.strip(color).equalsIgnoreCase("")) {
|
||||||
|
sender.sendMessage(Style.RED + "A rank's color must contain only valid color codes.");
|
||||||
|
sender.sendMessage(Style.RED + "Example: &6&l");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String oldColoredName = rank.getColoredName();
|
||||||
|
|
||||||
|
rank.setColor(Style.translate(color));
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate("&aUpdated color of " + oldColoredName + " &ato: " + rank.getColoredName()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank setweight",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void setWeight(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "weight") int weight) {
|
||||||
|
rank.setWeight(weight);
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
sender.sendMessage(
|
||||||
|
Style.translate("&aUpdated weight of &r" + rank.getColoredName() + " &ato: &r" + rank.getWeight()));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = { "rank addperm", "rank addpermission" },
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void addPermission(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "permission") String permission) {
|
||||||
|
if (rank.getPermissions().contains(permission)) {
|
||||||
|
sender.sendMessage(rank.getColoredName() + Style.RED + " already had the `" + permission + "` permission.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rank.getPermissions().add(permission);
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate(
|
||||||
|
"&aYou added `" + permission + "` to &r" + rank.getColoredName() + "&a's permissions."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = { "rank delperm", "rank deleteperm" },
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void deletePermission(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "permission") String permission) {
|
||||||
|
if (!rank.getPermissions().remove(permission)) {
|
||||||
|
sender.sendMessage(
|
||||||
|
rank.getColoredName() + Style.RED + " did not have the `" + permission + "` permission.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
rank.save();
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate(
|
||||||
|
"&aYou removed `" + permission + "` from &r" + rank.getColoredName() + "&a's permissions."));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank inherit",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void inherit(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank,
|
||||||
|
@Parameter(name = "otherRank") Rank otherRank) {
|
||||||
|
boolean removed = false;
|
||||||
|
|
||||||
|
if (rank.getInherits().remove(otherRank.getName())) {
|
||||||
|
removed = true;
|
||||||
|
} else {
|
||||||
|
rank.getInherits().add(otherRank.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Style.translate(
|
||||||
|
"&aYou made &r" + rank.getColoredName() + " &a" + (removed ? "no longer " : "") + "inherit &r" +
|
||||||
|
otherRank.getColoredName()));
|
||||||
|
|
||||||
|
rank.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "rank dump",
|
||||||
|
permissionNode = "nucleus.ranks",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void dump(CommandSender sender,
|
||||||
|
@Parameter(name = "rank") Rank rank) {
|
||||||
|
sender.sendMessage(rank.getColoredName() + "'s Permissions:");
|
||||||
|
|
||||||
|
for (String permission : rank.getEffectivePermissions()) {
|
||||||
|
sender.sendMessage(Style.GRAY + " * " + permission);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(rank.getColoredName() + " Inherits:");
|
||||||
|
|
||||||
|
for (String inherit : rank.getInherits()) {
|
||||||
|
Rank otherRank = Rank.getRankByName(inherit);
|
||||||
|
|
||||||
|
if (otherRank == null) {
|
||||||
|
sender.sendMessage(Style.GRAY + " - " + Style.RESET + inherit);
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Style.GRAY + " - " + Style.RESET + otherRank.getColoredName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(
|
||||||
|
names = "setrank",
|
||||||
|
permissionNode = "nucleus.setrank",
|
||||||
|
async = true
|
||||||
|
)
|
||||||
|
public static void setRank(CommandSender sender,
|
||||||
|
@Parameter(name = "target") PlayerInfo playerInfo,
|
||||||
|
@Parameter(name = "rank") Rank rank) {
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByName(playerInfo.getName());
|
||||||
|
|
||||||
|
if (targetData == null) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(playerInfo.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetData.isLoaded()) {
|
||||||
|
targetData.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetName = playerInfo.getName();
|
||||||
|
|
||||||
|
if (targetData.getName() != null && playerInfo.getName().equalsIgnoreCase(targetData.getName())) {
|
||||||
|
targetName = Style.RESET + targetData.getActiveRank().getColor() + targetData.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
targetData.setRank(rank);
|
||||||
|
targetData.save();
|
||||||
|
|
||||||
|
sender.sendMessage(Style.GREEN + "You updated " + Style.RESET + targetName + Style.GREEN + "'s " +
|
||||||
|
(rank.isGlobal() ? "global" : rank.getServerType().name() + " server") + " rank to: " +
|
||||||
|
rank.getColoredName());
|
||||||
|
|
||||||
|
Nucleus.getInstance().getNucleusJedis().write(
|
||||||
|
NucleusPayload.PLAYER_UPDATE_RANK,
|
||||||
|
new me.joeleoli.nucleus.json.JsonChain()
|
||||||
|
.addProperty("player_uuid", targetData.getUuid().toString())
|
||||||
|
.addProperty("rank_name", rank.getName())
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.rave.Rave;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class RaveCommands {
|
||||||
|
|
||||||
|
@Command(names = "nucleus rave", permissionNode = "nucleus.rave")
|
||||||
|
public static void rave(CommandSender sender) {
|
||||||
|
if (Nucleus.getInstance().getRave() != null) {
|
||||||
|
Nucleus.getInstance().getRave().end();
|
||||||
|
} else {
|
||||||
|
Nucleus.getInstance().setRave(new Rave(Nucleus.getInstance().getChatManager().getChatFormat()));
|
||||||
|
Nucleus.getInstance().getRave().start();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,56 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.task.ShutdownTask;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
|
public class ShutdownCommands {
|
||||||
|
|
||||||
|
@Command(names = { "shutdown", "restart" }, permissionNode = "nucleus.shutdown")
|
||||||
|
public static void shutdown(CommandSender sender) {
|
||||||
|
sender.sendMessage(Style.RED + "Usage: /shutdown <check|cancel|time> [seconds]");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "shutdown check", permissionNode = "nucleus.shutdown")
|
||||||
|
public static void time(CommandSender sender) {
|
||||||
|
if (Nucleus.getInstance().getShutdownTask() == null) {
|
||||||
|
sender.sendMessage(Style.RED + "The server is not scheduled to shut down.");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage(Style.GREEN + "The server will shutdown in " +
|
||||||
|
Nucleus.getInstance().getShutdownTask().getSecondsUntilShutdown() + " seconds.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "shutdown cancel", "shutdown stop" }, permissionNode = "nucleus.shutdown")
|
||||||
|
public static void cancel(CommandSender sender) {
|
||||||
|
if (Nucleus.getInstance().getShutdownTask() == null) {
|
||||||
|
sender.sendMessage(Style.RED + "The server is not scheduled to shut down.");
|
||||||
|
} else {
|
||||||
|
Nucleus.getInstance().getShutdownTask().cancel();
|
||||||
|
Nucleus.getInstance().setShutdownTask(null);
|
||||||
|
sender.sendMessage(Style.RED + "The server shutdown has been canceled.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = "shutdown time", permissionNode = "nucleus.shutdown")
|
||||||
|
public static void time(CommandSender sender, @Parameter(name = "seconds") int seconds) {
|
||||||
|
if (seconds <= 0) {
|
||||||
|
sender.sendMessage(Style.RED + "You must input a number greater than 0!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getShutdownTask() == null) {
|
||||||
|
Nucleus.getInstance().setShutdownTask(new ShutdownTask(Nucleus.getInstance(), seconds));
|
||||||
|
Nucleus.getInstance().getShutdownTask().runTaskTimer(Nucleus.getInstance(), 20L, 20L);
|
||||||
|
} else {
|
||||||
|
Nucleus.getInstance().getShutdownTask().setSecondsUntilShutdown(seconds);
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage(Style.GREEN + "The server will shutdown in " + seconds + " seconds.");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,188 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.joeleoli.nucleus.NucleusAPI;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.log.LogQueue;
|
||||||
|
import me.joeleoli.nucleus.log.PrivateMessageLog;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.player.DefinedSetting;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import me.joeleoli.nucleus.uuid.UUIDCache;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class SocialCommands {
|
||||||
|
|
||||||
|
@Command(names = { "togglepm", "togglepms", "tpm" })
|
||||||
|
public static void toggleMessages(Player player) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final boolean toggled = !NucleusAPI.<Boolean>getSetting(player, DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES);
|
||||||
|
|
||||||
|
nucleusPlayer.getSettings().getSettings().put(DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES, toggled);
|
||||||
|
|
||||||
|
if (toggled) {
|
||||||
|
player.sendMessage(Style.GREEN + "You enabled private messages.");
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Style.RED + "You disabled private messages.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "togglesounds", "sounds" })
|
||||||
|
public static void toggleSounds(Player player) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final boolean toggled = !NucleusAPI.<Boolean>getSetting(player, DefinedSetting.GlobalPlayerSetting.PLAY_MESSAGE_SOUNDS);
|
||||||
|
|
||||||
|
nucleusPlayer.getSettings().getSettings().put(DefinedSetting.GlobalPlayerSetting.PLAY_MESSAGE_SOUNDS, toggled);
|
||||||
|
|
||||||
|
if (toggled) {
|
||||||
|
player.sendMessage(Style.YELLOW + "You enabled message sounds.");
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Style.YELLOW + "You disabled message sounds.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "ignore" })
|
||||||
|
public static void ignore(Player player, @Parameter(name = "target") PlayerInfo target) {
|
||||||
|
final UUID targetUuid = UUIDCache.getUuid(target.getName());
|
||||||
|
|
||||||
|
if (targetUuid == null) {
|
||||||
|
player.sendMessage(Style.formatPlayerNotFoundMessage(target.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetUuid.equals(player.getUniqueId())) {
|
||||||
|
player.sendMessage(Style.RED + "You cannot ignore yourself.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final boolean removed = nucleusPlayer.getIgnored().remove(targetUuid);
|
||||||
|
|
||||||
|
if (!removed) {
|
||||||
|
nucleusPlayer.getIgnored().add(targetUuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(
|
||||||
|
Style.YELLOW + "You " + (!removed ? "are now" : "are no longer") + " ignoring " + Style.PINK +
|
||||||
|
target.getName());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "message", "msg", "m", "tell", "whisper" })
|
||||||
|
public static void message(Player player, @Parameter(name = "target") Player target,
|
||||||
|
@Parameter(name = "message", wildcard = true) String message) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByUuid(target.getUniqueId());
|
||||||
|
|
||||||
|
if (!nucleusPlayer.getSettings().getBoolean(DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES)) {
|
||||||
|
player.sendMessage(Style.RED + "Your private messages are currently disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String senderName = Style.RESET + NucleusAPI.getColoredName(player);
|
||||||
|
final String targetName = Style.RESET + NucleusAPI.getColoredName(target);
|
||||||
|
|
||||||
|
if (nucleusPlayer.isIgnored(target.getUniqueId())) {
|
||||||
|
player.sendMessage(Style.RED + "You are ignoring " + targetName + Style.RED + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetData.isIgnored(player.getUniqueId())) {
|
||||||
|
player.sendMessage(Style.RED + "You cannot send messages to " + targetName + Style.RED + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NucleusAPI.<Boolean>getSetting(target, DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES)) {
|
||||||
|
player.sendMessage(targetName + Style.RED + " is not accepting private messages right now.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nucleusPlayer.setReplyTo(target.getUniqueId());
|
||||||
|
targetData.setReplyTo(player.getUniqueId());
|
||||||
|
|
||||||
|
final String[] messages = Style.formatPrivateMessage(senderName, targetName, message);
|
||||||
|
|
||||||
|
player.sendMessage(messages[0]);
|
||||||
|
target.sendMessage(messages[1]);
|
||||||
|
|
||||||
|
if (NucleusAPI.getSetting(target, DefinedSetting.GlobalPlayerSetting.PLAY_MESSAGE_SOUNDS)) {
|
||||||
|
target.playSound(target.getLocation(), Sound.SUCCESSFUL_HIT, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogQueue.getPrivateMessageLogs().add(
|
||||||
|
new PrivateMessageLog(
|
||||||
|
player.getUniqueId(),
|
||||||
|
target.getUniqueId(),
|
||||||
|
message,
|
||||||
|
System.currentTimeMillis()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "reply", "r" })
|
||||||
|
public static void reply(Player player, @Parameter(name = "message", wildcard = true) String message) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
|
||||||
|
if (nucleusPlayer.getReplyTo() == null) {
|
||||||
|
player.sendMessage(Style.RED + "You have nobody to reply to.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final Player target = Bukkit.getPlayer(nucleusPlayer.getReplyTo());
|
||||||
|
|
||||||
|
if (target == null || !target.isOnline()) {
|
||||||
|
player.sendMessage(Style.RED + "That player is no longer online.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByUuid(target.getUniqueId());
|
||||||
|
|
||||||
|
if (!nucleusPlayer.getSettings().getBoolean(DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES)) {
|
||||||
|
player.sendMessage(Style.RED + "Your private messages are currently disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final String senderName = Style.RESET + NucleusAPI.getColoredName(player);
|
||||||
|
final String targetName = Style.RESET + NucleusAPI.getColoredName(target);
|
||||||
|
|
||||||
|
if (nucleusPlayer.isIgnored(target.getUniqueId())) {
|
||||||
|
player.sendMessage(Style.RED + "You are ignoring " + targetName + Style.RED + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetData.isIgnored(player.getUniqueId())) {
|
||||||
|
player.sendMessage(Style.RED + "You cannot send messages to " + targetName + Style.RED + ".");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NucleusAPI.<Boolean>getSetting(target, DefinedSetting.GlobalPlayerSetting.RECEIVE_PRIVATE_MESSAGES)) {
|
||||||
|
player.sendMessage(targetName + Style.RED + " is not accepting private messages right now.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nucleusPlayer.setReplyTo(target.getUniqueId());
|
||||||
|
targetData.setReplyTo(player.getUniqueId());
|
||||||
|
|
||||||
|
final String[] messages = Style.formatPrivateMessage(senderName, targetName, message);
|
||||||
|
|
||||||
|
player.sendMessage(messages[0]);
|
||||||
|
target.sendMessage(messages[1]);
|
||||||
|
|
||||||
|
if (NucleusAPI.getSetting(target, DefinedSetting.GlobalPlayerSetting.PLAY_MESSAGE_SOUNDS)) {
|
||||||
|
target.playSound(target.getLocation(), Sound.SUCCESSFUL_HIT, 1.0F, 1.0F);
|
||||||
|
}
|
||||||
|
|
||||||
|
LogQueue.getPrivateMessageLogs().add(
|
||||||
|
new PrivateMessageLog(
|
||||||
|
player.getUniqueId(),
|
||||||
|
target.getUniqueId(),
|
||||||
|
message,
|
||||||
|
System.currentTimeMillis()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,149 @@
|
|||||||
|
package me.joeleoli.nucleus.command.commands;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.NucleusAPI;
|
||||||
|
import me.joeleoli.nucleus.command.Command;
|
||||||
|
import me.joeleoli.nucleus.command.param.Parameter;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.json.JsonChain;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import me.joeleoli.nucleus.punishment.gui.PunishmentHistoryMenu;
|
||||||
|
import me.joeleoli.nucleus.util.PlayerUtil;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import me.joeleoli.nucleus.uuid.UUIDCache;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class StaffCommands {
|
||||||
|
|
||||||
|
@Command(names = { "freeze", "ss" }, permissionNode = "nucleus.freeze")
|
||||||
|
public static void freeze(CommandSender sender, @Parameter(name = "target") Player target) {
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByUuid(target.getUniqueId());
|
||||||
|
final boolean isFrozen = !targetData.isFrozen();
|
||||||
|
|
||||||
|
if (isFrozen) {
|
||||||
|
target.sendMessage(new String[]{
|
||||||
|
Style.BLANK_LINE,
|
||||||
|
Style.YELLOW + Style.center("You have been frozen by a staff member."),
|
||||||
|
Style.PINK + Style.center("Please join our TeamSpeak: ts.minexd.com"),
|
||||||
|
Style.PINK + Style.center("You have 5 minutes. Disconnecting will result in a ban."),
|
||||||
|
Style.BLANK_LINE,
|
||||||
|
});
|
||||||
|
|
||||||
|
PlayerUtil.denyMovement(target);
|
||||||
|
} else {
|
||||||
|
target.sendMessage(Style.YELLOW + "You are no longer frozen.");
|
||||||
|
|
||||||
|
PlayerUtil.allowMovement(target);
|
||||||
|
}
|
||||||
|
|
||||||
|
targetData.setFrozen(!targetData.isFrozen());
|
||||||
|
|
||||||
|
PlayerUtil.messageStaff(
|
||||||
|
Style.formatFreezeMessage(sender.getName(), target.getName(), isFrozen ? "frozen" : "unfrozen"));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "mutechat", "silencechat" }, permissionNode = "nucleus.mutechat")
|
||||||
|
public static void muteChat(CommandSender sender) {
|
||||||
|
Nucleus.getInstance().getChatManager().toggleMuteChat();
|
||||||
|
|
||||||
|
final String message = Style.formatMuteChatMessage(
|
||||||
|
sender.getName(),
|
||||||
|
Nucleus.getInstance().getChatManager().isChatMuted() ? "muted" : "unmuted"
|
||||||
|
);
|
||||||
|
|
||||||
|
for (Player player : Nucleus.getInstance().getServer().getOnlinePlayers()) {
|
||||||
|
player.sendMessage(message);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "staffchat", "sc" }, permissionNode = "nucleus.staff", async = true)
|
||||||
|
public static void staffChat(Player player, @Parameter(name = "message", wildcard = true) String message) {
|
||||||
|
Nucleus.getInstance().getNucleusJedis().write(
|
||||||
|
NucleusPayload.STAFF_CHAT,
|
||||||
|
new JsonChain()
|
||||||
|
.addProperty("server", Nucleus.getInstance().getNucleusConfig().getServerId())
|
||||||
|
.addProperty("player_name", NucleusAPI.getColoredName(player))
|
||||||
|
.addProperty("message", message)
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "punishments", "history" }, permissionNode = "nucleus.history", async = true)
|
||||||
|
public static void history(Player player, @Parameter(name = "target") PlayerInfo playerInfo) {
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByName(playerInfo.getName());
|
||||||
|
|
||||||
|
if (targetData == null) {
|
||||||
|
player.sendMessage(Style.formatPlayerNotFoundMessage(playerInfo.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetData.isLoaded()) {
|
||||||
|
targetData.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
new PunishmentHistoryMenu(targetData).openMenu(player);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "alts" }, permissionNode = "nucleus.staff", async = true)
|
||||||
|
public static void alternates(CommandSender sender, @Parameter(name = "target") PlayerInfo playerInfo) {
|
||||||
|
final NucleusPlayer targetData = NucleusPlayer.getByName(playerInfo.getName());
|
||||||
|
|
||||||
|
if (targetData == null) {
|
||||||
|
sender.sendMessage(Style.formatPlayerNotFoundMessage(playerInfo.getName()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!targetData.isLoaded()) {
|
||||||
|
targetData.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
String targetName = playerInfo.getName();
|
||||||
|
|
||||||
|
if (targetData.getName() != null && playerInfo.getName().equalsIgnoreCase(targetData.getName())) {
|
||||||
|
targetName = targetData.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (targetData.getAlternates().isEmpty()) {
|
||||||
|
sender.sendMessage(Style.PINK + targetName + Style.YELLOW + " does not have any alts.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final List<String> names = new ArrayList<>();
|
||||||
|
|
||||||
|
targetData.getAlternates().forEach(uuid -> {
|
||||||
|
String name = UUIDCache.getName(uuid);
|
||||||
|
|
||||||
|
if (name != null) {
|
||||||
|
names.add(name);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
sender.sendMessage(Style.YELLOW + "Alts of " + Style.PINK + targetName);
|
||||||
|
names.forEach(sender::sendMessage);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Command(names = { "clearchat", "cc" }, permissionNode = "nucleus.clearchat", async = true)
|
||||||
|
public static void clear(CommandSender sender) {
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
|
||||||
|
for (int i = 0; i < 100; i++) {
|
||||||
|
builder.append("§a §b §c §d §e §f §0 §r \n");
|
||||||
|
}
|
||||||
|
|
||||||
|
final String clear = builder.toString();
|
||||||
|
final String broadcast = Style.formatClearChatMessage(sender.getName());
|
||||||
|
|
||||||
|
for (Player player : Nucleus.getInstance().getServer().getOnlinePlayers()) {
|
||||||
|
if (!player.hasPermission("nucleus.staff")) {
|
||||||
|
player.sendMessage(clear);
|
||||||
|
}
|
||||||
|
|
||||||
|
player.sendMessage(broadcast);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
@Target(ElementType.PARAMETER)
|
||||||
|
public @interface Parameter {
|
||||||
|
|
||||||
|
String name();
|
||||||
|
|
||||||
|
boolean wildcard() default (false);
|
||||||
|
|
||||||
|
String defaultValue() default ("");
|
||||||
|
|
||||||
|
String[] tabCompleteFlags() default ("");
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
public final class ParameterData {
|
||||||
|
|
||||||
|
@Getter private String name;
|
||||||
|
@Getter private boolean wildcard;
|
||||||
|
@Getter private String defaultValue;
|
||||||
|
@Getter private String[] tabCompleteFlags;
|
||||||
|
@Getter private Class<?> parameterClass;
|
||||||
|
|
||||||
|
public ParameterData(Parameter parameterAnnotation, Class<?> parameterClass) {
|
||||||
|
this.name = parameterAnnotation.name();
|
||||||
|
this.wildcard = parameterAnnotation.wildcard();
|
||||||
|
this.defaultValue = parameterAnnotation.defaultValue();
|
||||||
|
this.tabCompleteFlags = parameterAnnotation.tabCompleteFlags();
|
||||||
|
this.parameterClass = parameterClass;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,14 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public interface ParameterType<T> {
|
||||||
|
|
||||||
|
T transform(CommandSender sender, String source);
|
||||||
|
|
||||||
|
List<String> tabComplete(Player sender, Set<String> flags, String source);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class BooleanParameterType implements ParameterType<Boolean> {
|
||||||
|
|
||||||
|
private static final Map<String, Boolean> MAP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
MAP.put("true", true);
|
||||||
|
MAP.put("on", true);
|
||||||
|
MAP.put("yes", true);
|
||||||
|
|
||||||
|
MAP.put("false", false);
|
||||||
|
MAP.put("off", false);
|
||||||
|
MAP.put("no", false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Boolean transform(CommandSender sender, String source) {
|
||||||
|
if (!MAP.containsKey(source.toLowerCase())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid boolean.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MAP.get(source.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (MAP.keySet().stream().filter(string -> StringUtils.startsWithIgnoreCase(string, source))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class DoubleParameterType implements ParameterType<Double> {
|
||||||
|
|
||||||
|
public Double transform(CommandSender sender, String source) {
|
||||||
|
if (source.toLowerCase().contains("e")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
double parsed = Double.parseDouble(source);
|
||||||
|
|
||||||
|
if (Double.isNaN(parsed) || !Double.isFinite(parsed)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (parsed);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class FloatParameterType implements ParameterType<Float> {
|
||||||
|
|
||||||
|
public Float transform(CommandSender sender, String source) {
|
||||||
|
if (source.toLowerCase().contains("e")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
float parsed = Float.parseFloat(source);
|
||||||
|
|
||||||
|
if (Float.isNaN(parsed) || !Float.isFinite(parsed)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (parsed);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class GameModeParameterType implements ParameterType<GameMode> {
|
||||||
|
|
||||||
|
private static final Map<String, GameMode> MAP = new HashMap<>();
|
||||||
|
|
||||||
|
static {
|
||||||
|
MAP.put("c", GameMode.CREATIVE);
|
||||||
|
MAP.put("creative", GameMode.CREATIVE);
|
||||||
|
MAP.put("1", GameMode.CREATIVE);
|
||||||
|
|
||||||
|
MAP.put("s", GameMode.SURVIVAL);
|
||||||
|
MAP.put("survival", GameMode.SURVIVAL);
|
||||||
|
MAP.put("0", GameMode.SURVIVAL);
|
||||||
|
}
|
||||||
|
|
||||||
|
public GameMode transform(CommandSender sender, String source) {
|
||||||
|
if (!MAP.containsKey(source.toLowerCase())) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid game mode.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return MAP.get(source.toLowerCase());
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (MAP.keySet().stream().filter(string -> StringUtils.startsWithIgnoreCase(string, source))
|
||||||
|
.collect(Collectors.toList()));
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,26 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class IntegerParameterType implements ParameterType<Integer> {
|
||||||
|
|
||||||
|
public Integer transform(CommandSender sender, String source) {
|
||||||
|
try {
|
||||||
|
return (Integer.parseInt(source));
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.util.ItemUtil;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
public class ItemStackParameterType implements ParameterType<ItemStack> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ItemStack transform(CommandSender sender, String source) {
|
||||||
|
ItemStack item = ItemUtil.get(source);
|
||||||
|
|
||||||
|
if (item == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No item with the name " + source + " found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return item;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return ImmutableList.of(); // it would probably be too intensive to go through all the aliases
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class LongParameterType implements ParameterType<Long> {
|
||||||
|
|
||||||
|
public Long transform(CommandSender sender, String source) {
|
||||||
|
if (source.toLowerCase().contains("e")) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
long parsed = Long.parseLong(source);
|
||||||
|
|
||||||
|
if (Double.isNaN(parsed) || !Double.isFinite(parsed)) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (parsed);
|
||||||
|
} catch (NumberFormatException exception) {
|
||||||
|
sender.sendMessage(ChatColor.RED + source + " is not a valid number.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
return (new ArrayList<>());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,40 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.player.PlayerInfo;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class PlayerInfoParameterType implements ParameterType<PlayerInfo> {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PlayerInfo transform(CommandSender sender, String source) {
|
||||||
|
final Player player = source.equalsIgnoreCase("self") && sender instanceof Player ? (Player) sender
|
||||||
|
: Bukkit.getPlayer(source);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
return new PlayerInfo(player.getUniqueId(), player.getName());
|
||||||
|
} else {
|
||||||
|
return new PlayerInfo(null, source);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(player.getName(), source)) {
|
||||||
|
completions.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class PlayerParameterType implements ParameterType<Player> {
|
||||||
|
|
||||||
|
public Player transform(CommandSender sender, String source) {
|
||||||
|
if (sender instanceof Player && (source.equalsIgnoreCase("self") || source.equals(""))) {
|
||||||
|
return ((Player) sender);
|
||||||
|
}
|
||||||
|
|
||||||
|
Player player = Nucleus.getInstance().getServer().getPlayer(source);
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No player with the name " + source + " found.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (player);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
final List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(player.getName(), source)) {
|
||||||
|
completions.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return completions;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,38 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class RankParameterType implements ParameterType<Rank> {
|
||||||
|
|
||||||
|
public Rank transform(CommandSender sender, String source) {
|
||||||
|
Rank rank = Rank.getRankByName(source);
|
||||||
|
|
||||||
|
if (rank == null) {
|
||||||
|
sender.sendMessage(Style.RED + "A rank with that name could not be found.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return rank;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
Rank.getRanks().forEach(rank -> {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(rank.getName(), source)) {
|
||||||
|
completions.add(rank.getName());
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
return (completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.server.ServerType;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class ServerTypeParameterType implements ParameterType<ServerType> {
|
||||||
|
|
||||||
|
public ServerType transform(CommandSender sender, String source) {
|
||||||
|
try {
|
||||||
|
return ServerType.valueOf(source.toUpperCase());
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage(Style.RED + "A server type with that name does not exist.");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (ServerType serverType : ServerType.values()) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(serverType.name(), source)) {
|
||||||
|
completions.add(serverType.name());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,42 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class UUIDParameterType implements ParameterType<UUID> {
|
||||||
|
|
||||||
|
public UUID transform(CommandSender sender, String source) {
|
||||||
|
if (sender instanceof Player && (source.equalsIgnoreCase("self") || source.equals(""))) {
|
||||||
|
return (((Player) sender).getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
return UUID.fromString(source);
|
||||||
|
} catch (Exception e) {
|
||||||
|
sender.sendMessage(Style.RED + "That UUID could not be parsed.");
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (Player player : Nucleus.getInstance().getServer().getOnlinePlayers()) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(player.getName(), source)) {
|
||||||
|
completions.add(player.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,39 @@
|
|||||||
|
package me.joeleoli.nucleus.command.param.defaults;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.command.param.ParameterType;
|
||||||
|
import org.apache.commons.lang.StringUtils;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.World;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
public class WorldParameterType implements ParameterType<World> {
|
||||||
|
|
||||||
|
public World transform(CommandSender sender, String source) {
|
||||||
|
World world = Nucleus.getInstance().getServer().getWorld(source);
|
||||||
|
|
||||||
|
if (world == null) {
|
||||||
|
sender.sendMessage(ChatColor.RED + "No world with the name " + source + " found.");
|
||||||
|
return (null);
|
||||||
|
}
|
||||||
|
|
||||||
|
return (world);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> tabComplete(Player sender, Set<String> flags, String source) {
|
||||||
|
List<String> completions = new ArrayList<>();
|
||||||
|
|
||||||
|
for (World world : Nucleus.getInstance().getServer().getWorlds()) {
|
||||||
|
if (StringUtils.startsWithIgnoreCase(world.getName(), source)) {
|
||||||
|
completions.add(world.getName());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return (completions);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
76
src/main/java/me/joeleoli/nucleus/config/ConfigCursor.java
Normal file
76
src/main/java/me/joeleoli/nucleus/config/ConfigCursor.java
Normal file
@ -0,0 +1,76 @@
|
|||||||
|
package me.joeleoli.nucleus.config;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Set;
|
||||||
|
import java.util.UUID;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.World;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public class ConfigCursor {
|
||||||
|
|
||||||
|
private final FileConfig fileConfig;
|
||||||
|
@Setter private String path;
|
||||||
|
|
||||||
|
public boolean exists() {
|
||||||
|
return this.exists(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean exists(String path) {
|
||||||
|
return this.fileConfig.getConfig().contains(this.path + (path == null ? "" : "." + path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getKeys() {
|
||||||
|
return this.getKeys(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Set<String> getKeys(String path) {
|
||||||
|
return this.fileConfig.getConfig().getConfigurationSection(this.path + (path == null ? "" : "." + path))
|
||||||
|
.getKeys(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getString(String path) {
|
||||||
|
return this.fileConfig.getConfig().getString((this.path == null ? "" : this.path + ".") + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean getBoolean(String path) {
|
||||||
|
return this.fileConfig.getConfig().getBoolean((this.path == null ? "" : this.path + ".") + "." + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getInt(String path) {
|
||||||
|
return this.fileConfig.getConfig().getInt((this.path == null ? "" : this.path + ".") + "." + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getLong(String path) {
|
||||||
|
return this.fileConfig.getConfig().getLong((this.path == null ? "" : this.path + ".") + "." + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<String> getStringList(String path) {
|
||||||
|
return this.fileConfig.getConfig().getStringList((this.path == null ? "" : this.path + ".") + "." + path);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUuid(String path) {
|
||||||
|
return UUID.fromString(this.fileConfig.getConfig().getString(this.path + "." + path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public World getWorld(String path) {
|
||||||
|
return Bukkit.getWorld(this.fileConfig.getConfig().getString(this.path + "." + path));
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(Object value) {
|
||||||
|
this.set(null, value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void set(String path, Object value) {
|
||||||
|
this.fileConfig.getConfig().set(this.path + (path == null ? "" : "." + path), value);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
this.fileConfig.save();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
src/main/java/me/joeleoli/nucleus/config/FileConfig.java
Normal file
46
src/main/java/me/joeleoli/nucleus/config/FileConfig.java
Normal file
@ -0,0 +1,46 @@
|
|||||||
|
package me.joeleoli.nucleus.config;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.configuration.file.YamlConfiguration;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class FileConfig {
|
||||||
|
|
||||||
|
private File file;
|
||||||
|
private FileConfiguration config;
|
||||||
|
|
||||||
|
public FileConfig(JavaPlugin plugin, String fileName) {
|
||||||
|
this.file = new File(plugin.getDataFolder(), fileName);
|
||||||
|
|
||||||
|
if (!this.file.exists()) {
|
||||||
|
this.file.getParentFile().mkdirs();
|
||||||
|
|
||||||
|
if (plugin.getResource(fileName) == null) {
|
||||||
|
try {
|
||||||
|
this.file.createNewFile();
|
||||||
|
} catch (IOException e) {
|
||||||
|
plugin.getLogger().severe("Failed to create new file " + fileName);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
plugin.saveResource(fileName, false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
this.config = YamlConfiguration.loadConfiguration(this.file);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void save() {
|
||||||
|
try {
|
||||||
|
this.config.save(this.file);
|
||||||
|
} catch (IOException e) {
|
||||||
|
Bukkit.getLogger().severe("Could not save config file " + this.file.toString());
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
41
src/main/java/me/joeleoli/nucleus/cooldown/Cooldown.java
Normal file
41
src/main/java/me/joeleoli/nucleus/cooldown/Cooldown.java
Normal file
@ -0,0 +1,41 @@
|
|||||||
|
package me.joeleoli.nucleus.cooldown;
|
||||||
|
|
||||||
|
import lombok.Data;
|
||||||
|
import me.joeleoli.nucleus.util.TimeUtil;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
public class Cooldown {
|
||||||
|
|
||||||
|
private long start = System.currentTimeMillis();
|
||||||
|
private long expire;
|
||||||
|
private boolean notified;
|
||||||
|
|
||||||
|
public Cooldown(long duration) {
|
||||||
|
this.expire = this.start + duration;
|
||||||
|
|
||||||
|
if (duration == 0) {
|
||||||
|
this.notified = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getPassed() {
|
||||||
|
return System.currentTimeMillis() - this.start;
|
||||||
|
}
|
||||||
|
|
||||||
|
public long getRemaining() {
|
||||||
|
return this.expire - System.currentTimeMillis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasExpired() {
|
||||||
|
return System.currentTimeMillis() - this.expire >= 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTimeLeft() {
|
||||||
|
if (this.getRemaining() >= 60_000) {
|
||||||
|
return TimeUtil.millisToRoundedTime(this.getRemaining());
|
||||||
|
} else {
|
||||||
|
return TimeUtil.millisToSeconds(this.getRemaining());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
28
src/main/java/me/joeleoli/nucleus/event/BaseEvent.java
Normal file
28
src/main/java/me/joeleoli/nucleus/event/BaseEvent.java
Normal file
@ -0,0 +1,28 @@
|
|||||||
|
package me.joeleoli.nucleus.event;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
import org.bukkit.event.Event;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
|
||||||
|
;
|
||||||
|
|
||||||
|
public class BaseEvent extends Event {
|
||||||
|
|
||||||
|
private static final HandlerList handlers = new HandlerList();
|
||||||
|
|
||||||
|
public static HandlerList getHandlerList() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public HandlerList getHandlers() {
|
||||||
|
return handlers;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean call() {
|
||||||
|
Nucleus.getInstance().getServer().getPluginManager().callEvent(this);
|
||||||
|
return this instanceof Cancellable && ((Cancellable) this).isCancelled();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package me.joeleoli.nucleus.event;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
import org.bukkit.event.Cancellable;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
@Setter
|
||||||
|
public class CancellableEvent extends BaseEvent implements Cancellable {
|
||||||
|
|
||||||
|
private boolean cancelled;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,17 @@
|
|||||||
|
package me.joeleoli.nucleus.event;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class NucleusPlayerEvent extends PlayerEvent {
|
||||||
|
|
||||||
|
private final NucleusPlayer nucleusPlayer;
|
||||||
|
|
||||||
|
public NucleusPlayerEvent(NucleusPlayer nucleusPlayer) {
|
||||||
|
super(nucleusPlayer.toPlayer());
|
||||||
|
|
||||||
|
this.nucleusPlayer = nucleusPlayer;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
13
src/main/java/me/joeleoli/nucleus/event/PlayerEvent.java
Normal file
13
src/main/java/me/joeleoli/nucleus/event/PlayerEvent.java
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
package me.joeleoli.nucleus.event;
|
||||||
|
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
@Getter
|
||||||
|
public class PlayerEvent extends BaseEvent {
|
||||||
|
|
||||||
|
private Player player;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,5 @@
|
|||||||
|
package me.joeleoli.nucleus.event;
|
||||||
|
|
||||||
|
public class PreShutdownEvent extends CancellableEvent {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package me.joeleoli.nucleus.event.player;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.event.NucleusPlayerEvent;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class RankUpdateEvent extends NucleusPlayerEvent {
|
||||||
|
|
||||||
|
private Rank from;
|
||||||
|
private Rank to;
|
||||||
|
|
||||||
|
public RankUpdateEvent(NucleusPlayer nucleusPlayer, Rank from, Rank to) {
|
||||||
|
super(nucleusPlayer);
|
||||||
|
|
||||||
|
this.from = from;
|
||||||
|
this.to = to;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
27
src/main/java/me/joeleoli/nucleus/jedis/JedisPublisher.java
Normal file
27
src/main/java/me/joeleoli/nucleus/jedis/JedisPublisher.java
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import org.apache.commons.lang3.Validate;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class JedisPublisher {
|
||||||
|
|
||||||
|
private final JedisSettings jedisSettings;
|
||||||
|
|
||||||
|
public void write(String channel, JsonObject payload) {
|
||||||
|
Validate.notNull(Nucleus.getInstance().getNucleusJedis().getPool());
|
||||||
|
|
||||||
|
Nucleus.getInstance().getNucleusJedis().runCommand(redis -> {
|
||||||
|
if (jedisSettings.hasPassword()) {
|
||||||
|
redis.auth(jedisSettings.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
redis.publish(channel, payload.toString());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
22
src/main/java/me/joeleoli/nucleus/jedis/JedisSettings.java
Normal file
22
src/main/java/me/joeleoli/nucleus/jedis/JedisSettings.java
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class JedisSettings {
|
||||||
|
|
||||||
|
private final String address;
|
||||||
|
private final int port;
|
||||||
|
private final String password;
|
||||||
|
|
||||||
|
public JedisSettings(String address, int port, String password) {
|
||||||
|
this.address = address;
|
||||||
|
this.port = port;
|
||||||
|
this.password = password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasPassword() {
|
||||||
|
return this.password != null && !this.password.equals("");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
57
src/main/java/me/joeleoli/nucleus/jedis/JedisSubscriber.java
Normal file
57
src/main/java/me/joeleoli/nucleus/jedis/JedisSubscriber.java
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import com.google.gson.JsonParseException;
|
||||||
|
import com.google.gson.JsonParser;
|
||||||
|
import lombok.Getter;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisPubSub;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class JedisSubscriber {
|
||||||
|
|
||||||
|
private static final JsonParser JSON_PARSER = new JsonParser();
|
||||||
|
|
||||||
|
private final String channel;
|
||||||
|
private final Jedis jedis;
|
||||||
|
private JedisPubSub pubSub;
|
||||||
|
private JedisSubscriptionHandler subscriptionHandler;
|
||||||
|
|
||||||
|
public JedisSubscriber(String channel, JedisSettings settings, JedisSubscriptionHandler subscriptionHandler) {
|
||||||
|
this.channel = channel;
|
||||||
|
this.subscriptionHandler = subscriptionHandler;
|
||||||
|
|
||||||
|
this.pubSub = new JedisPubSub() {
|
||||||
|
@Override
|
||||||
|
public void onMessage(String channel, String message) {
|
||||||
|
try {
|
||||||
|
JsonObject object = JSON_PARSER.parse(message).getAsJsonObject();
|
||||||
|
|
||||||
|
JedisSubscriber.this.subscriptionHandler.handleMessage(object);
|
||||||
|
} catch (JsonParseException e) {
|
||||||
|
System.out.println("Received message that could not be parsed");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
this.jedis = new Jedis(settings.getAddress(), settings.getPort());
|
||||||
|
|
||||||
|
if (settings.hasPassword()) {
|
||||||
|
this.jedis.auth(settings.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
// Run subscription in it's own thread
|
||||||
|
new Thread(() -> this.jedis.subscribe(this.pubSub, this.channel)).start();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void close() {
|
||||||
|
if (this.pubSub != null) {
|
||||||
|
this.pubSub.unsubscribe();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (this.jedis != null) {
|
||||||
|
this.jedis.close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public interface JedisSubscriptionHandler {
|
||||||
|
|
||||||
|
void handleMessage(JsonObject json);
|
||||||
|
|
||||||
|
}
|
72
src/main/java/me/joeleoli/nucleus/jedis/NucleusJedis.java
Normal file
72
src/main/java/me/joeleoli/nucleus/jedis/NucleusJedis.java
Normal file
@ -0,0 +1,72 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import lombok.Getter;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusSubscriptionHandler;
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
import redis.clients.jedis.JedisPool;
|
||||||
|
|
||||||
|
@Getter
|
||||||
|
public class NucleusJedis {
|
||||||
|
|
||||||
|
private JedisSettings settings;
|
||||||
|
private JedisPool pool;
|
||||||
|
private JedisPublisher publisher;
|
||||||
|
private JedisSubscriber subscriber;
|
||||||
|
|
||||||
|
public NucleusJedis(JedisSettings settings) {
|
||||||
|
this.settings = settings;
|
||||||
|
this.pool = new JedisPool(this.settings.getAddress(), this.settings.getPort());
|
||||||
|
|
||||||
|
try (Jedis jedis = this.pool.getResource()) {
|
||||||
|
if (this.settings.hasPassword()) {
|
||||||
|
jedis.auth(this.settings.getPassword());
|
||||||
|
}
|
||||||
|
|
||||||
|
this.publisher = new JedisPublisher(this.settings);
|
||||||
|
this.subscriber = new JedisSubscriber("nucleus", this.settings, new NucleusSubscriptionHandler());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static NucleusJedis getInstance() {
|
||||||
|
return Nucleus.getInstance().getNucleusJedis();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isActive() {
|
||||||
|
return this.pool != null && !this.pool.isClosed();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void write(NucleusPayload payload, JsonObject data) {
|
||||||
|
JsonObject object = new JsonObject();
|
||||||
|
|
||||||
|
object.addProperty("payload", payload.name());
|
||||||
|
object.add("data", data == null ? new JsonObject() : data);
|
||||||
|
|
||||||
|
this.publisher.write("nucleus", object);
|
||||||
|
}
|
||||||
|
|
||||||
|
public <T> T runCommand(RedisCommand<T> redisCommand) {
|
||||||
|
Jedis jedis = this.pool.getResource();
|
||||||
|
T result = null;
|
||||||
|
|
||||||
|
try {
|
||||||
|
result = redisCommand.execute(jedis);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
|
||||||
|
if (jedis != null) {
|
||||||
|
this.pool.returnBrokenResource(jedis);
|
||||||
|
jedis = null;
|
||||||
|
}
|
||||||
|
} finally {
|
||||||
|
if (jedis != null) {
|
||||||
|
this.pool.returnResource(jedis);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis;
|
||||||
|
|
||||||
|
import redis.clients.jedis.Jedis;
|
||||||
|
|
||||||
|
public interface RedisCommand<T> {
|
||||||
|
|
||||||
|
T execute(Jedis redis);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis.handler;
|
||||||
|
|
||||||
|
public enum NucleusPayload {
|
||||||
|
|
||||||
|
PUNISHMENT,
|
||||||
|
RANK_UPDATE,
|
||||||
|
RANK_DELETE,
|
||||||
|
STAFF_JOIN,
|
||||||
|
STAFF_CHAT,
|
||||||
|
PLAYER_UPDATE_RANK,
|
||||||
|
BROADCAST_MESSAGE,
|
||||||
|
CLEAR_PUNISHMENTS,
|
||||||
|
PLAYER_REPORT,
|
||||||
|
PLAYER_REQUEST
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,156 @@
|
|||||||
|
package me.joeleoli.nucleus.jedis.handler;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.UUID;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.jedis.JedisSubscriptionHandler;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.punishment.Punishment;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.util.PlayerUtil;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import me.joeleoli.nucleus.util.TaskUtil;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.Sound;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
|
|
||||||
|
public class NucleusSubscriptionHandler implements JedisSubscriptionHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handleMessage(JsonObject object) {
|
||||||
|
NucleusPayload payload;
|
||||||
|
|
||||||
|
try {
|
||||||
|
payload = NucleusPayload.valueOf(object.get("payload").getAsString());
|
||||||
|
} catch (IllegalArgumentException e) {
|
||||||
|
Nucleus.getInstance().getLogger().warning("Received a payload-type that could not be parsed");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
JsonObject data = object.get("data").getAsJsonObject();
|
||||||
|
|
||||||
|
switch (payload) {
|
||||||
|
case CLEAR_PUNISHMENTS: {
|
||||||
|
NucleusPlayer.getCached().values().forEach(playerData -> playerData.getPunishments().clear());
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PUNISHMENT: {
|
||||||
|
final UUID uuid = UUID.fromString(data.get("punishment_uuid").getAsString());
|
||||||
|
final Punishment punishment = new Punishment();
|
||||||
|
|
||||||
|
punishment.setUuid(uuid);
|
||||||
|
punishment.load();
|
||||||
|
punishment.broadcast(data.get("target_name").getAsString(), data.get("staff_name").getAsString());
|
||||||
|
|
||||||
|
final Player player = Bukkit.getPlayer(punishment.getTargetUuid());
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(punishment.getTargetUuid());
|
||||||
|
|
||||||
|
nucleusPlayer.getPunishments().removeIf(check -> check.getUuid().equals(punishment.getUuid()));
|
||||||
|
nucleusPlayer.getPunishments().add(punishment);
|
||||||
|
|
||||||
|
if (player == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nucleusPlayer.getActiveBan() != null) {
|
||||||
|
final String kickMessage = punishment.getType().getMessage()
|
||||||
|
.replace("%PLAYER%", "SHARED")
|
||||||
|
.replace("%EXPIRATION%", punishment.getTimeLeft());
|
||||||
|
|
||||||
|
TaskUtil.run(() -> player.kickPlayer(kickMessage));
|
||||||
|
|
||||||
|
for (Player alt : Nucleus.getInstance().getServer().getOnlinePlayers()) {
|
||||||
|
if (player.getAddress().getAddress().getHostAddress()
|
||||||
|
.equalsIgnoreCase(alt.getAddress().getAddress().getHostAddress())) {
|
||||||
|
TaskUtil.run(() -> alt.kickPlayer(kickMessage));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (nucleusPlayer.getActiveMute() != null) {
|
||||||
|
player.sendMessage(Style.RED + "You have been muted.");
|
||||||
|
player.sendMessage(Style.RED + "Time left: " + nucleusPlayer.getActiveMute().getTimeLeft());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RANK_DELETE: {
|
||||||
|
Rank rank = Rank.getRankByName(data.get("rank_name").getAsString());
|
||||||
|
|
||||||
|
if (rank != null) {
|
||||||
|
rank.delete(false);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case RANK_UPDATE: {
|
||||||
|
Rank rank = Rank.getRankByName(data.get("rank_name").getAsString());
|
||||||
|
|
||||||
|
if (rank == null) {
|
||||||
|
rank = new Rank(data.get("rank_name").getAsString());
|
||||||
|
}
|
||||||
|
|
||||||
|
rank.load(Nucleus.getInstance().getNucleusMongo().getRank(rank.getName()));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case BROADCAST_MESSAGE: {
|
||||||
|
final String message = Style.GOLD + Style.BOLD + "[MXD] " + Style.YELLOW +
|
||||||
|
Style.translate(data.get("message").getAsString());
|
||||||
|
|
||||||
|
Bukkit.getOnlinePlayers().forEach(player -> {
|
||||||
|
player.playSound(player.getLocation(), Sound.NOTE_PLING, 1.0F, 1.0F);
|
||||||
|
player.sendMessage(message);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STAFF_JOIN: {
|
||||||
|
final String server = data.get("server").getAsString();
|
||||||
|
final String playerName = data.get("player_name").getAsString();
|
||||||
|
|
||||||
|
PlayerUtil.messageStaff(Style.formatStaffJoinMessage(playerName, server));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case STAFF_CHAT: {
|
||||||
|
final String server = data.get("server").getAsString();
|
||||||
|
final String playerName = data.get("player_name").getAsString();
|
||||||
|
final String message = data.get("message").getAsString();
|
||||||
|
|
||||||
|
PlayerUtil.messageStaff(Style.formatStaffChatMessage(server, playerName, message));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PLAYER_UPDATE_RANK: {
|
||||||
|
final UUID uuid = UUID.fromString(data.get("player_uuid").getAsString());
|
||||||
|
final Player player = Bukkit.getPlayer(uuid);
|
||||||
|
|
||||||
|
if (player != null) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final Rank rank = Rank.getRankByName(data.get("rank_name").getAsString());
|
||||||
|
|
||||||
|
if (rank != null && !nucleusPlayer.getActiveRank().equals(rank)) {
|
||||||
|
nucleusPlayer.setRank(rank);
|
||||||
|
|
||||||
|
player.sendMessage(
|
||||||
|
Style.translate("&aYour rank has been updated to: &r" + rank.getColoredName()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PLAYER_REPORT: {
|
||||||
|
final String server = data.get("server").getAsString();
|
||||||
|
final String senderName = data.get("sender_name").getAsString();
|
||||||
|
final String reportedName = data.get("reported_name").getAsString();
|
||||||
|
final String reportedReason = data.get("report_reason").getAsString();
|
||||||
|
|
||||||
|
PlayerUtil.messageStaff(Style.formatReportMessage(senderName, reportedName, reportedReason, server));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case PLAYER_REQUEST: {
|
||||||
|
final String server = data.get("server").getAsString();
|
||||||
|
final String senderName = data.get("sender_name").getAsString();
|
||||||
|
final String requestReason = data.get("request_reason").getAsString();
|
||||||
|
|
||||||
|
PlayerUtil.messageStaff(Style.formatRequestMessage(senderName, requestReason, server));
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
39
src/main/java/me/joeleoli/nucleus/json/JsonChain.java
Normal file
39
src/main/java/me/joeleoli/nucleus/json/JsonChain.java
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
package me.joeleoli.nucleus.json;
|
||||||
|
|
||||||
|
import com.google.gson.JsonElement;
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public class JsonChain {
|
||||||
|
|
||||||
|
private JsonObject json = new JsonObject();
|
||||||
|
|
||||||
|
public JsonChain addProperty(String property, String value) {
|
||||||
|
this.json.addProperty(property, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonChain addProperty(String property, Number value) {
|
||||||
|
this.json.addProperty(property, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonChain addProperty(String property, Boolean value) {
|
||||||
|
this.json.addProperty(property, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonChain addProperty(String property, Character value) {
|
||||||
|
this.json.addProperty(property, value);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonChain add(String property, JsonElement element) {
|
||||||
|
this.json.add(property, element);
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public JsonObject get() {
|
||||||
|
return this.json;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,9 @@
|
|||||||
|
package me.joeleoli.nucleus.json;
|
||||||
|
|
||||||
|
import com.google.gson.JsonObject;
|
||||||
|
|
||||||
|
public interface JsonSerializer {
|
||||||
|
|
||||||
|
JsonObject toJson();
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,25 @@
|
|||||||
|
package me.joeleoli.nucleus.listener;
|
||||||
|
|
||||||
|
import org.bukkit.GameMode;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.PlayerDropItemEvent;
|
||||||
|
|
||||||
|
public class GriefListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
if (event.getEntity().getGameMode() == GameMode.CREATIVE) {
|
||||||
|
event.getDrops().clear();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDropItem(PlayerDropItemEvent event) {
|
||||||
|
if (event.getPlayer().getGameMode() == GameMode.CREATIVE) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,45 @@
|
|||||||
|
package me.joeleoli.nucleus.listener;
|
||||||
|
|
||||||
|
import me.joeleoli.nucleus.util.ClassUtil;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.plugin.Plugin;
|
||||||
|
|
||||||
|
public class ListenerHandler {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Registers all listeners from the given package with the given plugin.
|
||||||
|
*
|
||||||
|
* @param plugin The plugin responsible for these listeners. This is here because the .getClassesInPackage
|
||||||
|
* method requires it (for no real reason)
|
||||||
|
* @param packageName The package to load listeners from. Example: "me.joeleoli.nucleus.listeners"
|
||||||
|
*/
|
||||||
|
public static void loadListenersFromPackage(Plugin plugin, String packageName) {
|
||||||
|
for (Class<?> clazz : ClassUtil.getClassesInPackage(plugin, packageName)) {
|
||||||
|
if (isListener(clazz)) {
|
||||||
|
try {
|
||||||
|
plugin.getServer().getPluginManager().registerEvents((Listener) clazz.newInstance(), plugin);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if the given class implements the {@link Listener} interface.
|
||||||
|
*
|
||||||
|
* @param clazz The class to check
|
||||||
|
*
|
||||||
|
* @return If the class implements the {@link Listener} interface
|
||||||
|
*/
|
||||||
|
public static boolean isListener(Class<?> clazz) {
|
||||||
|
for (Class<?> interfaze : clazz.getInterfaces()) {
|
||||||
|
if (interfaze == Listener.class) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
297
src/main/java/me/joeleoli/nucleus/listener/PlayerListener.java
Normal file
297
src/main/java/me/joeleoli/nucleus/listener/PlayerListener.java
Normal file
@ -0,0 +1,297 @@
|
|||||||
|
package me.joeleoli.nucleus.listener;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.PacketType;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedChatComponent;
|
||||||
|
import me.joeleoli.nucleus.Nucleus;
|
||||||
|
import me.joeleoli.nucleus.NucleusAPI;
|
||||||
|
import me.joeleoli.nucleus.board.Board;
|
||||||
|
import me.joeleoli.nucleus.cooldown.Cooldown;
|
||||||
|
import me.joeleoli.nucleus.jedis.handler.NucleusPayload;
|
||||||
|
import me.joeleoli.nucleus.json.JsonChain;
|
||||||
|
import me.joeleoli.nucleus.log.CommandLog;
|
||||||
|
import me.joeleoli.nucleus.log.ConnectionLog;
|
||||||
|
import me.joeleoli.nucleus.log.LogQueue;
|
||||||
|
import me.joeleoli.nucleus.log.PublicMessageLog;
|
||||||
|
import me.joeleoli.nucleus.nametag.NameTagHandler;
|
||||||
|
import me.joeleoli.nucleus.packet.Packet;
|
||||||
|
import me.joeleoli.nucleus.player.NucleusPlayer;
|
||||||
|
import me.joeleoli.nucleus.player.DefinedSetting;
|
||||||
|
import me.joeleoli.nucleus.punishment.Punishment;
|
||||||
|
import me.joeleoli.nucleus.punishment.SharedBan;
|
||||||
|
import me.joeleoli.nucleus.rank.Rank;
|
||||||
|
import me.joeleoli.nucleus.util.PlayerUtil;
|
||||||
|
import me.joeleoli.nucleus.util.Style;
|
||||||
|
import me.joeleoli.nucleus.uuid.UUIDCache;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.EventPriority;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.entity.EntityDamageEvent;
|
||||||
|
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerChatEvent;
|
||||||
|
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
import org.bukkit.permissions.PermissionAttachment;
|
||||||
|
|
||||||
|
public class PlayerListener implements Listener {
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onCommandProcess(PlayerCommandPreprocessEvent event) {
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final String lowercase = event.getMessage().toLowerCase();
|
||||||
|
|
||||||
|
if (lowercase.startsWith("//calc") ||
|
||||||
|
lowercase.startsWith("//eval") ||
|
||||||
|
lowercase.startsWith("//solve") ||
|
||||||
|
lowercase.startsWith("/bukkit:") ||
|
||||||
|
lowercase.startsWith("/me") ||
|
||||||
|
lowercase.startsWith("/bukkit:me") ||
|
||||||
|
lowercase.startsWith("/minecraft:") ||
|
||||||
|
lowercase.startsWith("/minecraft:me")) {
|
||||||
|
player.sendMessage(Style.RED + "You cannot perform this command.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (NucleusPlayer.getByUuid(event.getPlayer().getUniqueId()).isFrozen()) {
|
||||||
|
if (!(lowercase.startsWith("/msg") || lowercase.startsWith("/r") || lowercase.startsWith("/reply"))) {
|
||||||
|
player.sendMessage(Style.RED + "You cannot use commands while frozen.");
|
||||||
|
event.setCancelled(true);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogQueue.getCommandLogs().add(new CommandLog(
|
||||||
|
player.getUniqueId(),
|
||||||
|
event.getMessage(),
|
||||||
|
System.currentTimeMillis()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
|
||||||
|
if (!Nucleus.getInstance().isLoaded()) {
|
||||||
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
|
event.setKickMessage(Style.RED + "The server is starting...");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(event.getUniqueId());
|
||||||
|
|
||||||
|
nucleusPlayer.setName(event.getName());
|
||||||
|
nucleusPlayer.setSessionLoginTimestamp(System.currentTimeMillis());
|
||||||
|
nucleusPlayer.setIpAddress(event.getAddress().getHostAddress());
|
||||||
|
|
||||||
|
if (!nucleusPlayer.isLoaded()) {
|
||||||
|
nucleusPlayer.load();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!nucleusPlayer.isLoaded()) {
|
||||||
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
|
event.setKickMessage(Style.API_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
nucleusPlayer.searchForAlts();
|
||||||
|
|
||||||
|
Punishment activeBan = nucleusPlayer.getActiveBan();
|
||||||
|
|
||||||
|
if (activeBan != null) {
|
||||||
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
|
||||||
|
event.setKickMessage(activeBan.getType().getMessage().replace("%EXPIRATION%", activeBan.getTimeLeft()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
SharedBan sharedBan = nucleusPlayer.getSharedBan();
|
||||||
|
|
||||||
|
if (sharedBan == null || !sharedBan.getPunishment().isActive()) {
|
||||||
|
nucleusPlayer.findSharedBan();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (sharedBan != null) {
|
||||||
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_BANNED);
|
||||||
|
event.setKickMessage(sharedBan.getPunishment().getType().getSharedMessage()
|
||||||
|
.replace("%PLAYER%", sharedBan.getAltName())
|
||||||
|
.replace("%EXPIRATION%", sharedBan.getPunishment().getTimeLeft())
|
||||||
|
);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
|
||||||
|
event.setKickMessage(Style.API_FAILED);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getNucleusJedis().isActive()) {
|
||||||
|
UUIDCache.update(event.getName(), event.getUniqueId());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.HIGHEST)
|
||||||
|
public void onAsyncPlayerPreLoginHighest(AsyncPlayerPreLoginEvent event) {
|
||||||
|
LogQueue.getConnectionLogs()
|
||||||
|
.add(new ConnectionLog(event.getUniqueId(), event.getAddress().getHostAddress(), event.getLoginResult(),
|
||||||
|
event.getKickMessage(), System.currentTimeMillis()
|
||||||
|
));
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerJoin(PlayerJoinEvent event) {
|
||||||
|
event.setJoinMessage(null);
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final PermissionAttachment attachment = player.addAttachment(Nucleus.getInstance());
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getBoardManager() != null) {
|
||||||
|
Nucleus.getInstance().getBoardManager().getPlayerBoards().put(
|
||||||
|
player.getUniqueId(),
|
||||||
|
new Board(Nucleus.getInstance(), player, Nucleus.getInstance().getBoardManager().getAdapter())
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (nucleusPlayer.getActiveRank() == null) {
|
||||||
|
System.out.println("DEBUG: ACTIVE RANK NULL");
|
||||||
|
nucleusPlayer.setRank(Rank.getDefaultRank());
|
||||||
|
}
|
||||||
|
|
||||||
|
nucleusPlayer.getActiveRank().getEffectivePermissions().forEach(permission -> {
|
||||||
|
attachment.setPermission(permission, true);
|
||||||
|
});
|
||||||
|
|
||||||
|
player.recalculatePermissions();
|
||||||
|
|
||||||
|
nucleusPlayer.refreshDisplayName();
|
||||||
|
|
||||||
|
if (player.hasPermission("nucleus.staff")) {
|
||||||
|
Nucleus.getInstance().getNucleusJedis().write(
|
||||||
|
NucleusPayload.STAFF_JOIN,
|
||||||
|
new JsonChain()
|
||||||
|
.addProperty("server", Nucleus.getInstance().getNucleusConfig().getServerId())
|
||||||
|
.addProperty("player_name", player.getDisplayName())
|
||||||
|
.get()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
NameTagHandler.setup(event.getPlayer());
|
||||||
|
|
||||||
|
final String json =
|
||||||
|
"{\"text\":\"\",\"extra\":[{\"text\":\"\\u00a70\\u00a70\\u00a71\\u00a72\\u00a73\\u00a74\\u00a75\\u00a76\\u00a77\\u00a7e\\u00a7f\"}]}";
|
||||||
|
final Packet packet = new Packet(PacketType.Play.Server.CHAT);
|
||||||
|
|
||||||
|
packet.getChatComponents().write(0, WrappedChatComponent.fromJson(json));
|
||||||
|
packet.send(event.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(priority = EventPriority.LOWEST)
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
event.setQuitMessage(null);
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getBoardManager() != null) {
|
||||||
|
Nucleus.getInstance().getBoardManager().getPlayerBoards().remove(event.getPlayer().getUniqueId());
|
||||||
|
}
|
||||||
|
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getCached().remove(event.getPlayer().getUniqueId());
|
||||||
|
|
||||||
|
if (nucleusPlayer != null) {
|
||||||
|
nucleusPlayer.save();
|
||||||
|
|
||||||
|
if (nucleusPlayer.isFrozen()) {
|
||||||
|
PlayerUtil.messageStaff(Style.GOLD + Style.BOLD + Style.UNICODE_CAUTION + " " +
|
||||||
|
Style.PINK + nucleusPlayer.getName() + Style.YELLOW +
|
||||||
|
" disconnected while frozen.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
|
||||||
|
public void onEntityDamage(EntityDamageEvent event) {
|
||||||
|
if (event.getEntity() instanceof Player) {
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(event.getEntity().getUniqueId());
|
||||||
|
|
||||||
|
if (nucleusPlayer.isFrozen()) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerDeath(PlayerDeathEvent event) {
|
||||||
|
event.setDeathMessage(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOW)
|
||||||
|
public void onAsyncPlayerChat(AsyncPlayerChatEvent event) {
|
||||||
|
event.setCancelled(true);
|
||||||
|
|
||||||
|
final Player player = event.getPlayer();
|
||||||
|
|
||||||
|
if (Nucleus.getInstance().getChatManager().isChatMuted() && !player.hasPermission("nucleus.staff")) {
|
||||||
|
player.sendMessage(Style.RED + "Public chat is currently muted.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!NucleusAPI.<Boolean>getSetting(player, DefinedSetting.GlobalPlayerSetting.RECEIVE_GLOBAL_MESSAGES)) {
|
||||||
|
player.sendMessage(Style.RED + "You can't chat while you have globla chat disabled.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
final NucleusPlayer nucleusPlayer = NucleusPlayer.getByUuid(player.getUniqueId());
|
||||||
|
final String message = event.getMessage();
|
||||||
|
final Punishment mute = nucleusPlayer.getActiveMute();
|
||||||
|
|
||||||
|
if (mute != null) {
|
||||||
|
if (mute.isPermanent()) {
|
||||||
|
player.sendMessage(Style.RED + "You are permanently muted.");
|
||||||
|
} else {
|
||||||
|
player.sendMessage(Style.RED + "You are currently muted for another " + mute.getTimeLeft() + ".");
|
||||||
|
}
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.hasPermission("nucleus.chatdelay.bypass")) {
|
||||||
|
if (!nucleusPlayer.getChatCooldown().hasExpired()) {
|
||||||
|
player.sendMessage(Style.RED + "You can chat again in " + Style.BOLD +
|
||||||
|
nucleusPlayer.getChatCooldown().getTimeLeft() + "s" + Style.RED + ".");
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
nucleusPlayer
|
||||||
|
.setChatCooldown(new Cooldown(Nucleus.getInstance().getChatManager().getDelayTime() * 1000));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!player.hasPermission("nucleus.chatfilter.bypass")) {
|
||||||
|
if (Nucleus.getInstance().getChatManager().shouldFilter(event.getMessage())) {
|
||||||
|
player.sendMessage(Style.RED + "Your message was filtered.");
|
||||||
|
PlayerUtil.messageStaff(Style.formatFilteredPublicMessage(player, event.getMessage()));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Player receiver : Bukkit.getOnlinePlayers()) {
|
||||||
|
final NucleusPlayer receiverData = NucleusPlayer.getByUuid(receiver.getUniqueId());
|
||||||
|
|
||||||
|
if (receiverData.getSettings().getBoolean(DefinedSetting.GlobalPlayerSetting.RECEIVE_GLOBAL_MESSAGES) &&
|
||||||
|
!receiverData.isIgnored(player.getUniqueId())) {
|
||||||
|
receiver.sendMessage(
|
||||||
|
Nucleus.getInstance().getChatManager().getChatFormat()
|
||||||
|
.format(event.getPlayer(), receiver, message));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
LogQueue.getPublicMessageLogs().add(
|
||||||
|
new PublicMessageLog(
|
||||||
|
player.getUniqueId(),
|
||||||
|
message,
|
||||||
|
System.currentTimeMillis()
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user