POTION EFFECT ON ITEM :(

Discussion in 'Plugin Development' started by ToPoEdiTs, Jul 20, 2014.

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

    ToPoEdiTs

    Hey look I'm creating a plugin such kits and the kits are already created but I want to put effects such potions example sword pasting nausias run the effect as serious or you can leave me an example would be very helpful ATT: topo
     
  2. Offline

    ZodiacTheories

    ToPoEdiTs

    I have told you multiple times:

    Listen to the EntityDamageByEntityEvent, check if the damager is a Player, check if the Players item in hand has the same meta as your custom item, then add a potion effect to the entity that was damaged
     
  3. Offline

    ToPoEdiTs

    I'll try if I get there now but it took two days and this effect and I can not go on :( fucking life

    nothing could help me with a sample code that Spoon-feeding is not helping but it took two days and this and I'm going crazy: (
    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 9, 2016
  4. Offline

    Gater12

    ToPoEdiTs

    If you really cannot make this happen, you shouldn't be programming in the first place. If you're not going to try and put some effort into solving your problem (especially with the solution right there), you're probably better off requesting a plugin to be made.
     
    L33m4n123 likes this.
  5. Offline

    stormneo7

    I know I shouldn't be spoon feeding lol. Sorry guyz.

    Code:java
    1. @EventHandler
    2. public void onDamage(EntityDamageByEntityEvent evt){
    3. // Check if the event is not cancelled.
    4. if(!(evt.isCancelled())){
    5. // Check if the Damager and the Receiver are both players.
    6. if(evt.getEntity() instanceof Player && evt.getDamager() instanceof Player){
    7. // Define the Player and the Reciever
    8. final Player p = (Player) evt.getEntity();
    9. final Player d = (Player) evt.getDamager();
    10. // Check for the damager's item in hand to match with your "Special Sword".
    11. // In this case, the damager will have a [Diamond Sword] named [ChatColor.RED + "Poison Sword"]
    12. if(d.getItemInHand() != null && d.getItemInHand().getType() == Material.DIAMOND_SWORD
    13. && d.getItemInHand().hasItemMeta() && d.getItemInHand().getItemMeta().hasDisplayName()
    14. && d.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.RED + "Poison Sword")){
    15. // Gives The Reciever The Poison Effect
    16. int PoisonMultiplier = 0; // This is the level of the poison. Remember, Java starts at 0. Level 1 poison = 0.
    17. int PoisonDuration = 3; // This is the duration of the poison in seconds.
    18. p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, PoisonDuration * 20, PoisonMultiplier));
    19. }
    20. }
    21. }
    22. }
     
    ToPoEdiTs likes this.
  6. Offline

    ToPoEdiTs

    thank you very much bro <3 really but already xD and found there a way to add permissions so you can only use that some people with a:
    if (player.hasPermission ("player.effect")) {

    then hit with a sword when someone runs the effect that no?

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

    ChipDev

    Code:java
    1. @EventHandler
    2. public void onDamage(EntityDamageByEntityEvent evt){
    3. // Check if the event is not cancelled.
    4. if(!(evt.isCancelled())){
    5. // Check if the Damager and the Receiver are both players.
    6. if(evt.getEntity() instanceof Player && evt.getDamager() instanceof Player){
    7. // Define the Player and the Reciever
    8. final Player p = (Player) evt.getEntity();
    9. final Player d = (Player) evt.getDamager();
    10. // Check for the damager's item in hand to match with your "Special Sword".
    11. // In this case, the damager will have a [Diamond Sword] named [ChatColor.RED + "Poison Sword"]
    12. if(d.getItemInHand() != null && d.getItemInHand().getType() == Material.DIAMOND_SWORD
    13. && d.getItemInHand().hasItemMeta() && d.getItemInHand().getItemMeta().hasDisplayName()
    14. && d.getItemInHand().getItemMeta().getDisplayName().equals(ChatColor.RED + "Poison Sword")){
    15. //PERMS! =D
    16. if(d.hasPermission(PosionSword.TRUE)) {
    17. // Gives The Reciever The Poison Effect
    18. int PoisonMultiplier = 0; // This is the level of the poison. Remember, Java starts at 0. Level 1 poison = 0.
    19. int PoisonDuration = 3; // This is the duration of the poison in seconds.
    20. p.addPotionEffect(new PotionEffect(PotionEffectType.POISON, PoisonDuration * 20, PoisonMultiplier));
    21. }
    22. }
    23. }
    24. }
    thx :pc stormneo7
     
  8. Offline

    ToPoEdiTs

    i do not understand that because I will get error http://gyazo.com/e0423e819b4d2d26e8ab1d62bb475e87
     
  9. Offline

    ChipDev

  10. Offline

    ZodiacTheories

  11. Offline

    Regablith

Thread Status:
Not open for further replies.

Share This Page