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 {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user