mirror of
https://github.com/tjtanjin/QuickTax.git
synced 2024-11-10 04:20:15 +01:00
feat: Add support for hex color code and fix permission nodes
This commit is contained in:
parent
111c8c8909
commit
c3c8243df9
2
pom.xml
2
pom.xml
@ -7,7 +7,7 @@
|
||||
|
||||
<groupId>quicktax</groupId>
|
||||
<artifactId>quicktax</artifactId>
|
||||
<version>1.5.2</version>
|
||||
<version>1.6.0</version>
|
||||
|
||||
<name>QuickTax</name>
|
||||
|
||||
|
@ -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<String> 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("(?<!\\\\)#[a-fA-F0-9]{6}");
|
||||
Matcher matcher = pattern.matcher(message);
|
||||
while (matcher.find()) {
|
||||
String hexCode = message.substring(matcher.start(), matcher.end());
|
||||
String replaceSharp = hexCode.replace('#', 'x');
|
||||
|
||||
char[] ch = replaceSharp.toCharArray();
|
||||
StringBuilder builder = new StringBuilder("");
|
||||
for (char c : ch) {
|
||||
builder.append("&" + c);
|
||||
}
|
||||
|
||||
message = message.replace(hexCode, builder.toString());
|
||||
matcher = pattern.matcher(message);
|
||||
}
|
||||
|
||||
message = message.replace("\\#", "#");
|
||||
return ChatColor.translateAlternateColorCodes('&', message);
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,8 @@
|
||||
prefix: '&6[&bQuickTax&6] '
|
||||
|
||||
# messages that support placeholders have them listed as comments on the right of the message
|
||||
# hexadeciaml color codes are also supported (e.g. #ff0000, #00ff00)
|
||||
# if you need # in your string but not as a color code, escape it with \ (e.g. \#hashtag)
|
||||
|
||||
# general messages
|
||||
reload-success: '&aQuickTax has been reloaded!'
|
||||
@ -61,7 +63,7 @@ no-quicktax-sign-remove-permission: '&cYou do not have permission to break a lea
|
||||
# format for help command
|
||||
help-header: '&b----- &6Commands &b-----'
|
||||
help-body: |
|
||||
&a/quicktax help &b- view a list of help options
|
||||
&a/quicktax help &b- view the list of commands
|
||||
&a/quicktax pay <amount> &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 <amount> &b- add money to the server tax balance
|
||||
&a/quicktax server admin take <amount> &b- take money from the server tax balance
|
||||
&a/quicktax server admin set <amount> &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 <name> &b- view a specific schedule
|
||||
&a/quicktax update &b- manually trigger an update for the leaderboard
|
||||
|
@ -10,4 +10,97 @@ api-version: 1.13
|
||||
commands:
|
||||
quicktax:
|
||||
description: Base command for the plugin
|
||||
aliases: [qt, qtax]
|
||||
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
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user