Skip to content

Commit

Permalink
Added option to allow refreshing of chunks after block-breaking abili…
Browse files Browse the repository at this point in the history
…ties.

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.
  • Loading branch information
NuclearW committed Mar 29, 2013
1 parent 80a5c2f commit 7f4efe1
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions Changelog.txt
Expand Up @@ -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
Expand Down
6 changes: 6 additions & 0 deletions src/main/java/com/gmail/nossr50/config/HiddenConfig.java
Expand Up @@ -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;
Expand All @@ -31,6 +32,7 @@ public void load() {
chunkletsEnabled = config.getBoolean("Options.Chunklets", true);
conversionRate = config.getInt("Options.ConversionRate", 1);
useEnchantmentBuffs = config.getBoolean("Options.EnchantmentBuffs", true);
resendChunksAfterBlockAbility = config.getBoolean("Options.RefreshChunks", false);
}
}

Expand All @@ -45,4 +47,8 @@ public int getConversionRate() {
public boolean useEnchantmentBuffs() {
return useEnchantmentBuffs;
}

public boolean resendChunksAfterBlockAbility() {
return resendChunksAfterBlockAbility;
}
}
8 changes: 8 additions & 0 deletions src/main/java/com/gmail/nossr50/util/Misc.java
Expand Up @@ -189,6 +189,14 @@ public static void profileCleanup(String playerName) {
}
}

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;
}
Expand Down
4 changes: 4 additions & 0 deletions src/main/java/com/gmail/nossr50/util/skills/SkillUtils.java
Expand Up @@ -187,6 +187,10 @@ else if (ability == AbilityType.SUPER_BREAKER || ability == AbilityType.GIGA_DRI
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);

Expand Down
4 changes: 3 additions & 1 deletion src/main/resources/hidden.yml
Expand Up @@ -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
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

0 comments on commit 7f4efe1

Please sign in to comment.