use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class InventoryClick method tracker.
@EventHandler(ignoreCancelled = false, priority = EventPriority.MONITOR)
public void tracker(InventoryClickEvent event) {
UPlayer player = new UPlayer(event.getWhoClicked());
player.tracker(PlayerInfo.INV_CLICK);
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerDeath method onDeath.
@EventHandler
public void onDeath(PlayerDeathEvent event) {
final UPlayer player = new UPlayer(event);
event.setDeathMessage(ChatColor.DARK_AQUA + "" + ChatColor.BOLD + player.getName() + " died near " + player.getLastTown().getName());
event.setKeepInventory(true);
if (player.getLifeCrystals() > 0) {
player.setLifeCrystals(player.getLifeCrystals() - 1);
} else {
player.getInventory().dropItems(player.getLocation());
player.getInventory().clear();
}
new BukkitRunnable() {
public void run() {
player.spigot().respawn();
}
}.runTaskLater(Main.getInstance(), 3L);
new BukkitRunnable() {
public void run() {
player.setMana(20);
CustomHealth.updateMaxHealth(player);
player.heal();
player.teleport(player.getLastTown().getSpawnLocation());
}
}.runTaskLater(Main.getInstance(), 25L);
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerInteract method tracker.
// ignoreCancelled = true - Still track clicks if they are cancelled
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void tracker(PlayerInteractEvent event) {
UPlayer player = new UPlayer(event);
Action action = event.getAction();
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
player.tracker(PlayerInfo.RIGHT_CLICKED);
}
if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
player.tracker(PlayerInfo.LEFT_CLICKED);
}
if (action == Action.RIGHT_CLICK_BLOCK) {
if (event.getClickedBlock().getType() == Material.CHEST) {
Chest chest = (Chest) event.getClickedBlock().getState();
if (Loot.isLoot(chest)) {
player.tracker(PlayerInfo.LOOT_FOUND);
}
}
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerInteract method chestOpen.
@EventHandler(priority = EventPriority.HIGH, ignoreCancelled = true)
public void chestOpen(PlayerInteractEvent event) {
if (event.getAction() != Action.RIGHT_CLICK_BLOCK || event.getClickedBlock().getType() != Material.CHEST)
return;
Chest chest = (Chest) event.getClickedBlock().getState();
UPlayer player = new UPlayer(event);
if (player.isInBuilderMode()) {
if (!Loot.isLoot(chest)) {
// Send message if chest is not loot
player.sendMessage(ChatColor.RED + "Warning: Regular players won't be able to open this chest.");
}
return;
}
if (!Loot.isLoot(chest)) {
// Cancel chest right click if chest is not loot
event.setCancelled(true);
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class PlayerInteractEntity method tracker.
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
public void tracker(PlayerInteractEntityEvent event) {
if (event.getHand() != EquipmentSlot.HAND)
return;
UPlayer player = new UPlayer(event);
player.tracker(PlayerInfo.ENTITY_CLICK);
}
Aggregations