BedHospital - Regenerate when sleep -

Discussion in 'Archived: Plugin Requests' started by Lummox, Apr 4, 2013.

  1. Description:
    I need a plugin to heal players if they spend a certain time in bed.

    Name of plugin:
    BedHospital

    Permissions:
    - bedhospital.instant
    # Anyone who has this permission, regenerates instantly, without waiting in bed.

    Configuration:
    Code:
    Regenerate each: 30
    # Specified in seconds
    Regenerate Health: 5
    # The complete health is 20
     
    Message to get into bed: Your health will regenerate gradually.
    Message to get out of bed: Your health is regenerated in {%} points.
    # {%} Represents health has recovered, for example, "Your health is regenerated by 5 points" if you spent 30 seconds in bed.
    Is required special addition in the configuration, to select whether time passes or not when sleep:
    Code:
    Change the time when everyone is asleep: <true> / <false>
    #  If in <false> though everyone is asleep in bed, time does not pass, continues to be night.
    Refrain from recommending the plugin "BedHealth" has bugs that can not solve their author.

    Greetings ;)
     
  2. Offline

    Deleted user

    Can try to do this!

    BUT not the config! it will give regeneration potion when asleep!

    can add the permission so only if you have permission it will work!

    Please PM me if you want it

    Oh Scratch that i'm doing it anyway! I will give you credit for the idea

    My verison will be different form what you want but it SHOULD be ok for you

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  3. Offline

    chasechocolate

    AWITFC player.setHealth(player.getHealth() + this.getConfig().getInt("regenerate"))?
     
  4. Online

    timtower Administrator Administrator Moderator

    AWITFC The code that chasechocolate shows makes much more sense, if you don't do it like that players are likely to go into the bed, exit the bed with the potion effect still on them
     
  5. Offline

    Deleted user

    Yeah Thanks I will start coding this now! Thank you @chasechocolate

    Ok im confused
    Code:
    import org.bukkit.ChatColor;
    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
     
    public class Main extends JavaPlugin {
       
        public void onEnable(){
            getLogger().info("Developed by AWITFC");
            getLogger().info("If you had to pay for this plugin");
            getLogger().info("Please contact AWITFC on BukkitDev");
            saveDefaultConfig();
            getServer().getPluginManager().registerEvents(new Listener(){
              @EventHandler
              public void playerJoin(PlayerJoinEvent event){
                    if (event.getPlayer().isSleeping()){
                        event.getPlayer().setHealth(event.getPlayer().getHealth() + getConfig().getInt("Regeneration Level"));
                        event.getPlayer().sendMessage(ChatColor.RED +  "[BedHospital] You are now in hospital!");
                    }
                }
            }
            , this);
            FileConfiguration config = getConfig();
            if (!config.getBoolean("Plugin Enabled", false))
            {
              getPluginLoader().disablePlugin(this);
            }
            saveConfig();
          }
        }
    Doesn't Work?? it Doesn't recognise when the player is in bed?

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  6. Online

    timtower Administrator Administrator Moderator

    AWITFC You have an function inside a function...
     
    devilquak likes this.
  7. Offline

    Deleted user

    ? srry Im not the best on listners

    Nearly Done!!! Xd thanks for all your help guys! :)

    will upload to bukkit dev later I gtg now

    Lummox
    http://dev.bukkit.org/server-mods/bedhospital/

    Not Approved by Mods yet but it will be soon!

    Please take time to check out my other plugins please
    http://www.awitfc.eu

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  8. Online

    timtower Administrator Administrator Moderator

  9. Offline

    Deleted user

  10. Thank you so much!, Wanting to try this now.

    Were you able to configure everything?, I mean, includes all these options in the configuration?:

    Code:
    Regenerate each: 30
    # Specified in seconds
    Regenerate Health: 5
    # The complete health is 20
     
    Message to get into bed: Your health will regenerate gradually.
    Message to get out of bed: Your health is regenerated in {%} points.
    # {%} Represents health has recovered, for example, "Your health is regenerated by 5 points" if you spent 30 seconds in bed.
     
    Change the time when everyone is asleep: <true> / <false>
    #  If in <false> though everyone is asleep in bed, time does not pass, continues to be night.
    By the way, in "BukkitDev" nickname "Q2Lummox" ... if you can change that ... : P
     
  11. Offline

    Deleted user

    Hi and no there isn't a config YET. I am working on a project for my server at the moment and cant ocde tomorrow but VERY soon I will have a config! I am not sure if I can make the health go gradually and the time will change anyway there is nothing I can do about that I don't fink. B ut I can add the regeneration level and I can give it so if people have a certain permmison node they only regenerate then! oh and I can add it so you can disable the plugin! and yes I change your bukkit dev name on the project now!
     

  12. Started this but don't have time to finish it atm, you might be able to use it.

    Code:
    public class BedHospital extends JavaPlugin implements Listener {
     
    private static HashMap<String, Boolean> isRegening = new HashMap<String, Boolean>();
     
    @Override
    public void onEnable() {
    getServer().getPluginManager().registerEvents(this, this);
    getConfig().options().copyDefaults(true);
    saveConfig();
    }
     
    @Override
    public void onDisable() {
     
    }
     
    @EventHandler
    public void onPlayerEnterBed(PlayerBedEnterEvent e) {
    String enterBedMessage = getConfig().getString("enterbedmessage");
    Player p = e.getPlayer();
    p.sendMessage(enterBedMessage);
    startRegen(p);
    isRegening.put(p.getName(), true);
    }
     
    @EventHandler
    public void onPlayerLeaveBed(PlayerBedLeaveEvent e) {
     
    String enterBedMessage = getConfig().getString("leavebedmessage");
    Player p = e.getPlayer();
    p.sendMessage(enterBedMessage);
    if(isRegening.containsKey(p.getName())) {
    isRegening.remove(p.getName());
    }
    }
     
    public void startRegen(final Player p) {
    int time = getConfig().getInt("regen-each");
    final int amount = getConfig().getInt("amount-per-regen");
    getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable() {
    public void run() {
       if(isRegening.containsKey(p.getName())) {
       p.setHealth(p.getHealth() + amount);
       }
    }
    }, time*20L);
       if(isRegening.containsKey(p.getName())) {
       startRegen(p);
       }
    }
     
    }
    
     
  13. The page of bukkit dev say this:

    This project has an abnormal status: Changes required.
    The description needs more information, you need to make it clear how to use the plugin. Be sure you include information on intended use/functionality, commands, permissions, etc.

    :(

    Please, can you fix this? and.... can you take the code of Cupcakes69 and add in the plugin?.

    Thank you ;)
     
  14. Offline

    martian3333

    I see there was a lot of work done on this, but couldn't you use BedHealth?
     
  15. How I say on my first post:

    This plugin have a several bugs, and does not work well. (As you can see on page "dev.bukkit" I am Tester of the plugin ;))
     
  16. Offline

    Deleted user

    Lummox Fixed the project page (fingers crossed) and resubmitted it! it should be up by tonight!
     
  17. Offline

    CeramicTitan

    Can I just make this? I'll have it done in 10 minutes with a full config and everything.
     
  18. Offline

    Deleted user

    I made it! its just waiting to be approved
     
  19. Offline

    CeramicTitan

    But it has no config :/
     
  20. The bukkit dev page, say this :'( :

    This project has no files!
    Please check out our Getting started guide for more information on project management.
    Please note that your project will not syndicate until your project has at least one beta or release file and has been approved by a moderator.
     
  21. Offline

    Deleted user

    Last edited by a moderator: May 31, 2016
  22. The plugin seems to work but ... but lacks many features to look like the plugin ask.

    I need:

    1) Ability to configure the amount of healing every X seconds (ability to configure, every few seconds regenerates health and how much health regenerates each time).

    2) A message when you get in bed, and another when you go (to tell you how much health you have recovered)

    3) And very importantly, that day is not made when using the bed, even when all players use the bed, not over time.
     
  23. Offline

    StaticE

    Lummox Not sure if you're happy with the version AWITFC made, but I think I could make a more customizable version with the features you want. Lemme know :)
     
  24. I would really appreciate it if you try, at least ... I need that the "plugin" have the options I have said in my previous post.

    I await your response.

    Thanks in advance;)
     
  25. Offline

    StaticE

    Lummox Ok, seems easy enough. I'll start working on it tomorrow and it should be finished by the end of the day :) If anyone else can finish it faster, by all means go ahead.
     
  26. Very thank you!, I can not wait to try it ...
     
  27. Offline

    Deleted user

    SE Plugins Lummox Hi yeah I have NO IDEA how to make it so it doesn't turn it day! do be honest I don't fin that is possible! I have a message when you get into bed and I will add it so you can change the hearts it heals!

    Lol sorry my plugin was rubbish :(

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 31, 2016
  28. Your plugin is not rubbish, the only thing is that it is a bit "simple". Not meets the needs I want.

    But I greatly appreciate your taking your time to do it.

    Greetings ;)
     
  29. Offline

    Deleted user

    :) Thanks I really will try to make it better
     
  30. Offline

    shadowlif

    Okay...
    Sorry i have school and friends, i create plugins for fun...
    Bedhealth v1.6.2 is out. See PM
     

Share This Page