Solved Creating a freeze plugin

Discussion in 'Plugin Development' started by Minecraft_GOLD, Nov 28, 2015.

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

    Minecraft_GOLD

  2. Offline

    timtower Administrator Administrator Moderator

    @Minecraft_GOLD if (cmd.getName().equalsIgnoreCase("freeze.player")) {
    Is probably returning false
     
  3. Offline

    Minecraft_GOLD

    I'm sorry, i'm really bad at coding, still learning, could you paste the new code with the fix so i can learn, i'm not sure quite what you mean, thanks for the fast reply!
     
  4. Offline

    mcdorli

    You never cancel the event.
     
  5. Offline

    Minecraft_GOLD

    I don't know what that means, could you explain, thanks!
     
  6. Offline

    timtower Administrator Administrator Moderator

    He is setting the to location though, so that won't matter.
    No, I won't spoonfeed, certainly not a single if statement.
     
  7. Offline

    Minecraft_GOLD

    Your answer "probably returning false" is it actually doing that if it is how can i stop it doing that
     
  8. Offline

    timtower Administrator Administrator Moderator

    @Minecraft_GOLD That is high likely, unless you run the command as /freeze.player
    And you put the correct string in the check.
     
  9. Offline

    mcdorli

    Because reinventing the wheel is always better. Why use e.setCancelled(true) if you can store the location and set it back every time.
     
  10. Offline

    timtower Administrator Administrator Moderator

    He isn't even storing the location.....
     
  11. Offline

    Minecraft_GOLD

    I'm really confused, in eclipse it says no errors but when im in game and try do /freeze it says an internal error occurred while attempting to perforn this command.
     
  12. Offline

    timtower Administrator Administrator Moderator

    Funny enough that means that you are making progress.
    What kind of error is it and on which line is it occurring?
     
  13. Offline

    Minecraft_GOLD

  14. Offline

    timtower Administrator Administrator Moderator

  15. Offline

    Scimiguy

    That using l33tsp34k is annoying?
     
  16. Offline

    mythbusterma

    Minecraft_GOLD likes this.
  17. Offline

    Minecraft_GOLD

    changed the first if statement in the onCommand from args.length ==0 to args.length < 1 still not working, my updated code http://pastebin.com/DEzLmtb9 @mythbusterman
     
  18. Offline

    mythbusterma

    @Minecraft_GOLD

    It's because you never return early, like you think you are. You REALLY need to format that code.
     
  19. Offline

    Scimiguy

    @Minecraft_GOLD
    Your spacing is awful, and probably what's causing your problems to be honest.

    This is your trouble line:
    Player target = Bukkit.getServer().getPlayer(args[0]);

    The reason it's your trouble line is because you're only running that if:
    if(args.length==0){

    So basically what you're telling your plugin is that:

    1. If I don't have any arguments;
    2. Use the first argument to get a player
    ?????????

    Also, wtf is this:
    if(cmd.getName().equalsIgnoreCase("freeze"));{


    @mythbusterma
    His problem isn't that he's not returning early, his problem is that he has his args[0] call INSIDE his if (args.length == 0)
     
  20. Offline

    Minecraft_GOLD

    thanks for the reply what should i changed that line to? could you give me a hint as i said im still learning. thanks a ton!
     
  21. Offline

    mcdorli

    Delete it, you do it twice
    Code:
    if (cmd.getName().equalsIgnoreCase("freeze")) {
                          if (args.length == 0) {
                                   if (cmd.getName().equalsIgnoreCase("freeze")); {
    
    Please press Ctrl+Shift+F in eclipse or Ctrl+Alt+L in IntelliJ, and repost the code

    and change the args==0 line to args==1
     
    Minecraft_GOLD likes this.
  22. Offline

    Minecraft_GOLD

    Thanks for the reply! i deleted the trouble line and replaced the args==0 to args==1 But now every target. command is coming up red, thanks again ! new cocde - > http://pastebin.com/rxPCCzYH
     
  23. Offline

    mcdorli

    Because in the hurry, you deleted the Player target = Bukkit.getServer().getPlayer() line. Use your head sometimes, and don't recline upon the plugin developement page.
     
    Minecraft_GOLD likes this.
  24. Offline

    Minecraft_GOLD

    Sorry, that was stupid of me and i know i shouldnt be so bad that this but i just needed help it's working now, thanks sir!
     
  25. Offline

    Scimiguy

    @Minecraft_GOLD
    Edit the title of this thread and mark it as solved then please
     
Thread Status:
Not open for further replies.

Share This Page