diff --git a/Stats/.classpath b/Stats/.classpath new file mode 100644 index 0000000..e18f43d --- /dev/null +++ b/Stats/.classpath @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/Stats/.gitignore b/Stats/.gitignore new file mode 100644 index 0000000..09e3bc9 --- /dev/null +++ b/Stats/.gitignore @@ -0,0 +1,2 @@ +/bin/ +/target/ diff --git a/Stats/.project b/Stats/.project new file mode 100644 index 0000000..89f3268 --- /dev/null +++ b/Stats/.project @@ -0,0 +1,23 @@ + + + Stats + + + + + + org.eclipse.jdt.core.javabuilder + + + + + org.eclipse.m2e.core.maven2Builder + + + + + + org.eclipse.m2e.core.maven2Nature + org.eclipse.jdt.core.javanature + + diff --git a/Stats/.settings/org.eclipse.jdt.core.prefs b/Stats/.settings/org.eclipse.jdt.core.prefs new file mode 100644 index 0000000..43c686f --- /dev/null +++ b/Stats/.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/Stats/.settings/org.eclipse.m2e.core.prefs b/Stats/.settings/org.eclipse.m2e.core.prefs new file mode 100644 index 0000000..f897a7f --- /dev/null +++ b/Stats/.settings/org.eclipse.m2e.core.prefs @@ -0,0 +1,4 @@ +activeProfiles= +eclipse.preferences.version=1 +resolveWorkspaceProjects=true +version=1 diff --git a/Stats/deploy_feature.sh b/Stats/deploy_feature.sh new file mode 100755 index 0000000..f1c429f --- /dev/null +++ b/Stats/deploy_feature.sh @@ -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 \ No newline at end of file diff --git a/Stats/pom.xml b/Stats/pom.xml new file mode 100644 index 0000000..b293c31 --- /dev/null +++ b/Stats/pom.xml @@ -0,0 +1,63 @@ + + 4.0.0 + cz.marwland.mc.features + Stats + + 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 + + + Version Calculation + deploy + + exec + + + + + ${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/Stats/resources/create.sql b/Stats/resources/create.sql new file mode 100644 index 0000000..4b1f2e4 --- /dev/null +++ b/Stats/resources/create.sql @@ -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; \ No newline at end of file diff --git a/Stats/src/cz/marwland/mc/features/Stats.java b/Stats/src/cz/marwland/mc/features/Stats.java new file mode 100644 index 0000000..6be2a57 --- /dev/null +++ b/Stats/src/cz/marwland/mc/features/Stats.java @@ -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(); + } + } + +}