(e.getRecipients()), ChatType.RANGE, rp);
+ UltraChatEvent uce = new UltraChatEvent(p, e.getMessage(), new HashSet<>(e.getRecipients()), ChatType.RANGE, rp);
Bukkit.getServer().getPluginManager().callEvent(uce);
+ e.getRecipients().clear();
if (!uce.isCancelled()) {
for (Player pl : uce.getRecipients()) {
- String form = pf.getLocal()
+ String formats = pf.getLocal()
.replace("%player%", p.getDisplayName())
.replace("%prefix%", pf.getPrefix())
.replace("%suffix%", pf.getSuffix())
+ pf.getColor();
-
+
ComponentBuilder cb = new ComponentBuilder("");
- cb.append(JComponentManager.formatComponents(form, p));
- TextComponent tc = new TextComponent(uce.getMessage());
- cb.append(tc);
+ cb.append(JComponentManager.formatComponents(formats, p));
+ cb.append(ChatUtil.translateColorCodesChat(uce.getMessage(), pf).create(), ComponentBuilder.FormatRetention.NONE);
pl.spigot().sendMessage(cb.create());
}
}
diff --git a/src/me/ryandw11/ultrachat/formatting/UUIDFormating.java b/src/me/ryandw11/ultrachat/formatting/UUIDFormating.java
index c325bc9..4304821 100644
--- a/src/me/ryandw11/ultrachat/formatting/UUIDFormating.java
+++ b/src/me/ryandw11/ultrachat/formatting/UUIDFormating.java
@@ -1,5 +1,6 @@
package me.ryandw11.ultrachat.formatting;
+import java.util.Objects;
import java.util.UUID;
import org.bukkit.Bukkit;
@@ -31,7 +32,7 @@ private UltraChat plugin;
OfflinePlayer op = Bukkit.getOfflinePlayer(ud);
- color = ChatColor.translateAlternateColorCodes('&', plugin.data.getString(ud + ".color"));
+ color = Objects.requireNonNull(plugin.data.getString(ud + ".color"));
try {
prefix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerPrefix(world, op));
suffix = ChatColor.translateAlternateColorCodes('&', plugin.chat.getPlayerSuffix(world, op));
@@ -40,11 +41,11 @@ private UltraChat plugin;
prefix = plugin.chat.getPlayerPrefix(world, op);
suffix = plugin.chat.getPlayerSuffix(world, op);
}
- formatOp = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Custom_Chat.Op_Chat.Format"));
- defaults = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Custom_Chat.Default_Chat.Format"));
- global = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Global.format"));
- this.world = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("World.format"));
- local = ChatColor.translateAlternateColorCodes('&', plugin.getConfig().getString("Local.format"));
+ formatOp = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Op_Chat")));
+ defaults = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Custom_Chat.Default_Chat")));
+ global = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Global.format")));
+ this.world = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("World.format")));
+ local = ChatColor.translateAlternateColorCodes('&', Objects.requireNonNull(plugin.getConfig().getString("Local.format")));
this.op = op;
worldName = world;
}
@@ -88,8 +89,8 @@ private UltraChat plugin;
return defaults;
}
- public String getCustomFormat(int num) {
- return plugin.getConfig().getString("Custom_Chat." + num + ".Format");
+ public String getCustomFormat(String name) {
+ return plugin.getConfig().getString("Custom_Chat.permission_format." + name);
}
public OfflinePlayer getOfflinePlayer() {
@@ -105,13 +106,11 @@ private UltraChat plugin;
UltraChatAPI uapi = new UltraChatAPI();
if(uapi.getChatType() == ChatType.NORMAL) {
if(op.isOp()) return this.getOpFormat();
-
- int i = 1;
- while (i <= plugin.getConfig().getInt("Custom_Chat.Chat_Count")) {
- if (plugin.perms.playerHas(worldName, op, plugin.getConfig().getString("Custom_Chat." + i + ".Permission"))) {
- return this.getCustomFormat(i);
+
+ for (String permission : Objects.requireNonNull(plugin.getConfig().getConfigurationSection("Custom_Chat.permission_format")).getKeys(false)) {
+ if (plugin.perms.playerHas(worldName, op, plugin.getConfig().getString(permission))) {
+ return this.getCustomFormat(permission);
}
- i++;
}
return this.getDefaultFormat();
}
diff --git a/src/me/ryandw11/ultrachat/gui/ColorGUI.java b/src/me/ryandw11/ultrachat/gui/ColorGUI.java
index c266038..d9ea0b1 100644
--- a/src/me/ryandw11/ultrachat/gui/ColorGUI.java
+++ b/src/me/ryandw11/ultrachat/gui/ColorGUI.java
@@ -7,5 +7,5 @@ import org.bukkit.entity.Player;
*
*/
public interface ColorGUI {
- public void openGUI(Player p);
+ void openGUI(Player p);
}
diff --git a/src/me/ryandw11/ultrachat/gui/ColorGUI_1_13_R2.java b/src/me/ryandw11/ultrachat/gui/ColorGUI_1_15_R1.java
similarity index 87%
rename from src/me/ryandw11/ultrachat/gui/ColorGUI_1_13_R2.java
rename to src/me/ryandw11/ultrachat/gui/ColorGUI_1_15_R1.java
index 1e1f004..d0c1277 100644
--- a/src/me/ryandw11/ultrachat/gui/ColorGUI_1_13_R2.java
+++ b/src/me/ryandw11/ultrachat/gui/ColorGUI_1_15_R1.java
@@ -1,5 +1,7 @@
package me.ryandw11.ultrachat.gui;
+import me.ryandw11.ultrachat.UltraChat;
+import me.ryandw11.ultrachat.api.Lang;
import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.Material;
@@ -10,27 +12,25 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.inventory.InventoryClickEvent;
+import org.bukkit.event.inventory.InventoryType;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
-import me.ryandw11.ultrachat.UltraChat;
-import me.ryandw11.ultrachat.api.Lang;
-
/**
* ColorGUI class.
- * Updated for 1.13.
+ * Updated for 1.14-1.15
* @author Ryandw11
*
*/
-public class ColorGUI_1_13_R2 implements CommandExecutor, Listener, ColorGUI{
-
+public class ColorGUI_1_15_R1 implements CommandExecutor, Listener, ColorGUI{
+
private UltraChat plugin;
- public ColorGUI_1_13_R2(){
+ public ColorGUI_1_15_R1(){
plugin = UltraChat.plugin;
}
public void openGUI(Player p){
- Inventory i = Bukkit.createInventory(null, 9*2, Lang.COLOR_GUI.toString());
+ Inventory i = Bukkit.createInventory(null, InventoryType.CHEST, Lang.COLOR_GUI.toString());
ItemStack darkblueitem = new ItemStack(Material.BLUE_WOOL);
ItemMeta darkbluemeta = darkblueitem.getItemMeta();
@@ -79,51 +79,60 @@ public class ColorGUI_1_13_R2 implements CommandExecutor, Listener, ColorGUI{
//==========================================================
- darkbluemeta.setDisplayName("§1Dark Blue Color Chat");
+ darkbluemeta.setDisplayName("§1Dark Blue Color Chat");
darkblueitem.setItemMeta(darkbluemeta);
- greenmeta.setDisplayName("§2Green Color Chat");
+ greenmeta.setDisplayName("§2Green Color Chat");
greenitem.setItemMeta(greenmeta);
- lightbluemeta.setDisplayName("§3Cyan Color Chat");
+ lightbluemeta.setDisplayName("§3Cyan Color Chat");
lightblueitem.setItemMeta(lightbluemeta);
- redmeta.setDisplayName("§4Red Color Chat");
+ redmeta.setDisplayName("§4Red Color Chat");
reditem.setItemMeta(redmeta);
- purplemeta.setDisplayName("§5Purple Color Chat");
+ purplemeta.setDisplayName("§5Purple Color Chat");
purpleitem.setItemMeta(purplemeta);
- goldmeta.setDisplayName("§6Gold Color Chat");
+ goldmeta.setDisplayName("§6Gold Color Chat");
golditem.setItemMeta(goldmeta);
- lightgraymeta.setDisplayName("§7Light Gray Color Chat");
+ lightgraymeta.setDisplayName("§7Light Gray Color Chat");
lightgrayitem.setItemMeta(lightgraymeta);
- graymeta.setDisplayName("§8Gray Color Chat");
+ graymeta.setDisplayName("§8Gray Color Chat");
grayitem.setItemMeta(graymeta);
- bluemeta.setDisplayName("§9Blue Color Chat");
+ bluemeta.setDisplayName("§9Blue Color Chat");
blueitem.setItemMeta(bluemeta);
- lightgreenmeta.setDisplayName("§aLight Green Color Chat");
+ lightgreenmeta.setDisplayName("§aLight Green Color Chat");
lightgreenitem.setItemMeta(lightgreenmeta);
- aquameta.setDisplayName("§bAqua Color Chat");
+ aquameta.setDisplayName("§bAqua Color Chat");
aquaitem.setItemMeta(aquameta);
- lightredmeta.setDisplayName("§cLight Red Color Chat");
+ lightredmeta.setDisplayName("§cLight Red Color Chat");
lightreditem.setItemMeta(lightredmeta);
- pinkmeta.setDisplayName("§dMagenta Color Chat");
+ pinkmeta.setDisplayName("§dMagenta Color Chat");
pinkitem.setItemMeta(pinkmeta);
- yellowmeta.setDisplayName("§eYellow Color Chat");
+ yellowmeta.setDisplayName("§eYellow Color Chat");
yellowitem.setItemMeta(yellowmeta);
- whitemeta.setDisplayName("§fWhite Color Chat");
+ whitemeta.setDisplayName("§fWhite Color Chat");
whiteitem.setItemMeta(whitemeta);
//==========================================================
+
+ ItemStack holder = new ItemStack(Material.GRAY_STAINED_GLASS_PANE, 1);
+ ItemMeta holderM = holder.getItemMeta();
+ holderM.setDisplayName(" ");
+ holder.setItemMeta(holderM);
+
+ for(int o = 15; o < 27; o++) {
+ i.setItem(o, holder);
+ }
i.setItem(0, darkblueitem);
@@ -171,18 +180,24 @@ public class ColorGUI_1_13_R2 implements CommandExecutor, Listener, ColorGUI{
@EventHandler
public void onInventoryClickEvent(InventoryClickEvent e){
- if(!e.getInventory().getTitle().equalsIgnoreCase(Lang.COLOR_GUI.toString())) return;
+ try {
+ if(e.getView() == null || e.getView().getTitle() == null) return;
+ if(!e.getView().getTitle().equalsIgnoreCase(Lang.COLOR_GUI.toString())) return;
+ }catch(IllegalStateException ex) {
+ return;
+ }
Player p = (Player) e.getWhoClicked();
e.setCancelled(true);
if(e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR || !e.getCurrentItem().hasItemMeta()){
- p.closeInventory();
return;
}
//================
ItemStack item = e.getCurrentItem();
+ if(!e.getInventory().contains(item)) return;
+
switch(item.getType()) {
case LAPIS_BLOCK:
if(p.hasPermission("ultrachat.color.blue")){
@@ -341,6 +356,8 @@ public class ColorGUI_1_13_R2 implements CommandExecutor, Listener, ColorGUI{
p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
}
break;
+ case GRAY_STAINED_GLASS_PANE:
+ break;
default:
p.sendMessage(ChatColor.WHITE + "You choose white color chat!");
p.closeInventory();
diff --git a/src/me/ryandw11/ultrachat/gui/ColorGUI_Latest.java b/src/me/ryandw11/ultrachat/gui/ColorGUI_Latest.java
index 727a165..5f707c2 100644
--- a/src/me/ryandw11/ultrachat/gui/ColorGUI_Latest.java
+++ b/src/me/ryandw11/ultrachat/gui/ColorGUI_Latest.java
@@ -20,7 +20,7 @@ import me.ryandw11.ultrachat.api.Lang;
/**
* ColorGUI class.
- * Updated for 1.14+
+ * Updated for 1.16+
* @author Ryandw11
*
*/
@@ -80,49 +80,49 @@ public class ColorGUI_Latest implements CommandExecutor, Listener, ColorGUI{
//==========================================================
- darkbluemeta.setDisplayName("§1Dark Blue Color Chat");
+ darkbluemeta.setDisplayName("�1Dark Blue Color Chat");
darkblueitem.setItemMeta(darkbluemeta);
- greenmeta.setDisplayName("§2Green Color Chat");
+ greenmeta.setDisplayName("�2Green Color Chat");
greenitem.setItemMeta(greenmeta);
- lightbluemeta.setDisplayName("§3Cyan Color Chat");
+ lightbluemeta.setDisplayName("�3Cyan Color Chat");
lightblueitem.setItemMeta(lightbluemeta);
- redmeta.setDisplayName("§4Red Color Chat");
+ redmeta.setDisplayName("�4Red Color Chat");
reditem.setItemMeta(redmeta);
- purplemeta.setDisplayName("§5Purple Color Chat");
+ purplemeta.setDisplayName("�5Purple Color Chat");
purpleitem.setItemMeta(purplemeta);
- goldmeta.setDisplayName("§6Gold Color Chat");
+ goldmeta.setDisplayName("�6Gold Color Chat");
golditem.setItemMeta(goldmeta);
- lightgraymeta.setDisplayName("§7Light Gray Color Chat");
+ lightgraymeta.setDisplayName("�7Light Gray Color Chat");
lightgrayitem.setItemMeta(lightgraymeta);
- graymeta.setDisplayName("§8Gray Color Chat");
+ graymeta.setDisplayName("�8Gray Color Chat");
grayitem.setItemMeta(graymeta);
- bluemeta.setDisplayName("§9Blue Color Chat");
+ bluemeta.setDisplayName("�9Blue Color Chat");
blueitem.setItemMeta(bluemeta);
- lightgreenmeta.setDisplayName("§aLight Green Color Chat");
+ lightgreenmeta.setDisplayName("�aLight Green Color Chat");
lightgreenitem.setItemMeta(lightgreenmeta);
- aquameta.setDisplayName("§bAqua Color Chat");
+ aquameta.setDisplayName("�bAqua Color Chat");
aquaitem.setItemMeta(aquameta);
- lightredmeta.setDisplayName("§cLight Red Color Chat");
+ lightredmeta.setDisplayName("�cLight Red Color Chat");
lightreditem.setItemMeta(lightredmeta);
- pinkmeta.setDisplayName("§dMagenta Color Chat");
+ pinkmeta.setDisplayName("�dMagenta Color Chat");
pinkitem.setItemMeta(pinkmeta);
- yellowmeta.setDisplayName("§eYellow Color Chat");
+ yellowmeta.setDisplayName("�eYellow Color Chat");
yellowitem.setItemMeta(yellowmeta);
- whitemeta.setDisplayName("§fWhite Color Chat");
+ whitemeta.setDisplayName("�fWhite Color Chat");
whiteitem.setItemMeta(whitemeta);
//==========================================================
diff --git a/src/me/ryandw11/ultrachat/gui/ColorGUI_Outdated.java b/src/me/ryandw11/ultrachat/gui/ColorGUI_Outdated.java
deleted file mode 100644
index be8fdf0..0000000
--- a/src/me/ryandw11/ultrachat/gui/ColorGUI_Outdated.java
+++ /dev/null
@@ -1,371 +0,0 @@
-package me.ryandw11.ultrachat.gui;
-
-import org.bukkit.Bukkit;
-import org.bukkit.ChatColor;
-import org.bukkit.DyeColor;
-import org.bukkit.Material;
-import org.bukkit.command.Command;
-import org.bukkit.command.CommandExecutor;
-import org.bukkit.command.CommandSender;
-import org.bukkit.entity.Player;
-import org.bukkit.event.EventHandler;
-import org.bukkit.event.Listener;
-import org.bukkit.event.inventory.InventoryClickEvent;
-import org.bukkit.inventory.Inventory;
-import org.bukkit.inventory.ItemStack;
-import org.bukkit.inventory.meta.ItemMeta;
-import org.bukkit.material.Wool;
-
-import me.ryandw11.ultrachat.UltraChat;
-import me.ryandw11.ultrachat.api.Lang;
-
-/**
- * ColorGUI class.
- * Old and outdated. Only in for compatibility.
- * (When compiling for 1.13+ only it is ok to leave this class out (Just remove references to it in the UltraChat main class))
- * @author Ryandw11
- *
- */
-public class ColorGUI_Outdated implements CommandExecutor, Listener, ColorGUI{
-
- private UltraChat plugin;
- public ColorGUI_Outdated(){
- plugin = UltraChat.plugin;
- }
- @SuppressWarnings("deprecation")
- public void openGUI(Player p){
- Inventory i = Bukkit.createInventory(null, 9*2, Lang.COLOR_GUI.toString());
-
- Wool darkblue = new Wool(DyeColor.BLUE);
- ItemStack darkblueitem = darkblue.toItemStack(1);
- ItemMeta darkbluemeta = darkblueitem.getItemMeta();
-
- Wool green = new Wool(DyeColor.GREEN);
- ItemStack greenitem = green.toItemStack(1);
- ItemMeta greenmeta = greenitem.getItemMeta();
-
- Wool lightblue = new Wool(DyeColor.CYAN);
- ItemStack lightblueitem = lightblue.toItemStack(1);
- ItemMeta lightbluemeta = lightblueitem.getItemMeta();
-
- Wool red = new Wool(DyeColor.RED);
- ItemStack reditem = red.toItemStack(1);
- ItemMeta redmeta = reditem.getItemMeta();
-
- Wool purple = new Wool(DyeColor.PURPLE);
- ItemStack purpleitem = purple.toItemStack(1);
- ItemMeta purplemeta = purpleitem.getItemMeta();
-
- Wool gold = new Wool(DyeColor.ORANGE);
- ItemStack golditem = gold.toItemStack(1);
- ItemMeta goldmeta = golditem.getItemMeta();
-
- ItemStack lightgrayitem = new ItemStack(Material.CLAY);
- ItemMeta lightgraymeta = lightgrayitem.getItemMeta();
-
- Wool gray = new Wool(DyeColor.GRAY);
- ItemStack grayitem = gray.toItemStack(1);
- ItemMeta graymeta = grayitem.getItemMeta();
-
- ItemStack blueitem = new ItemStack(Material.LAPIS_BLOCK);
- ItemMeta bluemeta = blueitem.getItemMeta();
-
- Wool lightgreen = new Wool(DyeColor.LIME);
- ItemStack lightgreenitem = lightgreen.toItemStack(1);
- ItemMeta lightgreenmeta = lightgreenitem.getItemMeta();
-
- Wool aqua = new Wool(DyeColor.LIGHT_BLUE);
- ItemStack aquaitem = aqua.toItemStack(1);
- ItemMeta aquameta = aquaitem.getItemMeta();
-
- Wool lightred = new Wool(DyeColor.PINK);
- ItemStack lightreditem = lightred.toItemStack(1);
- ItemMeta lightredmeta = lightreditem.getItemMeta();
-
- Wool pink = new Wool(DyeColor.MAGENTA);
- ItemStack pinkitem = pink.toItemStack(1);
- ItemMeta pinkmeta = pinkitem.getItemMeta();
-
- Wool yellow = new Wool(DyeColor.YELLOW);
- ItemStack yellowitem = yellow.toItemStack(1);
- ItemMeta yellowmeta = yellowitem.getItemMeta();
-
- Wool white = new Wool(DyeColor.WHITE);
- ItemStack whiteitem = white.toItemStack(1);
- ItemMeta whitemeta = whiteitem.getItemMeta();
-
- //==========================================================
-
- darkbluemeta.setDisplayName("§1Dark Blue Color Chat");
- darkblueitem.setItemMeta(darkbluemeta);
-
- greenmeta.setDisplayName("§2Green Color Chat");
- greenitem.setItemMeta(greenmeta);
-
- lightbluemeta.setDisplayName("§3Cyan Color Chat");
- lightblueitem.setItemMeta(lightbluemeta);
-
- redmeta.setDisplayName("§4Red Color Chat");
- reditem.setItemMeta(redmeta);
-
- purplemeta.setDisplayName("§5Purple Color Chat");
- purpleitem.setItemMeta(purplemeta);
-
- goldmeta.setDisplayName("§6Gold Color Chat");
- golditem.setItemMeta(goldmeta);
-
- lightgraymeta.setDisplayName("§7Light Gray Color Chat");
- lightgrayitem.setItemMeta(lightgraymeta);
-
- graymeta.setDisplayName("§8Gray Color Chat");
- grayitem.setItemMeta(graymeta);
-
- bluemeta.setDisplayName("§9Blue Color Chat");
- blueitem.setItemMeta(bluemeta);
-
- lightgreenmeta.setDisplayName("§aLight Green Color Chat");
- lightgreenitem.setItemMeta(lightgreenmeta);
-
- aquameta.setDisplayName("§bAqua Color Chat");
- aquaitem.setItemMeta(aquameta);
-
- lightredmeta.setDisplayName("§cLight Red Color Chat");
- lightreditem.setItemMeta(lightredmeta);
-
- pinkmeta.setDisplayName("§dMagenta Color Chat");
- pinkitem.setItemMeta(pinkmeta);
-
- yellowmeta.setDisplayName("§eYellow Color Chat");
- yellowitem.setItemMeta(yellowmeta);
-
- whitemeta.setDisplayName("§fWhite Chat");
- whiteitem.setItemMeta(whitemeta);
- //==========================================================
-
-
- i.setItem(0, darkblueitem);
- i.setItem(1, greenitem);
- i.setItem(2, lightblueitem);
- i.setItem(3, reditem);
- i.setItem(4, purpleitem);
- i.setItem(5, golditem);
- i.setItem(6, lightgrayitem);
- i.setItem(7, grayitem);
- i.setItem(8, blueitem);
- i.setItem(9, lightgreenitem);
- i.setItem(10, aquaitem);
- i.setItem(11, lightreditem);
- i.setItem(12, pinkitem);
- i.setItem(13, yellowitem);
- i.setItem(14, whiteitem);
-
-
- p.openInventory(i);
- }
- /*
- * Command
- */
-
- @Override
- public boolean onCommand(CommandSender sender, Command cmd, String s, String[] args) {
- if(!(sender instanceof Player)){
- plugin.getLogger().info("This command is for players only!");
- return true;
- }
- Player p = (Player) sender;
- if(p.hasPermission("ultrachat.color")){
- openGUI(p.getPlayer());
- }
- else{
- p.sendMessage(Lang.NO_PERM.toString());
- }
- return false;
-
- }
- /*
- * Event
- */
-
- @EventHandler
- public void onInventoryClickEvent(InventoryClickEvent e){
- if(!e.getInventory().getName().equalsIgnoreCase(Lang.COLOR_GUI.toString())) return;
-
- Player p = (Player) e.getWhoClicked();
- e.setCancelled(true);
-
- if(e.getCurrentItem() == null || e.getCurrentItem().getType() == Material.AIR || !e.getCurrentItem().hasItemMeta()){
- p.closeInventory();
- return;
- }
- //================
- ItemStack item = e.getCurrentItem();
- @SuppressWarnings("deprecation")
- int data = item.getDurability();
-
- if(item.getType() == Material.LAPIS_BLOCK){
- if(p.hasPermission("ultrachat.color.blue")){
- p.sendMessage(ChatColor.BLUE + "You choose blue chat color!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&9");
- plugin.saveFile();
- }
- else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- }
- else if(item.getType() == Material.CLAY){
- if(p.hasPermission("ultrachat.color.lightgray")){
- p.sendMessage(ChatColor.GRAY + "You choose light gray color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&7");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- }
- else{
-
- switch(data) {
- case 0:
- p.sendMessage(ChatColor.WHITE + "You choose white chat color!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&f");
- plugin.saveFile();
- break;
- case 1:
- if(p.hasPermission("ultrachat.color.gold")){
- p.sendMessage(ChatColor.GOLD + "You choose gold color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&6");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
-
- case 2:
- if(p.hasPermission("ultrachat.color.magenta")){
- p.sendMessage(ChatColor.LIGHT_PURPLE + "You choose magenta color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&d");
- plugin.saveFile();
- }
- else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
-
-
-
- case 3:
- if(p.hasPermission("ultrachat.color.aqua")){
- p.sendMessage(ChatColor.AQUA + "You choose Aqua color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&b");
- plugin.saveFile();
- }
- else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
-
-
-
- case 4:
- if(p.hasPermission("ultrachat.color.yellow")){
- p.sendMessage(ChatColor.YELLOW + "You choose yellow color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&e");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
-
- case 5:
- if(p.hasPermission("ultrachat.color.lightgreen")){
- p.sendMessage(ChatColor.GREEN + "You choose light green color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&a");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 6:
- if(p.hasPermission("ultrachat.color.lightred")){
- p.sendMessage(ChatColor.RED + "You choose light red color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&c");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 7:
- if(p.hasPermission("ultrachat.color.gray")){
- p.sendMessage(ChatColor.DARK_GRAY + "You choose gray color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&8");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 9:
- if(p.hasPermission("ultrachat.color.cyan")){
- p.sendMessage(ChatColor.DARK_AQUA + "You choose cyan color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&3");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 10:
- if(p.hasPermission("ultrachat.color.purple")){
- p.sendMessage(ChatColor.DARK_PURPLE + "You choose purple color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&5");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 11:
- if(p.hasPermission("ultrachat.color.darkblue")){
- p.sendMessage(ChatColor.DARK_BLUE + "You choose dark blue color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&1");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 13:
- if(p.hasPermission("ultrachat.color.green")){
- p.sendMessage(ChatColor.DARK_GREEN + "You choose green color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&2");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- case 14:
- if(p.hasPermission("ultrachat.color.red")){
- p.sendMessage(ChatColor.DARK_RED + "You choose red color chat!");
- p.closeInventory();
- plugin.data.set(p.getUniqueId() + ".color", "&4");
- plugin.saveFile();
- }else{
- p.sendMessage(ChatColor.RED + "You do not have permission for this color!");
- }
- break;
- }
- }
-
- }
-
-
-}
\ No newline at end of file
diff --git a/src/me/ryandw11/ultrachat/util/ChatUtil.java b/src/me/ryandw11/ultrachat/util/ChatUtil.java
new file mode 100644
index 0000000..fbf6c1d
--- /dev/null
+++ b/src/me/ryandw11/ultrachat/util/ChatUtil.java
@@ -0,0 +1,43 @@
+package me.ryandw11.ultrachat.util;
+
+import me.ryandw11.ultrachat.UltraChat;
+import me.ryandw11.ultrachat.formatting.PlayerFormatting;
+import net.md_5.bungee.api.chat.ComponentBuilder;
+import net.md_5.bungee.api.chat.TextComponent;
+import org.bukkit.craftbukkit.libs.org.apache.commons.lang3.tuple.Pair;
+import org.bukkit.entity.Player;
+
+import java.util.List;
+import java.util.Map;
+import java.util.SortedMap;
+
+/**
+ * This is a utility class to make chat easier.
+ */
+public class ChatUtil {
+
+ /**
+ * Translates the message into color codes.
+ * This also translates hex color codes: {#FFFFFF}
+ * @param message The message to translate
+ * @return The translated message.
+ */
+ public static String translateColorCodes(String message){
+ return UltraChat.plugin.chatColorUtil.translateChatColor(message);
+ }
+
+ public static String translateColorCodes(Player p, String message){
+ return UltraChat.plugin.chatColorUtil.translateChatColor(p, message);
+ }
+
+ public static ComponentBuilder translateColorCodesChat(String message, PlayerFormatting pf){
+ Map result = UltraChat.plugin.chatColorUtil.splitColors(message, pf);
+ ComponentBuilder builder = new ComponentBuilder();
+ for(Map.Entry s : result.entrySet()){
+ TextComponent textComponent = new TextComponent(s.getKey());
+ textComponent.setColor(UltraChat.plugin.chatColorUtil.translateChatCode(s.getValue()));
+ builder.append(textComponent);
+ }
+ return builder;
+ }
+}
diff --git a/plugin.yml b/src/plugin.yml
similarity index 100%
rename from plugin.yml
rename to src/plugin.yml