diff --git a/PingStatus/.classpath b/PingStatus/.classpath new file mode 100644 index 0000000..e18f43d --- /dev/null +++ b/PingStatus/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/PingStatus/.gitignore b/PingStatus/.gitignore new file mode 100644 index 0000000..09e3bc9 --- /dev/null +++ b/PingStatus/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/target/ diff --git a/PingStatus/.project b/PingStatus/.project new file mode 100644 index 0000000..02c08f8 --- /dev/null +++ b/PingStatus/.project @@ -0,0 +1,23 @@ + + + PingStatus + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/PingStatus/.settings/org.eclipse.jdt.core.prefs b/PingStatus/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..43c686f --- /dev/null +++ b/PingStatus/.settings/org.eclipse.jdt.core.prefs @@ -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 diff --git a/PingStatus/.settings/org.eclipse.m2e.core.prefs b/PingStatus/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/PingStatus/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/PingStatus/pom.xml b/PingStatus/pom.xml new file mode 100644 index 0000000..2d02b51 --- /dev/null +++ b/PingStatus/pom.xml @@ -0,0 +1,61 @@ + + 4.0.0 + cz.marwland.mc.features + PingStatus + + cz.marwland.mc + MarwStuff + 0.0.1-SNAPSHOT + ../../MarwStuff + + + src + + + resources + + + + + maven-compiler-plugin + 3.7.0 + + 10 + + + + exec-maven-plugin + 1.6.0 + org.codehaus.mojo + + + deploy + + exec + + + + + ${project.parent.basedir}/deploy_feature.sh + + ${project.build.directory}/${project.build.finalName}.jar + ${project.artifactId} + + + + + maven-resources-plugin + + ${project.build.outputDirectory}/resources + + + + + + + cz.marwland.mc + MarwCore + ${project.parent.version} + + + \ No newline at end of file diff --git a/PingStatus/resources/pingstatus.yml b/PingStatus/resources/pingstatus.yml new file mode 100644 index 0000000..deb3167 --- /dev/null +++ b/PingStatus/resources/pingstatus.yml @@ -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: diff --git a/PingStatus/src/cz/marwland/mc/features/PingStatus.java b/PingStatus/src/cz/marwland/mc/features/PingStatus.java new file mode 100644 index 0000000..ef84174 --- /dev/null +++ b/PingStatus/src/cz/marwland/mc/features/PingStatus.java @@ -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 line1 = new ArrayList<>(); + List line2 = new ArrayList<>(); + List common = new ArrayList<>(); + + public PingStatus() { + super(); + this.registerConfig("pingstatus.yml"); + } + + @Override + public void onEnable() { + super.onEnable(); + cfg = getConfig("pingstatus.yml"); + + List line1cfg = cfg.getStringList("line1"); + if (line1cfg != null) + line1 = line1cfg; + List line2cfg = cfg.getStringList("line2"); + if (line2cfg != null) + line2 = line2cfg; + List 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 getRandomEntry(List list) { + return list.get((int) Math.floor((Math.random() * list.size()))); + } + +}