Search in sources :

Example 1 with UPlayer

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);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 2 with UPlayer

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);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable) EventHandler(org.bukkit.event.EventHandler)

Example 3 with UPlayer

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);
            }
        }
    }
}
Also used : Chest(org.bukkit.block.Chest) Action(org.bukkit.event.block.Action) UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 4 with UPlayer

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);
    }
}
Also used : Chest(org.bukkit.block.Chest) UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 5 with UPlayer

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);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Aggregations

UPlayer (xyz.derkades.ublisk.utils.UPlayer)47 EventHandler (org.bukkit.event.EventHandler)26 Player (org.bukkit.entity.Player)9 PlayerNotFoundException (xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)7 ComponentBuilder (net.md_5.bungee.api.chat.ComponentBuilder)5 Item (xyz.derkades.ublisk.utils.inventory.Item)5 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)4 ArrayList (java.util.ArrayList)3 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)3 Material (org.bukkit.Material)3 OfflinePlayer (org.bukkit.OfflinePlayer)3 Chest (org.bukkit.block.Chest)3 Action (org.bukkit.event.block.Action)3 BukkitRunnable (org.bukkit.scheduler.BukkitRunnable)3 Town (xyz.derkades.ublisk.Town)3 MainMenu (xyz.derkades.ublisk.iconmenus.MainMenu)3 UUID (java.util.UUID)2 HoverEvent (net.md_5.bungee.api.chat.HoverEvent)2 Location (org.bukkit.Location)2 Block (org.bukkit.block.Block)2