mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 14:16:45 +01:00
b3e1acc563
If radius is 1 (as it is when called elsewhere in the class), the loop conditions fail to refresh some of the neighboring chunks, allowing for ghost blocks to continue to occur on eastern and southern edges of the chunk the player is in. This commit fixes the loop conditions. = Chunk diagram of old behavior = ----- -RR-- -RP-- ----- ----- = Chunk diagram of new behavior = ----- -RRR- -RPR- -RRR- ----- = Legend = P: the chunk the player is in R and P: chunks that are refreshed -: chunks that do not get refreshed
80 lines
2.5 KiB
Java
80 lines
2.5 KiB
Java
package com.gmail.nossr50.runnables.skills;
|
|
|
|
import org.bukkit.Chunk;
|
|
import org.bukkit.World;
|
|
import org.bukkit.entity.Player;
|
|
import org.bukkit.scheduler.BukkitRunnable;
|
|
|
|
import com.gmail.nossr50.mcMMO;
|
|
import com.gmail.nossr50.config.Config;
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
import com.gmail.nossr50.datatypes.skills.AbilityType;
|
|
import com.gmail.nossr50.util.EventUtils;
|
|
import com.gmail.nossr50.util.Misc;
|
|
import com.gmail.nossr50.util.skills.ParticleEffectUtils;
|
|
import com.gmail.nossr50.util.skills.PerksUtils;
|
|
import com.gmail.nossr50.util.skills.SkillUtils;
|
|
|
|
public class AbilityDisableTask extends BukkitRunnable {
|
|
private McMMOPlayer mcMMOPlayer;
|
|
private AbilityType ability;
|
|
|
|
public AbilityDisableTask(McMMOPlayer mcMMOPlayer, AbilityType ability) {
|
|
this.mcMMOPlayer = mcMMOPlayer;
|
|
this.ability = ability;
|
|
}
|
|
|
|
@Override
|
|
public void run() {
|
|
if (!mcMMOPlayer.getAbilityMode(ability)) {
|
|
return;
|
|
}
|
|
|
|
Player player = mcMMOPlayer.getPlayer();
|
|
|
|
switch (ability) {
|
|
case SUPER_BREAKER:
|
|
case GIGA_DRILL_BREAKER:
|
|
SkillUtils.handleAbilitySpeedDecrease(player);
|
|
// Fallthrough
|
|
|
|
case BERSERK:
|
|
if (Config.getInstance().getRefreshChunksEnabled()) {
|
|
resendChunkRadiusAt(player, 1);
|
|
}
|
|
// Fallthrough
|
|
|
|
default:
|
|
break;
|
|
}
|
|
|
|
EventUtils.callAbilityDeactivateEvent(player, ability);
|
|
|
|
mcMMOPlayer.setAbilityMode(ability, false);
|
|
mcMMOPlayer.setAbilityInformed(ability, false);
|
|
|
|
ParticleEffectUtils.playAbilityDisabledEffect(player);
|
|
|
|
if (mcMMOPlayer.useChatNotifications()) {
|
|
player.sendMessage(ability.getAbilityOff());
|
|
}
|
|
|
|
SkillUtils.sendSkillMessage(player, ability.getAbilityPlayerOff(player));
|
|
new AbilityCooldownTask(mcMMOPlayer, ability).runTaskLaterAsynchronously(mcMMO.p, PerksUtils.handleCooldownPerks(player, ability.getCooldown()) * Misc.TICK_CONVERSION_FACTOR);
|
|
}
|
|
|
|
private void resendChunkRadiusAt(Player player, int radius) {
|
|
Chunk chunk = player.getLocation().getChunk();
|
|
World world = player.getWorld();
|
|
|
|
int chunkX = chunk.getX();
|
|
int chunkZ = chunk.getZ();
|
|
|
|
for (int x = chunkX - radius; x <= chunkX + radius; x++) {
|
|
for (int z = chunkZ - radius; z <= chunkZ + radius; z++) {
|
|
world.refreshChunk(x, z);
|
|
}
|
|
}
|
|
}
|
|
}
|