Skip to content
Draft
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
13 changes: 8 additions & 5 deletions src/main/java/io/github/pylonmc/pylon/base/BaseItems.java
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import io.papermc.paper.datacomponent.item.*;
import io.papermc.paper.datacomponent.item.consumable.ConsumeEffect;
import io.papermc.paper.datacomponent.item.consumable.ItemUseAnimation;
import io.papermc.paper.registry.keys.SoundEventKeys;
import io.papermc.paper.registry.keys.tags.DamageTypeTagKeys;
import net.kyori.adventure.key.Key;
import org.bukkit.*;
Expand Down Expand Up @@ -1279,14 +1280,16 @@ private BaseItems() {

public static final ItemStack LOUPE = ItemStackBuilder.pylon(Material.CLAY_BALL, BaseKeys.LOUPE)
.set(DataComponentTypes.ITEM_MODEL, Material.GLASS_PANE.getKey())
.set(DataComponentTypes.CONSUMABLE, io.papermc.paper.datacomponent.item.Consumable.consumable()
.set(DataComponentTypes.CONSUMABLE, Consumable.consumable()
.animation(ItemUseAnimation.SPYGLASS)
.hasConsumeParticles(false)
.consumeSeconds(3)
.sound(Registry.SOUNDS.getKey(Sound.BLOCK_AMETHYST_CLUSTER_HIT))
.consumeSeconds(Settings.get(BaseKeys.LOUPE).getOrThrow("use-ticks", ConfigAdapter.INT) / 20.0F)
.sound(SoundEventKeys.INTENTIONALLY_EMPTY)
)
.set(DataComponentTypes.USE_COOLDOWN, UseCooldown.useCooldown(
Settings.get(BaseKeys.LOUPE).getOrThrow("cooldown-ticks", ConfigAdapter.INT))
.cooldownGroup(BaseKeys.LOUPE)
)
.set(DataComponentTypes.USE_COOLDOWN, UseCooldown.useCooldown(1)
.cooldownGroup(BaseKeys.LOUPE.key()))
.build();
static {
PylonItem.register(Loupe.class, LOUPE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,17 @@
import com.mojang.brigadier.context.CommandContext;
import com.mojang.brigadier.tree.LiteralCommandNode;
import io.github.pylonmc.pylon.base.content.machines.fluid.PortableFluidTank;
import io.github.pylonmc.pylon.base.content.science.Loupe;
import io.github.pylonmc.pylon.core.command.RegistryCommandArgument;
import io.github.pylonmc.pylon.core.fluid.PylonFluid;
import io.github.pylonmc.pylon.core.item.PylonItem;
import io.github.pylonmc.pylon.core.registry.PylonRegistry;
import io.papermc.paper.command.brigadier.CommandSourceStack;
import io.papermc.paper.command.brigadier.Commands;
import io.papermc.paper.command.brigadier.argument.ArgumentTypes;
import io.papermc.paper.command.brigadier.argument.resolvers.selector.PlayerSelectorArgumentResolver;
import lombok.experimental.UtilityClass;
import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
Expand All @@ -28,6 +32,13 @@ public class PylonBaseCommand {
.executes(PylonBaseCommand::fillFluid)
)
)
.then(Commands.literal("resetloupedata")
.requires(source -> source.getSender().hasPermission("pylonbase.command.reset_loupe"))
.executes(ctx -> resetLoupe(ctx, null))
.then(Commands.argument("player", ArgumentTypes.player())
.executes(ctx -> resetLoupe(ctx, ctx.getArgument("player", PlayerSelectorArgumentResolver.class).resolve(ctx.getSource()).getFirst()))
)
)
.build();

private int fillFluid(CommandContext<CommandSourceStack> ctx) {
Expand All @@ -52,4 +63,20 @@ private int fillFluid(CommandContext<CommandSourceStack> ctx) {

return Command.SINGLE_SUCCESS;
}

private int resetLoupe(CommandContext<CommandSourceStack> ctx, Player target) {
CommandSender sender = ctx.getSource().getSender();
if (target == null) {
if (!(sender instanceof Player player)) {
sender.sendRichMessage("<red>You must be a player to use this command");
return Command.SINGLE_SUCCESS;
}
target = player;
}

target.getPersistentDataContainer().remove(Loupe.CONSUMED_KEY);
sender.sendRichMessage("<green>Reset loupe data for <target>",
Placeholder.unparsed("target", target.getName()));
return Command.SINGLE_SUCCESS;
}
}
Loading