Solved Build Command

Discussion in 'Plugin Development' started by PhilDEV_Acc, Jan 7, 2020.

Thread Status:
Not open for further replies.
  1. Hello Im trying to code a /build command that ignors the InventoryMoveEvent. How can I code it?

    Code:
    public boolean onCommand(CommandSender sender, Command befehl, String befehlsname , String[] args) {
            if (sender instanceof Player) {
                Player spieler = (Player) sender;
              
                if (spieler.hasPermission("lobby.build")) {
                  
                }else {
                    spieler.sendMessage(ChatColor.RED + "Du hast keine berechtigung auf diesen Befehl");
                }
            }else {
                this.getLogger().info("Dieser Befehl kann nur von Spielern ausgeführt werden");
            }
    Thanks for helping.
     
    Last edited: Jan 7, 2020
  2. Offline

    KarimAKL

    @PhilDEV_Acc Could you explain a little more? What should the command do, why does it need to ignore an event, and which event is it? (There's no InventoryMoveEvent)
     
  3. So I disabled for my Lobby plugin the InventoryClickEvent and the PlayerDropItemEvent so you cant move items but now you cant take blocks out of the creative Inventory so you cant build. The command should deactivate this so you can take Items in your inventory.
     
  4. Offline

    c7dev

    If you mean to un-cancel these events, you can do: (for each event)
    Code:
    @EventHandler(priority = EventPriority.LOW)
    public void onClick(PlayerInventoryClickEvent e) {
        if (e.getPlayer().hasPermission("lobby.build")) {
            e.setCancelled(false);
        }
    }
    
    Also, the easiest way to stop players building is to cancel BlockPlaceEvent
     
  5. Add the players (or their uuids) to a list and check in the events for them
     
Thread Status:
Not open for further replies.

Share This Page