This might break everything so test this first on alpha or something

This should check if a player is in vanish
This commit is contained in:
Teriuihi 2022-02-26 03:03:02 +01:00
parent 295b9d1ee2
commit c259e3f035
3 changed files with 12 additions and 4 deletions

View File

@ -45,4 +45,5 @@ tasks {
dependencies { dependencies {
compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT") compileOnly("com.alttd:Galaxy-API:1.18.1-R0.1-SNAPSHOT")
compileOnly("com.github.LeonMangler:PremiumVanishAPI:2.7.11-2")
} }

View File

@ -5,6 +5,7 @@ dependencyResolutionManagement {
mavenLocal() mavenLocal()
mavenCentral() mavenCentral()
maven("https://papermc.io/repo/repository/maven-public/") // Paper maven("https://papermc.io/repo/repository/maven-public/") // Paper
maven("https://jitpack.io") //PremiumVanish
} }
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS) repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
} }

View File

@ -6,6 +6,8 @@ import com.alttd.frameSpawners.FrameSpawnerLocation;
import com.alttd.frameSpawners.FrameSpawnerPlayer; import com.alttd.frameSpawners.FrameSpawnerPlayer;
import com.alttd.storage.PlayerSettings; import com.alttd.storage.PlayerSettings;
import com.alttd.util.Logger; import com.alttd.util.Logger;
import de.myzelyam.api.vanish.VanishAPI;
import org.bukkit.GameMode;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
@ -34,15 +36,15 @@ public class ParticleSet {
this.itemStack = itemStack; this.itemStack = itemStack;
} }
public void run(Location location, UUID uuid) { public void run(Location location, Player player) {
if (tooSoon(uuid)) if (tooSoon(player.getUniqueId()) || isVanished(player))
return; return;
FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, repeatDelay, frames, location); FrameSpawnerLocation frameSpawnerLocation = new FrameSpawnerLocation(repeat, repeatDelay, frames, location);
frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay); frameSpawnerLocation.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
} }
public void run(Player player, PlayerSettings playerSettings, UUID uuid) { public void run(Player player, PlayerSettings playerSettings) {
if (tooSoon(uuid) && !player.hasPermission("apart.bypass-cooldown")) if (tooSoon(player.getUniqueId()) && !player.hasPermission("apart.bypass-cooldown"))
return; return;
if (Config.DEBUG) if (Config.DEBUG)
Logger.info("Starting particle set % for %.", uniqueId, player.getName()); Logger.info("Starting particle set % for %.", uniqueId, player.getName());
@ -50,6 +52,10 @@ public class ParticleSet {
frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay); frameSpawnerPlayer.runTaskTimerAsynchronously(AltitudeParticles.getInstance(), 0, frameDelay);
} }
private boolean isVanished(Player player) {
return VanishAPI.isInvisible(player) || player.getGameMode().equals(GameMode.SPECTATOR);
}
private boolean tooSoon(UUID uuid) { private boolean tooSoon(UUID uuid) {
PlayerSettings ps = PlayerSettings.getPlayer(uuid); PlayerSettings ps = PlayerSettings.getPlayer(uuid);
if (ps.canRun(aPartType)) if (ps.canRun(aPartType))