mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-03 14:38:51 +00:00
Add more group formatting options
This commit is contained in:
1 parent
34f138a96b
commit
90fed17d86
3 files changed
+67
No files matched your search
@@ -79,10 +79,14 @@ public abstract class ChatChannel implements ForwardingAudience {
|
|||||||
|
|
||||||
public abstract Boolean honorsRecipientList();
|
public abstract Boolean honorsRecipientList();
|
||||||
|
|
||||||
|
public abstract Boolean permissionGroupMatching();
|
||||||
|
|
||||||
public abstract boolean testContext(ChatUser sender, ChatUser target);
|
public abstract boolean testContext(ChatUser sender, ChatUser target);
|
||||||
|
|
||||||
public abstract Object getContext(String key);
|
public abstract Object getContext(String key);
|
||||||
|
|
||||||
|
public abstract List<String> getGroupOverrides();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return If the player can use this channel.
|
* @return If the player can use this channel.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -175,6 +175,16 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public String getFormat(ChatUser user) {
|
public String getFormat(ChatUser user) {
|
||||||
|
for (String group : this.getGroupOverrides()) {
|
||||||
|
if (userHasGroup(user, group)) {
|
||||||
|
String format = getFormat(group);
|
||||||
|
|
||||||
|
if (format != null) {
|
||||||
|
return format;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (primaryGroupOnly()) {
|
if (primaryGroupOnly()) {
|
||||||
return getPrimaryGroupFormat(user);
|
return getPrimaryGroupFormat(user);
|
||||||
} else {
|
} else {
|
||||||
@@ -182,6 +192,24 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private boolean userHasGroup(ChatUser user, String group) {
|
||||||
|
if (user.isOnline()) {
|
||||||
|
if (carbonChat.getPermission().playerInGroup(user.asPlayer(), group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (carbonChat.getPermission().playerInGroup(null, user.asOfflinePlayer(), group)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (user.isOnline() && this.permissionGroupMatching()) {
|
||||||
|
return user.asPlayer().hasPermission("carbonchat.group." + group);
|
||||||
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
private String getFirstFoundUserFormat(ChatUser user) {
|
private String getFirstFoundUserFormat(ChatUser user) {
|
||||||
String[] playerGroups;
|
String[] playerGroups;
|
||||||
|
|
||||||
@@ -337,6 +365,16 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
return getBoolean("honors-recipient-list");
|
return getBoolean("honors-recipient-list");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Boolean permissionGroupMatching() {
|
||||||
|
return getBoolean("permission-group-matching");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<String> getGroupOverrides() {
|
||||||
|
return getStringList("group-overrides");
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getName() {
|
public String getName() {
|
||||||
String name = getString("name");
|
String name = getString("name");
|
||||||
@@ -451,6 +489,20 @@ public class CarbonChatChannel extends ChatChannel {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private List<String> getStringList(String key) {
|
||||||
|
if (config != null && config.contains(key)) {
|
||||||
|
return config.getStringList(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
ConfigurationSection defaultSection = carbonChat.getConfig().getConfigurationSection("default");
|
||||||
|
|
||||||
|
if (defaultSection != null && defaultSection.contains(key)) {
|
||||||
|
return defaultSection.getStringList(key);
|
||||||
|
}
|
||||||
|
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
|
||||||
private boolean getBoolean(String key) {
|
private boolean getBoolean(String key) {
|
||||||
if (config != null && config.contains(key)) {
|
if (config != null && config.contains(key)) {
|
||||||
return config.getBoolean(key);
|
return config.getBoolean(key);
|
||||||
|
|||||||
@@ -18,6 +18,17 @@ default:
|
|||||||
# Also supports PlaceholderAPI
|
# Also supports PlaceholderAPI
|
||||||
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <reset><gray>» <color><message>'
|
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <reset><gray>» <color><message>'
|
||||||
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<reset><gray>: <color><message>'
|
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<reset><gray>: <color><message>'
|
||||||
|
# The plugin will look for matching group in here when choosing which group to use for formatting
|
||||||
|
# If there are no matches, the plugin will fall back to the primary-group-only option.
|
||||||
|
# It's advised to set this option to [] if you don't want to use this.
|
||||||
|
format-groups:
|
||||||
|
- Owner
|
||||||
|
- Admin
|
||||||
|
- Moderator
|
||||||
|
- VIP
|
||||||
|
# If set to true, players with the permission carbonchat.group.groupname will count has having
|
||||||
|
# The group with the name groupname (carbonchat.group.owner will count has having the group owner)
|
||||||
|
permission-group-matching: false
|
||||||
contexts:
|
contexts:
|
||||||
# -1 to disable, 0 to set to world, 1+ to fully enable
|
# -1 to disable, 0 to set to world, 1+ to fully enable
|
||||||
distance: -1
|
distance: -1
|
||||||
|
|||||||
Reference in new issue
Block a user