Sunlight Damage

Discussion in 'Spigot Help' started by Realwinslow, May 20, 2015.

  1. I am looking for a server plugin that does damage to players during the day when in the sunlight. Does something like this already exist? If not how would I make something like this to run on my server. Thanks.
     
  2. Would this be a paid project or no?
     
  3. Cldfire

    Cldfire Retired Moderator
    Retired

    He wasn't asking to hire someone, lol.
     
  4. joehot200

    Supporter

    It would be fairly simple code, something like this:

    Code (Java):

    //Set up a delayed task to run every second
    getServer().getScheduler().scheduleSyncRepeatingTask(this,
                    new Runnable() {
                     
                        @Override
                        public void run() {
                            //Replace onlinePlayers with something that gets online players.
                            //For example: delete onlinePlayers and set it to Bukkit.getServer().getOnlinePlayers()
                            for (Player p : onlinePlayers){
                                //Remember different players can be in different worlds!
                                World w = p.getWorld();
                                if (w.getTime() > 0 && w.getTime() < 12000){
                                    //Players have 20 health. This damages the player for half a heart.
                                    p.damage(1);
                                }
                            }
                        }
                    }, 0, 20); //The 20 means 20 ticks. 20 ticks = 1 second.
     
     
  5. Solar Apocalypse does this.
     
  6. Thanks for the responses. I'll look into what solar has or code my own.