mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
things
This commit is contained in:
1 parent
e263bccbfc
commit
8db4b9532c
63 files changed
+632
-472
No files matched your search
+3
-3
@@ -17,13 +17,13 @@ public class AdventureManager implements MessageProcessor {
|
||||
@NonNull
|
||||
private final FormatType formatType;
|
||||
|
||||
public AdventureManager(@NonNull final AudienceProvider provider, @NonNull final FormatType formatType) {
|
||||
public AdventureManager(final @NonNull AudienceProvider provider, final @NonNull FormatType formatType) {
|
||||
this.provider = provider;
|
||||
this.formatType = formatType;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Component processMessage(@Nullable final String input, @NonNull final String @NonNull ... placeholders) {
|
||||
public @NonNull Component processMessage(@Nullable final String input, final @NonNull String @NonNull ... placeholders) {
|
||||
if (input == null || input.trim().isEmpty()) {
|
||||
return TextComponent.empty();
|
||||
}
|
||||
@@ -41,7 +41,7 @@ public class AdventureManager implements MessageProcessor {
|
||||
}
|
||||
}
|
||||
|
||||
private @NonNull Component processMojang(@NonNull String input, @NonNull final String @NonNull ... placeholders) {
|
||||
private @NonNull Component processMojang(@NonNull String input, final @NonNull String @NonNull ... placeholders) {
|
||||
for (int i = 0; i < placeholders.length; i += 2) {
|
||||
final String placeholder = placeholders[i];
|
||||
final String replacement = placeholders[i + 1];
|
||||
|
||||
+106
@@ -0,0 +1,106 @@
|
||||
package net.draycia.carbon.common.channels;
|
||||
|
||||
import net.draycia.carbon.api.Context;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.regex.Pattern;
|
||||
|
||||
public class ChannelSettings {
|
||||
|
||||
@Nullable
|
||||
public String color() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Context> contexts() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> formats() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String defaultFormatName() {
|
||||
}
|
||||
|
||||
public boolean isDefault() {
|
||||
}
|
||||
|
||||
public boolean ignorable() {
|
||||
}
|
||||
|
||||
public boolean crossServer() {
|
||||
}
|
||||
|
||||
public boolean honorsRecipientList() {
|
||||
}
|
||||
|
||||
public boolean permissionGroupMatching() {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<@NonNull String> groupOverrides() {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public String name() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String messagePrefix() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String switchMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String switchOtherMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String switchFailureMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String cannotIgnoreMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOffMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOnMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOtherOnMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOtherOffMessage() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String cannotUseMessage() {
|
||||
}
|
||||
|
||||
public boolean primaryGroupOnly() {
|
||||
}
|
||||
|
||||
public boolean shouldCancelChatEvent() {
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<@NonNull Pattern> itemLinkPatterns() {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String aliases() {
|
||||
}
|
||||
|
||||
}
|
||||
+3
-3
@@ -18,7 +18,7 @@ public class AliasedChannelCommand {
|
||||
|
||||
private final @NonNull String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<ChatUser> commandManager, @NonNull final ChatChannel chatChannel) {
|
||||
public AliasedChannelCommand(final @NonNull CommandManager<ChatUser> commandManager, final @NonNull ChatChannel chatChannel) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.chatChannel = chatChannel;
|
||||
this.commandName = chatChannel.key();
|
||||
@@ -41,7 +41,7 @@ public class AliasedChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void channel(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
@@ -56,7 +56,7 @@ public class AliasedChannelCommand {
|
||||
user.selectedChannel(this.chatChannel());
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<ChatUser> context) {
|
||||
context.<String>get("message").ifPresent(message -> {
|
||||
final Component component = this.chatChannel().sendMessage(context.getSender(), message, false);
|
||||
|
||||
|
||||
+2
-2
@@ -47,7 +47,7 @@ public class ChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void channel(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
@@ -63,7 +63,7 @@ public class ChannelCommand {
|
||||
user.selectedChannel(channel);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
final String message = context.getRequired("message");
|
||||
|
||||
+6
-6
@@ -22,7 +22,7 @@ public class ChannelListCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ChannelListCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("channellist");
|
||||
@@ -51,11 +51,11 @@ public class ChannelListCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public void toggleSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
public void toggleSelf(final @NonNull CommandContext<ChatUser> context) {
|
||||
this.listAndSend(context.getSender(), context.getSender(), this.carbonChat.channelRegistry().iterator());
|
||||
}
|
||||
|
||||
public void toggleOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
public void toggleOther(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
|
||||
@@ -69,8 +69,8 @@ public class ChannelListCommand {
|
||||
this.listAndSend(sender, user, allChannels);
|
||||
}
|
||||
|
||||
private void listAndSend(@NonNull final ChatUser sender, @NonNull final ChatUser user,
|
||||
@NonNull final Iterator<ChatChannel> allChannels) {
|
||||
private void listAndSend(final @NonNull ChatUser sender, final @NonNull ChatUser user,
|
||||
final @NonNull Iterator<ChatChannel> allChannels) {
|
||||
ChatChannel channel;
|
||||
final List<ChatChannel> canSee = new ArrayList<>();
|
||||
final List<ChatChannel> cannotSee = new ArrayList<>();
|
||||
@@ -110,7 +110,7 @@ public class ChannelListCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private void makeList(@NonNull final Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
private void makeList(final @NonNull Iterator<@NonNull ChatChannel> iterator, final TextComponent.@NonNull Builder list) {
|
||||
final String listSeparator = this.carbonChat.translations().channelListSeparator();
|
||||
// TODO: Larry, why did you double assign the listSeparatorComponent?
|
||||
final Component listSeparatorComponent = TextComponent.of(listSeparator);
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ public class ChatReloadCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ChatReloadCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("chatreload");
|
||||
@@ -33,7 +33,7 @@ public class ChatReloadCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void reloadConfig(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void reloadConfig(final @NonNull CommandContext<ChatUser> context) {
|
||||
this.carbonChat.reloadConfig();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
|
||||
+2
-2
@@ -14,7 +14,7 @@ public class ClearChatCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ClearChatCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("clearchat");
|
||||
@@ -33,7 +33,7 @@ public class ClearChatCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void clearChat(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void clearChat(final @NonNull CommandContext<ChatUser> context) {
|
||||
final String sender = context.getSender().name();
|
||||
final String format = this.carbonChat.moderationSettings().clearChat().message();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n");
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ public class IgnoreCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public IgnoreCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("ignore");
|
||||
@@ -35,7 +35,7 @@ public class IgnoreCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void ignoreUser(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void ignoreUser(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser targetUser = context.getRequired("user");
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MeCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MeCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MeCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("me");
|
||||
@@ -35,7 +35,7 @@ public class MeCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void message(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void message(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
|
||||
final String message = context.<String>getRequired("message").replace("</pre>", "");
|
||||
|
||||
+2
-2
@@ -12,7 +12,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MessageCommand {
|
||||
|
||||
public MessageCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MessageCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
final CommandSettings commandSettings = carbonChat.commandSettingsRegistry().get("message");
|
||||
|
||||
@@ -32,7 +32,7 @@ public class MessageCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessage(final @NonNull CommandContext<ChatUser> context) {
|
||||
context.<ChatUser>getRequired("target")
|
||||
.sendMessage(context.getSender(), context.getRequired("message"));
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class MuteCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MuteCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("mute");
|
||||
@@ -35,7 +35,7 @@ public class MuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void mute(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void mute(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
|
||||
|
||||
+3
-3
@@ -15,7 +15,7 @@ public class NicknameCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public NicknameCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("nickname");
|
||||
@@ -47,7 +47,7 @@ public class NicknameCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void nicknameSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void nicknameSelf(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
String nickname = context.getRequired("nickname");
|
||||
|
||||
@@ -70,7 +70,7 @@ public class NicknameCommand {
|
||||
"user", user.name()));
|
||||
}
|
||||
|
||||
private void nicknameOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void nicknameOther(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser target = context.getRequired("user");
|
||||
String nickname = context.getRequired("nickname");
|
||||
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ public class ReplyCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ReplyCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("reply");
|
||||
@@ -35,7 +35,7 @@ public class ReplyCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void reply(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void reply(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final String input = context.getRequired("message");
|
||||
|
||||
|
||||
+1
-1
@@ -15,7 +15,7 @@ public class SetColorCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SetColorCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("setcolor");
|
||||
|
||||
+2
-2
@@ -15,7 +15,7 @@ public class ShadowMuteCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ShadowMuteCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("shadowmute");
|
||||
@@ -35,7 +35,7 @@ public class ShadowMuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void shadowMute(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void shadowMute(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
|
||||
|
||||
+4
-4
@@ -18,7 +18,7 @@ public class SpyChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SpyChannelCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("spy");
|
||||
@@ -59,7 +59,7 @@ public class SpyChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void spyChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void spyChannel(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel chatChannel = context.getRequired("channel");
|
||||
|
||||
@@ -79,7 +79,7 @@ public class SpyChannelCommand {
|
||||
"color", "<color:" + chatChannel.channelColor(user).toString() + ">", "channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
private void spyWhispers(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void spyWhispers(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
|
||||
final String message;
|
||||
@@ -95,7 +95,7 @@ public class SpyChannelCommand {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "br", "\n"));
|
||||
}
|
||||
|
||||
private void spyEverything(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void spyEverything(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final Boolean shouldSpy = context.getRequired("enabled");
|
||||
|
||||
|
||||
+3
-3
@@ -17,7 +17,7 @@ public class SudoChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SudoChannelCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("sudochannel");
|
||||
@@ -50,7 +50,7 @@ public class SudoChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void otherChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void otherChannel(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
@@ -69,7 +69,7 @@ public class SudoChannelCommand {
|
||||
"player", user.name()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessageOther(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
final String message = context.getRequired("message");
|
||||
|
||||
+3
-3
@@ -16,7 +16,7 @@ public class ToggleCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ToggleCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("toggle");
|
||||
@@ -47,7 +47,7 @@ public class ToggleCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void toggleSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void toggleSelf(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
@@ -69,7 +69,7 @@ public class ToggleCommand {
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
}
|
||||
|
||||
private void toggleOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void toggleOther(final @NonNull CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
+4
-4
@@ -13,22 +13,22 @@ import java.util.function.Consumer;
|
||||
public class EmptyMessageService implements MessageService {
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
public void unregisterMessageListener(final @NonNull String key) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -24,7 +24,7 @@ public class MessageManager {
|
||||
@NonNull
|
||||
private final GsonComponentSerializer gsonSerializer;
|
||||
|
||||
public MessageManager(final @NonNull CarbonChat carbonChat, @NonNull final MessageService messageService) {
|
||||
public MessageManager(final @NonNull CarbonChat carbonChat, final @NonNull MessageService messageService) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.messageService = messageService;
|
||||
this.gsonSerializer = this.carbonChat.messageProcessor().audiences().gsonSerializer();
|
||||
@@ -123,8 +123,8 @@ public class MessageManager {
|
||||
return this.messageService;
|
||||
}
|
||||
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid,
|
||||
@NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid,
|
||||
final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
this.messageService().sendMessage(key, uuid, consumer);
|
||||
}
|
||||
|
||||
|
||||
+5
-5
@@ -10,23 +10,23 @@ public interface RedisListener extends RedisPubSubListener<String, String> {
|
||||
void message(@NonNull String channel, @NonNull String message);
|
||||
|
||||
@Override
|
||||
default void message(@NonNull final String pattern, @NonNull final String channel, @NonNull final String message) {
|
||||
default void message(final @NonNull String pattern, final @NonNull String channel, final @NonNull String message) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void subscribed(@NonNull final String channel, final long count) {
|
||||
default void subscribed(final @NonNull String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void psubscribed(@NonNull final String pattern, final long count) {
|
||||
default void psubscribed(final @NonNull String pattern, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void unsubscribed(@NonNull final String channel, final long count) {
|
||||
default void unsubscribed(final @NonNull String channel, final long count) {
|
||||
}
|
||||
|
||||
@Override
|
||||
default void punsubscribed(@NonNull final String pattern, final long count) {
|
||||
default void punsubscribed(final @NonNull String pattern, final long count) {
|
||||
}
|
||||
|
||||
}
|
||||
+7
-6
@@ -10,6 +10,7 @@ import io.lettuce.core.pubsub.api.sync.RedisPubSubCommands;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.common.utils.RedisCredentials;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.Base64;
|
||||
@@ -39,7 +40,7 @@ public class RedisMessageService implements MessageService {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public RedisMessageService(@NonNull final CarbonChat carbonChat, @NonNull final RedisCredentials credentials) {
|
||||
public RedisMessageService(final @NonNull CarbonChat carbonChat, final @NonNull RedisCredentials credentials) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
final RedisURI.Builder builder = RedisURI.Builder.redis(credentials.host(), credentials.port())
|
||||
@@ -72,7 +73,7 @@ public class RedisMessageService implements MessageService {
|
||||
});
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
private void receiveMessage(final @NonNull UUID uuid, final @NonNull String key, final @NonNull ByteArrayDataInput value) {
|
||||
final ChatUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
@@ -91,19 +92,19 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUUIDMessageListener(final @NonNull String key, final @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userNotLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void unregisterMessageListener(@NonNull final String key) {
|
||||
public void unregisterMessageListener(final @NonNull String key) {
|
||||
this.userLoadedListeners.remove(key);
|
||||
this.userNotLoadedListeners.remove(key);
|
||||
|
||||
@@ -111,7 +112,7 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final String key, @NonNull final UUID uuid, @NonNull final Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
public void sendMessage(final @NonNull String key, final @NonNull UUID uuid, final @NonNull Consumer<@NonNull ByteArrayDataOutput> consumer) {
|
||||
final ByteArrayDataOutput msg = ByteStreams.newDataOutput();
|
||||
|
||||
msg.writeLong(this.serverUUID.getMostSignificantBits());
|
||||
|
||||
+12
-11
@@ -32,13 +32,14 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
private final @NonNull Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
private final @NonNull Type userType;
|
||||
private final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
|
||||
private final @NonNull LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public JSONUserService(@NonNull final Class<? extends ChatUser> userType,
|
||||
@NonNull final CarbonChat carbonChat,
|
||||
@NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier) {
|
||||
public JSONUserService(final @NonNull Class<? extends ChatUser> userType,
|
||||
final @NonNull CarbonChat carbonChat,
|
||||
final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier) {
|
||||
this.userType = userType;
|
||||
this.carbonChat = carbonChat;
|
||||
this.supplier = supplier;
|
||||
@@ -61,7 +62,7 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T wrap(@NonNull final UUID uuid) {
|
||||
public T wrap(final @NonNull UUID uuid) {
|
||||
try {
|
||||
return this.userCache.get(uuid);
|
||||
} catch (final ExecutionException exception) {
|
||||
@@ -72,25 +73,25 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T wrapIfLoaded(@NonNull final UUID uuid) {
|
||||
public T wrapIfLoaded(final @NonNull UUID uuid) {
|
||||
return this.userCache.getIfPresent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T refreshUser(@NonNull final UUID uuid) {
|
||||
public T refreshUser(final @NonNull UUID uuid) {
|
||||
this.userCache.invalidate(uuid);
|
||||
|
||||
return this.wrap(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(@NonNull final T user) {
|
||||
public void invalidate(final @NonNull T user) {
|
||||
this.userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(@NonNull final T user) {
|
||||
public void validate(final @NonNull T user) {
|
||||
this.userCache.put(user.uuid(), user);
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
}
|
||||
|
||||
@Nullable
|
||||
private T loadUser(@NonNull final UUID uuid) {
|
||||
private T loadUser(final @NonNull UUID uuid) {
|
||||
final File userFile = new File(this.carbonChat.dataFolder().toFile(), "users/" + uuid.toString() + ".json");
|
||||
this.ensureFileExists(userFile);
|
||||
|
||||
@@ -123,7 +124,7 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
return null;
|
||||
}
|
||||
|
||||
private void saveUser(@NonNull final RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
private void saveUser(final @NonNull RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
final File userFile = new File(this.carbonChat.dataFolder().toFile(), "users/" + notification.getKey().toString() + ".json");
|
||||
this.ensureFileExists(userFile);
|
||||
|
||||
@@ -134,7 +135,7 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureFileExists(@NonNull final File file) {
|
||||
private void ensureFileExists(final @NonNull File file) {
|
||||
if (!file.getParentFile().exists()) {
|
||||
file.getParentFile().mkdirs();
|
||||
}
|
||||
|
||||
+255
@@ -0,0 +1,255 @@
|
||||
package net.draycia.carbon.common.users;
|
||||
|
||||
import co.aikar.idb.DatabaseOptions;
|
||||
import co.aikar.idb.PooledDatabaseOptions;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import co.aikar.idb.DB;
|
||||
import co.aikar.idb.Database;
|
||||
import co.aikar.idb.DbRow;
|
||||
import co.aikar.idb.DbStatement;
|
||||
import com.google.common.cache.CacheBuilder;
|
||||
import com.google.common.cache.CacheLoader;
|
||||
import com.google.common.cache.LoadingCache;
|
||||
import com.google.common.cache.RemovalNotification;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.draycia.carbon.common.utils.SQLCredentials;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Type;
|
||||
import java.sql.SQLException;
|
||||
import java.sql.SQLSyntaxErrorException;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MySQLUserService<T extends ChatUser> implements UserService<T> {
|
||||
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
private final @NonNull Database database;
|
||||
private final @NonNull Type userType;
|
||||
private final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier;
|
||||
|
||||
private final @NonNull LoadingCache<@NonNull UUID, @NonNull T> userCache = CacheBuilder.newBuilder()
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public MySQLUserService(final @NonNull CarbonChat carbonChat, final @NonNull SQLCredentials credentials,
|
||||
final @NonNull Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
final @NonNull Class<? extends ChatUser> userType) {
|
||||
this.carbonChat = carbonChat;
|
||||
this.userType = userType;
|
||||
this.supplier = supplier;
|
||||
|
||||
final String username = credentials.username();
|
||||
final String password = credentials.password();
|
||||
final String database = credentials.password();
|
||||
final String host = credentials.host();
|
||||
final int port = credentials.port();
|
||||
|
||||
final String hostAndPort = host + ":" + port;
|
||||
|
||||
final DatabaseOptions options = DatabaseOptions.builder().mysql(username, password, database, hostAndPort).build();
|
||||
this.database = PooledDatabaseOptions.builder().options(options).createHikariDatabase();
|
||||
|
||||
DB.setGlobalDatabase(this.database);
|
||||
|
||||
try {
|
||||
this.database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_users (uuid CHAR(36) PRIMARY KEY," +
|
||||
"channel VARCHAR(16), muted BOOLEAN, shadowmuted BOOLEAN, spyingwhispers BOOLEAN," +
|
||||
"nickname VARCHAR(512))");
|
||||
|
||||
// Ignore the exception, it's just saying the column already exists
|
||||
try {
|
||||
this.database.executeUpdate("ALTER TABLE sc_users ADD COLUMN spyingwhispers BOOLEAN DEFAULT false");
|
||||
this.database.executeUpdate("ALTER TABLE sc_users ADD COLUMN nickname VARCHAR(512) DEFAULT false");
|
||||
} catch (final SQLSyntaxErrorException ignored) {
|
||||
}
|
||||
|
||||
this.database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_channel_settings (uuid CHAR(36), channel CHAR(16), spying BOOLEAN, ignored BOOLEAN, color TINYTEXT, PRIMARY KEY (uuid, channel))");
|
||||
|
||||
this.database.executeUpdate("CREATE TABLE IF NOT EXISTS sc_ignored_users (uuid CHAR(36), user CHAR(36), PRIMARY KEY (uuid, user))");
|
||||
} catch (final SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
final TimerTask timerTask = new TimerTask() {
|
||||
@Override
|
||||
public void run() {
|
||||
MySQLUserService.this.userCache.cleanUp();
|
||||
}
|
||||
};
|
||||
|
||||
new Timer().schedule(timerTask, 0L, 300000L);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable() {
|
||||
this.userCache.invalidateAll();
|
||||
this.userCache.cleanUp();
|
||||
this.database.close();
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T wrap(final @NonNull UUID uuid) {
|
||||
try {
|
||||
return this.userCache.get(uuid);
|
||||
} catch (final ExecutionException exception) {
|
||||
exception.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T wrapIfLoaded(final @NonNull UUID uuid) {
|
||||
return this.userCache.getIfPresent(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Nullable
|
||||
public T refreshUser(final @NonNull UUID uuid) {
|
||||
this.userCache.invalidate(uuid);
|
||||
|
||||
return this.wrap(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invalidate(final @NonNull T user) {
|
||||
this.userCache.invalidate(user.uuid());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void validate(final @NonNull T user) {
|
||||
this.userCache.put(user.uuid(), user);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<@NonNull T> onlineUsers() {
|
||||
return this.supplier.get();
|
||||
}
|
||||
|
||||
private @Nullable T loadUser(final @NonNull UUID uuid) {
|
||||
final T user;
|
||||
|
||||
try {
|
||||
user = (T) this.userType.getClass().getDeclaredConstructor(UUID.class).newInstance(uuid);
|
||||
} catch (InstantiationException | IllegalAccessException | InvocationTargetException | NoSuchMethodException e) {
|
||||
e.printStackTrace();
|
||||
return null;
|
||||
}
|
||||
|
||||
try (final DbStatement statement = this.database.query("SELECT * from sc_users WHERE uuid = ?;")) {
|
||||
statement.execute(uuid.toString());
|
||||
|
||||
final DbRow users = statement.getNextRow();
|
||||
|
||||
if (users == null) {
|
||||
return user;
|
||||
}
|
||||
|
||||
final List<DbRow> channelSettings = this.database.getResults("SELECT * from sc_channel_settings WHERE uuid = ?;", uuid.toString());
|
||||
final List<DbRow> ignoredUsers = this.database.getResults("SELECT * from sc_ignored_users WHERE uuid = ?;", uuid.toString());
|
||||
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().channelOrDefault(users.getString("channel"));
|
||||
|
||||
if (channel != null) {
|
||||
user.selectedChannel(channel, true);
|
||||
}
|
||||
|
||||
final String nickname = users.getString("nickname");
|
||||
|
||||
if (nickname != null) {
|
||||
user.nickname(nickname, true);
|
||||
}
|
||||
|
||||
user.muted(users.<Boolean>get("muted"), true);
|
||||
user.shadowMuted(users.<Boolean>get("shadowmuted"), true);
|
||||
user.spyingWhispers(users.<Boolean>get("spyingwhispers"), true);
|
||||
|
||||
for (final DbRow channelSetting : channelSettings) {
|
||||
final ChatChannel chatChannel = this.carbonChat.channelRegistry().get(channelSetting.getString("channel"));
|
||||
|
||||
if (chatChannel != null) {
|
||||
final UserChannelSettings settings = user.channelSettings(chatChannel);
|
||||
|
||||
settings.spying(channelSetting.<Boolean>get("spying"), true);
|
||||
settings.ignoring(channelSetting.<Boolean>get("ignored"), true);
|
||||
|
||||
final String color = channelSetting.getString("color");
|
||||
|
||||
if (color != null) {
|
||||
settings.color(TextColor.fromHexString(color), true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (final DbRow ignoredUser : ignoredUsers) {
|
||||
user.ignoringUser(UUID.fromString(ignoredUser.getString("user")), true, true);
|
||||
}
|
||||
} catch (final SQLException exception) {
|
||||
exception.printStackTrace();
|
||||
}
|
||||
|
||||
return user;
|
||||
}
|
||||
|
||||
private void saveUser(final @NonNull RemovalNotification<@NonNull UUID, @NonNull T> notification) {
|
||||
final T user = notification.getValue();
|
||||
|
||||
this.database.createTransaction(stm -> {
|
||||
// Save user general data
|
||||
String selectedName = null;
|
||||
|
||||
if (user.selectedChannel() != null) {
|
||||
selectedName = user.selectedChannel().key();
|
||||
}
|
||||
|
||||
this.carbonChat.logger().info("Saving user data!");
|
||||
stm.executeUpdateQuery("INSERT INTO sc_users (uuid, channel, muted, shadowmuted, spyingwhispers, nickname) VALUES (?, ?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE channel = ?, muted = ?, shadowmuted = ?, spyingwhispers = ?, nickname =?",
|
||||
user.uuid().toString(), selectedName, user.muted(), user.shadowMuted(), user.spyingwhispers(), user.nickname(),
|
||||
selectedName, user.muted(), user.shadowMuted(), user.spyingwhispers(), user.nickname());
|
||||
|
||||
this.carbonChat.logger().info("Saving user channel settings!");
|
||||
// Save user channel settings
|
||||
for (final Map.Entry<String, ? extends UserChannelSettings> entry : user.channelSettings().entrySet()) {
|
||||
final UserChannelSettings value = entry.getValue();
|
||||
|
||||
String colorString = null;
|
||||
|
||||
if (value.color() != null) {
|
||||
colorString = value.color().asHexString();
|
||||
}
|
||||
|
||||
stm.executeUpdateQuery("INSERT INTO sc_channel_settings (uuid, channel, spying, ignored, color) VALUES (?, ?, ?, ?, ?) " +
|
||||
"ON DUPLICATE KEY UPDATE spying = ?, ignored = ?, color = ?",
|
||||
user.uuid().toString(), entry.getKey(), value.spying(), value.ignored(), colorString,
|
||||
value.spying(), value.ignored(), colorString);
|
||||
}
|
||||
|
||||
this.carbonChat.logger().info("Saving user ignores!");
|
||||
// Save user ignore list (remove old entries then add new ones)
|
||||
// TODO: keep DB up to date with settings as settings are mutated
|
||||
stm.executeUpdateQuery("DELETE FROM sc_ignored_users WHERE uuid = ?", user.uuid().toString());
|
||||
|
||||
for (final UUID entry : user.ignoredUsers()) {
|
||||
stm.executeUpdateQuery("INSERT INTO sc_ignored_users (uuid, user) VALUES (?, ?)",
|
||||
user.uuid().toString(), entry.toString());
|
||||
}
|
||||
|
||||
return true;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
+1
-1
@@ -1,4 +1,4 @@
|
||||
package net.draycia.carbon.common.messaging;
|
||||
package net.draycia.carbon.common.utils;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -0,0 +1,42 @@
|
||||
package net.draycia.carbon.common.utils;
|
||||
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class SQLCredentials {
|
||||
|
||||
private final @NonNull String username;
|
||||
private final @NonNull String password;
|
||||
private final @NonNull String database;
|
||||
private final @NonNull String host;
|
||||
private final int port;
|
||||
|
||||
public SQLCredentials(final @NonNull String username, final @NonNull String password,
|
||||
final @NonNull String database, final @NonNull String host, final int port) {
|
||||
this.username = username;
|
||||
this.password = password;
|
||||
this.database = database;
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
}
|
||||
|
||||
public @NonNull String username() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
public @NonNull String password() {
|
||||
return this.password;
|
||||
}
|
||||
|
||||
public @NonNull String database() {
|
||||
return this.database;
|
||||
}
|
||||
|
||||
public @NonNull String host() {
|
||||
return this.host;
|
||||
}
|
||||
|
||||
public int port() {
|
||||
return this.port;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user