Skip to content

Commit

Permalink
Merge remote-tracking branch 'Slimefun/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
xMikux committed Jan 22, 2024
2 parents 1872526 + cd3672c commit 01075ff
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1199,7 +1199,7 @@ public final int hashCode() {
* The {@link ItemStack} to check
* @return The {@link Optional} {@link SlimefunItem} associated with this {@link ItemStack} if present, otherwise empty
*/
public @Nonnull Optional<SlimefunItem> getOptionalByItem(@Nullable ItemStack item) {
public static @Nonnull Optional<SlimefunItem> getOptionalByItem(@Nullable ItemStack item) {
return Optional.ofNullable(getByItem(item));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@

import javax.annotation.Nonnull;

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

Expand All @@ -22,6 +21,8 @@
*/
public class ArmorStandUtils {

private ArmorStandUtils() {}

/**
* Spawns an {@link ArmorStand} at the given {@link Location} with the given custom name
* <br>
Expand Down Expand Up @@ -49,14 +50,17 @@ public class ArmorStandUtils {
* @return The spawned {@link ArmorStand}
*/
public static @Nonnull ArmorStand spawnArmorStand(@Nonnull Location location) {
// 1.19 and below don't have the consumer method so flicker exists on these versions.
if (Slimefun.getMinecraftVersion().isBefore(MinecraftVersion.MINECRAFT_1_20)) {
// The consumer method was moved from World to RegionAccessor in 1.20.2
// Due to this, we need to use a rubbish workaround to support 1.20.1 and below
// This causes flicker on these versions which sucks but not sure a better way around this right now.
if (PaperLib.getMinecraftVersion() < 20 ||
(PaperLib.getMinecraftVersion() == 20 && PaperLib.getMinecraftPatchVersion() < 2)) {
ArmorStand armorStand = location.getWorld().spawn(location, ArmorStand.class);
setupArmorStand(armorStand);
return armorStand;
}

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

private static void setupArmorStand(ArmorStand armorStand) {
Expand Down

0 comments on commit 01075ff

Please sign in to comment.