Potion Effects on swords?

Discussion in 'Plugin Development' started by Chibbey, Jan 5, 2014.

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

    Chibbey

    Hello, So I am making a more advanced kitpvp plugin and Im going to have a kit called toxic that when you get hit by its sword, you get poisoned. So on play.redwardare.com(Search and destroy) they have a kit called Venom with poison on it. Only thing is poison is an effect and not an enchantment. So how did they do this? Is it just a lore and they have it so when you get hit by the sword you get poisoned? I think its a lore and they use a playerinteractevent/entitydamagebyentity and check if its that sword then poisons the hit player. Help me please. Or just tell me if im right with the lore and stuff.
     
  2. Offline

    bigteddy98

    You could use something like this example, untested, should work:

    Code:java
    1. @EventHandler
    2. public void onPlayerSprint(EntityDamageByEntityEvent event) {
    3. if (!(event.getDamager() instanceof Player) || (!(event.getEntity() instanceof Player))) {
    4. return;
    5. }
    6. Player p = (Player) event.getDamager();
    7. // for example, put it on all diamond swords, you could at a name filter
    8. if (p.getItemInHand() != null && p.getItemInHand().getType() == Material.DIAMOND_SWORD) {
    9. Player target = (Player) event.getEntity();
    10. target.addPotionEffect(new PotionEffect(PotionEffectType.POISON, 3 * 20, 1));
    11. }
    12. }
     
Thread Status:
Not open for further replies.

Share This Page