diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..2fd5a9b
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1 @@
+ALL RIGHTS RESERVED.
\ No newline at end of file
diff --git a/README.md b/README.md
index 8f9c4d0..fb0c076 100644
--- a/README.md
+++ b/README.md
@@ -1,2 +1,23 @@
-# LPC
-A chat formatting plugin for LuckPerms.
+# LPC-Color
+A chat formatting plugin for LuckPerms with support for color and formatting permissions.
+
+
+# Permissions
+> /lpc reload `lpc.reload`
+
+>ColorCodes `lpc.colorcodes`
+
+>Reset `lpc.reset`
+
+>Italics `lpc.italics`
+
+>Strikethrough `lpc.strikethrough`
+
+>Underline `lpc.underline`
+
+>Bold `lpc.bold`
+
+>Magic `lpc.magic`
+
+>RGB Color Codes `lpc.rgbcodes`
+
diff --git a/UNLICENSE b/UNLICENSE
deleted file mode 100644
index 68a49da..0000000
--- a/UNLICENSE
+++ /dev/null
@@ -1,24 +0,0 @@
-This is free and unencumbered software released into the public domain.
-
-Anyone is free to copy, modify, publish, use, compile, sell, or
-distribute this software, either in source code form or as a compiled
-binary, for any purpose, commercial or non-commercial, and by any
-means.
-
-In jurisdictions that recognize copyright laws, the author or authors
-of this software dedicate any and all copyright interest in the
-software to the public domain. We make this dedication for the benefit
-of the public at large and to the detriment of our heirs and
-successors. We intend this dedication to be an overt act of
-relinquishment in perpetuity of all present and future rights to this
-software under copyright law.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
-OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
-ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
-OTHER DEALINGS IN THE SOFTWARE.
-
-For more information, please refer to
diff --git a/pom.xml b/pom.xml
index 9aaac2d..5dc768a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -2,16 +2,16 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
4.0.0
- me.wikmor
- lpc
- LPC
- A chat formatting plugin for LuckPerms.
- 3.6.0
+ dev.noah
+ lpc-color
+ LPC-color
+ A chat formatting plugin for LuckPerms with support for color and formatting permissions.
+ 4.0.0jar
- wikmor
- me.wikmor.lpc.LPC
+ wikmor, noah
+ dev.noah.lpc.LPC1.8UTF-8
@@ -38,7 +38,7 @@
org.spigotmcspigot-api
- 1.19-R0.1-SNAPSHOT
+ 1.20.4-R0.1-SNAPSHOTprovided
@@ -75,8 +75,8 @@
https://mvnrepository.com/artifact/org.apache.maven.plugins/maven-compiler-plugin -->
3.10.1
- ${java.version}
- ${java.version}
+ 8
+ 8
diff --git a/src/main/java/me/wikmor/lpc/LPC.java b/src/main/java/dev/noah/lpc/LPC.java
similarity index 51%
rename from src/main/java/me/wikmor/lpc/LPC.java
rename to src/main/java/dev/noah/lpc/LPC.java
index 2e5765f..2271500 100644
--- a/src/main/java/me/wikmor/lpc/LPC.java
+++ b/src/main/java/dev/noah/lpc/LPC.java
@@ -1,4 +1,4 @@
-package me.wikmor.lpc;
+package dev.noah.lpc;
import me.clip.placeholderapi.PlaceholderAPI;
import net.luckperms.api.LuckPerms;
@@ -40,7 +40,7 @@ public boolean onCommand(final CommandSender sender, final Command command, fina
if (args.length == 1 && "reload".equals(args[0])) {
reloadConfig();
- sender.sendMessage(colorize("&aLPC has been reloaded."));
+ sender.sendMessage(unsafeColorize("&aLPC has been reloaded."));
return true;
}
@@ -55,6 +55,7 @@ public List onTabComplete(final CommandSender sender, final Command comm
return new ArrayList<>();
}
+
@EventHandler(priority = EventPriority.HIGHEST)
public void onChat(final AsyncPlayerChatEvent event) {
final String message = event.getMessage();
@@ -75,17 +76,90 @@ public void onChat(final AsyncPlayerChatEvent event) {
.replace("{username-color}", metaData.getMetaValue("username-color") != null ? metaData.getMetaValue("username-color") : "")
.replace("{message-color}", metaData.getMetaValue("message-color") != null ? metaData.getMetaValue("message-color") : "");
- format = colorize(translateHexColorCodes(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI") ? PlaceholderAPI.setPlaceholders(player, format) : format));
+ format = unsafeColorize(translateHexColorCodes(getServer().getPluginManager().isPluginEnabled("PlaceholderAPI") ? PlaceholderAPI.setPlaceholders(player, format) : format));
- event.setFormat(format.replace("{message}", player.hasPermission("lpc.colorcodes") && player.hasPermission("lpc.rgbcodes")
- ? colorize(translateHexColorCodes(message)) : player.hasPermission("lpc.colorcodes") ? colorize(message) : player.hasPermission("lpc.rgbcodes")
- ? translateHexColorCodes(message) : message).replace("%", "%%"));
+ event.setFormat(format.replace("{message}", colorize(message,player)).replace("%", "%%"));
}
- private String colorize(final String message) {
+ // Old colorize method without any checks
+ private String unsafeColorize(final String message) {
return ChatColor.translateAlternateColorCodes('&', message);
}
+ private String colorize(final String message, Player player) {
+ String output = message;
+ //do each step / color on its own and check for permissions for each step
+ if (player.hasPermission("lpc.colorcodes")) {
+ //translate each color individually
+ output = output.replace("&0", ChatColor.BLACK.toString());
+ output = output.replace("&1", ChatColor.DARK_BLUE.toString());
+ output = output.replace("&2", ChatColor.DARK_GREEN.toString());
+ output = output.replace("&3", ChatColor.DARK_AQUA.toString());
+ output = output.replace("&4", ChatColor.DARK_RED.toString());
+ output = output.replace("&5", ChatColor.DARK_PURPLE.toString());
+ output = output.replace("&6", ChatColor.GOLD.toString());
+ output = output.replace("&7", ChatColor.GRAY.toString());
+ output = output.replace("&8", ChatColor.DARK_GRAY.toString());
+ output = output.replace("&9", ChatColor.BLUE.toString());
+
+ output = output.replace("&a", ChatColor.GREEN.toString());
+ output = output.replace("&A", ChatColor.GREEN.toString());
+
+ output = output.replace("&b", ChatColor.AQUA.toString());
+ output = output.replace("&B", ChatColor.AQUA.toString());
+
+ output = output.replace("&c", ChatColor.RED.toString());
+ output = output.replace("&C", ChatColor.RED.toString());
+
+ output = output.replace("&d", ChatColor.LIGHT_PURPLE.toString());
+ output = output.replace("&D", ChatColor.LIGHT_PURPLE.toString());
+
+ output = output.replace("&e", ChatColor.YELLOW.toString());
+ output = output.replace("&E", ChatColor.YELLOW.toString());
+
+ output = output.replace("&f", ChatColor.WHITE.toString());
+ output = output.replace("&F", ChatColor.WHITE.toString());
+ }
+
+ if (player.hasPermission("lpc.magic")) {
+ //translate magic
+ output = output.replace("&k", ChatColor.MAGIC.toString());
+ output = output.replace("&K", ChatColor.MAGIC.toString());
+ }
+ if(player.hasPermission("lpc.bold")) {
+ //translate bold
+ output = output.replace("&l", ChatColor.BOLD.toString());
+ output = output.replace("&L", ChatColor.BOLD.toString());
+ }
+ if(player.hasPermission("lpc.underline")) {
+ //translate underline
+ output = output.replace("&n", ChatColor.UNDERLINE.toString());
+ output = output.replace("&N", ChatColor.UNDERLINE.toString());
+ }
+ if(player.hasPermission("lpc.italics")) {
+ //translate italics
+ output = output.replace("&o", ChatColor.ITALIC.toString());
+ output = output.replace("&O", ChatColor.ITALIC.toString());
+ }
+ if(player.hasPermission("lpc.strikethrough")) {
+ //translate strikethrough
+ output = output.replace("&m", ChatColor.STRIKETHROUGH.toString());
+ output = output.replace("&M", ChatColor.STRIKETHROUGH.toString());
+
+ }
+ if(player.hasPermission("lpc.reset")){
+ //translate reset
+ output = output.replace("&r", ChatColor.RESET.toString());
+ output = output.replace("&R", ChatColor.RESET.toString());
+ }
+
+ if(player.hasPermission("lpc.rgbcodes")){
+ output = translateHexColorCodes(output);
+ }
+
+ return output;
+ }
+
private String translateHexColorCodes(final String message) {
final char colorChar = ChatColor.COLOR_CHAR;
diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml
index 3627730..d60fb69 100644
--- a/src/main/resources/plugin.yml
+++ b/src/main/resources/plugin.yml
@@ -10,4 +10,33 @@ commands:
lpc:
description: Reload the configuration.
permission: lpc.reload
- usage: "Usage: /lpc reload"
\ No newline at end of file
+ usage: "Usage: /lpc reload"
+
+permissions:
+ lpc.reload:
+ description: Allows the player to reload the configuration.
+ default: op
+ lpc.colorcodes:
+ description: Allows the player to use color codes. (e.g. &a, &b, &c, &d, &e, &f, &0, &1, &2, &3, &4, &5, &6, &7, &8, &9)
+ default: op
+ lpc.reset:
+ description: Allows the player to reset the chat format. (e.g. &r)
+ default: op
+ lpc.bold:
+ description: Allows the player to use bold text. (e.g. &l)
+ default: op
+ lpc.italic:
+ description: Allows the player to use italic text. (e.g. &o)
+ default: op
+ lpc.underline:
+ description: Allows the player to use underline text. (e.g. &n)
+ default: op
+ lpc.strikethrough:
+ description: Allows the player to use strikethrough text. (e.g. &m)
+ default: op
+ lpc.magic:
+ description: Allows the player to use magic text. (e.g. &k)
+ default: op
+ lpc.rgbcodes:
+ description: Allows the player to use RGB color codes. (e.g. ff0000)
+ default: op
\ No newline at end of file