Giter Club home page Giter Club logo

fanciful's Introduction

Fanciful Build Status

Lightweight library offering pleasant chat message formatting for Bukkit plugins. A way to get at the good stuff offered by Minecraft 1.7's new chat protocol without dropping down to raw JSON.

Installation

Use Maven. Add the Fanciful dependency entry to your pom.xml.

<dependency>
  <groupId>mkremins</groupId>
  <artifactId>fanciful</artifactId>
  <version>0.4.0-SNAPSHOT</version>
</dependency>

As of October 2017, the Maven repository that formerly hosted Fanciful artifacts has been shut down. You could continue using Fanciful by cloning this GitHub repository, building Fanciful as a JAR, and installing it locally, but this is not recommended unless you know what you're doing.

Usage

See Example.java for a simple example.

Status

Outdated, and largely superseded by newer libraries. No new development or ongoing support. If you're still using Fanciful or looking for something like it, consider one of the following Fanciful-inspired alternatives:

License

MIT License. Hack away.

fanciful's People

Contributors

amoebaman avatar celticminstrel avatar crylegend avatar drtshock avatar ebonjaeger avatar favorlock avatar franga2000 avatar garris0n- avatar glen3b avatar kezz avatar killje avatar minidigger avatar mkremins avatar stealth2800 avatar thefatdemon avatar tzeentchful avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fanciful's Issues

Seems to be broken for latest 1.8.3 Spigot

[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 deseralisation or a clone method

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.

GSON

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.

API for hoverEvent show_entity action

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.

Reconsider use of (obfuscated) field names to obtain reflection instances

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 only private static final Gson field in the class and invoking the fromJson method with your string and the (reflectively obtained) IChatBaseComponent.class. However, that particular instance of Gson uses a type contained in net.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 no v1_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.

API for insertion

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.

"NumberFormatException"

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!

Handling of Bukkit ChatColor

Please integrate handling of org.bukkit.ChatColor so it doesn't make the chat white after a new line.

Thank you!

Spigot 1.7.10 - \n cartridge return?

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.

FUTURE: Add FancyMessage to BookMeta

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

Spigot 1.7.10 - \n cartridge return?

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?

Make 1.8 compatible

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

Send whole server, Fanciful Message

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?

Formatting With New Lines

I like to format my chat messages using the legal section symbol "§" as I can just write it in-line without concatenating and ChatColor.Color or using the .color(ChatColor) method. However, whenever I use it, the formatting always goes blank when the line skips down to a new line.
screenshot_5
screenshot_4

GSON Missing?

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

Sending FancyMessage's

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)

ItemStack JSON don't work with all chars and empty lines (lore).

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)

send(CommandSender) not working

Firstly, No toString()
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.

Text alignment

Is it possible to add a feature allowing for text to be aligned centrally?

Tooltips do not support formatted text

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.

Add a way to send a FancyMessage to multiple players

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)));
  }
}

CB-dependent

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.

Maven Repo down?

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>

Caused by: java.lang.IllegalArgumentException: The value must be specified.

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();

Can't mvn deploy

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.

IllegalArgumentException when using fm.text()

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)

Tooltip with only 1 word in a msg

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

JavaDocs not publicly accessible without downloading source

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.

Multiline Tooltip

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!"

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.