PixelRidge-Softworks / SurvivalPlus

Change the way you think about Survival!
GNU General Public License v3.0
14 stars 11 forks source link

[Future]: Supplement for Energy Change. [ Every player should lie down anytime and will filling the energy bar. ] #7

Closed ErythroCraft closed 2 years ago

ErythroCraft commented 2 years ago

Hi

The problem is that only one person (at night) can lie down. If there more player with low energy they can not lie down. The addition is intended to allow any player to lie down day or night and replenish energy in the process.


The following function must not be influenced. [It will filling the energy bar after wakeup]. https://github.com/Pixelated-Studios/SurvivalPlus/blob/main/src/main/java/veth/vetheon/survival/listeners/player/EnergyChange.java

// Increase players energy when they wakeup after the night skips
    // Or cancel the night skip event if true in config (forcing players to lay in bed and let energy increase)
    @EventHandler
    private void onSkipNight(TimeSkipEvent event) {
        if (config.MECHANICS_PREVENT_NIGHT_SKIP) {
            if (event.getSkipReason() == TimeSkipEvent.SkipReason.NIGHT_SKIP) {
                event.setCancelled(true);
            }
        } else {
            for (Player player : event.getWorld().getPlayers()) {
                if (!player.isSleeping()) continue;
                PlayerData playerData = playerManager.getPlayerData(player);

                EnergyLevelChangeEvent energyEvent = new EnergyLevelChangeEvent(player, 20.0 - playerData.getEnergy(), 20.0);
                Bukkit.getPluginManager().callEvent(energyEvent);
                if (energyEvent.isCancelled()) return;
                playerData.setEnergy(20);
            }
        }

part of config.yml

     # Every 5 seconds a player spends in bed, the level of energy to increase
     sleeping-refresh-rate: 0.83 # Default (0.83) equivalent to 10 levels in 1 minute

Result 1:

  1. Minecraft idle time can be taken over about 10 seconds. []
  2. Multiple players can lie down at different/any time | day and night.
  3. Refresh energy after wakeup.

OR

Result 2:

  1. Multiple player can lie down and fills the energie bar at different/any time | day and night.
  2. Player can press ESC-Keyboard-Key to stand up after full energy bar.

I found an person that can do this. We ask permission to add a few lines via pull request.

VetheonGames commented 2 years ago

I don't understand the issue.

The player's energy bar is only supposed to be refilled when the night is skipped, it listens for the event. If you wish to allow the night to skip without having to have all players sleeping, I suggest installing a third-party plugin for it.

SurvivalPlus does indeed support BetterSleeping3, I'd try that.

However, if you are able to implement the new feature without disturbing the existing energy system code (the energy system is rather delicate at times) you can create a PR and I'd be happy to merge the pull request. However, please be aware that you MUST be building with the current source from github. Ensure you are up-to-date with the repo before you make any pull requests as we are presently in the process of changing out a lot of deprecations.

Edit: The feature must also be configurable and togglable in config without issue.

ErythroCraft commented 2 years ago

That means. No night skipping. All player every time a day.

Example: One player lies down and a second player lies down a little later while the first person is still lying down. 24/7 As self as sitting on chairs.

VetheonGames commented 2 years ago

If you can incorporate the feature in the way I outlined above, I'll be glad to merge the PR. But we will not make the addition because we are much more focused on updating the plugin and finishing existing features like Burn Out Torches and Shared Workbenches

ErythroCraft commented 2 years ago

He is working.

He say: JoelGodOfWar I'll add a config for enabling this, and one to set the length of time they need to lay in bed before it happens.

ErythroCraft commented 2 years ago

sry

ErythroCraft commented 2 years ago

Issue closed, becouse the programmer can not this.

He says, it appears beyond his knowledge.