The method dispatchCommand(CommandSender, String) in the type Bukkit is not applicable for the argum

Discussion in 'Plugin Development' started by NDUGAR, May 8, 2014.

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

    NDUGAR

    So this is probably the simplest error I could've made but on my tp command I'm getting an error on my IDE 'The method dispatchCommand(CommandSender, String) in the type Bukkit is not applicable for the arguments (ConsoleCommandSender, boolean)' because I need to teleport the player on their client side to their location server side.

    Full code:


    Code:java
    1. package me.Schnel.Ghost;
    2.  
    3.  
    4.  
    5. import org.bukkit.Bukkit;
    6.  
    7. import org.bukkit.ChatColor;
    8.  
    9. import org.bukkit.Effect;
    10.  
    11. import org.bukkit.Location;
    12.  
    13. import org.bukkit.Sound;
    14.  
    15. import org.bukkit.World;
    16.  
    17. import org.bukkit.command.Command;
    18.  
    19. import org.bukkit.command.CommandSender;
    20.  
    21. import org.bukkit.entity.Player;
    22.  
    23. import org.bukkit.plugin.java.JavaPlugin;
    24.  
    25.  
    26.  
    27. public class main extends JavaPlugin{
    28.  
    29.  
    30.  
    31. @Override
    32.  
    33. public void onEnable(){
    34.  
    35. getLogger().info("Plugin Enabled");
    36.  
    37. getLogger().severe("Uh oh! The plugin is DEAD!!! (or broken)");
    38.  
    39. }
    40.  
    41.  
    42.  
    43. @Override
    44.  
    45. public void onDisable(){
    46.  
    47. getLogger().info("Plugin Disbled");
    48.  
    49. }
    50.  
    51. @Override
    52.  
    53. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    54.  
    55. if (cmd.getName().equalsIgnoreCase("ghost") && sender instanceof Player){
    56.  
    57. final Player player = (Player)sender;
    58.  
    59. if(player.hasPermission("ghost.*")){
    60.  
    61. Location location = player.getLocation();
    62.  
    63. World world = player.getWorld();
    64.  
    65. world.playEffect(location, Effect.ENDER_SIGNAL, 7);
    66.  
    67. world.playEffect(location, Effect.MOBSPAWNER_FLAMES, 5);
    68.  
    69. world.playEffect(location, Effect.SMOKE, 3);
    70.  
    71. world.playEffect(location, Effect.EXTINGUISH, 1);
    72.  
    73. world.playSound(location, Sound.EXPLODE, 5, 3);
    74.  
    75. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), player.teleport(location));
    76.  
    77. sender.sendMessage(ChatColor.DARK_GRAY + "You have been tp'ed back");
    78.  
    79.  
    80.  
    81. for (Player p: Bukkit.getOnlinePlayers()){
    82.  
    83. p.hidePlayer(player);
    84.  
    85. }
    86.  
    87. Bukkit.getScheduler().scheduleSyncDelayedTask(this, new Runnable(){
    88.  
    89. public void run(){
    90.  
    91. for (Player p: Bukkit.getOnlinePlayers()){
    92.  
    93. p.showPlayer(player);
    94.  
    95. }
    96.  
    97. }
    98.  
    99. }, 60L);
    100.  
    101.  
    102.  
    103. return true;
    104.  
    105. }
    106.  
    107. }
    108.  
    109.  
    110.  
    111. return false;
    112.  
    113.  
    114.  
    115. }
    116.  
    117. }
    118.  
    119.  
     
  2. To dispatch a command, you literally have to type it as a string. For example,
    Code:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "/teleport location");
    For example, if your plugin has the command 'teleport' and it's arguments are 'player, world, x, y, z' you would use them in the string:
    Code:
    Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "/teleport " + player.getName() + " " + world.getName() + " " + x + " " + y + " " + z);
     
  3. Offline

    reider45

    You donn even need to dispatch the command; just use player.teleport(location);
     
Thread Status:
Not open for further replies.

Share This Page