NicoNekoDev / AstralBooks

Github repository of CitizensBooks.
https://www.spigotmc.org/resources/citizensbooks.37465/
Apache License 2.0
9 stars 3 forks source link

Request: Save & Open books with command (No NPC Needed) #1

Closed TomLewis closed 6 years ago

TomLewis commented 6 years ago

Hello! I love this plugin! I have so many ideas how to use this plugin, but I need 2 basic things added.

Why? With PlaceholderAPI I should be able to display any details in a book, I want to have a book pop up at the end of a mini-game with information in it, I want to be able to move all my help pages (Commands /help) into books, its much easier to read a book than it is to read through chat. I also have an NPC that opens a custom menu for click items, I want to be able to have one of the items click and open a book (run a command) so then we can use deluxe menus to have multiple forms of Dialogue and custom options, all thats needed is a way to save books without typing them to a NPC and open them with a command.

NicoNekoDev commented 6 years ago

You have first to create an filter and then set a command. Enjoy!

TomLewis commented 6 years ago

How does filter work? I don't get it

NicoNekoDev commented 6 years ago

You need to have a book in your hand and then type /npcbook filter set [filter name]

TomLewis commented 6 years ago

I cant find a way to open the book without giving it to the player? Like when you right click on the NPC it just opens without giving them the book. Something like /npcbook filter openbook [filter name]

The filter seemed to save the book so its half there!

NicoNekoDev commented 6 years ago

Try now with the latest version I just uploaded on spigot.

TomLewis commented 6 years ago

Im sorry, I can't seem to get it to work. What is the command to open a book without giving it to the player? /npcbook openbook gives you a book to edit. it should display a saved book, not give them a physical book. ./npcbook filter getbook gives you the book, but I dont want it to give them a book, I want it to open.

I suggest: /npcbook filter openbook [filter name] And I also suggest a way to list them all /npcbook filter list

NicoNekoDev commented 6 years ago

So, you have to create your own command. After you create a filter, you type /npcbook setcmd [command you want] [filter name] then you use the command you create to open a book without clicking on any NPC.

TomLewis commented 6 years ago

Alright thanks, it didnt work.

[19:09:24 INFO]: GodsDead issued server command: /npcbook setcmd intro welcome
[19:09:26 INFO]: GodsDead issued server command: /intro
[19:09:26 ERROR]: Could not pass event PlayerCommandPreprocessEvent to CitizensBooks v2.2-SNAPSHOT
org.bukkit.event.EventException: null
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Paper-1337]
        at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1337]
        at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1337]
        at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[patched_1.12.2.jar:git-Paper-1337]
        at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand(PlayerConnection.java:1464) ~[patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1277) ~[patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:45) ~[patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a(PacketPlayInChat.java:5) ~[patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1337]
        at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_161]
        at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_161]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [patched_1.12.2.jar:git-Paper-1337]
        at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [patched_1.12.2.jar:git-Paper-1337]
        at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.lang.NullPointerException
        at ro.nicuch.citizensbooks.PlayerActions.event(PlayerActions.java:24) ~[?:?]
        at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor309.execute(Unknown Source) ~[?:?]
        at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1337]
        ... 17 more
NicoNekoDev commented 6 years ago

Can you send me your config file too?

Edit: I can't find why is there a NPE.

Edit2: Should be fixed now. I don't know why Paper-spigot detect Strings in config files as existent if they are not saved, and returning the value null.

TomLewis commented 6 years ago

Ah brilliant! I will give the updated version a try.

TomLewis commented 6 years ago

For some reason, when I put this on my live server (Latest Paper Spigot) I get this error when I try and open a book by right clicking an NPC new or old.

[22:19:19] [Server thread/ERROR]: Could not pass event NPCRightClickEvent to CitizensBooks v2.2-SNAPSHOT
org.bukkit.event.EventException: null
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Paper-1337]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[patched_1.12.2.jar:git-Paper-1337]
    at net.citizensnpcs.EventListen.onPlayerInteractEntity(EventListen.java:415) ~[citizens-2.0.22-SNAPSHOT.jar:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor415.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1337]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[patched_1.12.2.jar:git-Paper-1337]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1662) ~[patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:49) ~[patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:6) ~[patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1337]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_161]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_161]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [patched_1.12.2.jar:git-Paper-1337]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [patched_1.12.2.jar:git-Paper-1337]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.lang.NullPointerException
    at ro.nicuch.citizensbooks.CitizensActions.event(CitizensActions.java:30) ~[CitizensBooks-2.2-SNAPSHOT.jar:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor719.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1337]
    ... 23 more
NicoNekoDev commented 6 years ago

@FrozenBeard the API was loaded last, idk why I missed that. Should be fixed now in the latest version.

TomLewis commented 6 years ago

No sweat, thanks for fixing the bugs, I will report back once tested :)

TomLewis commented 6 years ago

I finally got around to updating it today, but im still getting this error:

[23:16:31] [Server thread/ERROR]: Could not pass event NPCRightClickEvent to CitizensBooks v2.2-SNAPSHOT
org.bukkit.event.EventException: null
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:72) ~[patched_1.12.2.jar:git-Paper-1349]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[patched_1.12.2.jar:git-Paper-1349]
    at net.citizensnpcs.EventListen.onPlayerInteractEntity(EventListen.java:417) ~[citizens-2.0.22-SNAPSHOT.jar:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor416.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1349]
    at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:78) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:515) ~[patched_1.12.2.jar:git-Paper-1349]
    at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:500) ~[patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.PlayerConnection.a(PlayerConnection.java:1662) ~[patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:49) ~[patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.PacketPlayInUseEntity.a(PacketPlayInUseEntity.java:6) ~[patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0(PlayerConnectionUtils.java:14) ~[patched_1.12.2.jar:git-Paper-1349]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [?:1.8.0_161]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266) [?:1.8.0_161]
    at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) [patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.MinecraftServer.D(MinecraftServer.java:843) [patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.DedicatedServer.D(DedicatedServer.java:426) [patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.MinecraftServer.C(MinecraftServer.java:767) [patched_1.12.2.jar:git-Paper-1349]
    at net.minecraft.server.v1_12_R1.MinecraftServer.run(MinecraftServer.java:665) [patched_1.12.2.jar:git-Paper-1349]
    at java.lang.Thread.run(Thread.java:748) [?:1.8.0_161]
Caused by: java.lang.NullPointerException
    at ro.nicuch.citizensbooks.CitizensActions.event(CitizensActions.java:30) ~[CitizensBooks-2.2-SNAPSHOT.jar:?]
    at com.destroystokyo.paper.event.executor.asm.generated.GeneratedEventExecutor720.execute(Unknown Source) ~[?:?]
    at org.bukkit.plugin.EventExecutor$2.execute(EventExecutor.java:70) ~[patched_1.12.2.jar:git-Paper-1349]
    ... 23 more
NicoNekoDev commented 6 years ago

Try deleting config.yml

NicoNekoDev commented 6 years ago

That error makes no sense, on line 30 is a null checking so it can't be. Did I uploaded the wrong jar? I'm gonna see tomorrow.

TomLewis commented 6 years ago

Any luck? I would love to get this working again :)

NicoNekoDev commented 6 years ago

Try now, I uploaded version 2.3. Also the jar file should be smaller in size.

TomLewis commented 6 years ago

The Error messages have disappeared and the book opens when set to a NPC now! So thats great, one issue is that all JSON, click events and hover over effects in a book now no longer work! Here is the book I generated in my inventory working, then there's a screenshot of it attached to an NPC. Hovering a section from the book in my Inv: 2018-03-19_20 02 57

When its set to an NPC, its just plane text no JSON features. 2018-03-19_20 02 51

NicoNekoDev commented 6 years ago

Spigot don't have a good support for books while saving/loading them. I'm gonna look into it, but I'm not gonna guarantee that I'm gonna do it.

TomLewis commented 6 years ago

Thanks. Just so you know I make my books in http://minecraft.tools/en/book.php So it generates a command to spawn them, maybe we could save them using that exact syntax as its used to spawn/generate one?

NicoNekoDev commented 6 years ago

Yes, that's what I want, but it's hard because I don't know the code. It's using NMS (of course I'm gonna use reflections for multiple versions support) and it's hard to read it.