Search in sources :

Example 6 with Town

use of xyz.derkades.ublisk.Town 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());
        }
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) Town(xyz.derkades.ublisk.Town)

Aggregations

Town (xyz.derkades.ublisk.Town)6 UPlayer (xyz.derkades.ublisk.utils.UPlayer)3 EventHandler (org.bukkit.event.EventHandler)2 ArrayList (java.util.ArrayList)1 UUID (java.util.UUID)1 BaseComponent (net.md_5.bungee.api.chat.BaseComponent)1 ClickEvent (net.md_5.bungee.api.chat.ClickEvent)1 TextComponent (net.md_5.bungee.api.chat.TextComponent)1 SongPlayer (xyz.derkades.ublisk.ext.com.xxmicloxx.noteblockapi.SongPlayer)1 QuestParticipant (xyz.derkades.ublisk.quest.QuestParticipant)1 URunnable (xyz.derkades.ublisk.utils.URunnable)1 PlayerNotFoundException (xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)1