Quantcast
Channel: SpigotMC - High Performance Minecraft
Viewing all articles
Browse latest Browse all 128654

String formatting not escaping properly?

$
0
0
The following code in Java:

Code (text):
CommandSender sender = ...;
sender.sendMessage(MessageFormat.format(ChatColor.GRAY + "You do not have the required permission " + ChatColor.RED + "{0}" + ChatColor.GRAY + "!", "herpy.derpy"));
sender.sendMessage(String.format(ChatColor.GRAY + "You do not have the required permission " + ChatColor.RED + "%s" + ChatColor.GRAY + "!", "herpy.derpy"));
produces the following output (using ampersands [&] instead of the utf-8 character):

Code (text):
&7You do not...
String formatting not escaping properly?

Viewing all articles
Browse latest Browse all 128654

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>