Yikess shouldnt skid

This commit is contained in:
disclearing 2019-08-17 20:32:19 +01:00
parent 1f8daebd41
commit cf13050890
446 changed files with 11724 additions and 2 deletions

502
Core.ipr Normal file
View File

@ -0,0 +1,502 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="CompilerConfiguration">
<annotationProcessing>
<profile name="Annotation profile for core" enabled="true">
<sourceOutputDir name="target/generated-sources/annotations" />
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
<outputRelativeToContentRoot value="true" />
<processorPath useClasspath="false">
<entry name="$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar" />
</processorPath>
<module name="core" />
</profile>
</annotationProcessing>
<bytecodeTargetLevel>
<module name="core" target="1.8" />
</bytecodeTargetLevel>
</component>
<component name="ExternalStorageConfigurationManager" enabled="true" />
<component name="InspectionProjectProfileManager">
<profile version="1.0">
<option name="myName" value="Project Default" />
</profile>
<version value="1.0" />
</component>
<component name="JavacSettings">
<option name="ADDITIONAL_OPTIONS_OVERRIDE">
<module name="core" options="" />
</option>
</component>
<component name="MavenProjectsManager">
<option name="originalFiles">
<list>
<option value="$PROJECT_DIR$/pom.xml" />
</list>
</option>
</component>
<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>
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/core.iml" filepath="$PROJECT_DIR$/core.iml" />
</modules>
</component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/out" />
</component>
<component name="VcsDirectoryMappings">
<mapping directory="$PROJECT_DIR$" vcs="Git" />
</component>
<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>
<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>
<library name="Maven: com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.4.0-SNAPSHOT/ProtocolLib-API-4.4.0-20180922.161950-42.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.4.0-SNAPSHOT/ProtocolLib-API-4.4.0-20180922.161950-42-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib-API/4.4.0-SNAPSHOT/ProtocolLib-API-4.4.0-20180922.161950-42-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: com.comphenix.protocol:ProtocolLib:4.4.0-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib/4.4.0-SNAPSHOT/ProtocolLib-4.4.0-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib/4.4.0-SNAPSHOT/ProtocolLib-4.4.0-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/comphenix/protocol/ProtocolLib/4.4.0-SNAPSHOT/ProtocolLib-4.4.0-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<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>
<library name="Maven: com.google.guava:guava:21.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/google/guava/guava/21.0/guava-21.0-sources.jar!/" />
</SOURCES>
</library>
<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>
<library name="Maven: com.minexd:pidgin:1.0-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/minexd/pidgin/1.0-SNAPSHOT/pidgin-1.0-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/minexd/pidgin/1.0-SNAPSHOT/pidgin-1.0-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/minexd/pidgin/1.0-SNAPSHOT/pidgin-1.0-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: com.qrakn:honcho:1.0-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/honcho/1.0-SNAPSHOT/honcho-1.0-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/honcho/1.0-SNAPSHOT/honcho-1.0-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/honcho/1.0-SNAPSHOT/honcho-1.0-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: com.qrakn:phoenix-lang:1.0-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/phoenix-lang/1.0-SNAPSHOT/phoenix-lang-1.0-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/phoenix-lang/1.0-SNAPSHOT/phoenix-lang-1.0-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/com/qrakn/phoenix-lang/1.0-SNAPSHOT/phoenix-lang-1.0-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<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>
<library name="Maven: gg.manny:genericspigot-api:1.7.10-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot-api/1.7.10-R0.1-SNAPSHOT/genericspigot-api-1.7.10-R0.1-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot-api/1.7.10-R0.1-SNAPSHOT/genericspigot-api-1.7.10-R0.1-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot-api/1.7.10-R0.1-SNAPSHOT/genericspigot-api-1.7.10-R0.1-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: gg.manny:genericspigot:1.7.10-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot/1.7.10-R0.1-SNAPSHOT/genericspigot-1.7.10-R0.1-SNAPSHOT.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot/1.7.10-R0.1-SNAPSHOT/genericspigot-1.7.10-R0.1-SNAPSHOT-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/gg/manny/genericspigot/1.7.10-R0.1-SNAPSHOT/genericspigot-1.7.10-R0.1-SNAPSHOT-sources.jar!/" />
</SOURCES>
</library>
<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>
<library name="Maven: net.milkbowl.vault:VaultAPI:1.7">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/VaultAPI/1.7/VaultAPI-1.7.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/VaultAPI/1.7/VaultAPI-1.7-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/net/milkbowl/vault/VaultAPI/1.7/VaultAPI-1.7-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.apache.commons:commons-pool2:2.4.3">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.3/commons-pool2-2.4.3.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.3/commons-pool2-2.4.3-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/apache/commons/commons-pool2/2.4.3/commons-pool2-2.4.3-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/bukkit/bukkit/1.13.1-R0.1-SNAPSHOT/bukkit-1.13.1-R0.1-20181022.190036-99-sources.jar!/" />
</SOURCES>
</library>
<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>
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.31/kotlin-stdlib-common-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.31/kotlin-stdlib-common-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-common/1.3.31/kotlin-stdlib-common-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.31/kotlin-stdlib-jdk7-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.31/kotlin-stdlib-jdk7-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk7/1.3.31/kotlin-stdlib-jdk7-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.31/kotlin-stdlib-jdk8-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.31/kotlin-stdlib-jdk8-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib-jdk8/1.3.31/kotlin-stdlib-jdk8-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.31/kotlin-stdlib-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.31/kotlin-stdlib-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-stdlib/1.3.31/kotlin-stdlib-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains.kotlin:kotlin-test-common:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test-common/1.3.31/kotlin-test-common-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test-common/1.3.31/kotlin-test-common-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test-common/1.3.31/kotlin-test-common-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains.kotlin:kotlin-test:1.3.31">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test/1.3.31/kotlin-test-1.3.31.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test/1.3.31/kotlin-test-1.3.31-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/kotlin/kotlin-test/1.3.31/kotlin-test-1.3.31-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.jetbrains:annotations:13.0">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/jetbrains/annotations/13.0/annotations-13.0-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.mongodb:mongo-java-driver:3.8.2">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.2/mongo-java-driver-3.8.2.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.2/mongo-java-driver-3.8.2-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/mongodb/mongo-java-driver/3.8.2/mongo-java-driver-3.8.2-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.projectlombok:lombok:1.18.8">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.8/lombok-1.18.8.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.8/lombok-1.18.8-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/projectlombok/lombok/1.18.8/lombok-1.18.8-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.slf4j:slf4j-api:1.7.22">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/slf4j/slf4j-api/1.7.22/slf4j-api-1.7.22-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: org.yaml:snakeyaml:1.21">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.21/snakeyaml-1.21.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.21/snakeyaml-1.21-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/org/yaml/snakeyaml/1.21/snakeyaml-1.21-sources.jar!/" />
</SOURCES>
</library>
<library name="Maven: redis.clients:jedis:3.0.1">
<CLASSES>
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/3.0.1/jedis-3.0.1.jar!/" />
</CLASSES>
<JAVADOC>
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/3.0.1/jedis-3.0.1-javadoc.jar!/" />
</JAVADOC>
<SOURCES>
<root url="jar://$MAVEN_REPOSITORY$/redis/clients/jedis/3.0.1/jedis-3.0.1-sources.jar!/" />
</SOURCES>
</library>
</component>
</project>

1047
Core.iws Normal file

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1,2 @@
# scoreboardapi-skid-of-zoot
don't fuck with my friends server pussy
# Core
# Core

77
core.iml Normal file
View File

@ -0,0 +1,77 @@
<?xml version="1.0" encoding="UTF-8"?>
<module org.jetbrains.idea.maven.project.MavenProjectsManager.isMavenModule="true" type="JAVA_MODULE" version="4">
<component name="AutoImportedSourceRoots">
<option name="directories">
<list>
<option value="src/main/java" />
<option value="src/main/kotlin" />
<option value="src/main/resources" />
</list>
</option>
</component>
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="3" platform="JVM 1.8" useProjectSettings="false">
<compilerSettings />
<compilerArguments>
<option name="jvmTarget" value="1.8" />
<option name="languageVersion" value="1.3" />
<option name="apiVersion" value="1.3" />
<option name="pluginOptions">
<array />
</option>
<option name="pluginClasspaths">
<array />
</option>
<option name="errors">
<ArgumentParseErrors />
</option>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_8">
<output url="file://$MODULE_DIR$/target/classes" />
<output-test url="file://$MODULE_DIR$/target/test-classes" />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/src/main/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/target/generated-sources/annotations" isTestSource="false" generated="true" />
<sourceFolder url="file://$MODULE_DIR$/src/main/java" isTestSource="false" />
<sourceFolder url="file://$MODULE_DIR$/src/main/kotlin" isTestSource="false" />
<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: gg.manny:genericspigot-api:1.7.10-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: gg.manny:genericspigot:1.7.10-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.projectlombok:lombok:1.18.8" level="project" />
<orderEntry type="library" name="Maven: redis.clients:jedis:3.0.1" level="project" />
<orderEntry type="library" name="Maven: org.slf4j:slf4j-api:1.7.22" level="project" />
<orderEntry type="library" name="Maven: org.apache.commons:commons-pool2:2.4.3" level="project" />
<orderEntry type="library" name="Maven: com.qrakn:honcho:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.google.code.gson:gson:2.8.5" level="project" />
<orderEntry type="library" name="Maven: org.mongodb:mongo-java-driver:3.8.2" level="project" />
<orderEntry type="library" name="Maven: com.qrakn:phoenix-lang:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib:4.4.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.protocol:ProtocolLib-API:4.4.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: cglib:cglib-nodep:3.2.5" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.comphenix.executors:BukkitExecutors:1.1-SNAPSHOT" level="project" />
<orderEntry type="library" name="Maven: com.minexd:pidgin:1.0-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: net.milkbowl.vault:VaultAPI:1.7" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.bukkit:bukkit:1.13.1-R0.1-SNAPSHOT" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: commons-lang:commons-lang:2.6" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.googlecode.json-simple:json-simple:1.1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: junit:junit:4.10" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.hamcrest:hamcrest-core:1.1" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.guava:guava:21.0" level="project" />
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.21" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.31" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib:1.3.31" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-common:1.3.31" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains:annotations:13.0" level="project" />
<orderEntry type="library" name="Maven: org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test:1.3.31" level="project" />
<orderEntry type="library" scope="TEST" name="Maven: org.jetbrains.kotlin:kotlin-test-common:1.3.31" level="project" />
</component>
</module>

Binary file not shown.

Binary file not shown.

BIN
lib/pidgin-1.0-SNAPSHOT.jar Normal file

Binary file not shown.

218
pom.xml Normal file
View File

@ -0,0 +1,218 @@
<?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>net.centilehcf</groupId>
<artifactId>core</artifactId>
<version>1.2-SNAPSHOT</version>
<properties>
<kotlin.version>1.3.31</kotlin.version>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
</properties>
<build>
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<plugin>
<groupId>pl.project13.maven</groupId>
<artifactId>git-commit-id-plugin</artifactId>
<version>2.2.2</version>
<executions>
<execution>
<goals>
<goal>revision</goal>
</goals>
</execution>
</executions>
<configuration>
<dateFormat>dd.MM.yyyy HH:mm:ss</dateFormat>
<verbose>false</verbose>
<dotGitDirectory>${project.basedir}/.git</dotGitDirectory>
<generateGitPropertiesFile>false</generateGitPropertiesFile>
<failOnNoGitDirectory>true</failOnNoGitDirectory>
</configuration>
</plugin>
<plugin>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<version>${kotlin.version}</version>
<executions>
<execution>
<id>compile</id>
<phase>compile</phase>
<goals>
<goal>compile</goal>
</goals>
<configuration>
<sourceDirs>
<source>src/main/java</source>
<source>src/main/kotlin</source>
<source>src/main/resources</source>
</sourceDirs>
</configuration>
</execution>
<execution>
<id>test-compile</id>
<phase>test-compile</phase>
<goals>
<goal>test-compile</goal>
</goals>
</execution>
</executions>
<configuration>
<jvmTarget>1.8</jvmTarget>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.5.1</version>
<executions>
<!-- Replacing default-compile as it is treated specially by maven -->
<execution>
<id>default-compile</id>
<phase>none</phase>
</execution>
<!-- Replacing default-testCompile as it is treated specially by maven -->
<execution>
<id>default-testCompile</id>
<phase>none</phase>
</execution>
<execution>
<id>java-compile</id>
<phase>compile</phase>
<goals> <goal>compile</goal> </goals>
</execution>
<execution>
<id>java-test-compile</id>
<phase>test-compile</phase>
<goals> <goal>testCompile</goal> </goals>
</execution>
</executions>
<configuration>
<source>1.8</source>
<target>1.8</target>
<annotationProcessorPaths>
<path>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>LATEST</version>
</path>
</annotationProcessorPaths>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-assembly-plugin</artifactId>
<version>2.2-beta-5</version>
<executions>
<execution>
<id>make-assembly</id>
<phase>package</phase>
<goals> <goal>single</goal> </goals>
<configuration>
<appendAssemblyId>false</appendAssemblyId>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</build>
<repositories>
<repository>
<id>spigot-repo</id>
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
</repository>
<repository>
<id>vault-repo</id>
<url>http://nexus.hc.to/content/repositories/pub_releases</url>
</repository>
</repositories>
<dependencies>
<dependency>
<groupId>gg.manny</groupId>
<artifactId>genericspigot-api</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>gg.manny</groupId>
<artifactId>genericspigot</artifactId>
<version>1.7.10-R0.1-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>LATEST</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>redis.clients</groupId>
<artifactId>jedis</artifactId>
<version>3.0.1</version>
</dependency>
<dependency>
<groupId>com.qrakn</groupId>
<artifactId>honcho</artifactId>
<version>1.0-SNAPSHOT</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.mongodb</groupId>
<artifactId>mongo-java-driver</artifactId>
<version>3.8.2</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.qrakn</groupId>
<artifactId>phoenix-lang</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.4.0-SNAPSHOT</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>com.minexd</groupId>
<artifactId>pidgin</artifactId>
<version>1.0-SNAPSHOT</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>net.milkbowl.vault</groupId>
<artifactId>VaultAPI</artifactId>
<version>1.7</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-stdlib-jdk8</artifactId>
<version>${kotlin.version}</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-test</artifactId>
<version>${kotlin.version}</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,334 @@
package net.centilehcf.core;
import com.comphenix.protocol.ProtocolLibrary;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;
import com.minexd.pidgin.Pidgin;
import net.centilehcf.core.chat.Chat;
import net.centilehcf.core.chat.command.MuteChatCommand;
import net.centilehcf.core.chat.listener.ChatListener;
import net.centilehcf.core.essentials.Essentials;
import net.centilehcf.core.essentials.command.*;
import net.centilehcf.core.essentials.listener.DurabilityListener;
import net.centilehcf.core.essentials.listener.EssentialsListener;
import net.centilehcf.core.hook.VaultProvider;
import net.centilehcf.core.network.NetworkPacketListener;
import net.centilehcf.core.network.packet.*;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.prefix.PrefixHandler;
import net.centilehcf.core.prefix.command.*;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.profile.ProfileTypeAdapter;
import net.centilehcf.core.profile.command.OptionsCommand;
import net.centilehcf.core.profile.command.StaffChatToggleCommand;
import net.centilehcf.core.profile.command.individualperms.AddIndividualPermissionCommand;
import net.centilehcf.core.profile.command.individualperms.ListIndividualPermissionsCommand;
import net.centilehcf.core.profile.command.individualperms.RemoveIndividualPermissionCommand;
import net.centilehcf.core.profile.grant.command.ClearGrantsCommand;
import net.centilehcf.core.profile.grant.command.GrantCommand;
import net.centilehcf.core.profile.grant.command.GrantsCommand;
import net.centilehcf.core.profile.grant.command.SetRankCommand;
import net.centilehcf.core.profile.grant.listener.GrantListener;
import net.centilehcf.core.profile.ProfileListener;
import net.centilehcf.core.profile.option.commands.TogglePrivateMessagesCommand;
import net.centilehcf.core.profile.punishment.command.*;
import net.centilehcf.core.profile.command.AltsCommand;
import net.centilehcf.core.profile.punishment.listener.PunishmentListener;
import net.centilehcf.core.rank.Rank;
import net.centilehcf.core.rank.RankTypeAdapter;
import net.centilehcf.core.profile.command.StaffChatCommand;
import net.centilehcf.core.rank.command.*;
import net.centilehcf.core.tab.TabAdapter;
import net.centilehcf.core.tab.TabEngine;
import net.centilehcf.core.tab.test.TestLayoutProvider;
import net.centilehcf.core.util.CC;
import net.centilehcf.core.util.TaskUtil;
import net.centilehcf.core.util.duration.Duration;
import net.centilehcf.core.util.duration.DurationTypeAdapter;
import net.centilehcf.core.util.menu.MenuListener;
import net.centilehcf.core.uuid.UUIDCache;
import com.mongodb.MongoClient;
import com.mongodb.MongoClientOptions;
import com.mongodb.MongoCredential;
import com.mongodb.ServerAddress;
import com.mongodb.client.MongoDatabase;
import com.qrakn.honcho.Honcho;
import com.qrakn.phoenix.lang.file.type.BasicConfigurationFile;
import java.lang.reflect.Type;
import java.util.Arrays;
import java.util.List;
import java.util.logging.Level;
import lombok.Getter;
import net.centilehcf.core.network.packet.PacketDeleteGrant;
import net.centilehcf.core.network.packet.PacketDeleteRank;
import net.centilehcf.core.network.packet.PacketStaffSwitchServer;
import net.centilehcf.core.prefix.command.AddPrefixCommand;
import net.centilehcf.core.prefix.command.ListPrefixCommand;
import net.centilehcf.core.prefix.command.PrefixTypeAdapter;
import net.centilehcf.core.prefix.command.SetPrefixCommand;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.ServicePriority;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
@Getter
public class Core extends JavaPlugin {
public static Gson GSON = new Gson();
public static Type LIST_STRING_TYPE = new TypeToken<List<String>>() {
}.getType();
private static Core core;
private BasicConfigurationFile mainConfig;
private Honcho honcho;
private MongoDatabase mongoDatabase;
private JedisPool jedisPool;
private UUIDCache uuidCache;
private Essentials essentials;
private PrefixHandler prefixHandler;
private Chat chat;
private Pidgin pidgin;
private boolean loaded;
@Override
public void onEnable() {
core = this;
getServer().getServicesManager().register(Permission.class, new VaultProvider(), this, ServicePriority.Highest);
mainConfig = new BasicConfigurationFile(this, "config");
loadMongo();
loadRedis();
uuidCache = new UUIDCache(this);
essentials = new Essentials(this);
chat = new Chat(this);
honcho = new Honcho(this);
Arrays.asList(
new BroadcastCommand(),
new ClearCommand(),
new DayCommand(),
new GameModeCommand(),
new HealCommand(),
new HidePlayerCommand(),
new MoreCommand(),
new NightCommand(),
new SetSlotsCommand(),
new SetSpawnCommand(),
new ShowPlayerCommand(),
new SpawnCommand(),
new SunsetCommand(),
new AltsCommand(),
new BanCommand(),
new BlacklistCommand(),
new UnblacklistCommand(),
new HistoryCommand(),
new KickCommand(),
new MuteCommand(),
new UnbanCommand(),
new UnmuteCommand(),
new WarnCommand(),
new GrantCommand(),
new GrantsCommand(),
new StaffChatCommand(),
new StaffChatToggleCommand(),
new MuteChatCommand(),
new OptionsCommand(),
new RankAddPermissionCommand(),
new RankCreateCommand(),
new RankDeleteCommand(),
new RankRenameCommand(),
new RankRemovePermissionCommand(),
new RankSetColorCommand(),
new RankSetPrefixCommand(),
new RankSetSuffixCommand(),
new RankSetWeightCommand(),
new RankAuditCommand(),
new RankDumpCommand(),
new RankListCommand(),
new PingCommand(),
new AddIndividualPermissionCommand(),
new ListIndividualPermissionsCommand(),
new RemoveIndividualPermissionCommand(),
new PrefixCommand(),
new AddPrefixCommand(),
new DeletePrefixCommand(),
new ListPrefixCommand(),
new SetPrefixCommand(),
new SetPrefixCommand(),
new TeleportAllCommand(),
new TeleportHereCommand(),
new MasssayCommand(),
new RawCommand(),
new TeleportPositionCommand(),
new MessageCommand(),
new ReplyCommand(),
new TeleportCommand(),
new InvseeCommand(),
new StreamingCommand(),
new WorldCommand(),
new ClearChatCommand(),
new SpawnerCommand(),
new RequestCommand(),
new ListCommand(),
new ClearGrantsCommand(),
new ClearPunishmentsCommand(),
new TogglePrivateMessagesCommand(),
new CraftCommand(),
new RenameCommand(),
new SetRankCommand()
).forEach(honcho::registerCommand);
honcho.registerTypeAdapter(Rank.class, new RankTypeAdapter());
honcho.registerTypeAdapter(Profile.class, new ProfileTypeAdapter());
honcho.registerTypeAdapter(Duration.class, new DurationTypeAdapter());
honcho.registerTypeAdapter(Prefix.class, new PrefixTypeAdapter());
Arrays.asList(
new ProfileListener(this),
new MenuListener(this),
new EssentialsListener(this),
new ChatListener(this),
new GrantListener(this),
new PunishmentListener(this),
new DurabilityListener(this)
).forEach(listener -> getServer().getPluginManager().registerEvents(listener, this));
pidgin = new Pidgin("zoot",
mainConfig.getString("REDIS.HOST"),
mainConfig.getInteger("REDIS.PORT"),
mainConfig.getBoolean("REDIS.AUTHENTICATION.ENABLED") ?
mainConfig.getString("REDIS.AUTHENTICATION.PASSWORD") : null
);
Arrays.asList(
PacketAddGrant.class,
PacketBroadcastPunishment.class,
PacketDeleteGrant.class,
PacketDeleteRank.class,
PacketRefreshRank.class,
PacketStaffChat.class,
PacketStaffJoinNetwork.class,
PacketStaffLeaveNetwork.class,
PacketStaffSwitchServer.class,
PacketUpdatePrefix.class,
PacketDeletePrefix.class,
PacketRequestCommand.class,
PacketClearGrants.class,
PacketServerRestart.class,
PacketRemovePunishments.class
).forEach(pidgin::registerPacket);
pidgin.registerListener(new NetworkPacketListener(this));
Rank.init();
Profile.init();
ProtocolLibrary.getProtocolManager().addPacketListener(new TabAdapter());
/* TabEngine.init();
TabEngine.setLayoutProvider(new TestLayoutProvider());*/
this.prefixHandler = new PrefixHandler();
new BukkitRunnable() {
@Override
public void run() {
for (Profile profile : Profile.getProfiles().values()) {
profile.checkGrants();
}
}
}.runTaskTimerAsynchronously(this, 20L, 20L);
TaskUtil.runLater(() -> this.loaded = true, 60L);
Core.get().getPidgin().sendPacket(new PacketServerRestart( Core.get().getMainConfig().getString("SERVER_NAME"), CC.GREEN + "Online"));
}
@Override
public void onDisable() {
Core.get().getPidgin().sendPacket(new PacketServerRestart( Core.get().getMainConfig().getString("SERVER_NAME"), CC.RED +"Offline"));
try {
jedisPool.close();
} catch (Exception e) {
e.printStackTrace();
}
}
/**
* Prints a message and exception to console. If the server is not in debug mode, the messages will be suppressed.
*
* @param level The log level.
* @param message The message.
* @param exception The thrown exception.
*/
public void debug(Level level, String message, Exception exception) {
getLogger().log(level, message);
exception.printStackTrace();
}
/**
* Prints a message to console and server operators.
*
* @param message The message.
*/
public void debug(String message) {
broadcastOps(CC.translate("&e(Debug) &r" + message));
}
/**
* Prints a message triggered by an action a player performed to console and server operators.
*
* @param player The player that triggered this log.
* @param message The message.
*/
public void debug(Player player, String message) {
broadcastOps(CC.translate("&e(Debug) &r" + player.getDisplayName() + ": " + message));
}
/**
* Broadcasts a message to all server operators.
*
* @param message The message.
*/
public static void broadcastOps(String message) {
Bukkit.getOnlinePlayers().stream().filter(Player::isOp).forEach(op -> op.sendMessage(message));
}
private void loadMongo() {
if (mainConfig.getBoolean("MONGO.AUTHENTICATION.ENABLED")) {
mongoDatabase = new MongoClient(
new ServerAddress(
mainConfig.getString("MONGO.HOST"),
mainConfig.getInteger("MONGO.PORT")),
MongoCredential.createCredential(
mainConfig.getString("MONGO.AUTHENTICATION.USERNAME"),
"admin", mainConfig.getString("MONGO.AUTHENTICATION.PASSWORD").toCharArray()),
MongoClientOptions.builder().build()
).getDatabase("zoot");
} else {
mongoDatabase = new MongoClient(mainConfig.getString("MONGO.HOST"), mainConfig.getInteger("MONGO.PORT"))
.getDatabase("zoot");
}
}
private void loadRedis() {
jedisPool = new JedisPool(mainConfig.getString("REDIS.HOST"), mainConfig.getInteger("REDIS.PORT"));
if (mainConfig.getBoolean("REDIS.AUTHENTICATION.ENABLED")) {
try (Jedis jedis = jedisPool.getResource()) {
jedis.auth(mainConfig.getString("REDIS.AUTHENTICATION.PASSWORD"));
}
}
}
public static Core get() {
return core;
}
}

View File

@ -0,0 +1,34 @@
package net.centilehcf.core;
import lombok.AllArgsConstructor;
import org.bukkit.ChatColor;
import java.text.MessageFormat;
@AllArgsConstructor
public enum Locale {
FAILED_TO_LOAD_PROFILE("COMMON_ERRORS.FAILED_TO_LOAD_PROFILE"),
COULD_NOT_RESOLVE_PLAYER("COMMON_ERRORS.COULD_NOT_RESOLVE_PLAYER"),
PLAYER_NOT_FOUND("COMMON_ERRORS.PLAYER_NOT_FOUND"),
RANK_NOT_FOUND("COMMON_ERRORS.RANK_NOT_FOUND"),
STAFF_CHAT("STAFF.CHAT"),
STAFF_REQUEST("STAFF.REQUEST"),
STAFF_BROADCAST_PREFIX("STAFF.BROADCAST_PREFIX"),
STAFF_REQUEST_PREFIX("STAFF.REQUEST_PREFIX"),
STAFF_JOIN_NETWORK("STAFF.JOIN_NETWORK"),
STAFF_SWITCH_SERVER("STAFF.SWITCH_SERVER"),
STAFF_LEAVE_NETWORK("STAFF.LEAVE_NETWORK"),
SERVER_STATUS("SERVER.STATUS"),
SERVER_STATUS_PREFIX("SERVER.PREFIX"),
NETWORK_BROADCAST_PREFIX("NETWORK.BROADCAST_PREFIX"),
NETWORK_RANK_REFRESHED("NETWORK.RANK_REFRESH"),
NETWORK_RANK_DELETED("NETWORK.RANK_DELETE");
private String path;
public String format(Object... objects) {
return new MessageFormat(ChatColor.translateAlternateColorCodes('&',
Core.get().getMainConfig().getString(path))).format(objects);
}
}

View File

@ -0,0 +1,81 @@
package net.centilehcf.core.board;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
import lombok.Getter;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.DisplaySlot;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
@Getter
public class Board {
// We assign a unique identifier (random string of ChatColor values)
// to each board entry to: bypass the 32 char limit, using
// a team's prefix & suffix and a team entry's display name, and to
// track the order of entries;
private final List<BoardEntry> entries = new ArrayList<>();
private final List<String> identifiers = new ArrayList<>();
private Scoreboard scoreboard;
private Objective objective;
public Board(Player player) {
this.setup(player);
}
private void setup(Player player) {
// Register new scoreboard if needed
if (player.getScoreboard().equals(Bukkit.getScoreboardManager().getMainScoreboard())) {
this.scoreboard = Bukkit.getScoreboardManager().getNewScoreboard();
} else {
this.scoreboard = player.getScoreboard();
}
// Setup sidebar objective
this.objective = this.scoreboard.registerNewObjective("Default", "dummy");
this.objective.setDisplaySlot(DisplaySlot.SIDEBAR);
this.objective.setDisplayName(MainBoard.getInstance().getAdapter().getTitle(player));
// Update scoreboard
player.setScoreboard(this.scoreboard);
}
public BoardEntry getEntryAtPosition(int pos) {
if (pos >= this.entries.size()) {
return null;
} else {
return this.entries.get(pos);
}
}
public String getUniqueIdentifier(String text) {
String identifier = getRandomChatColor() + ChatColor.WHITE;
while (this.identifiers.contains(identifier)) {
identifier = identifier + getRandomChatColor() + ChatColor.WHITE;
}
// This is rare, but just in case, make the method recursive
if (identifier.length() > 16) {
return this.getUniqueIdentifier(text);
}
// Add our identifier to the list so there are no duplicates
this.identifiers.add(identifier);
return identifier;
}
// Gets a random ChatColor and returns the String value of it
private static String getRandomChatColor() {
return ChatColor.values()[ThreadLocalRandom.current().nextInt(ChatColor.values().length)].toString();
}
}

View File

@ -0,0 +1,14 @@
package net.centilehcf.core.board;
import java.util.List;
import org.bukkit.entity.Player;
public interface BoardAdapter {
String getTitle(Player player);
List<String> getLines(Player player);
void preLoop();
}

View File

@ -0,0 +1,98 @@
package net.centilehcf.core.board;
import lombok.Setter;
import org.bukkit.ChatColor;
import org.bukkit.scoreboard.Score;
import org.bukkit.scoreboard.Scoreboard;
import org.bukkit.scoreboard.Team;
public class BoardEntry {
private final Board board;
@Setter
private String text;
private String identifier;
private Team team;
public BoardEntry(Board board, String text) {
this.board = board;
this.text = text;
this.identifier = this.board.getUniqueIdentifier(text);
this.setup();
}
public void setup() {
final Scoreboard scoreboard = this.board.getScoreboard();
String teamName = this.identifier;
// This shouldn't happen, but just in case
if (teamName.length() > 16) {
teamName = teamName.substring(0, 16);
}
Team team = scoreboard.getTeam(teamName);
// Register the team if it does not exist
if (team == null) {
team = scoreboard.registerNewTeam(teamName);
}
// Add the entry to the team
if (!team.getEntries().contains(this.identifier)) {
team.addEntry(this.identifier);
}
// Add the entry if it does not exist
if (!this.board.getEntries().contains(this)) {
this.board.getEntries().add(this);
}
this.team = team;
}
public void send(int position) {
if (this.text.length() > 16) {
String prefix = this.text.substring(0, 16);
String suffix;
if (prefix.charAt(15) == ChatColor.COLOR_CHAR) {
prefix = prefix.substring(0, 15);
suffix = this.text.substring(15);
} else if (prefix.charAt(14) == ChatColor.COLOR_CHAR) {
prefix = prefix.substring(0, 14);
suffix = this.text.substring(14);
} else {
if (ChatColor.getLastColors(prefix).equalsIgnoreCase(ChatColor.getLastColors(this.identifier))) {
suffix = this.text.substring(16);
} else {
suffix = ChatColor.getLastColors(prefix) + this.text.substring(16);
}
}
if (suffix.length() > 16) {
suffix = suffix.substring(0, 16);
}
this.team.setPrefix(prefix);
this.team.setSuffix(suffix);
} else {
this.team.setPrefix(this.text);
this.team.setSuffix("");
}
final Score score = this.board.getObjective().getScore(this.identifier);
score.setScore(position);
}
public void remove() {
this.board.getIdentifiers().remove(this.identifier);
this.board.getScoreboard().resetScores(this.identifier);
}
}

View File

@ -0,0 +1,52 @@
package net.centilehcf.core.board;
import net.centilehcf.core.board.events.BoardCreateEvent;
import net.centilehcf.core.board.events.BoardDestroyEvent;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.server.PluginDisableEvent;
public class BoardListener implements Listener {
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
final BoardCreateEvent createEvent = new BoardCreateEvent(event.getPlayer());
Bukkit.getPluginManager().callEvent(createEvent);
if (createEvent.isCancelled()) {
return;
}
MainBoard.getInstance().getBoards().put(event.getPlayer().getUniqueId(), new Board(event.getPlayer()));
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
final BoardDestroyEvent destroyEvent = new BoardDestroyEvent(event.getPlayer());
Bukkit.getPluginManager().callEvent(destroyEvent);
if (destroyEvent.isCancelled()) {
return;
}
MainBoard.getInstance().getBoards().remove(event.getPlayer().getUniqueId());
}
@EventHandler
public void onPluginDisable(PluginDisableEvent event) {
if (MainBoard.getInstance().getThread() == null) {
return;
}
MainBoard.getInstance().getThread().stop();
}
}

View File

@ -0,0 +1,24 @@
package net.centilehcf.core.board;
public enum BoardStyle {
KOHI(true, 15),
VIPER(true, -1),
MODERN(false, 1);
private boolean decending;
private int startNumber;
BoardStyle(boolean decending, int startNumber) {
this.decending = decending;
this.startNumber = startNumber;
}
public boolean isDecending() {
return this.decending;
}
public int getStartNumber() {
return this.startNumber;
}
}

View File

@ -0,0 +1,114 @@
package net.centilehcf.core.board;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.scoreboard.Objective;
import org.bukkit.scoreboard.Scoreboard;
import java.util.Collections;
import java.util.List;
public class BoardThread extends Thread {
private MainBoard mainBoard;
BoardThread(MainBoard mainBoard) {
this.mainBoard = mainBoard;
this.start();
}
@Override
public void run() {
while(true) {
//Tick
try {
tick();
} catch (NullPointerException e) {
e.printStackTrace();
}
//Thread Sleep
try {
sleep(mainBoard.getTicks() * 50);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
}
private void tick() {
mainBoard.getAdapter().preLoop();
for (Player player : this.mainBoard.getPlugin().getServer().getOnlinePlayers()) {
final Board board = this.mainBoard.getBoards().get(player.getUniqueId());
// This shouldn't happen, but just in case
if (board == null) {
continue;
}
final Scoreboard scoreboard = board.getScoreboard();
final Objective objective = board.getObjective();
// Just make a variable so we don't have to²
// process the same thing twice
final String title = ChatColor.translateAlternateColorCodes('&', this.mainBoard.getAdapter().getTitle(player));
// Update the title if needed
if (!objective.getDisplayName().equals(title)) {
objective.setDisplayName(title);
}
final List<String> newLines = this.mainBoard.getAdapter().getLines(player);
// Allow adapter to return null/empty list to display nothing
if (newLines == null || newLines.isEmpty()) {
board.getEntries().forEach(BoardEntry::remove);
board.getEntries().clear();
} else {
// Reverse the lines because scoreboard scores are in descending order
if (!this.mainBoard.getBoardStyle().isDecending()) {
Collections.reverse(newLines);
}
// Remove excessive amount of board entries
if (board.getEntries().size() > newLines.size()) {
for (int i = newLines.size(); i < board.getEntries().size(); i++) {
final BoardEntry entry = board.getEntryAtPosition(i);
if (entry != null) {
entry.remove();
}
}
}
// Update existing entries / add new entries
int cache = this.mainBoard.getBoardStyle().getStartNumber();
for (int i = 0; i < newLines.size(); i++) {
BoardEntry entry = board.getEntryAtPosition(i);
// Translate any colors
final String line = ChatColor.translateAlternateColorCodes('&', newLines.get(i));
// If the entry is null, just create a new one.
// Creating a new BoardEntry instance will add
// itself to the provided board's entries list.
if (entry == null) {
entry = new BoardEntry(board, line);
}
// Update text, setup the team, and update the display values
entry.setText(line);
entry.setup();
entry.send(
this.mainBoard.getBoardStyle().isDecending() ? cache-- : cache++
);
}
}
if (player.getScoreboard() != scoreboard) {
player.setScoreboard(scoreboard);
}
}
}
}

View File

@ -0,0 +1,66 @@
package net.centilehcf.core.board;
import java.util.Map;
import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.Core;
import org.bukkit.Bukkit;
import org.bukkit.plugin.java.JavaPlugin;
@Getter
public class MainBoard {
//Instance
@Getter private static MainBoard instance;
private JavaPlugin plugin;
private BoardAdapter adapter;
private Map<UUID, Board> boards;
private BoardThread thread;
//Scoreboard Ticks
@Setter
private long ticks = 2;
//Default Scoreboard Style
@Setter
private BoardStyle boardStyle = BoardStyle.MODERN;
public MainBoard(JavaPlugin plugin, BoardAdapter adapter) {
if (instance != null) {
throw new RuntimeException("MainBoard has already been instantiated!");
}
if (plugin == null) {
throw new RuntimeException("MainBoard can not be instantiated without a plugin instance!");
}
instance = this;
this.plugin = plugin;
this.adapter = adapter;
this.boards = new ConcurrentHashMap<>();
this.setup();
}
private void setup() {
//Register Events
Bukkit.getPluginManager().registerEvents(new BoardListener(), Core.get());
//Ensure that the thread has stopped running
if (this.thread != null) {
this.thread.stop();
this.thread = null;
}
//Start Thread
this.thread = new BoardThread(this);
}
}

View File

@ -0,0 +1,28 @@
package net.centilehcf.core.board.events;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
public class BoardCreateEvent extends Event implements Cancellable {
@Getter public static HandlerList HANDLER_LIST = new HandlerList();
private Player player;
@Setter
private boolean cancelled = false;
public BoardCreateEvent(Player player) {
this.player = player;
}
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
}

View File

@ -0,0 +1,31 @@
package net.centilehcf.core.board.events;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
@Getter
public class BoardDestroyEvent extends Event implements Cancellable {
@Getter
public static HandlerList HANDLER_LIST = new HandlerList();
private Player player;
@Setter
private boolean cancelled = false;
public BoardDestroyEvent(Player player) {
this.player = player;
}
@Override
public HandlerList getHandlers() {
return HANDLER_LIST;
}
}

View File

@ -0,0 +1,14 @@
package net.centilehcf.core.bootstrap;
import net.centilehcf.core.Core;
import lombok.Getter;
@Getter
public class Bootstrapped {
protected final Core core;
public Bootstrapped(Core core) {
this.core = core;
}
}

View File

@ -0,0 +1,11 @@
package net.centilehcf.core.bootstrap;
import net.centilehcf.core.Core;
import org.bukkit.event.Listener;
public class BootstrappedListener extends Bootstrapped implements Listener {
public BootstrappedListener(Core core) {
super(core);
}
}

View File

@ -0,0 +1,67 @@
package net.centilehcf.core.chat;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.Bootstrapped;
import net.centilehcf.core.chat.filter.ChatFilter;
import net.centilehcf.core.profile.Profile;
import java.util.ArrayList;
import java.util.List;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
public class Chat extends Bootstrapped {
public Chat(Core core) {
super(core);
}
@Getter @Setter private int delayTime = 3;
@Getter private boolean publicChatMuted = false;
@Getter private boolean publicChatDelayed = false;
@Getter private final List<ChatFilter> filters = new ArrayList<>();
@Getter private List<String> filteredPhrases = new ArrayList<>();
@Getter private List<String> linkWhitelist = new ArrayList<>();
public void setPublicChatMuted(boolean muted) {
if (this.publicChatMuted == muted) {
return;
}
publicChatMuted = !publicChatMuted;
}
public ChatAttempt attemptChatMessage(Player player, String message) {
Profile profile = Profile.getProfiles().get(player.getUniqueId());
if (profile.getActiveMute() != null) {
return new ChatAttempt(ChatAttempt.Response.PLAYER_MUTED, profile.getActiveMute());
}
if (publicChatMuted && !player.hasPermission("core.mod")) {
return new ChatAttempt(ChatAttempt.Response.CHAT_MUTED);
}
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 (ChatFilter chatFilter : this.filters) {
if (chatFilter.isFiltered(msg, words)) {
return new ChatAttempt(ChatAttempt.Response.MESSAGE_FILTERED);
}
}
return new ChatAttempt(ChatAttempt.Response.ALLOWED);
}
}

View File

@ -0,0 +1,38 @@
package net.centilehcf.core.chat;
import net.centilehcf.core.chat.filter.ChatFilter;
import net.centilehcf.core.profile.punishment.Punishment;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class ChatAttempt {
private Response response;
private ChatFilter filterFlagged;
private Punishment punishment;
public ChatAttempt(Response response) {
this.response = response;
}
public ChatAttempt(Response response, ChatFilter filterFlagged) {
this.response = response;
this.filterFlagged = filterFlagged;
}
public ChatAttempt(Response response, Punishment punishment) {
this.response = response;
this.punishment = punishment;
}
public enum Response {
ALLOWED,
MESSAGE_FILTERED,
PLAYER_MUTED,
CHAT_MUTED,
CHAT_DELAYED
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.chat.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "mutechat", permission = "core.seniormod")
public class MuteChatCommand {
public void execute(CommandSender sender) {
Core.get().getChat().setPublicChatMuted(!Core.get().getChat().isPublicChatMuted());
Core.get().getServer().broadcastMessage((CC.PINK + "Public chat has been {context} by " + sender.getName())
.replace("{context}", Core.get().getChat().isPublicChatMuted() ? "muted" : "unmuted"));
}
}

View File

@ -0,0 +1,27 @@
package net.centilehcf.core.chat.event;
import net.centilehcf.core.chat.ChatAttempt;
import net.centilehcf.core.util.BaseEvent;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.chat.ChatAttempt;
import net.centilehcf.core.util.BaseEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@Getter
public class ChatAttemptEvent extends BaseEvent implements Cancellable {
private final Player player;
private final ChatAttempt chatAttempt;
@Setter private String chatMessage;
@Setter private boolean cancelled;
@Setter private String cancelReason = "";
public ChatAttemptEvent(Player player, ChatAttempt chatAttempt, String chatMessage) {
this.player = player;
this.chatAttempt = chatAttempt;
this.chatMessage = chatMessage;
}
}

View File

@ -0,0 +1,26 @@
package net.centilehcf.core.chat.filter;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.Bootstrapped;
import org.bukkit.entity.Player;
public abstract class ChatFilter extends Bootstrapped {
private String command;
public ChatFilter(Core core, String command) {
super(core);
this.command = command;
}
public abstract boolean isFiltered(String message, String[] words);
public void punish(Player player) {
if (command != null) {
core.getServer().dispatchCommand(core.getServer().getConsoleSender(), command
.replace("{player}", player.getName())
.replace("{player-uuid}", player.getUniqueId().toString()));
}
}
}

View File

@ -0,0 +1,30 @@
package net.centilehcf.core.chat.filter.impl;
import net.centilehcf.core.Core;
import net.centilehcf.core.chat.filter.ChatFilter;
public class ContainsFilter extends ChatFilter {
private final String phrase;
public ContainsFilter(Core core, String phrase) {
this(core, phrase, null);
}
public ContainsFilter(Core core, String phrase, String command) {
super(core, command);
this.phrase = phrase;
}
@Override
public boolean isFiltered(String message, String[] words) {
for (String word : words) {
if (word.contains(this.phrase)) {
return true;
}
}
return false;
}
}

View File

@ -0,0 +1,50 @@
package net.centilehcf.core.chat.filter.impl;
import net.centilehcf.core.Core;
import net.centilehcf.core.chat.filter.ChatFilter;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class LinkFilter extends ChatFilter {
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])$");
public LinkFilter(Core core) {
super(core, null);
}
@Override
public boolean isFiltered(String message, String[] words) {
for (String word : message.replace("(dot)", ".").replace("[dot]", ".").trim().split(" ")) {
boolean continueIt = false;
for (String phrase : this.core.getChat().getLinkWhitelist()) {
if (word.toLowerCase().contains(phrase)) {
continueIt = true;
break;
}
}
if (!continueIt) {
Matcher matcher = IP_REGEX.matcher(word);
if (matcher.matches()) {
return true;
}
matcher = URL_REGEX.matcher(word);
if (matcher.matches()) {
return true;
}
}
}
return false;
}
}

View File

@ -0,0 +1,76 @@
package net.centilehcf.core.chat.listener;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.BootstrappedListener;
import net.centilehcf.core.chat.ChatAttempt;
import net.centilehcf.core.chat.event.ChatAttemptEvent;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import net.centilehcf.core.util.Cooldown;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.player.AsyncPlayerChatEvent;
public class ChatListener extends BootstrappedListener {
public ChatListener(Core core) {
super(core);
}
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onAsyncPlayerChatEvent(AsyncPlayerChatEvent event) {
Player player = event.getPlayer();
Profile profile = Profile.getByUuid(player.getUniqueId());
ChatAttempt chatAttempt = core.getChat().attemptChatMessage(event.getPlayer(), event.getMessage());
ChatAttemptEvent chatAttemptEvent = new ChatAttemptEvent(event.getPlayer(), chatAttempt, event.getMessage());
if (!player.hasPermission("core.staff")) {
if (!profile.getChatCooldown().hasExpired()) {
player.sendMessage(CC.translate("&cYou can chat again in &c&l%TIME_LEFT%s&c.".replace("%TIME_LEFT%", profile.getChatCooldown().getTimeLeft())));
event.setCancelled(true);
return;
} else {
profile.setChatCooldown(new Cooldown(Core.get().getChat().getDelayTime() * 1000));
}
}
core.getServer().getPluginManager().callEvent(chatAttemptEvent);
if (!chatAttemptEvent.isCancelled()) {
switch (chatAttempt.getResponse()) {
case ALLOWED: {
if (profile.getPrefix() == Core.get().getPrefixHandler().getDefaultPrefix()) {
event.setFormat("%1$s" + profile.getActiveGrant().getRank().getSuffix() + CC.RESET + ": %2$s");
} else {
event.setFormat(profile.getPrefix().getPrefix() + "%1$s" + profile.getActiveGrant().getRank().getSuffix() + CC.RESET + ": %2$s");
}
}
break;
case MESSAGE_FILTERED: {
event.setCancelled(true);
chatAttempt.getFilterFlagged().punish(event.getPlayer());
}
break;
case PLAYER_MUTED: {
event.setCancelled(true);
event.getPlayer().sendMessage(CC.RED + "You are currently muted.");
event.getPlayer().sendMessage(CC.RED + "Reason: " + CC.YELLOW + chatAttempt.getPunishment().getAddedReason());
event.getPlayer().sendMessage(CC.RED + "Expires: " + CC.YELLOW + chatAttempt.getPunishment().getTimeRemaining());
}
break;
case CHAT_MUTED: {
event.setCancelled(true);
event.getPlayer().sendMessage(CC.RED + "The public chat is currently muted.");
}
break;
case CHAT_DELAYED: {
event.setCancelled(true);
event.getPlayer().sendMessage(CC.RED + "Slow down! You may chat again in {time}.");
}
break;
}
}
}
}

View File

@ -0,0 +1,219 @@
package net.centilehcf.core.chat.util;
import java.lang.reflect.Field;
import java.util.ArrayList;
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) {
for (Object part : getParts()) {
TextComponent component = (TextComponent) part;
if (component.getHoverEvent() == null) {
component.setHoverEvent(hoverEvent);
}
}
this.getCurrent().setHoverEvent(hoverEvent);
return this;
}
public ChatComponentBuilder attachToEachPart(ClickEvent clickEvent) {
for (Object part : getParts()) {
TextComponent component = (TextComponent) part;
if (component.getClickEvent() == null) {
component.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()) {
if (getParts().isEmpty() && getCurrent() != null && getCurrent().getText().isEmpty()) {
getCurrent().setText(text);
} else {
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()) {
if (getParts().isEmpty() && getCurrent() != null && getCurrent().getText().isEmpty()) {
getCurrent().setText(word);
} else {
this.append(word);
}
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(BaseComponent[] components) {
for (BaseComponent component : components) {
append((TextComponent) component);
}
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;
}
@Override
public BaseComponent[] create() {
List<TextComponent> components = new ArrayList<>(getParts());
components.add(getCurrent());
TextComponent first = components.get(0);
if (first.getText().isEmpty()) {
components.remove(0);
}
TextComponent last = components.get(components.size() - 1);
if (last.getText().isEmpty()) {
components.remove(components.size() - 1);
}
return components.toArray(new BaseComponent[components.size()]);
}
}

View File

@ -0,0 +1,15 @@
package net.centilehcf.core.chat.util;
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;
}

View File

@ -0,0 +1,89 @@
package net.centilehcf.core.essentials;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.Bootstrapped;
import net.centilehcf.core.essentials.event.SpawnTeleportEvent;
import net.centilehcf.core.util.LocationUtil;
import java.io.IOException;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
public class Essentials extends Bootstrapped {
private Location spawn;
public Essentials(Core core) {
super(core);
spawn = LocationUtil.deserialize(core.getMainConfig().getStringOrDefault("ESSENTIAL.SPAWN_LOCATION", null));
}
public void setSpawn(Location location) {
spawn = location;
if (spawn == null) {
core.getMainConfig().getConfiguration().set("ESSENTIAL.SPAWN_LOCATION", null);
} else {
core.getMainConfig().getConfiguration().set("ESSENTIAL.SPAWN_LOCATION", LocationUtil.serialize(this.spawn));
}
try {
core.getMainConfig().getConfiguration().save(core.getMainConfig().getFile());
} catch (IOException e) {
e.printStackTrace();
}
}
public void teleportToSpawn(Player player) {
Location location = spawn == null ? core.getServer().getWorlds().get(0).getSpawnLocation() : spawn;
SpawnTeleportEvent event = new SpawnTeleportEvent(player, location);
event.call();
if (!event.isCancelled() && event.getLocation() != null) {
player.teleport(event.getLocation());
}
}
public int clearEntities(World world) {
int removed = 0;
for (Entity entity : world.getEntities()) {
if (entity.getType() == EntityType.PLAYER) {
continue;
}
removed++;
entity.remove();
}
return removed;
}
public int clearEntities(World world, EntityType... excluded) {
int removed = 0;
entityLoop:
for (Entity entity : world.getEntities()) {
for (EntityType type : excluded) {
if (entity.getType() == EntityType.PLAYER) {
continue entityLoop;
}
if (entity.getType() == type) {
continue entityLoop;
}
}
removed++;
entity.remove();
}
return removed;
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import com.qrakn.honcho.command.CommandOption;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
@CommandMeta(label = { "broadcast", "bc" }, options = "r", permission = "rank.manager")
public class BroadcastCommand {
public void execute(CommandSender sender, CommandOption option, String broadcast) {
String message = broadcast.replaceAll("(&([a-f0-9l-or]))", "\u00A7$2");
Bukkit.broadcastMessage(CC.translate((option == null ? "&6[Broadcast] &r" : "") + message));
}
}

View File

@ -0,0 +1,30 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/12/2019.
*/
@CommandMeta(label = {"clearchat", "cc", "removeallshitinthechat"}, permission = "rank.mod")
public class ClearChatCommand {
public void execute(Player player) {
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();
for (Player player2 : Core.get().getServer().getOnlinePlayers()) {
if (!player2.hasPermission("plib.staff")) {
player2.sendMessage(clear);
}
player2.sendMessage(CC.GREEN + "Chat has been cleared!");
}
}
}

View File

@ -0,0 +1,27 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
@CommandMeta(label = { "clearinv", "clear", "ci" }, permission = "rank.admin")
public class ClearCommand {
public void execute(Player player) {
player.getInventory().setContents(new ItemStack[36]);
player.getInventory().setArmorContents(new ItemStack[4]);
player.updateInventory();
player.sendMessage(CC.GOLD + "You cleared your inventory.");
}
public void execute(CommandSender sender, Player player) {
player.getInventory().setContents(new ItemStack[36]);
player.getInventory().setArmorContents(new ItemStack[4]);
player.updateInventory();
player.sendMessage(CC.GOLD + "Your inventory has been cleared by " + sender.getName());
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 5/28/2019.
*/
@CommandMeta(label = "craft", permission = "command.craft")
public class CraftCommand {
public void execute(Player player) {
player.openWorkbench(player.getLocation(), true);
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
@CommandMeta(label = "day")
public class DayCommand {
public void execute(Player player) {
player.setPlayerTime(6000L, false);
player.sendMessage(CC.GREEN + "It's now day time.");
}
}

View File

@ -0,0 +1,42 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.Locale;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.Locale;
import net.centilehcf.core.util.CC;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandMeta(label = { "gamemode", "gm" }, permission = "rank.admin")
public class GameModeCommand {
public void execute(Player player, GameMode gameMode) {
if (gameMode == null) {
player.sendMessage(CC.RED + "That game mode is not valid.");
return;
}
player.setGameMode(gameMode);
player.updateInventory();
player.sendMessage(CC.GOLD + "You updated your game mode.");
}
public void execute(CommandSender sender, Player target, GameMode gameMode) {
if (target == null) {
sender.sendMessage(Locale.PLAYER_NOT_FOUND.format());
return;
}
if (gameMode == null) {
sender.sendMessage(CC.RED + "That game mode is not valid.");
return;
}
target.setGameMode(gameMode);
target.updateInventory();
target.sendMessage(CC.GOLD + "Your game mode has been updated by " + sender.getName());
}
}

View File

@ -0,0 +1,35 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.Locale;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.Locale;
import net.centilehcf.core.util.CC;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@CommandMeta(label = "heal", permission = "rank.admin")
public class HealCommand {
public void execute(Player player) {
player.setHealth(20.0);
player.setFoodLevel(20);
player.setSaturation(5.0F);
player.updateInventory();
player.sendMessage(CC.GOLD + "You healed yourself.");
}
public void execute(CommandSender sender, Player player) {
if (player == null) {
sender.sendMessage(Locale.PLAYER_NOT_FOUND.format());
return;
}
player.setHealth(20.0);
player.setFoodLevel(20);
player.setSaturation(5.0F);
player.updateInventory();
player.sendMessage(CC.GOLD + "You have been healed by " + sender.getName());
}
}

View File

@ -0,0 +1,13 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "hideplayer", permission = "rank.manager")
public class HidePlayerCommand {
public void execute(Player player, Player target) {
player.hidePlayer(target);
}
}

View File

@ -0,0 +1,14 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/5/2019.
*/
@CommandMeta(label = "invsee", permission = "rank.mod")
public class InvseeCommand {
public void execute(Player player, Player target) {
player.openInventory(target.getInventory());
}
}

View File

@ -0,0 +1,47 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.rank.Rank;
import net.centilehcf.core.rank.comparator.RankComparator;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.craftbukkit.libs.joptsimple.internal.Strings;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.stream.Collectors;
@CommandMeta(label = {"list", "who", "online"}, async = true)
public class ListCommand {
public void execute(CommandSender sender) {
List<Rank> ranks = Rank.getRanks().values().stream().sorted(new RankComparator()).collect(Collectors.toList());
List<String> rankStr = ranks.stream().filter(rank -> !rank.getPermissions().contains("hidden")).map(rank -> rank.getColor() + rank.getDisplayName()).collect(Collectors.toList());
sender.sendMessage(Strings.join(rankStr, CC.GRAY + ", "));
List<Player> onlinePlayers = Bukkit.getOnlinePlayers().stream().sorted(Comparator.comparingInt(player -> Profile.getByUuid(player.getUniqueId()).getActiveRank().getWeight())).collect(Collectors.toList());
Collections.reverse(onlinePlayers);
String onlinePlayersOutOfMaximumPlayers = CC.WHITE + "(" + Bukkit.getOnlinePlayers().size() + "/" + Bukkit.getMaxPlayers() + ") ";
if (sender.hasPermission("core.staff")) {
List<String> list = new ArrayList<>();
for (Player player : onlinePlayers) {
String vanished = (player.hasMetadata("VANISHED") ? CC.GRAY + "*" : "") + Profile.getByUuid(player.getUniqueId()).getColoredUsername();
list.add(vanished);
}
sender.sendMessage(onlinePlayersOutOfMaximumPlayers + Strings.join(list, CC.GRAY + ", "));
} else {
List<String> list = new ArrayList<>();
for (Player player : onlinePlayers) {
if (!player.hasMetadata("VANISHED")) {
String coloredUsername = Profile.getByUuid(player.getUniqueId()).getColoredUsername();
list.add(coloredUsername);
}
}
sender.sendMessage(onlinePlayersOutOfMaximumPlayers + Strings.join(list, CC.GRAY + ", "));
}
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 3/30/2019.
*/
@CommandMeta(label = "masssay", permission = "rank.manager")
public class MasssayCommand {
public void execute(Player player, String message) {
message = CC.translate(message); // translate the colors
for (Player players : Bukkit.getOnlinePlayers()) {
players.chat(message);
}
player.sendMessage(CC.GREEN + "Just made all players type '" + message + CC.GREEN + "'");
}
}

View File

@ -0,0 +1,45 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/5/2019.
*/
@CommandMeta(label = {"message", "msg", "m", "tell", "whisper"})
public class MessageCommand {
public void execute(Player player, Player target, String message) {
if (target == null) {
player.sendMessage(CC.RED + "This player is not online.");
return;
}
Profile targetprofile = Profile.getByUuid(target.getUniqueId());
Profile profile = Profile.getByUuid(player.getUniqueId());
if (!targetprofile.getOptions().isPrivateChatEnabled()) {
player.sendMessage(CC.RED + "This player has messages disabled.");
return;
}
if (!profile.getOptions().isPrivateChatEnabled()) {
player.sendMessage(CC.RED + "You have messages disabled.");
return;
}
Profile targetData = Profile.getByUuid(target.getUniqueId());
String senderName = CC.RESET + player.getDisplayName();
String targetName = CC.RESET + target.getDisplayName();
profile.setReplyTo(target.getUniqueId());
targetData.setReplyTo(player.getUniqueId());
String toMessage = CC.GRAY + "(To " + targetName + CC.GRAY + ") " + message;
String fromMessage = CC.GRAY + "(From " + senderName + CC.GRAY + ") " + message;
player.sendMessage(toMessage);
target.sendMessage(fromMessage);
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "more", permission = "rank.admin")
public class MoreCommand {
public void execute(Player player) {
if (player.getItemInHand() == null) {
player.sendMessage(CC.RED + "There is nothing in your hand.");
return;
}
player.getItemInHand().setAmount(64);
player.updateInventory();
player.sendMessage(CC.GREEN + "You gave yourself more of the item in your hand.");
}
}

View File

@ -0,0 +1,15 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "night")
public class NightCommand {
public void execute(Player player) {
player.setPlayerTime(18000L, false);
player.sendMessage(CC.GREEN + "It's now night time.");
}
}

View File

@ -0,0 +1,23 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/6/2019.
*/
@CommandMeta(label = "ping")
public class PingCommand {
public void execute(Player player, Player target) {
if (target == null) {
player.sendMessage(CC.RED + "Player isn't online!");
return;
}
int ping = ((CraftPlayer) player).getHandle().ping;
player.sendMessage(target.getDisplayName() + CC.YELLOW + "'s ping: " + (ping > 100 ? CC.RED : (ping > 50 ? CC.YELLOW : CC.GREEN)) + ping);
}
}

View File

@ -0,0 +1,14 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.prefix.menu.PrefixSelectionMenu;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.prefix.menu.PrefixSelectionMenu;
import org.bukkit.entity.Player;
@CommandMeta(label = "prefix")
public class PrefixCommand {
public void execute(Player player){
new PrefixSelectionMenu().openMenu(player);
}
}

View File

@ -0,0 +1,18 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import com.qrakn.honcho.command.CommandOption;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
/**
* Created by DaddyDombo daddydombo@gmail.com on 3/30/2019.
*/
@CommandMeta(label = "raw", options = "r", permission = "rank.manager", async = true)
public class RawCommand {
public void execute(CommandSender sender, CommandOption option, String broadcast) {
String message = broadcast.replaceAll("(&([a-f0-9l-or]))", "\u00A7$2");
Bukkit.broadcastMessage(CC.translate((option == null ? "" : "") + message));
}
}

View File

@ -0,0 +1,55 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import java.util.Arrays;
import java.util.List;
/**
* Created by DaddyDombo daddydombo@gmail.com on 5/28/2019.
*/
@CommandMeta(label = "rename", permission = "command.rename")
public class RenameCommand {
public static final List<String> DENIED_NAMES = Arrays.asList("nigger", "n1gger");
public void execute(Player player, String newName) {
ItemStack stack = player.getItemInHand();
if (stack == null || stack.getType() == Material.AIR) {
player.sendMessage(CC.RED + "You have nothing in your hand.");
return;
}
ItemMeta meta = stack.getItemMeta();
String oldname = meta.getDisplayName();
if (oldname != null) {
oldname = oldname.trim();
}
if (oldname == null && newName == null) {
player.sendMessage(CC.RED + "Item already has no name.");
return;
}
if (newName != null) {
for (String word : DENIED_NAMES) {
if (newName.toLowerCase().contains(word)) {
player.sendMessage(CC.RED + "This name is not allowed.");
Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "warn -s " + player + " Disallowed Rename Name.");
return;
}
}
}
meta.setDisplayName(CC.translate(newName));
stack.setItemMeta(meta);
player.sendMessage(CC.translate("&aItem has been renamed from &c" + oldname + " &ato &c" + newName + "&a."));
}
}

View File

@ -0,0 +1,42 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/5/2019.
*/
@CommandMeta(label = {"reply", "r"})
public class ReplyCommand {
public void execute(Player player, String message) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile.getReplyTo() == null) {
player.sendMessage(CC.RED + "You have nobody to reply to.");
return;
}
final Player target = Bukkit.getPlayer(profile.getReplyTo());
if (target == null || !target.isOnline()) {
player.sendMessage(CC.RED + "That player is no longer online.");
return;
}
Profile targetData = Profile.getByUuid(target.getUniqueId());
String senderName = CC.RESET + player.getDisplayName();
String targetName = CC.RESET + target.getDisplayName();
profile.setReplyTo(target.getUniqueId());
targetData.setReplyTo(player.getUniqueId());
String toMessage = CC.GRAY + "(To " + targetName + CC.GRAY + ") " + message;
String fromMessage = CC.GRAY + "(From " + senderName + CC.GRAY + ") " + message;
player.sendMessage(toMessage);
target.sendMessage(fromMessage);
}
}

View File

@ -0,0 +1,33 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.Core;
import net.centilehcf.core.network.packet.PacketRequestCommand;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import net.centilehcf.core.util.Cooldown;
import org.bukkit.entity.Player;
import java.util.concurrent.TimeUnit;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/21/2019.
*/
@CommandMeta(label = {"request", "helpop"})
public class RequestCommand {
private static final long requestcooldown = TimeUnit.SECONDS.toMillis(60);
public void execute(Player player, String request) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (!profile.getRequestCooldown().hasExpired()) {
player.sendMessage(CC.RED + "You must wait before you can request assistance again.");
return;
}
player.sendMessage(CC.GREEN + "We have received your request and will help soon. Please be patient.");
profile.setRequestCooldown(new Cooldown(requestcooldown));
Core.get().getPidgin().sendPacket(new PacketRequestCommand(Core.get().getMainConfig().getString("SERVER_NAME"), player.getDisplayName(), request));
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.BukkitReflection;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "setslots", async = true, permission = "rank.owner")
public class SetSlotsCommand {
public void execute(CommandSender sender, int slots) {
BukkitReflection.setMaxPlayers(Core.get().getServer(), slots);
sender.sendMessage(CC.GOLD + "You set the max slots to " + slots + ".");
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "setspawn", permission = "rank.manager")
public class SetSpawnCommand {
public void execute(Player player) {
Core.get().getEssentials().setSpawn(player.getLocation());
player.sendMessage(CC.GREEN + "You updated this world's spawn.");
}
}

View File

@ -0,0 +1,12 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "showplayer", permission = "rank.manager")
public class ShowPlayerCommand {
public void execute(Player player, Player target) {
player.showPlayer(target);
}
}

View File

@ -0,0 +1,15 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.entity.Player;
@CommandMeta(label = "spawn", permission = "rank.trialmod")
public class SpawnCommand {
public void execute(Player player) {
Core.get().getEssentials().teleportToSpawn(player);
player.sendMessage(CC.GREEN + "You teleported to this world's spawn.");
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import net.centilehcf.core.util.ItemBuilder;
import org.apache.commons.lang.WordUtils;
import org.bukkit.ChatColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/12/2019.
*/
@CommandMeta(label = "spawner", permission = "rank.manager")
public class SpawnerCommand {
public void execute(Player player, Player target, String spawner) {
Inventory inventory = target.getInventory();
inventory.addItem(new ItemBuilder(Material.MOB_SPAWNER).name(CC.GREEN + "Spawner").lore(CC.WHITE + WordUtils.capitalizeFully(spawner)).build());
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/8/2019.
*/
@CommandMeta(label = "streaming", permission = "rank.media")
public class StreamingCommand {
public void execute(Player player, String url) {
Bukkit.broadcastMessage(player.getDisplayName() + CC.YELLOW + " is currently streaming! " + CC.GRAY + "(" + url + ")");
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.essentials.command;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
@CommandMeta(label = "sunset")
public class SunsetCommand {
public void execute(Player player) {
player.setPlayerTime(12000, false);
player.sendMessage(CC.GREEN + "It's now sunset.");
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/4/2019.
*/
@CommandMeta(label = "tpall", permission = "rank.manager")
public class TeleportAllCommand {
public void execute(Player player) {
for (Player other : Bukkit.getOnlinePlayers()) {
if (other == player)
continue;
other.teleport(player);
}
player.sendMessage(CC.GREEN + "All players have been teleported to you.");
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/4/2019.
*/
@CommandMeta(label = { "teleport", "tp" }, permission = "rank.trialmod")
public class TeleportCommand {
public void execute(Player player, Player target) {
if (target == null) {
player.sendMessage(CC.RED + "This player is not online.");
return;
}
player.teleport(target);
player.sendMessage(CC.translate(CC.translate("&6Teleported to %TELEPORTER%&6.")).replace("%TELEPORTER%", target.getDisplayName()));
}
}

View File

@ -0,0 +1,22 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/4/2019.
*/
@CommandMeta(label = "tphere", permission = "rank.seniormod")
public class TeleportHereCommand {
public void execute(Player player, Player target) {
if (target == null) {
player.sendMessage(CC.RED + "This player is not online.");
return;
}
target.teleport(player);
player.sendMessage(CC.translate(CC.translate("&6Teleported %PLAYER% &6to %TELEPORTER%&6.")).replace("%PLAYER%", target.getDisplayName()).replace("%TELEPORTER%", player.getDisplayName()));
}
}

View File

@ -0,0 +1,20 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Location;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/4/2019.
*/
@CommandMeta(label = "tppos", permission = "rank.trialmod")
public class TeleportPositionCommand {
public void execute(Player player, Double x, Double y, Double z) {
Location location = new Location(player.getWorld(), x, y, z);
player.teleport(location);
player.sendMessage(CC.translate(CC.translate("&6Teleported to x:&f %X% &6y: &f%Y%&6 z:&f%Z%")).replace("%X%", "" + x).replace("%Y%", "" + y).replace("%Z%", "" + z));
}
}

View File

@ -0,0 +1,31 @@
package net.centilehcf.core.essentials.command;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.entity.Player;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/8/2019.
*/
@CommandMeta(label = "world", permission = "rank.admin")
public class WorldCommand {
public void execute(Player player, String newworld) {
World world = Bukkit.getWorld(newworld);
if (world == null) {
player.sendMessage(CC.RED + "World not found!");
}
if (player.getWorld().equals(world)) {
player.sendMessage(CC.RED + "You are already in this world!");
}
Location playerlocation = player.getLocation();
Location newlocation = new Location(world, playerlocation.getX(), playerlocation.getY(), playerlocation.getZ(), playerlocation.getYaw(), playerlocation.getPitch());
player.teleport(newlocation);
player.sendMessage(CC.GREEN + "You have been sent to world " + CC.PINK + world + CC.GREEN + " !");
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.essentials.event;
import net.centilehcf.core.util.BaseEvent;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.BaseEvent;
import org.bukkit.Location;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class SpawnTeleportEvent extends BaseEvent implements Cancellable {
@Getter private final Player player;
@Getter @Setter private Location location;
@Getter @Setter private boolean cancelled;
public SpawnTeleportEvent(Player player, Location location) {
this.player = player;
this.location = location;
}
}

View File

@ -0,0 +1,33 @@
package net.centilehcf.core.essentials.listener;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.BootstrappedListener;
import org.bukkit.Material;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerItemDamageEvent;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.ThreadLocalRandom;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/12/2019.
*/
public class DurabilityListener extends BootstrappedListener {
private List<Material> ALLOWED = Arrays.asList(Material.GOLD_HELMET, Material.GOLD_CHESTPLATE, Material.GOLD_LEGGINGS, Material.GOLD_BOOTS, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.CHAINMAIL_HELMET, Material.CHAINMAIL_CHESTPLATE, Material.CHAINMAIL_LEGGINGS, Material.CHAINMAIL_BOOTS, Material.LEATHER_HELMET, Material.LEATHER_CHESTPLATE, Material.LEATHER_LEGGINGS, Material.LEATHER_BOOTS, Material.DIAMOND_HELMET, Material.DIAMOND_CHESTPLATE, Material.DIAMOND_LEGGINGS, Material.DIAMOND_BOOTS);
public DurabilityListener(Core core) {
super(core);
}
@EventHandler
public void onItemDamage(PlayerItemDamageEvent event) {
ItemStack stack = event.getItem();
if (stack != null && ALLOWED.contains(stack.getType()) && ThreadLocalRandom.current().nextInt(3) != 0) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,54 @@
package net.centilehcf.core.essentials.listener;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.BootstrappedListener;
import net.centilehcf.core.util.CC;
import java.util.Arrays;
import java.util.List;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockFadeEvent;
import org.bukkit.event.entity.FoodLevelChangeEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
public class EssentialsListener extends BootstrappedListener {
public EssentialsListener(Core core) {
super(core);
}
@EventHandler(priority = EventPriority.LOWEST)
public void onCommandProcess(PlayerCommandPreprocessEvent event) {
Player player = event.getPlayer();
final String lowercase = event.getMessage().toLowerCase();
if (lowercase.startsWith("//calc") ||
lowercase.startsWith("//eval") ||
lowercase.startsWith("//solve") ||
lowercase.startsWith("/me") ||
lowercase.startsWith("/bukkit:me") ||
lowercase.startsWith("/minecraft:") ||
lowercase.startsWith("/minecraft:me")) {
player.sendMessage(CC.WHITE + "Unknown command.");
event.setCancelled(true);
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void foodFix(FoodLevelChangeEvent event) {
if ((event.getEntity() instanceof Player)) {
Player player = (Player) event.getEntity();
player.setSaturation(10.0F);
}
}
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void onBlockFade(BlockFadeEvent event) {
if (event.getBlock().getType() == Material.ICE || event.getBlock().getType() == Material.PACKED_ICE || event.getBlock().getType() == Material.SNOW_BLOCK) {
event.setCancelled(true);
}
}
}

View File

@ -0,0 +1,236 @@
package net.centilehcf.core.hook;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.rank.Rank;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.stream.Collectors;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.rank.Rank;
import net.milkbowl.vault.permission.Permission;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
public class VaultProvider extends Permission {
@Override
public String getName() {
return "E";
}
@Override
public boolean isEnabled() {
return true;
}
@Override
public boolean hasGroupSupport() {
return true;
}
@Override
public boolean hasSuperPermsCompat() {
return true;
}
@Override
public boolean playerAddGroup(Player player, String group) {
Rank rank = Rank.getRankByDisplayName(group);
if (rank != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
profile.getGrants().add(new Grant(UUID.randomUUID(), rank, null,
System.currentTimeMillis(), "VaultAPI", Integer.MAX_VALUE));
return true;
}
}
return false;
}
@Override
public boolean playerAddGroup(String world, String playerName, String group) {
Rank rank = Rank.getRankByDisplayName(group);
if (rank != null) {
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
profile.getGrants().add(new Grant(UUID.randomUUID(), rank, null,
System.currentTimeMillis(), "VaultAPI", Integer.MAX_VALUE));
}
}
}
return false;
}
@Override
public String[] getPlayerGroups(String world, String playerName) {
List<String> rankNames = new ArrayList<>();
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
for (Grant grant : profile.getGrants()) {
if (!grant.isRemoved() && !grant.hasExpired()) {
if (!rankNames.contains(grant.getRank().getDisplayName())) {
rankNames.add(grant.getRank().getDisplayName());
}
}
}
}
}
return new String[0];
}
@Override
public boolean playerHas(String world, String playerName, String permission) {
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
for (Grant grant : profile.getGrants()) {
if (!grant.isRemoved() && !grant.hasExpired()) {
if (grant.getRank().getAllPermissions().contains(permission)) {
return true;
}
}
}
}
}
return false;
}
@Override
public boolean playerAdd(String world, String playerName, String permission) {
return false;
}
@Override
public boolean playerRemove(String world, String playerName, String permission) {
return false;
}
@Override
public boolean groupHas(String world, String group, String permission) {
Rank rank = Rank.getRankByDisplayName(group);
if (rank != null) {
return rank.getAllPermissions().contains(permission);
}
return false;
}
@Override
public boolean groupAdd(String world, String group, String permission) {
Rank rank = Rank.getRankByDisplayName(group);
if (rank != null) {
if (!rank.hasPermission(permission)) {
rank.addPermission(permission);
return true;
}
}
return false;
}
@Override
public boolean groupRemove(String world, String group, String permission) {
Rank rank = Rank.getRankByDisplayName(group);
if (rank != null) {
if (rank.hasPermission(permission)) {
rank.deletePermission(permission);
return true;
}
}
return false;
}
@Override
public boolean playerInGroup(String world, String playerName, String group) {
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
for (Grant grant : profile.getGrants()) {
if (grant.getRank().getDisplayName().equalsIgnoreCase(group)) {
return true;
}
}
}
}
return false;
}
@Override
public boolean playerRemoveGroup(String world, String playerName, String group) {
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
for (Grant grant : profile.getGrants()) {
if (grant.getRank().getDisplayName().equalsIgnoreCase(group)) {
grant.setRemoved(true);
grant.setRemovedBy(null);
grant.setRemovedAt(System.currentTimeMillis());
grant.setRemovedReason("VaultAPI");
return true;
}
}
}
}
return false;
}
@Override
public String getPrimaryGroup(String world, String playerName) {
Player player = Bukkit.getPlayer(playerName);
if (player != null) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
return profile.getActiveGrant().getRank().getDisplayName();
}
}
return "";
}
@Override
public String[] getGroups() {
return new ArrayList<>(Rank.getRanks().values()).stream()
.map(Rank::getDisplayName)
.collect(Collectors.toList())
.toArray(new String[Rank.getRanks().values().size()]);
}
}

View File

@ -0,0 +1,184 @@
package net.centilehcf.core.network;
import com.minexd.pidgin.packet.handler.IncomingPacketHandler;
import com.minexd.pidgin.packet.listener.PacketListener;
import net.centilehcf.core.Core;
import net.centilehcf.core.Locale;
import net.centilehcf.core.network.event.ReceiveRequestCommandEvent;
import net.centilehcf.core.network.event.ReceiveStaffChatEvent;
import net.centilehcf.core.network.packet.*;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.profile.grant.event.GrantAppliedEvent;
import net.centilehcf.core.profile.grant.event.GrantExpireEvent;
import net.centilehcf.core.profile.punishment.Punishment;
import net.centilehcf.core.profile.punishment.PunishmentType;
import net.centilehcf.core.rank.Rank;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitRunnable;
import java.util.Objects;
public class NetworkPacketListener implements PacketListener {
private Core core;
public NetworkPacketListener(Core core) {
this.core = core;
}
@IncomingPacketHandler
public void onAddGrant(PacketAddGrant packet) {
Player player = Bukkit.getPlayer(packet.getPlayerUuid());
Grant grant = packet.getGrant();
if (player != null) {
Profile profile = Profile.getProfiles().get(player.getUniqueId());
profile.getGrants().removeIf(other -> Objects.equals(other, grant));
profile.getGrants().add(grant);
new GrantAppliedEvent(player, grant);
}
}
@IncomingPacketHandler
public void onDeleteGrant(PacketDeleteGrant packet) {
Player player = Bukkit.getPlayer(packet.getPlayerUuid());
Grant grant = packet.getGrant();
if (player != null) {
Profile profile = Profile.getProfiles().get(player.getUniqueId());
profile.getGrants().removeIf(other -> Objects.equals(other, grant));
profile.getGrants().add(grant);
profile.checkGrants();
new GrantExpireEvent(player, grant);
}
}
@IncomingPacketHandler
public void onBroadcastPunishment(PacketBroadcastPunishment packet) {
Punishment punishment = packet.getPunishment();
punishment.broadcast(packet.getStaff(), packet.getTarget(), packet.isSilent());
Player player = Bukkit.getPlayer(packet.getTargetUuid());
if (player != null) {
Profile profile = Profile.getProfiles().get(player.getUniqueId());
profile.getPunishments().removeIf(other -> Objects.equals(other, punishment));
profile.getPunishments().add(punishment);
if (punishment.getType().isBan()) {
new BukkitRunnable() {
@Override
public void run() {
player.kickPlayer(punishment.getKickMessage());
}
}.runTask(Core.get());
}
if (punishment.getType() == PunishmentType.BLACKLIST) {
new BukkitRunnable() {
@Override
public void run() {
player.kickPlayer(punishment.getKickMessage());
}
}.runTask(Core.get());
}
}
}
@IncomingPacketHandler
public void onRankRefresh(PacketRefreshRank packet) {
Rank rank = Rank.getRankByUuid(packet.getUuid());
if (rank == null) {
rank = new Rank(packet.getUuid(), packet.getName());
}
rank.load();
Core.broadcastOps(Locale.NETWORK_RANK_REFRESHED.format(Locale.NETWORK_BROADCAST_PREFIX.format(),
rank.getDisplayName()));
}
@IncomingPacketHandler
public void onRankDelete(PacketDeleteRank packet) {
Rank rank = Rank.getRanks().remove(packet.getUuid());
if (rank != null) {
Core.broadcastOps(Locale.NETWORK_RANK_DELETED.format(Locale.NETWORK_BROADCAST_PREFIX.format(),
rank.getDisplayName()));
}
}
@IncomingPacketHandler
public void onStaffChat(PacketStaffChat packet) {
core.getServer().getOnlinePlayers().stream()
.filter(onlinePlayer -> onlinePlayer.hasPermission("core.staff"))
.forEach(onlinePlayer -> {
ReceiveStaffChatEvent event = new ReceiveStaffChatEvent(onlinePlayer);
core.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
if (Profile.getProfiles().get(event.getPlayer().getUniqueId()).getStaffOptions().isStaffChatEnabled()) {
onlinePlayer.sendMessage(Locale.STAFF_CHAT.format(Locale.STAFF_BROADCAST_PREFIX.format(),
packet.getPlayerName(), packet.getServerName(), packet.getChatMessage()
));
}
}
});
}
@IncomingPacketHandler
public void onRequestCommand(PacketRequestCommand packet) {
core.getServer().getOnlinePlayers().stream()
.filter(onlinePlayer -> onlinePlayer.hasPermission("core.staff"))
.forEach(onlinePlayer -> {
ReceiveRequestCommandEvent event = new ReceiveRequestCommandEvent(onlinePlayer);
core.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) {
onlinePlayer.sendMessage(Locale.STAFF_REQUEST.format(Locale.STAFF_REQUEST_PREFIX.format(),
packet.getServerName(), packet.getPlayerName(), packet.getRequest()
));
}
});
}
@IncomingPacketHandler
public void getServerStatus(PacketServerRestart packet) {
core.getServer().getOnlinePlayers().stream()
.filter(onlinePlayer -> onlinePlayer.hasPermission("core.staff"))
.forEach(onlinePlayer -> onlinePlayer.sendMessage(Locale.SERVER_STATUS.format(Locale.SERVER_STATUS_PREFIX.format(),
packet.getServerName(), packet.getStatus())));
}
@IncomingPacketHandler
public void onStaffJoinNetwork(PacketStaffJoinNetwork packet) {
core.getServer().broadcast(Locale.STAFF_JOIN_NETWORK.format(Locale.STAFF_BROADCAST_PREFIX.format(),
packet.getPlayerName(), packet.getServerName()), "core.staff");
}
@IncomingPacketHandler
public void onStaffLeaveNetwork(PacketStaffLeaveNetwork packet) {
core.getServer().broadcast(Locale.STAFF_LEAVE_NETWORK.format(Locale.STAFF_BROADCAST_PREFIX.format(),
packet.getPlayerName(), packet.getServerName()), "core.staff");
}
@IncomingPacketHandler
public void onStaffSwitchServer(PacketStaffSwitchServer packet) {
core.getServer().broadcast(Locale.STAFF_SWITCH_SERVER.format(Locale.STAFF_BROADCAST_PREFIX.format(),
packet.getPlayerName(), packet.getToServerName(), packet.getFromServerName()), "core.staff");
}
@IncomingPacketHandler
public void onPacketRemovePunishments(PacketRemovePunishments packet) {
Player player = Bukkit.getPlayer(packet.getUuid()); // We don't care if they aren't online
if (player != null) {
Profile profile = Profile.getByUuid(packet.getUuid());
profile.getPunishments().clear();
}
}
}

View File

@ -0,0 +1,22 @@
package net.centilehcf.core.network.event;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.BaseEvent;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/21/2019.
*/
public class ReceiveRequestCommandEvent extends BaseEvent implements Cancellable {
@Getter
private Player player;
@Getter @Setter
private boolean cancelled;
public ReceiveRequestCommandEvent(Player player) {
this.player = player;
}
}

View File

@ -0,0 +1,17 @@
package net.centilehcf.core.network.event;
import net.centilehcf.core.util.BaseEvent;
import lombok.Getter;
import lombok.Setter;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
public class ReceiveStaffChatEvent extends BaseEvent implements Cancellable {
@Getter private Player player;
@Getter @Setter private boolean cancelled;
public ReceiveStaffChatEvent(Player player) {
this.player = player;
}
}

View File

@ -0,0 +1,45 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
import lombok.Getter;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.util.json.JsonChain;
public class PacketAddGrant implements Packet {
@Getter private UUID playerUuid;
@Getter private Grant grant;
public PacketAddGrant() {
}
public PacketAddGrant(UUID playerUuid, Grant grant) {
this.playerUuid = playerUuid;
this.grant = grant;
}
@Override
public int id() {
return 1;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerUuid", playerUuid.toString())
.add("grant", Grant.SERIALIZER.serialize(grant))
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerUuid = UUID.fromString(jsonObject.get("playerUuid").getAsString());
grant = Grant.DESERIALIZER.deserialize(jsonObject.get("grant").getAsJsonObject());
}
}

View File

@ -0,0 +1,55 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.profile.punishment.Punishment;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
import lombok.Getter;
public class PacketBroadcastPunishment implements Packet {
@Getter private Punishment punishment;
@Getter private String staff;
@Getter private String target;
@Getter private UUID targetUuid;
@Getter private boolean silent;
public PacketBroadcastPunishment() {
}
public PacketBroadcastPunishment(Punishment punishment, String staff, String target, UUID targetUuid, boolean silent) {
this.punishment = punishment;
this.staff = staff;
this.target = target;
this.targetUuid = targetUuid;
this.silent = silent;
}
@Override
public int id() {
return 2;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.add("punishment", Punishment.SERIALIZER.serialize(punishment))
.addProperty("staff", staff)
.addProperty("target", target)
.addProperty("targetUuid", targetUuid.toString())
.addProperty("silent", silent)
.get();
}
@Override
public void deserialize(JsonObject object) {
punishment = Punishment.DESERIALIZER.deserialize(object.get("punishment").getAsJsonObject());
staff = object.get("staff").getAsString();
target = object.get("target").getAsString();
targetUuid = UUID.fromString(object.get("targetUuid").getAsString());
silent = object.get("silent").getAsBoolean();
}
}

View File

@ -0,0 +1,39 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
/**
* Created by DaddyDombo daddydombo@gmail.com on 5/14/2019.
*/
@AllArgsConstructor
@NoArgsConstructor
@Getter
public class PacketClearGrants implements Packet {
private UUID uuid;
@Override
public int id() {
return 13;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("uuid", uuid.toString())
.get();
}
@Override
public void deserialize(JsonObject object) {
uuid = UUID.fromString(object.get("uuid").getAsString());
}
}

View File

@ -0,0 +1,45 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
import lombok.Getter;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.util.json.JsonChain;
public class PacketDeleteGrant implements Packet {
@Getter private UUID playerUuid;
@Getter private Grant grant;
public PacketDeleteGrant() {
}
public PacketDeleteGrant(UUID playerUuid, Grant grant) {
this.playerUuid = playerUuid;
this.grant = grant;
}
@Override
public int id() {
return 3;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerUuid", playerUuid.toString())
.add("grant", Grant.SERIALIZER.serialize(grant))
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerUuid = UUID.fromString(jsonObject.get("playerUuid").getAsString());
grant = Grant.DESERIALIZER.deserialize(jsonObject.get("grant").getAsJsonObject());
}
}

View File

@ -0,0 +1,38 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.Core;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.json.JsonChain;
import lombok.NoArgsConstructor;
@NoArgsConstructor
public class PacketDeletePrefix implements Packet {
private String prefix;
public PacketDeletePrefix(String prefix) {
this.prefix = prefix;
}
@Override
public int id() {
return 11;
}
@Override
public JsonObject serialize() {
return new JsonChain().addProperty("name", prefix).get();
}
@Override
public void deserialize(JsonObject object) {
Profile.getProfiles().forEach((uuid, profile) -> {
if (profile.getPrefix().getName().equalsIgnoreCase(object.get("name").getAsString())) {
profile.setPrefix(Core.get().getPrefixHandler().getDefaultPrefix());
}
});
}
}

View File

@ -0,0 +1,38 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
@AllArgsConstructor
@Getter
public class PacketDeleteRank implements Packet {
private UUID uuid;
public PacketDeleteRank() {
}
@Override
public int id() {
return 4;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("uuid", uuid.toString())
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
uuid = UUID.fromString(jsonObject.get("uuid").getAsString());
}
}

View File

@ -0,0 +1,41 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
@AllArgsConstructor
@Getter
public class PacketRefreshRank implements Packet {
private UUID uuid;
private String name;
public PacketRefreshRank() {
}
@Override
public int id() {
return 5;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("uuid", uuid.toString())
.addProperty("name", name)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
uuid = UUID.fromString(jsonObject.get("uuid").getAsString());
name = jsonObject.get("name").getAsString();
}
}

View File

@ -0,0 +1,34 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import lombok.AllArgsConstructor;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
import java.util.UUID;
@Getter
@AllArgsConstructor
public class PacketRemovePunishments implements Packet {
private UUID uuid;
public PacketRemovePunishments() {
}
@Override
public int id() {
return 15;
}
@Override
public JsonObject serialize() {
return new JsonChain().addProperty("uuid", uuid.toString()).get();
}
@Override
public void deserialize(JsonObject object) {
this.uuid = UUID.fromString(object.get("uuid").getAsString());
}
}

View File

@ -0,0 +1,50 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.json.JsonChain;
/**
* Created by DaddyDombo daddydombo@gmail.com on 4/21/2019.
*/
@Getter
@Setter
public class PacketRequestCommand implements Packet {
private String playerName;
private String serverName;
private String request;
public PacketRequestCommand() {
}
public PacketRequestCommand(String serverName, String playerName, String request) {
this.serverName = serverName;
this.playerName = playerName;
this.request = request;
}
public int id() {
return 12;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("serverName", serverName)
.addProperty("playerName", playerName)
.addProperty("request", request)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
serverName = jsonObject.get("serverName").getAsString();
playerName = jsonObject.get("playerName").getAsString();
request = jsonObject.get("request").getAsString();
}
}

View File

@ -0,0 +1,44 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.json.JsonChain;
/**
* Created by DaddyDombo daddydombo@gmail.com on 5/21/2019.
*/
@Getter
@Setter
public class PacketServerRestart implements Packet {
private String serverName;
private String status;
public PacketServerRestart() {
}
public PacketServerRestart(String serverName, String status) {
this.serverName = serverName;
this.status = status;
}
public int id() {
return 14;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("serverName", serverName)
.addProperty("status", status)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
serverName = jsonObject.get("serverName").getAsString();
status = jsonObject.get("status").getAsString();
}
}

View File

@ -0,0 +1,48 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.json.JsonChain;
@Getter
@Setter
public class PacketStaffChat implements Packet {
private String playerName;
private String serverName;
private String chatMessage;
public PacketStaffChat() {
}
public PacketStaffChat(String playerName, String serverName, String chatMessage) {
this.playerName = playerName;
this.serverName = serverName;
this.chatMessage = chatMessage;
}
public int id() {
return 6;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerName", playerName)
.addProperty("serverName", serverName)
.addProperty("chatMessage", chatMessage)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerName = jsonObject.get("playerName").getAsString();
serverName = jsonObject.get("serverName").getAsString();
chatMessage = jsonObject.get("chatMessage").getAsString();
}
}

View File

@ -0,0 +1,43 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
@Getter
public class PacketStaffJoinNetwork implements Packet {
private String playerName;
private String serverName;
public PacketStaffJoinNetwork() {
}
public PacketStaffJoinNetwork(String playerName, String serverName) {
this.playerName = playerName;
this.serverName = serverName;
}
@Override
public int id() {
return 7;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerName", playerName)
.addProperty("serverName", serverName)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerName = jsonObject.get("playerName").getAsString();
serverName = jsonObject.get("serverName").getAsString();
}
}

View File

@ -0,0 +1,43 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
@Getter
public class PacketStaffLeaveNetwork implements Packet {
private String playerName;
private String serverName;
public PacketStaffLeaveNetwork() {
}
public PacketStaffLeaveNetwork(String playerName, String serverName) {
this.playerName = playerName;
this.serverName = serverName;
}
@Override
public int id() {
return 8;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerName", playerName)
.addProperty("serverName", serverName)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerName = jsonObject.get("playerName").getAsString();
serverName = jsonObject.get("serverName").getAsString();
}
}

View File

@ -0,0 +1,47 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.util.json.JsonChain;
import lombok.Getter;
import net.centilehcf.core.util.json.JsonChain;
@Getter
public class PacketStaffSwitchServer implements Packet {
private String playerName;
private String fromServerName;
private String toServerName;
public PacketStaffSwitchServer() {
}
public PacketStaffSwitchServer(String playerName, String fromServerName, String toServerName) {
this.playerName = playerName;
this.fromServerName = fromServerName;
this.toServerName = toServerName;
}
@Override
public int id() {
return 9;
}
@Override
public JsonObject serialize() {
return new JsonChain()
.addProperty("playerName", playerName)
.addProperty("fromServerName", fromServerName)
.addProperty("toServerName", toServerName)
.get();
}
@Override
public void deserialize(JsonObject jsonObject) {
playerName = jsonObject.get("playerName").getAsString();
fromServerName = jsonObject.get("fromServerName").getAsString();
toServerName = jsonObject.get("toServerName").getAsString();
}
}

View File

@ -0,0 +1,34 @@
package net.centilehcf.core.network.packet;
import com.google.gson.JsonObject;
import com.minexd.pidgin.packet.Packet;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.json.JsonChain;
import lombok.Getter;
import lombok.NoArgsConstructor;
@Getter
@NoArgsConstructor
public class PacketUpdatePrefix implements Packet {
private String prefixName;
public PacketUpdatePrefix(String prefixName) {
this.prefixName = prefixName;
}
@Override
public int id() {
return 10;
}
@Override
public JsonObject serialize() {
return new JsonChain().addProperty("name", prefixName).get();
}
@Override
public void deserialize(JsonObject object) {
Core.get().getPrefixHandler().loadPrefixByName(object.get("name").getAsString());
}
}

View File

@ -0,0 +1,30 @@
package net.centilehcf.core.prefix;
import net.centilehcf.core.util.CC;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.CC;
@Getter
@Setter
@EqualsAndHashCode
public class Prefix implements Comparable<Prefix> {
private String name;
private String prefix = "";
private int weight;
public Prefix(String name) {
this.name = name;
}
public String getPrefixInfo() {
return this.getName() + CC.RESET + "(W: " + this.getWeight() + ") (P: " + this.getPrefix() + ")";
}
@Override
public int compareTo(Prefix other) {
return Integer.compare(this.weight, other.weight);
}
}

View File

@ -0,0 +1,110 @@
package net.centilehcf.core.prefix;
import net.centilehcf.core.Core;
import net.centilehcf.core.network.packet.PacketDeletePrefix;
import net.centilehcf.core.network.packet.PacketUpdatePrefix;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.ReplaceOptions;
import lombok.Getter;
import org.bson.Document;
import org.bukkit.ChatColor;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class PrefixHandler {
private final Core plugin = Core.get();
private final MongoCollection<Document> prefixCollection;
@Getter
private final List<Prefix> prefixes;
public PrefixHandler() {
this.prefixes = new ArrayList<>();
this.prefixCollection = plugin.getMongoDatabase().getCollection("prefixes");
loadPrefixes();
}
public Prefix getPrefixByName(String search) {
return this.prefixes.stream().filter(prefix -> prefix.getName().equalsIgnoreCase(search)).findFirst().orElse(null);
}
public Prefix getDefaultPrefix() {
return this.prefixes.stream().filter(prefix -> prefix.getName().equalsIgnoreCase("Default")).findFirst().orElse(null);
}
private void loadPrefixes() {
for (Document document : prefixCollection.find()) {
Prefix prefix = new Prefix(document.getString("name"));
prefix.setPrefix(ChatColor.translateAlternateColorCodes('&', document.getString("prefix")));
prefix.setWeight(document.getInteger("weight"));
savePrefix(prefix);
}
// Create the default prefix if it doesn't exist!
if (getDefaultPrefix() == null) {
Prefix prefix = new Prefix("Default");
prefix.setPrefix("");
prefix.setWeight(-1);
savePrefix(prefix);
}
}
public Optional<Document> getPrefixDocumentFromDb(String name){
return Optional.ofNullable(prefixCollection.find(Filters.eq("name", name)).first());
}
public void loadPrefixByName(String name) {
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
getPrefixDocumentFromDb(name).ifPresent(document -> {
Prefix prefix = getPrefixByName(name);
if (prefix != null) {
prefix.setPrefix(ChatColor.translateAlternateColorCodes('&', document.getString("prefix")));
prefix.setWeight(document.getInteger("weight"));
} else {
prefix = new Prefix(document.getString("name"));
prefix.setPrefix(ChatColor.translateAlternateColorCodes('&', document.getString("prefix")));
prefix.setWeight(document.getInteger("weight"));
if (prefixes.contains(prefix)){
prefixes.remove(prefix);
prefixes.add(prefix);
} else {
prefixes.add(prefix);
}
}
});
});
}
public void savePrefix(Prefix prefix) {
if (!prefixes.contains(prefix)) {
prefixes.add(prefix);
}
Document document = new Document();
document.put("name", prefix.getName());
document.put("prefix", prefix.getPrefix().replace(ChatColor.COLOR_CHAR, '&'));
document.put("weight", prefix.getWeight());
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
prefixCollection.replaceOne(Filters.eq("name", prefix.getName()), document, new ReplaceOptions().upsert(true));
Core.get().getPidgin().sendPacket(new PacketUpdatePrefix(prefix.getName()));
});
}
public void removePrefix(Prefix prefix) {
prefixes.remove(prefix);
plugin.getServer().getScheduler().runTaskAsynchronously(plugin, () -> {
prefixCollection.deleteOne(Filters.eq("name", prefix.getName())); // Deletes the prefix
Core.get().getPidgin().sendPacket(new PacketDeletePrefix(prefix.getName()));
plugin.getMongoDatabase().getCollection("profiles") // Everyone that had that prefix gets their current one set to the default
.updateMany(Filters.eq("prefix", prefix.getName()), new Document("$set", getDefaultPrefix().getName()));
});
}
}

View File

@ -0,0 +1,22 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "prefix add", permission = "rank.manager")
public class AddPrefixCommand {
public void execute(CommandSender sender, String name){
if (Core.get().getPrefixHandler().getPrefixByName(name) != null){
sender.sendMessage(CC.RED + "A prefix with the name " + "\'" + name + "\' already exists!");
return;
}
Prefix prefix = new Prefix(name);
Core.get().getPrefixHandler().savePrefix(prefix);
sender.sendMessage(CC.GREEN + "Created a new prefix with the name \'" + name + "\'.");
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "prefix delete", permission = "rank.manager")
public class DeletePrefixCommand {
public void execute(CommandSender sender, Prefix prefix) {
Core.get().getPrefixHandler().removePrefix(prefix);
sender.sendMessage(CC.GREEN + "Removed the prefix \'" + prefix.getName() + "\'.");
}
}

View File

@ -0,0 +1,20 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "prefix list", permission = "rank.manager")
public class ListPrefixCommand {
public void execute(CommandSender sender) {
sender.sendMessage(CC.CHAT_BAR);
sender.sendMessage(CC.YELLOW + "Listing all prefixes");
for (Prefix prefix : Core.get().getPrefixHandler().getPrefixes()) {
sender.sendMessage(CC.RED + prefix.getName() + CC.YELLOW + " " + prefix.getPrefixInfo() + CC.GRAY + " (Displays as: " + prefix.getPrefix() + CC.GRAY + ")");
}
sender.sendMessage(CC.CHAT_BAR);
}
}

View File

@ -0,0 +1,21 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import com.qrakn.honcho.command.adapter.CommandTypeAdapter;
import java.util.List;
import java.util.stream.Collectors;
public class PrefixTypeAdapter implements CommandTypeAdapter {
@Override
public <T> T convert(String string, Class<T> type) {
return type.cast(Core.get().getPrefixHandler().getPrefixByName(string));
}
@Override
public <T> List<String> tabComplete(String string, Class<T> type) {
return Core.get().getPrefixHandler().getPrefixes().stream().map(Prefix::getName).collect(Collectors.toList());
}
}

View File

@ -0,0 +1,18 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "prefix setprefix", permission = "rank.manager")
public class SetPrefixCommand {
public void execute(CommandSender sender, Prefix prefix, String name) {
prefix.setPrefix(CC.translate(name));
sender.sendMessage(CC.GREEN + "Set the prefix of " + prefix.getName() + " to " + prefix.getPrefix() + '.');
Core.get().getPrefixHandler().savePrefix(prefix);
}
}

View File

@ -0,0 +1,16 @@
package net.centilehcf.core.prefix.command;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.util.CC;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.util.CC;
import org.bukkit.command.CommandSender;
@CommandMeta(label = "prefix setprefix", permission = "rank.manager")
public class SetPrefixWeightCommand {
public void execute(CommandSender sender, Prefix prefix, int weight) {
prefix.setWeight(weight);
sender.sendMessage(CC.GREEN + "Set the weight of \'" + prefix.getName() + "\' to " + weight + '.');
}
}

View File

@ -0,0 +1,103 @@
package net.centilehcf.core.prefix.menu;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import net.centilehcf.core.util.ItemBuilder;
import net.centilehcf.core.util.menu.Button;
import net.centilehcf.core.util.menu.Menu;
import lombok.AllArgsConstructor;
import org.bukkit.ChatColor;
import org.bukkit.DyeColor;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.inventory.ClickType;
import org.bukkit.inventory.ItemStack;
import java.util.*;
public class PrefixSelectionMenu extends Menu {
@Override
public String getTitle(Player player) {
return ChatColor.YELLOW.toString() + ChatColor.BOLD.toString() + "Choose a prefix.";
}
@Override
public Map<Integer, Button> getButtons(Player player) {
final Map<Integer, Button> buttons = new HashMap<>();
Core.get().getPrefixHandler().getPrefixes().sort(Comparator.comparingInt(Prefix::getWeight).reversed());
Core.get().getPrefixHandler().getPrefixes().forEach(prefix -> {
buttons.put(buttons.size(), new PrefixSelectionButton(prefix));
});
buttons.put(49, new Button() {
@Override
public ItemStack getButtonItem(Player player) {
return new ItemBuilder(Material.REDSTONE_BLOCK).name(CC.RED + "Reset prefix").lore(
Arrays.asList(
CC.SB_BAR,
CC.YELLOW + "Click to remove your prefix",
CC.SB_BAR
)
).build();
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarButton) {
Profile profile = Profile.getByUuid(player.getUniqueId());
if (profile != null) {
profile.setPrefix(Core.get().getPrefixHandler().getDefaultPrefix());
}
player.sendMessage(CC.YELLOW + "You have reset your prefix.");
}
});
return buttons;
}
@AllArgsConstructor
private static class PrefixSelectionButton extends Button {
private Prefix prefix;
@Override
public ItemStack getButtonItem(Player player) {
final List<String> lore = new ArrayList<>();
lore.add(0, CC.SB_BAR);
lore.add(CC.YELLOW + "Shows as " + prefix.getPrefix());
lore.add(CC.SB_BAR);
byte color;
if (Profile.getByUuid(player.getUniqueId()).getPrefix().equals(prefix)) {
color = DyeColor.GREEN.getData();
} else if (player.hasPermission("prefix." + prefix.getName())) {
color = DyeColor.SILVER.getData();
} else {
color = DyeColor.RED.getData();
}
return new ItemBuilder(Material.WOOL)
.name(ChatColor.GOLD + prefix.getName())
.lore(lore)
.durability(color)
.build();
}
@Override
public void clicked(Player player, int slot, ClickType clickType, int hotbarSlot) {
if (!player.hasPermission("prefix." + prefix.getName())) {
player.sendMessage(CC.RED + "You don't have access for that prefix! Purchase it on the store!");
return;
}
player.closeInventory();
player.sendMessage(CC.GREEN + "You have updated your prefix to: " + CC.WHITE + prefix.getName());
Profile.getByUuid(player.getUniqueId()).setPrefix(prefix);
}
}
}

View File

@ -0,0 +1,375 @@
package net.centilehcf.core.profile;
import com.google.gson.JsonArray;
import com.google.gson.JsonElement;
import com.google.gson.JsonObject;
import com.google.gson.JsonParser;
import net.centilehcf.core.Core;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.profile.grant.Grant;
import net.centilehcf.core.profile.grant.event.GrantAppliedEvent;
import net.centilehcf.core.profile.grant.event.GrantExpireEvent;
import net.centilehcf.core.profile.option.ProfileOptions;
import net.centilehcf.core.profile.option.ProfileStaffOptions;
import net.centilehcf.core.profile.punishment.Punishment;
import net.centilehcf.core.profile.punishment.PunishmentType;
import net.centilehcf.core.rank.Rank;
import com.mongodb.client.MongoCollection;
import com.mongodb.client.MongoCursor;
import com.mongodb.client.model.Filters;
import com.mongodb.client.model.ReplaceOptions;
import lombok.Getter;
import lombok.Setter;
import net.centilehcf.core.util.Cooldown;
import org.bson.Document;
import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player;
import org.bukkit.permissions.PermissionAttachment;
import org.bukkit.permissions.PermissionAttachmentInfo;
import java.util.*;
public class Profile {
@Getter
private static Map<UUID, Profile> profiles = new HashMap<>();
private static MongoCollection<Document> collection;
@Getter
private final UUID uuid;
@Getter
private final ProfileOptions options = new ProfileOptions();
@Getter
private final ProfileStaffOptions staffOptions = new ProfileStaffOptions();
@Getter
private final List<Grant> grants;
@Getter
private final List<Punishment> punishments;
@Getter
@Setter
private String username;
@Getter
@Setter
private Long firstSeen;
@Getter
@Setter
private Long lastSeen;
@Getter
@Setter
private String currentAddress;
@Getter
private List<String> ipAddresses = new ArrayList<>();
@Getter
private List<UUID> knownAlts = new ArrayList<>();
@Getter
private List<String> individualPermissions;
@Getter
private Grant activeGrant;
@Getter
@Setter
private Prefix prefix;
@Getter
@Setter
private UUID replyTo;
@Getter
@Setter
private boolean loaded;
@Getter
@Setter
private Cooldown requestCooldown = new Cooldown(0);
@Setter
@Getter
private Cooldown chatCooldown = new Cooldown(1000);
public Profile(String username, UUID uuid) {
this.username = username;
this.uuid = uuid;
this.grants = new ArrayList<>();
this.punishments = new ArrayList<>();
this.individualPermissions = new ArrayList<>();
load();
}
public static void init() {
collection = Core.get().getMongoDatabase().getCollection("profiles");
}
public static Profile getByUuid(UUID uuid) {
if (profiles.containsKey(uuid)) {
return profiles.get(uuid);
}
return new Profile(null, uuid);
}
public static Profile getByUsername(String username) {
Player player = Bukkit.getPlayer(username);
if (player != null) {
return profiles.get(player.getUniqueId());
}
OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(username);
if (offlinePlayer.hasPlayedBefore()) {
if (profiles.containsKey(offlinePlayer.getUniqueId())) {
return profiles.get(offlinePlayer.getUniqueId());
}
return new Profile(offlinePlayer.getName(), offlinePlayer.getUniqueId());
}
UUID uuid = Core.get().getUuidCache().getUuid(username);
if (uuid != null) {
if (profiles.containsKey(uuid)) {
return profiles.get(uuid);
}
return new Profile(username, uuid);
}
return null;
}
public static List<Profile> getByIpAddress(String ipAddress) {
List<Profile> profiles = new ArrayList<>();
try (MongoCursor<Document> cursor = collection.find(Filters.eq("currentAddress", ipAddress)).iterator()) {
while (cursor.hasNext()) {
Document document = cursor.next();
profiles.add(new Profile(document.getString("username"), UUID.fromString(document.getString("uuid"))));
}
}
return profiles;
}
public Player getPlayer() {
return Bukkit.getPlayer(uuid);
}
public String getColoredUsername() {
return activeGrant.getRank().getColor() + username;
}
public Punishment getActiveMute() {
for (Punishment punishment : punishments) {
if (punishment.getType() == PunishmentType.MUTE && punishment.isActive()) {
return punishment;
}
}
return null;
}
public Punishment getActiveBlacklist() {
for (Punishment punishment : punishments) {
if (punishment.getType() == PunishmentType.BLACKLIST && punishment.isActive()) {
return punishment;
}
}
return null;
}
public Punishment getActiveBan() {
for (Punishment punishment : punishments) {
if (punishment.getType().isBan() && punishment.isActive()) {
return punishment;
}
}
return null;
}
public int getPunishmentCountByType(PunishmentType type) {
int i = 0;
for (Punishment punishment : punishments) {
if (punishment.getType() == type) i++;
}
return i;
}
public Rank getActiveRank() {
return activeGrant.getRank();
}
public void setActiveGrant(Grant grant) {
activeGrant = grant;
Player player = getPlayer();
if (player != null) {
player.setDisplayName(grant.getRank().getPrefix() + player.getName() + grant.getRank().getSuffix());
}
}
public void activateNextGrant() {
List<Grant> grants = new ArrayList<>(this.grants);
grants.sort(Comparator.comparingInt(grant -> grant.getRank().getWeight()));
for (Grant grant : grants) {
if (!grant.isRemoved() && !grant.hasExpired()) {
setActiveGrant(grant);
}
}
}
public void checkGrants() {
for (Grant grant : grants) {
if (!grant.isRemoved() && grant.hasExpired()) {
grant.setRemovedAt(System.currentTimeMillis());
grant.setRemovedReason("Grant expired");
grant.setRemoved(true);
if (activeGrant != null && activeGrant.equals(grant)) {
activeGrant = null;
}
Player player = getPlayer();
if (player != null) {
new GrantExpireEvent(player, grant).call();
}
}
}
if (activeGrant == null) {
activateNextGrant();
if (activeGrant != null) {
return;
}
Grant grant = new Grant(UUID.randomUUID(), Rank.getDefaultRank(), null,
System.currentTimeMillis(), "Default", Integer.MAX_VALUE);
this.grants.add(grant);
setActiveGrant(grant);
Player player = getPlayer();
if (player != null) {
new GrantAppliedEvent(player, grant).call();
}
}
}
public void setupPermissionsAttachment(Core core, Player player) {
for (PermissionAttachmentInfo attachmentInfo : player.getEffectivePermissions()) {
if (attachmentInfo.getAttachment() == null) {
continue;
}
attachmentInfo.getAttachment().getPermissions().forEach((permission, value) -> {
attachmentInfo.getAttachment().unsetPermission(permission);
});
}
PermissionAttachment attachment = player.addAttachment(core);
for (String perm : activeGrant.getRank().getAllPermissions()) { // Rank permissions
attachment.setPermission(perm, true);
}
// Check for 'null' permissions
individualPermissions.removeIf(s -> s == null || s.isEmpty());
for (String permission : individualPermissions) { // Individual permissions
attachment.setPermission(permission, true);
}
player.recalculatePermissions();
}
public void load() {
final Document document = collection.find(Filters.eq("uuid", uuid.toString())).first();
if (document != null) {
if (username == null) {
username = document.getString("username");
}
firstSeen = document.getLong("firstSeen");
lastSeen = document.getLong("lastSeen");
currentAddress = document.getString("currentAddress");
ipAddresses = Core.GSON.fromJson(document.getString("ipAddresses"), Core.LIST_STRING_TYPE);
this.individualPermissions = Core.GSON.fromJson(document.getString("individualPermissions"), Core.LIST_STRING_TYPE);
Prefix prefix = Core.get().getPrefixHandler().getPrefixByName(document.getString("prefix"));
if (prefix != null) {
this.prefix = prefix;
} else {
this.prefix = Core.get().getPrefixHandler().getDefaultPrefix();
}
Document optionsDocument = (Document) document.get("options");
options.setPublicChatEnabled(optionsDocument.getBoolean("publicChatEnabled"));
options.setPrivateChatEnabled(optionsDocument.getBoolean("privateChatEnabled"));
options.setPrivateChatSoundsEnabled(optionsDocument.getBoolean("privateChatSoundsEnabled"));
JsonArray grants = new JsonParser().parse(document.getString("grants")).getAsJsonArray();
for (JsonElement jsonElement : grants) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
Rank rank = Rank.getRankByUuid(UUID.fromString(jsonObject.get("rank").getAsString()));
if (rank != null) {
this.grants.add(Grant.DESERIALIZER.deserialize(jsonObject));
}
}
JsonArray punishments = new JsonParser().parse(document.getString("punishments")).getAsJsonArray();
for (JsonElement jsonElement : punishments) {
JsonObject jsonObject = jsonElement.getAsJsonObject();
this.punishments.add(Punishment.DESERIALIZER.deserialize(jsonObject));
}
}
checkGrants();
// Set loaded to true
loaded = true;
}
public void save() {
Document document = new Document();
document.put("username", username);
document.put("uuid", uuid.toString());
document.put("firstSeen", firstSeen);
document.put("lastSeen", lastSeen);
document.put("currentAddress", currentAddress);
document.put("ipAddresses", Core.GSON.toJson(ipAddresses, Core.LIST_STRING_TYPE));
document.put("individualPermissions", Core.GSON.toJson(individualPermissions, Core.LIST_STRING_TYPE));
if (this.prefix != null) {
document.put("prefix", this.prefix.getName());
} else {
document.put("prefix", Core.get().getPrefixHandler().getDefaultPrefix().getName());
}
Document optionsDocument = new Document();
optionsDocument.put("publicChatEnabled", options.isPublicChatEnabled());
optionsDocument.put("privateChatEnabled", options.isPrivateChatEnabled());
optionsDocument.put("privateChatSoundsEnabled", options.isPrivateChatSoundsEnabled());
document.put("options", optionsDocument);
JsonArray grants = new JsonArray();
for (Grant grant : this.grants) {
grants.add(Grant.SERIALIZER.serialize(grant));
}
document.put("grants", grants.toString());
JsonArray punishments = new JsonArray();
for (Punishment punishment : this.punishments) {
punishments.add(Punishment.SERIALIZER.serialize(punishment));
}
document.put("punishments", punishments.toString());
collection.replaceOne(Filters.eq("uuid", uuid.toString()), document, new ReplaceOptions().upsert(true));
}
}

View File

@ -0,0 +1,51 @@
package net.centilehcf.core.profile;
import net.centilehcf.core.Core;
import net.centilehcf.core.util.BukkitReflection;
import org.bukkit.entity.Player;
import java.util.UUID;
/**
* Created by DaddyDombo daddydombo@gmail.com on 3/29/2019.
*/
public class ProfileInfo {
private UUID uuid;
private String name;
public ProfileInfo(Player player) {
this.uuid = player.getUniqueId();
this.name = player.getName();
}
public ProfileInfo(UUID uuid, String name) {
this.uuid = uuid;
this.name = name;
}
public Player toPlayer() {
Player player = Core.get().getServer().getPlayer(this.getUuid());
return player != null && player.isOnline() ? player : null;
}
public String getDisplayName() {
Player player = this.toPlayer();
return player == null ? this.getName() : player.getDisplayName();
}
public int getPing() {
Player player = Core.get().getServer().getPlayer(this.getUuid());
return player == null ? 0 : BukkitReflection.getPing(player);
}
public UUID getUuid() {
return this.uuid;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
}

View File

@ -0,0 +1,156 @@
package net.centilehcf.core.profile;
import net.centilehcf.core.Locale;
import net.centilehcf.core.Core;
import net.centilehcf.core.bootstrap.BootstrappedListener;
import net.centilehcf.core.network.packet.PacketStaffJoinNetwork;
import net.centilehcf.core.network.packet.PacketStaffLeaveNetwork;
import net.centilehcf.core.prefix.Prefix;
import net.centilehcf.core.prefix.PrefixHandler;
import net.centilehcf.core.profile.punishment.Punishment;
import net.centilehcf.core.util.CC;
import java.util.List;
import java.util.logging.Level;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerPreLoginEvent;
import org.bukkit.event.player.PlayerJoinEvent;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.scheduler.BukkitRunnable;
public class ProfileListener extends BootstrappedListener {
public ProfileListener(Core core) {
super(core);
}
@EventHandler
public void onAsyncPlayerPreLogin(AsyncPlayerPreLoginEvent event) {
Player player = core.getServer().getPlayer(event.getUniqueId());
if (!Core.get().isLoaded()) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(CC.RED + "The server is starting...");
return;
}
// Need to check if player is still logged in when receiving another login attempt
// This happens when a player using a custom client can access the server list while in-game (and reconnecting)
if (player != null && player.isOnline()) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(CC.RED + "You tried to login too quickly after disconnecting.\nTry again in a few seconds.");
core.getServer().getScheduler().runTask(core, () -> player.kickPlayer(CC.RED + "Duplicate login kick"));
return;
}
Profile profile = null;
try {
profile = new Profile(event.getName(), event.getUniqueId());
if (!profile.isLoaded()) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(Locale.FAILED_TO_LOAD_PROFILE.format());
return;
}
if (profile.getActiveBan() != null) {
handleBan(event, profile.getActiveBan());
return;
}
if (profile.getActiveBlacklist() != null) {
handleBan(event, profile.getActiveBlacklist());
}
profile.setUsername(event.getName());
if (profile.getFirstSeen() == null) {
profile.setFirstSeen(System.currentTimeMillis());
}
profile.setLastSeen(System.currentTimeMillis());
if (profile.getCurrentAddress() == null) {
profile.setCurrentAddress(event.getAddress().getHostAddress());
}
if (!profile.getIpAddresses().contains(event.getAddress().getHostAddress())) {
profile.getIpAddresses().add(event.getAddress().getHostAddress());
}
if (!profile.getCurrentAddress().equals(event.getAddress().getHostAddress())) {
List<Profile> alts = Profile.getByIpAddress(event.getAddress().getHostAddress());
for (Profile alt : alts) {
if (alt.getActiveBan() != null) {
handleBan(event, alt.getActiveBan());
return;
}
profile.getKnownAlts().add(alt.getUuid());
}
}
profile.save();
} catch (Exception e) {
core.debug(Level.SEVERE, "Failed to load profile for " + event.getName(), e);
}
if (profile == null || !profile.isLoaded()) {
event.setKickMessage(Locale.FAILED_TO_LOAD_PROFILE.format());
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
return;
}
Profile.getProfiles().put(profile.getUuid(), profile);
core.getUuidCache().update(event.getName(), event.getUniqueId());
}
@EventHandler
public void onPlayerJoin(PlayerJoinEvent event) {
event.setJoinMessage(null);
Player player = event.getPlayer();
Profile profile = Profile.getProfiles().get(player.getUniqueId());
profile.setupPermissionsAttachment(core, event.getPlayer());
player.setDisplayName(profile.getActiveGrant().getRank().getPrefix() + player.getName() + profile.getActiveGrant().getRank().getSuffix());
if (player.hasPermission("core.staff")) {
String server = Core.get().getMainConfig().getConfiguration().getString("SERVER_NAME");
Core.get().getPidgin().sendPacket(new PacketStaffJoinNetwork(player.getDisplayName(), server));
}
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
event.setQuitMessage(null);
Profile profile = Profile.getProfiles().remove(event.getPlayer().getUniqueId());
profile.setLastSeen(System.currentTimeMillis());
Player player = event.getPlayer();
if (player.hasPermission("core.staff")) {
String server = Core.get().getMainConfig().getConfiguration().getString("SERVER_NAME");
Core.get().getPidgin().sendPacket(new PacketStaffLeaveNetwork(player.getDisplayName(), server));
}
if (profile.isLoaded()) {
new BukkitRunnable() {
@Override
public void run() {
try {
profile.save();
} catch (Exception e) {
core.debug(Level.SEVERE, "Failed to save profile " + event.getPlayer().getName(), e);
}
}
}.runTaskAsynchronously(Core.get());
}
}
private void handleBan(AsyncPlayerPreLoginEvent event, Punishment punishment) {
event.setLoginResult(AsyncPlayerPreLoginEvent.Result.KICK_OTHER);
event.setKickMessage(punishment.getKickMessage());
}
}

View File

@ -0,0 +1,28 @@
package net.centilehcf.core.profile;
import com.qrakn.honcho.command.adapter.CommandTypeAdapter;
import java.util.ArrayList;
import java.util.List;
public class ProfileTypeAdapter implements CommandTypeAdapter {
public <T> T convert(String string, Class<T> type) {
return type.cast(Profile.getByUsername(string));
}
@Override
public <T> List<String> tabComplete(String string, Class<T> type) {
List<String> completed = new ArrayList<>();
for (Profile profile : Profile.getProfiles().values()) {
if (profile.getUsername() == null) continue;
if (profile.getUsername().toLowerCase().startsWith(string.toLowerCase())) {
completed.add(profile.getUsername());
}
}
return completed;
}
}

View File

@ -0,0 +1,41 @@
package net.centilehcf.core.profile.command;
import com.qrakn.honcho.command.CPL;
import com.qrakn.honcho.command.CommandMeta;
import net.centilehcf.core.Core;
import net.centilehcf.core.Locale;
import net.centilehcf.core.profile.Profile;
import net.centilehcf.core.util.CC;
import net.minecraft.util.com.google.common.base.Joiner;
import org.bukkit.command.CommandSender;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
@CommandMeta(label = "alts", async = true, permission = "rank.mod")
public class AltsCommand {
public void execute(CommandSender sender, @CPL("player") Profile profile) {
if (profile == null || !profile.isLoaded()) {
sender.sendMessage(Locale.COULD_NOT_RESOLVE_PLAYER.format());
return;
}
List<String> alts = new ArrayList<>();
for (UUID altUuid : profile.getKnownAlts()) {
String cachedName = Core.get().getUuidCache().getName(altUuid);
if (cachedName != null) {
alts.add(cachedName);
}
}
if (alts.isEmpty()) {
sender.sendMessage(CC.RED + "This player has no known alt accounts.");
} else {
sender.sendMessage(CC.GOLD + "Alts: " + CC.RESET + Joiner.on(", ").join(alts));
}
}
}

Some files were not shown because too many files have changed in this diff Show More