Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Skript API changes lore of item #821

Closed
MinecollYT opened this issue Apr 10, 2021 · 6 comments
Closed

[BUG] Skript API changes lore of item #821

MinecollYT opened this issue Apr 10, 2021 · 6 comments
Labels
type: bug Something isn't working

Comments

@MinecollYT
Copy link

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):

  • Server version: paper 1.16.5
  • Client version: fabric 1.16.5
  • Plugin version: 2.2.12

Additional context
Add any other context about the problem here.

@MinecollYT MinecollYT added the type: bug Something isn't working label Apr 10, 2021
@LoneDev6
Copy link
Collaborator

are you using the official itemsadder skript?

@MinecollYT
Copy link
Author

are you using the official itemsadder skript?

yes

@MinecollYT
Copy link
Author

^^ wrong button

@LoneDev6
Copy link
Collaborator

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
Copy link

@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
Copy link
Collaborator

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

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Nov 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants