Solved Player can’t drop the item from the creative

Discussion in 'Plugin Development' started by GRENKA, Jul 15, 2021.

  1. Offline


    My problem:
    When I right-click, I am given a creative. I press "E" to enter the inventory and I can take things from the creative to my inventory, BUT I cannot hover over the item and click "Q" to throw it away, nothing happens. Wish the items were thrown away.

    package plugin.grenka.plugin;
    import org.bukkit.GameMode;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.Action;
    import org.bukkit.event.player.*;
    import org.bukkit.inventory.ItemStack;
    import static java.lang.Thread.sleep;
    public final class Plugin extends JavaPlugin implements Listener {
        boolean ibb = true;
        public void onEnable() {
            // Plugin startup logic
            System.out.println("The plugin is starting up.");
            getServer().getPluginManager().registerEvents(this, this);
        public void onPlayer(PlayerInteractEvent event) throws InterruptedException {
            Player player = event.getPlayer();
            Action action = event.getAction();
            if (action.equals(Action.RIGHT_CLICK_AIR) || action.equals(Action.RIGHT_CLICK_BLOCK)) {
                if (player.getItemInHand().getType() == Material.TRIDENT) {
                    player.getInventory().getItemInMainHand().setAmount(player.getInventory().getItemInMainHand().getAmount() - 1);
        public void PlayerAdvancementDone(PlayerAdvancementDoneEvent event){
            Player player = event.getPlayer();
            player.getInventory().addItem(new ItemStack(Material.TRIDENT, 1));
    If I turn on the creative myself, then that's okay, if the plugin turns it on, I can't. And all what i do in creative - everything rolls back. I think problem with "sleep"...

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Jul 16, 2021
  2. Offline

    timtower Administrator Administrator Moderator

    @GRENKA Yeah, sleep is your code is bad.
  3. Offline


    I change to

    Bukkit.getScheduler().runTaskLater(this, () -> {
                    }, 40L);

Share This Page