1
0
mirror of https://github.com/nkomarn/harbor.git synced 2024-06-29 16:24:46 +02:00

🌧 Independent weather toggles + instant skip

This commit is contained in:
Mykyta 2020-04-02 10:24:32 -07:00
parent 99d917177c
commit e8de0f35c1
No known key found for this signature in database
GPG Key ID: C147E30C19EA3570
4 changed files with 37 additions and 18 deletions

View File

@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
public class HarborCommand implements TabExecutor {
@Override
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
final String prefix = Config.getString("messages.miscellaneous.prefix");
if (args.length < 1) {
@ -53,6 +52,12 @@ public class HarborCommand implements TabExecutor {
Player player = (Player) sender;
World world = player.getWorld();
if (Checker.skippingWorlds.contains(world)) {
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix
+ "&7This world's time is already being accelerated."));
return true;
}
Checker.skippingWorlds.add(world);
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix

View File

@ -1,8 +1,10 @@
package xyz.nkomarn.Harbor.task;
import org.bukkit.Bukkit;
import org.bukkit.Statistic;
import org.bukkit.World;
import org.bukkit.scheduler.BukkitRunnable;
import xyz.nkomarn.Harbor.Harbor;
import xyz.nkomarn.Harbor.util.Config;
import xyz.nkomarn.Harbor.util.Messages;
@ -17,27 +19,27 @@ public class AccelerateNightTask extends BukkitRunnable {
public void run() {
final long time = world.getTime();
final int interval = Config.getInteger("values.interval");
final int dayTime = Config.getInteger("values.day-time");
if (!(time >= (dayTime - interval * 2) && time <= dayTime)) {
// Variable interval based on player count
if (!(time >= 450 && time <= 1000)) {
world.setTime(time + interval);
} else {
// Announce night skip and clear queue
Messages.sendRandomChatMessage(world, "messages.chat.skipped");
Checker.skippingWorlds.remove(world);
// Reset sleep statistic if phantoms are disabled
if (!Config.getBoolean("features.phantoms")) {
world.getPlayers().forEach(player ->
player.setStatistic(Statistic.TIME_SINCE_REST, 0));
}
// Clear weather
if (Config.getBoolean("features.weather")) {
if (Config.getBoolean("features.clear-rain")) {
world.setStorm(false);
}
if (Config.getBoolean("features.clear-thunder")) {
world.setThundering(false);
}
Checker.skippingWorlds.remove(world);
Messages.sendRandomChatMessage(world, "messages.chat.skipped");
this.cancel();
}
}

View File

@ -45,8 +45,12 @@ public class Checker implements Runnable {
Messages.sendActionBarMessage(world, Config.getString("messages.actionbar.everyone"));
if (!Config.getBoolean("features.skip")) return;
skippingWorlds.add(world);
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
if (Config.getBoolean("features.instant-skip")) {
world.setTime(1000);
} else {
skippingWorlds.add(world);
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
}
Messages.sendRandomChatMessage(world, "messages.chat.accelerateNight");
}
}

View File

@ -1,23 +1,28 @@
# Harbor - A Sleep Enhancement Plugin!
# An open-source project by Mykyta (TechToolbox)
# https://harbor.nkomarn.xyz
#
# Ahoy, matey! You've arrived at the configuration file, where things get a bit scary.
# Every single thing within this plugin is customizable (at least I tried to make it that way),
# so every message and plugin module can be modified here. If you would like to report a bug
# or suggest a feature, make sure to add an issue on the GitHub page for this plugin!
# GitHub URL: https://github.com/nkomarn/Harbor/issues
# Important note regarding Essentials
# Please make sure you negate the permission "essentials.sleepingignored"
# to prevent issues with Harbor and server operators
values:
timer: 2 # How often (in seconds) to run the clock task (used to detect sleep, AFK players, time actionbar, etc.)
percent: 50 # Percent of players that need to sleep to skip night (must be between 0 to 100)
interval: 60 # Time skip interval that is added when the night is accelerated.
day-time: 1000 # Time (in ticks) that Harbor considers as day
timeout: 15 # Time (in minutes) until a player is considered AFK (for internal AFK detection system only- when Essentials isn't present)
features:
skip: true # Toggle night skipping feature. Configure amount of players needed to skip above (percent)
weather: true # Clear weather when skipping night
instant-skip: false # Toggle the instant skipping of night (instead of showing the full animation). Requires "skip" to be true.
clear-rain: true # Clear rain when skipping the night
clear-thunder: true # Clear thunder when skipping the night
phantoms: false # Reset the sleep statistic (practically disables phantom spawns - false = no phantoms | Set the doInsomnia gamerule to false to disable phantoms if you're on 1.15+)
bypass: true # Toggle exclusion of operators/players with permission "harbor.bypass" from sleep count
ignore: true # Toggle exclusion of players in creative and spectator mode
@ -54,10 +59,13 @@ messages:
permission: "&7Insufficient permissions." # Sent when player doesn't have permissions to run command
unrecognized: "&7Unrecognized command." # Sent when command argument isn't recognized
blacklist: # Blacklist for worlds (Harbor will be disabled in these worlds)
# Blacklist for worlds
# Harbor will be disabled in these worlds
blacklist:
- "world_nether"
- "world_the_end"
# Spooky controls (don't change)
version: 1.6
# Spooky controls
# (don't change)
version: 1.6.2
debug: false