mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +00:00
Refactor ChatUser
This commit is contained in:
1 parent
f9515f98fb
commit
941d7ee096
56 files changed
+455
-354
No files matched your search
@@ -8,7 +8,8 @@ import net.draycia.carbon.api.config.CarbonSettings;
|
||||
import net.draycia.carbon.api.config.ChannelSettings;
|
||||
import net.draycia.carbon.api.config.ModerationSettings;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
@@ -33,7 +34,7 @@ public interface CarbonChat {
|
||||
|
||||
@NonNull Path dataFolder();
|
||||
|
||||
@NonNull <T extends ChatUser> UserService<T> userService();
|
||||
@NonNull <T extends PlayerUser> UserService<T> userService();
|
||||
|
||||
@NonNull MessageProcessor messageProcessor();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@@ -15,29 +15,29 @@ import java.util.regex.Pattern;
|
||||
public interface ChatChannel extends Audience {
|
||||
|
||||
/**
|
||||
* Gets the {@link TextColor} the supplied {@link ChatUser} has set for this channel.
|
||||
* Gets the {@link TextColor} the supplied {@link CarbonUser} has set for this channel.
|
||||
* If none is set, returns this channel's set color with the "color" config option.
|
||||
* @param user The user that may have a color set.
|
||||
* @return The color the user may have set, otherwise the channel's color.
|
||||
*/
|
||||
@Nullable TextColor channelColor(@NonNull ChatUser user);
|
||||
@Nullable TextColor channelColor(@NonNull CarbonUser user);
|
||||
|
||||
@NonNull
|
||||
Map<ChatUser, Component> parseMessage(@NonNull ChatUser user, @NonNull String message, boolean fromRemote);
|
||||
Map<CarbonUser, Component> parseMessage(@NonNull CarbonUser user, @NonNull String message, boolean fromRemote);
|
||||
|
||||
@NonNull
|
||||
Map<ChatUser, Component> parseMessage(@NonNull ChatUser user, @NonNull Collection<@NonNull ChatUser> recipients,
|
||||
@NonNull String message, boolean fromRemote);
|
||||
Map<CarbonUser, Component> parseMessage(@NonNull CarbonUser user, @NonNull Collection<@NonNull CarbonUser> recipients,
|
||||
@NonNull String message, boolean fromRemote);
|
||||
|
||||
boolean canPlayerUse(@NonNull ChatUser user);
|
||||
boolean canPlayerUse(@NonNull CarbonUser user);
|
||||
|
||||
boolean canPlayerSee(@NonNull ChatUser sender, @NonNull ChatUser target, boolean checkSpying);
|
||||
boolean canPlayerSee(@NonNull CarbonUser sender, @NonNull CarbonUser target, boolean checkSpying);
|
||||
|
||||
boolean canPlayerSee(@NonNull ChatUser target, boolean checkSpying);
|
||||
boolean canPlayerSee(@NonNull CarbonUser target, boolean checkSpying);
|
||||
|
||||
void sendComponents(@NonNull final Map<ChatUser, Component> components);
|
||||
void sendComponents(@NonNull final Map<CarbonUser, Component> components);
|
||||
|
||||
void sendComponentsAndLog(@NonNull final Map<ChatUser, Component> components);
|
||||
void sendComponentsAndLog(@NonNull final Map<CarbonUser, Component> components);
|
||||
|
||||
@NonNull String name();
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -8,9 +8,9 @@ import java.util.Collection;
|
||||
|
||||
public interface GroupChannel extends ChatChannel, ForwardingAudience {
|
||||
|
||||
@NonNull ChatUser owner();
|
||||
@NonNull CarbonUser owner();
|
||||
|
||||
@Override
|
||||
@NonNull Collection<@NonNull ChatUser> audiences();
|
||||
@NonNull Collection<@NonNull CarbonUser> audiences();
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
@@ -14,7 +14,7 @@ import java.util.List;
|
||||
public interface TextChannel extends ChatChannel, ForwardingAudience {
|
||||
|
||||
@Override
|
||||
@NonNull List<@NonNull ChatUser> audiences();
|
||||
@NonNull List<@NonNull CarbonUser> audiences();
|
||||
|
||||
/**
|
||||
* Gets the string format for the specified group.
|
||||
@@ -53,12 +53,12 @@ public interface TextChannel extends ChatChannel, ForwardingAudience {
|
||||
|
||||
boolean permissionGroupMatching();
|
||||
|
||||
boolean testContext(@NonNull ChatUser sender, @NonNull ChatUser target);
|
||||
boolean testContext(@NonNull CarbonUser sender, @NonNull CarbonUser target);
|
||||
|
||||
@Nullable Context context(@NonNull String key);
|
||||
|
||||
@NonNull List<@NonNull String> groupOverrides();
|
||||
|
||||
void sendComponent(@NonNull ChatUser user, @NonNull Component component);
|
||||
void sendComponent(@NonNull CarbonUser user, @NonNull Component component);
|
||||
|
||||
}
|
||||
@@ -1,19 +1,19 @@
|
||||
package net.draycia.carbon.api.channels;
|
||||
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public interface WhisperChannel extends ChatChannel, ForwardingAudience.Single {
|
||||
|
||||
@NonNull ChatUser sender();
|
||||
@NonNull CarbonUser sender();
|
||||
|
||||
/**
|
||||
* The recipient for this channel, where messages are sent to.
|
||||
* @return The channel recipient.
|
||||
*/
|
||||
@Override
|
||||
@NonNull ChatUser audience();
|
||||
@NonNull CarbonUser audience();
|
||||
|
||||
@Override
|
||||
default @NonNull String name() {
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -10,17 +11,17 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class ChannelSwitchEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final ChatChannel channel;
|
||||
private @NonNull final ChatUser user;
|
||||
private @NonNull final PlayerUser user;
|
||||
private @NonNull String failureMessage;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public ChannelSwitchEvent(@NonNull final ChatChannel channel, @NonNull final ChatUser user, @Nullable final String failureMessage) {
|
||||
public ChannelSwitchEvent(@NonNull final ChatChannel channel, @NonNull final PlayerUser user, @Nullable final String failureMessage) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
this.failureMessage = failureMessage;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser user() {
|
||||
public @NonNull PlayerUser user() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
import net.kyori.event.Cancellable;
|
||||
@@ -11,13 +11,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class ChatComponentEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final ChatUser sender;
|
||||
private @NonNull final ChatUser target;
|
||||
private @NonNull final CarbonUser sender;
|
||||
private @NonNull final CarbonUser target;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull TextComponent component;
|
||||
private @NonNull final String originalMessage;
|
||||
|
||||
public ChatComponentEvent(@NonNull final ChatUser sender, @Nullable final ChatUser target,
|
||||
public ChatComponentEvent(@NonNull final CarbonUser sender, @Nullable final CarbonUser target,
|
||||
@NonNull final ChatChannel chatChannel, @NonNull final TextComponent component,
|
||||
@NonNull final String originalMessage) {
|
||||
|
||||
@@ -38,11 +38,11 @@ public class ChatComponentEvent implements CarbonEvent, Cancellable {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser sender() {
|
||||
public @NonNull CarbonUser sender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public @Nullable ChatUser target() {
|
||||
public @Nullable CarbonUser target() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -10,13 +10,13 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
public class ChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final ChatUser sender;
|
||||
private @NonNull final ChatUser target;
|
||||
private @NonNull final CarbonUser sender;
|
||||
private @NonNull final CarbonUser target;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull String format;
|
||||
private @NonNull String message;
|
||||
|
||||
public ChatFormatEvent(@NonNull final ChatUser sender, @Nullable final ChatUser target,
|
||||
public ChatFormatEvent(@NonNull final CarbonUser sender, @Nullable final CarbonUser target,
|
||||
@NonNull final ChatChannel chatChannel, @Nullable final String format,
|
||||
@NonNull final String message) {
|
||||
|
||||
@@ -38,11 +38,11 @@ public class ChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser sender() {
|
||||
public @NonNull CarbonUser sender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public @Nullable ChatUser target() {
|
||||
public @Nullable CarbonUser target() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MessageContextEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final TextChannel channel;
|
||||
private @NonNull final ChatUser user;
|
||||
private @NonNull final PlayerUser user;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public MessageContextEvent(@NonNull final TextChannel channel, @NonNull final ChatUser user) {
|
||||
public MessageContextEvent(@NonNull final TextChannel channel, @NonNull final PlayerUser user) {
|
||||
this.channel = channel;
|
||||
this.user = user;
|
||||
}
|
||||
@@ -36,7 +37,7 @@ public class MessageContextEvent implements CarbonEvent, Cancellable {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser user() {
|
||||
public @NonNull PlayerUser user() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,21 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private boolean isCancelled = false;
|
||||
private @NonNull final ChatUser user;
|
||||
private @NonNull final PlayerUser user;
|
||||
private @NonNull ChatChannel chatChannel;
|
||||
private @NonNull String format;
|
||||
private @NonNull String message;
|
||||
|
||||
public PreChatFormatEvent(@NonNull final ChatUser user, @NonNull final ChatChannel chatChannel,
|
||||
public PreChatFormatEvent(@NonNull final PlayerUser user, @NonNull final ChatChannel chatChannel,
|
||||
@NonNull final String format, @NonNull final String message) {
|
||||
|
||||
this.user = user;
|
||||
@@ -33,7 +34,7 @@ public class PreChatFormatEvent implements CarbonEvent, Cancellable {
|
||||
this.isCancelled = cancelled;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser user() {
|
||||
public @NonNull PlayerUser user() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.event.Cancellable;
|
||||
@@ -8,14 +8,14 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PrivateMessageEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final ChatUser sender;
|
||||
private @NonNull final ChatUser target;
|
||||
private @NonNull final CarbonUser sender;
|
||||
private @NonNull final CarbonUser target;
|
||||
private @NonNull final Component senderComponent;
|
||||
private @NonNull final Component targetComponent;
|
||||
private @NonNull final String message;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public PrivateMessageEvent(@NonNull final ChatUser sender, @NonNull final ChatUser target,
|
||||
public PrivateMessageEvent(@NonNull final CarbonUser sender, @NonNull final CarbonUser target,
|
||||
@NonNull final Component senderComponent, @NonNull final Component targetComponent,
|
||||
@NonNull final String message) {
|
||||
|
||||
@@ -36,11 +36,11 @@ public class PrivateMessageEvent implements CarbonEvent, Cancellable {
|
||||
this.cancelled = cancelled;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser sender() {
|
||||
public @NonNull CarbonUser sender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser target() {
|
||||
public @NonNull CarbonUser target() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
|
||||
+8
-6
@@ -1,20 +1,22 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class ReceiverContextEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final TextChannel channel;
|
||||
private @NonNull final ChatUser sender;
|
||||
private @NonNull final ChatUser recipient;
|
||||
private @NonNull final PlayerUser sender;
|
||||
private @NonNull final PlayerUser recipient;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public ReceiverContextEvent(@NonNull final TextChannel channel, @NonNull final ChatUser sender, @NonNull final ChatUser recipient) {
|
||||
public ReceiverContextEvent(@NonNull final TextChannel channel, @NonNull final PlayerUser sender,
|
||||
@NonNull final PlayerUser recipient) {
|
||||
this.channel = channel;
|
||||
this.sender = sender;
|
||||
this.recipient = recipient;
|
||||
@@ -38,11 +40,11 @@ public class ReceiverContextEvent implements CarbonEvent, Cancellable {
|
||||
return this.channel;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser sender() {
|
||||
public @NonNull PlayerUser sender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser recipient() {
|
||||
public @NonNull PlayerUser recipient() {
|
||||
return this.recipient;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,20 @@
|
||||
package net.draycia.carbon.api.events;
|
||||
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvent;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.event.Cancellable;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class UserEvent implements CarbonEvent, Cancellable {
|
||||
|
||||
private @NonNull final ChatUser user;
|
||||
private @NonNull final CarbonUser user;
|
||||
private boolean cancelled = false;
|
||||
|
||||
public UserEvent(@NonNull final ChatUser user) {
|
||||
public UserEvent(@NonNull final CarbonUser user) {
|
||||
this.user = user;
|
||||
}
|
||||
|
||||
public @NonNull ChatUser user() {
|
||||
public @NonNull CarbonUser user() {
|
||||
return this.user;
|
||||
}
|
||||
|
||||
@@ -29,13 +29,13 @@ public class UserEvent implements CarbonEvent, Cancellable {
|
||||
}
|
||||
|
||||
public static class Join extends UserEvent {
|
||||
public Join(@NonNull final ChatUser user) {
|
||||
public Join(@NonNull final CarbonUser user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Leave extends UserEvent {
|
||||
public Leave(@NonNull final ChatUser user) {
|
||||
public Leave(@NonNull final CarbonUser user) {
|
||||
super(user);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package net.draycia.carbon.api.messaging;
|
||||
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -11,7 +11,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public interface MessageService {
|
||||
|
||||
void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener);
|
||||
void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
void registerUUIDMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput> listener);
|
||||
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package net.draycia.carbon.api.users;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface CarbonUser extends Audience {
|
||||
|
||||
boolean hasPermission(@NonNull String permission);
|
||||
|
||||
@NonNull String name();
|
||||
|
||||
@Nullable ChatChannel selectedChannel();
|
||||
|
||||
default void selectedChannel(@NonNull final ChatChannel channel) {
|
||||
this.selectedChannel(channel, false);
|
||||
}
|
||||
|
||||
void selectedChannel(@NonNull ChatChannel channel, boolean fromRemote);
|
||||
|
||||
void clearSelectedChannel();
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package net.draycia.carbon.api.users;
|
||||
|
||||
public interface ConsoleUser extends ChatUser {
|
||||
public interface ConsoleUser extends CarbonUser {
|
||||
}
|
||||
+8
-26
@@ -1,7 +1,6 @@
|
||||
package net.draycia.carbon.api.users;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -10,17 +9,12 @@ import java.util.Collection;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
public interface ChatUser extends Audience {
|
||||
public interface PlayerUser extends CarbonUser {
|
||||
|
||||
@NonNull UUID uuid();
|
||||
|
||||
@Deprecated
|
||||
boolean permissible();
|
||||
|
||||
boolean online();
|
||||
|
||||
boolean hasPermission(@NonNull String permission);
|
||||
|
||||
@Nullable String nickname();
|
||||
|
||||
default void nickname(@Nullable final String nickname) {
|
||||
@@ -33,18 +27,6 @@ public interface ChatUser extends Audience {
|
||||
|
||||
void displayName(@Nullable String displayName);
|
||||
|
||||
@NonNull String name();
|
||||
|
||||
@Nullable ChatChannel selectedChannel();
|
||||
|
||||
default void selectedChannel(@NonNull final ChatChannel channel) {
|
||||
this.selectedChannel(channel, false);
|
||||
}
|
||||
|
||||
void selectedChannel(@NonNull ChatChannel channel, boolean fromRemote);
|
||||
|
||||
void clearSelectedChannel();
|
||||
|
||||
@NonNull UserChannelSettings channelSettings(@NonNull ChatChannel channel);
|
||||
|
||||
@NonNull Map<@NonNull String, @NonNull ? extends UserChannelSettings> channelSettings();
|
||||
@@ -79,13 +61,13 @@ public interface ChatUser extends Audience {
|
||||
this.replyTarget(target, false);
|
||||
}
|
||||
|
||||
default void replyTarget(@Nullable final ChatUser user) {
|
||||
default void replyTarget(@Nullable final PlayerUser user) {
|
||||
this.replyTarget(user.uuid(), false);
|
||||
}
|
||||
|
||||
void replyTarget(@Nullable UUID target, boolean fromRemote);
|
||||
|
||||
default void replyTarget(@Nullable final ChatUser user, final boolean fromRemote) {
|
||||
default void replyTarget(@Nullable final PlayerUser user, final boolean fromRemote) {
|
||||
this.replyTarget(user.uuid(), fromRemote);
|
||||
}
|
||||
|
||||
@@ -97,19 +79,19 @@ public interface ChatUser extends Audience {
|
||||
this.ignoringUser(uuid, ignoring, false);
|
||||
}
|
||||
|
||||
default boolean ignoringUser(@NonNull final ChatUser user) {
|
||||
default boolean ignoringUser(@NonNull final PlayerUser user) {
|
||||
return this.ignoringUser(user.uuid());
|
||||
}
|
||||
|
||||
default void ignoringUser(@NonNull final ChatUser user, final boolean ignoring, final boolean fromRemote) {
|
||||
default void ignoringUser(@NonNull final PlayerUser user, final boolean ignoring, final boolean fromRemote) {
|
||||
this.ignoringUser(user.uuid(), ignoring, fromRemote);
|
||||
}
|
||||
|
||||
default void ignoringUser(@NonNull final ChatUser user, final boolean ignoring) {
|
||||
default void ignoringUser(@NonNull final PlayerUser user, final boolean ignoring) {
|
||||
this.ignoringUser(user.uuid(), ignoring, false);
|
||||
}
|
||||
|
||||
@NonNull Iterable<ChatUser> ignoredChatUsers();
|
||||
@NonNull Iterable<CarbonUser> ignoredChatUsers();
|
||||
|
||||
@NonNull Iterable<UUID> ignoredUsers();
|
||||
|
||||
@@ -121,6 +103,6 @@ public interface ChatUser extends Audience {
|
||||
|
||||
@Nullable Group primaryGroup();
|
||||
|
||||
void sendMessage(@NonNull final ChatUser sender, @NonNull String message);
|
||||
void sendMessage(@NonNull final PlayerUser sender, @NonNull String message);
|
||||
|
||||
}
|
||||
@@ -5,7 +5,7 @@ import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
public interface UserService<T extends ChatUser> {
|
||||
public interface UserService<T extends PlayerUser> {
|
||||
|
||||
@Nullable
|
||||
UUID resolve(String name);
|
||||
|
||||
@@ -31,7 +31,7 @@ dependencies {
|
||||
compileOnly 'com.vexsoftware:nuvotifier-universal:2.6.0'
|
||||
|
||||
compileOnly 'net.luckperms:api:5.1'
|
||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7' // TODO: remove
|
||||
compileOnly 'com.github.MilkBowl:VaultAPI:1.7'
|
||||
|
||||
// Server
|
||||
compileOnly 'com.destroystokyo.paper:paper-api:1.16.2-R0.1-SNAPSHOT'
|
||||
|
||||
@@ -14,7 +14,8 @@ import net.draycia.carbon.api.config.MessagingType;
|
||||
import net.draycia.carbon.api.config.ModerationSettings;
|
||||
import net.draycia.carbon.api.config.StorageType;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.adventure.FormatType;
|
||||
import net.draycia.carbon.common.channels.ChannelManager;
|
||||
import net.draycia.carbon.common.config.KeySerializer;
|
||||
@@ -51,7 +52,8 @@ import net.draycia.carbon.api.users.UserService;
|
||||
import net.draycia.carbon.common.users.JSONUserService;
|
||||
import net.draycia.carbon.common.users.MySQLUserService;
|
||||
import net.draycia.carbon.messaging.BungeeMessageService;
|
||||
import net.draycia.carbon.storage.BukkitChatUser;
|
||||
import net.draycia.carbon.users.BukkitPlayerUser;
|
||||
import net.draycia.carbon.users.BukkitConsoleUser;
|
||||
import net.draycia.carbon.util.CarbonPlaceholders;
|
||||
import net.draycia.carbon.util.FunctionalityConstants;
|
||||
import net.draycia.carbon.util.Metrics;
|
||||
@@ -63,6 +65,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import net.milkbowl.vault.economy.Economy;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
@@ -94,7 +97,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
private CarbonSettings carbonSettings;
|
||||
private ChannelSettings channelSettings;
|
||||
|
||||
private UserService<BukkitChatUser> userService;
|
||||
private UserService<BukkitPlayerUser> userService;
|
||||
private MessageManager messageManager;
|
||||
|
||||
private CarbonTranslations translations;
|
||||
@@ -147,8 +150,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
// Handle storage service
|
||||
final StorageType storageType = this.carbonSettings().storageType();
|
||||
|
||||
final Supplier<Iterable<BukkitChatUser>> supplier = () -> {
|
||||
final List<BukkitChatUser> users = new ArrayList<>();
|
||||
final Supplier<Iterable<BukkitPlayerUser>> supplier = () -> {
|
||||
final List<BukkitPlayerUser> users = new ArrayList<>();
|
||||
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
users.add(this.userService.wrap(player.getUniqueId()));
|
||||
@@ -162,13 +165,13 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
if (storageType == StorageType.MYSQL) {
|
||||
this.logger().info("Enabling MySQL storage!");
|
||||
final SQLCredentials credentials = this.carbonSettings().sqlCredentials();
|
||||
this.userService = new MySQLUserService<>(this, credentials, supplier, BukkitChatUser::new, nameResolver);
|
||||
this.userService = new MySQLUserService<>(this, credentials, supplier, BukkitPlayerUser::new, nameResolver);
|
||||
} else if (storageType == StorageType.JSON) {
|
||||
this.logger().info("Enabling JSON storage!");
|
||||
this.userService = new JSONUserService<>(BukkitChatUser.class, this, supplier, BukkitChatUser::new, nameResolver);
|
||||
this.userService = new JSONUserService<>(BukkitPlayerUser.class, this, supplier, BukkitPlayerUser::new, nameResolver);
|
||||
} else {
|
||||
this.logger().error("Invalid storage type selected! Falling back to JSON.");
|
||||
this.userService = new JSONUserService<>(BukkitChatUser.class, this, supplier, BukkitChatUser::new, nameResolver);
|
||||
this.userService = new JSONUserService<>(BukkitPlayerUser.class, this, supplier, BukkitPlayerUser::new, nameResolver);
|
||||
}
|
||||
|
||||
// Setup listeners
|
||||
@@ -214,16 +217,21 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
|
||||
private void setupCommands() {
|
||||
try {
|
||||
final PaperCommandManager<ChatUser> manager = new PaperCommandManager<>(this,
|
||||
final PaperCommandManager<CarbonUser> manager = new PaperCommandManager<>(this,
|
||||
CommandExecutionCoordinator
|
||||
.simpleCoordinator(), sender -> {
|
||||
if (sender instanceof Player) {
|
||||
return this.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
// TODO: weeeeee fix this
|
||||
throw new IllegalArgumentException("Non-players not supported yet!");
|
||||
return new BukkitConsoleUser((ConsoleCommandSender)sender);
|
||||
}
|
||||
}, user -> Bukkit.getPlayer(user.uuid()));
|
||||
}, user -> {
|
||||
if (user instanceof PlayerUser) {
|
||||
return Bukkit.getPlayer(((PlayerUser)user).uuid());
|
||||
} else {
|
||||
return Bukkit.getConsoleSender();
|
||||
}
|
||||
});
|
||||
|
||||
CommandRegistrar.registerCommands(manager);
|
||||
} catch (final Exception e) {
|
||||
@@ -351,7 +359,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
return this.messageManager;
|
||||
}
|
||||
|
||||
public @NonNull UserService<BukkitChatUser> userService() {
|
||||
public @NonNull UserService<BukkitPlayerUser> userService() {
|
||||
return this.userService;
|
||||
}
|
||||
|
||||
|
||||
+6
-5
@@ -11,8 +11,9 @@ import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChannelSwitchEvent;
|
||||
import net.draycia.carbon.api.events.MessageContextEvent;
|
||||
import net.draycia.carbon.api.events.ReceiverContextEvent;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.PostOrders;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
@@ -68,7 +69,7 @@ public final class TownyContext implements Listener {
|
||||
@EventHandler
|
||||
public void onResidentRemove(final TownRemoveResidentEvent event) {
|
||||
final String name = event.getResident().getName();
|
||||
final ChatUser user = this.carbonChat.userService().wrap(Bukkit.getPlayer(name).getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(Bukkit.getPlayer(name).getUniqueId());
|
||||
final ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (!(channel instanceof TextChannel)) {
|
||||
@@ -85,7 +86,7 @@ public final class TownyContext implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (!(channel instanceof TextChannel)) {
|
||||
@@ -100,7 +101,7 @@ public final class TownyContext implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInTown(@NonNull final ChatUser user) {
|
||||
public boolean isInTown(@NonNull final PlayerUser user) {
|
||||
try {
|
||||
return TownyAPI.getInstance().getDataSource().getResident(Bukkit.getPlayer(user.uuid()).getName()).hasTown();
|
||||
} catch (final NotRegisteredException exception) {
|
||||
@@ -110,7 +111,7 @@ public final class TownyContext implements Listener {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isInSameTown(@NonNull final ChatUser user1, @NonNull final ChatUser user2) {
|
||||
public boolean isInSameTown(@NonNull final PlayerUser user1, @NonNull final PlayerUser user2) {
|
||||
if (Bukkit.getPlayer(user1.uuid()) == null || Bukkit.getPlayer(user2.uuid()) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+5
-4
@@ -9,8 +9,9 @@ import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.ChannelSwitchEvent;
|
||||
import net.draycia.carbon.api.events.MessageContextEvent;
|
||||
import net.draycia.carbon.api.events.ReceiverContextEvent;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.event.PostOrders;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -80,7 +81,7 @@ public final class mcMMOContext implements Listener {
|
||||
}
|
||||
|
||||
private void checkContext(final Player player) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (!(channel instanceof TextChannel)) {
|
||||
@@ -95,11 +96,11 @@ public final class mcMMOContext implements Listener {
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isInParty(@NonNull final ChatUser user) {
|
||||
public boolean isInParty(@NonNull final PlayerUser user) {
|
||||
return PartyAPI.inParty(Bukkit.getPlayer(user.uuid()));
|
||||
}
|
||||
|
||||
public boolean isInSameParty(@NonNull final ChatUser user1, @NonNull final ChatUser user2) {
|
||||
public boolean isInSameParty(@NonNull final PlayerUser user1, @NonNull final PlayerUser user2) {
|
||||
if (Bukkit.getPlayer(user1.uuid()) == null || Bukkit.getPlayer(user2.uuid()) == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
+6
-6
@@ -4,7 +4,7 @@ import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.events.UserEvent;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.plain.PlainComponentSerializer;
|
||||
@@ -33,7 +33,7 @@ public class BukkitChatListener implements Listener {
|
||||
// TODO: Move most of this to Common handling
|
||||
// TODO: ChatMessageEvent that's called at the start of this
|
||||
// TODO: Obtain a component (for console usage) from that event, or another
|
||||
final ChatUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
ChatChannel channel = user.selectedChannel();
|
||||
|
||||
if (channel == null) {
|
||||
@@ -77,10 +77,10 @@ public class BukkitChatListener implements Listener {
|
||||
event.getRecipients().clear();
|
||||
|
||||
if (event.isAsynchronous()) {
|
||||
final Map<ChatUser, Component> messages =
|
||||
final Map<CarbonUser, Component> messages =
|
||||
selectedChannel.parseMessage(user, event.getMessage(), false);
|
||||
|
||||
for (final Map.Entry<ChatUser, Component> entry : messages.entrySet()) {
|
||||
for (final Map.Entry<CarbonUser, Component> entry : messages.entrySet()) {
|
||||
if (entry.getValue().equals(Component.empty())) {
|
||||
continue;
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public class BukkitChatListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerJoin(final PlayerJoinEvent event) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final UserEvent.Join joinEvent = new UserEvent.Join(user);
|
||||
|
||||
CarbonEvents.post(joinEvent);
|
||||
@@ -116,7 +116,7 @@ public class BukkitChatListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onPlayerLeave(final PlayerQuitEvent event) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(event.getPlayer().getUniqueId());
|
||||
final UserEvent.Leave leaveEvent = new UserEvent.Leave(user);
|
||||
|
||||
CarbonEvents.post(leaveEvent);
|
||||
|
||||
+5
-5
@@ -6,7 +6,7 @@ import com.google.common.io.ByteStreams;
|
||||
import io.github.leonardosnt.bungeechannelapi.BungeeChannelApi;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -22,7 +22,7 @@ public class BungeeMessageService implements MessageService {
|
||||
|
||||
private @NonNull final BungeeChannelApi api;
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
|
||||
@@ -61,10 +61,10 @@ public class BungeeMessageService implements MessageService {
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
final ChatUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
final CarbonUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
for (final Map.Entry<String, BiConsumer<ChatUser, ByteArrayDataInput>> listener : this.userLoadedListeners.entrySet()) {
|
||||
for (final Map.Entry<String, BiConsumer<CarbonUser, ByteArrayDataInput>> listener : this.userLoadedListeners.entrySet()) {
|
||||
if (key.equals(listener.getKey())) {
|
||||
listener.getValue().accept(user, value);
|
||||
}
|
||||
@@ -79,7 +79,7 @@ public class BungeeMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package net.draycia.carbon.users;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ConsoleUser;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.kyori.adventure.audience.ForwardingAudience;
|
||||
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.ConsoleCommandSender;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
|
||||
import java.util.Collections;
|
||||
|
||||
public class BukkitConsoleUser implements ConsoleUser, ForwardingAudience {
|
||||
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
private final @NonNull Iterable<Audience> audience;
|
||||
|
||||
public BukkitConsoleUser(final @NonNull ConsoleCommandSender sender) {
|
||||
final Plugin plugin = Bukkit.getPluginManager().getPlugin("CarbonChat-Bukkit");
|
||||
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.audience = Collections.singletonList(BukkitAudiences.create(plugin).sender(sender));
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<? extends Audience> audiences() {
|
||||
return audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NonNull final String permission) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull String name() {
|
||||
return "Console";
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable ChatChannel selectedChannel() {
|
||||
// TODO: stub
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void selectedChannel(@NonNull final ChatChannel channel, final boolean fromRemote) {
|
||||
// TODO: stub
|
||||
}
|
||||
|
||||
@Override
|
||||
public void clearSelectedChannel() {
|
||||
// TODO: stub
|
||||
}
|
||||
|
||||
}
|
||||
+10
-14
@@ -1,7 +1,8 @@
|
||||
package net.draycia.carbon.storage;
|
||||
package net.draycia.carbon.users;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.common.channels.CarbonWhisperChannel;
|
||||
import net.draycia.carbon.util.FunctionalityConstants;
|
||||
@@ -34,7 +35,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
public class BukkitPlayerUser implements PlayerUser, ForwardingAudience {
|
||||
|
||||
private @NonNull final transient CarbonChatBukkit carbonChat;
|
||||
private @NonNull final Map<@NonNull String, @NonNull SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
||||
@@ -49,11 +50,11 @@ public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
private @Nullable String selectedChannelKey = null;
|
||||
private transient @Nullable ChatChannel selectedChannel = null;
|
||||
|
||||
public BukkitChatUser() {
|
||||
public BukkitPlayerUser() {
|
||||
this.carbonChat = (CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat-Bukkit");
|
||||
}
|
||||
|
||||
public BukkitChatUser(@NonNull final UUID uuid) {
|
||||
public BukkitPlayerUser(@NonNull final UUID uuid) {
|
||||
this();
|
||||
this.uuid = uuid;
|
||||
}
|
||||
@@ -78,11 +79,6 @@ public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
return this.nickname;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean permissible() {
|
||||
return Bukkit.getPlayer(this.uuid()) != null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(@NonNull final String permission) {
|
||||
return LuckPermsProvider.get().getUserManager().getUser(this.uuid())
|
||||
@@ -257,8 +253,8 @@ public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Iterable<@NonNull ChatUser> ignoredChatUsers() {
|
||||
final List<ChatUser> users = new ArrayList<>();
|
||||
public @NonNull Iterable<@NonNull CarbonUser> ignoredChatUsers() {
|
||||
final List<CarbonUser> users = new ArrayList<>();
|
||||
|
||||
for (final UUID uuid : this.ignoredUsers) {
|
||||
users.add(this.carbonChat.userService().wrap(uuid));
|
||||
@@ -344,7 +340,7 @@ public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendMessage(@NonNull final ChatUser sender, @NonNull final String message) {
|
||||
public void sendMessage(@NonNull final PlayerUser sender, @NonNull final String message) {
|
||||
if (this.ignoringUser(sender) || sender.ignoringUser(this)) {
|
||||
return;
|
||||
}
|
||||
@@ -441,7 +437,7 @@ public class BukkitChatUser implements ChatUser, ForwardingAudience {
|
||||
}
|
||||
|
||||
for (final Player player : Bukkit.getOnlinePlayers()) {
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final PlayerUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
if (!user.spyingWhispers()) {
|
||||
continue;
|
||||
+3
-3
@@ -1,8 +1,8 @@
|
||||
package net.draycia.carbon.storage;
|
||||
package net.draycia.carbon.users;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
||||
@@ -27,7 +27,7 @@ public class SimpleUserChannelSettings implements UserChannelSettings {
|
||||
this.channel = channel;
|
||||
}
|
||||
|
||||
private @NonNull ChatUser user() {
|
||||
private @NonNull CarbonUser user() {
|
||||
return this.carbonChat.userService().wrap(this.uuid);
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.util;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
@@ -49,7 +49,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
return "false";
|
||||
}
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
return String.valueOf(channel.canPlayerUse(user));
|
||||
} else if (key.startsWith("can_see_")) {
|
||||
@@ -61,7 +61,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
return "false";
|
||||
}
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
return String.valueOf(channel.canPlayerSee(user, true));
|
||||
} else if (key.startsWith("ignoring_channel_")) {
|
||||
@@ -73,7 +73,7 @@ public class CarbonPlaceholders extends PlaceholderExpansion {
|
||||
return "false";
|
||||
}
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
|
||||
return String.valueOf(user.channelSettings(channel).ignored());
|
||||
} else if (key.startsWith("selected_channel")) {
|
||||
|
||||
+24
-24
@@ -11,7 +11,7 @@ import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.events.MessageContextEvent;
|
||||
import net.draycia.carbon.api.events.PreChatFormatEvent;
|
||||
import net.draycia.carbon.api.events.ReceiverContextEvent;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@@ -51,7 +51,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean testContext(@NonNull final ChatUser sender, @NonNull final ChatUser target) {
|
||||
public boolean testContext(@NonNull final CarbonUser sender, @NonNull final CarbonUser target) {
|
||||
final ReceiverContextEvent event = new ReceiverContextEvent(this, sender, target);
|
||||
|
||||
CarbonEvents.post(event);
|
||||
@@ -60,15 +60,15 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(@NonNull final ChatUser user) {
|
||||
public boolean canPlayerUse(@NonNull final CarbonUser user) {
|
||||
return user.permissible() && user.hasPermission("carbonchat.channels." + this.name() + ".use");
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull List<@NonNull ChatUser> audiences() {
|
||||
final List<ChatUser> audience = new ArrayList<>();
|
||||
public @NonNull List<@NonNull CarbonUser> audiences() {
|
||||
final List<CarbonUser> audience = new ArrayList<>();
|
||||
|
||||
for (final ChatUser user : this.carbonChat.userService().onlineUsers()) {
|
||||
for (final CarbonUser user : this.carbonChat.userService().onlineUsers()) {
|
||||
if (this.canPlayerSee(user, true)) {
|
||||
audience.add(user);
|
||||
}
|
||||
@@ -97,7 +97,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
// }
|
||||
|
||||
@Override
|
||||
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user, @NonNull final Collection<@NonNull ChatUser> recipients, @NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final CarbonUser user, @NonNull final Collection<@NonNull CarbonUser> recipients, @NonNull final String message, final boolean fromRemote) {
|
||||
//this.updateUserNickname(user);
|
||||
|
||||
final MessageContextEvent event = new MessageContextEvent(this, user);
|
||||
@@ -130,10 +130,10 @@ public class CarbonChatChannel implements TextChannel {
|
||||
displayName = user.displayName();
|
||||
}
|
||||
|
||||
final Map<ChatUser, Component> users = new HashMap<>();
|
||||
final Map<CarbonUser, Component> users = new HashMap<>();
|
||||
|
||||
// Iterate through players who should receive messages in this channel
|
||||
for (final ChatUser target : recipients) {
|
||||
for (final CarbonUser target : recipients) {
|
||||
// Call second format event. Used for relational stuff (placeholders etc)
|
||||
final ChatFormatEvent formatEvent = new ChatFormatEvent(user, target, this, preFormatEvent.format(), preFormatEvent.message());
|
||||
|
||||
@@ -194,8 +194,8 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponents(@NonNull final Map<ChatUser, Component> components) {
|
||||
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
|
||||
public void sendComponents(@NonNull final Map<CarbonUser, Component> components) {
|
||||
for (final Map.Entry<CarbonUser, Component> entry : components.entrySet()) {
|
||||
if (entry.getValue().equals(Component.empty())) {
|
||||
continue;
|
||||
}
|
||||
@@ -205,8 +205,8 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponentsAndLog(@NonNull final Map<ChatUser, Component> components) {
|
||||
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
|
||||
public void sendComponentsAndLog(@NonNull final Map<CarbonUser, Component> components) {
|
||||
for (final Map.Entry<CarbonUser, Component> entry : components.entrySet()) {
|
||||
if (entry.getValue().equals(Component.empty())) {
|
||||
continue;
|
||||
}
|
||||
@@ -220,11 +220,11 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user, @NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final CarbonUser user, @NonNull final String message, final boolean fromRemote) {
|
||||
return this.parseMessage(user, this.audiences(), message, fromRemote);
|
||||
}
|
||||
|
||||
public @Nullable String format(@NonNull final ChatUser user) {
|
||||
public @Nullable String format(@NonNull final CarbonUser user) {
|
||||
for (final String group : this.groupOverrides()) {
|
||||
if (this.userHasGroup(user, group)) {
|
||||
final String format = this.format(group);
|
||||
@@ -242,7 +242,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean userHasGroup(@NonNull final ChatUser user, @NonNull final String group) {
|
||||
private boolean userHasGroup(@NonNull final CarbonUser user, @NonNull final String group) {
|
||||
if (user.hasGroup(group)) {
|
||||
return true;
|
||||
}
|
||||
@@ -254,7 +254,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return false;
|
||||
}
|
||||
|
||||
private @NonNull String firstFoundUserFormat(@NonNull final ChatUser user) {
|
||||
private @NonNull String firstFoundUserFormat(@NonNull final CarbonUser user) {
|
||||
for (final Group group : user.groups()) {
|
||||
final String groupFormat = this.format(group);
|
||||
|
||||
@@ -266,7 +266,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return this.defaultFormat();
|
||||
}
|
||||
|
||||
private @NonNull String primaryGroupFormat(@NonNull final ChatUser user) {
|
||||
private @NonNull String primaryGroupFormat(@NonNull final CarbonUser user) {
|
||||
final Group primaryGroup = user.primaryGroup();
|
||||
final String primaryGroupFormat = this.format(primaryGroup);
|
||||
|
||||
@@ -291,7 +291,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return this.options().format(group);
|
||||
}
|
||||
|
||||
private boolean isUserSpying(@NonNull final ChatUser sender, @NonNull final ChatUser target) {
|
||||
private boolean isUserSpying(@NonNull final CarbonUser sender, @NonNull final CarbonUser target) {
|
||||
if (!this.canPlayerSee(sender, target, false)) {
|
||||
return target.channelSettings(this).spying();
|
||||
}
|
||||
@@ -300,8 +300,8 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponent(@NonNull final ChatUser player, @NonNull final Component component) {
|
||||
for (final ChatUser user : this.audiences()) {
|
||||
public void sendComponent(@NonNull final CarbonUser player, @NonNull final Component component) {
|
||||
for (final CarbonUser user : this.audiences()) {
|
||||
if (!user.ignoringUser(player)) {
|
||||
user.sendMessage(component);
|
||||
}
|
||||
@@ -316,7 +316,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final ChatUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(@NonNull final CarbonUser target, final boolean checkSpying) {
|
||||
if (checkSpying && target.permissible() && target.hasPermission("carbonchat.spy." + this.name())) {
|
||||
if (target.channelSettings(this).spying()) {
|
||||
return true;
|
||||
@@ -334,7 +334,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean canPlayerSee(@NonNull final ChatUser sender, @NonNull final ChatUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(@NonNull final CarbonUser sender, @NonNull final CarbonUser target, final boolean checkSpying) {
|
||||
|
||||
if (!this.canPlayerSee(target, checkSpying)) {
|
||||
return false;
|
||||
@@ -348,7 +348,7 @@ public class CarbonChatChannel implements TextChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable TextColor channelColor(@NonNull final ChatUser user) {
|
||||
public @Nullable TextColor channelColor(@NonNull final CarbonUser user) {
|
||||
final TextColor userColor = user.channelSettings(this).color();
|
||||
|
||||
if (userColor != null) {
|
||||
|
||||
+20
-20
@@ -6,7 +6,7 @@ import net.draycia.carbon.api.channels.WhisperChannel;
|
||||
import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.ConsoleUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@@ -26,42 +26,42 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
private @NonNull final ChatUser sender;
|
||||
private @NonNull final ChatUser audience;
|
||||
private @NonNull final CarbonUser sender;
|
||||
private @NonNull final CarbonUser audience;
|
||||
|
||||
public CarbonWhisperChannel(@NonNull final ChatUser sender, @NonNull final ChatUser audience) {
|
||||
public CarbonWhisperChannel(@NonNull final CarbonUser sender, @NonNull final CarbonUser audience) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.sender = sender;
|
||||
this.audience = audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChatUser sender() {
|
||||
public @NonNull CarbonUser sender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull ChatUser audience() {
|
||||
public @NonNull CarbonUser audience() {
|
||||
return this.audience;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @Nullable TextColor channelColor(@NonNull final ChatUser user) {
|
||||
public @Nullable TextColor channelColor(@NonNull final CarbonUser user) {
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user, @NonNull final String message,
|
||||
final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final CarbonUser user, @NonNull final String message,
|
||||
final boolean fromRemote) {
|
||||
return this.parseMessage(user, Collections.singleton(this.audience()), message, fromRemote);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user,
|
||||
@NonNull final Collection<@NonNull ChatUser> recipients,
|
||||
@NonNull final String message, final boolean fromRemote) {
|
||||
public @NonNull Map<CarbonUser, Component> parseMessage(@NonNull final CarbonUser user,
|
||||
@NonNull final Collection<@NonNull CarbonUser> recipients,
|
||||
@NonNull final String message, final boolean fromRemote) {
|
||||
// TODO: extract to method, this is just the same thing but twice
|
||||
final Map<ChatUser, Component> result = new HashMap<>();
|
||||
final Map<CarbonUser, Component> result = new HashMap<>();
|
||||
|
||||
// Formats
|
||||
final String senderFormat = this.senderFormat();
|
||||
@@ -160,30 +160,30 @@ public class CarbonWhisperChannel implements WhisperChannel {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerUse(@NonNull final ChatUser user) {
|
||||
public boolean canPlayerUse(@NonNull final CarbonUser user) {
|
||||
return user.equals(this.sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final ChatUser sender, @NonNull final ChatUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(@NonNull final CarbonUser sender, @NonNull final CarbonUser target, final boolean checkSpying) {
|
||||
return (checkSpying && target.spyingWhispers()) || (sender.equals(this.sender) && target.equals(this.audience));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean canPlayerSee(@NonNull final ChatUser target, final boolean checkSpying) {
|
||||
public boolean canPlayerSee(@NonNull final CarbonUser target, final boolean checkSpying) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponents(@NonNull final Map<ChatUser, Component> components) {
|
||||
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
|
||||
public void sendComponents(@NonNull final Map<CarbonUser, Component> components) {
|
||||
for (final Map.Entry<CarbonUser, Component> entry : components.entrySet()) {
|
||||
entry.getKey().sendMessage(entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void sendComponentsAndLog(@NonNull final Map<ChatUser, Component> components) {
|
||||
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
|
||||
public void sendComponentsAndLog(@NonNull final Map<CarbonUser, Component> components) {
|
||||
for (final Map.Entry<CarbonUser, Component> entry : components.entrySet()) {
|
||||
entry.getKey().sendMessage(entry.getValue());
|
||||
|
||||
if (entry.getKey() instanceof ConsoleUser) {
|
||||
|
||||
+8
-7
@@ -6,7 +6,8 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class AliasedChannelCommand {
|
||||
@@ -17,14 +18,14 @@ public class AliasedChannelCommand {
|
||||
|
||||
private @NonNull final String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<ChatUser> commandManager, @NonNull final TextChannel chatChannel) {
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager, @NonNull final TextChannel chatChannel) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.chatChannel = chatChannel;
|
||||
this.commandName = chatChannel.key();
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(this.commandName)
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.channel")
|
||||
.handler(this::channel)
|
||||
.build()
|
||||
@@ -32,7 +33,7 @@ public class AliasedChannelCommand {
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(this.commandName)
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.channel.message")
|
||||
.argument(StringArgument.required("message"))
|
||||
.handler(this::sendMessage)
|
||||
@@ -40,8 +41,8 @@ public class AliasedChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void channel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
|
||||
if (user.channelSettings(this.chatChannel()).ignored()) {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(this.chatChannel().cannotUseMessage(),
|
||||
@@ -54,7 +55,7 @@ public class AliasedChannelCommand {
|
||||
user.selectedChannel(this.chatChannel());
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
context.<String>get("message").ifPresent(message -> {
|
||||
this.chatChannel().sendComponentsAndLog(
|
||||
this.chatChannel().parseMessage(context.getSender(), message, false));
|
||||
|
||||
+7
-6
@@ -8,7 +8,8 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -16,7 +17,7 @@ public class ChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("channel");
|
||||
@@ -28,7 +29,7 @@ public class ChannelCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.channel")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(StringArgument.optional("message")) // carbonchat.channel.message
|
||||
@@ -43,8 +44,8 @@ public class ChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void channel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void channel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final TextChannel channel = context.getRequired("channel");
|
||||
|
||||
if (user.channelSettings(channel).ignored()) {
|
||||
@@ -58,7 +59,7 @@ public class ChannelCommand {
|
||||
user.selectedChannel(channel);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
final String message = context.getRequired("message");
|
||||
|
||||
|
||||
+10
-8
@@ -5,8 +5,9 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.TextComponent;
|
||||
@@ -21,7 +22,7 @@ public class ChannelListCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ChannelListCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("channellist");
|
||||
@@ -33,8 +34,9 @@ public class ChannelListCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withSenderType(CarbonUser.class) // console & player
|
||||
.withPermission("carbonchat.channellist")
|
||||
// TODO: make this return a PlayerUser
|
||||
.argument(CommandUtils.optionalChatUserArgument()) // carbonchat.channellist.other
|
||||
.handler(context -> {
|
||||
if (context.get("user").isPresent()) {
|
||||
@@ -47,13 +49,13 @@ public class ChannelListCommand {
|
||||
);
|
||||
}
|
||||
|
||||
public void channelListSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
public void channelListSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
this.listAndSend(context.getSender(), context.getSender(), this.carbonChat.channelRegistry().iterator());
|
||||
}
|
||||
|
||||
public void channelListOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
public void channelListOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.getRequired("user");
|
||||
|
||||
if (!user.online()) {
|
||||
final String mustBeOnline = this.carbonChat.translations().userMustBeOnline();
|
||||
@@ -65,7 +67,7 @@ public class ChannelListCommand {
|
||||
this.listAndSend(sender, user, allChannels);
|
||||
}
|
||||
|
||||
private void listAndSend(@NonNull final ChatUser sender, @NonNull final ChatUser user,
|
||||
private void listAndSend(@NonNull final CarbonUser sender, @NonNull final CarbonUser user,
|
||||
@NonNull final Iterator<ChatChannel> allChannels) {
|
||||
ChatChannel channel;
|
||||
final List<ChatChannel> canSee = new ArrayList<>();
|
||||
|
||||
+4
-4
@@ -5,7 +5,7 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -13,7 +13,7 @@ public class ChatReloadCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ChatReloadCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("chatreload");
|
||||
@@ -25,14 +25,14 @@ public class ChatReloadCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player & console
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.reload")
|
||||
.handler(this::reloadConfig)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void reloadConfig(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void reloadConfig(@NonNull final CommandContext<CarbonUser> context) {
|
||||
this.carbonChat.reloadConfig();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
|
||||
+5
-5
@@ -4,7 +4,7 @@ import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -13,7 +13,7 @@ public class ClearChatCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ClearChatCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("clearchat");
|
||||
@@ -25,19 +25,19 @@ public class ClearChatCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player & console
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.clearchat.clear")
|
||||
.handler(this::clearChat)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void clearChat(@NonNull final CommandContext<ChatUser> context) {
|
||||
private void clearChat(@NonNull final CommandContext<CarbonUser> 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");
|
||||
|
||||
for (final ChatUser user : this.carbonChat.userService().onlineUsers()) {
|
||||
for (final CarbonUser user : this.carbonChat.userService().onlineUsers()) {
|
||||
if (user.hasPermission("carbonchat.clearchat.exempt")) {
|
||||
final String message = this.carbonChat.translations().clearExempt();
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "player", sender));
|
||||
|
||||
+7
-6
@@ -5,7 +5,8 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -14,7 +15,7 @@ public class IgnoreCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public IgnoreCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("ignore");
|
||||
@@ -26,7 +27,7 @@ public class IgnoreCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.ignore")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::ignoreUser)
|
||||
@@ -34,9 +35,9 @@ public class IgnoreCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void ignoreUser(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser targetUser = context.getRequired("user");
|
||||
private void ignoreUser(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser sender = (PlayerUser)context.getSender();
|
||||
final PlayerUser targetUser = context.getRequired("user");
|
||||
|
||||
if (sender.ignoringUser(targetUser)) {
|
||||
sender.ignoringUser(targetUser, false);
|
||||
|
||||
@@ -5,8 +5,9 @@ import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class MeCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public MeCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MeCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("me");
|
||||
@@ -26,16 +27,16 @@ public class MeCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.me")
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().build())
|
||||
.handler(this::message)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void message(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void message(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
|
||||
final String message = context.<String>getRequired("message").replace("</pre>", "");
|
||||
String format = this.carbonChat.translations().roleplayFormat();
|
||||
@@ -50,7 +51,7 @@ public class MeCommand {
|
||||
if (user.shadowMuted()) {
|
||||
user.sendMessage(component);
|
||||
} else {
|
||||
for (final ChatUser onlineUser : this.carbonChat.userService().onlineUsers()) {
|
||||
for (final PlayerUser onlineUser : this.carbonChat.userService().onlineUsers()) {
|
||||
if (onlineUser.ignoringUser(user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
+8
-8
@@ -7,8 +7,8 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.config.ChannelSettings;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.common.channels.CarbonWhisperChannel;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
@@ -20,7 +20,7 @@ public class MessageCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public MessageCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MessageCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
@@ -33,18 +33,18 @@ public class MessageCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.message")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().asOptional().build())
|
||||
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().asOptional().build())
|
||||
.handler(this::sendMessage)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void sendMessage(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser receiver = context.getRequired("user");
|
||||
private void sendMessage(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser sender = (PlayerUser)context.getSender();
|
||||
final PlayerUser receiver = context.getRequired("user");
|
||||
|
||||
if (sender.equals(receiver)) {
|
||||
final String message = this.carbonChat.translations().cannotWhisperSelf();
|
||||
|
||||
+11
-9
@@ -5,8 +5,9 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -15,7 +16,7 @@ public class MsgToggleCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public MsgToggleCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MsgToggleCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("msgtoggle");
|
||||
@@ -27,13 +28,14 @@ public class MsgToggleCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player & console
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.msgtoggle")
|
||||
.argument(CommandUtils.optionalChatUserArgument()) // carbonchat.msgtoggle.other
|
||||
.handler(context -> {
|
||||
if (context.get("user").isPresent()) {
|
||||
this.toggleOther(context);
|
||||
} else {
|
||||
} else if (context.getSender() instanceof PlayerUser) {
|
||||
// TODO: better handling of this
|
||||
this.toggleSelf(context);
|
||||
}
|
||||
})
|
||||
@@ -41,8 +43,8 @@ public class MsgToggleCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void toggleSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void toggleSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get("whisper");
|
||||
|
||||
final String message;
|
||||
@@ -62,9 +64,9 @@ public class MsgToggleCommand {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message));
|
||||
}
|
||||
|
||||
private void toggleOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
private void toggleOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.getRequired("user");
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get("whisper");
|
||||
|
||||
final String message;
|
||||
|
||||
+12
-11
@@ -4,8 +4,9 @@ import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -14,7 +15,7 @@ public class MuteCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public MuteCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("mute");
|
||||
@@ -26,7 +27,7 @@ public class MuteCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.mute")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::mute)
|
||||
@@ -34,16 +35,16 @@ public class MuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void mute(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
private void mute(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser user = context.getSender();
|
||||
final PlayerUser target = context.getRequired("user");
|
||||
|
||||
if (user.muted()) {
|
||||
user.muted(false);
|
||||
if (target.muted()) {
|
||||
target.muted(false);
|
||||
final String format = this.carbonChat.translations().noLongerMuted();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
"player", target.name());
|
||||
"player", target.name(), "sender", user.name());
|
||||
|
||||
user.sendMessage(message);
|
||||
} else {
|
||||
@@ -53,12 +54,12 @@ public class MuteCommand {
|
||||
if (target.hasPermission("carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.translations().muteExempt();
|
||||
} else {
|
||||
user.muted(true);
|
||||
target.muted(true);
|
||||
format = this.carbonChat.translations().nowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
"player", target.name());
|
||||
"player", target.name(), "sender", user.name());
|
||||
|
||||
user.sendMessage(message);
|
||||
}
|
||||
|
||||
+12
-10
@@ -6,7 +6,8 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class NicknameCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public NicknameCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("nickname");
|
||||
@@ -26,14 +27,15 @@ public class NicknameCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.nickname")
|
||||
.argument(StringArgument.required("nickname"))
|
||||
.argument(CommandUtils.optionalChatUserArgument()) // carbonchat.nickname.other
|
||||
.handler(context -> {
|
||||
if (context.get("user").isPresent()) {
|
||||
this.nicknameOther(context);
|
||||
} else {
|
||||
} else if (context.getSender() instanceof PlayerUser) {
|
||||
// TODO: better handling of this
|
||||
this.nicknameSelf(context);
|
||||
}
|
||||
})
|
||||
@@ -41,8 +43,8 @@ public class NicknameCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void nicknameSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void nicknameSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
String nickname = context.getRequired("nickname");
|
||||
|
||||
if (nickname.equalsIgnoreCase("off") || nickname.equalsIgnoreCase(user.name())) {
|
||||
@@ -61,11 +63,11 @@ public class NicknameCommand {
|
||||
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", user.name()));
|
||||
"user", user.name(), "sender", context.getSender().name()));
|
||||
}
|
||||
|
||||
private void nicknameOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser target = context.getRequired("user");
|
||||
private void nicknameOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser target = context.getRequired("user");
|
||||
String nickname = context.getRequired("nickname");
|
||||
|
||||
if (nickname.equalsIgnoreCase("off") ||
|
||||
@@ -85,7 +87,7 @@ public class NicknameCommand {
|
||||
|
||||
context.getSender().sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
message, "nickname", nickname == null ? "" : nickname,
|
||||
"user", target.name()));
|
||||
"user", target.name(), "sender", context.getSender().name()));
|
||||
}
|
||||
|
||||
}
|
||||
+8
-7
@@ -5,8 +5,9 @@ import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -14,7 +15,7 @@ public class ReplyCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ReplyCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("reply");
|
||||
@@ -26,16 +27,16 @@ public class ReplyCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.reply")
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().build())
|
||||
.handler(this::reply)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void reply(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void reply(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final String input = context.getRequired("message");
|
||||
|
||||
if (input.isEmpty()) {
|
||||
@@ -56,7 +57,7 @@ public class ReplyCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final ChatUser targetUser = this.carbonChat.userService().wrap(user.replyTarget());
|
||||
final PlayerUser targetUser = this.carbonChat.userService().wrap(user.replyTarget());
|
||||
|
||||
targetUser.sendMessage(user, input);
|
||||
}
|
||||
|
||||
+6
-4
@@ -4,8 +4,9 @@ import com.intellectualsites.commands.CommandManager;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -14,7 +15,7 @@ public class SetColorCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SetColorCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("setcolor");
|
||||
@@ -28,11 +29,12 @@ public class SetColorCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.setcolor")
|
||||
// TODO: colorArgument
|
||||
//.argument(CommandUtils.colorArgument())
|
||||
.handler(context -> {
|
||||
final ChatUser user = context.getSender();
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final TextColor color = context.getRequired("color");
|
||||
|
||||
if (!user.hasPermission("carbonchat.setcolor." + channel.key())) {
|
||||
|
||||
+10
-9
@@ -4,8 +4,9 @@ import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -14,7 +15,7 @@ public class ShadowMuteCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("shadowmute");
|
||||
@@ -26,7 +27,7 @@ public class ShadowMuteCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.shadowmute")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::shadowMute)
|
||||
@@ -34,12 +35,12 @@ public class ShadowMuteCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void shadowMute(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
private void shadowMute(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser user = context.getSender();
|
||||
final PlayerUser target = context.getRequired("user");
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
if (target.shadowMuted()) {
|
||||
target.shadowMuted(false);
|
||||
final String format = this.carbonChat.translations().noLongerShadowMuted();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
@@ -53,7 +54,7 @@ public class ShadowMuteCommand {
|
||||
if (target.hasPermission("carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.translations().shadowMuteExempt();
|
||||
} else {
|
||||
user.shadowMuted(true);
|
||||
target.shadowMuted(true);
|
||||
format = this.carbonChat.translations().nowShadowMuted();
|
||||
}
|
||||
|
||||
|
||||
+12
-11
@@ -7,8 +7,9 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -17,7 +18,7 @@ public class SpyChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SpyChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("spy");
|
||||
@@ -30,7 +31,7 @@ public class SpyChannelCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.handler(this::spyChannel)
|
||||
@@ -40,7 +41,7 @@ public class SpyChannelCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(StaticArgument.required("whispers"))
|
||||
.handler(this::spyWhispers)
|
||||
@@ -50,7 +51,7 @@ public class SpyChannelCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(PlayerUser.class) // player
|
||||
.withPermission("carbonchat.spy")
|
||||
.argument(StaticArgument.required("everything"))
|
||||
.argument(BooleanArgument.required("enabled"))
|
||||
@@ -59,8 +60,8 @@ public class SpyChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void spyChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void spyChannel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final ChatChannel chatChannel = context.getRequired("channel");
|
||||
|
||||
final String message;
|
||||
@@ -79,8 +80,8 @@ public class SpyChannelCommand {
|
||||
"color", "<color:" + chatChannel.channelColor(user).toString() + ">", "channel", chatChannel.name()));
|
||||
}
|
||||
|
||||
private void spyWhispers(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void spyWhispers(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
|
||||
final String message;
|
||||
|
||||
@@ -95,8 +96,8 @@ public class SpyChannelCommand {
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message));
|
||||
}
|
||||
|
||||
private void spyEverything(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void spyEverything(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final Boolean shouldSpy = context.getRequired("enabled");
|
||||
|
||||
final String message;
|
||||
|
||||
+9
-9
@@ -6,7 +6,7 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -15,7 +15,7 @@ public class SudoChannelCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public SudoChannelCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("sudochannel");
|
||||
@@ -27,11 +27,11 @@ public class SudoChannelCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withSenderType(CarbonUser.class) // player
|
||||
.withPermission("carbonchat.channel.others.message")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().asOptional().build())
|
||||
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().asOptional().build())
|
||||
.handler(context -> {
|
||||
if (context.get("message").isPresent()) {
|
||||
this.sendMessageOther(context);
|
||||
@@ -43,9 +43,9 @@ public class SudoChannelCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void otherChannel(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
private void otherChannel(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final CarbonUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
user.selectedChannel(channel);
|
||||
@@ -62,8 +62,8 @@ public class SudoChannelCommand {
|
||||
"player", user.name()));
|
||||
}
|
||||
|
||||
private void sendMessageOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getRequired("user");
|
||||
private void sendMessageOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
final String message = context.getRequired("message");
|
||||
|
||||
|
||||
+10
-9
@@ -5,8 +5,9 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.draycia.carbon.api.users.UserChannelSettings;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -15,7 +16,7 @@ public class ToggleCommand {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public ToggleCommand(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("toggle");
|
||||
@@ -27,14 +28,14 @@ public class ToggleCommand {
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player & console
|
||||
.withSenderType(CarbonUser.class) // player & console
|
||||
.withPermission("carbonchat.toggle")
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(CommandUtils.optionalChatUserArgument()) // carbonchat.toggle.other
|
||||
.handler(context -> {
|
||||
if (context.get("user").isPresent()) {
|
||||
this.toggleOther(context);
|
||||
} else {
|
||||
} else if (context.getSender() instanceof PlayerUser) {
|
||||
this.toggleSelf(context);
|
||||
}
|
||||
})
|
||||
@@ -42,8 +43,8 @@ public class ToggleCommand {
|
||||
);
|
||||
}
|
||||
|
||||
private void toggleSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
private void toggleSelf(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final PlayerUser user = (PlayerUser)context.getSender();
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
final String message;
|
||||
@@ -64,9 +65,9 @@ public class ToggleCommand {
|
||||
"color", "<color:" + channel.channelColor(user).toString() + ">", "channel", channel.name()));
|
||||
}
|
||||
|
||||
private void toggleOther(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser user = context.getRequired("user");
|
||||
private void toggleOther(@NonNull final CommandContext<CarbonUser> context) {
|
||||
final CarbonUser sender = context.getSender();
|
||||
final PlayerUser user = context.getRequired("user");
|
||||
final ChatChannel channel = context.getRequired("channel");
|
||||
|
||||
final String message;
|
||||
|
||||
+2
-2
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.common.commands.misc;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.common.commands.ChannelCommand;
|
||||
import net.draycia.carbon.common.commands.ChannelListCommand;
|
||||
import net.draycia.carbon.common.commands.ChatReloadCommand;
|
||||
@@ -25,7 +25,7 @@ public final class CommandRegistrar {
|
||||
|
||||
}
|
||||
|
||||
public static void registerCommands(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
public static void registerCommands(@NonNull final CommandManager<CarbonUser> commandManager) {
|
||||
new ChannelCommand(commandManager);
|
||||
new ChannelListCommand(commandManager);
|
||||
new ChatReloadCommand(commandManager);
|
||||
|
||||
+2
-2
@@ -5,7 +5,7 @@ import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.events.UserEvent;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
|
||||
public class PlayerJoinListener {
|
||||
|
||||
@@ -13,7 +13,7 @@ public class PlayerJoinListener {
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
CarbonEvents.register(UserEvent.Join.class, event -> {
|
||||
final ChatUser user = event.user();
|
||||
final CarbonUser user = event.user();
|
||||
|
||||
carbonChat.userService().validate(user);
|
||||
|
||||
|
||||
+2
-2
@@ -3,7 +3,7 @@ package net.draycia.carbon.common.messaging;
|
||||
import com.google.common.io.ByteArrayDataInput;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.UUID;
|
||||
@@ -13,7 +13,7 @@ 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(@NonNull final String key, @NonNull final BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput> listener) {
|
||||
// do nothing
|
||||
}
|
||||
|
||||
|
||||
+3
-3
@@ -5,7 +5,7 @@ import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.messaging.MessageService;
|
||||
import com.google.common.io.ByteArrayDataOutput;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -88,7 +88,7 @@ public class MessageManager {
|
||||
|
||||
this.messageService().registerUUIDMessageListener("channel-component", (uuid, byteArray) -> {
|
||||
final ChatChannel channel = this.carbonChat.channelRegistry().get(byteArray.readUTF());
|
||||
final ChatUser user = this.carbonChat.userService().wrap(uuid);
|
||||
final CarbonUser user = this.carbonChat.userService().wrap(uuid);
|
||||
|
||||
if (channel instanceof TextChannel) {
|
||||
final Component component = this.carbonChat.gsonSerializer().deserialize(byteArray.readUTF());
|
||||
@@ -102,7 +102,7 @@ public class MessageManager {
|
||||
this.messageService().registerUUIDMessageListener("whisper-component", (uuid, byteArray) -> {
|
||||
final UUID recipient = new UUID(byteArray.readLong(), byteArray.readLong());
|
||||
|
||||
final ChatUser target = this.carbonChat.userService().wrap(recipient);
|
||||
final CarbonUser target = this.carbonChat.userService().wrap(recipient);
|
||||
final String message = byteArray.readUTF();
|
||||
|
||||
if (!target.ignoringUser(uuid)) {
|
||||
|
||||
+5
-5
@@ -9,7 +9,7 @@ import io.lettuce.core.pubsub.StatefulRedisPubSubConnection;
|
||||
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.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.config.RedisCredentials;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -22,7 +22,7 @@ import java.util.function.Consumer;
|
||||
|
||||
public class RedisMessageService implements MessageService {
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput>> userLoadedListeners = new HashMap<>();
|
||||
|
||||
private @NonNull final Map<@NonNull String, @NonNull BiConsumer<@NonNull UUID, @NonNull ByteArrayDataInput>> userNotLoadedListeners = new HashMap<>();
|
||||
|
||||
@@ -68,10 +68,10 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
private void receiveMessage(@NonNull final UUID uuid, @NonNull final String key, @NonNull final ByteArrayDataInput value) {
|
||||
final ChatUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
final CarbonUser user = this.carbonChat.userService().wrapIfLoaded(uuid);
|
||||
|
||||
if (user != null) {
|
||||
for (final Map.Entry<String, BiConsumer<ChatUser, ByteArrayDataInput>> listener : this.userLoadedListeners.entrySet()) {
|
||||
for (final Map.Entry<String, BiConsumer<CarbonUser, ByteArrayDataInput>> listener : this.userLoadedListeners.entrySet()) {
|
||||
if (key.equals(listener.getKey())) {
|
||||
listener.getValue().accept(user, value);
|
||||
}
|
||||
@@ -86,7 +86,7 @@ public class RedisMessageService implements MessageService {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull ChatUser, @NonNull ByteArrayDataInput> listener) {
|
||||
public void registerUserMessageListener(@NonNull final String key, @NonNull final BiConsumer<@NonNull CarbonUser, @NonNull ByteArrayDataInput> listener) {
|
||||
this.userLoadedListeners.put(key, listener);
|
||||
this.subscribeSync.subscribe(key);
|
||||
}
|
||||
|
||||
+3
-3
@@ -9,7 +9,7 @@ import com.google.gson.GsonBuilder;
|
||||
import com.google.gson.stream.JsonReader;
|
||||
import com.google.gson.stream.JsonWriter;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -26,7 +26,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
public class JSONUserService<T extends CarbonUser> implements UserService<T> {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private @NonNull final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||
@@ -39,7 +39,7 @@ public class JSONUserService<T extends ChatUser> implements UserService<T> {
|
||||
.removalListener(this::saveUser)
|
||||
.build(CacheLoader.from(this::loadUser));
|
||||
|
||||
public JSONUserService(@NonNull final Class<? extends ChatUser> userType,
|
||||
public JSONUserService(@NonNull final Class<? extends CarbonUser> userType,
|
||||
@NonNull final CarbonChat carbonChat,
|
||||
@NonNull final Supplier<@NonNull Iterable<@NonNull T>> supplier,
|
||||
@NonNull final Function<UUID, T> userFactory,
|
||||
|
||||
+2
-2
@@ -13,7 +13,7 @@ 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.CarbonUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.draycia.carbon.api.config.SQLCredentials;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
@@ -31,7 +31,7 @@ import java.util.concurrent.ExecutionException;
|
||||
import java.util.function.Function;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class MySQLUserService<T extends ChatUser> implements UserService<T> {
|
||||
public class MySQLUserService<T extends CarbonUser> implements UserService<T> {
|
||||
|
||||
private @NonNull final CarbonChat carbonChat;
|
||||
private @NonNull final Database database;
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
package net.draycia.carbon.common.utils;
|
||||
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.kyori.adventure.text.format.TextDecoration;
|
||||
@@ -21,7 +21,7 @@ public final class ColorUtils {
|
||||
return parseColor(null, input);
|
||||
}
|
||||
|
||||
public @Nullable static TextColor parseColor(@Nullable final ChatUser user, @Nullable String input) {
|
||||
public @Nullable static TextColor parseColor(@Nullable final CarbonUser user, @Nullable String input) {
|
||||
if (input == null || input.isEmpty()) {
|
||||
return NamedTextColor.WHITE;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.channels.TextChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
@@ -19,8 +19,8 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
// TODO: turn this into a proper class that handles suggestions
|
||||
public static CommandArgument<ChatUser, TextChannel> channelArgument() {
|
||||
return CommandArgument.<ChatUser, TextChannel>ofType(TextChannel.class, "channel")
|
||||
public static CommandArgument<CarbonUser, TextChannel> channelArgument() {
|
||||
return CommandArgument.<CarbonUser, TextChannel>ofType(TextChannel.class, "channel")
|
||||
.asRequired()
|
||||
.withParser((c, i) -> {
|
||||
final String input = i.poll();
|
||||
@@ -44,22 +44,22 @@ public final class CommandUtils {
|
||||
.build();
|
||||
}
|
||||
|
||||
public static CommandArgument<ChatUser, ChatUser> optionalChatUserArgument() {
|
||||
return CommandArgument.<ChatUser, ChatUser>ofType(ChatUser.class, "user")
|
||||
public static CommandArgument<CarbonUser, CarbonUser> optionalChatUserArgument() {
|
||||
return CommandArgument.<CarbonUser, CarbonUser>ofType(CarbonUser.class, "user")
|
||||
.asOptional()
|
||||
.withParser(CommandUtils::parse)
|
||||
.build();
|
||||
}
|
||||
|
||||
// TODO: turn this into a proper class that handles suggestions
|
||||
public static CommandArgument<ChatUser, ChatUser> chatUserArgument() {
|
||||
return CommandArgument.<ChatUser, ChatUser>ofType(ChatUser.class, "user")
|
||||
public static CommandArgument<CarbonUser, CarbonUser> chatUserArgument() {
|
||||
return CommandArgument.<CarbonUser, CarbonUser>ofType(CarbonUser.class, "user")
|
||||
.asRequired()
|
||||
.withParser(CommandUtils::parse)
|
||||
.build();
|
||||
}
|
||||
|
||||
private static @NonNull ArgumentParseResult<ChatUser> parse(final CommandContext<ChatUser> c, final Queue<String> i) {
|
||||
private static @NonNull ArgumentParseResult<CarbonUser> parse(final CommandContext<CarbonUser> c, final Queue<String> i) {
|
||||
final String input = i.poll();
|
||||
|
||||
if (input == null) {
|
||||
@@ -67,7 +67,7 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
final UserService<?> userService = CarbonChatProvider.carbonChat().userService();
|
||||
final ChatUser user = userService.wrap(userService.resolve(input));
|
||||
final CarbonUser user = userService.wrap(userService.resolve(input));
|
||||
|
||||
if (user != null) {
|
||||
return ArgumentParseResult.success(user);
|
||||
|
||||
Reference in new issue
Block a user