Add an as bungee method to the Bukkit ChatColor enum

This commit is contained in:
Adam Thomas 2015-07-22 19:00:06 +10:00 committed by Byteflux
parent 23f4ae7bbd
commit aa255563f1

View File

@ -1,4 +1,4 @@
From 26b7703296a3bd3f17e248689e2dc1bd72edc8b8 Mon Sep 17 00:00:00 2001
From 19ad28e2723089c484b88d70248d3c62aa2e2e69 Mon Sep 17 00:00:00 2001
From: md_5 <git@md-5.net>
Date: Sat, 13 Dec 2014 12:59:14 +1100
Subject: [PATCH] BungeeCord Chat API
@ -23,6 +23,250 @@ index dc430c0..f0ceea5 100644
<!-- testing -->
<dependency>
<groupId>junit</groupId>
diff --git a/src/main/java/org/bukkit/ChatColor.java b/src/main/java/org/bukkit/ChatColor.java
index b8872b4..adbae51 100644
--- a/src/main/java/org/bukkit/ChatColor.java
+++ b/src/main/java/org/bukkit/ChatColor.java
@@ -10,95 +10,205 @@ import com.google.common.collect.Maps;
/**
* All supported color values for chat
*/
-public enum ChatColor {
+public enum ChatColor{
/**
* Represents black
*/
- BLACK('0', 0x00),
+ BLACK('0', 0x00) {
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.BLACK;
+ }
+ },
/**
* Represents dark blue
*/
- DARK_BLUE('1', 0x1),
+ DARK_BLUE('1', 0x1){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_BLUE;
+ }
+ },
/**
* Represents dark green
*/
- DARK_GREEN('2', 0x2),
+ DARK_GREEN('2', 0x2){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_GREEN;
+ }
+ },
/**
* Represents dark blue (aqua)
*/
- DARK_AQUA('3', 0x3),
+ DARK_AQUA('3', 0x3){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_AQUA;
+ }
+ },
/**
* Represents dark red
*/
- DARK_RED('4', 0x4),
+ DARK_RED('4', 0x4){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_RED;
+ }
+ },
/**
* Represents dark purple
*/
- DARK_PURPLE('5', 0x5),
+ DARK_PURPLE('5', 0x5){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_PURPLE;
+ }
+ },
/**
* Represents gold
*/
- GOLD('6', 0x6),
+ GOLD('6', 0x6){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.GOLD;
+ }
+ },
/**
* Represents gray
*/
- GRAY('7', 0x7),
+ GRAY('7', 0x7){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.GRAY;
+ }
+ },
/**
* Represents dark gray
*/
- DARK_GRAY('8', 0x8),
+ DARK_GRAY('8', 0x8){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.DARK_GRAY;
+ }
+ },
/**
* Represents blue
*/
- BLUE('9', 0x9),
+ BLUE('9', 0x9){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.BLUE;
+ }
+ },
/**
* Represents green
*/
- GREEN('a', 0xA),
+ GREEN('a', 0xA){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.GREEN;
+ }
+ },
/**
* Represents aqua
*/
- AQUA('b', 0xB),
+ AQUA('b', 0xB){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.AQUA;
+ }
+ },
/**
* Represents red
*/
- RED('c', 0xC),
+ RED('c', 0xC){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.RED;
+ }
+ },
/**
* Represents light purple
*/
- LIGHT_PURPLE('d', 0xD),
+ LIGHT_PURPLE('d', 0xD){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.LIGHT_PURPLE;
+ }
+ },
/**
* Represents yellow
*/
- YELLOW('e', 0xE),
+ YELLOW('e', 0xE){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.YELLOW;
+ }
+ },
/**
* Represents white
*/
- WHITE('f', 0xF),
+ WHITE('f', 0xF){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.WHITE;
+ }
+ },
/**
* Represents magical characters that change around randomly
*/
- MAGIC('k', 0x10, true),
+ MAGIC('k', 0x10, true){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.MAGIC;
+ }
+ },
/**
* Makes the text bold.
*/
- BOLD('l', 0x11, true),
+ BOLD('l', 0x11, true){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.BOLD;
+ }
+ },
/**
* Makes a line appear through the text.
*/
- STRIKETHROUGH('m', 0x12, true),
+ STRIKETHROUGH('m', 0x12, true){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.STRIKETHROUGH;
+ }
+ },
/**
* Makes the text appear underlined.
*/
- UNDERLINE('n', 0x13, true),
+ UNDERLINE('n', 0x13, true){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.UNDERLINE;
+ }
+ },
/**
* Makes the text italic.
*/
- ITALIC('o', 0x14, true),
+ ITALIC('o', 0x14, true){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.ITALIC;
+ }
+ },
/**
* Resets all previous chat colors or formats.
*/
- RESET('r', 0x15);
+ RESET('r', 0x15){
+ @Override
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.RESET;
+ }
+ };
/**
* The special character which prefixes all chat colour codes. Use this if
@@ -125,6 +235,10 @@ public enum ChatColor {
this.toString = new String(new char[] {COLOR_CHAR, code});
}
+ public net.md_5.bungee.api.ChatColor asBungee() {
+ return net.md_5.bungee.api.ChatColor.RESET;
+ };
+
/**
* Gets the char value associated with this color
*
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index 52dd005..20edb77 100644
--- a/src/main/java/org/bukkit/Server.java