Skip to content

Commit

Permalink
Pequenas melhorias
Browse files Browse the repository at this point in the history
  • Loading branch information
SrBedrock committed Nov 30, 2024
1 parent ee0f47b commit e12e145
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import dev.jorel.commandapi.arguments.TextArgument;
import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases;
import io.th0rgal.oraxen.config.Message;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.ItemUpdater;
Expand Down Expand Up @@ -111,7 +110,7 @@ private CommandAPICommand getGiveCommand() {

for (final Player target : targets) {
for (final ItemStack item : items) {
final Map<Integer, ItemStack> output = target.getInventory().addItem(PapiAliases.setPlaceholders(target, item.clone(), true));
final Map<Integer, ItemStack> output = target.getInventory().addItem(io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases.setPlaceholders(target, item.clone(), true));
if (!output.isEmpty()) {
for (final ItemStack stack : output.values()) {
target.getWorld().dropItem(target.getLocation(), stack);
Expand Down Expand Up @@ -150,7 +149,7 @@ private CommandAPICommand getSimpleGiveCommand() {
}

for (final Player target : targets) {
final Map<Integer, ItemStack> output = target.getInventory().addItem(PapiAliases.setPlaceholders(target, ItemUpdater.updateItem(itemBuilder.build()).clone(), true));
final Map<Integer, ItemStack> output = target.getInventory().addItem(io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases.setPlaceholders(target, ItemUpdater.updateItem(itemBuilder.build()).clone(), true));
if (!output.isEmpty()) {
for (final ItemStack stack : output.values()) {
target.getWorld().dropItem(target.getLocation(), stack);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.NotNull;

import java.util.ArrayList;
import java.util.List;

public class PapiAliases {
Expand All @@ -20,10 +19,14 @@ public static String setPlaceholders(final Player player, final String text) {
return PlaceholderAPI.setPlaceholders(player, text);
}

@NotNull
public static List<String> setPlaceholders(final Player player, final List<String> text) {
return PlaceholderAPI.setPlaceholders(player, text);
}

@NotNull
@Contract("_, _, _ -> param2")
public static ItemStack setPlaceholders(final Player player, @NotNull final ItemStack item, final boolean updateLore) {

if (item.hasItemMeta()) {
final ItemMeta meta = item.getItemMeta();
if (meta.hasDisplayName())
Expand All @@ -36,11 +39,7 @@ public static ItemStack setPlaceholders(final Player player, @NotNull final Item
if (updateLore) {
final List<String> itemLore = meta.getLore();
if (itemLore != null && !itemLore.isEmpty()) {
final List<String> lore = new ArrayList<>();
for (final var line : itemLore) {
lore.add(setPlaceholders(player, line));
}
meta.setLore(lore);
meta.setLore(setPlaceholders(player, itemLore));
}
}
item.setItemMeta(meta);
Expand Down
3 changes: 1 addition & 2 deletions core/src/main/java/io/th0rgal/oraxen/items/ItemUpdater.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import com.jeff_media.persistentdataserializer.PersistentDataSerializer;
import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases;
import io.th0rgal.oraxen.config.Settings;
import io.th0rgal.oraxen.nms.NMSHandlers;
import io.th0rgal.oraxen.utils.AdventureUtils;
Expand Down Expand Up @@ -319,7 +318,7 @@ public static ItemStack updateItem(ItemStack oldItem) {
nmsHandler.consumableComponent(newItem, Optional.ofNullable(nmsHandler.consumableComponent(newItem)).orElse(nmsHandler.consumableComponent(oldItem)))
);

PapiAliases.setPlaceholders(null, newItem, false);
io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases.setPlaceholders(null, newItem, false);
return newItem;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import dev.triumphteam.gui.guis.PaginatedGui;
import io.th0rgal.oraxen.OraxenPlugin;
import io.th0rgal.oraxen.api.OraxenItems;
import io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases;
import io.th0rgal.oraxen.config.Settings;
import io.th0rgal.oraxen.items.ItemBuilder;
import io.th0rgal.oraxen.items.ItemUpdater;
Expand Down Expand Up @@ -99,11 +98,10 @@ private PaginatedGui createSubGUI(final String fileName, final List<ItemBuilder>
if (builder == null) continue;
final ItemStack itemStack = builder.build();
if (ItemUtils.isEmpty(itemStack)) continue;

final GuiItem guiItem = new GuiItem(itemStack);
guiItem.setAction(e -> {
final Player player = (Player) e.getWhoClicked();
player.getInventory().addItem(PapiAliases.setPlaceholders(player, ItemUpdater.updateItem(guiItem.getItemStack().clone()), true));
player.getInventory().addItem(io.th0rgal.oraxen.compatibilities.provided.placeholderapi.PapiAliases.setPlaceholders(player, ItemUpdater.updateItem(guiItem.getItemStack().clone()), true));
});
gui.addItem(guiItem);
}
Expand Down

0 comments on commit e12e145

Please sign in to comment.