From c3c8243df9ff39a7dac88e7f9ae6974295f29c03 Mon Sep 17 00:00:00 2001 From: tjtanjin Date: Sat, 30 Dec 2023 14:16:20 +0800 Subject: [PATCH] feat: Add support for hex color code and fix permission nodes --- pom.xml | 2 +- .../quicktax/utils/MessageManager.java | 31 +++++- src/main/resources/en.yml | 8 +- src/main/resources/plugin.yml | 95 ++++++++++++++++++- 4 files changed, 129 insertions(+), 7 deletions(-) diff --git a/pom.xml b/pom.xml index 01da469..6633925 100644 --- a/pom.xml +++ b/pom.xml @@ -7,7 +7,7 @@ quicktax quicktax - 1.5.2 + 1.6.0 QuickTax diff --git a/src/main/java/tk/taverncraft/quicktax/utils/MessageManager.java b/src/main/java/tk/taverncraft/quicktax/utils/MessageManager.java index 21a3816..d2ab3e0 100644 --- a/src/main/java/tk/taverncraft/quicktax/utils/MessageManager.java +++ b/src/main/java/tk/taverncraft/quicktax/utils/MessageManager.java @@ -6,6 +6,8 @@ import java.util.HashMap; import java.util.Set; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; +import java.util.regex.Matcher; +import java.util.regex.Pattern; import org.bukkit.Bukkit; import org.bukkit.ChatColor; @@ -33,8 +35,7 @@ public class MessageManager { Set messageKeysSet = lang.getConfigurationSection("").getKeys(false); for (String messageKey : messageKeysSet) { - messageKeysMap.put(messageKey, ChatColor.translateAlternateColorCodes('&', - lang.get(messageKey).toString() + " ")); + messageKeysMap.put(messageKey, formatMessageColor(lang.get(messageKey).toString() + " ")); } } @@ -313,4 +314,30 @@ public class MessageManager { } return message; } + + /** + * Formats color in chat messages. + * + * @param message message to format + */ + private static String formatMessageColor(String message) { + Pattern pattern = Pattern.compile("(? &b- pay tax to the server &a/quicktax top &b- view tax payer leaderboard &a/quicktax stats &b- view your own tax stats @@ -77,8 +79,8 @@ help-body: | &a/quicktax server admin add &b- add money to the server tax balance &a/quicktax server admin take &b- take money from the server tax balance &a/quicktax server admin set &b- set the server tax balance - &a/quicktax schedule start &b- start tax collection schedule - &a/quicktax schedule stop &b- stop tax collection schedule + &a/quicktax schedule start &b- start tax collection schedules + &a/quicktax schedule stop &b- stop tax collection schedules &a/quicktax schedule view &b- view all schedules &a/quicktax schedule view &b- view a specific schedule &a/quicktax update &b- manually trigger an update for the leaderboard diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 0e588c2..0d77bec 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -10,4 +10,97 @@ api-version: 1.13 commands: quicktax: description: Base command for the plugin - aliases: [qt, qtax] \ No newline at end of file + aliases: [qt, qtax] +permissions: + quicktax.help: + description: View the list of commands + default: op + quicktax.pay: + description: Pay tax to the server + default: op + quicktax.top: + description: View the tax payer leaderboard + default: op + quicktax.stats: + description: View your own tax stats + default: op + quicktax.schedule.view.enabled: + description: View enabled tax collection schedules + default: op + quicktax.stats.others: + description: View a specific player's tax stats + default: op + quicktax.collectall: + description: Collect tax from all players + default: op + quicktax.collectrank: + description: Collect tax from players by rank + default: op + quicktax.collectbal: + description: Collect tax from players by balance + default: op + quicktax.collectactivity: + description: Collect tax from players by activity + default: op + quicktax.collectname: + description: Collect tax from a specific player + default: op + quicktax.server.stats: + description: View the server total tax stats + default: op + quicktax.server.withdraw.self: + description: Withdraw money to self from server tax balance + default: op + quicktax.server.withdraw.others: + description: Withdraw money to specific player from server tax balance + default: op + quicktax.server.admin.add: + description: Add money to the server tax balance + default: op + quicktax.server.admin.take: + description: Remove money from the server tax balance + default: op + quicktax.server.admin.set: + description: Set the server tax balance + default: op + quicktax.schedule.start: + description: Start tax collection schedules + default: op + quicktax.schedule.stop: + description: Stop tax collection schedules + default: op + quicktax.schedule.view.*: + description: View all tax collection schedules + default: op + quicktax.schedule.view.disabled: + description: View disabled tax collection schedules + default: op + quicktax.reload: + description: Reload the plugin + default: op + quicktax.sign.add: + description: Allow creation of leaderboard signs + default: op + quicktax.sign.remove: + description: Allow removal of leaderboard signs + default: op + quicktax.exempt.*: + description: Exempt player from all tax collections + default: op + quicktax.exempt.collectname: + description: Exempt player from tax collection by name + default: op + quicktax.exempt.collectall: + description: Exempt player from tax collection on all players + default: op + quicktax.exempt.collectrank: + description: Exempt player from tax collection by rank + default: op + quicktax.exempt.collectbal: + description: Exempt player from tax collection by balance + default: op + quicktax.exempt.collectactivity: + description: Exempt player from tax collection by activity + default: op + +