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);
}
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();
}
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");
}
}
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);
}
}
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.");
}
Aggregations