Search in sources :

Example 26 with PlayerStat

use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.

the class ToolsBrokenListener method onToolBreak.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onToolBreak(final PlayerItemBreakEvent event) {
    final PlayerStat stat = PlayerStat.TOOLS_BROKEN;
    // Get player
    final Player player = event.getPlayer();
    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;
    ItemStack item = event.getBrokenItem();
    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId(), "value", 1, "world", player.getWorld().getName(), "item", item.getType().toString()));
}
Also used : Player(org.bukkit.entity.Player) PlayerStat(me.staartvin.statz.datamanager.player.PlayerStat) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 27 with PlayerStat

use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.

the class VillagerTradesListener method onVillagerTrade.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onVillagerTrade(final InventoryClickEvent event) {
    final PlayerStat stat = PlayerStat.VILLAGER_TRADES;
    if (event.getInventory().getType() != InventoryType.MERCHANT) {
        return;
    }
    if (!event.getSlotType().equals(SlotType.RESULT)) {
        return;
    }
    if (!event.getAction().equals(InventoryAction.MOVE_TO_OTHER_INVENTORY) && !event.getAction().equals(InventoryAction.PICKUP_ALL)) {
        return;
    }
    if (!(event.getWhoClicked() instanceof Player)) {
        return;
    }
    Player player = (Player) event.getWhoClicked();
    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;
    ItemStack item = event.getCurrentItem();
    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, StatzUtil.makeQuery("uuid", player.getUniqueId().toString(), "value", item.getAmount(), "world", player.getWorld().getName(), "trade", item.getType().toString()));
}
Also used : Player(org.bukkit.entity.Player) PlayerStat(me.staartvin.statz.datamanager.player.PlayerStat) ItemStack(org.bukkit.inventory.ItemStack) EventHandler(org.bukkit.event.EventHandler)

Example 28 with PlayerStat

use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.

the class XPGainedListener method onXPGain.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onXPGain(final PlayerExpChangeEvent event) {
    final PlayerStat stat = PlayerStat.XP_GAINED;
    // 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", event.getAmount(), "world", player.getWorld().getName()));
}
Also used : Player(org.bukkit.entity.Player) PlayerStat(me.staartvin.statz.datamanager.player.PlayerStat) EventHandler(org.bukkit.event.EventHandler)

Example 29 with PlayerStat

use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.

the class CommandsPerformedListener method onPerformCommand.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onPerformCommand(final PlayerCommandPreprocessEvent event) {
    final PlayerStat stat = PlayerStat.COMMANDS_PERFORMED;
    // Get player
    final Player player = event.getPlayer();
    // Do general check
    if (!plugin.doGeneralCheck(player, stat))
        return;
    String message = event.getMessage();
    int subString = message.indexOf(" ");
    String command = "";
    String arguments = "";
    if (subString > 0) {
        command = message.substring(0, subString).trim();
        arguments = message.substring(subString).trim();
    } else {
        command = message.trim();
    }
    Query query = StatzUtil.makeQuery("uuid", player.getUniqueId(), "value", 1, "world", player.getWorld().getName(), "command", command, "arguments", arguments);
    // Update value to new stat.
    plugin.getDataManager().setPlayerInfo(player.getUniqueId(), stat, query);
}
Also used : Player(org.bukkit.entity.Player) Query(me.staartvin.statz.database.datatype.Query) PlayerStat(me.staartvin.statz.datamanager.player.PlayerStat) EventHandler(org.bukkit.event.EventHandler)

Example 30 with PlayerStat

use of me.staartvin.statz.datamanager.player.PlayerStat in project Statz by Staartvin.

the class DeathsListener method onDie.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onDie(final PlayerDeathEvent event) {
    final PlayerStat stat = PlayerStat.DEATHS;
    // Get player
    final Player player = event.getEntity();
    // 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()));
}
Also used : Player(org.bukkit.entity.Player) PlayerStat(me.staartvin.statz.datamanager.player.PlayerStat) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PlayerStat (me.staartvin.statz.datamanager.player.PlayerStat)44 Player (org.bukkit.entity.Player)30 EventHandler (org.bukkit.event.EventHandler)29 Query (me.staartvin.statz.database.datatype.Query)11 PlayerInfo (me.staartvin.statz.datamanager.player.PlayerInfo)11 UUID (java.util.UUID)7 ItemStack (org.bukkit.inventory.ItemStack)6 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 Entity (org.bukkit.entity.Entity)3 Block (org.bukkit.block.Block)2 EntityDamageByEntityEvent (org.bukkit.event.entity.EntityDamageByEntityEvent)2 Inventory (org.bukkit.inventory.Inventory)2 Map (java.util.Map)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 Material (org.bukkit.Material)1 Arrow (org.bukkit.entity.Arrow)1 Item (org.bukkit.entity.Item)1 Vehicle (org.bukkit.entity.Vehicle)1