Infection system

Discussion in 'Spigot Plugin Development' started by Dev222, Jul 8, 2015.

  1. Hi,

    I want to make an infection system, where player loose 1 heart per minute and has the effect notification aside of inventary (like poison) when he's attacked
    So I did this:
    Code (Text):
    @EventHandler
        public void onAttack(final EntityDamageByEntityEvent event) {
            if(event.getEntity() instanceof Player) {
                Player joueur = (Player)event.getEntity();
                if (getConfig().getString("joueurs."+joueur.getName()+".infecte") != "oui") { // If player isn't infected
                     getConfig().set("joueurs."+joueur.getName()+".infecte", "oui");
                    saveDefaultConfig();
                    // Make player infected
                }
            }
        }
    I know how to remove hearts, but I don't know how to make the player infected
    I did dome searches about custom potions but I didn't found what I want to do
    Anyone have an idea ?

    Thanks, and sorry for my english
     
  2. _Ug

    _Ug

    Schedule a repeating task for every 60 seconds to loop through every infected player that is online and remove a heart away from them? This would not add the potion effect, so sorry if they is what you were confused about, but this will do the non-visual part of the plugin.
     
  3. Thanks for reply
    I will try with the Scheduler method
    About the visual effects, I added a potion spawner and It works a charm