PluginBugs / Issues-ItemsAdder

Repository used to keep track of issues of my plugin ItemsAdder
https://itemsadder.devs.beer
54 stars 21 forks source link

[BUG] Skript API changes lore of item #821

Closed MinecollYT closed 3 years ago

MinecollYT commented 3 years ago

Describe the bug Skript TuSKe custom lore in gui changes itemsadder lore. I tried to bypass it via executing iagive command, nothing worked.

To Reproduce Steps to reproduce the behavior: Create custom gui with tuske and add a custom lore Setting item slot: format gui slot 10 of player with customitem "emerald_sword_1" with lore " &8● &7Kosten&8: &e%format(2800)% Coins" and "" and "&a&l[!] &fKlicke um das Item zu kaufen&8." and "&c&l[!] &7&nKeine Rückerstattung&r &7möglich&8!" to close then run function buyCI(player, 2800, "emerald_sword_1")

Function:

function buyCI(p: player, preis: integer, i: text):
    wait 0.5 seconds
    if {_p}'s balance is more than or equal to {_preis}:
        if {_p} has enough space for barrier named "sadasdar":
            remove {_preis} from {_p}'s balance
            make console execute command "iagive %{_p}% %{_i}%"
        else:
            send "{@Prefix} &7Dafür hast du &f&lNICHT GENUG PLATZ &7in deinem Inventar&8." to {_p}
    else:
        send "{@Prefix} &7Dafür hast du &f&lNICHT GENUG GELD&8." to {_p}

Expected behavior Don't change item lore

Screenshots Trader/Shop: https://imgur.com/16qEv9J Before: https://imgur.com/a/GnOWiIl After: https://imgur.com/a/FSbbVy4

Info (please complete the following information):

Additional context Add any other context about the problem here.

LoneDev6 commented 3 years ago

are you using the official itemsadder skript?

MinecollYT commented 3 years ago

are you using the official itemsadder skript?

yes

MinecollYT commented 3 years ago

^^ wrong button

LoneDev6 commented 3 years ago

I sincerely have no idea, this is my implementation of the skript api, can you send this issue report to the author of skript?

package dev.lone.itemsadder.api.Skript.implementation.expressions;

import ch.njol.skript.Skript;
import ch.njol.skript.aliases.ItemType;
import ch.njol.skript.doc.Description;
import ch.njol.skript.doc.Examples;
import ch.njol.skript.doc.Name;
import ch.njol.skript.expressions.base.PropertyExpression;
import ch.njol.skript.lang.Expression;
import ch.njol.skript.lang.ExpressionType;
import ch.njol.skript.lang.SkriptParser.ParseResult;
import ch.njol.util.Kleenean;
import dev.lone.itemsadder.Core.Core;
import org.bukkit.event.Event;
import org.bukkit.inventory.ItemStack;
import com.sun.istack.internal.NotNull;

import javax.annotation.Nullable;

@Name("ItemsAdderItem")
@Description("Get an ItemsAdder item by NamespacedID")
@Examples({"give player a customitem itemsadder:ruby",
        "set slot 1 of inventory of player to customitem ruby"})
public class ExprGetCustomItem extends PropertyExpression<String, ItemType>
{

    static
    {
        Skript.registerExpression(ExprGetCustomItem.class, ItemType.class, ExpressionType.SIMPLE, "customitem %string%");
    }

    private Expression<String> itemName;

    @Override
    public boolean init(Expression<?>[] exprs, int i, @NotNull Kleenean kleenean, @NotNull ParseResult parseResult)
    {
        setExpr((Expression<String>) exprs[0]);
        itemName = (Expression<String>) exprs[0];
        return true;
    }

    @NotNull
    @Override
    protected ItemType[] get(@NotNull Event e, @NotNull String[] source)
    {
        String data = this.itemName.getSingle(e);
        ItemStack item = Core.getInstance().getOriginalItemByNamespacedID(data);
        if (item == null)
        {
            return null;
        }
        ItemType itemType = new ItemType(item);
        return new ItemType[]{itemType};
    }

    @NotNull
    @Override
    public Class<? extends ItemType> getReturnType()
    {
        return ItemType.class;
    }

    @NotNull
    @Override
    public String toString(@Nullable Event e, boolean d)
    {
        return "customitem" + itemName.getSingle(e);
    }
}
TPGamesNL commented 3 years ago

@LoneDev6 Because you're using a PropertyExpression you don't have to store itemName, it's stored for you with setExpr, and its value is given by String[] source in the get method. Can you try to see if cloning the itemstack before creating the ItemType fixes the issue?

LoneDev6 commented 3 years ago

I will release an update today, let me know if it works. I clone the item stack now.