Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c231a2a45 |
38
.gitignore
vendored
38
.gitignore
vendored
@ -1,38 +0,0 @@
|
|||||||
target/
|
|
||||||
!.mvn/wrapper/maven-wrapper.jar
|
|
||||||
!**/src/main/**/target/
|
|
||||||
!**/src/test/**/target/
|
|
||||||
|
|
||||||
### IntelliJ IDEA ###
|
|
||||||
.idea/modules.xml
|
|
||||||
.idea/jarRepositories.xml
|
|
||||||
.idea/compiler.xml
|
|
||||||
.idea/libraries/
|
|
||||||
*.iws
|
|
||||||
*.iml
|
|
||||||
*.ipr
|
|
||||||
|
|
||||||
### Eclipse ###
|
|
||||||
.apt_generated
|
|
||||||
.classpath
|
|
||||||
.factorypath
|
|
||||||
.project
|
|
||||||
.settings
|
|
||||||
.springBeans
|
|
||||||
.sts4-cache
|
|
||||||
|
|
||||||
### NetBeans ###
|
|
||||||
/nbproject/private/
|
|
||||||
/nbbuild/
|
|
||||||
/dist/
|
|
||||||
/nbdist/
|
|
||||||
/.nb-gradle/
|
|
||||||
build/
|
|
||||||
!**/src/main/**/build/
|
|
||||||
!**/src/test/**/build/
|
|
||||||
|
|
||||||
### VS Code ###
|
|
||||||
.vscode/
|
|
||||||
|
|
||||||
### Mac OS ###
|
|
||||||
.DS_Store
|
|
||||||
3
.idea/.gitignore
generated
vendored
3
.idea/.gitignore
generated
vendored
@ -1,3 +0,0 @@
|
|||||||
# Default ignored files
|
|
||||||
/shelf/
|
|
||||||
/workspace.xml
|
|
||||||
7
.idea/encodings.xml
generated
7
.idea/encodings.xml
generated
@ -1,7 +0,0 @@
|
|||||||
<?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>
|
|
||||||
19
.idea/misc.xml
generated
19
.idea/misc.xml
generated
@ -1,19 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="EntryPointsManager">
|
|
||||||
<list size="1">
|
|
||||||
<item index="0" class="java.lang.String" itemvalue="org.bukkit.event.EventHandler" />
|
|
||||||
</list>
|
|
||||||
</component>
|
|
||||||
<component name="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="temurin-1.8" project-jdk-type="JavaSDK">
|
|
||||||
<output url="file://$PROJECT_DIR$/out" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
124
.idea/uiDesigner.xml
generated
124
.idea/uiDesigner.xml
generated
@ -1,124 +0,0 @@
|
|||||||
<?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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" 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.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
|
||||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
|
||||||
</item>
|
|
||||||
</group>
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
6
.idea/vcs.xml
generated
6
.idea/vcs.xml
generated
@ -1,6 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="UTF-8"?>
|
|
||||||
<project version="4">
|
|
||||||
<component name="VcsDirectoryMappings">
|
|
||||||
<mapping directory="" vcs="Git" />
|
|
||||||
</component>
|
|
||||||
</project>
|
|
||||||
@ -1,5 +1,3 @@
|
|||||||
# FMCServer - ForeverMC 服务器插件
|
# FMCServer
|
||||||
|
|
||||||
适用版本:1.9.4 - 最新
|
ForeverMC 服务器状态报告插件
|
||||||
|
|
||||||
详细说明请看主分支 README.md
|
|
||||||
104
pom.xml
104
pom.xml
@ -1,104 +0,0 @@
|
|||||||
<?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.imyeyu.fmcserver</groupId>
|
|
||||||
<artifactId>FMCServer</artifactId>
|
|
||||||
<version>0.0.1+${mc.version}</version>
|
|
||||||
<packaging>jar</packaging>
|
|
||||||
|
|
||||||
<properties>
|
|
||||||
<mc.version>1.9.4+</mc.version>
|
|
||||||
<java.version>8</java.version>
|
|
||||||
<maven.compiler.source>8</maven.compiler.source>
|
|
||||||
<maven.compiler.target>8</maven.compiler.target>
|
|
||||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
|
||||||
</properties>
|
|
||||||
|
|
||||||
<repositories>
|
|
||||||
<repository>
|
|
||||||
<id>spigot-repo</id>
|
|
||||||
<url>https://hub.spigotmc.org/nexus/content/repositories/snapshots/</url>
|
|
||||||
</repository>
|
|
||||||
</repositories>
|
|
||||||
|
|
||||||
<build>
|
|
||||||
<plugins>
|
|
||||||
<plugin>
|
|
||||||
<groupId>org.apache.maven.plugins</groupId>
|
|
||||||
<artifactId>maven-assembly-plugin</artifactId>
|
|
||||||
<version>3.7.1</version>
|
|
||||||
<configuration>
|
|
||||||
<finalName>${project.artifactId}-${project.version}+${mc.version}</finalName>
|
|
||||||
<outputDirectory>E:\SpigotMC\test194\plugins</outputDirectory>
|
|
||||||
<descriptorRefs>
|
|
||||||
<descriptorRef>jar-with-dependencies</descriptorRef>
|
|
||||||
</descriptorRefs>
|
|
||||||
</configuration>
|
|
||||||
<executions>
|
|
||||||
<execution>
|
|
||||||
<phase>package</phase>
|
|
||||||
<goals>
|
|
||||||
<goal>single</goal>
|
|
||||||
</goals>
|
|
||||||
</execution>
|
|
||||||
</executions>
|
|
||||||
</plugin>
|
|
||||||
</plugins>
|
|
||||||
</build>
|
|
||||||
|
|
||||||
<dependencies>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.spigotmc</groupId>
|
|
||||||
<artifactId>spigot-api</artifactId>
|
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.forevermc.spigot</groupId>
|
|
||||||
<artifactId>fmc-core</artifactId>
|
|
||||||
<version>0.0.1+1.9.4+</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.imyeyu.inject</groupId>
|
|
||||||
<artifactId>timi-inject</artifactId>
|
|
||||||
<version>0.0.1-legacy</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>cn.forevermc.spigot</groupId>
|
|
||||||
<artifactId>fmc-debug</artifactId>
|
|
||||||
<version>0.0.1+1.9.4+</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
<exclusions>
|
|
||||||
<exclusion>
|
|
||||||
<groupId>com.imyeyu.inject</groupId>
|
|
||||||
<artifactId>timi-inject</artifactId>
|
|
||||||
</exclusion>
|
|
||||||
</exclusions>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-io</artifactId>
|
|
||||||
<version>1.3.2</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-codec</groupId>
|
|
||||||
<artifactId>commons-codec</artifactId>
|
|
||||||
<version>1.17.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.httpcomponents.client5</groupId>
|
|
||||||
<artifactId>httpclient5-fluent</artifactId>
|
|
||||||
<version>5.4.1</version>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.projectlombok</groupId>
|
|
||||||
<artifactId>lombok</artifactId>
|
|
||||||
<version>1.18.34</version>
|
|
||||||
<scope>provided</scope>
|
|
||||||
</dependency>
|
|
||||||
</dependencies>
|
|
||||||
</project>
|
|
||||||
@ -1,71 +0,0 @@
|
|||||||
package cn.forevermc.server.spigot;
|
|
||||||
|
|
||||||
import cn.forevermc.server.spigot.bean.Config;
|
|
||||||
import cn.forevermc.server.spigot.service.ReportService;
|
|
||||||
import cn.forevermc.spigot.core.FMCCore;
|
|
||||||
import cn.forevermc.spigot.core.FMCPlugin;
|
|
||||||
import cn.forevermc.spigot.core.command.FMCCommand;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.imyeyu.inject.InjectApp;
|
|
||||||
import com.imyeyu.inject.TimiInject;
|
|
||||||
import com.imyeyu.inject.annotation.IOCReturn;
|
|
||||||
import com.imyeyu.inject.annotation.Inject;
|
|
||||||
import com.imyeyu.inject.annotation.TimiInjectApplication;
|
|
||||||
|
|
||||||
import java.util.UUID;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* ForeverMC 服务器状态报告插件
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2022-11-14 11:05
|
|
||||||
*/
|
|
||||||
@TimiInjectApplication
|
|
||||||
public class FMCServer extends FMCPlugin {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Config config;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private ReportService service;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onLoad() {
|
|
||||||
FMCCore.register(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onEnable() {
|
|
||||||
TimiInject.run(new InjectApp(this));
|
|
||||||
defaultConfig("config.yml");
|
|
||||||
if (config.getId() == null || config.getId().isEmpty()) {
|
|
||||||
config.setId(UUID.randomUUID().toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onDisable() {
|
|
||||||
saveConfigAs(config, getConfig());
|
|
||||||
}
|
|
||||||
|
|
||||||
@IOCReturn
|
|
||||||
public Gson gson() {
|
|
||||||
return new Gson();
|
|
||||||
}
|
|
||||||
|
|
||||||
@IOCReturn
|
|
||||||
public Logger log() {
|
|
||||||
return getLogger();
|
|
||||||
}
|
|
||||||
|
|
||||||
@IOCReturn
|
|
||||||
public FMCCommand fmcCommand() {
|
|
||||||
return fmcCommand;
|
|
||||||
}
|
|
||||||
|
|
||||||
@IOCReturn
|
|
||||||
public Config config() {
|
|
||||||
return loadConfigAs(Config.class, getConfig());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,29 +0,0 @@
|
|||||||
package cn.forevermc.server.spigot.bean;
|
|
||||||
|
|
||||||
import cn.forevermc.spigot.core.bean.ConfigPath;
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2025-07-23 23:51
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class Config {
|
|
||||||
|
|
||||||
@ConfigPath("enable")
|
|
||||||
private boolean enable;
|
|
||||||
|
|
||||||
@ConfigPath("id")
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
@ConfigPath("api")
|
|
||||||
private String api;
|
|
||||||
|
|
||||||
@ConfigPath("token")
|
|
||||||
private String token;
|
|
||||||
|
|
||||||
@ConfigPath("worlds")
|
|
||||||
private List<String> worlds;
|
|
||||||
}
|
|
||||||
@ -1,171 +0,0 @@
|
|||||||
package cn.forevermc.server.spigot.bean;
|
|
||||||
|
|
||||||
import lombok.Data;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 服务器状态
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2024-08-06 20:38
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public class ReportRequest {
|
|
||||||
|
|
||||||
private String id;
|
|
||||||
|
|
||||||
/** true 为调试中 */
|
|
||||||
private Boolean isDebugging;
|
|
||||||
|
|
||||||
/** TPS */
|
|
||||||
private double tps;
|
|
||||||
|
|
||||||
/** 报告时间 */
|
|
||||||
private long reportAt;
|
|
||||||
|
|
||||||
/** 静态基本信息 */
|
|
||||||
private BaseInfo baseInfo;
|
|
||||||
|
|
||||||
/** 主世界状态 */
|
|
||||||
private List<WorldStatus> worldStatusList = new ArrayList<>();
|
|
||||||
|
|
||||||
/** JVM 状态 */
|
|
||||||
private JVM jvm = new JVM();
|
|
||||||
|
|
||||||
/** 在线列表 */
|
|
||||||
private List<String> onlineList = new ArrayList<>();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置 TPS 取平均
|
|
||||||
*
|
|
||||||
* @param tpsList TPS 列表
|
|
||||||
*/
|
|
||||||
public void setTps(double[] tpsList) {
|
|
||||||
double sum = 0;
|
|
||||||
for (int i = 0; i < tpsList.length; i++) {
|
|
||||||
sum += tpsList[i];
|
|
||||||
}
|
|
||||||
tps = sum / tpsList.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 静态基本信息
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2025-01-19 10:25
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class BaseInfo {
|
|
||||||
|
|
||||||
/** 核心 */
|
|
||||||
private String core;
|
|
||||||
|
|
||||||
/** 启动时间 */
|
|
||||||
private Long bootAt;
|
|
||||||
|
|
||||||
/** 最大在线数量 */
|
|
||||||
private Integer maxOnline;
|
|
||||||
|
|
||||||
/** 图标 Base64 */
|
|
||||||
private String icon;
|
|
||||||
|
|
||||||
/** 游戏版本 */
|
|
||||||
private String version;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* JVM 状态
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2022-11-11 14:52
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class JVM {
|
|
||||||
|
|
||||||
/** JVM 名称 */
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/** CPU 已使用 */
|
|
||||||
private double cpuUsed;
|
|
||||||
|
|
||||||
/** 内存状态 */
|
|
||||||
private Memory memory = new Memory();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 内存状态
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2022-11-15 09:54
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class Memory {
|
|
||||||
|
|
||||||
/** 已使用 */
|
|
||||||
private long used;
|
|
||||||
|
|
||||||
/** 已申请 */
|
|
||||||
private long committed;
|
|
||||||
|
|
||||||
/** 最大内存 */
|
|
||||||
private long max;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 世界时间
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2024-10-29 23:59
|
|
||||||
*/
|
|
||||||
@Data
|
|
||||||
public static class WorldStatus {
|
|
||||||
|
|
||||||
/** 世界名称 */
|
|
||||||
private String name;
|
|
||||||
|
|
||||||
/** 总时刻 */
|
|
||||||
private long ticks;
|
|
||||||
|
|
||||||
/** 总天数 */
|
|
||||||
private int day;
|
|
||||||
|
|
||||||
/** 时 */
|
|
||||||
private int hour;
|
|
||||||
|
|
||||||
/** 分 */
|
|
||||||
private int minute;
|
|
||||||
|
|
||||||
/** true 为正在下雨 */
|
|
||||||
private boolean isRaining;
|
|
||||||
|
|
||||||
/** true 为正在雷雨 */
|
|
||||||
private boolean isThundering;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 设置自世界诞生后经历的总时刻,会同时计算详细时间
|
|
||||||
*
|
|
||||||
* @param ticks 总时刻
|
|
||||||
*/
|
|
||||||
public void setTicks(long ticks) {
|
|
||||||
this.ticks = ticks;
|
|
||||||
|
|
||||||
// +6000 是因为 tick 为 0 时太阳从地平线开始升起,此时应该为早晨 6 点
|
|
||||||
this.ticks += 6000;
|
|
||||||
|
|
||||||
// mcTime | mcTick | realTime
|
|
||||||
// 1s | 0.27 | 0.0138s
|
|
||||||
// 1m | 16.6 | 0.83s
|
|
||||||
// 1h | 1000 | 50s
|
|
||||||
// 1d | 24000 | 20m
|
|
||||||
|
|
||||||
day = (int) (this.ticks / 24000);
|
|
||||||
|
|
||||||
int remainingTick = (int) (this.ticks % 24000);
|
|
||||||
|
|
||||||
hour = remainingTick / 1000;
|
|
||||||
minute = (int) ((remainingTick - hour * 1000) / 16.6);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,211 +0,0 @@
|
|||||||
package cn.forevermc.server.spigot.service;
|
|
||||||
|
|
||||||
import cn.forevermc.server.spigot.FMCServer;
|
|
||||||
import cn.forevermc.server.spigot.bean.Config;
|
|
||||||
import cn.forevermc.server.spigot.bean.ReportRequest;
|
|
||||||
import cn.forevermc.spigot.debug.FMCDebugInterface;
|
|
||||||
import com.google.gson.Gson;
|
|
||||||
import com.google.gson.JsonObject;
|
|
||||||
import com.google.gson.JsonParser;
|
|
||||||
import com.imyeyu.inject.annotation.Inject;
|
|
||||||
import com.imyeyu.inject.annotation.InvokeForInjected;
|
|
||||||
import com.imyeyu.inject.annotation.Service;
|
|
||||||
import com.sun.management.OperatingSystemMXBean;
|
|
||||||
import lombok.Getter;
|
|
||||||
import org.apache.commons.codec.binary.Base64;
|
|
||||||
import org.apache.commons.io.FileUtils;
|
|
||||||
import org.apache.hc.client5.http.fluent.Request;
|
|
||||||
import org.apache.hc.core5.http.ContentType;
|
|
||||||
import org.apache.hc.core5.util.Timeout;
|
|
||||||
import org.bukkit.Bukkit;
|
|
||||||
import org.bukkit.Server;
|
|
||||||
import org.bukkit.World;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.lang.management.ManagementFactory;
|
|
||||||
import java.lang.management.MemoryMXBean;
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
|
||||||
import java.util.logging.Level;
|
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 状态报告服务
|
|
||||||
*
|
|
||||||
* @author 夜雨
|
|
||||||
* @since 2022-11-11 14:38
|
|
||||||
*/
|
|
||||||
@Service
|
|
||||||
public class ReportService extends BukkitRunnable {
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Config config;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Gson gson;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private Logger log;
|
|
||||||
|
|
||||||
@Inject
|
|
||||||
private FMCServer fmcServer;
|
|
||||||
|
|
||||||
@Getter
|
|
||||||
private boolean isWorking = false;
|
|
||||||
|
|
||||||
private final long bootAt;
|
|
||||||
private final Server server = Bukkit.getServer();
|
|
||||||
private final ReportRequest reportReq = new ReportRequest();
|
|
||||||
private final MemoryMXBean jvmMemory = ManagementFactory.getMemoryMXBean();
|
|
||||||
private final double[] tpsList = new double[9];
|
|
||||||
|
|
||||||
private boolean requiredBaseInfo = false;
|
|
||||||
private final OperatingSystemMXBean operatingSystemMXBean;
|
|
||||||
|
|
||||||
/** 失败时间,用于失败时任务执行周期将会更长 */
|
|
||||||
private long failAt = -1;
|
|
||||||
|
|
||||||
public ReportService() {
|
|
||||||
bootAt = System.currentTimeMillis();
|
|
||||||
operatingSystemMXBean = ManagementFactory.getPlatformMXBean(OperatingSystemMXBean.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@InvokeForInjected
|
|
||||||
private void injected() {
|
|
||||||
try {
|
|
||||||
if (config.getApi() == null || config.getApi().isEmpty()) {
|
|
||||||
throw new RuntimeException("not found report.api in config");
|
|
||||||
}
|
|
||||||
if (config.getToken() == null || config.getToken().isEmpty()) {
|
|
||||||
throw new RuntimeException("not found report.token in config");
|
|
||||||
}
|
|
||||||
|
|
||||||
log.info("report: " + config.isEnable());
|
|
||||||
log.info("report.id: " + config.getId());
|
|
||||||
log.info("worlds: " + server.getWorlds());
|
|
||||||
if (!config.isEnable()) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
reportReq.setId(config.getId());
|
|
||||||
// TPS 计算
|
|
||||||
server.getScheduler().scheduleSyncRepeatingTask(fmcServer, new Runnable() {
|
|
||||||
|
|
||||||
private int ticks;
|
|
||||||
private int tpsI;
|
|
||||||
private long cs;
|
|
||||||
private double tps;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
long now = System.nanoTime();
|
|
||||||
|
|
||||||
if (cs == 0) {
|
|
||||||
cs = now;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
long diff = now - cs;
|
|
||||||
double currentTps = (double) TimeUnit.SECONDS.toNanos(1) / diff * ticks;
|
|
||||||
tpsI++;
|
|
||||||
tpsList[tpsI % tpsList.length] = tps = (tps == 0) ? currentTps : (tps * 0.9 + currentTps * 0.1);
|
|
||||||
|
|
||||||
cs = now;
|
|
||||||
ticks = 1;
|
|
||||||
}
|
|
||||||
}, 0, 1);
|
|
||||||
|
|
||||||
runTaskTimerAsynchronously(fmcServer, 0, 60);
|
|
||||||
isWorking = true;
|
|
||||||
} catch (Exception e) {
|
|
||||||
log.log(Level.WARNING, e.getMessage());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** 报告状态 */
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
// 失败时延长周期,(15+-3) 秒
|
|
||||||
if (System.currentTimeMillis() - failAt < 1E3 * 15) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
Plugin fmcDebug = fmcServer.getServer().getPluginManager().getPlugin("FMCDebug");
|
|
||||||
if (fmcDebug instanceof FMCDebugInterface) {
|
|
||||||
FMCDebugInterface fmcDebugInterface = (FMCDebugInterface) fmcDebug;
|
|
||||||
reportReq.setIsDebugging(fmcDebugInterface.isDebugging());
|
|
||||||
}
|
|
||||||
reportReq.getOnlineList().clear();
|
|
||||||
Collection<? extends Player> players = server.getOnlinePlayers();
|
|
||||||
for (Player player : players) {
|
|
||||||
reportReq.getOnlineList().add(player.getName());
|
|
||||||
}
|
|
||||||
|
|
||||||
reportReq.getWorldStatusList().clear();
|
|
||||||
List<String> worldList = config.getWorlds();
|
|
||||||
if (worldList != null) {
|
|
||||||
for (String worldName : worldList) {
|
|
||||||
World world = fmcServer.getServer().getWorld(worldName);
|
|
||||||
ReportRequest.WorldStatus worldStatus = new ReportRequest.WorldStatus();
|
|
||||||
worldStatus.setName(world.getName());
|
|
||||||
worldStatus.setTicks(world.getFullTime());
|
|
||||||
worldStatus.setRaining(world.hasStorm());
|
|
||||||
worldStatus.setRaining(world.isThundering());
|
|
||||||
reportReq.getWorldStatusList().add(worldStatus);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
reportReq.setTps(tpsList);
|
|
||||||
reportReq.setReportAt(System.currentTimeMillis());
|
|
||||||
reportReq.getJvm().setCpuUsed(operatingSystemMXBean.getProcessCpuLoad());
|
|
||||||
reportReq.getJvm().setName(System.getProperty("java.vm.name"));
|
|
||||||
reportReq.getJvm().getMemory().setUsed(jvmMemory.getHeapMemoryUsage().getUsed());
|
|
||||||
reportReq.getJvm().getMemory().setCommitted(jvmMemory.getHeapMemoryUsage().getCommitted());
|
|
||||||
reportReq.getJvm().getMemory().setMax(jvmMemory.getHeapMemoryUsage().getMax());
|
|
||||||
|
|
||||||
if (requiredBaseInfo) {
|
|
||||||
ReportRequest.BaseInfo baseInfo = new ReportRequest.BaseInfo();
|
|
||||||
int end = server.getVersion().indexOf("MC:");
|
|
||||||
if (end == -1) {
|
|
||||||
baseInfo.setCore(server.getVersion());
|
|
||||||
} else {
|
|
||||||
baseInfo.setCore(server.getVersion().substring(0, end - 2));
|
|
||||||
}
|
|
||||||
baseInfo.setBootAt(bootAt);
|
|
||||||
baseInfo.setMaxOnline(server.getMaxPlayers());
|
|
||||||
File iconFile = new File(new File(fmcServer.getDataFolder().getParent()).getParent(), "server-icon.png");
|
|
||||||
if (iconFile.exists()) {
|
|
||||||
baseInfo.setIcon(Base64.encodeBase64String(FileUtils.readFileToByteArray(iconFile)));
|
|
||||||
}
|
|
||||||
baseInfo.setVersion(server.getBukkitVersion().split("-")[0]); // 1.9.4-R0.1-SNAPSHOT
|
|
||||||
reportReq.setBaseInfo(baseInfo);
|
|
||||||
requiredBaseInfo = false;
|
|
||||||
} else {
|
|
||||||
reportReq.setBaseInfo(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
String respText = Request.post(config.getApi())
|
|
||||||
.addHeader("Token", config.getToken())
|
|
||||||
.bodyString(gson.toJson(reportReq), ContentType.APPLICATION_JSON)
|
|
||||||
.connectTimeout(Timeout.ofSeconds(60))
|
|
||||||
.execute()
|
|
||||||
.returnContent()
|
|
||||||
.asString();
|
|
||||||
|
|
||||||
JsonObject resp = new JsonParser().parse(respText).getAsJsonObject();
|
|
||||||
|
|
||||||
int code = resp.get("code").getAsInt();
|
|
||||||
if (code < 40000) {
|
|
||||||
// 被服务端忽略时视为需要基本信息
|
|
||||||
requiredBaseInfo = code == 20001;
|
|
||||||
} else {
|
|
||||||
log.log(Level.WARNING, String.format("report api response error:%s", resp.get("msg").getAsString()));
|
|
||||||
}
|
|
||||||
} catch (Exception e) {
|
|
||||||
failAt = System.currentTimeMillis();
|
|
||||||
log.log(Level.WARNING, String.format("report error:%s", e.getMessage()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@ -1,6 +0,0 @@
|
|||||||
enable: false
|
|
||||||
id: ""
|
|
||||||
api: http://localhost:8091/fmc/server/report
|
|
||||||
token: qweqwe123
|
|
||||||
worlds:
|
|
||||||
- world
|
|
||||||
@ -1,9 +0,0 @@
|
|||||||
name: FMCServer
|
|
||||||
main: cn.forevermc.server.spigot.FMCServer
|
|
||||||
version: '0.0.1'
|
|
||||||
api-version: '1.9'
|
|
||||||
depend: [FMCCore]
|
|
||||||
|
|
||||||
author: Timi
|
|
||||||
website: forevermc.cn
|
|
||||||
description: This plugin is ForeverMC Server status reporter
|
|
||||||
Reference in New Issue
Block a user