mirror of
https://github.com/nkomarn/harbor.git
synced 2025-01-22 23:41:31 +01:00
🌧 Independent weather toggles + instant skip
This commit is contained in:
parent
99d917177c
commit
e8de0f35c1
@ -22,7 +22,6 @@ import java.util.concurrent.ExecutionException;
|
|||||||
public class HarborCommand implements TabExecutor {
|
public class HarborCommand implements TabExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
|
|
||||||
final String prefix = Config.getString("messages.miscellaneous.prefix");
|
final String prefix = Config.getString("messages.miscellaneous.prefix");
|
||||||
|
|
||||||
if (args.length < 1) {
|
if (args.length < 1) {
|
||||||
@ -53,6 +52,12 @@ public class HarborCommand implements TabExecutor {
|
|||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
World world = player.getWorld();
|
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);
|
Checker.skippingWorlds.add(world);
|
||||||
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
|
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
|
||||||
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix
|
sender.sendMessage(ChatColor.translateAlternateColorCodes('&', prefix
|
||||||
|
@ -1,8 +1,10 @@
|
|||||||
package xyz.nkomarn.Harbor.task;
|
package xyz.nkomarn.Harbor.task;
|
||||||
|
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.Statistic;
|
import org.bukkit.Statistic;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.scheduler.BukkitRunnable;
|
import org.bukkit.scheduler.BukkitRunnable;
|
||||||
|
import xyz.nkomarn.Harbor.Harbor;
|
||||||
import xyz.nkomarn.Harbor.util.Config;
|
import xyz.nkomarn.Harbor.util.Config;
|
||||||
import xyz.nkomarn.Harbor.util.Messages;
|
import xyz.nkomarn.Harbor.util.Messages;
|
||||||
|
|
||||||
@ -17,27 +19,27 @@ public class AccelerateNightTask extends BukkitRunnable {
|
|||||||
public void run() {
|
public void run() {
|
||||||
final long time = world.getTime();
|
final long time = world.getTime();
|
||||||
final int interval = Config.getInteger("values.interval");
|
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);
|
world.setTime(time + interval);
|
||||||
} else {
|
} 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")) {
|
if (!Config.getBoolean("features.phantoms")) {
|
||||||
world.getPlayers().forEach(player ->
|
world.getPlayers().forEach(player ->
|
||||||
player.setStatistic(Statistic.TIME_SINCE_REST, 0));
|
player.setStatistic(Statistic.TIME_SINCE_REST, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Clear weather
|
if (Config.getBoolean("features.clear-rain")) {
|
||||||
if (Config.getBoolean("features.weather")) {
|
|
||||||
world.setStorm(false);
|
world.setStorm(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Config.getBoolean("features.clear-thunder")) {
|
||||||
world.setThundering(false);
|
world.setThundering(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Checker.skippingWorlds.remove(world);
|
||||||
|
Messages.sendRandomChatMessage(world, "messages.chat.skipped");
|
||||||
this.cancel();
|
this.cancel();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,8 +45,12 @@ public class Checker implements Runnable {
|
|||||||
Messages.sendActionBarMessage(world, Config.getString("messages.actionbar.everyone"));
|
Messages.sendActionBarMessage(world, Config.getString("messages.actionbar.everyone"));
|
||||||
|
|
||||||
if (!Config.getBoolean("features.skip")) return;
|
if (!Config.getBoolean("features.skip")) return;
|
||||||
|
if (Config.getBoolean("features.instant-skip")) {
|
||||||
|
world.setTime(1000);
|
||||||
|
} else {
|
||||||
skippingWorlds.add(world);
|
skippingWorlds.add(world);
|
||||||
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
|
new AccelerateNightTask(world).runTaskTimer(Harbor.instance, 0L, 1);
|
||||||
|
}
|
||||||
Messages.sendRandomChatMessage(world, "messages.chat.accelerateNight");
|
Messages.sendRandomChatMessage(world, "messages.chat.accelerateNight");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,28 @@
|
|||||||
# Harbor - A Sleep Enhancement Plugin!
|
# Harbor - A Sleep Enhancement Plugin!
|
||||||
# An open-source project by Mykyta (TechToolbox)
|
# An open-source project by Mykyta (TechToolbox)
|
||||||
# https://harbor.nkomarn.xyz
|
# https://harbor.nkomarn.xyz
|
||||||
#
|
|
||||||
# Ahoy, matey! You've arrived at the configuration file, where things get a bit scary.
|
# 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),
|
# 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
|
# 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!
|
# 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
|
# 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:
|
values:
|
||||||
timer: 2 # How often (in seconds) to run the clock task (used to detect sleep, AFK players, time actionbar, etc.)
|
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)
|
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.
|
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)
|
timeout: 15 # Time (in minutes) until a player is considered AFK (for internal AFK detection system only- when Essentials isn't present)
|
||||||
|
|
||||||
features:
|
features:
|
||||||
skip: true # Toggle night skipping feature. Configure amount of players needed to skip above (percent)
|
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+)
|
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
|
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
|
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
|
permission: "&7Insufficient permissions." # Sent when player doesn't have permissions to run command
|
||||||
unrecognized: "&7Unrecognized command." # Sent when command argument isn't recognized
|
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_nether"
|
||||||
- "world_the_end"
|
- "world_the_end"
|
||||||
|
|
||||||
# Spooky controls (don't change)
|
# Spooky controls
|
||||||
version: 1.6
|
# (don't change)
|
||||||
|
version: 1.6.2
|
||||||
debug: false
|
debug: false
|
||||||
|
Loading…
Reference in New Issue
Block a user