new feature: Stats
This commit is contained in:
parent
0991b616f3
commit
48ca6d4d8f
21
Stats/.classpath
Normal file
21
Stats/.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
Stats/.gitignore
vendored
Normal file
2
Stats/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
/bin/
|
||||
/target/
|
23
Stats/.project
Normal file
23
Stats/.project
Normal file
@ -0,0 +1,23 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<projectDescription>
|
||||
<name>Stats</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
Stats/.settings/org.eclipse.jdt.core.prefs
Normal file
13
Stats/.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
Stats/.settings/org.eclipse.m2e.core.prefs
Normal file
4
Stats/.settings/org.eclipse.m2e.core.prefs
Normal file
@ -0,0 +1,4 @@
|
||||
activeProfiles=
|
||||
eclipse.preferences.version=1
|
||||
resolveWorkspaceProjects=true
|
||||
version=1
|
20
Stats/deploy_feature.sh
Executable file
20
Stats/deploy_feature.sh
Executable file
@ -0,0 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [[ "Darwin" == `uname` ]]; then
|
||||
MC_PATH="../../server"
|
||||
|
||||
cp "$1" "../../server/plugins/MarwCore/modules/$2.jar"
|
||||
"$MC_PATH/cmd.sh" "marw reload $2"
|
||||
else
|
||||
LXC_CONT="marw"
|
||||
MC_USER="mc"
|
||||
MC_PATH="/home/mc/factions"
|
||||
|
||||
|
||||
lxc file push "$1" "$LXC_CONT$MC_PATH/plugins/MarwCore/modules/$2.jar"
|
||||
lxc exec $LXC_CONT chown $MC_USER:$MC_USER "$MC_PATH/plugins/MarwCore/modules/$2.jar"
|
||||
lxc exec $LXC_CONT -- sudo -u $MC_USER "$MC_PATH/cmd.sh" "marw reload $2"
|
||||
|
||||
fi
|
||||
|
||||
exit 0
|
63
Stats/pom.xml
Normal file
63
Stats/pom.xml
Normal file
@ -0,0 +1,63 @@
|
||||
<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>Stats</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>
|
||||
<id>Version Calculation</id>
|
||||
<phase>deploy</phase>
|
||||
<goals>
|
||||
<goal>exec</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
<configuration>
|
||||
<executable>${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>
|
9
Stats/resources/create.sql
Normal file
9
Stats/resources/create.sql
Normal file
@ -0,0 +1,9 @@
|
||||
CREATE TABLE IF NOT EXISTS `{prefix}players` (
|
||||
`id` int UNSIGNED NOT NULL AUTO_INCREMENT,
|
||||
`uuid` binary(16) NOT NULL,
|
||||
`serverNick` varchar(32) NOT NULL,
|
||||
`kills` int DEFAULT 0,
|
||||
`deaths` int UNSIGNED DEFAULT 0,
|
||||
`voteCount` int UNSIGNED DEFAULT 0,
|
||||
PRIMARY KEY `id` (`id`)
|
||||
) DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
|
54
Stats/src/cz/marwland/mc/features/Stats.java
Normal file
54
Stats/src/cz/marwland/mc/features/Stats.java
Normal file
@ -0,0 +1,54 @@
|
||||
package cz.marwland.mc.features;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.defaults.BukkitCommand;
|
||||
|
||||
import cz.marwland.mc.core.MarwCore;
|
||||
import cz.marwland.mc.core.features.Feature;
|
||||
import cz.marwland.mc.core.storage.SQLStorage;
|
||||
|
||||
public class Stats extends Feature {
|
||||
|
||||
private final Class<?> parentClass = this.getClass();
|
||||
private final SQLStorage database = MarwCore.getInstance().getStorage();
|
||||
|
||||
public Stats() {
|
||||
super();
|
||||
this.addCommand(new BukkitCommand(
|
||||
"mwstats",
|
||||
"Manages player's statistics.",
|
||||
"/mwstats",
|
||||
Arrays.asList() ) {
|
||||
@Override
|
||||
public boolean execute(CommandSender sender, String commandLabel, String[] args) {
|
||||
if (!permissionMissingCheck(sender, this.getPermission()))
|
||||
return true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPermission() {
|
||||
return getPermissionPath();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onEnable() {
|
||||
createTables();
|
||||
}
|
||||
|
||||
public void createTables() {
|
||||
try {
|
||||
database.executeRaw(parentClass.getResourceAsStream("/resources/create.sql"));
|
||||
} catch (SQLException | IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user