完成基本功能
This commit is contained in:
commit
4dc0f661e9
27 changed files with 1206 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
||||||
|
/target/
|
3
.idea/.gitignore
vendored
Normal file
3
.idea/.gitignore
vendored
Normal file
|
@ -0,0 +1,3 @@
|
||||||
|
# Default ignored files
|
||||||
|
/shelf/
|
||||||
|
/workspace.xml
|
9
.idea/UnionBan-Client-Spigot.iml
Normal file
9
.idea/UnionBan-Client-Spigot.iml
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" inherit-compiler-output="true">
|
||||||
|
<exclude-output />
|
||||||
|
<content url="file://$MODULE_DIR$" />
|
||||||
|
<orderEntry type="inheritedJdk" />
|
||||||
|
<orderEntry type="sourceFolder" forTests="false" />
|
||||||
|
</component>
|
||||||
|
</module>
|
16
.idea/compiler.xml
Normal file
16
.idea/compiler.xml
Normal file
|
@ -0,0 +1,16 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="CompilerConfiguration">
|
||||||
|
<annotationProcessing>
|
||||||
|
<profile name="Maven default annotation processors profile" enabled="true">
|
||||||
|
<sourceOutputDir name="target/generated-sources/annotations" />
|
||||||
|
<sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
|
||||||
|
<outputRelativeToContentRoot value="true" />
|
||||||
|
<module name="UnionBanClientSpigot" />
|
||||||
|
</profile>
|
||||||
|
</annotationProcessing>
|
||||||
|
<bytecodeTargetLevel>
|
||||||
|
<module name="UnionBan-Client-Spigot" target="1.5" />
|
||||||
|
</bytecodeTargetLevel>
|
||||||
|
</component>
|
||||||
|
</project>
|
7
.idea/encodings.xml
Normal file
7
.idea/encodings.xml
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Encoding">
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
|
||||||
|
<file url="file://$PROJECT_DIR$/src/main/resources" charset="UTF-8" />
|
||||||
|
</component>
|
||||||
|
</project>
|
30
.idea/jarRepositories.xml
Normal file
30
.idea/jarRepositories.xml
Normal file
|
@ -0,0 +1,30 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="RemoteRepositoriesConfiguration">
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://maven.aliyun.com/repository/public" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Central Repository" />
|
||||||
|
<option name="url" value="https://repo.maven.apache.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="central" />
|
||||||
|
<option name="name" value="Maven Central repository" />
|
||||||
|
<option name="url" value="https://repo1.maven.org/maven2" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="spigotmc-repo" />
|
||||||
|
<option name="name" value="spigotmc-repo" />
|
||||||
|
<option name="url" value="https://hub.spigotmc.org/nexus/content/repositories/snapshots/" />
|
||||||
|
</remote-repository>
|
||||||
|
<remote-repository>
|
||||||
|
<option name="id" value="jboss.community" />
|
||||||
|
<option name="name" value="JBoss Community repository" />
|
||||||
|
<option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
|
||||||
|
</remote-repository>
|
||||||
|
</component>
|
||||||
|
</project>
|
14
.idea/misc.xml
Normal file
14
.idea/misc.xml
Normal file
|
@ -0,0 +1,14 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="ExternalStorageConfigurationManager" enabled="true" />
|
||||||
|
<component name="MavenProjectsManager">
|
||||||
|
<option name="originalFiles">
|
||||||
|
<list>
|
||||||
|
<option value="$PROJECT_DIR$/pom.xml" />
|
||||||
|
</list>
|
||||||
|
</option>
|
||||||
|
</component>
|
||||||
|
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
|
||||||
|
<output url="file://$PROJECT_DIR$/out" />
|
||||||
|
</component>
|
||||||
|
</project>
|
124
.idea/uiDesigner.xml
Normal file
124
.idea/uiDesigner.xml
Normal file
|
@ -0,0 +1,124 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="Palette2">
|
||||||
|
<group name="Swing">
|
||||||
|
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.png" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Button" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="RadioButton" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="CheckBox" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||||
|
<initial-values>
|
||||||
|
<property name="text" value="Label" />
|
||||||
|
</initial-values>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||||
|
<preferred-size width="150" height="-1" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||||
|
<preferred-size width="150" height="50" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||||
|
<preferred-size width="200" height="200" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.png" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||||
|
<preferred-size width="-1" height="20" />
|
||||||
|
</default-constraints>
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.png" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||||
|
</item>
|
||||||
|
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.png" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||||
|
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||||
|
</item>
|
||||||
|
</group>
|
||||||
|
</component>
|
||||||
|
</project>
|
6
.idea/vcs.xml
Normal file
6
.idea/vcs.xml
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project version="4">
|
||||||
|
<component name="VcsDirectoryMappings">
|
||||||
|
<mapping directory="$PROJECT_DIR$" vcs="Git" />
|
||||||
|
</component>
|
||||||
|
</project>
|
24
UnionBan-Client-Spigot.iml
Normal file
24
UnionBan-Client-Spigot.iml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<module type="JAVA_MODULE" version="4">
|
||||||
|
<component name="NewModuleRootManager" LANGUAGE_LEVEL="JDK_1_5">
|
||||||
|
<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$/src/main/java" 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: org.spigotmc:spigot-api:1.15.2-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.google.guava:guava:21.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: com.google.code.gson:gson:2.8.0" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: net.md-5:bungeecord-chat:1.15-SNAPSHOT" level="project" />
|
||||||
|
<orderEntry type="library" scope="PROVIDED" name="Maven: org.yaml:snakeyaml:1.25" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-databind:2.11.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-annotations:2.11.0" level="project" />
|
||||||
|
<orderEntry type="library" name="Maven: com.fasterxml.jackson.core:jackson-core:2.11.0" level="project" />
|
||||||
|
</component>
|
||||||
|
</module>
|
53
dependency-reduced-pom.xml
Normal file
53
dependency-reduced-pom.xml
Normal file
|
@ -0,0 +1,53 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
<groupId>cn.cnklp.studio</groupId>
|
||||||
|
<artifactId>UnionBanClientSpigot</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
<properties>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
</properties>
|
||||||
|
</project>
|
65
pom.xml
Normal file
65
pom.xml
Normal file
|
@ -0,0 +1,65 @@
|
||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||||
|
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||||
|
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||||
|
<modelVersion>4.0.0</modelVersion>
|
||||||
|
|
||||||
|
<groupId>cn.cnklp.studio</groupId>
|
||||||
|
<artifactId>UnionBanClientSpigot</artifactId>
|
||||||
|
<version>1.0-SNAPSHOT</version>
|
||||||
|
|
||||||
|
<repositories>
|
||||||
|
<repository>
|
||||||
|
<id>spigotmc-repo</id>
|
||||||
|
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
||||||
|
</repository>
|
||||||
|
</repositories>
|
||||||
|
|
||||||
|
<dependencies>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.spigotmc</groupId>
|
||||||
|
<artifactId>spigot-api</artifactId>
|
||||||
|
<version>1.15.2-R0.1-SNAPSHOT</version>
|
||||||
|
<scope>provided</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
<artifactId>jackson-databind</artifactId>
|
||||||
|
<version>2.11.0</version>
|
||||||
|
</dependency>
|
||||||
|
</dependencies>
|
||||||
|
|
||||||
|
<properties>
|
||||||
|
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||||
|
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
|
||||||
|
</properties>
|
||||||
|
|
||||||
|
<build>
|
||||||
|
<plugins>
|
||||||
|
<plugin>
|
||||||
|
<groupId>org.apache.maven.plugins</groupId>
|
||||||
|
<artifactId>maven-shade-plugin</artifactId>
|
||||||
|
<version>3.2.3</version>
|
||||||
|
<executions>
|
||||||
|
<execution>
|
||||||
|
<phase>package</phase>
|
||||||
|
<goals>
|
||||||
|
<goal>shade</goal>
|
||||||
|
</goals>
|
||||||
|
<configuration>
|
||||||
|
<minimizeJar>true</minimizeJar>
|
||||||
|
</configuration>
|
||||||
|
</execution>
|
||||||
|
</executions>
|
||||||
|
</plugin>
|
||||||
|
<plugin>
|
||||||
|
<artifactId>maven-compiler-plugin</artifactId>
|
||||||
|
<version>3.8.1</version>
|
||||||
|
<configuration>
|
||||||
|
<source>1.8</source>
|
||||||
|
<target>1.8</target>
|
||||||
|
</configuration>
|
||||||
|
</plugin>
|
||||||
|
</plugins>
|
||||||
|
</build>
|
||||||
|
</project>
|
|
@ -0,0 +1,46 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class BanTask extends BukkitRunnable {
|
||||||
|
private final String username;
|
||||||
|
private final CommandSender sender;
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public BanTask(ClientPlugin plugin, CommandSender sender, String username) {
|
||||||
|
this.sender = sender;
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String uuid;
|
||||||
|
sender.sendMessage("Querying UUID of player " + username + " from Mojang server...");
|
||||||
|
try {
|
||||||
|
uuid = PlayerUUID.FromUsername(username);
|
||||||
|
sender.sendMessage("UUID of player " + username + " is " + uuid + ".");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("Player does not exist!")) {
|
||||||
|
sender.sendMessage("Player " + username + " does not exist!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Cannot connect to Mojang server!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PlayerUUID.Ban(plugin.ServerAddress, uuid);
|
||||||
|
sender.sendMessage("Banned player " + username + " successfully!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("Record exists!")) {
|
||||||
|
sender.sendMessage("Player " + username + " is already in the UnionBan list!");
|
||||||
|
} else if (e.getMessage().equals("Not logged in!")) {
|
||||||
|
sender.sendMessage("You have not logged in!");
|
||||||
|
} else {
|
||||||
|
e.printStackTrace();
|
||||||
|
sender.sendMessage("Failed to ban player " + username + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,33 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.HandlerList;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
|
import java.net.CookieHandler;
|
||||||
|
import java.net.CookieManager;
|
||||||
|
import java.net.CookiePolicy;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class ClientPlugin extends JavaPlugin {
|
||||||
|
public String ServerAddress = "https://api.unionban.icu";
|
||||||
|
public BukkitTask login = null;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onEnable() {
|
||||||
|
CookieHandler.setDefault(new CookieManager(null, CookiePolicy.ACCEPT_ALL));
|
||||||
|
getServer().getPluginManager().registerEvents(new PlayerLoginListener(this), this);
|
||||||
|
getServer().getPluginManager().registerEvents(new WhitelistListener(this), this);
|
||||||
|
CommandsExecutor executor = new CommandsExecutor(this);
|
||||||
|
Objects.requireNonNull(this.getCommand("unionban")).setExecutor(executor);
|
||||||
|
Objects.requireNonNull(this.getCommand("unionban")).setTabCompleter(executor);
|
||||||
|
saveDefaultConfig();
|
||||||
|
new LoginTask(this, Bukkit.getConsoleSender()).runTaskAsynchronously(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onDisable() {
|
||||||
|
HandlerList.unregisterAll(this);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,105 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.OfflinePlayer;
|
||||||
|
import org.bukkit.command.Command;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.command.TabExecutor;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class CommandsExecutor implements TabExecutor {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
private final List<String> SubCommands = new ArrayList<>();
|
||||||
|
|
||||||
|
public CommandsExecutor(ClientPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
SubCommands.add("help");
|
||||||
|
SubCommands.add("status");
|
||||||
|
SubCommands.add("login");
|
||||||
|
SubCommands.add("logout");
|
||||||
|
SubCommands.add("ban");
|
||||||
|
SubCommands.add("pardon");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
|
if (sender.hasPermission("unionban.account")) {
|
||||||
|
if (args.length == 3 && args[0].equals("login")) {
|
||||||
|
if (plugin.login != null) {
|
||||||
|
plugin.login.cancel();
|
||||||
|
plugin.login = null;
|
||||||
|
}
|
||||||
|
plugin.getConfig().set("username", args[1]);
|
||||||
|
plugin.getConfig().set("password", args[2]);
|
||||||
|
plugin.getConfig().set("api_key", "");
|
||||||
|
plugin.saveConfig();
|
||||||
|
new LoginTask(plugin, sender).runTaskAsynchronously(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 1 && args[0].equals("logout")) {
|
||||||
|
sender.sendMessage("Logging out...");
|
||||||
|
if (plugin.login != null) {
|
||||||
|
plugin.login.cancel();
|
||||||
|
plugin.login = null;
|
||||||
|
}
|
||||||
|
plugin.getConfig().set("username", "");
|
||||||
|
plugin.getConfig().set("password", "");
|
||||||
|
plugin.getConfig().set("api_key", "");
|
||||||
|
plugin.saveConfig();
|
||||||
|
new LogoutTask(plugin, sender).runTaskAsynchronously(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("unionban.ban")) {
|
||||||
|
if (args.length == 2 && args[0].equals("ban")) {
|
||||||
|
new BanTask(plugin, sender, args[1]).runTaskAsynchronously(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
if (args.length == 2 && args[0].equals("pardon")) {
|
||||||
|
new PardonTask(plugin, sender, args[1]).runTaskAsynchronously(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (sender.hasPermission("unionban.info")) {
|
||||||
|
if (args.length == 0) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (args.length == 1 && args[0].equals("help")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (args.length == 1 && args[0].equals("status")) {
|
||||||
|
new GetServerStatusTask(plugin, sender).runTaskAsynchronously(plugin);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sender.sendMessage("Unknown command. Type \"/unionban help\" for help.");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
sender.sendMessage("You do not have permission to execute this command!");
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
builder.append(cmd);
|
||||||
|
for (String arg : args) {
|
||||||
|
builder.append(" ");
|
||||||
|
builder.append(arg);
|
||||||
|
}
|
||||||
|
plugin.getLogger().warning(sender.getName() + " tried to execute command: " + builder);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> onTabComplete(CommandSender sender, Command cmd, String alias, String[] args) {
|
||||||
|
List<String> result = new ArrayList<>();
|
||||||
|
if (args.length == 1) {
|
||||||
|
result.addAll(SubCommands);
|
||||||
|
} else if (args.length == 2 && (args[0].equals("ban") || args[0].equals("pardon"))) {
|
||||||
|
for (OfflinePlayer player : Bukkit.getOfflinePlayers()) {
|
||||||
|
String name = player.getName();
|
||||||
|
if (name != null) {
|
||||||
|
result.add(name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,74 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
class ServerStatus {
|
||||||
|
public String version;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GetServerStatusTask extends BukkitRunnable {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public GetServerStatusTask(ClientPlugin plugin, CommandSender sender) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String GetVersion(String ServerAddress) throws Exception {
|
||||||
|
URL url = new URL(ServerAddress);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
if (responseCode != 200) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("HTTP Response Code: " + responseCode);
|
||||||
|
}
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
|
builder.append(inputLine);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
ServerStatus status = objectMapper.readValue(builder.toString(), ServerStatus.class);
|
||||||
|
|
||||||
|
return status.version;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
sender.sendMessage("Querying server status...");
|
||||||
|
try {
|
||||||
|
String version = GetVersion(plugin.ServerAddress);
|
||||||
|
sender.sendMessage("UnionBan Server is ON! Version: " + version);
|
||||||
|
String username = LoginTask.GetLoginStatus(plugin.ServerAddress).username;
|
||||||
|
sender.sendMessage("Logged in as " + plugin.getConfig().getString("username") + ".");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("Not logged in!")) {
|
||||||
|
sender.sendMessage("You have not logged in!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Failed to connect to UnionBan server.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
|
public class KickPlayerTask extends BukkitRunnable {
|
||||||
|
private final String username;
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public KickPlayerTask(ClientPlugin plugin, String username) {
|
||||||
|
this.username = username;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void run() {
|
||||||
|
Objects.requireNonNull(Bukkit.getPlayer(username)).kickPlayer("You are in the UnionBan list!");
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,216 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.configuration.file.FileConfiguration;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.DataOutputStream;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
class LoginStatus {
|
||||||
|
public String username;
|
||||||
|
public String api_key;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Expire {
|
||||||
|
public int expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
class UserInfo {
|
||||||
|
public String account;
|
||||||
|
public String password;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class LoginTask extends BukkitRunnable {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public LoginTask(ClientPlugin plugin, CommandSender sender) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int LoginViaKey(String ServerAddress, String api_key) throws Exception {
|
||||||
|
LoginStatus key = new LoginStatus();
|
||||||
|
key.api_key = api_key;
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String json = mapper.writeValueAsString(key);
|
||||||
|
|
||||||
|
String Address = ServerAddress + "/session/";
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("PUT");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
con.connect();
|
||||||
|
|
||||||
|
DataOutputStream stream = new DataOutputStream(con.getOutputStream());
|
||||||
|
stream.writeBytes(json);
|
||||||
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode != 200) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("Login failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
|
builder.append(inputLine);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
Expire expire = mapper.readValue(builder.toString(), Expire.class);
|
||||||
|
|
||||||
|
return expire.expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int LoginViaUsername(String ServerAddress, String username, String password) throws Exception {
|
||||||
|
UserInfo info = new UserInfo();
|
||||||
|
info.account = username;
|
||||||
|
info.password = password;
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
String json = mapper.writeValueAsString(info);
|
||||||
|
|
||||||
|
String Address = ServerAddress + "/session/";
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("POST");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
con.connect();
|
||||||
|
|
||||||
|
DataOutputStream stream = new DataOutputStream(con.getOutputStream());
|
||||||
|
stream.writeBytes(json);
|
||||||
|
stream.flush();
|
||||||
|
stream.close();
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode != 200) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("Login failed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
|
builder.append(inputLine);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
Expire expire = mapper.readValue(builder.toString(), Expire.class);
|
||||||
|
|
||||||
|
return expire.expire;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static LoginStatus GetLoginStatus(String ServerAddress) throws Exception {
|
||||||
|
URL url = new URL(ServerAddress + "/user/");
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
if (responseCode != 200) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("Not logged in!");
|
||||||
|
}
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
|
builder.append(inputLine);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
ObjectMapper mapper = new ObjectMapper();
|
||||||
|
mapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
|
||||||
|
return mapper.readValue(builder.toString(), LoginStatus.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
FileConfiguration config = plugin.getConfig();
|
||||||
|
String username = config.getString("username");
|
||||||
|
String password = config.getString("password");
|
||||||
|
String api_key = config.getString("api_key");
|
||||||
|
|
||||||
|
sender.sendMessage("Logging in via api_key...");
|
||||||
|
|
||||||
|
if (api_key != null && !api_key.isEmpty()) {
|
||||||
|
try {
|
||||||
|
int expire = LoginViaKey(plugin.ServerAddress, api_key);
|
||||||
|
sender.sendMessage("Login success. The session will expires after " + expire + " seconds.");
|
||||||
|
plugin.login = new LoginTask(plugin, Bukkit.getConsoleSender()).runTaskLaterAsynchronously(plugin, expire * 20);
|
||||||
|
sender.sendMessage("Automated login scheduled.");
|
||||||
|
return;
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (!e.getMessage().equals("Login failed!")) {
|
||||||
|
sender.sendMessage("Failed to connect to UnionBan server.");
|
||||||
|
sender.sendMessage("Failed to login!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sender.sendMessage("Cannot login via api_key. Trying username and password...");
|
||||||
|
|
||||||
|
if (username != null && username.isEmpty()) {
|
||||||
|
sender.sendMessage("Username is empty.");
|
||||||
|
sender.sendMessage("Failed to login!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
int expire = LoginViaUsername(plugin.ServerAddress, username, password);
|
||||||
|
sender.sendMessage("Login success. Updating api_key...");
|
||||||
|
api_key = GetLoginStatus(plugin.ServerAddress).api_key;
|
||||||
|
sender.sendMessage("Got new api_key: " + api_key + ". Saving to file...");
|
||||||
|
config.set("api_key", api_key);
|
||||||
|
plugin.saveConfig();
|
||||||
|
sender.sendMessage("The session will expires after " + expire + " seconds.");
|
||||||
|
plugin.login = new LoginTask(plugin, Bukkit.getConsoleSender()).runTaskLaterAsynchronously(plugin, expire * 20);
|
||||||
|
sender.sendMessage("Automated login scheduled.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
if (e.getMessage().equals("Login failed!")) {
|
||||||
|
sender.sendMessage("Cannot login via username and password!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Failed to connect to UnionBan server.");
|
||||||
|
}
|
||||||
|
sender.sendMessage("Failed to login!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,54 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
public class LogoutTask extends BukkitRunnable {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
private final CommandSender sender;
|
||||||
|
|
||||||
|
public LogoutTask(ClientPlugin plugin, CommandSender sender) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.sender = sender;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void Logout(String ServerAddress) throws Exception {
|
||||||
|
String Address = ServerAddress + "/session/";
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("DELETE");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
con.connect();
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
|
||||||
|
if (responseCode != 204) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("You have not logged in!");
|
||||||
|
}
|
||||||
|
|
||||||
|
con.disconnect();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
Logout(plugin.ServerAddress);
|
||||||
|
sender.sendMessage("Logged out successfully.");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("You have not logged in!")) {
|
||||||
|
sender.sendMessage("You have not logged in!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Cannot connect to UnionBan server!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,46 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.command.CommandSender;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class PardonTask extends BukkitRunnable {
|
||||||
|
private final String username;
|
||||||
|
private final CommandSender sender;
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public PardonTask(ClientPlugin plugin, CommandSender sender, String username) {
|
||||||
|
this.sender = sender;
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
String uuid;
|
||||||
|
sender.sendMessage("Querying UUID of player " + username + " from Mojang server...");
|
||||||
|
try {
|
||||||
|
uuid = PlayerUUID.FromUsername(username);
|
||||||
|
sender.sendMessage("UUID of player " + username + " is " + uuid + ".");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("Player does not exist!")) {
|
||||||
|
sender.sendMessage("Player " + username + " does not exist!");
|
||||||
|
} else {
|
||||||
|
sender.sendMessage("Cannot connect to Mojang server!");
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PlayerUUID.Pardon(plugin.ServerAddress, uuid);
|
||||||
|
sender.sendMessage("Removed player " + username + " from UnionBan list successfully!");
|
||||||
|
} catch (Exception e) {
|
||||||
|
if (e.getMessage().equals("Record does not exist!")) {
|
||||||
|
sender.sendMessage("Player " + username + " is not in the UnionBan list!");
|
||||||
|
} else if (e.getMessage().equals("Not logged in!")) {
|
||||||
|
sender.sendMessage("You have not logged in!");
|
||||||
|
} else {
|
||||||
|
e.printStackTrace();
|
||||||
|
sender.sendMessage("Failed to remove player " + username + " from UnionBan list!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,20 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerLoginEvent;
|
||||||
|
|
||||||
|
public final class PlayerLoginListener implements Listener {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public PlayerLoginListener(ClientPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onLogin(PlayerLoginEvent event) {
|
||||||
|
Bukkit.getLogger().info("Player " + event.getPlayer().getName() + " is logging in!");
|
||||||
|
new PlayerLoginTask(plugin, event.getPlayer().getName()).runTaskAsynchronously(plugin);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,29 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class PlayerLoginTask extends BukkitRunnable {
|
||||||
|
private final String username;
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public PlayerLoginTask(ClientPlugin plugin, String username) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
this.username = username;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String uuid = PlayerUUID.FromUsername(username);
|
||||||
|
plugin.getLogger().info("UUID of " + username + ": " + uuid);
|
||||||
|
boolean isBanned = PlayerUUID.IsBan(plugin.ServerAddress, uuid);
|
||||||
|
plugin.getLogger().info("Player " + username + " is banned: " + isBanned);
|
||||||
|
if (isBanned) {
|
||||||
|
new KickPlayerTask(plugin, username).runTask(plugin);
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Bukkit.getLogger().warning("Failed to get information about player " + username + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,121 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
|
||||||
|
import javax.net.ssl.HttpsURLConnection;
|
||||||
|
import java.io.BufferedReader;
|
||||||
|
import java.io.InputStreamReader;
|
||||||
|
import java.net.URL;
|
||||||
|
|
||||||
|
class MojangUserInfo {
|
||||||
|
public String id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class PlayerUUID {
|
||||||
|
public static boolean IsBan(String ServerAddress, String uuid) throws Exception {
|
||||||
|
String Address = ServerAddress + "/record/uuid/" + uuid;
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
if (responseCode == 200) {
|
||||||
|
return true;
|
||||||
|
} else if (responseCode == 404) {
|
||||||
|
return false;
|
||||||
|
} else {
|
||||||
|
throw new Exception("Failed to connect to UnionBan server!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static String FromUsername(String username) throws Exception {
|
||||||
|
String Address = "https://api.mojang.com/users/profiles/minecraft/" + username;
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("GET");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
if (responseCode == 204) {
|
||||||
|
throw new Exception("Player does not exist!");
|
||||||
|
} else if (responseCode != 200) {
|
||||||
|
con.disconnect();
|
||||||
|
throw new Exception("Failed to connect to Mojang API!");
|
||||||
|
}
|
||||||
|
BufferedReader reader = new BufferedReader(new InputStreamReader(con.getInputStream()));
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
String inputLine;
|
||||||
|
while ((inputLine = reader.readLine()) != null) {
|
||||||
|
builder.append(inputLine);
|
||||||
|
}
|
||||||
|
reader.close();
|
||||||
|
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
ObjectMapper objectMapper = new ObjectMapper();
|
||||||
|
objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
|
||||||
|
MojangUserInfo mojangUserInfo = objectMapper.readValue(builder.toString(), MojangUserInfo.class);
|
||||||
|
|
||||||
|
return mojangUserInfo.id.substring(0, 8) + "-" + mojangUserInfo.id.substring(8, 12) + "-" + mojangUserInfo.id.substring(12, 16) + "-" + mojangUserInfo.id.substring(16, 20) + "-" + mojangUserInfo.id.substring(20, 32);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Ban(String ServerAddress, String uuid) throws Exception {
|
||||||
|
String Address = ServerAddress + "/record/uuid/" + uuid;
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("PUT");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
con.connect();
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
if (responseCode == 409) {
|
||||||
|
throw new Exception("Record exists!");
|
||||||
|
} else if (responseCode == 403) {
|
||||||
|
throw new Exception("Not logged in!");
|
||||||
|
} else if (responseCode != 200) {
|
||||||
|
throw new Exception("Ban failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void Pardon(String ServerAddress, String uuid) throws Exception {
|
||||||
|
String Address = ServerAddress + "/record/uuid/" + uuid;
|
||||||
|
URL url = new URL(Address);
|
||||||
|
HttpsURLConnection con = (HttpsURLConnection) url.openConnection();
|
||||||
|
con.setReadTimeout(5000);
|
||||||
|
con.setConnectTimeout(5000);
|
||||||
|
con.setRequestProperty("User-Agent", "Mozilla/5.0");
|
||||||
|
con.setRequestProperty("Content-Type", "application/json");
|
||||||
|
con.setRequestMethod("DELETE");
|
||||||
|
con.setDoOutput(true);
|
||||||
|
|
||||||
|
con.connect();
|
||||||
|
int responseCode = con.getResponseCode();
|
||||||
|
con.disconnect();
|
||||||
|
|
||||||
|
if (responseCode == 404) {
|
||||||
|
throw new Exception("Record does not exist!");
|
||||||
|
} else if (responseCode == 403) {
|
||||||
|
throw new Exception("Not logged in!");
|
||||||
|
} else if (responseCode != 204) {
|
||||||
|
throw new Exception("Pardon failed!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,32 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerCommandPreprocessEvent;
|
||||||
|
import org.bukkit.event.server.ServerCommandEvent;
|
||||||
|
|
||||||
|
public class WhitelistListener implements Listener {
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public WhitelistListener(ClientPlugin plugin) {
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
void onWhitelist(String prefix, String command) {
|
||||||
|
if (command.startsWith(prefix) && command.length() > prefix.length() + 2 && command.charAt(prefix.length() + 1) != ' ') {
|
||||||
|
new WhitelistTask(plugin, command.substring(prefix.length() + 1)).runTask(plugin);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void PlayerAction(PlayerCommandPreprocessEvent event) {
|
||||||
|
String prefix = "/whitelist add";
|
||||||
|
onWhitelist(prefix, event.getMessage());
|
||||||
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void ServerAction(ServerCommandEvent event) {
|
||||||
|
String prefix = "whitelist add";
|
||||||
|
onWhitelist(prefix, event.getCommand());
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,30 @@
|
||||||
|
package cn.cnklp.studio.UnionBanClientSpigot;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.ChatColor;
|
||||||
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
|
||||||
|
public class WhitelistTask extends BukkitRunnable {
|
||||||
|
private final String username;
|
||||||
|
private final ClientPlugin plugin;
|
||||||
|
|
||||||
|
public WhitelistTask(ClientPlugin plugin, String username) {
|
||||||
|
this.username = username;
|
||||||
|
this.plugin = plugin;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
String uuid = PlayerUUID.FromUsername(username);
|
||||||
|
plugin.getLogger().info("UUID of " + username + ": " + uuid);
|
||||||
|
boolean isBanned = PlayerUUID.IsBan(plugin.ServerAddress, uuid);
|
||||||
|
plugin.getLogger().info("Player " + username + " is banned: " + isBanned);
|
||||||
|
if (isBanned) {
|
||||||
|
Bukkit.broadcastMessage(ChatColor.RED + "[UnionBan] Player " + username + " is in the UnionBan list!");
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
Bukkit.getLogger().warning("Failed to get information about player " + username + "!");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
4
src/main/resources/config.yml
Normal file
4
src/main/resources/config.yml
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
# Do NOT change this file manually!
|
||||||
|
username: ""
|
||||||
|
password: ""
|
||||||
|
api_key: ""
|
24
src/main/resources/plugin.yml
Normal file
24
src/main/resources/plugin.yml
Normal file
|
@ -0,0 +1,24 @@
|
||||||
|
name: UnionBan-Client
|
||||||
|
version: "1.0"
|
||||||
|
api-version: "1.15"
|
||||||
|
main: cn.cnklp.studio.UnionBanClientSpigot.ClientPlugin
|
||||||
|
commands:
|
||||||
|
unionban:
|
||||||
|
description: UnionBan-Client
|
||||||
|
usage: |
|
||||||
|
/unionban help - Show this help.
|
||||||
|
/unionban status - Show status of UnionBan plugin and server.
|
||||||
|
/unionban login <username> <password> - Login to UnionBan server.
|
||||||
|
/unionban logout - Logout from UnionBan server.
|
||||||
|
/unionban ban <player> - Add <player> to UnionBan server(requires login).
|
||||||
|
/unionban pardon <player> - Remove <player> from UnionBan server(requires login).
|
||||||
|
permissions:
|
||||||
|
unionban.info:
|
||||||
|
description: Allow user to get help and status of UnionBan plugin and server.
|
||||||
|
default: true
|
||||||
|
unionban.account:
|
||||||
|
description: Allow user to login or logout.
|
||||||
|
default: op
|
||||||
|
unionban.ban:
|
||||||
|
description: Allow user to add or remove player from UnionBan list.
|
||||||
|
default: op
|
Loading…
Reference in a new issue