Warping

Discussion in 'Spigot Plugin Development' started by DJJujuVI, Jun 13, 2016.

  1. Hey guys, I'm creating a custom inventory plugin, so when the player opens the inv I want it to show them a list of options which I have done, when I do my e.getWhoClicked() I want it to do an in-game command, anyway to do this with or without this method? Thanks!
     
  2. You can use the performCommand() command to do this.
     
    • Agree Agree x 1
  3. Bukkit#dispatchCommamd(sender, cmd);

    or

    player.chat(cmd);
     
    • Agree Agree x 1
  4. Yes what they said and with this way you can perform whatever command you want
     
    • Optimistic Optimistic x 1
  5. Do you even realise that this is completely useless? Don't post farm please..
     
  6. if he use Bukkit#dispatchCommand he can perform any command he want by the console
     
  7. Code (Text):
            @EventHandler
            public void onInventoryClick(InventoryClickEvent e) {
                    e.setCancelled(true);
                    if (!e.getInventory().getName().equalsIgnoreCase(inv.getName())) return;
                    if (e.getCurrentItem().getItemMeta() == null) return;
                    if (e.getCurrentItem().getItemMeta().getDisplayName().contains("Crypto")) {
                            e.setCancelled(true);
                            player.chat("warp Crypto");
                            e.getWhoClicked().closeInventory();
    Hey guys, here is my code and I am having trouble with adding the variables and I am having trouble with making a Player variable and doing the command, can someone help me with this? Thanks!
    (New DEV)
     
  8. Same thing with this command, I can't create a variable for some reason and it doesn't let me do it because of the variable.
     
  9. The #getWhoClicked() method in that event will return an instance of the Player that clicked.
     
  10. Add some debug messages, also have an else state when you check for the name, and have it return the item name, and Crypto.
    Post what it says here and I can help you further.
     
  11. Hey, can you give me an example piece of code? I am a little confused with your statement.
     
  12. Player clicker = (Player) e.getWhoClicked
     
  13. I know that, I mean a piece of code for the player.chat method or the performCommand method
     
  14. You quoted him saying that that #getWhoClicked() returns a player instance.
    I assumed that's what you were having trouble with :p
     
  15. Ok, so can you give me an example code?
     
  16. What does the # mean anyway? I don't understand that.
     
  17. Of what?
    A period
     
  18. Example for the performCommand() code and player.chat() code ingame.

    I keep saying this...
     
  19. Anyone else with ideas?