Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Added beardstat to statistics handlers.

  • Loading branch information...
commit af0a9dd25220d7526fbec67eab170d54b139c499 1 parent a3c0a33
@mkalus authored
View
8 pom.xml
@@ -35,10 +35,10 @@
<artifactId>worldguard</artifactId>
<version>5.5.1</version>
</dependency>
- <dependency><!-- You have to run 'mvn install:install-file -DgroupId=terranetworkorg -DartifactId=stats -Dversion=2.1.1 -Dpackaging=jar -Dfile=Stats.jar' in order to make this work: -->
- <groupId>terranetworkorg</groupId>
- <version>[2.1.1,)</version>
- <artifactId>stats</artifactId>
+ <dependency><!-- You have to run 'mvn install:install-file -DgroupId=tehbeard -DartifactId=beardstat -Dversion=0.4 -Dpackaging=jar -Dfile=BeardStat.jar' in order to make this work: -->
+ <groupId>tehbeard</groupId>
+ <version>[0.4,)</version>
+ <artifactId>beardstat</artifactId>
</dependency>
</dependencies>
<properties>
View
102 src/main/java/de/beimax/simplespleef/statistics/BeardStatisticsModule.java
@@ -0,0 +1,102 @@
+/**
+ * This file is part of the SimpleSpleef bukkit plugin.
+ * Copyright (C) 2011 Maximilian Kalus
+ * See http://dev.bukkit.org/server-mods/simple-spleef/
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ **/
+
+package de.beimax.simplespleef.statistics;
+
+import me.tehbeard.BeardStat.BeardStat;
+import me.tehbeard.BeardStat.containers.*;
+
+import org.bukkit.entity.Player;
+import org.bukkit.plugin.Plugin;
+
+import de.beimax.simplespleef.SimpleSpleef;
+import de.beimax.simplespleef.game.Game;
+
+/**
+ * @author mkalus
+ *
+ */
+public class BeardStatisticsModule extends FileStatisticsModule {
+ /**
+ * Manager of player statistics
+ */
+ protected PlayerStatManager beardStatManager;
+
+ /* (non-Javadoc)
+ * @see de.beimax.simplespleef.statistics.StatisticsModule#initialize()
+ */
+ @Override
+ public void initialize() throws Exception {
+ // call superclass
+ super.initialize();
+
+ // initialize beard stats manager
+ Plugin plugin = SimpleSpleef.getPlugin().getServer().getPluginManager().getPlugin("BeardStat");
+
+ // WorldGuard may not be loaded
+ if (plugin == null || !(plugin instanceof BeardStat)) {
+ beardStatManager = null;
+ SimpleSpleef.log.warning("[SimpleSpleef] Could not initiate BeardStat statistics.");
+ } else {
+ beardStatManager = ((BeardStat) plugin).getStatManager();
+ SimpleSpleef.log.info("[SimpleSpleef] Using BeardStat for statistics.");
+ }
+ }
+
+ /* (non-Javadoc)
+ * @see de.beimax.simplespleef.statistics.StatisticsModule#playerWonGame(org.bukkit.entity.Player, de.beimax.simplespleef.game.Game)
+ */
+ @Override
+ public void playerWonGame(Player player, Game game) {
+ // call superclass
+ super.playerWonGame(player, game);
+
+ // get games won
+ String key = "players." + player.getName() + ".";
+ int gamesCount = statistics.getInt(key + "gamesWon", 0);
+
+ // set stats
+ PlayerStatBlob blob = beardStatManager.findPlayerBlob(player.getName());
+ PlayerStat stat = blob.getStat("spleef", "won");
+ if (stat == null) stat = new PlayerStat("spleef", "won", gamesCount);
+ else stat.setValue(gamesCount);
+
+ blob.addStat(stat);
+ }
+
+ /* (non-Javadoc)
+ * @see de.beimax.simplespleef.statistics.StatisticsModule#playerLostGame(org.bukkit.entity.Player, de.beimax.simplespleef.game.Game)
+ */
+ @Override
+ public void playerLostGame(Player player, Game game) {
+ // call superclass
+ super.playerLostGame(player, game);
+ // get games won
+ String key = "players." + player.getName() + ".";
+ int gamesCount = statistics.getInt(key + "gamesLost", 0);
+
+ // set stats
+ PlayerStatBlob blob = beardStatManager.findPlayerBlob(player.getName());
+ PlayerStat stat = blob.getStat("spleef", "lost");
+ if (stat == null) stat = new PlayerStat("spleef", "lost", gamesCount);
+ else stat.setValue(gamesCount);
+
+ blob.addStat(stat);
+ }
+}
View
4 src/main/java/de/beimax/simplespleef/statistics/FileStatisticsModule.java
@@ -42,12 +42,12 @@
/**
* statistics reference (YAML)
*/
- YamlConfiguration statistics;
+ protected YamlConfiguration statistics;
/**
* file reference
*/
- File statisticsFile;
+ protected File statisticsFile;
/* (non-Javadoc)
* @see de.beimax.simplespleef.statistics.StatisticsModule#initialize()
View
3  src/main/java/de/beimax/simplespleef/statistics/StatisticsFactory.java
@@ -39,6 +39,9 @@ public StatisticsModule getStatisticsModuleByName(String moduleName, Configurati
if (moduleName.equalsIgnoreCase("file")) {
// just create file statistics - do nothing else
module = new FileStatisticsModule();
+ } else if (moduleName.equalsIgnoreCase("beardstat")) {
+ // just create file statistics - do nothing else
+ module = new BeardStatisticsModule();
}
// TODO: more module types here
View
3  src/main/resources/config.yml
@@ -65,7 +65,8 @@ settings:
changeGameModeBackToCreative: true
# Enable statistics module?
enableStatistics: true
-# Type of statistics module; possible values are: file
+# Type of statistics module; possible values are: file, beardstat
+# beardstat uses beardstat api for players' wins and losses - adds a spleef category with these two entries
statisticsModule: file
# Settings for statistics modules
statisticsSettings: false
View
2  src/main/resources/plugin.yml
@@ -1,6 +1,6 @@
name: SimpleSpleef
main: de.beimax.simplespleef.SimpleSpleef
-version: 3.0.14
+version: 3.0.15
dev-url: http://dev.bukkit.org/server-mods/simple-spleef/
author: maxkalus
description: >
Please sign in to comment.
Something went wrong with that request. Please try again.