PingStatus module
This commit is contained in:
parent
c4279130f7
commit
2628105be4
21
PingStatus/.classpath
Normal file
21
PingStatus/.classpath
Normal file
@ -0,0 +1,21 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<classpath>
|
||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-10">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" output="target/classes" path="src">
|
||||
<attributes>
|
||||
<attribute name="optional" value="true"/>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="src" path="resources"/>
|
||||
<classpathentry kind="con" path="org.eclipse.m2e.MAVEN2_CLASSPATH_CONTAINER">
|
||||
<attributes>
|
||||
<attribute name="maven.pomderived" value="true"/>
|
||||
</attributes>
|
||||
</classpathentry>
|
||||
<classpathentry kind="output" path="target/classes"/>
|
||||
</classpath>
|
2
PingStatus/.gitignore
vendored
Normal file
2
PingStatus/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/bin/
|
||||
/target/
|
23
PingStatus/.project
Normal file
23
PingStatus/.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>PingStatus</name>
|
||||
<comment></comment>
|
||||
<projects>
|
||||
</projects>
|
||||
<buildSpec>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.jdt.core.javabuilder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
<buildCommand>
|
||||
<name>org.eclipse.m2e.core.maven2Builder</name>
|
||||
<arguments>
|
||||
</arguments>
|
||||
</buildCommand>
|
||||
</buildSpec>
|
||||
<natures>
|
||||
<nature>org.eclipse.m2e.core.maven2Nature</nature>
|
||||
<nature>org.eclipse.jdt.core.javanature</nature>
|
||||
</natures>
|
||||
</projectDescription>
|
13
PingStatus/.settings/org.eclipse.jdt.core.prefs
Normal file
13
PingStatus/.settings/org.eclipse.jdt.core.prefs
Normal file
@ -0,0 +1,13 @@
|
||||
eclipse.preferences.version=1
|
||||
org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
|
||||
org.eclipse.jdt.core.compiler.codegen.targetPlatform=10
|
||||
org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
|
||||
org.eclipse.jdt.core.compiler.compliance=10
|
||||
org.eclipse.jdt.core.compiler.debug.lineNumber=generate
|
||||
org.eclipse.jdt.core.compiler.debug.localVariable=generate
|
||||
org.eclipse.jdt.core.compiler.debug.sourceFile=generate
|
||||
org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
|
||||
org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning
|
||||
org.eclipse.jdt.core.compiler.release=enabled
|
||||
org.eclipse.jdt.core.compiler.source=10
|
4
PingStatus/.settings/org.eclipse.m2e.core.prefs
Normal file
4
PingStatus/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
61
PingStatus/pom.xml
Normal file
61
PingStatus/pom.xml
Normal file
@ -0,0 +1,61 @@
|
||||
<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>cz.marwland.mc.features</groupId>
|
||||
<artifactId>PingStatus</artifactId>
|
||||
<parent>
|
||||
<groupId>cz.marwland.mc</groupId>
|
||||
<artifactId>MarwStuff</artifactId>
|
||||
<version>0.0.1-SNAPSHOT</version>
|
||||
<relativePath>../../MarwStuff</relativePath>
|
||||
</parent>
|
||||
<build>
|
||||
<sourceDirectory>src</sourceDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
</resource>
|
||||
</resources>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<version>3.7.0</version>
|
||||
<configuration>
|
||||
<release>10</release>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>exec-maven-plugin</artifactId>
|
||||
<version>1.6.0</version>
|
||||
<groupId>org.codehaus.mojo</groupId>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>${project.parent.basedir}/deploy_feature.sh</executable>
|
||||
<arguments>
|
||||
<argument>${project.build.directory}/${project.build.finalName}.jar</argument>
|
||||
<argument>${project.artifactId}</argument>
|
||||
</arguments>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<configuration>
|
||||
<outputDirectory>${project.build.outputDirectory}/resources</outputDirectory>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>cz.marwland.mc</groupId>
|
||||
<artifactId>MarwCore</artifactId>
|
||||
<version>${project.parent.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
5
PingStatus/resources/pingstatus.yml
Normal file
5
PingStatus/resources/pingstatus.yml
Normal file
@ -0,0 +1,5 @@
|
||||
line1:
|
||||
- ' §7─§9─§8─§7─§9─§8─ §9§lMarw§f§lLand §3§lNS Frakce §8─§9─§7─§8─§9─§7─'
|
||||
line2:
|
||||
- ' §8§l> §7fakofbic §8§l<'
|
||||
common:
|
56
PingStatus/src/cz/marwland/mc/features/PingStatus.java
Normal file
56
PingStatus/src/cz/marwland/mc/features/PingStatus.java
Normal file
@ -0,0 +1,56 @@
|
||||
package cz.marwland.mc.features;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.server.ServerListPingEvent;
|
||||
|
||||
import cz.marwland.mc.core.features.Feature;
|
||||
|
||||
public class PingStatus extends Feature {
|
||||
|
||||
FileConfiguration cfg;
|
||||
List<String> line1 = new ArrayList<>();
|
||||
List<String> line2 = new ArrayList<>();
|
||||
List<String> common = new ArrayList<>();
|
||||
|
||||
public PingStatus() {
|
||||
super();
|
||||
this.registerConfig("pingstatus.yml");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
super.onEnable();
|
||||
cfg = getConfig("pingstatus.yml");
|
||||
|
||||
List<String> line1cfg = cfg.getStringList("line1");
|
||||
if (line1cfg != null)
|
||||
line1 = line1cfg;
|
||||
List<String> line2cfg = cfg.getStringList("line2");
|
||||
if (line2cfg != null)
|
||||
line2 = line2cfg;
|
||||
List<String> commoncfg = cfg.getStringList("common");
|
||||
if (commoncfg != null)
|
||||
common = commoncfg;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onPingServer(ServerListPingEvent event) {
|
||||
String motd = null;
|
||||
if (common.size() > 0) {
|
||||
motd = getRandomEntry(this.common);
|
||||
} else if (line1.size() > 0 && line2.size() > 0) {
|
||||
motd = getRandomEntry(this.line1) + "\n" + getRandomEntry(this.line2);
|
||||
}
|
||||
if (motd != null)
|
||||
event.setMotd(motd);
|
||||
}
|
||||
|
||||
public static <T> T getRandomEntry(List<T> list) {
|
||||
return list.get((int) Math.floor((Math.random() * list.size())));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user