use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class AbilityListener method onInteract.
@EventHandler
public void onInteract(PlayerInteractEvent event) {
Action action = event.getAction();
if (action == Action.PHYSICAL)
return;
UPlayer player = new UPlayer(event);
if (action == Action.LEFT_CLICK_AIR || action == Action.LEFT_CLICK_BLOCK) {
for (Weapon weapon : Weapon.WEAPONS) {
if (Weapon.itemStackIsWeapon(player.getInventory().getItemInMainHand().getItemStack(), weapon)) {
player.doAbility(weapon.getLeftClickAbility());
}
}
}
if (action == Action.RIGHT_CLICK_AIR || action == Action.RIGHT_CLICK_BLOCK) {
for (Weapon weapon : Weapon.WEAPONS) {
if (Weapon.itemStackIsWeapon(player.getInventory().getItemInMainHand().getItemStack(), weapon)) {
player.doAbility(weapon.getRightClickAbility());
}
}
}
}
use of xyz.derkades.ublisk.utils.UPlayer in project Ublisk by Derkades.
the class CheckTown method run.
@Override
public void run() {
for (UPlayer player : Ublisk.getOnlinePlayers()) {
Town town = player.getTown();
Town lastTown = player.getLastTown();
if (town == null && !SENT_LEFT_MESSAGE.contains(player.getUniqueId())) {
// If the player is no longer in a town
player.sendSubTitle(ChatColor.GRAY + "You left " + lastTown.getName());
SENT_LEFT_MESSAGE.add(player.getUniqueId());
Logger.log(LogLevel.INFO, "Town", player.getName() + " left " + lastTown.getName());
} else if (town != null && SENT_LEFT_MESSAGE.contains(player.getUniqueId())) {
// As soon as the player enters a town and has got a left message
player.sendSubTitle(ChatColor.GRAY + "You are now in " + town.getName());
Logger.log(LogLevel.INFO, "Town", player.getName() + " is now in " + lastTown.getName());
player.setLastTown(town);
SENT_LEFT_MESSAGE.remove(player.getUniqueId());
}
if (town != null) {
player.setWeather(town.getWeather());
}
}
}
Aggregations