mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
More small bug and config fixes
This commit is contained in:
1 parent
30793f1c72
commit
58477c0b6a
8 files changed
+89
-26
No files matched your search
@@ -102,6 +102,8 @@ public abstract class ChatChannel {
|
||||
return false;
|
||||
}
|
||||
|
||||
public abstract boolean firstMatchingGroup();
|
||||
|
||||
/**
|
||||
* @return If the player can use this channel.
|
||||
*/
|
||||
@@ -148,6 +150,7 @@ public abstract class ChatChannel {
|
||||
public abstract ChatChannel.Builder setShouldForwardFormatting(boolean forwardFormatting);
|
||||
public abstract ChatChannel.Builder setShouldBungee(boolean shouldBungee);
|
||||
public abstract ChatChannel.Builder setFilterEnabled(boolean filterEnabled);
|
||||
public abstract ChatChannel.Builder setFirstMatchingGroup(boolean firstMatchingGroup);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import java.util.Map;
|
||||
|
||||
public class AllianceChatChannel extends SimpleChatChannel {
|
||||
|
||||
AllianceChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, simpleChat);
|
||||
AllianceChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, boolean firstMatchingGroup, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -12,8 +12,8 @@ import java.util.Map;
|
||||
|
||||
public class NationChatChannel extends SimpleChatChannel {
|
||||
|
||||
NationChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, simpleChat);
|
||||
NationChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, boolean firstMatchingGroup, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -9,8 +9,8 @@ import java.util.Map;
|
||||
|
||||
public class PartyChatChannel extends SimpleChatChannel {
|
||||
|
||||
PartyChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, simpleChat);
|
||||
PartyChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, boolean firstMatchingGroup, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -41,6 +41,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
private boolean forwardFormatting;
|
||||
private boolean shouldBungee;
|
||||
private boolean filterEnabled;
|
||||
private boolean firstMatchingGroup;
|
||||
|
||||
private DiscordWebhook discordWebhook = null;
|
||||
|
||||
@@ -50,7 +51,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
private SimpleChatChannel() { }
|
||||
|
||||
SimpleChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
SimpleChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, boolean firstMatchingGroup, SimpleChat simpleChat) {
|
||||
this.color = color;
|
||||
this.id = id;
|
||||
this.formats = formats;
|
||||
@@ -65,6 +66,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
this.forwardFormatting = forwardFormatting;
|
||||
this.shouldBungee = shouldBungee;
|
||||
this.filterEnabled = filterEnabled;
|
||||
this.firstMatchingGroup = firstMatchingGroup;
|
||||
|
||||
this.simpleChat = simpleChat;
|
||||
|
||||
@@ -142,7 +144,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
@Override
|
||||
public void sendMessage(ChatUser user, String message, boolean fromBungee) {
|
||||
// Get player's formatting
|
||||
String messageFormat = getFormat(getGroup(user));
|
||||
String messageFormat = getFormat(user);
|
||||
|
||||
// Call custom chat event
|
||||
ChatFormatEvent formatEvent = new ChatFormatEvent(user, this, messageFormat, message);
|
||||
@@ -220,18 +222,39 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
simpleChat.getPluginMessageManager().sendMessage(this, player, message);
|
||||
}
|
||||
|
||||
private String getGroup(ChatUser user) {
|
||||
if (user.isOnline()) {
|
||||
return simpleChat.getPermission().getPrimaryGroup(user.asPlayer());
|
||||
private String getFormat(ChatUser user) {
|
||||
String group = "default";
|
||||
|
||||
if (!firstMatchingGroup()) {
|
||||
if (user.isOnline()) {
|
||||
group = simpleChat.getPermission().getPrimaryGroup(user.asPlayer());
|
||||
} else {
|
||||
group = simpleChat.getPermission().getPrimaryGroup(null, user.asOfflinePlayer());
|
||||
}
|
||||
} else {
|
||||
return simpleChat.getPermission().getPrimaryGroup(null, user.asOfflinePlayer());
|
||||
String[] groups;
|
||||
|
||||
if (user.isOnline()) {
|
||||
groups = simpleChat.getPermission().getPlayerGroups(user.asPlayer());
|
||||
} else {
|
||||
groups = simpleChat.getPermission().getPlayerGroups(null, user.asOfflinePlayer());
|
||||
}
|
||||
|
||||
for (String entry : groups) {
|
||||
if (formats.containsKey(entry.toLowerCase())) {
|
||||
group = entry;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return getFormat(group);
|
||||
}
|
||||
|
||||
public boolean canPlayerSee(ChatUser sender, ChatUser target) {
|
||||
Player targetPlayer = target.asPlayer();
|
||||
|
||||
if (!targetPlayer.hasPermission("simplechat." + getName().toLowerCase() + ".see")) {
|
||||
if (!targetPlayer.hasPermission("simplechat.channels." + getName() + ".see")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -328,6 +351,11 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
return filterEnabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean firstMatchingGroup() {
|
||||
return firstMatchingGroup;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Pattern> getItemLinkPatterns() {
|
||||
return itemPatterns;
|
||||
@@ -353,6 +381,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
private boolean forwardFormatting = true;
|
||||
private boolean shouldBungee = false;
|
||||
private boolean filterEnabled = true;
|
||||
private boolean firstMatchingGroup = false;
|
||||
|
||||
private Builder() { }
|
||||
|
||||
@@ -362,7 +391,7 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
@Override
|
||||
public SimpleChatChannel build(SimpleChat simpleChat) {
|
||||
return new SimpleChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, simpleChat);
|
||||
return new SimpleChatChannel(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -467,6 +496,13 @@ public class SimpleChatChannel extends ChatChannel {
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Builder setFirstMatchingGroup(boolean firstMatchingGroup) {
|
||||
this.firstMatchingGroup = firstMatchingGroup;
|
||||
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -11,8 +11,8 @@ import java.util.Map;
|
||||
|
||||
public class TownChatChannel extends SimpleChatChannel {
|
||||
|
||||
TownChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, simpleChat);
|
||||
TownChatChannel(TextColor color, long id, Map<String, String> formats, String webhook, boolean isDefault, boolean ignorable, String name, double distance, String switchMessage, String toggleOffMessage, String toggleOnMessage, boolean forwardFormatting, boolean shouldBungee, boolean filterEnabled, boolean firstMatchingGroup, SimpleChat simpleChat) {
|
||||
super(color, id, formats, webhook, isDefault, ignorable, name, distance, switchMessage, toggleOffMessage, toggleOnMessage, forwardFormatting, shouldBungee, filterEnabled, firstMatchingGroup, simpleChat);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -126,6 +126,18 @@ public class ChannelManager {
|
||||
builder.setShouldBungee(defaults.getBoolean("should-bungee"));
|
||||
}
|
||||
|
||||
if (section.contains("filter-enabled")) {
|
||||
builder.setFilterEnabled(section.getBoolean("filter-enabled"));
|
||||
} else if (defaults != null && defaults.contains("filter-enabled")) {
|
||||
builder.setFilterEnabled(defaults.getBoolean("filter-enabled"));
|
||||
}
|
||||
|
||||
if (section.contains("first-matching-group")) {
|
||||
builder.setFirstMatchingGroup(section.getBoolean("first-matching-group"));
|
||||
} else if (defaults != null && defaults.contains("first-matching-group")) {
|
||||
builder.setFirstMatchingGroup(defaults.getBoolean("first-matching-group"));
|
||||
}
|
||||
|
||||
ChatChannel channel = builder.build(simpleChat);
|
||||
|
||||
if (channel.isTownChat() || channel.isNationChat() || channel.isAllianceChat()) {
|
||||
@@ -173,5 +185,4 @@ public class ChannelManager {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -12,22 +12,35 @@ default:
|
||||
toggle-on-message: '<gray>You can now see <color><channel> <gray>chat!'
|
||||
toggle-off-message: '<gray>You can no longer see <color><channel> <gray>chat!'
|
||||
formats:
|
||||
discord-to-mc: '<gray>[<blue>Discord<gray>] <username><white>: <pre><message>' # Placeholders: username, displayname, channel, server, message, primaryrole
|
||||
# Placeholders: username, displayname, channel, server, message, primaryrole
|
||||
# Also supports PlaceholderAPI
|
||||
discord-to-mc: '<gray>[<blue>Discord<gray>] <username><white>: <pre><message>'
|
||||
staff: '<gray>{[%vault_prefix%<gray>]} %player_displayname% <gray>» <white><pre><message>'
|
||||
default: '<gray>[%vault_prefix%<gray>] %player_displayname%<gray>: <white><pre><message>'
|
||||
color: '#FFFFFF' # Removing this option defaults to '#FFFFFF'
|
||||
ignorable: true # Removing this option defaults to 'true'
|
||||
distance: -1 # Set to -1, comment out, or remove to disable distance checking
|
||||
forward-format: true # Removing this option defaults to 'true'. Forces all other servers to use this server's formatting for this channel.
|
||||
should-bungee: true # Removing this option defaults to 'false'. Enables/disables cross server chat for this channel.
|
||||
color: '#FFFFFF'
|
||||
# Can players /toggle this channel and hide its messages?
|
||||
ignorable: true
|
||||
# Set to -1, comment out, or remove to disable distance checking
|
||||
distance: -1
|
||||
# Forces all other servers to use this server's formatting for this channel
|
||||
forward-format: true
|
||||
# Enables/disables cross server chat for this channel
|
||||
should-bungee: true
|
||||
# Determines if this channel should use the highest matching vault group found for formatting
|
||||
first-matching-group: false
|
||||
# Determines if the chat filter is enabled for this channel
|
||||
filter-enabled: true
|
||||
|
||||
channels:
|
||||
global:
|
||||
name: 'Global'
|
||||
aliases: 'global|g'
|
||||
id: '' # Comment out / remove to disable channel bridge
|
||||
webhook: '' # Comment out / remove to disable webhook
|
||||
default: true # Removing this option defaults to 'false'
|
||||
# Discord channel ID for bridging
|
||||
id: -1
|
||||
# Webhook URL for bridging
|
||||
webhook: ''
|
||||
# If this channel is the default channel
|
||||
default: true
|
||||
announcements:
|
||||
name: 'Announcements'
|
||||
formats:
|
||||
|
||||
Reference in new issue
Block a user