Open DereWah opened 1 year ago
Can you send your .lang file?
You have to have a default.lang or LANGUAGE.lang file registered to your addon using SkriptAddon.html#setLanguageFileDirectory(java.lang.String) when registering types
I don't have any lang file created in my project. Should I create one such as
version: 1.3
types:
virtualanvil: anvil gui
and then set the file directory in the addon registration code?
(For the lang file above I followed the lang at https://github.com/ShaneBeee/SkBee/blob/master/src/main/resources/lang/english.lang)
Even with the lang file, the error still exists,but slightly different:
I think I solved the issue: I changed the userInputPattern of the anvil type from "anvil gui" to "virtual anvil" and it seems to now work. Is it because the pattern "anvil gui" is already taken by Skript? I don't see it used but it seems to be the issue.
I've been testing this for the last hour, and I have no clue what's going on. Here's all I tried. Please note that I would like to not change the syntax of the addon, as there are already a lot of skripts that use it published.
types:
anvil: anvil gui¦s
and now only the expression "anvil guis" is recognized. Only the plural, NOT the singular. In the TypeInfo class, I have this:
package org.derewah.skriptanvilgui;
import ch.njol.skript.classes.ClassInfo;
import ch.njol.skript.classes.Parser;
import ch.njol.skript.expressions.base.EventValueExpression;
import ch.njol.skript.lang.ParseContext;
import ch.njol.skript.registrations.Classes;
import net.wesjd.anvilgui.AnvilGUI;
import org.derewah.skriptanvilgui.anvilgui.Anvil;
public class Types {
static {
Classes.registerClass(new ClassInfo<>(Anvil.class, "anvil")
.user("anvil gui[s]")
.defaultExpression(new EventValueExpression<>(Anvil.class))
.name("anvil gui")
.description("Represents an anvil gui.")
.parser(new Parser<Anvil>(){
@Override
public boolean canParse(ParseContext parseContext){
return false;
}
@Override
public String toString(Anvil anvil, int debug){
return anvil.toString();
}
@Override
public String toVariableNameString(Anvil anvil){
return anvil.toString();
}
})
);
}
}
As you can see the allowed input patterns allow for the plural, but because of the lang file only that one gets recognized.
Here is a SimplePropertyExpression that makes use of the anvil TypeInfo.
package org.derewah.skriptanvilgui.expressions;
import ch.njol.skript.classes.Changer.ChangeMode;
import ch.njol.skript.expressions.base.SimplePropertyExpression;
import ch.njol.util.coll.CollectionUtils;
import org.bukkit.event.Event;
import org.derewah.skriptanvilgui.anvilgui.Anvil;
public class ExprAnvilGUITitle extends SimplePropertyExpression<Anvil, String> {
static {
register(ExprAnvilGUITitle.class, String.class, "title", "anvil");
}
@Override
public String convert(Anvil anvil) {
return anvil.getTitle();
}
@Override
public Class<?>[] acceptChange(final ChangeMode mode){
if (mode == ChangeMode.SET) {return CollectionUtils.array(String.class);}
return null;
}
@Override
public void change(Event event, Object[] delta, ChangeMode mode) {
Anvil anvil = getExpr().getSingle(event);
if(anvil != null && delta != null){
anvil.setTitle((String) delta[0]);
}
}
@Override
public Class<? extends String> getReturnType() {
return String.class;
}
@Override
protected String getPropertyName() {
return "title";
}
}
Whenever I use it in an event such as on anvil gui click
, it throws this error on skript reload:
But if I change it to plural, it says
So we have two errors here:
After further investigation, I'm 99% there's already a ClassInfo that occupies the name "anvil gui".
I changed the userInputPattern to a proper regEx "(?:virtual(?: )?)?anvil(?:(?: )?gui)?"
And also I set the lang file to types: virtualanvil: [virtual[ ]]anvil[[ ]gui]
(even tho I think the square brackets are useless now, as the lang file is not for parsing but for errors and formatting (?))
Now, whenever I use "virtual anvil" or "virtualanvil" or "anvil" it works perfectly.
However, when I use "anvilgui" or "anvil gui", it says
I tried running on a server with only Skript and the addon and the error is still there. So it's Skript.
Any updates on this? Anyone has any idea?
Skript/Server Version
Bug Description
I've been trying to update my addon to Skript 2.7, but I am getting an error and i have no idea where that is from.
Note that the addon works perfectly with Skript 2.6.4, it's just the version jump. https://github.com/DereWah/Skript-AnvilGUI here is the source code, the error is
From the code
on anvil gui click: if title of event-anvil gui is "&0Inserisci codice": In the console there are no errors when loading the plugin. It just seems like adding event values has changed since the 2 versions, and I don't know what is the different thing to do Initially I thought the issue was naming the class "anvil", as it would create problems with a possible new existing class, but this error persists even if I call the classinfo virtualanvil or anything different.
Specifically, here's the event class where I register the event values
Expected Behavior
The custom event should have the custom event value registered.
Steps to Reproduce
Add a custom event value with a custom class to an event
Errors or Screenshots
No response
Other
No response
Agreement