Case-insensitive check for game channel owner name comparison, added some comments

This commit is contained in:
Vankka 2022-04-12 11:30:46 +03:00
parent da8ba3d3a6
commit 02121a61f9
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0

View File

@ -183,19 +183,23 @@ public class ChannelConfigHelper {
public BaseChannelConfig get(String ownerName, String channelName) { public BaseChannelConfig get(String ownerName, String channelName) {
if (ownerName != null) { if (ownerName != null) {
ownerName = ownerName.toLowerCase(Locale.ROOT); ownerName = ownerName.toLowerCase(Locale.ROOT);
// Check if there is a channel defined like this: "owner:channel"
BaseChannelConfig config = findChannel(ownerName + ":" + channelName); BaseChannelConfig config = findChannel(ownerName + ":" + channelName);
if (config != null) { if (config != null) {
return config; return config;
} }
// Check if this owner has the highest priority for this channel name
GameChannel gameChannel = nameToChannelCache.get(channelName); GameChannel gameChannel = nameToChannelCache.get(channelName);
if (gameChannel != null && gameChannel.getOwnerName().equals(ownerName)) { if (gameChannel != null && gameChannel.getOwnerName().equalsIgnoreCase(ownerName)) {
config = findChannel(channelName); config = findChannel(channelName);
return config; return config;
} }
return null; return null;
} }
// Get the highest priority owner for this channel name and relookup
GameChannel gameChannel = nameToChannelCache.get(channelName); GameChannel gameChannel = nameToChannelCache.get(channelName);
return gameChannel != null ? get(gameChannel) : null; return gameChannel != null ? get(gameChannel) : null;
} }