mirror of
https://github.com/RonanPlugins/BetterRTP.git
synced 2025-07-01 23:36:18 +00:00
potion effect Async fix
This commit is contained in:
parent
044054d594
commit
b4dae7de00
@ -73,7 +73,8 @@ public class RTPTeleport {
|
|||||||
|
|
||||||
//Effects
|
//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.getSounds().playTeleport(p);
|
||||||
effects.getParticles().display(p);
|
effects.getParticles().display(p);
|
||||||
effects.getPotions().giveEffects(p);
|
effects.getPotions().giveEffects(p);
|
||||||
|
@ -2,6 +2,8 @@ package me.SuperRonanCraft.BetterRTP.player.rtp.effects;
|
|||||||
|
|
||||||
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
import me.SuperRonanCraft.BetterRTP.BetterRTP;
|
||||||
import me.SuperRonanCraft.BetterRTP.references.file.FileOther;
|
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.entity.Player;
|
||||||
import org.bukkit.potion.PotionEffect;
|
import org.bukkit.potion.PotionEffect;
|
||||||
import org.bukkit.potion.PotionEffectType;
|
import org.bukkit.potion.PotionEffectType;
|
||||||
@ -49,18 +51,20 @@ public class RTPEffect_Potions { //Potions AND Invincibility
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void giveEffects(Player p) {
|
public void giveEffects(Player p) {
|
||||||
if (invincibleEnabled)
|
AsyncHandler.sync(() -> {
|
||||||
p.setNoDamageTicks(invincibleTime * 20);
|
if (invincibleEnabled)
|
||||||
if (potionEnabled) {
|
p.setNoDamageTicks(invincibleTime * 20);
|
||||||
List<PotionEffect> effects = new ArrayList<>();
|
if (potionEnabled) {
|
||||||
for (PotionEffectType e : potionEffects.keySet()) {
|
List<PotionEffect> effects = new ArrayList<>();
|
||||||
Integer[] mods = potionEffects.get(e);
|
for (PotionEffectType e : potionEffects.keySet()) {
|
||||||
int duration = mods[0];
|
Integer[] mods = potionEffects.get(e);
|
||||||
int amplifier = mods[1];
|
int duration = mods[0];
|
||||||
effects.add(new PotionEffect(e, duration, amplifier, false, false));
|
int amplifier = mods[1];
|
||||||
|
effects.add(new PotionEffect(e, duration, amplifier, false, false));
|
||||||
|
}
|
||||||
|
p.addPotionEffects(effects);
|
||||||
}
|
}
|
||||||
p.addPotionEffects(effects);
|
});
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user