Help getting a Item ID and Item Material name Configurable! Also Error help!

Discussion in 'Plugin Development' started by TECGaming360, Apr 26, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    TECGaming360

    I am trying to get this fixed tried for atleast a hour and is now getting frustrated, Well what im trying to do is letting a person config this as Item name as well as item id! but i get this error! "Incompatible operand types InventoryType and Material"

    Here is a clipping of my code
    Code:java
    1. @EventHandler
    2. public void PlayerInvClick(InventoryClickEvent e){
    3. Player player = (Player) e.getWhoClicked();
    4. if(e.getInventory().equals(player.getInventory().getType() == Material.getMaterial(KeepthatItem.plugin.getConfig().getString("Set Stuck Item")))) {
    5. e.setCancelled(true);
    6. }
    7. }
     
  2. Offline

    killerman747

    Code:java
    1. @EventHandler
    2. public void FirstInventory(InventoryClickEvent event){
    3. if(event.getInventory().getName().equals("Your Inventory")){
    4. Player player = (Player) event.getWhoClicked();
    5. event.setCancelled(true);
    6. if((!(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || !event.getCurrentItem().hasItemMeta()))){
    7. switch(event.getCurrentItem().getType()){
    8. case DIRT:
    9. player.sendMessage("YOU CLICKED DIRT");
    10.  
    11. break;
    12.  
    13. case STONE:
    14. player.sendMessage("YOU CLICKED STONE");
    15.  
    16. break;
    17.  
    18. default:
    19. player.sendMessage("YOU CLICKED SOMETHING ELSE");
    20.  
    21. break;
    22. }
    23. }
    24. }
    25. }

    That should help you
     
  3. Offline

    TECGaming360

    Soo, it kind helps but you remeber me i asked for help earlier how to get item stuck to hotbar were players can't move them so is "case Dirt" and "case STONE" the items that are stuck in hotbar??? and if so do i add getConfig String there?
     
  4. Offline

    killerman747

    TECGaming360
    If you want to use a config, you'll have to change the code slightly. You will have to make another event like I showed earlier to cancel the click event in this inventory. Heres the code for pulling from config:
    Code:java
    1. @EventHandler
    2. public void FirstInventory(InventoryClickEvent event){
    3. if(event.getInventory().getName().equals("Your Inventory")){
    4. Player player = (Player) event.getWhoClicked();
    5. event.setCancelled(true);
    6. if((!(event.getCurrentItem() == null || event.getCurrentItem().getType() == Material.AIR || !event.getCurrentItem().hasItemMeta()))){
    7. if(event.getCurrentItem().getType().equals(getConfig().getString("path.to.string"))){
    8. player.sendMessage("Message");
    9. }
    10. }
    11. }
    12. }

    Pretty sure that should work, untested. Let me know
     
  5. Offline

    TECGaming360

    so this will replace both Cancel click event and sticky item to hotbar?
     
  6. Offline

    killerman747

    TECGaming360
    No this should just handle the clicking of the specified item. Just edit the code I gave you earlier a little to make items stick.
     
Thread Status:
Not open for further replies.

Share This Page