I NEED ON THIS CODE PLIS :C

Discussion in 'Spigot Plugin Development' started by gomero, Aug 19, 2017.

  1. What happened to code markup?
     
  2. oooo l see the
    ((Player) p.getInventory()).updateInventory();
    its wrong, can somebody tell me a code to clear player's inventory?
     
  3. What is line 313?
     
  4. P.getInventory().clearInventory();
    ...
     
  5. ItemStack item = new ItemStack(Material.REDSTONE, 1, (byte)0);
     
  6. the method clearInventory not exist
     
  7. REDSTONE_TORCH_ON
     
  8. it say that the problem is on clearInventory not the item
     
  9. Its .clear();
    Sorry
     
  10. Try this out :

    Code (Text):
    @EventHandler
        public void onPlayerInteract(PlayerInteractEvent event) {
            Player player = event.getPlayer();
            if(event.getItem() == null) return;
            if(event.getItem().getType() == Material.BLAZE_ROD) {
                player.sendMessage("§cRankeds games are not available on this beta!");
            } else if(event.getItem().getType() == Material.EMERALD) {
                player.sendMessage("§cEvents are not ready on this beta!");
            } else if(event.getItem().getType() == Material.BOOK) {
                Bukkit.dispatchCommand(player, "settings");
            } else if(event.getItem().getType() == Material.TORCH) {
                player.setGameMode(GameMode.CREATIVE);
                player.getInventory().clear();
                ItemStack leaveItem = new ItemStack(Material.TORCH); // Creating ItemStack
                ItemMeta leaveItemMeta = leaveItem.getItemMeta(); // Getting ItemMeta
                leaveItemMeta.setDisplayName("§cLeave"); // Setting DisplayName
                leaveItem.setItemMeta(leaveItemMeta); // Setting ItemMeta
                player.getInventory().setItem(8, leaveItem); // Giving item to player's 8th inventory slot (the last one)
            }
        }
    Can we have more informations of what you are trying to do ?
     
  11. BINGO!!!! it work thanks for the help!
     
  12. l found a bug, so when l right click the Leave (Torch item) does not clear all my inv, and not give me the Torch to inv 8
    any idea?
     
  13. but when l hit with the item any where it put me in creative and clear my inventory with giving me the Torch item on my inv 8
     
  14. What's your code ?
     
  15. @EventHandler
    public void onPlayerInteract(PlayerInteractEvent event) {
    Player player = event.getPlayer();
    if(event.getItem() == null) return;
    if(event.getItem().getType() == Material.BLAZE_ROD) {
    player.sendMessage("§cRankeds games are not available on this beta!");
    } else if(event.getItem().getType() == Material.EMERALD) {
    player.sendMessage("§cEvents are not ready on this beta!");
    } else if(event.getItem().getType() == Material.BOOK) {
    Bukkit.dispatchCommand(player, "settings");
    } else if(event.getItem().getType() == Material.TORCH) {
    player.setGameMode(GameMode.CREATIVE);
    player.getInventory().clear();
    ItemStack leaveItem = new ItemStack(Material.REDSTONE);
    ItemMeta leaveItemMeta = leaveItem.getItemMeta();
    leaveItemMeta.setDisplayName("§cLeave");
    leaveItem.setItemMeta(leaveItemMeta);
    player.getInventory().setItem(8, leaveItem);
    }
    }
     
  16. Is it a redstone torch or a simple torch ?
     
  17. to execute (creative, clear inv, give the item): Torch
    To leave: Redstone
     
  18. go it ? what l try to do ?