Search in sources :

Example 31 with UPlayer

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

the class ReplyCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (!(sender instanceof Player)) {
        sender.sendMessage(Message.NOT_A_PLAYER.toString());
        return true;
    }
    UPlayer player = new UPlayer(sender);
    UPlayer target = player.getLastSender();
    if (target == null) {
    // TODO Last sender unknown message
    }
    String msg = String.join("", args);
    target.sendPrivateMessage(player, msg);
    return true;
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) Player(org.bukkit.entity.Player) UPlayer(xyz.derkades.ublisk.utils.UPlayer)

Example 32 with UPlayer

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

the class StatsCommand method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
    UPlayer player = new UPlayer(sender);
    if (args.length == 1) {
        UPlayer target = null;
        try {
            target = new UPlayer(args[1]);
        } catch (PlayerNotFoundException e) {
            player.sendMessage(Message.PLAYER_NOT_FOUND);
            return true;
        }
        BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
        BaseComponent[] text = new ComponentBuilder("Click here to open " + target.getName() + "'s statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, target.getStatsURL())).create();
        player.sendMessage(text);
        return true;
    } else if (args.length == 0) {
        BaseComponent[] hoverText = new ComponentBuilder("yes click me pls").create();
        BaseComponent[] text = new ComponentBuilder("Click here to open your statistics page in your browser.").color(ChatColor.AQUA).bold(true).event(new HoverEvent(HoverEvent.Action.SHOW_TEXT, hoverText)).event(new ClickEvent(ClickEvent.Action.OPEN_URL, player.getStatsURL())).create();
        player.sendMessage(text);
        return true;
    } else {
        return false;
    }
}
Also used : HoverEvent(net.md_5.bungee.api.chat.HoverEvent) BaseComponent(net.md_5.bungee.api.chat.BaseComponent) UPlayer(xyz.derkades.ublisk.utils.UPlayer) ClickEvent(net.md_5.bungee.api.chat.ClickEvent) PlayerNotFoundException(xyz.derkades.ublisk.utils.exception.PlayerNotFoundException) ComponentBuilder(net.md_5.bungee.api.chat.ComponentBuilder)

Example 33 with UPlayer

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

the class Debug method onCommand.

@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    if (sender instanceof Player) {
        UPlayer player = new UPlayer(sender);
        if (player.hasPermission(Permission.COMMAND_DEBUG)) {
            if (args.length == 2) {
                if (args[0].equalsIgnoreCase("xp")) {
                    int xp = Integer.parseInt(args[1]);
                    player.setXP(xp);
                    return true;
                } else if (args[0].equals("refreshxp")) {
                    UPlayer target;
                    try {
                        target = new UPlayer(args[1]);
                    } catch (PlayerNotFoundException e) {
                        player.sendMessage("player not found");
                        return true;
                    }
                    player.updateXPBar();
                    player.sendMessage("XP refreshed!");
                    player.sendMessage("XP: " + target.getXP());
                    player.sendMessage("Level: " + target.getLevel());
                    return true;
                } else if (args[0].equals("life")) {
                    int life = Integer.parseInt(args[1]);
                    player.setLifeCrystals(life);
                    return true;
                } else if (args[0].equals("vote")) {
                    UPlayer target;
                    try {
                        target = new UPlayer(args[1]);
                    } catch (PlayerNotFoundException e) {
                        player.sendMessage("player not found");
                        return true;
                    }
                    player.sendMessage("Voting points: " + target.getVotingPoints());
                    return true;
                } else if (args[0].equals("inv")) {
                    UPlayer target;
                    try {
                        target = new UPlayer(args[1]);
                    } catch (PlayerNotFoundException e) {
                        player.sendMessage(Message.PLAYER_NOT_FOUND);
                        return true;
                    }
                    player.bukkit().openInventory(target.bukkit().getInventory());
                    return true;
                } else if (args[0].equals("skull")) {
                    player.getInventory().addItem(new Item(args[1]));
                    return true;
                } else if (args[0].equals("disablepl")) {
                    Main.getInstance().getServer().getPluginManager().disablePlugin(Main.getInstance().getServer().getPluginManager().getPlugin(args[1]));
                    return true;
                } else if (args[0].equals("enablepl")) {
                    Main.getInstance().getServer().getPluginManager().enablePlugin(Main.getInstance().getServer().getPluginManager().getPlugin(args[1]));
                    return true;
                } else {
                    player.sendMessage(Message.WRONG_USAGE);
                    return true;
                }
            } else if (args.length == 1) {
                if (args[0].equals("save")) {
                    for (DataFile file : DataFile.values()) {
                        file.save();
                    }
                    return true;
                } else {
                    player.sendMessage(Message.WRONG_USAGE);
                    return true;
                }
            } else {
                player.sendMessage(Message.WRONG_USAGE);
                return true;
            }
        } else {
            player.sendMessage(Message.NO_PERMISSION);
            return true;
        }
    } else {
        sender.sendMessage(Message.NOT_A_PLAYER.toString());
        return true;
    }
}
Also used : DataFile(xyz.derkades.ublisk.DataFile) Item(xyz.derkades.ublisk.utils.inventory.Item) UPlayer(xyz.derkades.ublisk.utils.UPlayer) Player(org.bukkit.entity.Player) UPlayer(xyz.derkades.ublisk.utils.UPlayer) PlayerNotFoundException(xyz.derkades.ublisk.utils.exception.PlayerNotFoundException)

Example 34 with UPlayer

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

the class InventoryClick method onItemClick.

@EventHandler
public void onItemClick(InventoryClickEvent event) {
    UPlayer player = new UPlayer(event.getWhoClicked());
    if (player.isInBuilderMode()) {
        return;
    }
    if (event.getInventory() != null && event.getInventory().getName() != null && event.getInventory().getName().contains("Box")) {
        event.setCancelled(true);
        return;
    }
    Material[] cancel = { Material.NETHER_STAR, Material.CHEST };
    Material clicked = event.getCurrentItem().getType();
    for (Material material : cancel) {
        if (clicked.equals(material)) {
            event.setCancelled(true);
        }
    }
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) Material(org.bukkit.Material) EventHandler(org.bukkit.event.EventHandler)

Example 35 with UPlayer

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

the class PlayerCommandPreprocess method tracker.

@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = false)
public void tracker(PlayerCommandPreprocessEvent event) {
    UPlayer player = new UPlayer(event);
    player.tracker(PlayerInfo.COMMANDS_EXECUTED);
}
Also used : UPlayer(xyz.derkades.ublisk.utils.UPlayer) 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