Search in sources :

Example 41 with UPlayer

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

the class PlayerLoginRoom method onQuit.

@EventHandler(priority = EventPriority.MONITOR)
public void onQuit(PlayerQuitEvent event) {
    final UPlayer player = new UPlayer(event);
    if (IN_PORTAL_ROOM.contains(player.getName())) {
        return;
    }
    Location location = player.getLocation();
    String locationString = LocationUtils.getStringFromLocation(location);
    DataFile.PLAYER_LOCATION.getConfig().set(player.getUniqueId().toString(), locationString);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) Location(org.bukkit.Location) EventHandler(org.bukkit.event.EventHandler)

Example 42 with UPlayer

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

the class ResourcePack method onJoin.

@EventHandler(priority = EventPriority.MONITOR)
public void onJoin(PlayerJoinEvent event) {
    final UPlayer player = new UPlayer(event);
    player.sendMessage(Message.PACK_SENDING);
    Bukkit.getScheduler().scheduleSyncDelayedTask(Main.getInstance(), new Runnable() {

        // For some reason sending the pack has to be delayed, otherwise the client won't get the message
        public void run() {
            player.setResourcePack(RESOURCE_PACK_URL);
        }
    }, 1 * 20);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) EventHandler(org.bukkit.event.EventHandler)

Example 43 with UPlayer

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

the class Chat method onChat.

@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(AsyncPlayerChatEvent event) {
    // Don't send chat message, we'll send a custom message
    event.setCancelled(true);
    UPlayer player = new UPlayer(event);
    if (Chat.IS_MUTED.get(player.getUniqueId())) {
        player.sendMessage(Message.CANT_CHAT_MUTED);
        event.setCancelled(true);
        return;
    }
    for (Trigger trigger : Trigger.values()) {
        if (event.getMessage().equals(trigger.getTrigger())) {
            event.setMessage(trigger.getMessage());
        }
    }
    ChatColor chatColor = ChatColor.WHITE;
    if (IS_SOFT_MUTED.get(player.getUniqueId()))
        chatColor = ChatColor.GRAY;
    int level = player.getLevel();
    BaseComponent[] message = new ComponentBuilder("").append("[").reset().color(ChatColor.DARK_GRAY).append(level + "").reset().color(ChatColor.GRAY).append("] ").reset().color(ChatColor.DARK_GRAY).append(player.getGroup().getName()).color(player.getGroup().getPrefixColor()).bold(player.getGroup().nameBold()).append(":").reset().color(ChatColor.DARK_GRAY).append(" ").create();
    message = ArrayUtils.addAll(message, player.getDisplayName(player.getGroup().getNameColor(), player.getGroup().nameBold()));
    message = ArrayUtils.addAll(message, new ComponentBuilder("").append(": ").reset().color(ChatColor.DARK_GRAY).bold(true).append(event.getMessage()).reset().color(chatColor).create());
    Ublisk.getServer().spigot().broadcast(message);
}
Also used : BaseComponent(net.md_5.bungee.api.chat.BaseComponent) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Trigger(xyz.derkades.ublisk.chat.Trigger) ChatColor(net.md_5.bungee.api.ChatColor) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder) EventHandler(org.bukkit.event.EventHandler)

Example 44 with UPlayer

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

the class Chat method onEnable.

@Override
public void onEnable() {
    for (UPlayer player : Ublisk.getOnlinePlayers()) {
        IS_MUTED.put(player.getUniqueId(), false);
        IS_SOFT_MUTED.put(player.getUniqueId(), false);
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer)

Example 45 with UPlayer

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

the class AddTrackersInfoToQueue method run.

public void run() {
    if (!SyncQueue.isEmpty())
        return;
    // The SyncQueue is empty, so add new stuff to it:
    List<BukkitRunnable> list = new ArrayList<BukkitRunnable>();
    for (final UPlayer player : Ublisk.getOnlinePlayers()) {
        list.add(new BukkitRunnable() {

            public void run() {
                if (player.isAfk()) {
                    Logger.log(LogLevel.INFO, "PlayerInfo", "Skipping " + player.getName() + " (afk)");
                    return;
                }
                PlayerInfo.syncWithDatabase(player);
                Logger.log(LogLevel.INFO, "PlayerInfo", "Synchronised player info for " + player.getName());
            }
        });
    }
    list.add(new BukkitRunnable() {

        public void run() {
            ServerInfo.syncWithDatabase();
            Logger.log(LogLevel.INFO, "Synced server info.");
        }
    });
    SyncQueue.addToQueue(list);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) ArrayList(java.util.ArrayList) BukkitRunnable(org.bukkit.scheduler.BukkitRunnable)

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