Added enchanted glow to current color! #v0.3.1

This commit is contained in:
BlueFox 2024-05-21 15:50:08 +02:00
parent c905e8db77
commit 6423fb0d68
4 changed files with 55 additions and 7 deletions

View File

@ -6,7 +6,7 @@
<groupId>de.privacynerd</groupId>
<artifactId>ChatBeautifier</artifactId>
<version>0.3.0</version>
<version>0.3.1</version>
<packaging>jar</packaging>
<name>ChatBeautifier</name>

View File

@ -1,12 +1,16 @@
package de.privacynerd.chatbeautifier.displaynamecolor;
import de.privacynerd.chatbeautifier.utils.ConfigFilenames;
import de.privacynerd.chatbeautifier.utils.FileConfig;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor;
import net.kyori.adventure.text.format.TextColor;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemFlag;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;
import de.privacynerd.chatbeautifier.displaynamecolor.ChatColorUtils;
@ -18,6 +22,11 @@ public class ChooseChatColorGUI {
public Inventory getGUI(Player player) {
Inventory gui = Bukkit.createInventory(player, 45, Component.text("Set chat color (0x01)", NamedTextColor.DARK_GRAY));
int currentColorCodesIndex = -1;
FileConfig chatColorConfig = new FileConfig(ConfigFilenames.chatNameColors);
String uuidStr = player.getUniqueId().toString();
if ( chatColorConfig.contains(uuidStr) ) currentColorCodesIndex = chatColorConfig.getInt(uuidStr);
// create item stacks to be filled into the gui later
ItemStack nothing = new ItemStack(Material.LIGHT_BLUE_STAINED_GLASS_PANE); // for filling the gaps
@ -26,7 +35,7 @@ public class ChooseChatColorGUI {
ArrayList<TextColor> chooseColorCodes = ChatColorUtils.getChooseColorCodes();
for (int i=0; i<15; i++) {
ItemMeta color_meta = nothing.getItemMeta();
ItemMeta color_meta = chooseColorItems.get(i).getItemMeta();
if(i==0) { // make it the black text readable
color_meta.displayName(Component.text(chooseColorNames.get(i), NamedTextColor.WHITE));
} else {
@ -50,12 +59,51 @@ public class ChooseChatColorGUI {
}
for (int i=38; i<45; i++) { gui.setItem(i, nothing); }
// now fill the actual selectables
int i1, i2, i3, i4, i5; // indexes
ItemStack is1, is2, is3, is4, is5; // the item stacks
ItemMeta itemMeta; // just to declare it here and fill it later
for(int i=0; i<3; i++) {
gui.setItem(11 + (8 * i) + i, chooseColorItems.get((4 * i) + i));
gui.setItem(11 + (8 * i) + i +1, chooseColorItems.get((4 * i) + i +1));
gui.setItem(11 + (8 * i) + i +2, chooseColorItems.get((4 * i) + i +2));
gui.setItem(11 + (8 * i) + i +3, chooseColorItems.get((4 * i) + i +3));
gui.setItem(11 + (8 * i) + i +4, chooseColorItems.get((4 * i) + i +4));
i1 = (4 * i) + i; is1 = chooseColorItems.get(i1);
i2 = i1 + 1; is2 = chooseColorItems.get(i2);
i3 = i1 + 2; is3 = chooseColorItems.get(i3);
i4 = i1 + 3; is4 = chooseColorItems.get(i4);
i5 = i1 + 4; is5 = chooseColorItems.get(i5);
if(i1 == currentColorCodesIndex) {
itemMeta = is1.getItemMeta();
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.THORNS, 1, true);
is1.setItemMeta(itemMeta);
}
if(i2 == currentColorCodesIndex) {
itemMeta = is2.getItemMeta();
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.THORNS, 1, true);
is2.setItemMeta(itemMeta);
}
if(i3 == currentColorCodesIndex) {
itemMeta = is3.getItemMeta();
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.THORNS, 1, true);
is3.setItemMeta(itemMeta);
}
if(i4 == currentColorCodesIndex) {
itemMeta = is4.getItemMeta();
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.THORNS, 1, true);
is4.setItemMeta(itemMeta);
}
if(i5 == currentColorCodesIndex) {
itemMeta = is5.getItemMeta();
itemMeta.addItemFlags(ItemFlag.HIDE_ENCHANTS);
itemMeta.addEnchant(Enchantment.THORNS, 1, true);
is5.setItemMeta(itemMeta);
}
gui.setItem(11 + (8 * i) + i, is1);
gui.setItem(11 + (8 * i) + i +1, is2);
gui.setItem(11 + (8 * i) + i +2, is3);
gui.setItem(11 + (8 * i) + i +3, is4);
gui.setItem(11 + (8 * i) + i +4, is5);
}
return gui;

Binary file not shown.

Binary file not shown.