Skip to content

Commit

Permalink
Merge branch 'Slimefun:master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
WalshyDev committed Jan 16, 2024
2 parents 8fdd3da + 6bc1b1f commit 188654f
Showing 1 changed file with 19 additions and 8 deletions.
Expand Up @@ -2,6 +2,8 @@

import javax.annotation.Nonnull;

import io.github.thebusybiscuit.slimefun4.api.MinecraftVersion;
import io.github.thebusybiscuit.slimefun4.implementation.Slimefun;
import org.bukkit.Location;
import org.bukkit.entity.ArmorStand;

Expand Down Expand Up @@ -47,13 +49,22 @@ public class ArmorStandUtils {
* @return The spawned {@link ArmorStand}
*/
public static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location location) {
return location.getWorld().spawn(location, ArmorStand.class, armorStand -> {
armorStand.setVisible(false);
armorStand.setSilent(true);
armorStand.setMarker(true);
armorStand.setGravity(false);
armorStand.setBasePlate(false);
armorStand.setRemoveWhenFarAway(false);
});
// 1.19 and below don't have the consumer method so flicker exists on these versions.
if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_20)) {
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
setupArmorStand(armorStand);
return armorStand;
}

return location.getWorld().spawn(location, ArmorStand.class, armorStand -> setupArmorStand(armorStand));
}

private static void setupArmorStand(ArmorStand armorStand) {
armorStand.setVisible(false);
armorStand.setSilent(true);
armorStand.setMarker(true);
armorStand.setGravity(false);
armorStand.setBasePlate(false);
armorStand.setRemoveWhenFarAway(false);
}
}

0 comments on commit 188654f

Please sign in to comment.