mkremins / fanciful Goto Github PK
View Code? Open in Web Editor NEWFancy Bukkit message formatting
License: MIT License
Fancy Bukkit message formatting
License: MIT License
Copied from @glen3b's comment on commit 62978b7:
Obfuscation changes, so your code must adapt. Many fields and methods in CB/NMS are not obfuscated, but many are. When I am accessing these obfuscated members, I take pains to not get them by name. @aadnk does too in ProtocolLib so that his code is less likely to break on updates. For example, the method you get here looks like it is the only method in its class which is static, returns an
IChatBaseComponent
, and accepts a single string. If you search by those criteria, your code is less likely to break on updates. For this particular instance, since the method is a one-liner, you might be better off reflectively obtaining the onlyprivate static final Gson
field in the class and invoking thefromJson
method with your string and the (reflectively obtained)IChatBaseComponent.class
. However, that particular instance ofGson
uses a type contained innet.minecraft.util.
..., which requires CraftBukkit to build, but is not versioned. This means that if you build off CraftBukkit, it will not break each update because there's nov1_BLAH_BLAH
in the compiled package name. So, for this instance, you might want to build off of CB (which also lets you use all the JSON goodies embedded in NMU), but you could also access it reflectively.
I get this error when using
FancyMessage message = new FancyMessage()
.text(displayKey)
.color(ChatColor.AQUA)
.then(link)
.color(ChatColor.BLUE)
.style(ChatColor.ITALIC);
if (hyperlink) message.link(link);
if (tooltip != null && tooltip != "") message.tooltip(tooltip).color(ChatColor.AQUA);
return message.toJSONString();
Please integrate handling of org.bukkit.ChatColor
so it doesn't make the chat white after a new line.
Thank you!
I am trying to set a maven dependency in my pom.xml but I am getting this error when I start my server up and run the method that uses the maven dependency: http://pastebin.com/AZrse1PW here is my pom.xml: http://pastebin.com/HHdV6WjF .
Is it possible to add a feature allowing for text to be aligned centrally?
Copied from @glen3b's comment on commit 62978b7:
Cache the reflection instances (the
Method
instances, theField
instances, etc) as local variables: Better to avoid expenses you don't need with each call and only do them once (I use a similiar approach for fields in my library: a lazily initialized global field cache.
Example /tellraw:
/tellraw @a {
text:"Hover.",
hoverEvent:{
action:show_entity,
value:"{name:\"Bob\",type:Creeper,id:00000000-0000-0000-0000-000000000000}"
}
}
Apparently, all keys within value
(name
, type
and id
) are optional.
See this post for details. Basically, we need an API method that allows users to specify "translate"
values for message parts and have them be correctly rendered into the final message JSON.
Fanciful's surface area continues to expand. Having well-written and correctly-formatted Javadocs for public-facing API methods will go a long way towards making Fanciful even more developer-friendly.
Stacktrace:
org.bukkit.command.CommandException: Unhandled exception executing command 'youtubers' in plugin LabMain v0.1
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:46) ~[spigot.jar:git-Spigot-b73910a-726656b]
at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141) ~[spigot.jar:git-Spigot-b73910a-726656b]
at org.bukkit.craftbukkit.v1_8_R1.CraftServer.dispatchCommand(CraftServer.java:646) ~[spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.PlayerConnection.handleCommand(PlayerConnection.java:1115) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.PlayerConnection.a(PlayerConnection.java:950) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:26) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.PacketPlayInChat.a(PacketPlayInChat.java:53) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.PacketHandleTask.run(SourceFile:13) [spigot.jar:git-Spigot-b73910a-726656b]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_51]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_51]
at net.minecraft.server.v1_8_R1.MinecraftServer.z(MinecraftServer.java:696) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.DedicatedServer.z(DedicatedServer.java:316) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.MinecraftServer.y(MinecraftServer.java:634) [spigot.jar:git-Spigot-b73910a-726656b]
at net.minecraft.server.v1_8_R1.MinecraftServer.run(MinecraftServer.java:537) [spigot.jar:git-Spigot-b73910a-726656b]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_51]
Caused by: java.lang.NoClassDefFoundError: com/google/gson/JsonParser
at mkremins.fanciful.FancyMessage.(FancyMessage.java:772) ~[?:?]
at com.thelabmc.labmain.commands.Youtube.onCommand(Youtube.java:35) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-b73910a-726656b]
... 14 more
Caused by: java.lang.ClassNotFoundException: com.google.gson.JsonParser
at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_51]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigot.jar:git-Spigot-b73910a-726656b]
at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigot.jar:git-Spigot-b73910a-726656b]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_51]
at mkremins.fanciful.FancyMessage.(FancyMessage.java:772) ~[?:?]
at com.thelabmc.labmain.commands.Youtube.onCommand(Youtube.java:35) ~[?:?]
at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44) ~[spigot.jar:git-Spigot-b73910a-726656b]
... 14 more
GSON Is missing?
I am building against the new spigot, Also have Google JSON imported.
Says it's on line 772 of FancyMessage.java
Hi, actually when I save the fancyMessage toJSONString() and then i try to load it I just get a NullPointerException.
if I create a potion with e.g.
new ItemStack(373,1, 8621,0)
...and pass that into the itemTooltip method, the tooltip is not respecting the damage value and is just showing a water bottle
What I should see
What I actually see
It does respect data values for block items
Spigot no longer remaps nms libs which is where the GSON you used was. You'll either have to shade it yourself or use the one in craftbukkit (older version I think).
"The lack of remapping libs is intended. It was originally done, but having newer versions was a better idea. (Guava was ~2 years old). It was overlooked as it was assumed NMS plugins weren't going to use them, rather the CB ones" - spigot devs.
Hey, I'm trying to add your great library to my maven project but it seems that the fanciful artifact is missing?
<repository>
<id>fanciful-mvn-repo</id>
<url>http://repo.franga2000.com/artifactory/public</url>
</repository>
<dependency>
<groupId>mkremins</groupId>
<artifactId>fanciful</artifactId>
<version>0.3.1</version>
</dependency>
Seems this has been entirely removed in 0.4.0-SNAPSHOT with no obvious replacement. Is there some new way to do this now?
Im aware about the .send command, but there are only two options, .Send(player) and .send(sender),
Is there a way to broadcast a Fancy Message to the whole server?
Hey!
I really love Fanciful, and I need to make a beginning message,
"§e* (10) ["
And then add more string after that inside of a loop.
But when I do this:
fm.text(API.getUniqueIdentifier().getName(uuid)) .color(ChatColor.YELLOW) .suggest(uuid) .tooltip("§f" + API.getUniqueIdentifier().getName(uuid) + "'s UUID:","§b" + uuid);
It gives an IllegalArgumentException:
[09:00:23] [Server thread/WARN]: java.lang.IllegalArgumentException: The value must be specified.
[09:00:23] [Server thread/WARN]: at com.google.common.base.Preconditions.checkArgument(Preconditions.java:125)
[09:00:23] [Server thread/WARN]: at mkremins.fanciful.TextualComponent$ArbitraryTextTypeComponent.setValue(TextualComponent.java:103)
[09:00:23] [Server thread/WARN]: at mkremins.fanciful.TextualComponent$ArbitraryTextTypeComponent.(TextualComponent.java:85)
[09:00:23] [Server thread/WARN]: at mkremins.fanciful.TextualComponent.rawText(TextualComponent.java:225)
[09:00:23] [Server thread/WARN]: at mkremins.fanciful.FancyMessage.text(FancyMessage.java:90)
[09:00:23] [Server thread/WARN]: at me.Swedz.base.Commands.onCommand(Commands.java:50)
[09:00:23] [Server thread/WARN]: at org.bukkit.command.PluginCommand.execute(PluginCommand.java:44)
[09:00:23] [Server thread/WARN]: at org.bukkit.command.SimpleCommandMap.dispatch(SimpleCommandMap.java:141)
[09:00:23] [Server thread/WARN]: at org.bukkit.craftbukkit.v1_8_R3.CraftServer.dispatchCommand(CraftServer.java:640)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.handleCommand(PlayerConnection.java:1162)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:997)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:45)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.PacketPlayInChat.a(PacketPlayInChat.java:1)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.PlayerConnectionUtils$1.run(SourceFile:13)
[09:00:23] [Server thread/WARN]: at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
[09:00:23] [Server thread/WARN]: at java.util.concurrent.FutureTask.run(FutureTask.java:266)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.SystemUtils.a(SourceFile:44)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.B(MinecraftServer.java:714)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.DedicatedServer.B(DedicatedServer.java:374)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.A(MinecraftServer.java:653)
[09:00:23] [Server thread/WARN]: at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:556)
[09:00:23] [Server thread/WARN]: at java.lang.Thread.run(Thread.java:745)
FancyMessage message = new FancyMessage(ChatColor.GOLD + playerName + ChatColor.GREEN + " is in ").then(ChatColor.GOLD + "[Arena " + arena.getID() + "]");
message.tooltip(ChatColor.GREEN + "World: " + ChatColor.GOLD + arena.getWorldName() + "\n" + ChatColor.GREEN + "Type: " + ChatColor.GOLD + type);
Produces
{"text":"","extra":[{"text":"§6JamsJar§a is in "},{"text":"§6[Arena 1]","hoverEvent":{"action":"show_item","value":"{"id":1,"tag":{"display":{"Name":"\u00A7f§aWorld: §6Vareide1-1","Lore":["§aType: §6Classes"]}}}"}}]}
Formatted:
{
"text": "",
"extra": [
{
"text": "§6JamsJar§a is in "
},
{
"text": "§6[Arena 1]",
"hoverEvent": {
"action": "show_item",
"value": "{\"id\":1,\"tag\":{\"display\":{\"Name\":\"\\\\u00A7f§aWorld: §6Vareide1-1\",\"Lore\":[\"§aType: §6Classes\"]}}}"
}
}
]
}
However when hovering over, it says "Invalid Item!"
This this not compatible with the with spigot 1.8 since they moved Gson around (or removed it?)
I am getting an NoClassDefFoundError:
Caused by: java.lang.NoClassDefFoundError: net/minecraft/util/com/google/gson/Gson
at mkremins.fanciful.FancyMessage.createChatPacket(FancyMessage.java:568) ~[?:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:549) ~[?:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:537) ~[?:?]
I'll search around where it was moved too ;D
If you have empty line in lore, it will be changed to "" (visible in item lore).
If you use "" then you get empty line.
if you use """ then you get "Invalid Item" message.
If you use " then you get "Invalid Item" message.
So parsing " is broken.
(Not tested how that works with Achievements and Statistics)
[15:18:49 INFO]: woutwoot issued server command: /Q Working?
[15:18:54 WARN]: java.lang.ClassNotFoundException: net.minecraft.server.v1_8_R2.ChatSerializer
[15:18:54 WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:91)
[15:18:54 WARN]: at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86)
[15:18:54 WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[15:18:54 WARN]: at java.lang.ClassLoader.loadClass(Unknown Source)
[15:18:54 WARN]: at java.lang.Class.forName0(Native Method)
[15:18:54 WARN]: at java.lang.Class.forName(Unknown Source)
[15:18:54 WARN]: at net.amoebaman.util.Reflection.getNMSClass(Reflection.java:64)
[15:18:54 WARN]: at mkremins.fanciful.FancyMessage.createChatPacket(FancyMessage.java:573)
[15:18:54 WARN]: at mkremins.fanciful.FancyMessage.send(FancyMessage.java:552)
[15:18:54 WARN]: at mkremins.fanciful.FancyMessage.send(FancyMessage.java:599)
[15:18:54 WARN]: at com.woutwoot.tickets.ticket.TicketManager.sendList(TicketManager.java:214)
[15:18:54 WARN]: at com.woutwoot.tickets.tasks.YourTicketsTask.run(YourTicketsTask.java:20)
[15:18:54 WARN]: at org.bukkit.craftbukkit.v1_8_R2.scheduler.CraftTask.run(CraftTask.java:71)
[15:18:54 WARN]: at org.bukkit.craftbukkit.v1_8_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftSchedule
r.java:350)
[15:18:54 WARN]: at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:718)
[15:18:54 WARN]: at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368)
[15:18:54 WARN]: at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651)
[15:18:54 WARN]: at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554)
[15:18:54 WARN]: at java.lang.Thread.run(Unknown Source)
[15:18:54 WARN]: [Tickets] Task #13 for Tickets v1.0 generated an exception
java.lang.NullPointerException
at mkremins.fanciful.FancyMessage.createChatPacket(FancyMessage.java:573) ~[?:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:552) ~[?:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:599) ~[?:?]
at com.woutwoot.tickets.ticket.TicketManager.sendList(TicketManager.java:214) ~[?:?]
at com.woutwoot.tickets.tasks.YourTicketsTask.run(YourTicketsTask.java:20) ~[?:?]
at org.bukkit.craftbukkit.v1_8_R2.scheduler.CraftTask.run(CraftTask.java:71) ~[spigot.jar:git-Spigot-dbe012b
-61ef214]
at org.bukkit.craftbukkit.v1_8_R2.scheduler.CraftScheduler.mainThreadHeartbeat(CraftScheduler.java:350) [spi
got.jar:git-Spigot-dbe012b-61ef214]
at net.minecraft.server.v1_8_R2.MinecraftServer.A(MinecraftServer.java:718) [spigot.jar:git-Spigot-dbe012b-6
1ef214]
at net.minecraft.server.v1_8_R2.DedicatedServer.A(DedicatedServer.java:368) [spigot.jar:git-Spigot-dbe012b-6
1ef214]
at net.minecraft.server.v1_8_R2.MinecraftServer.z(MinecraftServer.java:651) [spigot.jar:git-Spigot-dbe012b-6
1ef214]
at net.minecraft.server.v1_8_R2.MinecraftServer.run(MinecraftServer.java:554) [spigot.jar:git-Spigot-dbe012b
-61ef214]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_40]
Add a way to replace a certain String with a FancyMessagePart
Firstly,
I've narrowed it down to the following:
Calling FancyMessage.send(CommandSender) will lead it to toOldMessageFormat() (in the case of the CommandSender not being a Player, which is true for the ConsoleCommandSender), which then uses a StringBuilder to get a textual representation of the FancyMessage. The issue is that it appends the TextualComponent to the StringBuilder, and it has no toString() that outputs the real text. So, the class and hash code are output instead, creating this issue.
As of writing, the only way to send a FancyMessage to multiple players is to to call send(player)
over and over again with calls toJSONString()
each time. This might produce an overhead that can easily be removed by providing a send-method that takes an Iterable of players that calls toJSONString()
once and sends this result to everybody:
public void send(Iterable<Players> players){
String json = toJSONString();
for (Player player : players) {
((CraftPlayer) player).getHandle().playerConnection.sendPacket(new PacketPlayOutChat(ChatSerializer.a(json)));
}
}
Hi! I love Fanciful, and currently use it in a plugin of mine.
I'm using the following code to run a multi-lined reply, while keeping them all wrapped as 1 long line.
public FancyMessage linkNMS(Player player, String platform) {
String line1 = ChatColor.STRIKETHROUGH + " " + ChatColor.RESET + " " + Main.Tag + ChatColor.RESET + " " + ChatColor.STRIKETHROUGH + " ";
String line2 = "+ " + ChatColor.BLUE + "Update your URL using the command:";
String line3 = "+ " + ChatColor.GREEN + "/yt " + ChatColor.RED + platform + ChatColor.GOLD + " <your link> " + ChatColor.AQUA + "[Click Me!]";
String lb = "\n";
String cmd = "";
String tooltip = "";
if (Main.Strummer.containsKey(player.getName())) {
Streamer strum = Main.Strummer.get(player.getName());
if (platform.equals("youtube")) {
tooltip = "Current Link: " + strum.youtube;
cmd = "/yt " + platform + " http://www.youtube.com/";
}
if (platform.equals("twitch")) {
tooltip = "Current Link: " + strum.twitch;
cmd = "/yt " + platform + " http://www.twitch.tv/";
}
if (platform.equals("twitter")) {
tooltip = "Current Link: " + strum.twitter;
cmd = "/yt " + platform + " http://www.twitter.com/";
}
}
return new FancyMessage(line1).suggest(cmd).tooltip(tooltip).then(lb).then(line2).suggest(cmd).tooltip(tooltip).then(lb).then(line3).suggest(cmd).tooltip(tooltip);
}
and it works just fine.
This isn't an issue in Fanciful per se, but I wanted to document this here in case anyone wonders why the 0.2.1-SNAPSHOT
version of Fanciful isn't yet available from the Maven repo. I'm using GitHub's site-maven-plugin
to publish artifacts to the mvn-repo
branch of this repository, and as of today there's an outstanding issue with site-maven-plugin
that causes it to crash on attempted deploy unless the user has a publicly visible email address on GitHub.
I don't particularly want to make my email public, especially since there exist outstanding but unmerged fixes for the issue upstream. Until one of those fixes gets merged, or until I figure out another workaround, I won't be able to deploy artifacts to the mvn-repo
branch.
I was using this library in one of my plugins, and its been working, but for some reason, it just stopped working and is giving me this error:
02.05 17:23:21 [Server] WARN java.lang.NoSuchFieldException: playerConnection
02.05 17:23:21 [Server] WARN at java.lang.Class.getDeclaredField(Class.java:2070)
02.05 17:23:21 [Server] WARN at net.amoebaman.util.Reflection.getField(Reflection.java:147)
02.05 17:23:21 [Server] WARN at mkremins.fanciful.FancyMessage.send(FancyMessage.java:616)
02.05 17:23:21 [Server] WARN at mkremins.fanciful.FancyMessage.send(FancyMessage.java:605)
02.05 17:23:21 [Server] WARN at me.thatcurlyfry.showitem.Main.onChat(Main.java:159)
02.05 17:23:21 [Server] WARN at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
02.05 17:23:21 [Server] WARN at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
02.05 17:23:21 [Server] WARN at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
02.05 17:23:21 [Server] WARN at java.lang.reflect.Method.invoke(Method.java:498)
02.05 17:23:21 [Server] WARN at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:300)
02.05 17:23:21 [Server] WARN at co.aikar.timings.TimedEventExecutor.execute(TimedEventExecutor.java:74)
02.05 17:23:21 [Server] WARN at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62)
02.05 17:23:21 [Server] WARN at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:501)
02.05 17:23:21 [Server] WARN at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:483)
02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PlayerConnection.chat(PlayerConnection.java:1111)
02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PlayerConnection.a(PlayerConnection.java:1026)
02.05 17:23:21 [Server] WARN at net.minecraft.server.v1_8_R3.PacketPlayInChat$1.run(PacketPlayInChat.java:39)
02.05 17:23:21 [Server] WARN at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
02.05 17:23:21 [Server] WARN at java.util.concurrent.FutureTask.run(FutureTask.java:266)
02.05 17:23:21 [Server] WARN at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
02.05 17:23:21 [Server] WARN at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
02.05 17:23:21 [Server] WARN at java.lang.Thread.run(Thread.java:745)
PS: line 159 in my main class is just fancymessage.send(player)
Just an FYI to anyone still using Fanciful in any of their projects - my Maven repo (repo.stealthyone.com) has been shut down. I would recommend moving to Spigot's ChatComponent API
Since I want to use this a prefix with some nice popups and so on I have to clone it. A deserialisation method that accepts the JSON String generated by toJsonString() would also do the job.
Tooltips in this library do not support formatting (I believe only color, style, and extra, not nested click and hover events), but the JSON format supplied by minecraft does.
Also, from my testing with tellraw and dispatchCommand
, without special handling, newlines are fully-functional in JSON text.
Just saw the new snapshot and saw that you can apply JSON to books. So it would be great to use fanciful for that. Maybe it will work with toJsonString() but we need to keep an eye on that once the api fro 1.8 is released
The JavaDocs for this project are embedded within the source, but cannot be easily viewed in an IDE without downloading the source.
Currently, your solution for the similiar issue of the Maven repository is housing it on a separate branch. Instead of this, I propose that both the JavaDocs and the Maven repository are stored on the gh-pages
branch under their own subdirectories, such that they can be accessed through URLs like http://mkremins.github.io/fanciful/javadocs/ and http://mkremins.github.io/fanciful/repo/, which improves readability.
Hey!
Having some troubles with 1.10, it was working perfectly in 1.9
new FancyMessage("[Accept]")
.color(ChatColor.GREEN)
.command("/acceptduel")
.tooltip("Accept The Duel!")
.then(" ")
.then("[Deny]")
.color(ChatColor.RED)
.command("/denyduel")
.tooltip("Deny The Duel!")
.send(player);
I get an error on .send(player) saying
[13:20:20 WARN]: Argument could not be passed.
java.lang.NumberFormatException: For input string: "R"
Here is the full error
[13:20:20 WARN]: Argument could not be passed.
java.lang.NumberFormatException: For input string: "R"
at java.lang.NumberFormatException.forInputString(Unknown Source) ~[?:1.8.0_65]
at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_65]
at java.lang.Integer.parseInt(Unknown Source) ~[?:1.8.0_65]
at mkremins.fanciful.FancyMessage.createChatPacket(FancyMessage.java:644) ~[Plugin.jar:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:617) [Plugin.jar:?]
at mkremins.fanciful.FancyMessage.send(FancyMessage.java:605) [Plugin.jar:?]
at com.star.MAODueling.MAODueling.main.onClick(main.java:314) [Plugin.jar:?]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_65]
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_65]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_65]
at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:306) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:502) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:487) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.PlayerConnection.a(PlayerConnection.java:1850) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.PacketPlayInWindowClick.a(SourceFile:33) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.PacketPlayInWindowClick.a(SourceFile:10) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.PlayerConnectionUtils$1.run(SourceFile:13) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at java.util.concurrent.Executors$RunnableAdapter.call(Unknown Source) [?:1.8.0_65]
at java.util.concurrent.FutureTask.run(Unknown Source) [?:1.8.0_65]
at net.minecraft.server.v1_10_R1.SystemUtils.a(SourceFile:45) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.MinecraftServer.D(MinecraftServer.java:733) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.DedicatedServer.D(DedicatedServer.java:399) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.MinecraftServer.C(MinecraftServer.java:672) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at net.minecraft.server.v1_10_R1.MinecraftServer.run(MinecraftServer.java:571) [spigot-1.10.jar:git-Spigot-3ccadba-fb568fd]
at java.lang.Thread.run(Unknown Source) [?:1.8.0_65]
Any help? Thanks!
Hey,
Is there a way I can only use .tooltip for 1 word in a list of strings/a msg. If i say in chat "Hey Josh", if i put my cursor over Josh, it will only show the tooltip but when i put it over "Hey", it wont show the tooltip.
Thanks, Josh
look like the same problem as magic where the chatcolor name is underline and the JSON name is underlined with a d at the end
Fanciful is currently dependent on CB being used (or its derivatives). It would be immensely useful if this was not the case. I'm not sure if this is at all possible, but removing the need for OBC and NMS imports would be awesome, since plugins using Fanciful could then run on other Bukkit implementations.
Tested with settings on plugin page, would not build.
Example tellraw:
/tellraw @a {
text:"Click.",
insertion:"Hello there."
}
Shift-clicking on the text "Click." will then append the text "Hello there." to the contents of the recipient's chat input box. This feature is apparently similar and orthogonal to clickEvent
and hoverEvent
.
Currently fanciful does not work with CB1.7.5 due to outdated minecraft imports.
Hi! I love Fanciful, and currently use it in a plugin of mine.
I'm using the following code to run a multi-lined reply, while keeping them all wrapped as 1 long line.
public FancyMessage linkNMS(Player player, String platform) {
String line1 = ChatColor.STRIKETHROUGH + " " + ChatColor.RESET + " " + Main.Tag + ChatColor.RESET + " " + ChatColor.STRIKETHROUGH + " ";
String line2 = "+ " + ChatColor.BLUE + "Update your URL using the command:";
String line3 = "+ " + ChatColor.GREEN + "/yt " + ChatColor.RED + platform + ChatColor.GOLD + " <your link> " + ChatColor.AQUA + "[Click Me!]";
String lb = "\n";
String cmd = "";
String tooltip = "";
if (Main.Strummer.containsKey(player.getName())) {
Streamer strum = Main.Strummer.get(player.getName());
if (platform.equals("youtube")) {
tooltip = "Current Link: " + strum.youtube;
cmd = "/yt " + platform + " http://www.youtube.com/";
}
if (platform.equals("twitch")) {
tooltip = "Current Link: " + strum.twitch;
cmd = "/yt " + platform + " http://www.twitch.tv/";
}
if (platform.equals("twitter")) {
tooltip = "Current Link: " + strum.twitter;
cmd = "/yt " + platform + " http://www.twitter.com/";
}
}
return new FancyMessage(line1).suggest(cmd).tooltip(tooltip).then(lb).then(line2).suggest(cmd).tooltip(tooltip).then(lb).then(line3).suggest(cmd).tooltip(tooltip);
}
In spigot 1.9.4 - the \n works perfectly fine as a line-break option, however when trying to support a 1.7.10 server, it prints a cartridge return. As seen below:
1.7.10 - http://i.imgur.com/shPUcNt.png
1.9.4 - http://i.imgur.com/vWwkRB9.png
These are from the exact same Jar file on both servers.
Additionally to test if it is 1.7.10 Spigot I ran the following command as a debug
if (args[0].equals("fancy")) {
Bukkit.getServer().broadcastMessage("This is a test \nAnother test?" + '\n' + "Cookies");
}
and it works just fine.
I'd rather not send back multiple fanciful messages, as it's pretty cool to have 1 big block that's clickable anywhere on the text, acting as 1 fanciful message, so my questions are the following:
Is there a better way to do this?
Is there a built in line-break option for Fanciful API?
Any idea why I'm getting a cartridge return on 1.7.10 but not 1.9.4?
When creating a FancyMessage, if the string contains a URL it isn't clickable once sent. My request is that the ability to parse these is added.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.