Reorder keywords and annotations again

This commit is contained in:
Draycia committed 2020-10-02 23:40:32 -07:00
1 parent f2ea4ad8ab
commit 8b0549ac9b
67 files changed
+387 -453

No files matched your search

@@ -33,11 +33,11 @@ import java.util.regex.Pattern;
public class CarbonChatChannel implements TextChannel {
private final @NonNull CarbonChat carbonChat;
private @NonNull final CarbonChat carbonChat;
private final @NonNull ChannelOptions options;
private @NonNull final ChannelOptions options;
public CarbonChatChannel(final @NonNull CarbonChat carbonChat, final @Nullable ChannelOptions options) {
public CarbonChatChannel(@NonNull final CarbonChat carbonChat, @Nullable final ChannelOptions options) {
this.carbonChat = carbonChat;
this.options = options;
}
@@ -46,13 +46,12 @@ public class CarbonChatChannel implements TextChannel {
return this.options;
}
@NonNull
public CarbonChat carbonChat() {
public @NonNull CarbonChat carbonChat() {
return this.carbonChat;
}
@Override
public boolean testContext(final @NonNull ChatUser sender, final @NonNull ChatUser target) {
public boolean testContext(@NonNull final ChatUser sender, @NonNull final ChatUser target) {
final ReceiverContextEvent event = new ReceiverContextEvent(this, sender, target);
CarbonEvents.post(event);
@@ -61,13 +60,12 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public boolean canPlayerUse(final @NonNull ChatUser user) {
public boolean canPlayerUse(@NonNull final ChatUser user) {
return user.permissible() && user.hasPermission("carbonchat.channels." + this.name() + ".use");
}
@Override
@NonNull
public List<@NonNull ChatUser> audiences() {
public @NonNull List<@NonNull ChatUser> audiences() {
final List<ChatUser> audience = new ArrayList<>();
for (final ChatUser user : this.carbonChat.userService().onlineUsers()) {
@@ -79,7 +77,7 @@ public class CarbonChatChannel implements TextChannel {
return audience;
}
// private void updateUserNickname(final @NonNull ChatUser user) {
// private void updateUserNickname(@NonNull final ChatUser user) {
// final Player player = Bukkit.getPlayer(user.uuid());
//
// if (player != null) {
@@ -99,8 +97,7 @@ public class CarbonChatChannel implements TextChannel {
// }
@Override
@NonNull
public Map<ChatUser, Component> parseMessage(final @NonNull ChatUser user, final @NonNull Collection<@NonNull ChatUser> recipients, final @NonNull String message, final boolean fromRemote) {
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user, @NonNull final Collection<@NonNull ChatUser> recipients, @NonNull final String message, final boolean fromRemote) {
//this.updateUserNickname(user);
final MessageContextEvent event = new MessageContextEvent(this, user);
@@ -201,7 +198,7 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public void sendComponents(final @NonNull Map<ChatUser, Component> components) {
public void sendComponents(@NonNull final Map<ChatUser, Component> components) {
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
if (entry.getValue().equals(Component.empty())) {
continue;
@@ -212,7 +209,7 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public void sendComponentsAndLog(final @NonNull Map<ChatUser, Component> components) {
public void sendComponentsAndLog(@NonNull final Map<ChatUser, Component> components) {
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
if (entry.getValue().equals(Component.empty())) {
continue;
@@ -227,12 +224,11 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
@NonNull
public Map<ChatUser, Component> parseMessage(final @NonNull ChatUser user, final @NonNull String message, final boolean fromRemote) {
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user, @NonNull final String message, final boolean fromRemote) {
return this.parseMessage(user, this.audiences(), message, fromRemote);
}
public @Nullable String format(final @NonNull ChatUser user) {
public @Nullable String format(@NonNull final ChatUser user) {
for (final String group : this.groupOverrides()) {
if (this.userHasGroup(user, group)) {
final String format = this.format(group);
@@ -250,7 +246,7 @@ public class CarbonChatChannel implements TextChannel {
}
}
private boolean userHasGroup(final @NonNull ChatUser user, final @NonNull String group) {
private boolean userHasGroup(@NonNull final ChatUser user, @NonNull final String group) {
if (user.hasGroup(group)) {
return true;
}
@@ -262,8 +258,7 @@ public class CarbonChatChannel implements TextChannel {
return false;
}
@Nullable
private String firstFoundUserFormat(final @NonNull ChatUser user) {
private @NonNull String firstFoundUserFormat(@NonNull final ChatUser user) {
for (final Group group : user.groups()) {
final String groupFormat = this.format(group);
@@ -275,8 +270,7 @@ public class CarbonChatChannel implements TextChannel {
return this.defaultFormat();
}
@Nullable
private String primaryGroupFormat(final @NonNull ChatUser user) {
private @NonNull String primaryGroupFormat(@NonNull final ChatUser user) {
final Group primaryGroup = user.primaryGroup();
final String primaryGroupFormat = this.format(primaryGroup);
@@ -287,22 +281,21 @@ public class CarbonChatChannel implements TextChannel {
return this.defaultFormat();
}
@Nullable
private String defaultFormat() {
private @NonNull String defaultFormat() {
return this.format(this.defaultFormatName());
}
@Override
public @Nullable String format(final @NonNull Group group) {
public @Nullable String format(@NonNull final Group group) {
return this.format(group.getName());
}
@Override
public @Nullable String format(final @NonNull String group) {
public @Nullable String format(@NonNull final String group) {
return this.options().format(group);
}
private boolean isUserSpying(final @NonNull ChatUser sender, final @NonNull ChatUser target) {
private boolean isUserSpying(@NonNull final ChatUser sender, @NonNull final ChatUser target) {
if (!this.canPlayerSee(sender, target, false)) {
return target.channelSettings(this).spying();
}
@@ -311,7 +304,7 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public void sendComponent(final @NonNull ChatUser player, final @NonNull Component component) {
public void sendComponent(@NonNull final ChatUser player, @NonNull final Component component) {
for (final ChatUser user : this.audiences()) {
if (!user.ignoringUser(player)) {
user.sendMessage(component);
@@ -319,7 +312,7 @@ public class CarbonChatChannel implements TextChannel {
}
}
public void sendMessageToBungee(final @NonNull UUID uuid, final @NonNull Component component) {
public void sendMessageToBungee(@NonNull final UUID uuid, @NonNull final Component component) {
this.carbonChat.messageService().sendMessage("channel-component", uuid, byteArray -> {
byteArray.writeUTF(this.key());
byteArray.writeUTF(this.carbonChat.gsonSerializer().serialize(component));
@@ -327,7 +320,7 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public boolean canPlayerSee(final @NonNull ChatUser target, final boolean checkSpying) {
public boolean canPlayerSee(@NonNull final ChatUser target, final boolean checkSpying) {
if (checkSpying && target.permissible() && target.hasPermission("carbonchat.spy." + this.name())) {
if (target.channelSettings(this).spying()) {
return true;
@@ -345,7 +338,7 @@ public class CarbonChatChannel implements TextChannel {
return true;
}
public boolean canPlayerSee(final @NonNull ChatUser sender, final @NonNull ChatUser target, final boolean checkSpying) {
public boolean canPlayerSee(@NonNull final ChatUser sender, @NonNull final ChatUser target, final boolean checkSpying) {
if (!this.canPlayerSee(target, checkSpying)) {
return false;
@@ -359,7 +352,7 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public @Nullable TextColor channelColor(final @NonNull ChatUser user) {
public @Nullable TextColor channelColor(@NonNull final ChatUser user) {
final TextColor userColor = user.channelSettings(this).color();
if (userColor != null) {
@@ -412,14 +405,12 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
@NonNull
public List<@NonNull String> groupOverrides() {
public @NonNull List<@NonNull String> groupOverrides() {
return this.options().groupOverrides();
}
@Override
@NonNull
public String name() {
public @NonNull String name() {
return this.options().name();
}
@@ -484,8 +475,7 @@ public class CarbonChatChannel implements TextChannel {
// }
@Override
@NonNull
public List<@NonNull Pattern> itemLinkPatterns() {
public @NonNull List<@NonNull Pattern> itemLinkPatterns() {
return this.carbonChat.carbonSettings().itemLinkPatterns();
}
@@ -495,13 +485,12 @@ public class CarbonChatChannel implements TextChannel {
}
@Override
public @Nullable Context context(final @NonNull String key) {
public @Nullable Context context(@NonNull final String key) {
return this.options().context(key);
}
@Override
@NonNull
public String key() {
public @NonNull String key() {
return this.options().key();
}
@@ -24,12 +24,12 @@ import java.util.regex.Pattern;
public class CarbonWhisperChannel implements WhisperChannel {
private final @NonNull CarbonChat carbonChat;
private @NonNull final CarbonChat carbonChat;
private final @NonNull ChatUser sender;
private final @NonNull ChatUser audience;
private @NonNull final ChatUser sender;
private @NonNull final ChatUser audience;
public CarbonWhisperChannel(final @NonNull ChatUser sender, final @NonNull ChatUser audience) {
public CarbonWhisperChannel(@NonNull final ChatUser sender, @NonNull final ChatUser audience) {
this.carbonChat = CarbonChatProvider.carbonChat();
this.sender = sender;
this.audience = audience;
@@ -46,20 +46,20 @@ public class CarbonWhisperChannel implements WhisperChannel {
}
@Override
public @Nullable TextColor channelColor(final @NonNull ChatUser user) {
public @Nullable TextColor channelColor(@NonNull final ChatUser user) {
return NamedTextColor.WHITE;
}
@Override
public @NonNull Map<ChatUser, Component> parseMessage(final @NonNull ChatUser user, final @NonNull String message,
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser 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(final @NonNull ChatUser user,
final @NonNull Collection<@NonNull ChatUser> recipients,
final @NonNull String message, final boolean fromRemote) {
public @NonNull Map<ChatUser, Component> parseMessage(@NonNull final ChatUser user,
@NonNull final Collection<@NonNull ChatUser> 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<>();
@@ -167,29 +167,29 @@ public class CarbonWhisperChannel implements WhisperChannel {
}
@Override
public boolean canPlayerUse(final @NonNull ChatUser user) {
public boolean canPlayerUse(@NonNull final ChatUser user) {
return user.equals(this.sender);
}
@Override
public boolean canPlayerSee(final @NonNull ChatUser sender, final @NonNull ChatUser target, final boolean checkSpying) {
public boolean canPlayerSee(@NonNull final ChatUser sender, @NonNull final ChatUser target, final boolean checkSpying) {
return (checkSpying && target.spyingWhispers()) || (sender.equals(this.sender) && target.equals(this.audience));
}
@Override
public boolean canPlayerSee(final @NonNull ChatUser target, final boolean checkSpying) {
public boolean canPlayerSee(@NonNull final ChatUser target, final boolean checkSpying) {
return false;
}
@Override
public void sendComponents(final @NonNull Map<ChatUser, Component> components) {
public void sendComponents(@NonNull final Map<ChatUser, Component> components) {
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
entry.getKey().sendMessage(entry.getValue());
}
}
@Override
public void sendComponentsAndLog(final @NonNull Map<ChatUser, Component> components) {
public void sendComponentsAndLog(@NonNull final Map<ChatUser, Component> components) {
for (final Map.Entry<ChatUser, Component> entry : components.entrySet()) {
entry.getKey().sendMessage(entry.getValue());
@@ -16,15 +16,15 @@ import java.util.Map;
public class ChannelManager {
private final @NonNull CarbonChat carbonChat;
private @NonNull final CarbonChat carbonChat;
private final @NonNull ChannelRegistry registry;
private @NonNull final ChannelRegistry registry;
@Nullable
@MonotonicNonNull
private String defaultChannelKey = null;
public ChannelManager(final @NonNull CarbonChat carbonChat) {
public ChannelManager(@NonNull final CarbonChat carbonChat) {
this.carbonChat = carbonChat;
this.registry = new ChannelRegistry();
@@ -32,7 +32,7 @@ public class ChannelManager {
this.reload();
}
public @Nullable ChatChannel loadChannel(final @NonNull ChannelOptions settings) {
public @Nullable ChatChannel loadChannel(@NonNull final ChannelOptions settings) {
final ChatChannel channel = new CarbonChatChannel(this.carbonChat, settings);
final String name = settings.name();
@@ -46,7 +46,7 @@ public class ChannelManager {
return channel;
}
public void registerChannel(final @NonNull ChatChannel channel) {
public void registerChannel(@NonNull final ChatChannel channel) {
this.registry().register(channel.key(), channel);
if (channel instanceof TextChannel) {
@@ -71,7 +71,7 @@ public class ChannelManager {
return null;
}
public @Nullable ChatChannel channelOrDefault(final @Nullable String key) {
public @Nullable ChatChannel channelOrDefault(@Nullable final String key) {
if (key == null) {
return this.defaultChannel();
}