From 7f4efe1775046060929b412d22a2b0f5baedbb15 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Fri, 29 Mar 2013 18:29:31 -0400 Subject: [PATCH] Added option to allow refreshing of chunks after block-breaking abilities. This, if enabled, should fix the problem of clients believing they have broken more blocks than they really have when the enchanced enchantment is removed. If testing proves it to be useful, could be enabled by default. This currently send a 3x3 set of chunks centered around the player, so some servers may wish to disable it in that case. --- Changelog.txt | 1 + src/main/java/com/gmail/nossr50/config/HiddenConfig.java | 6 ++++++ src/main/java/com/gmail/nossr50/util/Misc.java | 8 ++++++++ .../java/com/gmail/nossr50/util/skills/SkillUtils.java | 4 ++++ src/main/resources/hidden.yml | 4 +++- 5 files changed, 22 insertions(+), 1 deletion(-) diff --git a/Changelog.txt b/Changelog.txt index e7a54efb7..e3cb1c6ff 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -8,6 +8,7 @@ Key: - Removal Version 1.4.05-dev + + Added option to allow refreshing of chunks after block-breaking abilities. Version 1.4.04 + Added functions to ExperienceAPI for use with offline players diff --git a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java index 5179c3ecb..ffb21ca45 100644 --- a/src/main/java/com/gmail/nossr50/config/HiddenConfig.java +++ b/src/main/java/com/gmail/nossr50/config/HiddenConfig.java @@ -11,6 +11,7 @@ public class HiddenConfig { private static boolean chunkletsEnabled; private static int conversionRate; private static boolean useEnchantmentBuffs; + private static boolean resendChunksAfterBlockAbility; public HiddenConfig(String fileName) { HiddenConfig.fileName = fileName; @@ -31,6 +32,7 @@ public class HiddenConfig { chunkletsEnabled = config.getBoolean("Options.Chunklets", true); conversionRate = config.getInt("Options.ConversionRate", 1); useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true); + resendChunksAfterBlockAbility = config.getBoolean("Options.RefreshChunks", false); } } @@ -45,4 +47,8 @@ public class HiddenConfig { public boolean useEnchantmentBuffs() { return useEnchantmentBuffs; } + + public boolean resendChunksAfterBlockAbility() { + return resendChunksAfterBlockAbility; + } } diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index 43c8a4bca..5f6580269 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -189,6 +189,14 @@ public final class Misc { } } + public static void resendChunkRadiusAt(Player player, int radius) { + for (int x = player.getLocation().getChunk().getX() - radius; x < player.getLocation().getChunk().getX() + radius; x++) { + for (int z = player.getLocation().getChunk().getZ() - radius; z < player.getLocation().getChunk().getZ() + radius; z++) { + player.getWorld().refreshChunk(x, z); + } + } + } + public static Random getRandom() { return random; } diff --git a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java index b1dbbd444..637d5b2ad 100644 --- a/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java +++ b/src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java @@ -187,6 +187,10 @@ public class SkillUtils { handleAbilitySpeedDecrease(player); } + if (HiddenConfig.getInstance().resendChunksAfterBlockAbility() && (ability == AbilityType.BERSERK || ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRILL_BREAKER)) { + Misc.resendChunkRadiusAt(player, 1); + } + mcMMOPlayer.setAbilityMode(ability, false); mcMMOPlayer.setAbilityInformed(ability, false); diff --git a/src/main/resources/hidden.yml b/src/main/resources/hidden.yml index a6f89e025..cf0894914 100644 --- a/src/main/resources/hidden.yml +++ b/src/main/resources/hidden.yml @@ -8,4 +8,6 @@ Options: # Square root of the number of chunks to convert per tick. ConversionRate: 1 # true to use enchantment buffs for Super Breaker & Giga Drill Breaker, false to use potion buffs - EnchantmentBuffs: true \ No newline at end of file + EnchantmentBuffs: true + # true to enable refreshing of chunks around a player at the end of Super Breaker, Giga Drill Breaker, and Berserk. This should fix blocks being broken client side, but not server-side + RefreshChunks: false