use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.
the class Statz method registerListeners.
private void registerListeners() {
if (!this.getConfigHandler().getStatsTracking()) {
this.debugMessage(ChatColor.GOLD + "Statz won't track stats of any player!");
// We don't track stats, so we don't register listeners
return;
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.DEATHS)) {
this.getServer().getPluginManager().registerEvents(new DeathsListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.JOINS)) {
this.getServer().getPluginManager().registerEvents(new JoinsListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ITEMS_CAUGHT)) {
this.getServer().getPluginManager().registerEvents(new ItemsCaughtListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.BLOCKS_PLACED)) {
this.getServer().getPluginManager().registerEvents(new BlocksPlacedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.BLOCKS_BROKEN)) {
this.getServer().getPluginManager().registerEvents(new BlocksBrokenListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.KILLS_MOBS)) {
this.getServer().getPluginManager().registerEvents(new KillsMobsListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.KILLS_PLAYERS)) {
this.getServer().getPluginManager().registerEvents(new KillsPlayersListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.FOOD_EATEN)) {
this.getServer().getPluginManager().registerEvents(new FoodEatenListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.DAMAGE_TAKEN)) {
this.getServer().getPluginManager().registerEvents(new DamageTakenListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.TIMES_SHORN)) {
this.getServer().getPluginManager().registerEvents(new TimesShornListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.DISTANCE_TRAVELLED)) {
this.getServer().getPluginManager().registerEvents(new DistanceTravelledListener(this), this);
this.getServer().getPluginManager().registerEvents(new DistanceTravelledVehicleListener(this), this);
this.getServer().getPluginManager().registerEvents(new DistanceTravelledToggleGlideListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ITEMS_CRAFTED)) {
this.getServer().getPluginManager().registerEvents(new ItemsCraftedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.XP_GAINED)) {
this.getServer().getPluginManager().registerEvents(new XPGainedListener(this), this);
}
// Important listeners that should always be on.
this.getServer().getPluginManager().registerEvents(new JoinPlayerListener(this), this);
this.getServer().getPluginManager().registerEvents(new QuitListener(this), this);
if (this.getDependencyManager().isAvailable(StatzDependency.VOTIFIER) || this.getDependencyManager().isAvailable(StatzDependency.NUVOTIFIER) && !this.getConfigHandler().isStatDisabled(PlayerStat.VOTES)) {
this.getServer().getPluginManager().registerEvents(new VotesListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ARROWS_SHOT)) {
this.getServer().getPluginManager().registerEvents(new ArrowsShotListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ENTERED_BEDS)) {
this.getServer().getPluginManager().registerEvents(new EnteredBedsListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.COMMANDS_PERFORMED)) {
this.getServer().getPluginManager().registerEvents(new CommandsPerformedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.TIMES_KICKED)) {
this.getServer().getPluginManager().registerEvents(new TimesKickedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.TOOLS_BROKEN)) {
this.getServer().getPluginManager().registerEvents(new ToolsBrokenListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.EGGS_THROWN)) {
this.getServer().getPluginManager().registerEvents(new EggsThrownListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.WORLDS_CHANGED)) {
this.getServer().getPluginManager().registerEvents(new WorldsChangedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.BUCKETS_FILLED)) {
this.getServer().getPluginManager().registerEvents(new BucketsFilledListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.BUCKETS_EMPTIED)) {
this.getServer().getPluginManager().registerEvents(new BucketsEmptiedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ITEMS_PICKED_UP)) {
this.getServer().getPluginManager().registerEvents(new ItemsPickedUpListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.ITEMS_DROPPED)) {
this.getServer().getPluginManager().registerEvents(new ItemsDroppedListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.TELEPORTS)) {
this.getServer().getPluginManager().registerEvents(new TeleportsListener(this), this);
}
if (!this.getConfigHandler().isStatDisabled(PlayerStat.VILLAGER_TRADES)) {
this.getServer().getPluginManager().registerEvents(new VillagerTradesListener(this), this);
}
for (PlayerStat stat : this.getConfigHandler().getDisabledStats()) {
this.debugMessage(ChatColor.DARK_AQUA + "Statz won't track " + stat.toString() + "!");
}
// Register confirm command
this.getServer().getPluginManager().registerEvents(new ConfirmTransferCommandListener(this), this);
}
use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.
the class BlocksBrokenListener method onBlockBreak.
@SuppressWarnings("deprecation")
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBlockBreak(final BlockBreakEvent event) {
final PlayerStat stat = PlayerStat.BLOCKS_BROKEN;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
Block blockBroken = event.getBlock();
final int typeId = blockBroken.getTypeId();
final int dataValue = blockBroken.getData();
final String worldName = blockBroken.getWorld().getName();
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "typeid", typeId, "datavalue", dataValue, "world", worldName));
}
use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.
the class BucketsEmptiedListener method onBucketEmpty.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onBucketEmpty(final PlayerBucketEmptyEvent event) {
final PlayerStat stat = PlayerStat.BUCKETS_EMPTIED;
// Get player
final Player player = event.getPlayer();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", 1, "world", player.getWorld().getName()));
}
use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.
the class UpdatePlayerCacheTask method run.
@Override
public void run() {
PlayerInfo cachedData = new PlayerInfo(uuid);
for (PlayerStat statType : PlayerStat.values()) {
if (statType.equals(PlayerStat.PLAYERS)) {
continue;
}
PlayerInfo databaseInfo = plugin.getDataManager().getFreshPlayerInfo(uuid, statType);
// User is not loaded, or there is no cache so we don't bother overwriting the cache.
if (databaseInfo == null) {
continue;
}
// Remove all 'id' columns to prevent leakage from the database.
for (Query query : databaseInfo.getRows()) {
query.removeColumn("id");
}
cachedData = cachedData.resolveConflicts(databaseInfo);
}
plugin.debugMessage("Updated cache of " + uuid);
// Store into cache.
plugin.getCachingManager().registerCachedData(uuid, cachedData);
}
use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.
the class ItemsCraftedListener method onCraft.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onCraft(final CraftItemEvent event) {
final PlayerStat stat = PlayerStat.ITEMS_CRAFTED;
// Get player
final Player player = (Player) event.getWhoClicked();
// Do general check
if (!plugin.doGeneralCheck(player, stat))
return;
final String itemCrafted = event.getCurrentItem().getType().toString();
// Update value to new stat.
plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", getCraftAmount(event), "world", player.getWorld().getName(), "item", itemCrafted));
}
Aggregations