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,18 +51,20 @@ public class RTPEffect_Potions { //Potions AND Invincibility
}
public void giveEffects(Player p) {
if (invincibleEnabled)
p.setNoDamageTicks(invincibleTime * 20);
if (potionEnabled) {
List<PotionEffect> effects = new ArrayList<>();
for (PotionEffectType e : potionEffects.keySet()) {
Integer[] mods = potionEffects.get(e);
int duration = mods[0];
int amplifier = mods[1];
effects.add(new PotionEffect(e, duration, amplifier, false, false));
AsyncHandler.sync(() -> {
if (invincibleEnabled)
p.setNoDamageTicks(invincibleTime * 20);
if (potionEnabled) {
List<PotionEffect> effects = new ArrayList<>();
for (PotionEffectType e : potionEffects.keySet()) {
Integer[] mods = potionEffects.get(e);
int duration = mods[0];
int amplifier = mods[1];
effects.add(new PotionEffect(e, duration, amplifier, false, false));
}
p.addPotionEffects(effects);
}
p.addPotionEffects(effects);
}
});
}
}