Closed starry99 closed 1 year ago
Thanks for reporting! I will look at it later today.
That's intentional. If you return new lines in the function parameter of onFinish
, the api will open these lines on a sign. If you want to close the sign, you have to return null
.
That is also the behaviour described in the Javadoc of that function.
That's intentional. If you return new lines in the function parameter of
onFinish
, the api will open these lines on a sign. If you want to close the sign, you have to returnnull
. That is also the behaviour described in the Javadoc of that function.
Hi, thanks for reply. When I tried with the sample code in Readme.md, the sign still keep blinking.
new SignGUI()
.lines("§6Line 1", null, "§6Line 3")
.line(3, "Line 4")
.type(Material.DARK_OAK_SIGN)
.color(DyeColor.YELLOW)
.stripColor()
.onFinish((p, lines) -> {
if (!lines[1].isEmpty() && !lines[3].isEmpty()) {
player.sendMessage("Line 2: " + lines[1] + "\nLine 4:" + lines[3]);
return null;
} else
// Due to stripColor the sign won't display line 1 and 3 in orange after it has been closed once.
return lines;
}).open(player);
if I change my code to return `null', no sign gui appears.
public void onPlayerJoin(PlayerJoinEvent event) {
Player player = event.getPlayer();
SignGUI s = new SignGUI()
.lines("t", "e", "s", "t")
.onFinish((p, lines) -> {
return null;
}).open(player);
}
Sorry to bother you. I am quite new to minecraft development. Is it okay to use with PlayerJoinEvent
?
FYI, what I try to build is 1) if a user connects to my server, a sign gui pops up 2) the user types some text 3) save the text to my server. (I made a custom log-saving plugin and I'm trying to integrate the sign-gui ) Thanks in advance.
The sample code should do the following: the sign keeps popping up until you wrote something in line 2 and 4. As for your other code, maybe try this:
public void onPlayerJoin(PlayerJoinEvent event) {
Bukkit.getScheduler().runTask(YOUR_MAIN_INSTANCE, () -> {
Player player = event.getPlayer();
SignGUI s = new SignGUI()
.lines("t", "e", "s", "t")
.onFinish((p, lines) -> {
return null;
}).open(player);
});
}
Just tested this code out, it works for me. But your one did not, so the problem was that you tried to open the sign too early. By running it in a BukkitTask in the next tick, you solve that problem.
Don't forget to replace YOUR_MAIN_INSTANCE
by the main instance of your plugin. For example: if that code runs in your main class, you can just replace it with this
.
Thanks a lot! I tried your code but first it failed for me. But interestingly, it worked after I changed 1 tick into 20 tick. Thanks a million!
hi, I installed SignGUI and integrated into my custom plugin.
but SignGUI doesn't show any lines and it keeps blinking. And my mouse cursor is fixed to the center of the sign and I can't type anything.
versions: sign-gui: v1.9.1 test server: paper 1.19.3 (no other plugins)
code: ` @EventHandler public void onPlayerJoin(PlayerJoinEvent event) {
`
thanks in advance.