From e7e3e14825390305217b006e262dcedffaec0e7d Mon Sep 17 00:00:00 2001 From: ProSavage Date: Sun, 29 Jul 2018 14:34:40 -0500 Subject: [PATCH] 1.13 now has working particles. --- src/main/java/com/massivecraft/factions/P.java | 5 +++++ .../java/com/massivecraft/factions/cmd/CmdFly.java | 11 ++++++++++- 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/P.java b/src/main/java/com/massivecraft/factions/P.java index c63ee207..ddf620ab 100644 --- a/src/main/java/com/massivecraft/factions/P.java +++ b/src/main/java/com/massivecraft/factions/P.java @@ -55,6 +55,7 @@ public class P extends MPlugin { public CmdAutoHelp cmdAutoHelp; public boolean mc17 = false; public boolean mc18 = false; + public boolean useNonPacketParticles = false; public boolean factionsFlight = false; ItemStack item = new ItemStack(Material.CAKE); // Persistence related @@ -150,6 +151,7 @@ public class P extends MPlugin { //massive stats MassiveStats massive = new MassiveStats(this); + int version = Integer.parseInt(ReflectionUtils.PackageType.getServerVersion().split("_")[1]); if (version == 7) { P.p.log("Minecraft Version 1.7 found, disabling banners, itemflags inside GUIs, and Titles."); @@ -157,6 +159,9 @@ public class P extends MPlugin { } else if (version == 8) { P.p.log("Minecraft Version 1.8 found, Title Fadeouttime etc will not be configurable."); mc18 = true; + } else if (version > 8) { + useNonPacketParticles = true; + P.p.log("Minecraft Version 1.9 or higher found, using non packet based particle API"); } if (P.p.getConfig().getBoolean("enable-faction-flight")) { diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java index e253580f..d24859c1 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdFly.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdFly.java @@ -11,6 +11,7 @@ import com.massivecraft.factions.zcore.fperms.PermissableAction; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.GameMode; +import org.bukkit.Particle; import org.bukkit.entity.Entity; import org.bukkit.entity.Player; @@ -57,7 +58,15 @@ public class CmdFly extends FCommand { continue; } - ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16); + if (P.p.useNonPacketParticles) { + // 1.9+ based servers will use the built in particleAPI instead of packet based. + // any particle amount higher than 0 made them go everywhere, and the offset at 0 was not working. + // So setting the amount to 0 spawns 1 in the precise location + player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation().add(0, -0.35, 0), 0); + } else { + ParticleEffect.CLOUD.display((float) 0, (float) 0, (float) 0, (float) 0, 3, player.getLocation().add(0, -0.35, 0), 16); + } + } if (flyMap.keySet().size() == 0) { Bukkit.getScheduler().cancelTask(id);