Skip to content

Commit

Permalink
Merge pull request #293 from Nuytemans-Dieter/v4.0.2
Browse files Browse the repository at this point in the history
V4.0.2
  • Loading branch information
Nuytemans-Dieter authored Jul 10, 2022
2 parents 664c575 + 8c51494 commit 0ebf979
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 47 deletions.
5 changes: 4 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ Quite extensive configuration is included to suit your needs. The configuration
- ... And **so much more**! Check the [wiki](https://github.com/Nuytemans-Dieter/BetterSleeping/wiki) to see all options.

## Tested Spigot versions
This plugin is functional and has been tested on several Spigot versions. Bukkit should be compatible too but no extensive testing has been done. You can see the **latest** and **tested** BetterSleeping version for every supported Spigot version in the table below. Newer updates than the mentioned BetterSleeping versions may still be fully compatible but have not been tested (yet). Previous versions of BetterSleeping can be found under [Releases](https://github.com/Nuytemans-Dieter/BetterSleeping/releases).
This plugin is functional and has been tested on several Spigot versions. Bukkit should be compatible too but no extensive testing has been done.
You can see the **latest** and **tested** BetterSleeping version for every supported Spigot version in the table below.
Newer updates than the mentioned BetterSleeping versions will probably be fully compatible but have not been tested (yet).
Previous versions of BetterSleeping can be found under [Releases](https://github.com/Nuytemans-Dieter/BetterSleeping/releases).

| Spigot | BetterSleeping |
| :----: | :------------: |
Expand Down
Binary file modified lib/GSit.jar
Binary file not shown.
13 changes: 9 additions & 4 deletions lib/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ Libraries in this folder are solely used as dependencies to ensure compatibility
For each file, an official download location can be found in the table below.

If you are the owner of any library in this folder and want your artifact removed, give me a notice through an issue and I will remove them at once.
Keep in mind that support for your plugin may be dropped, until it can be included as a Maven dependency to keep cloning the project simple.
Keep in mind that support for your plugin may be dropped until it can be included as a Maven dependency, to keep cloning the project simple.

| Library | Download location |
| ------- | ----------------- |
| GSit.jar| [Spigot](https://www.spigotmc.org/resources/gsit-sit-on-nice-seats-and-chairs-or-lay-down-wherever-you-want-1-13-x-1-16-x.62325/) |
# For server admins

The mentioned version is the latest version that definitely works with the newest BetterSleeping version.
Newer versions may work fine as well, but this is not guaranteed and depends on breaking changes on their end.

| Library | Version | Download location |
| ------- | ------- | ----------------- |
| GSit.jar| 1.0.5 | [Spigot](https://www.spigotmc.org/resources/gsit-sit-on-nice-seats-and-chairs-or-lay-down-wherever-you-want-1-13-x-1-16-x.62325/) |
4 changes: 2 additions & 2 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>be.betterplugins.bettersleeping</groupId>
<artifactId>bettersleeping</artifactId>
<version>4.0.1</version>
<version>4.0.2</version>

<properties>
<maven.compiler.target>1.8</maven.compiler.target>
Expand Down Expand Up @@ -81,7 +81,7 @@
<dependency>
<groupId>com.github.BetterPluginsSpigot</groupId>
<artifactId>betteryaml</artifactId>
<version>1.1.0</version>
<version>1.1.1</version>
</dependency>

<!-- ESSENTIALS -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,19 +25,16 @@
import org.bukkit.ChatColor;
import org.bukkit.event.HandlerList;
import org.bukkit.event.Listener;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.java.JavaPluginLoader;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.logging.Level;

public class BetterSleeping extends JavaPlugin implements IReloadable
{

private final static Level logLevel = Level.CONFIG;
private static Level logLevel = Level.WARNING;

private BPLogger logger;
private SleepWorldManager sleepWorldManager;
Expand Down Expand Up @@ -82,6 +79,10 @@ private void startPlugin()

// Get all configuration
ConfigContainer config = injector.getInstance(ConfigContainer.class);
String logLevelSetting = config.getConfig().getString("logging_level", "Default");
logLevel = logLevelSetting.equalsIgnoreCase("Default") ? Level.WARNING :
logLevelSetting.equalsIgnoreCase("Config") ? Level.CONFIG :
logLevelSetting.equalsIgnoreCase("All") ? Level.ALL : Level.WARNING;

// Capture the state of all worlds
this.worldStateHandler = injector.getInstance( WorldStateHandler.class );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import be.betterplugins.bettersleeping.model.sleeping.SleepWorldManager;
import be.betterplugins.bettersleeping.util.TimeUtil;
import com.google.inject.Inject;
import me.gsit.api.events.PlayerGetUpPoseEvent;
import me.gsit.api.events.PlayerPoseEvent;
import dev.geco.gsit.api.event.PlayerGetUpPoseEvent;
import dev.geco.gsit.api.event.PlayerPoseEvent;
import org.bukkit.World;
import org.bukkit.entity.Player;
import org.bukkit.entity.Pose;
Expand Down Expand Up @@ -40,7 +40,7 @@ public void onPlayerLay (PlayerPoseEvent layOrCrawlEvent)
return;
}

if (layOrCrawlEvent.getPose() == Pose.SLEEPING)
if (layOrCrawlEvent.getPoseSeat().getPose() == Pose.SLEEPING)
{
sleepWorldManager.addSleeper(player);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,41 +31,44 @@ public class ConfigContainer
public ConfigContainer(JavaPlugin plugin, BPLogger logger)
{
ValidationHandler configValidation = new ValidationHandler()
.addValidator("language", new StringWhiteList
(
"en-US",
true,
"de-DE", "en-US", "es-ES", "fr-FR", "it-IT", "ja-JP", "nl-BE", "pt-PT", "ru-RU", "silent", "zh-CN", "zh-HK", "zh-TW")
);
.addValidator("language", new StringWhiteList
(
"en-US",
true,
"de-DE", "en-US", "es-ES", "fr-FR", "it-IT", "ja-JP", "nl-BE", "pt-PT", "ru-RU", "silent", "zh-CN", "zh-HK", "zh-TW")
)
.addValidator(
"logging_level", new StringWhiteList("Default", true, "Default", "Config", "All")
);

ValidationHandler buffsValidation = new ValidationHandler()
.addOptionalSection("sleeper_buffs")
.setOptionalValue("sleeper_buffs.speed.time", 20)
.setOptionalValue("sleeper_buffs.speed.level", 1)
.addOptionalSection("non_sleeper_debuffs")
.setOptionalValue("non_sleeper_debuffs.slow.time", 3)
.setOptionalValue("non_sleeper_debuffs.slow.level", 1)
.addOptionalSection("sleeper_commands")
.addOptionalSection("non_sleeper_commands");
.addOptionalSection("sleeper_buffs")
.setOptionalValue("sleeper_buffs.speed.time", 20)
.setOptionalValue("sleeper_buffs.speed.level", 1)
.addOptionalSection("non_sleeper_debuffs")
.setOptionalValue("non_sleeper_debuffs.slow.time", 3)
.setOptionalValue("non_sleeper_debuffs.slow.level", 1)
.addOptionalSection("sleeper_commands")
.addOptionalSection("non_sleeper_commands");

ValidationHandler hooksValidation = new ValidationHandler()
.addValidator("minimum_afk_time", new Min(-1));

ValidationHandler sleeping_settingsValidation = new ValidationHandler()
.addValidator("sleeper_counter", new ChainedValidator(
new StringWhiteList("percentage", true, "percentage", "absolute"),
new ToLowerCase()
))
.addValidator("needed", new Min(0))
.addValidator("night_skip_length", new Min(0))
.addValidator("day_length", new Min(0))
.addValidator("night_length", new Min(0))
.addValidator("bed_enter_cooldown", new Min(0))
.addOptionalSection("world_settings")
.setOptionalValue("world_settings.worldname.enabled", true)
.setOptionalValue("world_settings.worldname.day_length", 700)
.setOptionalValue("world_settings.worldname.night_length", 500)
.setOptionalValue("world_settings.worldname.night_skip_length", 10);
.addValidator("sleeper_calculator", new ChainedValidator(
new StringWhiteList("percentage", true, "percentage", "absolute"),
new ToLowerCase()
))
.addValidator("needed", new Min(0))
.addValidator("night_skip_length", new Min(0))
.addValidator("day_length", new Min(0))
.addValidator("night_length", new Min(0))
.addValidator("bed_enter_cooldown", new Min(0))
.addOptionalSection("world_settings")
.setOptionalValue("world_settings.worldname.enabled", true)
.setOptionalValue("world_settings.worldname.day_length", 700)
.setOptionalValue("world_settings.worldname.night_length", 500)
.setOptionalValue("world_settings.worldname.night_skip_length", 10);

OptionalBetterYaml configBY = new OptionalBetterYaml("config.yml", configValidation, plugin, true);
OptionalBetterYaml buffsBY = new OptionalBetterYaml("buffs.yml", buffsValidation, plugin, true);
Expand Down
1 change: 1 addition & 0 deletions src/main/resources/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ enable_bossbar: true
update_notifier: true
disable_phantoms: false
enable_animations: true
logging_level: "Default"
save_logs: false
6 changes: 3 additions & 3 deletions src/main/resources/lang/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ Most of these are created by other server owners that are using BetterSleeping.
| Language | Code | Credits |
| :-------: | :---: | :-----: |
| English | en-US | |
| Chinese (Hong Kong Cantonese) | zh-HK | |
| Chinese (Simplified) | zh-CN | |
| Chinese (Traditional) | zh-TW | |
| Chinese (Hong Kong Cantonese)| zh-HK ||
| Chinese (Simplified)| zh-CN ||
| Chinese (Taiwan) | zh-TW | |
| Dutch | nl-BE | |
| French | fr-FR | lucas-luchack |
| German | de-DE | |
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/sleeping_settings.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
sleeper_counter: "percentage"
sleeper_calculator: "percentage"
needed: 30
night_skip_length: 10
day_length: 700
Expand Down
4 changes: 4 additions & 0 deletions src/main/resources/templates/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,9 @@ disable_phantoms: {disable_phantoms}
# These are precomputed to save on processing time
enable_animations: {enable_animations}

# Determines which messages are logged to the console, the settings are:
# Default (shows warnings only), config (shows info when reading your configuration), all (shows all logs ~ will spam your console, great for debugging)
logging_level: {logging_level}

# Whether you want to save BetterSleeping output to log files
save_logs: {save_logs}
2 changes: 1 addition & 1 deletion src/main/resources/templates/sleeping_settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
# Choose an option from below (percentage or absolute)
# With percentage, a relative amount of players needs to sleep (eg. needed: 30 -> 13 online players, 30% of 13 is 3,9. Will be rounded to the nearest number -> 4 sleeping players needed)
# With absolute, a static amount of players needs to sleep (eg. needed: 2 -> any amount of online players, 2 players need to sleep)
sleeper_calculator: {sleeper_counter}
sleeper_calculator: {sleeper_calculator}

# This depends on your sleeper_calculator setting
# Percentage: This value is the percentage of players in a world that must sleep ([0, 100])
Expand Down

0 comments on commit 0ebf979

Please sign in to comment.