use of com.gmail.stefvanschiedev.buildinggame.managers.stats.StatManager in project buildinggame by stefvanschie.
the class CommandManager method onReload.
/**
* Called whenever a command sender wants to reload the plugin
*
* @param sender the command sender
* @since 5.8.0
*/
@Subcommand("reload")
@Description("Reload the plugin")
@CommandPermission("bg.reload")
public void onReload(CommandSender sender) {
ArenaManager.getInstance().getArenas().stream().filter(arena -> arena.getPlayers() > 0).forEach(Arena::stop);
StatManager instance = StatManager.getInstance();
if (instance.getMySQLDatabase() == null)
instance.saveToFile();
else
instance.saveToDatabase();
FileCheckerTimer runnable = SettingsManager.getInstance().getRunnable();
if (!runnable.isCancelled())
runnable.cancel();
Main.getInstance().loadPlugin(true);
MessageManager.getInstance().send(sender, ChatColor.GREEN + "Reloaded the plugin!");
}
use of com.gmail.stefvanschiedev.buildinggame.managers.stats.StatManager in project buildinggame by stefvanschie.
the class BreakStat method onBlockBreak.
/**
* Handles statistics for broken blocks
*
* @param e an event representing a block being broken
* @see BlockBreakEvent
* @since 2.2.0
*/
@EventHandler
public void onBlockBreak(BlockBreakEvent e) {
var player = e.getPlayer();
if (ArenaManager.getInstance().getArena(player) == null)
return;
StatManager instance = StatManager.getInstance();
var stat = instance.getStat(player, StatType.BROKEN);
instance.registerStat(player, StatType.BROKEN, stat == null ? 1 : stat.getValue() + 1);
}
use of com.gmail.stefvanschiedev.buildinggame.managers.stats.StatManager in project buildinggame by stefvanschie.
the class FirstStat method onPlayerWin.
/**
* Handles statistics for players becoming first
*
* @param e an event that represents a player winning
* @see PlayerWinEvent
* @since 2.2.0
*/
@EventHandler
public void onPlayerWin(PlayerWinEvent e) {
if (e.getWin() != Win.FIRST)
return;
StatManager instance = StatManager.getInstance();
e.getPlayers().stream().map(GamePlayer::getPlayer).forEach(player -> {
var stat = instance.getStat(player, StatType.FIRST);
instance.registerStat(player, StatType.FIRST, stat == null ? 1 : stat.getValue() + 1);
});
}
use of com.gmail.stefvanschiedev.buildinggame.managers.stats.StatManager in project buildinggame by stefvanschie.
the class PlaysStat method onArenaStart.
/**
* Handles statistics for games played
*
* @param e an event that represents an arena starting
* @see ArenaStartEvent
* @since 2.2.0
*/
@EventHandler
public static void onArenaStart(ArenaStartEvent e) {
StatManager instance = StatManager.getInstance();
e.getArena().getUsedPlots().stream().flatMap(plot -> plot.getGamePlayers().stream()).forEach(gamePlayer -> {
var player = gamePlayer.getPlayer();
var stat = instance.getStat(player, StatType.PLAYS);
instance.registerStat(player, StatType.PLAYS, stat == null ? 1 : stat.getValue() + 1);
});
}
use of com.gmail.stefvanschiedev.buildinggame.managers.stats.StatManager in project buildinggame by stefvanschie.
the class ThirdStat method onPlayerWin.
/**
* Handles statistics for players becoming third
*
* @param e an event representing a player winning
* @see PlayerWinEvent
* @since 2.2.0
*/
@EventHandler
public static void onPlayerWin(PlayerWinEvent e) {
if (e.getWin() != Win.THIRD)
return;
StatManager instance = StatManager.getInstance();
e.getPlayers().stream().map(GamePlayer::getPlayer).forEach(player -> {
var stat = instance.getStat(player, StatType.THIRD);
instance.registerStat(player, StatType.THIRD, stat == null ? 1 : stat.getValue() + 1);
});
}
Aggregations