Help with "if(player.performCommand(arg0)"

Discussion in 'Plugin Development' started by Windwaker, Jun 2, 2011.

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

    Windwaker

    Okay I know I'm doing something wrong here... Basically right now this is just a teleport request, but that is not what it's going to be when it's done. I tested it and what it does is basically just ignores the if(player.performCommand("daccept") and just goes straight to teleporting the player.

    Mah code so far:

    http://pastebin.com/JWXjPct3
     
  2. Offline

    Jayjay110

    well ur basically expecting them to type the commands at the exact same point in time, not gonna happen, heres how i would do it:


    In on command check for /duel player, send that player a message asking him/her to accept it, then put a hashmap of the player and true and then put a hashmap of both the player and the sender, set a delayed task to set that to false in say 1 minute, and change the sender player one to null

    then seperately check for /daccept, for the other player, and then use the hashmap to check if he is accepting, then use the other hashmap to get the player hes accepting from... this should be easy for you, btw ur plugin sounds like it would be good :)
     
  3. Offline

    Windwaker

    Okay, already running into problems... I assume I'm doing it wrong here because it spams my console with errors if I type /duel <player> or /daccept. Ever.
     
  4. Offline

    Jayjay110

    Ok, I dont know what you doin but its definitely wrong :3, the main problem is you checking if its /duel daccept which is wierd? but your codes all over the place... here is a remodified version of what it should be...

    http://pastebin.com/0u2Lcife

    Done :) Editing that is lol :p
     
  5. Offline

    Windwaker

    Awesome! I managed to get the chat features working after cleaning up some of your code ;) so now everything else shouldn't be to hard :D

    I need to get better at boolean XD. Thanks again and I will credit you if I end up releasing this :)
     
  6. Offline

    Jayjay110

    Lol cleaning up my code, :p yeah it was just rough because I was editing it at like 8:00am on pastebin not in eclipse lol. Btw if you need any more help on this ill be glad 2 help :)
     
  7. Offline

    Windwaker

    @Jayjay110 Okay I have added some things, now I need help making PvP toggle-able. I gave it a shot, but pretty much I hit a wall after I disabled PvP. I tried using if(plugin.duelAccepted){ within the PvP disable function, but I wasn't able to get it work.

    What I have:

    Main Class
    EntityListener
     
  8. Offline

    Jayjay110

    WAit I buggerd this post hold on
     
  9. Offline

    Windwaker

    Are you still working on this? :p
     
  10. Offline

    Jayjay110

    Lol ya I was, Ok i thought i saw some errors but i didnt, what actually are you trying to do tho?
     
  11. Offline

    Windwaker

    Make it so when a player accepts a duel PvP is turned on for the acceptor and the asker. Once I know how to do that I will be able to figure out how to turn it off onPlayerDeath

    EDIT: Just to clarify, I tested it and it works fine.
     
  12. Offline

    Jayjay110

    So you got it working?
     
  13. Offline

    Windwaker

    No, lol, sorry for the confusion, what I have above works.
     
  14. Offline

    Jayjay110

    so your saying that it just doesnt turn off pvp?

    if so just do this in your entity listener:

    if (duelAccepted.containsKey(defender)){
    if (duelAccepted.get(defender)){
    event.setCancelled(true)
    }
    }


    btw go on the bukkit dev #bukkit on irc.esper.net, it would be easier to talk

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

    Windwaker

    Okay well when I do that I get errors. I tried doing yours, with "plugin." in front of it, and with "mcDuel." in front of it but It didn't work. I'm sorry to bother you, I am just hopeless with HashMaps :(

    I was on that earlier.. I'll go on now.

    @Jayjay110

    Just to clarify once more. What it does is this:

    /duel <player> - Request to Duel
    /daccept - Accept duel + teleport
    /ddeny - Deny duel - Sends message to both players
    PvP is off at all times

    What I want is to be:

    PvP is off at all times except when a player accepts a duel. Once this is toggled both players have PvP on until one of them dies.

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

    Jayjay110

    its ok :p

    OH really? Ok then do this:

    if (!plugin.duelAccepted.containsKey(defender)){
    event.setCancelled(true)
    }else{
    if (!plugin.duelAccepted.get(defender)){
    event.setCancelled(true)
    }
    }


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

    Windwaker

    @Jayjay110

    Thanks for all the help, I look forward to a prosperous partnership :)
     
Thread Status:
Not open for further replies.

Share This Page