Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@


import net.kyori.adventure.text.Component;
import net.kyori.adventure.util.TriState;
import net.onelitefeather.stardust.StardustPlugin;
import org.bukkit.attribute.Attribute;
import org.bukkit.attribute.AttributeInstance;
Expand All @@ -16,7 +17,7 @@
public class HealCommand {

private static final int DEFAULT_PLAYER_FIRE_TICKS = 0;
private static final boolean DEFAULT_ENTITY_HAS_VISUAL_FIRE = false;
private static final TriState DEFAULT_ENTITY_HAS_VISUAL_FIRE = TriState.FALSE;
private static final int DEFAULT_PLAYER_FOOD_LEVEL = 20;
private static final float DEFAULT_PLAYER_SATURATION_LEVEL = 5.0f;

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package net.onelitefeather.stardust.service;

import io.papermc.paper.event.player.PrePlayerAttackEntityEvent;
import io.papermc.paper.registry.RegistryAccess;
import io.papermc.paper.registry.RegistryKey;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.onelitefeather.stardust.StardustPlugin;
Expand All @@ -15,7 +17,6 @@
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.ItemStack;
import org.bukkit.persistence.PersistentDataType;
import org.bukkit.util.StringUtil;
import org.incendo.cloud.annotation.specifier.Quoted;
import org.incendo.cloud.annotations.Argument;
import org.incendo.cloud.annotations.Command;
Expand All @@ -30,6 +31,8 @@

public class SyncFrogService implements Listener {

private static final Registry<Frog.@NotNull Variant> FROG_REGISTRY = RegistryAccess.registryAccess().getRegistry(RegistryKey.FROG_VARIANT);

private static final String FROG_BUCKET_NAME = "Frog Bucket";
private static final Frog.Variant DEFAULT_VARIANT = Frog.Variant.TEMPERATE;

Expand Down Expand Up @@ -68,7 +71,7 @@ public void handlePlayerInteract(PlayerInteractEvent event) {
var player = event.getPlayer();

var itemStack = event.getItem();
if(itemStack == null) return;
if (itemStack == null) return;

var clickedBlock = event.getClickedBlock();
if (clickedBlock == null) return;
Expand Down Expand Up @@ -171,13 +174,14 @@ private ItemStack createFrogItemStack(int amount, Frog.Variant variant, Componen
container.set(frogVariantKey, PersistentDataType.STRING, frogVariantName(variant));
itemStack.setItemMeta(itemMeta);


return itemStack;
}

private void addFrogBucketToPlayer(Player player, int amount, Component customName, Frog.Variant variant, boolean actionBarMessage) {

var slot = player.getInventory().firstEmpty();
if(slot == -1) {
if (slot == -1) {
player.sendMessage(Component.translatable("plugin.inventory-full").arguments(plugin.getPrefix()));
return;
}
Expand All @@ -200,14 +204,12 @@ private void addFrogBucketToPlayer(Player player, int amount, Component customNa

@NotNull
private Frog.Variant frogVariant(@Nullable String variant) {

if (variant == null) return DEFAULT_VARIANT;

var key = NamespacedKey.fromString(variant.toLowerCase());
if (key == null) return Frog.Variant.TEMPERATE;

var frogVariant = Registry.FROG_VARIANT.get(key);
if (key == null) return DEFAULT_VARIANT;

var frogVariant = FROG_REGISTRY.get(key);
return frogVariant != null ? frogVariant : DEFAULT_VARIANT;
}

Expand All @@ -217,9 +219,8 @@ private String frogVariantName(Frog.Variant variant) {

@Suggestions(value = "frogVariants")
public List<String> frogVariants(CommandContext<CommandSender> context, String input) {
return Registry.FROG_VARIANT.stream()
.map(Frog.Variant::getKey)
.map(NamespacedKey::value)
return FROG_REGISTRY.stream()
.map(variant -> variant.key().value())
.filter(s -> s.startsWith(input))
.toList();
}
Expand Down
Loading