Fixed some concurrency concerns around BleedTasks

This commit is contained in:
Shane Freeder 2019-07-29 17:41:57 +01:00
parent 62ce98c8a5
commit e4d980b135
No known key found for this signature in database
GPG Key ID: A3F61EA5A085289C
4 changed files with 11 additions and 2 deletions

View File

@ -1,3 +1,7 @@
Version 2.1.101
mcnotify command now checks that it's being executed by a player
Fixed some concurrency concerns around BleedTasks
Version 2.1.100 Version 2.1.100
Corrected some mistakes made in the updated Russian locale (thanks myfbone!) Corrected some mistakes made in the updated Russian locale (thanks myfbone!)

View File

@ -259,8 +259,6 @@ public class EntityListener implements Listener {
if(defender.getMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY).size() > 0) if(defender.getMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY).size() > 0)
{ {
defender.removeMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, plugin);
if(defender instanceof Player) if(defender instanceof Player)
{ {
LivingEntity defLive = (LivingEntity) defender; LivingEntity defLive = (LivingEntity) defender;

View File

@ -9,6 +9,8 @@ import com.gmail.nossr50.util.skills.CombatUtils;
import com.gmail.nossr50.util.skills.ParticleEffectUtils; import com.gmail.nossr50.util.skills.ParticleEffectUtils;
import com.gmail.nossr50.util.sounds.SoundManager; import com.gmail.nossr50.util.sounds.SoundManager;
import com.gmail.nossr50.util.sounds.SoundType; import com.gmail.nossr50.util.sounds.SoundType;
import org.bukkit.Bukkit;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -171,6 +173,10 @@ public class BleedTimerTask extends BukkitRunnable {
* @param ticks Number of bleeding ticks * @param ticks Number of bleeding ticks
*/ */
public static void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank, int toolTier) { public static void add(LivingEntity entity, LivingEntity attacker, int ticks, int bleedRank, int toolTier) {
if (!Bukkit.isPrimaryThread()) {
throw new IllegalStateException("Cannot add bleed task async!");
}
if(toolTier < 4) if(toolTier < 4)
ticks = Math.max(1, (ticks / 3)); ticks = Math.max(1, (ticks / 3));

View File

@ -552,6 +552,7 @@ public final class CombatUtils {
target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue); target.setMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.metadataValue);
target.damage(damage, attacker); target.damage(damage, attacker);
target.removeMetadata(mcMMO.CUSTOM_DAMAGE_METAKEY, mcMMO.p);
// //IFrame storage // //IFrame storage
//// int noDamageTicks = target.getNoDamageTicks(); //// int noDamageTicks = target.getNoDamageTicks();