"Unknown Command" when using dispatchCommand

Discussion in 'Plugin Development' started by najm, Aug 15, 2014.

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

    najm

    Hey guys,
    so I've got that code:
    Code:java
    1. @EventHandler
    2. public void ifgold(PlayerInteractEvent e) {
    3. if(e.getPlayer().getInventory().getItemInHand().getType().equals(Material.GOLD_INGOT)) {
    4. Bukkit.getServer().dispatchCommand(e.getPlayer(), "buy");

    It's for the buycraft plugin, so when u rightclick the gold ingot it should execute /buy.
    Well, when I rightclick the goldingot, it's telling me: "Unknown Command[...]"
    But when I write /buy everything works fine D:
    Whats wrong?

    Thx for your answers <3
     
  2. najm
    Code:
    Bukkit.getServer().dispatchCommand(e.getPlayer(), "/buy");
     
  3. Offline

    Garris0n

  4. You could try this
    Code:java
    1. e.getPlayer().performCommand("buy");
     
Thread Status:
Not open for further replies.

Share This Page