Search in sources :

Example 11 with UPlayer

use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.

the class AFK method onMove.

@EventHandler(priority = EventPriority.MONITOR)
public void onMove(PlayerMoveEvent event) {
    UPlayer player = new UPlayer(event);
    if (player.isAfk())
        player.setAfk(false);
    AFK_SECONDS.put(player.getName(), 0);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 12 with UPlayer

use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.

the class PlayerQuit method onQuit.

@EventHandler(priority = EventPriority.HIGH)
public void onQuit(PlayerQuitEvent event) {
    final UPlayer player = new UPlayer(event);
    event.setQuitMessage(DARK_AQUA + "" + BOLD + player.getName() + AQUA + " has left");
    player.refreshLastSeenDate();
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 13 with UPlayer

use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.

the class SongEnd method musicStopped.

@EventHandler
public void musicStopped(SongEndEvent event) {
    try {
        SongPlayer songPlayer = event.getSongPlayer();
        for (String playername : songPlayer.getPlayerList()) {
            UPlayer player = new UPlayer(playername);
            if (player.getSetting(Setting.PLAY_MUSIC)) {
                Town town = player.getTown();
                if (town != null) {
                    town.playThemeToPlayer(player);
                }
            }
        }
        songPlayer.destroy();
    } catch (PlayerNotFoundException e) {
        Logger.log(LogLevel.WARNING, "Music", "Tried to play new song but player has already logged out");
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) SongPlayer(xyz.derkades.ublisk.ext.com.xxmicloxx.noteblockapi.SongPlayer) Town(xyz.derkades.ublisk.Town) PlayerNotFoundException(xyz.derkades.ublisk.utils.exception.PlayerNotFoundException) EventHandler(org.bukkit.event.EventHandler)

Example 14 with UPlayer

use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.

the class Voting method onVoteBoxOpen.

@EventHandler(priority = EventPriority.HIGH)
public void onVoteBoxOpen(PlayerInteractEvent event) {
    if (event.getAction() != Action.RIGHT_CLICK_BLOCK) {
        return;
    }
    UPlayer player = new UPlayer(event);
    if (player.isSneaking()) {
        return;
    }
    Block block = event.getClickedBlock();
    if (Voting.isVotingChest(block)) {
        Chest chest = (Chest) block.getState();
        Inventory inv = chest.getInventory();
        int gold = Voting.getRandomGold();
        int xp = Voting.getRandomXP();
        int life = Voting.getRandomLife();
        Item goldItem = new Item(Material.GOLD_NUGGET).setName(ChatColor.GOLD + "" + ChatColor.BOLD + "Gold: " + gold).setAmount(gold);
        Item xpItem = new Item(Material.EXP_BOTTLE).setName(ChatColor.GREEN + "" + ChatColor.BOLD + "XP: " + xp).setAmount(xp);
        Item lifeItem = new Item(Material.NETHER_STAR).setName(ChatColor.BOLD + "Life Crystals: " + life).setAmount(life);
        inv.setItem(12, goldItem.getItemStack());
        inv.setItem(13, xpItem.getItemStack());
        inv.setItem(14, lifeItem.getItemStack());
        if (gold != 0) {
            player.getInventory().addItem(Material.GOLD_NUGGET, gold);
        }
        if (xp != 0) {
            player.addXP(xp);
        }
        if (life != 0) {
            player.setLifeCrystals(player.getLifeCrystals() + life);
        }
        player.tracker(PlayerInfo.VOTE_BOX);
        Logger.log(LogLevel.DEBUG, "Voting", "Gold: " + gold + " | XP: " + xp + " | Life: " + life);
    }
}
Also used : Chest(org.bukkit.block.Chest) Item(xyz.derkades.ublisk.utils.inventory.Item) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Block(org.bukkit.block.Block) Inventory(org.bukkit.inventory.Inventory) EventHandler(org.bukkit.event.EventHandler)

Example 15 with UPlayer

use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.

the class Voting method onVote.

@EventHandler(priority = EventPriority.HIGH)
public void onVote(VotifierEvent event) {
    Vote vote = event.getVote();
    UPlayer player;
    try {
        player = new UPlayer(vote.getUsername());
    } catch (PlayerNotFoundException e) {
        // TODO Deal with player not online exception
        e.printStackTrace();
        return;
    }
    int points = Random.getRandomInteger(1, 3);
    player.setVotingPoints(player.getVotingPoints() + points);
    Ublisk.broadcastPrefixedMessage(player.getName() + " has voted and got " + points + " points! Vote at " + Var.VOTE_URL);
    Logger.log(LogLevel.INFO, "Vote", player.getName() + " has voted at " + vote.getServiceName() + " (" + vote.getAddress() + ") and got " + points + " points.");
}
Also used : Vote(com.vexsoftware.votifier.model.Vote) UPlayer(xyz.derkades.ublisk.utils.UPlayer) PlayerNotFoundException(xyz.derkades.ublisk.utils.exception.PlayerNotFoundException) 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