potion effect Async fix

This commit is contained in:
SuperRonanCraft 2023-10-07 00:13:56 -04:00
parent 044054d594
commit b4dae7de00
2 changed files with 17 additions and 12 deletions

View File

@ -73,7 +73,8 @@ public class RTPTeleport {
//Effects
public void afterTeleport(Player p, Location loc, WorldPlayer wPlayer, int attempts, Location oldLoc, RTP_TYPE type) { //Only a successful rtp should run this OR '/rtp test'
public void afterTeleport(Player p, Location loc, WorldPlayer wPlayer, int attempts, Location oldLoc, RTP_TYPE type) {
//Only a successful rtp should run this OR '/rtp test'
effects.getSounds().playTeleport(p);
effects.getParticles().display(p);
effects.getPotions().giveEffects(p);

View File

@ -2,6 +2,8 @@ package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
import me.SuperRonanCraft.BetterRTP.BetterRTP;
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
import me.SuperRonanCraft.BetterRTP.versions.AsyncHandler;
import me.SuperRonanCraft.BetterRTP.versions.FoliaHandler;
import org.bukkit.entity.Player;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
@ -49,6 +51,7 @@ public class RTPEffect_Potions { //Potions AND Invincibility
}
public void giveEffects(Player p) {
AsyncHandler.sync(() -> {
if (invincibleEnabled)
p.setNoDamageTicks(invincibleTime * 20);
if (potionEnabled) {
@ -61,6 +64,7 @@ public class RTPEffect_Potions { //Potions AND Invincibility
}
p.addPotionEffects(effects);
}
});
}
}