How to select another player to do stuff to?

Discussion in 'Plugin Development' started by vanwed94, Aug 23, 2011.

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

    vanwed94

    Ok so i made a plugin that just made people a god when they type /god (Not releasing worldGuard and essentials work fine) but i find it annoying when god people just destroy everyone in pvp is there a way so that if a player punches an entity (Mob) they get "Ungoded" to prevent this or how to make a command that when i type /degod ExampleMan123, ExampleMan123 gets ungoded and gets a message saying :youve been degoded by vanwed94.
    thanks for any help possible
     
  2. MIm pretty sure you savemyour god-players in some list/set/map.
    In your ungod-command, use getPlayer or matchPlayer in the server class to parse your args string. When you use entitydamageevent ... Open your eyes or Search how to get the attacker if any. If its a player, you have your object.

    Then you obviously only need to remove the plqyer entry from your collection.
     
  3. Offline

    sddddgjd

    right click?
    You just check for ENTITY_INTERACT_EVENT,and get event.getPlayer() and event.getRightClicked()!
     
  4. Offline

    vanwed94

    @Bone008 actually i just have it so you type the command and you get 200 health with no Hashmap or other stuff like that (i want a better explination cause the HUGE plugin tutorial is not very helpful)
    @sddddgjd
    not rightclick i was looking for something like is it possible (with a hashmap or something) to have when a player gets hit by a player using the getlast damage casue thing then it checks if the other player is in the hashmap then takes them out if they are
    and also i was wondering what the event or whaever its called is to type /ungod <player>
    and then it sets their health back to normal
     
  5. Offline

    Blacky372

    Or you do that when somebody is a god he cant hurt mobs or players.
     
  6. Offline

    Kostronor

    Try to add if(attacker.getHealth() > 20) {
    Set to 20
     
  7. Offline

    vanwed94

    oh that might work thanks
     
  8. A bigger health isnt exactly gOd mode ...
    Just put the players who are gods in a HashSet and check in EntityDamageEvent if the damaged one is in it.
    To /ungod, just see if the given player is in it, and remove it.

    If you want more basic explanation to do what i said, go and look for some tutorials on commands and so on, there are honestly enough out there!

    Also use he forum's search and the apidocs, that answers most of your questions.
     
  9. Offline

    vanwed94

    umm is attacker an alias cause it's not registering
     
  10. Offline

    Kostronor

    i'm just blindcoding, you have to use event.get(something like cause but a player)().getHealth()
     
  11. Offline

    vanwed94

Thread Status:
Not open for further replies.

Share This Page