Solved The method playEffect(Location, Effect, int) in the type World is not applicable for the arguments (

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

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

    NDUGAR

    Hello, this is my second plugin ever and I am wondering on how to either make the plugin work better or a solution to why my playEffect() is not working it comes up with this error code in the IDE
    'The method playEffect(Location, Effect, int) in the type World is not applicable for the arguments (Location, Effect)'

    Here is my full code:

    Code:java
    1. package me.Schnel.Ghost;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Effect;
    6. import org.bukkit.Location;
    7. import org.bukkit.Sound;
    8. import org.bukkit.command.Command;
    9. import org.bukkit.command.CommandSender;
    10. import org.bukkit.entity.Player;
    11. import org.bukkit.event.player.PlayerJoinEvent;
    12. import org.bukkit.plugin.java.JavaPlugin;
    13.  
    14. public class main extends JavaPlugin{
    15.  
    16. @Override
    17. public void onEnable(){
    18. getLogger().info("Plugin Enabled");
    19. }
    20.  
    21. @Override
    22. public void onDisable(){
    23. getLogger().info("Plugin Disbled");
    24. }
    25. @Override
    26. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    27. if (cmd.getName().equalsIgnoreCase("ghost")){
    28. Player player = (Player) sender;
    29. Location location = player.getLocation();
    30. player.getPlayer().getWorld().playEffect(location, Effect.GHAST_SHOOT);
    31. String ghost = "tp " + sender + sender;
    32. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ghost);
    33. sender.sendMessage(ChatColor.DARK_GRAY + "You have been tp'ed back");
    34. return true;
    35.  
    36. }
    37. return false;
    38.  
    39. }
    40. }
    41.  


    Sorry if this is a newbie mistake :| Anyway thanks for the help! ;D
     
  2. Offline

    TGRHavoc

    NDUGAR
    You need to add an Integer (Number) to the end of the playEffect method.
     
  3. Offline

    NDUGAR

    Oh thanks, I forgot that :p What does the integer argument do?
     
  4. Offline

    TGRHavoc

    NDUGAR
    I think it's the sound level.. Not too 100% sure though..
     
  5. Offline

    NDUGAR

    Oh thanks, also could you check if the plugin works, I think it does but there's no way to be sure apart from looking at the code so I want it to tp the player to themselves to fix the glitch were the client-side and server-side aren't in sync :D
     
  6. Offline

    TGRHavoc

    NDUGAR
    The string that tps the player will be something stupid like "tp Object@28Object@28" try adding a space between the two senders and using their name instead of their object
    hint:
    Code:
    sender.getName() + " " + sender.getName()
     
  7. Offline

    NDUGAR

    Thanks for all your help :D
     
  8. Offline

    TGRHavoc

    NDUGAR
    No problem, glad I could help.
     
  9. Offline

    NDUGAR


    One last thing, how would you add a permission node to the command, I attempted on my last plugin and it kind of failed tremendously :p

    Would you have it like if(player.hasPermission("ghost.*"))
     
  10. Offline

    TGRHavoc

    NDUGAR
    Yes, and you would also have to make sure that the permission is defined in the plugin.yml.
     
  11. Offline

    NDUGAR

    As in would this work for it:
    Code:java
    1. package me.Schnel.Ghost;
    2.  
    3. import org.bukkit.Bukkit;
    4. import org.bukkit.ChatColor;
    5. import org.bukkit.Effect;
    6. import org.bukkit.Location;
    7. import org.bukkit.command.Command;
    8. import org.bukkit.command.CommandSender;
    9. import org.bukkit.entity.Player;
    10. import org.bukkit.plugin.java.JavaPlugin;
    11.  
    12. public class main extends JavaPlugin{
    13.  
    14. @Override
    15. public void onEnable(){
    16. getLogger().info("Plugin Enabled");
    17. }
    18.  
    19. @Override
    20. public void onDisable(){
    21. getLogger().info("Plugin Disbled");
    22. }
    23. @Override
    24. public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
    25. if (cmd.getName().equalsIgnoreCase("ghost")){
    26. Player player = (Player) sender;
    27. if(player.hasPermission("ghost.*")){
    28. Location location = player.getLocation();
    29. player.getPlayer().getWorld().playEffect(location, Effect.GHAST_SHOOT, 7);
    30. String ghost = "tp " + sender.getName() + " " + sender.getName();
    31. Bukkit.dispatchCommand(Bukkit.getConsoleSender(), ghost);
    32. sender.sendMessage(ChatColor.DARK_GRAY + "You have been tp'ed back");
    33. return true;
    34. }
    35. }
    36. return false;
    37.  
    38. }
    39. }
    40.  
     
  12. Offline

    TGRHavoc

    NDUGAR
    If you have the permission in the plugin.yml then yes, that looks like it would work.
     
  13. Offline

    NDUGAR

    1 final thing I think I screwed up in YAML and I don't know how to correct it... ._. Sorry :3

    Code:
    name: Ghost
    author: SchnelStudios Inc.
    version: 1.0.0
    main: me.Schnel.Ghost.main
    description: Ever get endlessly tp'ed into a block or just stuck in limbo, using /ghost will make your day
    commands:
      ghost:
        usage: /ghost
        description: teleports a player to their server location instead of their client side location.
        permission: ghost.basic
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  14. Offline

    TGRHavoc

    NDUGAR
    What seems to be the problem with it? Any errors in the console?
    Edit: Yea, you posted it just as I asked :p
     
  15. Offline

    NDUGAR

    Done! Look up 1 post :p

    So it broken?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  16. Offline

    TGRHavoc

    NDUGAR
    Do you get any errors in the console when you boot up the plugin?
     
  17. Offline

    NDUGAR


    I think I fixed it and it came up with something like plugin.yml invalid...

    Code:
    name: Ghost
    author: SchnelStudios Inc.
    version: 1.0.0
    main: me.Schnel.Ghost.main
    description: Ever get endlessly tp'ed into a block or just stuck in limbo, using /ghost will make your day
    permissions:
      permission: ghost.*
      permission-message: You cannot disappear
    commands:
      ghost:
        usage: /ghost
        description: teleports a player to their server location instead of their client side location.
    
    Permission node 'permission-message' in plugin description file for Ghost v1.0.0 is invalid. Oh no :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  18. Offline

    TGRHavoc

    NDUGAR
    The plugin.yml should look like this..
    Code:
    name: Ghost
    author: SchnelStudios Inc.
    version: 1.0.0
    main: me.Schnel.Ghost.main
    description: Ever get endlessly tp'ed into a block or just stuck in limbo, using /ghost will make your day
    permissions:
      permission: ghost.*
     
    commands:
      ghost:
        usage: /ghost
        description: teleports a player to their server location instead of their client side location.
        permission: ghost.*
        permission-message: You cannot disappear
     
  19. Offline

    NDUGAR

    Thanks :D

    TGRHavoc
    Finally I get the message in game
    'Console teleported you to <playername>'

    How do I get that to hide :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  20. Offline

    TGRHavoc

  21. Offline

    NDUGAR

    Thanks anyway :p
     
  22. Offline

    TGRHavoc

  23. Offline

    NDUGAR

    TGRHavoc
    Erm I just reloaded it but now it still says that:


    Permission node 'permission' in plugin description file for Ghost v1.0.3 is invalid

    Here's my yml:

    Code:
    name: Ghost
    author: SchnelStudios Inc.
    version: 1.0.3
    main: me.Schnel.Ghost.main
    description: Ever get endlessly tp'ed into a block or just stuck in limbo, using /ghost will make your day
    permissions:
      permission: ghost.*
     
    commands:
      ghost:
        usage: /ghost
        description: teleports a player to their server location instead of their client side location.
        permission: ghost.*
        permission-message: You cannot disappear
     
  24. Offline

    TGRHavoc

    NDUGAR
    Code:
    name: Ghost
    author: SchnelStudios Inc.
    version: 1.0.3
    main: me.Schnel.Ghost.main
    description: Ever get endlessly tp'ed into a block or just stuck in limbo, using /ghost will make your day
    permissions:
      ghost.*:
     
     
    commands:
      ghost:
        usage: /ghost
        description: teleports a player to their server location instead of their client side location.
        permission: ghost.*
        permission-message: You cannot disappear
     
  25. Offline

    NDUGAR

    Ah ty, testing now :D
    TGRHavoc
    EDIT: It didn't work :( Permission node 'ghost.*' in plugin description file for Ghost v1.0.3 is invalid

    Why does this happen :p
    TGRHavoc sorry for all this spam :p

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 8, 2016
  26. Offline

    TGRHavoc

    NDUGAR
    Hmm, don't know exactly, try this:
    Code:
    permissions:
      ghost.*:
        default: op
     
  27. Offline

    NDUGAR

    THANKS :D Tytyty it worked but why xD
     
  28. Offline

    TGRHavoc

    NDUGAR
    It might of been the amount of spaces you put before the ghost node before... If there's one space too many or too little it screws with the whole file.
     
  29. Offline

    NDUGAR

    Ah thanks :D Any suggestions to make my ghost plugin better?
     
Thread Status:
Not open for further replies.

Share This Page