From 67dcc5147dca2d4ed786e40194e53146ad769d67 Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 14 Aug 2024 09:17:50 -0300 Subject: [PATCH 1/7] Add remaining time of day/night to the boss bar --- pom.xml | 4 +- .../daynightpvp/commands/DnpCommand.java | 6 +- .../subcommands/AddWorldSubCommand.java | 9 ++- .../subcommands/DelWorldSubCommand.java | 6 +- .../callv2/daynightpvp/files/ConfigFile.java | 6 +- .../placeholder/PvpStatusPlaceholder.java | 18 +++-- .../daynightpvp/runnables/AutomaticPvp.java | 4 +- .../runnables/CustomTimeDuration.java | 3 +- .../runnables/RemainingTimeBossBar.java | 78 +++++++++++++++++++ .../runnables/RunnableHandler.java | 53 +++++++++---- src/main/resources/config.yml | 6 +- 11 files changed, 158 insertions(+), 35 deletions(-) create mode 100644 src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java diff --git a/pom.xml b/pom.xml index 57039ee..2d88243 100644 --- a/pom.xml +++ b/pom.xml @@ -7,11 +7,11 @@ org.callv2 DayNightPvP DayNightPvP - 1.2.6.5 + 1.2.7.0 jar UTF-8 - 1.8 + 17 org.callv2.daynightpvp ${project.name} ${project.groupId}.daynightpvp.DayNightPvP diff --git a/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java b/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java index 0ce10f9..dd0c607 100644 --- a/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java +++ b/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java @@ -38,8 +38,8 @@ public DnpCommand(LangFile langFile, ConfigFile configFile, RunnableHandler runn private void registerSubCommands() { subCommands.put("reload", new ReloadSubCommand(langFile, new PluginServices(loseMoneyOnDeath, runnableHandler))); - subCommands.put("addworld", new AddWorldSubCommand(langFile, configFile)); - subCommands.put("delworld", new DelWorldSubCommand(langFile, configFile)); + subCommands.put("addworld", new AddWorldSubCommand(langFile, configFile, new PluginServices(loseMoneyOnDeath, runnableHandler))); + subCommands.put("delworld", new DelWorldSubCommand(langFile, configFile, new PluginServices(loseMoneyOnDeath, runnableHandler))); } @Override @@ -52,6 +52,8 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command PlayerUtils.sendMessage(sender,""); PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp §8-> §7Show all available commands."); PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp reload §8-> §7Reload the plugin."); + PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp addworld §8-> §7Adds a world to the configuration file."); + PlayerUtils.sendMessage(sender,"§7§l* §7/§9dnp delworld §8-> §7Deletes a world from the configuration file."); return true; } diff --git a/src/main/java/org/callv2/daynightpvp/commands/subcommands/AddWorldSubCommand.java b/src/main/java/org/callv2/daynightpvp/commands/subcommands/AddWorldSubCommand.java index 3fb21b0..4ae7a5a 100644 --- a/src/main/java/org/callv2/daynightpvp/commands/subcommands/AddWorldSubCommand.java +++ b/src/main/java/org/callv2/daynightpvp/commands/subcommands/AddWorldSubCommand.java @@ -7,6 +7,7 @@ import org.callv2.daynightpvp.commands.ISubCommand; import org.callv2.daynightpvp.files.ConfigFile; import org.callv2.daynightpvp.files.LangFile; +import org.callv2.daynightpvp.services.PluginServices; import java.util.ArrayList; import java.util.List; @@ -15,10 +16,12 @@ public class AddWorldSubCommand implements ISubCommand { private final LangFile langFile; private final ConfigFile configFile; + private final PluginServices pluginServices; - public AddWorldSubCommand(LangFile langFile, ConfigFile configFile) { + public AddWorldSubCommand(LangFile langFile, ConfigFile configFile, PluginServices pluginServices) { this.langFile = langFile; this.configFile = configFile; + this.pluginServices = pluginServices; } @Override @@ -27,6 +30,7 @@ public void executeCommand(CommandSender sender, Command cmd, String commandLabe if (Bukkit.getWorlds().contains(Bukkit.getWorld(args[1]))) { if (!configFile.contains("worlds." + args[1])) { addWorldToConfig(args[1]); + pluginServices.reloadPlugin(); sender.sendMessage(langFile.getFeedbackAddedWorld().replace("{0}", args[1])); return; } @@ -44,7 +48,7 @@ public List tabComplete(CommandSender sender, Command command, String al List suggestions = new ArrayList<>(); if (args.size() == 1) { - String prefix = args.get(0).toLowerCase(); // Obtenha o prefixo digitado + String prefix = args.get(0).toLowerCase(); for (World world : Bukkit.getWorlds()) { if (World.Environment.NORMAL == world.getEnvironment()) { String worldName = world.getName().toLowerCase(); @@ -63,6 +67,7 @@ private void addWorldToConfig(String worldName) { configFile.setValue("worlds." + worldName + ".day-night-duration.night-duration", 600); configFile.setValue("worlds." + worldName + ".automatic-pvp.enabled", true); configFile.setValue("worlds." + worldName + ".automatic-pvp.day-end", 12000); + configFile.setValue("worlds." + worldName + ".boss-bar.time-remaining", false); configFile.setValue("worlds." + worldName + ".automatic-difficulty.enabled", false); configFile.setValue("worlds." + worldName + ".automatic-difficulty.day", "NORMAL"); configFile.setValue("worlds." + worldName + ".automatic-difficulty.night", "HARD"); diff --git a/src/main/java/org/callv2/daynightpvp/commands/subcommands/DelWorldSubCommand.java b/src/main/java/org/callv2/daynightpvp/commands/subcommands/DelWorldSubCommand.java index 41976a8..eafd57e 100644 --- a/src/main/java/org/callv2/daynightpvp/commands/subcommands/DelWorldSubCommand.java +++ b/src/main/java/org/callv2/daynightpvp/commands/subcommands/DelWorldSubCommand.java @@ -5,6 +5,7 @@ import org.callv2.daynightpvp.commands.ISubCommand; import org.callv2.daynightpvp.files.ConfigFile; import org.callv2.daynightpvp.files.LangFile; +import org.callv2.daynightpvp.services.PluginServices; import java.util.ArrayList; import java.util.List; @@ -13,10 +14,12 @@ public class DelWorldSubCommand implements ISubCommand { private final LangFile langFile; private final ConfigFile configFile; + private final PluginServices pluginServices; - public DelWorldSubCommand(LangFile langFile, ConfigFile configFile) { + public DelWorldSubCommand(LangFile langFile, ConfigFile configFile, PluginServices pluginServices) { this.langFile = langFile; this.configFile = configFile; + this.pluginServices = pluginServices; } @Override @@ -24,6 +27,7 @@ public void executeCommand(CommandSender sender, Command cmd, String commandLabe if (args.length == 2) { if (configFile.contains("worlds." + args[1])) { removeWorldFromConfig(args[1]); + pluginServices.reloadPlugin(); sender.sendMessage(langFile.getFeedbackDeletedWorld().replace("{0}", args[1])); return; } diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index a5379a9..c7bec45 100644 --- a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java @@ -29,7 +29,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 18; + int latestFileVersion = 19; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml.old"); if (outdatedFile.exists()) { @@ -259,6 +259,10 @@ public int getAutomaticPvpDayEnd(String worldName) { return getInt("worlds." + worldName + ".automatic-pvp.day-end", 12000, 1, 24000); } + public boolean getTimeRemainingBossBarEnabled(String worldName) { + return getBoolean("worlds." + worldName + ".boss-bar.time-remaining", false); + } + public boolean getAutomaticDifficultyEnabled(String worldName) { return getBoolean("worlds." + worldName + ".automatic-difficulty.enabled", false); } diff --git a/src/main/java/org/callv2/daynightpvp/placeholder/PvpStatusPlaceholder.java b/src/main/java/org/callv2/daynightpvp/placeholder/PvpStatusPlaceholder.java index 6d7b877..1a52064 100644 --- a/src/main/java/org/callv2/daynightpvp/placeholder/PvpStatusPlaceholder.java +++ b/src/main/java/org/callv2/daynightpvp/placeholder/PvpStatusPlaceholder.java @@ -33,18 +33,23 @@ public PvpStatusPlaceholder(LangFile langFile, ConfigFile configFile) { @Override public @NotNull String getVersion() { - return DayNightPvP.getInstance().getDescription().getVersion(); + return "GENERIC"; + } + + @Override + public boolean canRegister() { + return true; } @Override public boolean persist() { - return true; // This is required or else PlaceholderAPI will unregister the Expansion on reload + return true; } @Override - public String onPlaceholderRequest(Player player, String params) { + public String onPlaceholderRequest(Player player, @NotNull String params) { - if (params.equalsIgnoreCase("current_world_pvpstatus")) { + if (params.equalsIgnoreCase("pvp_status_current_world")) { boolean pvpStatus; World world = player.getWorld(); @@ -57,9 +62,9 @@ public String onPlaceholderRequest(Player player, String params) { return pvpStatus ? langFile.getPlaceholderPvpEnabled() : langFile.getPlaceholderPvpDisabled(); } - if (params.startsWith("pvpstatus_")) { + if (params.startsWith("pvp_status_world")) { boolean pvpStatus; - String worldName = params.substring("pvpstatus_".length()); + String worldName = params.substring("pvp_status_world:".length()); World world = Bukkit.getWorld(worldName); if (world != null) { if (SearchUtils.worldExistsInWorldListSetString(configFile.getWorlds(), world.getName())) { @@ -69,6 +74,7 @@ public String onPlaceholderRequest(Player player, String params) { } } } + return langFile.getFeedbackError(); } diff --git a/src/main/java/org/callv2/daynightpvp/runnables/AutomaticPvp.java b/src/main/java/org/callv2/daynightpvp/runnables/AutomaticPvp.java index 06cb355..1dcf134 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/AutomaticPvp.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/AutomaticPvp.java @@ -1,9 +1,9 @@ package org.callv2.daynightpvp.runnables; +import org.bukkit.Bukkit; import org.bukkit.Difficulty; import org.bukkit.Sound; import org.bukkit.World; -import org.bukkit.scheduler.BukkitRunnable; import org.callv2.daynightpvp.files.LangFile; import org.callv2.daynightpvp.utils.ConsoleUtils; import org.callv2.daynightpvp.utils.PlayerUtils; @@ -11,7 +11,7 @@ import java.util.ArrayList; import java.util.List; -public class AutomaticPvp extends BukkitRunnable { +public class AutomaticPvp implements Runnable { public static List worldsPvpOff = new ArrayList<>(); public static List worldsPvpOn = new ArrayList<>(); diff --git a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java index 2d1d6f1..698c87b 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java @@ -1,9 +1,8 @@ package org.callv2.daynightpvp.runnables; import org.bukkit.World; -import org.bukkit.scheduler.BukkitRunnable; -public class CustomTimeDuration extends BukkitRunnable { +public class CustomTimeDuration implements Runnable { private final double dayTickIncrement; private final double nightTickIncrement; diff --git a/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java b/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java new file mode 100644 index 0000000..334cb31 --- /dev/null +++ b/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java @@ -0,0 +1,78 @@ +package org.callv2.daynightpvp.runnables; + +import org.bukkit.Bukkit; +import org.bukkit.World; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BossBar; + +public class RemainingTimeBossBar implements Runnable { + + private final BossBar bossBar; + private final World world; + private final boolean customDayNightDurationEnabled; + private final int dayDurationTicks; + private final int nightDurationTicks; + private final int dayEnd; + + public RemainingTimeBossBar(BossBar bossbar, World world, boolean customDayNightDurationEnabled, int dayDurationSeconds, int nightDurationSeconds, int dayEnd) { + this.bossBar = bossbar; + this.world = world; + this.customDayNightDurationEnabled = customDayNightDurationEnabled; + this.dayDurationTicks = defineDurationTicks(dayDurationSeconds); + this.nightDurationTicks = defineDurationTicks(nightDurationSeconds); + this.dayEnd = dayEnd; + } + + @Override + public void run() { + + updateBossBar(); + + Bukkit.getServer().getOnlinePlayers().forEach(bossBar::removePlayer); + world.getPlayers().forEach(bossBar::addPlayer); + } + + private void updateBossBar() { + long time = world.getTime(); + + long remainingTicks; + double progress; + String title; + + if (time >= 0 && time < dayEnd) { + remainingTicks = dayEnd - time; + progress = (double) time / dayEnd; + title = formatTime(remainingTicks, dayDurationTicks) + " até o pôr do sol"; + bossBar.setColor(BarColor.YELLOW); + } else { + remainingTicks = 24000 - time; + progress = (double) (time - dayEnd) / (24000 - dayEnd); + title = formatTime(remainingTicks, nightDurationTicks) + " até o nascer do sol"; + bossBar.setColor(BarColor.PURPLE); + } + + bossBar.setProgress(progress); + bossBar.setTitle(title); + } + + private String formatTime(long remainingTicks, long totalTicks) { + // Converte ticks para segundos + long remainingSeconds = (long) (remainingTicks * (totalTicks / 12000.0) / 20); + + // Calcula horas, minutos e segundos + long hours = remainingSeconds / 3600; + long minutes = (remainingSeconds % 3600) / 60; + long seconds = remainingSeconds % 60; + + // Formata a string com horas, minutos e segundos + return String.format("%02d:%02d:%02d", hours, minutes, seconds); + } + + private int defineDurationTicks(int seconds) { + if (customDayNightDurationEnabled) { + return seconds * 20; + } else { + return 12000; + } + } +} diff --git a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java index d862d2a..f7bacee 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java @@ -1,7 +1,9 @@ package org.callv2.daynightpvp.runnables; import org.bukkit.*; -import org.bukkit.scheduler.BukkitTask; +import org.bukkit.boss.BarColor; +import org.bukkit.boss.BarStyle; +import org.bukkit.boss.BossBar; import org.callv2.daynightpvp.DayNightPvP; import org.callv2.daynightpvp.files.ConfigFile; import org.callv2.daynightpvp.files.LangFile; @@ -14,7 +16,8 @@ public class RunnableHandler { private final ConfigFile configFile; private final LangFile langFile; - private List serviceTasks = new ArrayList<>(); + private List tasks = new ArrayList<>(); + private List bossBarList = new ArrayList<>(); public RunnableHandler(ConfigFile configFile, LangFile langFile) { this.configFile = configFile; @@ -34,6 +37,15 @@ public void startAllRunnables() { Bukkit.getWorld(worldName)); } + if (configFile.getTimeRemainingBossBarEnabled(worldName)) { + startRemainingTimeBossBar( + Bukkit.getWorld(worldName), + configFile.getDayNightDurationEnabled(worldName), + configFile.getDayNightDurationDayDuration(worldName), + configFile.getDayNightDurationNightDuration(worldName), + configFile.getAutomaticPvpDayEnd(worldName)); + } + if (configFile.getAutomaticPvpEnabled(worldName)) { startAutomaticPvp( langFile, @@ -63,8 +75,7 @@ private void startCustomTimeDuration( int dayDuration, int nightDuration, World world) { - BukkitTask customTimeTask = new CustomTimeDuration(dayTicks, dayDuration, nightDuration, world).runTaskTimer(DayNightPvP.getInstance(), 0, 1); - serviceTasks.add(customTimeTask); + tasks.add(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(DayNightPvP.getInstance(), new CustomTimeDuration(dayTicks, dayDuration, nightDuration, world), 0, 1)); world.setGameRule(GameRule.DO_DAYLIGHT_CYCLE, false); } @@ -85,7 +96,7 @@ private void startAutomaticPvp( float soundDayVolume, boolean notifyPlayersChatDayNightStarts, World world) { - BukkitTask automaticPvpTask = new AutomaticPvp( + tasks.add(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(DayNightPvP.getInstance(), new AutomaticPvp( langFile, dayEnd, automaticDifficultyEnabled, @@ -101,15 +112,31 @@ private void startAutomaticPvp( soundNightVolume, soundDayVolume, notifyPlayersChatDayNightStarts, - world).runTaskTimer(DayNightPvP.getInstance(), 0, 20); - serviceTasks.add(automaticPvpTask); + world), 0, 20)); + } + + private void startRemainingTimeBossBar( + World world, + boolean customDayNightDurationEnabled, + int dayDuration, + int nightDuration, + int dayEnd) { + BossBar bossbar = Bukkit.createBossBar("name", BarColor.BLUE, BarStyle.SOLID); + bossBarList.add(bossbar); + tasks.add(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(DayNightPvP.getInstance(), new RemainingTimeBossBar(bossbar, world, customDayNightDurationEnabled, dayDuration, nightDuration, dayEnd), 0, 20)); } public void stopAllRunnables() { - for (BukkitTask task : serviceTasks) { - stopRunnable(task); + + for (int task : tasks) { + Bukkit.getScheduler().cancelTask(task); + } + + tasks.clear(); + + for (BossBar bossBar : bossBarList) { + bossBar.removeAll(); } - serviceTasks.clear(); for(String worldName : configFile.getWorlds()) { if (WorldUtils.checkWorldIsValid(worldName)) { @@ -119,10 +146,4 @@ public void stopAllRunnables() { } - private void stopRunnable(BukkitTask task) { - if (task != null && !task.isCancelled()) { - task.cancel(); - } - } - } diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f37a806..f454086 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # Configuration file version, DO NOT MODIFY. -version: 18 +version: 19 # Enables or disables the update checker (recommended to keep as true). # Configuration type: Boolean @@ -39,6 +39,10 @@ worlds: # Default value: 12000 # Configuration range: 1 - 24000 day-end: 12000 + # BossBar settings. + boss-bar: + # Displays the time remaining until day/night starts. + time-remaining: false # Automatic difficulty settings. automatic-difficulty: # If enabled, the world difficulty will be changed to the configured value. From 0078bfe737a0c67966c7c8e4300b5285593a846a Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 14 Aug 2024 13:41:29 -0300 Subject: [PATCH 2/7] Add translations for the bossbar. --- pom.xml | 2 +- src/main/java/org/callv2/daynightpvp/files/LangFile.java | 8 ++++++++ .../daynightpvp/runnables/RemainingTimeBossBar.java | 9 ++++++--- .../callv2/daynightpvp/runnables/RunnableHandler.java | 4 ++-- src/main/resources/lang/en-US.yml | 2 ++ src/main/resources/lang/es-ES.yml | 2 ++ src/main/resources/lang/pt-BR.yml | 2 ++ src/main/resources/lang/ru-RU.yml | 2 ++ 8 files changed, 25 insertions(+), 6 deletions(-) diff --git a/pom.xml b/pom.xml index 2d88243..e01e6e8 100644 --- a/pom.xml +++ b/pom.xml @@ -117,7 +117,7 @@ com.github.TechFortress GriefPrevention - 16.18.3 + 16.18.2 provided diff --git a/src/main/java/org/callv2/daynightpvp/files/LangFile.java b/src/main/java/org/callv2/daynightpvp/files/LangFile.java index 110ca58..b18af59 100644 --- a/src/main/java/org/callv2/daynightpvp/files/LangFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/LangFile.java @@ -166,6 +166,14 @@ public String getFeedbackNonExistentCommand() { return formatMessage("feedback-non-existent-command"); } + public String getFeedbackBossbarSunset() { + return formatMessage("feedback-boss-bar-sunset"); + } + + public String getFeedbackBossbarSunrise() { + return formatMessage("feedback-boss-bar-sunrise"); + } + public String getFeedbackError() { return formatMessage("feedback-error"); } diff --git a/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java b/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java index 334cb31..300d5ec 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/RemainingTimeBossBar.java @@ -4,9 +4,11 @@ import org.bukkit.World; import org.bukkit.boss.BarColor; import org.bukkit.boss.BossBar; +import org.callv2.daynightpvp.files.LangFile; public class RemainingTimeBossBar implements Runnable { + private final LangFile langFile; private final BossBar bossBar; private final World world; private final boolean customDayNightDurationEnabled; @@ -14,7 +16,8 @@ public class RemainingTimeBossBar implements Runnable { private final int nightDurationTicks; private final int dayEnd; - public RemainingTimeBossBar(BossBar bossbar, World world, boolean customDayNightDurationEnabled, int dayDurationSeconds, int nightDurationSeconds, int dayEnd) { + public RemainingTimeBossBar(LangFile langFile, BossBar bossbar, World world, boolean customDayNightDurationEnabled, int dayDurationSeconds, int nightDurationSeconds, int dayEnd) { + this.langFile = langFile; this.bossBar = bossbar; this.world = world; this.customDayNightDurationEnabled = customDayNightDurationEnabled; @@ -42,12 +45,12 @@ private void updateBossBar() { if (time >= 0 && time < dayEnd) { remainingTicks = dayEnd - time; progress = (double) time / dayEnd; - title = formatTime(remainingTicks, dayDurationTicks) + " até o pôr do sol"; + title = langFile.getFeedbackBossbarSunset().replace("{0}", formatTime(remainingTicks, dayDurationTicks)); bossBar.setColor(BarColor.YELLOW); } else { remainingTicks = 24000 - time; progress = (double) (time - dayEnd) / (24000 - dayEnd); - title = formatTime(remainingTicks, nightDurationTicks) + " até o nascer do sol"; + title = langFile.getFeedbackBossbarSunrise().replace("{0}", formatTime(remainingTicks, nightDurationTicks)); bossBar.setColor(BarColor.PURPLE); } diff --git a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java index f7bacee..9e2341c 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java @@ -121,9 +121,9 @@ private void startRemainingTimeBossBar( int dayDuration, int nightDuration, int dayEnd) { - BossBar bossbar = Bukkit.createBossBar("name", BarColor.BLUE, BarStyle.SOLID); + BossBar bossbar = Bukkit.createBossBar("bossbar", BarColor.BLUE, BarStyle.SOLID); bossBarList.add(bossbar); - tasks.add(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(DayNightPvP.getInstance(), new RemainingTimeBossBar(bossbar, world, customDayNightDurationEnabled, dayDuration, nightDuration, dayEnd), 0, 20)); + tasks.add(Bukkit.getServer().getScheduler().scheduleSyncRepeatingTask(DayNightPvP.getInstance(), new RemainingTimeBossBar(langFile, bossbar, world, customDayNightDurationEnabled, dayDuration, nightDuration, dayEnd), 0, 20)); } public void stopAllRunnables() { diff --git a/src/main/resources/lang/en-US.yml b/src/main/resources/lang/en-US.yml index 8a8ddf5..13989f4 100644 --- a/src/main/resources/lang/en-US.yml +++ b/src/main/resources/lang/en-US.yml @@ -27,6 +27,8 @@ feedback-world-already-exists: "&8[&aDayNightPvP&8] &7World &b{0} &7already exis feedback-world-does-not-exist: "&8[&aDayNightPvP&8] &7World &b{0} &7does not exist." feedback-incorrect-command: "&8[&aDayNightPvP&8] &7Incorrect command, use: &b{0}" feedback-non-existent-command: "&8[&aDayNightPvP&8] &7Command not found!" +feedback-boss-bar-sunset: "{0} until sunset" +feedback-boss-bar-sunrise: "{0} until sunrise" feedback-error: "&c&lERROR!" # Actions diff --git a/src/main/resources/lang/es-ES.yml b/src/main/resources/lang/es-ES.yml index ef6fc2b..dff666c 100644 --- a/src/main/resources/lang/es-ES.yml +++ b/src/main/resources/lang/es-ES.yml @@ -27,6 +27,8 @@ feedback-world-already-exists: "&8[&aDayNightPvP&8] &7El mundo &b{0} &7ya existe feedback-world-does-not-exist: "&8[&aDayNightPvP&8] &7El mundo &b{0} &7no existe." feedback-incorrect-command: "&8[&aDayNightPvP&8] &7Comando incorrecto, usa: &b{0}" feedback-non-existent-command: "&8[&aDayNightPvP&8] &7¡Comando no encontrado!" +feedback-boss-bar-sunset: "{0} hasta el atardecer" +feedback-boss-bar-sunrise: "{0} hasta el amanecer" feedback-error: "&c&l¡ERROR!" # Actions diff --git a/src/main/resources/lang/pt-BR.yml b/src/main/resources/lang/pt-BR.yml index 52c3c37..b0e4337 100644 --- a/src/main/resources/lang/pt-BR.yml +++ b/src/main/resources/lang/pt-BR.yml @@ -27,6 +27,8 @@ feedback-world-already-exists: "&8[&aDayNightPvP&8] &7O mundo &b{0} &7já existe feedback-world-does-not-exist: "&8[&aDayNightPvP&8] &7O mundo &b{0} &7não existe." feedback-incorrect-command: "&8[&aDayNightPvP&8] &7Comando incorreto, use: &b{0}" feedback-non-existent-command: "&8[&aDayNightPvP&8] &7Comando não encontrado!" +feedback-boss-bar-sunset: "{0} até o pôr do sol" +feedback-boss-bar-sunrise: "{0} até o nascer do sol" feedback-error: "&c&lERRO!" # Actions diff --git a/src/main/resources/lang/ru-RU.yml b/src/main/resources/lang/ru-RU.yml index 336f3aa..ba8f2d6 100644 --- a/src/main/resources/lang/ru-RU.yml +++ b/src/main/resources/lang/ru-RU.yml @@ -27,6 +27,8 @@ feedback-world-already-exists: "&8[&aDayNightPvP&8] &7Мир &b{0} &7уже су feedback-world-does-not-exist: "&8[&aDayNightPvP&8] &7Мир &b{0} &7не существует." feedback-incorrect-command: "&8[&aDayNightPvP&8] &7Неверная команда, используйте: &b{0}" feedback-non-existent-command: "&8[&aDayNightPvP&8] &7Команда не найдена!" +feedback-boss-bar-sunset: "{0} до заката" +feedback-boss-bar-sunrise: "{0} до рассвета" feedback-error: "&c&lОШИБКА!" # Actions From cf50f7f92b3976eb9c8dc151e820a9eca1da6713 Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 28 Aug 2024 09:25:54 -0300 Subject: [PATCH 3/7] Update branch --- .../callv2/daynightpvp/files/ConfigFile.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index c7bec45..4e97df4 100644 --- a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java @@ -84,7 +84,7 @@ private int getInt(String path, Integer defaultValue, Integer minValue, Integer if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -110,7 +110,7 @@ private float getFloat(String path, Float defaultValue, Float minValue, Float ma if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -136,7 +136,7 @@ private Difficulty getDifficulty(String path, Difficulty defaultValue) { if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -155,7 +155,7 @@ private Sound getSound(String path, Sound defaultValue) { if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -173,7 +173,7 @@ private String getString(String path, String defaultValue) { if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -186,7 +186,7 @@ private boolean getBoolean(String path, Boolean defaultValue) { if (configValue == null) { resetFile(); String configName = path.replace(".", "/"); - ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" não foi encontrado e o arquivo foi redefinido."); + ConsoleUtils.sendWarningMessage("[DayNightPvP] The \"" + configName + "\" configuration was not found and the file was reset."); return defaultValue; } @@ -336,7 +336,11 @@ public boolean getVaultLoseMoneyOnDeathKillerRewardMoney(String worldName) { } public boolean getGriefPreventionPvpInLand(String worldName) { - return getBoolean("worlds." + worldName + ".grief-prevention.pvp-in-land", false); + if (getWorlds().contains(worldName)) { + return getBoolean("worlds." + worldName + ".grief-prevention.pvp-in-land", false); + } else { + return false; + } } } From f832760ac28706fcc455499ce305649834e9fb2b Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 28 Aug 2024 10:26:02 -0300 Subject: [PATCH 4/7] Add a bossbar for remaining time. --- pom.xml | 2 +- .../callv2/daynightpvp/files/ConfigFile.java | 6 +++--- .../callv2/daynightpvp/files/LangFile.java | 2 +- .../runnables/CustomTimeDuration.java | 20 ++++++++++++++++--- src/main/resources/config.yml | 6 +++--- src/main/resources/lang/en-US.yml | 2 +- src/main/resources/lang/es-ES.yml | 2 +- src/main/resources/lang/pt-BR.yml | 2 +- src/main/resources/lang/ru-RU.yml | 2 +- 9 files changed, 29 insertions(+), 15 deletions(-) diff --git a/pom.xml b/pom.xml index e01e6e8..c915392 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ maven-jar-plugin 3.4.2 - D:\Tranqueiras\Minecraft\Servidores\Debug\plugins + C:\Users\Usuario\Desktop\Debug\plugins diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index 4e97df4..b0647bc 100644 --- a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java @@ -29,7 +29,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 19; + int latestFileVersion = 20; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml.old"); if (outdatedFile.exists()) { @@ -244,11 +244,11 @@ public boolean getDayNightDurationEnabled(String worldName) { } public int getDayNightDurationDayDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 2147483647); + return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 86400); } public int getDayNightDurationNightDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 2147483647); + return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 86400); } public boolean getAutomaticPvpEnabled(String worldName) { diff --git a/src/main/java/org/callv2/daynightpvp/files/LangFile.java b/src/main/java/org/callv2/daynightpvp/files/LangFile.java index b18af59..4db8523 100644 --- a/src/main/java/org/callv2/daynightpvp/files/LangFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/LangFile.java @@ -31,7 +31,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 15; + int latestFileVersion = 16; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "lang/" + configFile.getLanguage() + ".yml.old"); if (outdatedFile.exists()) { diff --git a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java index 698c87b..723d793 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java @@ -1,5 +1,6 @@ package org.callv2.daynightpvp.runnables; +import org.bukkit.Bukkit; import org.bukkit.World; public class CustomTimeDuration implements Runnable { @@ -8,6 +9,7 @@ public class CustomTimeDuration implements Runnable { private final double nightTickIncrement; private final long dayTicks; private final World world; + private double tickAccumulator; public CustomTimeDuration( long dayTicks, @@ -27,11 +29,23 @@ public CustomTimeDuration( @Override public void run() { long time = world.getTime(); + double increment; + + // Determina o incremento de tempo com base na hora do dia if (time < dayTicks) { - world.setTime((long) (time + dayTickIncrement)); + increment = dayTickIncrement; } else { - world.setTime((long) (time + nightTickIncrement)); + increment = nightTickIncrement; } - } + // Adiciona o incremento ao acumulador + tickAccumulator += increment; + + // Só avança o tempo quando o acumulador excede 1 tick + if (tickAccumulator >= 1.0) { + long ticksToAdvance = (long) tickAccumulator; + world.setTime(time + ticksToAdvance); + tickAccumulator -= ticksToAdvance; // Reduz o acumulador + } + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f454086..e7af157 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # Configuration file version, DO NOT MODIFY. -version: 19 +version: 20 # Enables or disables the update checker (recommended to keep as true). # Configuration type: Boolean @@ -21,12 +21,12 @@ worlds: # Day duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 2147483647 + # Configuration range: 1 - 86400 day-duration: 600 # Night duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 2147483647 + # Configuration range: 1 - 86400 night-duration: 600 # Automatic PvP settings. automatic-pvp: diff --git a/src/main/resources/lang/en-US.yml b/src/main/resources/lang/en-US.yml index 13989f4..ebf4947 100644 --- a/src/main/resources/lang/en-US.yml +++ b/src/main/resources/lang/en-US.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lDay! PvP Disabled!" diff --git a/src/main/resources/lang/es-ES.yml b/src/main/resources/lang/es-ES.yml index dff666c..a21fe9a 100644 --- a/src/main/resources/lang/es-ES.yml +++ b/src/main/resources/lang/es-ES.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&l¡Día! ¡PvP Desactivado!" diff --git a/src/main/resources/lang/pt-BR.yml b/src/main/resources/lang/pt-BR.yml index b0e4337..c6bbfb7 100644 --- a/src/main/resources/lang/pt-BR.yml +++ b/src/main/resources/lang/pt-BR.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lDia! PvP Desativado!" diff --git a/src/main/resources/lang/ru-RU.yml b/src/main/resources/lang/ru-RU.yml index ba8f2d6..538d5ff 100644 --- a/src/main/resources/lang/ru-RU.yml +++ b/src/main/resources/lang/ru-RU.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lДень! PvP Отключен!" From c380aaab07883e781a283ebc6cdd1819c4d0e84e Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 28 Aug 2024 10:26:02 -0300 Subject: [PATCH 5/7] Update "outputDirectory". --- .../callv2/daynightpvp/files/ConfigFile.java | 6 +++--- .../callv2/daynightpvp/files/LangFile.java | 2 +- .../runnables/CustomTimeDuration.java | 20 ++++++++++++++++--- src/main/resources/config.yml | 6 +++--- src/main/resources/lang/en-US.yml | 2 +- src/main/resources/lang/es-ES.yml | 2 +- src/main/resources/lang/pt-BR.yml | 2 +- src/main/resources/lang/ru-RU.yml | 2 +- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index 4e97df4..b0647bc 100644 --- a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java @@ -29,7 +29,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 19; + int latestFileVersion = 20; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml.old"); if (outdatedFile.exists()) { @@ -244,11 +244,11 @@ public boolean getDayNightDurationEnabled(String worldName) { } public int getDayNightDurationDayDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 2147483647); + return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 86400); } public int getDayNightDurationNightDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 2147483647); + return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 86400); } public boolean getAutomaticPvpEnabled(String worldName) { diff --git a/src/main/java/org/callv2/daynightpvp/files/LangFile.java b/src/main/java/org/callv2/daynightpvp/files/LangFile.java index b18af59..4db8523 100644 --- a/src/main/java/org/callv2/daynightpvp/files/LangFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/LangFile.java @@ -31,7 +31,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 15; + int latestFileVersion = 16; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "lang/" + configFile.getLanguage() + ".yml.old"); if (outdatedFile.exists()) { diff --git a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java index 698c87b..723d793 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java @@ -1,5 +1,6 @@ package org.callv2.daynightpvp.runnables; +import org.bukkit.Bukkit; import org.bukkit.World; public class CustomTimeDuration implements Runnable { @@ -8,6 +9,7 @@ public class CustomTimeDuration implements Runnable { private final double nightTickIncrement; private final long dayTicks; private final World world; + private double tickAccumulator; public CustomTimeDuration( long dayTicks, @@ -27,11 +29,23 @@ public CustomTimeDuration( @Override public void run() { long time = world.getTime(); + double increment; + + // Determina o incremento de tempo com base na hora do dia if (time < dayTicks) { - world.setTime((long) (time + dayTickIncrement)); + increment = dayTickIncrement; } else { - world.setTime((long) (time + nightTickIncrement)); + increment = nightTickIncrement; } - } + // Adiciona o incremento ao acumulador + tickAccumulator += increment; + + // Só avança o tempo quando o acumulador excede 1 tick + if (tickAccumulator >= 1.0) { + long ticksToAdvance = (long) tickAccumulator; + world.setTime(time + ticksToAdvance); + tickAccumulator -= ticksToAdvance; // Reduz o acumulador + } + } } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f454086..e7af157 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # Configuration file version, DO NOT MODIFY. -version: 19 +version: 20 # Enables or disables the update checker (recommended to keep as true). # Configuration type: Boolean @@ -21,12 +21,12 @@ worlds: # Day duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 2147483647 + # Configuration range: 1 - 86400 day-duration: 600 # Night duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 2147483647 + # Configuration range: 1 - 86400 night-duration: 600 # Automatic PvP settings. automatic-pvp: diff --git a/src/main/resources/lang/en-US.yml b/src/main/resources/lang/en-US.yml index 13989f4..ebf4947 100644 --- a/src/main/resources/lang/en-US.yml +++ b/src/main/resources/lang/en-US.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lDay! PvP Disabled!" diff --git a/src/main/resources/lang/es-ES.yml b/src/main/resources/lang/es-ES.yml index dff666c..a21fe9a 100644 --- a/src/main/resources/lang/es-ES.yml +++ b/src/main/resources/lang/es-ES.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&l¡Día! ¡PvP Desactivado!" diff --git a/src/main/resources/lang/pt-BR.yml b/src/main/resources/lang/pt-BR.yml index b0e4337..c6bbfb7 100644 --- a/src/main/resources/lang/pt-BR.yml +++ b/src/main/resources/lang/pt-BR.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lDia! PvP Desativado!" diff --git a/src/main/resources/lang/ru-RU.yml b/src/main/resources/lang/ru-RU.yml index ba8f2d6..538d5ff 100644 --- a/src/main/resources/lang/ru-RU.yml +++ b/src/main/resources/lang/ru-RU.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 15 +version: 16 # Notifications notify-day-chat: "&a&lДень! PvP Отключен!" From d763031f7d56f65b45577c56d0a5a98b3a6183e4 Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 28 Aug 2024 10:28:35 -0300 Subject: [PATCH 6/7] Revert "Update "outputDirectory"." This reverts commit c380aaab07883e781a283ebc6cdd1819c4d0e84e. --- .../callv2/daynightpvp/files/ConfigFile.java | 6 +++--- .../callv2/daynightpvp/files/LangFile.java | 2 +- .../runnables/CustomTimeDuration.java | 20 +++---------------- src/main/resources/config.yml | 6 +++--- src/main/resources/lang/en-US.yml | 2 +- src/main/resources/lang/es-ES.yml | 2 +- src/main/resources/lang/pt-BR.yml | 2 +- src/main/resources/lang/ru-RU.yml | 2 +- 8 files changed, 14 insertions(+), 28 deletions(-) diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index b0647bc..4e97df4 100644 --- a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java @@ -29,7 +29,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 20; + int latestFileVersion = 19; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "config.yml.old"); if (outdatedFile.exists()) { @@ -244,11 +244,11 @@ public boolean getDayNightDurationEnabled(String worldName) { } public int getDayNightDurationDayDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 86400); + return getInt("worlds." + worldName + ".day-night-duration.day-duration", 600, 1, 2147483647); } public int getDayNightDurationNightDuration(String worldName) { - return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 86400); + return getInt("worlds." + worldName + ".day-night-duration.night-duration", 600, 1, 2147483647); } public boolean getAutomaticPvpEnabled(String worldName) { diff --git a/src/main/java/org/callv2/daynightpvp/files/LangFile.java b/src/main/java/org/callv2/daynightpvp/files/LangFile.java index 4db8523..b18af59 100644 --- a/src/main/java/org/callv2/daynightpvp/files/LangFile.java +++ b/src/main/java/org/callv2/daynightpvp/files/LangFile.java @@ -31,7 +31,7 @@ public void createFile() { } private void verifyFileVersion() { - int latestFileVersion = 16; + int latestFileVersion = 15; if (latestFileVersion != getVersion()) { File outdatedFile = new File(DayNightPvP.getInstance().getDataFolder(), "lang/" + configFile.getLanguage() + ".yml.old"); if (outdatedFile.exists()) { diff --git a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java index 723d793..698c87b 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/CustomTimeDuration.java @@ -1,6 +1,5 @@ package org.callv2.daynightpvp.runnables; -import org.bukkit.Bukkit; import org.bukkit.World; public class CustomTimeDuration implements Runnable { @@ -9,7 +8,6 @@ public class CustomTimeDuration implements Runnable { private final double nightTickIncrement; private final long dayTicks; private final World world; - private double tickAccumulator; public CustomTimeDuration( long dayTicks, @@ -29,23 +27,11 @@ public CustomTimeDuration( @Override public void run() { long time = world.getTime(); - double increment; - - // Determina o incremento de tempo com base na hora do dia if (time < dayTicks) { - increment = dayTickIncrement; + world.setTime((long) (time + dayTickIncrement)); } else { - increment = nightTickIncrement; - } - - // Adiciona o incremento ao acumulador - tickAccumulator += increment; - - // Só avança o tempo quando o acumulador excede 1 tick - if (tickAccumulator >= 1.0) { - long ticksToAdvance = (long) tickAccumulator; - world.setTime(time + ticksToAdvance); - tickAccumulator -= ticksToAdvance; // Reduz o acumulador + world.setTime((long) (time + nightTickIncrement)); } } + } \ No newline at end of file diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index e7af157..f454086 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1,5 +1,5 @@ # Configuration file version, DO NOT MODIFY. -version: 20 +version: 19 # Enables or disables the update checker (recommended to keep as true). # Configuration type: Boolean @@ -21,12 +21,12 @@ worlds: # Day duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 86400 + # Configuration range: 1 - 2147483647 day-duration: 600 # Night duration in seconds. # Configuration type: Integer # Default value: 600 - # Configuration range: 1 - 86400 + # Configuration range: 1 - 2147483647 night-duration: 600 # Automatic PvP settings. automatic-pvp: diff --git a/src/main/resources/lang/en-US.yml b/src/main/resources/lang/en-US.yml index ebf4947..13989f4 100644 --- a/src/main/resources/lang/en-US.yml +++ b/src/main/resources/lang/en-US.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 16 +version: 15 # Notifications notify-day-chat: "&a&lDay! PvP Disabled!" diff --git a/src/main/resources/lang/es-ES.yml b/src/main/resources/lang/es-ES.yml index a21fe9a..dff666c 100644 --- a/src/main/resources/lang/es-ES.yml +++ b/src/main/resources/lang/es-ES.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 16 +version: 15 # Notifications notify-day-chat: "&a&l¡Día! ¡PvP Desactivado!" diff --git a/src/main/resources/lang/pt-BR.yml b/src/main/resources/lang/pt-BR.yml index c6bbfb7..b0e4337 100644 --- a/src/main/resources/lang/pt-BR.yml +++ b/src/main/resources/lang/pt-BR.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 16 +version: 15 # Notifications notify-day-chat: "&a&lDia! PvP Desativado!" diff --git a/src/main/resources/lang/ru-RU.yml b/src/main/resources/lang/ru-RU.yml index 538d5ff..ba8f2d6 100644 --- a/src/main/resources/lang/ru-RU.yml +++ b/src/main/resources/lang/ru-RU.yml @@ -1,5 +1,5 @@ # This is the version of the file, DO NOT MODIFY. -version: 16 +version: 15 # Notifications notify-day-chat: "&a&lДень! PvP Отключен!" From df27fd389ea3ecbf3c578d604a39e7ad75d23879 Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 28 Aug 2024 10:31:00 -0300 Subject: [PATCH 7/7] Update "outputDirectory". --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index c915392..e01e6e8 100644 --- a/pom.xml +++ b/pom.xml @@ -30,7 +30,7 @@ maven-jar-plugin 3.4.2 - C:\Users\Usuario\Desktop\Debug\plugins + D:\Tranqueiras\Minecraft\Servidores\Debug\plugins