mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
Finalize class fields that can be final
This commit is contained in:
1 parent
15e105ac32
commit
a5da40fee5
18 files changed
+34
-43
No files matched your search
@@ -15,7 +15,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public final class SimpleChat extends JavaPlugin {
|
public final class SimpleChat extends JavaPlugin {
|
||||||
|
|
||||||
private List<Pattern> itemPatterns = new ArrayList<>();
|
private final List<Pattern> itemPatterns = new ArrayList<>();
|
||||||
|
|
||||||
private Permission permission;
|
private Permission permission;
|
||||||
|
|
||||||
|
|||||||
@@ -15,8 +15,8 @@ import java.util.Map;
|
|||||||
|
|
||||||
public class ChannelRegistry implements Registry<ChatChannel> {
|
public class ChannelRegistry implements Registry<ChatChannel> {
|
||||||
|
|
||||||
private Map<String, ChatChannel> registry = new HashMap<>();
|
private final Map<String, ChatChannel> registry = new HashMap<>();
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
|
|
||||||
public ChannelRegistry(SimpleChat simpleChat) {
|
public ChannelRegistry(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
@@ -30,7 +30,7 @@ public class ChannelRegistry implements Registry<ChatChannel> {
|
|||||||
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
CommandManager commandManager = simpleChat.getCommandManager().getCommandManager();
|
||||||
|
|
||||||
commandManager.getCommandReplacements().addReplacement("channelName", value.getAliases());
|
commandManager.getCommandReplacements().addReplacement("channelName", value.getAliases());
|
||||||
commandManager.registerCommand(new AliasedChannelCommand(simpleChat, value));
|
commandManager.registerCommand(new AliasedChannelCommand(value));
|
||||||
|
|
||||||
if (value instanceof Listener) {
|
if (value instanceof Listener) {
|
||||||
Bukkit.getPluginManager().registerEvents((Listener)value, simpleChat);
|
Bukkit.getPluginManager().registerEvents((Listener)value, simpleChat);
|
||||||
|
|||||||
+3
-5
@@ -19,12 +19,10 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class SimpleChatChannel extends ChatChannel {
|
public class SimpleChatChannel extends ChatChannel {
|
||||||
|
|
||||||
private String key;
|
private final String key;
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
private ConfigurationSection config;
|
private final ConfigurationSection config;
|
||||||
|
|
||||||
private SimpleChatChannel() { }
|
|
||||||
|
|
||||||
public SimpleChatChannel(String key, SimpleChat simpleChat, ConfigurationSection config) {
|
public SimpleChatChannel(String key, SimpleChat simpleChat, ConfigurationSection config) {
|
||||||
this.key = key;
|
this.key = key;
|
||||||
|
|||||||
+3
-2
@@ -16,8 +16,9 @@ public class AliasedChannelCommand extends BaseCommand {
|
|||||||
private SimpleChat simpleChat;
|
private SimpleChat simpleChat;
|
||||||
private ChatChannel chatChannel;
|
private ChatChannel chatChannel;
|
||||||
|
|
||||||
public AliasedChannelCommand(SimpleChat simpleChat, ChatChannel chatChannel) {
|
private final ChatChannel chatChannel;
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
|
public AliasedChannelCommand(ChatChannel chatChannel) {
|
||||||
this.chatChannel = chatChannel;
|
this.chatChannel = chatChannel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ public class ChatFormatEvent extends Event implements Cancellable {
|
|||||||
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
private static final HandlerList HANDLERS_LIST = new HandlerList();
|
||||||
private boolean isCancelled = false;
|
private boolean isCancelled = false;
|
||||||
|
|
||||||
private ChatUser user;
|
private final ChatUser user;
|
||||||
private ChatChannel chatChannel;
|
private ChatChannel chatChannel;
|
||||||
private String format;
|
private String format;
|
||||||
private String message;
|
private String message;
|
||||||
|
|||||||
@@ -45,7 +45,6 @@ public class PrivateMessageEvent extends Event {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Component getSenderComponent() {
|
public Component getSenderComponent() {
|
||||||
return senderComponent;
|
return senderComponent;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import org.bukkit.event.player.AsyncPlayerChatEvent;
|
|||||||
|
|
||||||
public class BukkitChatListener implements Listener {
|
public class BukkitChatListener implements Listener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
|
|
||||||
public BukkitChatListener(SimpleChat simpleChat) {
|
public BukkitChatListener(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
+1
-1
@@ -8,7 +8,7 @@ import org.bukkit.event.Listener;
|
|||||||
|
|
||||||
public class EmptyChatHandler implements Listener {
|
public class EmptyChatHandler implements Listener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
|
|
||||||
public EmptyChatHandler(SimpleChat simpleChat) {
|
public EmptyChatHandler(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
+1
-1
@@ -11,7 +11,7 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class ItemLinkHandler implements Listener {
|
public class ItemLinkHandler implements Listener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
|
|
||||||
public ItemLinkHandler(SimpleChat simpleChat) {
|
public ItemLinkHandler(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
+1
-1
@@ -10,7 +10,7 @@ import org.bukkit.event.Listener;
|
|||||||
|
|
||||||
public class PlaceholderHandler implements Listener {
|
public class PlaceholderHandler implements Listener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
|
|
||||||
public PlaceholderHandler(SimpleChat simpleChat) {
|
public PlaceholderHandler(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
+2
-2
@@ -11,8 +11,8 @@ import org.bukkit.entity.Player;
|
|||||||
|
|
||||||
public class AdventureManager {
|
public class AdventureManager {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
private BukkitAudiences audiences;
|
private final BukkitAudiences audiences;
|
||||||
|
|
||||||
public AdventureManager(SimpleChat simpleChat) {
|
public AdventureManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
@@ -13,9 +13,9 @@ import java.util.Collections;
|
|||||||
|
|
||||||
public class ChannelManager {
|
public class ChannelManager {
|
||||||
|
|
||||||
private ChannelRegistry registry;
|
private final SimpleChat simpleChat;
|
||||||
|
private final ChannelRegistry registry;
|
||||||
private String defaultChannelKey = null;
|
private String defaultChannelKey = null;
|
||||||
private SimpleChat simpleChat;
|
|
||||||
|
|
||||||
public ChannelManager(SimpleChat simpleChat) {
|
public ChannelManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
@@ -12,11 +12,9 @@ import java.util.List;
|
|||||||
|
|
||||||
public class CommandManager {
|
public class CommandManager {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final BukkitCommandManager commandManager;
|
||||||
private BukkitCommandManager commandManager;
|
|
||||||
|
|
||||||
public CommandManager(SimpleChat simpleChat) {
|
public CommandManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
|
|
||||||
commandManager = new BukkitCommandManager(simpleChat);
|
commandManager = new BukkitCommandManager(simpleChat);
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -18,8 +18,8 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class PluginMessageManager implements PluginMessageListener {
|
public class PluginMessageManager implements PluginMessageListener {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
private BungeeChannelApi api;
|
private final BungeeChannelApi api;
|
||||||
|
|
||||||
public PluginMessageManager(SimpleChat simpleChat) {
|
public PluginMessageManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
@@ -16,17 +16,14 @@ import java.util.UUID;
|
|||||||
|
|
||||||
public class RedisManager {
|
public class RedisManager {
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final RedisClient client;
|
||||||
|
private final StatefulRedisPubSubConnection<String, String> connection;
|
||||||
|
private final RedisPubSubCommands<String, String> sync;
|
||||||
|
|
||||||
private RedisClient client;
|
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
private StatefulRedisPubSubConnection<String, String> connection;
|
private final Type userType = new TypeToken<SimpleChatUser>() {}.getType();
|
||||||
private RedisPubSubCommands<String, String> sync;
|
|
||||||
|
|
||||||
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
|
||||||
private Type userType = new TypeToken<SimpleChatUser>() {}.getType();
|
|
||||||
|
|
||||||
public RedisManager(SimpleChat simpleChat) {
|
public RedisManager(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
|
||||||
|
|
||||||
String host = simpleChat.getConfig().getString("redis.host");
|
String host = simpleChat.getConfig().getString("redis.host");
|
||||||
int port = simpleChat.getConfig().getInt("redis.port");
|
int port = simpleChat.getConfig().getInt("redis.port");
|
||||||
|
|||||||
+2
-2
@@ -30,8 +30,8 @@ public class JSONUserService extends UserService {
|
|||||||
.removalListener(this::saveUser)
|
.removalListener(this::saveUser)
|
||||||
.build(CacheLoader.from(this::loadUser));
|
.build(CacheLoader.from(this::loadUser));
|
||||||
|
|
||||||
private Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
private final Gson gson = new GsonBuilder().setPrettyPrinting().create();
|
||||||
private Type userType = new TypeToken<SimpleChatUser>() {}.getType();
|
private final Type userType = new TypeToken<SimpleChatUser>() {}.getType();
|
||||||
|
|
||||||
public JSONUserService(SimpleChat simpleChat) {
|
public JSONUserService(SimpleChat simpleChat) {
|
||||||
this.simpleChat =simpleChat;
|
this.simpleChat =simpleChat;
|
||||||
|
|||||||
+2
-4
@@ -30,10 +30,8 @@ public class MySQLUserService extends UserService {
|
|||||||
.removalListener(this::saveUser)
|
.removalListener(this::saveUser)
|
||||||
.build(CacheLoader.from(this::loadUser));
|
.build(CacheLoader.from(this::loadUser));
|
||||||
|
|
||||||
private SimpleChat simpleChat;
|
private final SimpleChat simpleChat;
|
||||||
private Database database;
|
private final Database database;
|
||||||
|
|
||||||
private MySQLUserService() { }
|
|
||||||
|
|
||||||
public MySQLUserService(SimpleChat simpleChat) {
|
public MySQLUserService(SimpleChat simpleChat) {
|
||||||
this.simpleChat = simpleChat;
|
this.simpleChat = simpleChat;
|
||||||
|
|||||||
+3
-3
@@ -21,13 +21,13 @@ import java.util.*;
|
|||||||
|
|
||||||
public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
public class SimpleChatUser implements ChatUser, ForwardingAudience {
|
||||||
|
|
||||||
private transient SimpleChat simpleChat;
|
private final transient SimpleChat simpleChat;
|
||||||
|
|
||||||
private UUID uuid;
|
private UUID uuid;
|
||||||
|
|
||||||
private String selectedChannel = null;
|
private String selectedChannel = null;
|
||||||
private Map<String, SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
private final Map<String, SimpleUserChannelSettings> channelSettings = new HashMap<>();
|
||||||
private List<UUID> ignoredUsers = new ArrayList<>();
|
private final List<UUID> ignoredUsers = new ArrayList<>();
|
||||||
private boolean muted = false;
|
private boolean muted = false;
|
||||||
private boolean shadowMuted = false;
|
private boolean shadowMuted = false;
|
||||||
private boolean spyingWhispers = false;
|
private boolean spyingWhispers = false;
|
||||||
|
|||||||
Reference in new issue
Block a user