PlayerChatEvent.setFormat validation

By: Dinnerbone <dinnerbone@dinnerbone.com>
This commit is contained in:
Bukkit/Spigot 2011-02-09 19:08:45 +00:00
parent f0f2768937
commit 845e8fbc2e

View file

@ -1,6 +1,7 @@
package org.bukkit.event.player;
import java.util.IllegalFormatException;
import org.bukkit.entity.Player;
import org.bukkit.event.Cancellable;
@ -80,6 +81,14 @@ public class PlayerChatEvent extends PlayerEvent implements Cancellable {
* @param format String.Format compatible format string
*/
public void setFormat(final String format) {
// Oh for a better way to do this!
try {
String.format(format, player, message);
} catch (RuntimeException ex) {
ex.fillInStackTrace();
throw ex;
}
this.format = format;
}
}