From 167dda77bc9ad7f173629679369f8731d349879f Mon Sep 17 00:00:00 2001 From: needkg Date: Wed, 14 Aug 2024 10:40:07 -0300 Subject: [PATCH 1/3] Organize the code. --- pom.xml | 4 ++-- src/main/java/org/callv2/daynightpvp/DayNightPvP.java | 8 ++++---- .../org/callv2/daynightpvp/commands/DnpCommand.java | 8 ++++---- .../griefprevention/GriefPreventionHandler.java | 2 +- .../callv2/daynightpvp/listeners/DamageListener.java | 3 +-- .../callv2/daynightpvp/listeners/DeathListener.java | 2 +- .../callv2/daynightpvp/runnables/RunnableHandler.java | 4 ++-- src/main/resources/plugin.yml | 10 +++++----- 8 files changed, 20 insertions(+), 21 deletions(-) diff --git a/pom.xml b/pom.xml index 57039ee..8a52994 100644 --- a/pom.xml +++ b/pom.xml @@ -115,9 +115,9 @@ - com.github.TechFortress + com.github.GriefPrevention GriefPrevention - 16.18.3 + 16.18.2 provided diff --git a/src/main/java/org/callv2/daynightpvp/DayNightPvP.java b/src/main/java/org/callv2/daynightpvp/DayNightPvP.java index be985f6..08cf714 100644 --- a/src/main/java/org/callv2/daynightpvp/DayNightPvP.java +++ b/src/main/java/org/callv2/daynightpvp/DayNightPvP.java @@ -47,6 +47,10 @@ public DayNightPvP() { } + public static DayNightPvP getInstance() { + return instance; + } + @Override public void onLoad() { verifyCompatibilityPlugins(); @@ -79,10 +83,6 @@ public void onDisable() { runnableHandler.stopAllRunnables(); } - public static DayNightPvP getInstance() { - return instance; - } - private void verifyCompatibilityPlugins() { vaultIsPresent = PluginUtils.isPluginInstalled("Vault"); worldGuardIsPresent = PluginUtils.isPluginInstalled("WorldGuard"); diff --git a/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java b/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java index 0ce10f9..7007dbd 100644 --- a/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java +++ b/src/main/java/org/callv2/daynightpvp/commands/DnpCommand.java @@ -48,10 +48,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command if (args.length == 0) { PlayerUtils.sendMessage(sender, ""); - PlayerUtils.sendMessage(sender,"§7§l* §a§lCommands§7:"); - 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* §a§lCommands§7:"); + 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."); return true; } diff --git a/src/main/java/org/callv2/daynightpvp/griefprevention/GriefPreventionHandler.java b/src/main/java/org/callv2/daynightpvp/griefprevention/GriefPreventionHandler.java index 396faf3..bf7d816 100644 --- a/src/main/java/org/callv2/daynightpvp/griefprevention/GriefPreventionHandler.java +++ b/src/main/java/org/callv2/daynightpvp/griefprevention/GriefPreventionHandler.java @@ -8,7 +8,7 @@ public class GriefPreventionHandler { public boolean verify(Player damagedPlayer, Player damager) { DataStore griefPrevention = GriefPrevention.instance.dataStore; - return griefPrevention.getClaimAt(damagedPlayer.getLocation(), true, null) != null || griefPrevention.getClaimAt(damager.getLocation(), true, null) != null; + return griefPrevention.getClaimAt(damagedPlayer.getLocation(), true, null) != null || griefPrevention.getClaimAt(damager.getLocation(), true, null) != null; } } diff --git a/src/main/java/org/callv2/daynightpvp/listeners/DamageListener.java b/src/main/java/org/callv2/daynightpvp/listeners/DamageListener.java index bf1e5cf..6c7600d 100644 --- a/src/main/java/org/callv2/daynightpvp/listeners/DamageListener.java +++ b/src/main/java/org/callv2/daynightpvp/listeners/DamageListener.java @@ -119,8 +119,7 @@ private boolean checkHooks(Player damagedPlayer, Player damager, String worldNam if (DayNightPvP.worldGuardIsPresent && AllowDaytimePvpFlag.checkStateOnPosition(damagedPlayer) && AllowDaytimePvpFlag.checkStateOnPosition(damager)) { return false; } - if (WorldUtils.checkPlayerIsInWorld(damagedPlayer)) - { + if (WorldUtils.checkPlayerIsInWorld(damagedPlayer)) { if (configFile.getNotifyPlayersChatHitAnotherPlayerDuringDay(worldName)) { damager.sendMessage(notifyPvpDisabled); } diff --git a/src/main/java/org/callv2/daynightpvp/listeners/DeathListener.java b/src/main/java/org/callv2/daynightpvp/listeners/DeathListener.java index 85b60ad..35d733c 100644 --- a/src/main/java/org/callv2/daynightpvp/listeners/DeathListener.java +++ b/src/main/java/org/callv2/daynightpvp/listeners/DeathListener.java @@ -11,7 +11,7 @@ import org.callv2.daynightpvp.files.ConfigFile; import org.callv2.daynightpvp.vault.LoseMoneyOnDeath; -public class DeathListener implements Listener { +public class DeathListener implements Listener { private final ConfigFile configFile; private final LoseMoneyOnDeath loseMoneyOnDeath; diff --git a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java index d862d2a..2827c2f 100644 --- a/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java +++ b/src/main/java/org/callv2/daynightpvp/runnables/RunnableHandler.java @@ -23,7 +23,7 @@ public RunnableHandler(ConfigFile configFile, LangFile langFile) { public void startAllRunnables() { - for(String worldName : configFile.getWorlds()) { + for (String worldName : configFile.getWorlds()) { if (WorldUtils.checkWorldIsValid(worldName)) { if (configFile.getDayNightDurationEnabled(worldName)) { @@ -111,7 +111,7 @@ public void stopAllRunnables() { } serviceTasks.clear(); - for(String worldName : configFile.getWorlds()) { + for (String worldName : configFile.getWorlds()) { if (WorldUtils.checkWorldIsValid(worldName)) { Bukkit.getWorld(worldName).setGameRule(GameRule.DO_DAYLIGHT_CYCLE, true); } diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 1a3c602..1cf3d19 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -3,29 +3,29 @@ version: '${project.version}' author: needkg main: org.callv2.daynightpvp.DayNightPvP api-version: '1.16' -softdepend: [PlaceholderAPI, GriefPrevention, Vault, WorldGuard] +softdepend: [ PlaceholderAPI, GriefPrevention, Vault, WorldGuard ] load: POSTWORLD commands: daynightpvp: description: "Show all available commands" usage: "/dnp" - aliases: [dnp] + aliases: [ dnp ] permission: dnp.admin daynightpvp reload: description: "Reload the plugin" usage: "/dnp reload" - aliases: [dnp reload] + aliases: [ dnp reload ] permission: dnp.admin daynightpvp addworld: description: "Adds a world to the configuration file" usage: "/dnp addworld" - aliases: [dnp addworld] + aliases: [ dnp addworld ] permission: dnp.admin daynightpvp delworld: description: "Deletes a world from the configuration file" usage: "/dnp delworld" - aliases: [dnp delworld] + aliases: [ dnp delworld ] permission: dnp.admin permissions: From 8e61271bc21c3a5576d717acb09658a2d8c9562b Mon Sep 17 00:00:00 2001 From: needkg Date: Thu, 22 Aug 2024 10:08:47 -0300 Subject: [PATCH 2/3] Fixed debug message issues and config resets during combat in unconfigured worlds. --- .../callv2/daynightpvp/files/ConfigFile.java | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java b/src/main/java/org/callv2/daynightpvp/files/ConfigFile.java index a5379a9..2a4aa2e 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; } @@ -332,7 +332,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; + } } -} +} \ No newline at end of file From d9c38f5d476ccc4ccf6ebd065886818be1761142 Mon Sep 17 00:00:00 2001 From: needkg Date: Thu, 22 Aug 2024 10:10:22 -0300 Subject: [PATCH 3/3] Change version to '1.2.6.7' --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 8a52994..47ea502 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ org.callv2 DayNightPvP DayNightPvP - 1.2.6.5 + 1.2.6.7 jar UTF-8