Make variables final if they can be. (#1843)

* Make variables final if they can be.

* Do not use final so that test can pass.

For testing, we use a trick to set this variable, but it won't work if
it is final. Right now, I'd like to keep the test.
This commit is contained in:
tastybento 2021-08-29 18:17:21 -07:00 committed by GitHub
parent a9a7673ce8
commit 9dc4ebc2d1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
98 changed files with 201 additions and 179 deletions

View File

@ -40,7 +40,7 @@ public abstract class Addon {
private FileConfiguration config;
private File dataFolder;
private File file;
private Map<String, AddonRequestHandler> requestHandlers = new HashMap<>();
private final Map<String, AddonRequestHandler> requestHandlers = new HashMap<>();
protected Addon() {
state = State.DISABLED;

View File

@ -30,8 +30,8 @@ import world.bentobox.bentobox.managers.AddonsManager;
public class AddonClassLoader extends URLClassLoader {
private final Map<String, Class<?>> classes = new HashMap<>();
private Addon addon;
private AddonsManager loader;
private final Addon addon;
private final AddonsManager loader;
public AddonClassLoader(AddonsManager addonsManager, YamlConfiguration data, File jarFile, ClassLoader parent)
throws InvalidAddonInheritException,

View File

@ -163,9 +163,12 @@ public final class AddonDescription {
}
public static class Builder {
private @NonNull String main;
private @NonNull String name;
private @NonNull String version;
private @NonNull
final String main;
private @NonNull
final String name;
private @NonNull
final String version;
private @NonNull String description = "";
private @NonNull List<String> authors = new ArrayList<>();
private @NonNull List<String> dependencies = new ArrayList<>();

View File

@ -20,7 +20,7 @@ public class AddonRequestBuilder
{
private String addonName;
private String requestLabel;
private Map<String, Object> metaData = new HashMap<>();
private final Map<String, Object> metaData = new HashMap<>();
/**
* Define the addon you wish to request.

View File

@ -78,12 +78,12 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
/**
* Map of sub commands
*/
private Map<String, CompositeCommand> subCommands;
private final Map<String, CompositeCommand> subCommands;
/**
* Map of aliases for subcommands
*/
private Map<String, CompositeCommand> subCommandAliases;
private final Map<String, CompositeCommand> subCommandAliases;
/**
* The command chain from the very top, e.g., island team promote
*/
@ -93,7 +93,7 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
* The prefix to be used in this command
*/
@Nullable
private String permissionPrefix;
private final String permissionPrefix;
/**
* The world that this command operates in. This is an overworld and will cover any associated nether or end
@ -104,17 +104,17 @@ public abstract class CompositeCommand extends Command implements PluginIdentifi
/**
* The addon creating this command, if any
*/
private Addon addon;
private final Addon addon;
/**
* The top level label
*/
private String topLabel;
private final String topLabel;
/**
* Cool down tracker
*/
private Map<String, Map<String, Long>> cooldowns = new HashMap<>();
private final Map<String, Map<String, Long>> cooldowns = new HashMap<>();
/**
* Top level command

View File

@ -20,7 +20,7 @@ public abstract class ConfirmableCommand extends CompositeCommand {
/**
* Confirmation tracker
*/
private static Map<User, Confirmer> toBeConfirmed = new HashMap<>();
private static final Map<User, Confirmer> toBeConfirmed = new HashMap<>();
/**
* Top level command

View File

@ -26,7 +26,7 @@ public abstract class DelayedTeleportCommand extends CompositeCommand implements
/**
* User monitor map
*/
private static Map<UUID, DelayedCommand> toBeMonitored = new HashMap<>();
private static final Map<UUID, DelayedCommand> toBeMonitored = new HashMap<>();
@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
public void onPlayerMove(PlayerMoveEvent e) {

View File

@ -20,7 +20,7 @@ import world.bentobox.bentobox.util.Util;
*/
public class AdminResetFlagsCommand extends ConfirmableCommand {
private List<String> options;
private final List<String> options;
public AdminResetFlagsCommand(CompositeCommand parent) {
super(parent, "resetflags");

View File

@ -38,7 +38,7 @@ public class AdminSettingsCommand extends CompositeCommand {
private final List<String> PROTECTION_FLAG_NAMES;
private Island island;
private final List<String> SETTING_FLAG_NAMES;
private List<String> WORLD_SETTING_FLAG_NAMES;
private final List<String> WORLD_SETTING_FLAG_NAMES;
private @NonNull Optional<Flag> flag = Optional.empty();
private boolean activeState;
private int rank;

View File

@ -24,7 +24,7 @@ public class AdminRangeDisplayCommand extends CompositeCommand {
private static final String HIDE = "hide";
// Map of users to which ranges must be displayed
private Map<User, Integer> displayRanges = new HashMap<>();
private final Map<User, Integer> displayRanges = new HashMap<>();
public AdminRangeDisplayCommand(CompositeCommand parent) {
super(parent, DISPLAY, SHOW, HIDE);

View File

@ -29,7 +29,7 @@ public class IslandTeamCommand extends CompositeCommand {
* Invited list. Key is the invited party, value is the invite.
* @since 1.8.0
*/
private Map<UUID, Invite> inviteMap;
private final Map<UUID, Invite> inviteMap;
public IslandTeamCommand(CompositeCommand parent) {
super(parent, "team");

View File

@ -22,7 +22,7 @@ import world.bentobox.bentobox.util.Util;
*/
public class IslandTeamCoopCommand extends CompositeCommand {
private IslandTeamCommand itc;
private final IslandTeamCommand itc;
private @Nullable UUID targetUUID;
public IslandTeamCoopCommand(IslandTeamCommand parentCommand) {

View File

@ -20,7 +20,7 @@ import world.bentobox.bentobox.util.Util;
*/
public class IslandTeamInviteAcceptCommand extends ConfirmableCommand {
private IslandTeamCommand itc;
private final IslandTeamCommand itc;
private UUID playerUUID;
private UUID prospectiveOwnerUUID;

View File

@ -20,7 +20,7 @@ import world.bentobox.bentobox.util.Util;
public class IslandTeamInviteCommand extends CompositeCommand {
private IslandTeamCommand itc;
private final IslandTeamCommand itc;
private @Nullable User invitedPlayer;
public IslandTeamInviteCommand(IslandTeamCommand parent) {

View File

@ -11,7 +11,7 @@ import world.bentobox.bentobox.api.user.User;
public class IslandTeamInviteRejectCommand extends CompositeCommand {
private IslandTeamCommand itc;
private final IslandTeamCommand itc;
public IslandTeamInviteRejectCommand(IslandTeamCommand islandTeamCommand) {
super(islandTeamCommand, "reject");

View File

@ -22,8 +22,8 @@ import world.bentobox.bentobox.database.yaml.YamlDatabase;
*/
public class Config<T> {
private AbstractDatabaseHandler<T> handler;
private Logger logger;
private final AbstractDatabaseHandler<T> handler;
private final Logger logger;
private Addon addon;
public Config(BentoBox plugin, Class<T> type) {

View File

@ -53,7 +53,8 @@ public class Flag implements Comparable<Flag> {
*/
WORLD_SETTING(Material.GRASS_BLOCK);
private @NonNull Material icon;
private @NonNull
final Material icon;
Type(@NonNull Material icon) {
this.icon = icon;
@ -482,8 +483,8 @@ public class Flag implements Comparable<Flag> {
*/
public static class Builder {
// Mandatory fields
private String id;
private Material icon;
private final String id;
private final Material icon;
// Listener
private Listener listener;
@ -512,7 +513,7 @@ public class Flag implements Comparable<Flag> {
private Mode mode = Mode.EXPERT;
// Subflags
private Set<Flag> subflags;
private final Set<Flag> subflags;
/**
* Builder for making flags

View File

@ -23,8 +23,8 @@ import world.bentobox.bentobox.util.Util;
*/
public class IslandToggleClick implements ClickHandler {
private BentoBox plugin = BentoBox.getInstance();
private String id;
private final BentoBox plugin = BentoBox.getInstance();
private final String id;
/**
* @param id - the flag ID that this click listener is associated with

View File

@ -20,16 +20,16 @@ public class BentoBoxLocale {
private static final String UNKNOWN = "unknown";
private Locale locale;
private YamlConfiguration config;
private ItemStack banner;
private List<String> authors;
private final Locale locale;
private final YamlConfiguration config;
private final ItemStack banner;
private final List<String> authors;
/**
* List of available prefixes in this locale.
* @since 1.12.0
*/
private Set<String> prefixes;
private final Set<String> prefixes;
public BentoBoxLocale(Locale locale, YamlConfiguration config) {
this.locale = locale;

View File

@ -47,7 +47,7 @@ public class LogEntry {
public static class Builder {
private long timestamp;
private String type;
private final String type;
private Map<String, String> data;
public Builder(@NonNull String type) {

View File

@ -29,7 +29,7 @@ public class PanelItem {
private String name;
private boolean glow;
private ItemMeta meta;
private String playerHeadName;
private final String playerHeadName;
private boolean invisible;
public PanelItem(PanelItemBuilder builtItem) {

View File

@ -31,7 +31,8 @@ public class TabbedPanel extends Panel implements PanelListener {
private static final String PROTECTION_PANEL = "protection.panel.";
private static final long ITEMS_PER_PAGE = 36;
private final TabbedPanelBuilder tpb;
private @NonNull BentoBox plugin = BentoBox.getInstance();
private @NonNull
final BentoBox plugin = BentoBox.getInstance();
private int activeTab;
private int activePage;
private boolean closed;

View File

@ -3,7 +3,7 @@ package world.bentobox.bentobox.api.placeholders.placeholderapi;
import world.bentobox.bentobox.api.addons.Addon;
public class AddonPlaceholderExpansion extends BasicPlaceholderExpansion {
private Addon addon;
private final Addon addon;
public AddonPlaceholderExpansion(Addon addon) {
this.addon = addon;

View File

@ -16,7 +16,7 @@ import world.bentobox.bentobox.api.user.User;
*/
abstract class BasicPlaceholderExpansion extends PlaceholderExpansion {
@NonNull
private Map<@NonNull String, @NonNull PlaceholderReplacer> placeholders;
private final Map<@NonNull String, @NonNull PlaceholderReplacer> placeholders;
BasicPlaceholderExpansion() {
super();

View File

@ -3,7 +3,7 @@ package world.bentobox.bentobox.api.placeholders.placeholderapi;
import world.bentobox.bentobox.BentoBox;
public class BentoBoxPlaceholderExpansion extends BasicPlaceholderExpansion {
private BentoBox plugin;
private final BentoBox plugin;
public BentoBoxPlaceholderExpansion(BentoBox plugin) {
super();

View File

@ -47,7 +47,7 @@ import world.bentobox.bentobox.util.Util;
*/
public class User implements MetaDataAble {
private static Map<UUID, User> users = new HashMap<>();
private static final Map<UUID, User> users = new HashMap<>();
/**
* Clears all users from the user list
@ -136,7 +136,7 @@ public class User implements MetaDataAble {
private static BentoBox plugin = BentoBox.getInstance();
@Nullable
private Player player;
private final Player player;
private OfflinePlayer offlinePlayer;
private final UUID playerUUID;
@Nullable

View File

@ -63,10 +63,10 @@ public class BlueprintClipboard {
private boolean copying;
private int index;
private int lastPercentage;
private Map<Vector, List<BlueprintEntity>> bpEntities = new LinkedHashMap<>();
private Map<Vector, BlueprintBlock> bpAttachable = new LinkedHashMap<>();
private Map<Vector, BlueprintBlock> bpBlocks = new LinkedHashMap<>();
private BentoBox plugin = BentoBox.getInstance();
private final Map<Vector, List<BlueprintEntity>> bpEntities = new LinkedHashMap<>();
private final Map<Vector, BlueprintBlock> bpAttachable = new LinkedHashMap<>();
private final Map<Vector, BlueprintBlock> bpBlocks = new LinkedHashMap<>();
private final BentoBox plugin = BentoBox.getInstance();
/**
* Create a clipboard for blueprint

View File

@ -72,7 +72,7 @@ public class BlueprintPaster {
private static final Map<String, String> BLOCK_CONVERSION = ImmutableMap.of("sign", "oak_sign", "wall_sign", "oak_wall_sign");
private BentoBox plugin;
private final BentoBox plugin;
// The minimum block position (x,y,z)
private Location pos1;
// The maximum block position (x,y,z)
@ -85,19 +85,19 @@ public class BlueprintPaster {
* The Blueprint to paste.
*/
@NonNull
private Blueprint blueprint;
private final Blueprint blueprint;
/**
* The Location to paste to.
*/
@NonNull
private Location location;
private final Location location;
/**
* Island related to this paste, may be null.
*/
@Nullable
private Island island;
private final Island island;
/**
* Paste a clipboard to a location and run task

View File

@ -23,8 +23,8 @@ import world.bentobox.bentobox.util.Util;
public class DescriptionPrompt extends StringPrompt {
private static final String DESCRIPTION = "description";
private GameModeAddon addon;
private BlueprintBundle bb;
private final GameModeAddon addon;
private final BlueprintBundle bb;
public DescriptionPrompt(GameModeAddon addon, BlueprintBundle bb) {
this.addon = addon;

View File

@ -15,8 +15,8 @@ import world.bentobox.bentobox.panels.BlueprintManagementPanel;
public class DescriptionSuccessPrompt extends MessagePrompt {
private GameModeAddon addon;
private BlueprintBundle bb;
private final GameModeAddon addon;
private final BlueprintBundle bb;
/**
* @param addon game mode addon

View File

@ -20,9 +20,9 @@ import world.bentobox.bentobox.util.Util;
public class NamePrompt extends StringPrompt {
private GameModeAddon addon;
private final GameModeAddon addon;
@Nullable
private BlueprintBundle bb;
private final BlueprintBundle bb;
@Nullable
private Blueprint bp;

View File

@ -17,9 +17,9 @@ import world.bentobox.bentobox.panels.BlueprintManagementPanel;
public class NameSuccessPrompt extends MessagePrompt {
private GameModeAddon addon;
private final GameModeAddon addon;
private BlueprintBundle bb;
private Blueprint bp;
private final Blueprint bp;
/**
* Handles the name processing

View File

@ -11,7 +11,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardReader;
*/
public class BlueprintClipboardReader implements ClipboardReader {
private InputStream inputStream;
private final InputStream inputStream;
public BlueprintClipboardReader(InputStream inputStream) {
this.inputStream = inputStream;

View File

@ -11,7 +11,7 @@ import com.sk89q.worldedit.extent.clipboard.io.ClipboardWriter;
*/
public class BlueprintClipboardWriter implements ClipboardWriter {
private OutputStream outputStream;
private final OutputStream outputStream;
public BlueprintClipboardWriter(OutputStream outputStream) {
this.outputStream = outputStream;

View File

@ -21,8 +21,8 @@ import world.bentobox.bentobox.api.addons.Addon;
*/
public class Database<T> {
private AbstractDatabaseHandler<T> handler;
private Logger logger;
private final AbstractDatabaseHandler<T> handler;
private final Logger logger;
private static DatabaseSetup databaseSetup = DatabaseSetup.getDatabase();
/**

View File

@ -17,7 +17,7 @@ import world.bentobox.bentobox.database.DatabaseConnector;
*/
public abstract class AbstractJSONDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
private Gson gson;
private final Gson gson;
/**
* Constructor

View File

@ -6,7 +6,7 @@ import world.bentobox.bentobox.database.DatabaseSetup;
public class JSONDatabase implements DatabaseSetup {
private JSONDatabaseConnector connector = new JSONDatabaseConnector(BentoBox.getInstance());
private final JSONDatabaseConnector connector = new JSONDatabaseConnector(BentoBox.getInstance());
/* (non-Javadoc)
* @see world.bentobox.bentobox.database.DatabaseSetup#getHandler(java.lang.Class)

View File

@ -15,7 +15,7 @@ import world.bentobox.bentobox.api.flags.Flag;
public class FlagTypeAdapter extends TypeAdapter<Flag> {
private BentoBox plugin;
private final BentoBox plugin;
public FlagTypeAdapter(BentoBox plugin) {
this.plugin = plugin;

View File

@ -40,7 +40,7 @@ public class MongoDBDatabaseHandler<T> extends AbstractJSONDatabaseHandler<T> {
private static final String MONGO_ID = "_id";
private MongoCollection<Document> collection;
private DatabaseConnector dbConnecter;
private final DatabaseConnector dbConnecter;
/**
* Handles the connection to the database and creation of the initial database schema (tables) for

View File

@ -18,7 +18,7 @@ public class SQLConfiguration {
private String loadObjectsSQL;
private String renameTableSQL;
private final String tableName;
private boolean renameRequired;
private final boolean renameRequired;
private final String oldTableName;
public <T> SQLConfiguration(BentoBox plugin, Class<T> type) {

View File

@ -15,7 +15,7 @@ import world.bentobox.bentobox.database.DatabaseConnector;
public abstract class SQLDatabaseConnector implements DatabaseConnector {
protected String connectionUrl;
private DatabaseConnectionSettingsImpl dbSettings;
private final DatabaseConnectionSettingsImpl dbSettings;
protected static Connection connection = null;
protected static Set<Class<?>> types = new HashSet<>();

View File

@ -10,7 +10,7 @@ import world.bentobox.bentobox.database.DatabaseSetup;
*/
public class SQLiteDatabase implements DatabaseSetup {
private SQLiteDatabaseConnector connector = new SQLiteDatabaseConnector(BentoBox.getInstance());
private final SQLiteDatabaseConnector connector = new SQLiteDatabaseConnector(BentoBox.getInstance());
@Override
public <T> AbstractDatabaseHandler<T> getHandler(Class<T> dataObjectClass) {

View File

@ -19,8 +19,8 @@ import world.bentobox.bentobox.database.AbstractDatabaseHandler;
*/
public class TransitionDatabaseHandler<T> extends AbstractDatabaseHandler<T> {
private AbstractDatabaseHandler<T> fromHandler;
private AbstractDatabaseHandler<T> toHandler;
private final AbstractDatabaseHandler<T> fromHandler;
private final AbstractDatabaseHandler<T> toHandler;
/**
* Constructor

View File

@ -6,7 +6,7 @@ import world.bentobox.bentobox.database.DatabaseSetup;
public class YamlDatabase implements DatabaseSetup {
private YamlDatabaseConnector connector = new YamlDatabaseConnector(BentoBox.getInstance());
private final YamlDatabaseConnector connector = new YamlDatabaseConnector(BentoBox.getInstance());
/**
* Get the config

View File

@ -24,7 +24,7 @@ public class DynmapHook extends Hook {
private MarkerAPI markerAPI;
@NonNull
private Map<@NonNull GameModeAddon, @NonNull MarkerSet> markerSets;
private final Map<@NonNull GameModeAddon, @NonNull MarkerSet> markerSets;
public DynmapHook() {
super("dynmap", Material.FILLED_MAP);

View File

@ -26,7 +26,7 @@ import world.bentobox.bentobox.api.placeholders.placeholderapi.BentoBoxPlacehold
public class PlaceholderAPIHook extends PlaceholderHook {
private BentoBoxPlaceholderExpansion bentoboxExpansion;
private Map<Addon, AddonPlaceholderExpansion> addonsExpansions;
private final Map<Addon, AddonPlaceholderExpansion> addonsExpansions;
private final Set<String> bentoBoxPlaceholders;
private final Map<Addon, Set<String>> addonPlaceholders;

View File

@ -19,7 +19,7 @@ import world.bentobox.bentobox.lists.Flags;
*/
public class BannedCommands implements Listener {
private BentoBox plugin;
private final BentoBox plugin;
/**
* @param plugin - plugin

View File

@ -18,7 +18,7 @@ import world.bentobox.bentobox.lists.Flags;
public class BlockEndDragon implements Listener {
private BentoBox plugin;
private final BentoBox plugin;
public BlockEndDragon(@NonNull BentoBox plugin) {
this.plugin = plugin;

View File

@ -15,7 +15,7 @@ import world.bentobox.bentobox.BentoBox;
*/
public class DeathListener implements Listener {
private BentoBox plugin;
private final BentoBox plugin;
public DeathListener(@NonNull BentoBox plugin) {
super();

View File

@ -32,8 +32,8 @@ import world.bentobox.bentobox.util.Util;
public class JoinLeaveListener implements Listener {
private BentoBox plugin;
private PlayersManager players;
private final BentoBox plugin;
private final PlayersManager players;
/**
* @param plugin - plugin object

View File

@ -24,7 +24,7 @@ import world.bentobox.bentobox.api.user.User;
public class PanelListenerManager implements Listener {
private static HashMap<UUID, Panel> openPanels = new HashMap<>();
private static final HashMap<UUID, Panel> openPanels = new HashMap<>();
@EventHandler(priority = EventPriority.HIGHEST)
public void onInventoryClick(InventoryClickEvent event) {

View File

@ -43,8 +43,8 @@ import world.bentobox.bentobox.util.teleport.SafeSpotTeleport;
public class PortalTeleportationListener implements Listener {
private final BentoBox plugin;
private Set<UUID> inPortal;
private Set<UUID> inTeleport;
private final Set<UUID> inPortal;
private final Set<UUID> inTeleport;
public PortalTeleportationListener(@NonNull BentoBox plugin) {
this.plugin = plugin;

View File

@ -17,9 +17,9 @@ import world.bentobox.bentobox.managers.RanksManager;
*/
public class CommandCycleClick implements ClickHandler {
private BentoBox plugin = BentoBox.getInstance();
private String command;
private CommandRankClickListener commandRankClickListener;
private final BentoBox plugin = BentoBox.getInstance();
private final String command;
private final CommandRankClickListener commandRankClickListener;
public CommandCycleClick(CommandRankClickListener commandRankClickListener, String c) {
this.commandRankClickListener = commandRankClickListener;

View File

@ -29,7 +29,7 @@ import world.bentobox.bentobox.util.Util;
*/
public class CommandRankClickListener implements ClickHandler {
private BentoBox plugin = BentoBox.getInstance();
private final BentoBox plugin = BentoBox.getInstance();
/* (non-Javadoc)
* @see world.bentobox.bentobox.api.panels.PanelItem.ClickHandler#onClick(world.bentobox.bentobox.api.panels.Panel, world.bentobox.bentobox.api.user.User, org.bukkit.event.inventory.ClickType, int)

View File

@ -41,8 +41,8 @@ import world.bentobox.bentobox.versions.ServerCompatibility;
*/
public class HurtingListener extends FlagListener {
private Map<Integer, Player> thrownPotions = new HashMap<>();
private Map<Entity, Entity> firedFireworks = new WeakHashMap<>();
private final Map<Integer, Player> thrownPotions = new HashMap<>();
private final Map<Entity, Entity> firedFireworks = new WeakHashMap<>();
/**
* Handles mob and monster protection

View File

@ -40,8 +40,8 @@ import world.bentobox.bentobox.managers.RanksManager;
*/
public class PVPListener extends FlagListener {
private Map<Integer, UUID> thrownPotions = new HashMap<>();
private Map<Entity, Player> firedFireworks = new WeakHashMap<>();
private final Map<Integer, UUID> thrownPotions = new HashMap<>();
private final Map<Entity, Player> firedFireworks = new WeakHashMap<>();
/**
* This method protects players from PVP if it is not allowed and from

View File

@ -31,14 +31,14 @@ import world.bentobox.bentobox.util.Pair;
*/
public class CleanSuperFlatListener extends FlagListener {
private BentoBox plugin = BentoBox.getInstance();
private final BentoBox plugin = BentoBox.getInstance();
/**
* Stores pairs of X,Z coordinates of chunks that need to be regenerated.
* @since 1.1
*/
@NonNull
private Queue<@NonNull Pair<@NonNull Integer, @NonNull Integer>> chunkQueue = new LinkedList<>();
private final Queue<@NonNull Pair<@NonNull Integer, @NonNull Integer>> chunkQueue = new LinkedList<>();
/**
* Task that runs each tick to regenerate chunks that are in the {@link #chunkQueue}.

View File

@ -24,7 +24,7 @@ import world.bentobox.bentobox.database.objects.Island;
*/
public class GeoLimitMobsListener extends FlagListener {
private Map<Entity, Island> mobSpawnTracker = new WeakHashMap<>();
private final Map<Entity, Island> mobSpawnTracker = new WeakHashMap<>();
/**
* Start the tracker when the plugin is loaded

View File

@ -422,7 +422,7 @@ public final class Flags {
.listener(new PistonPushListener())
.build();
private static InvincibleVisitorsListener ilv = new InvincibleVisitorsListener();
private static final InvincibleVisitorsListener ilv = new InvincibleVisitorsListener();
public static final Flag INVINCIBLE_VISITORS = new Flag.Builder("INVINCIBLE_VISITORS", Material.DIAMOND_CHESTPLATE).type(Type.WORLD_SETTING)
.listener(ilv).clickHandler(ilv).usePanel(true).build();

View File

@ -319,11 +319,11 @@ public enum GameModePlaceholder {
*/
OWNS_ISLAND("owns_island", (addon, user, island) -> String.valueOf(island != null && user != null && user.getUniqueId().equals(island.getOwner())));
private String placeholder;
private final String placeholder;
/**
* @since 1.5.0
*/
private GameModePlaceholderReplacer replacer;
private final GameModePlaceholderReplacer replacer;
GameModePlaceholder(String placeholder, GameModePlaceholderReplacer replacer) {
this.placeholder = placeholder;

View File

@ -62,14 +62,16 @@ public class AddonsManager {
private static final String GAMEMODE = "[gamemode].";
@NonNull
private List<Addon> addons;
private final List<Addon> addons;
@NonNull
private Map<@NonNull Addon, @Nullable AddonClassLoader> loaders;
private final Map<@NonNull Addon, @Nullable AddonClassLoader> loaders;
@NonNull
private final Map<String, Class<?>> classes;
private BentoBox plugin;
private @NonNull Map<@NonNull String, @Nullable GameModeAddon> worldNames;
private @NonNull Map<@NonNull Addon, @NonNull List<Listener>> listeners;
private final BentoBox plugin;
private @NonNull
final Map<@NonNull String, @Nullable GameModeAddon> worldNames;
private @NonNull
final Map<@NonNull Addon, @NonNull List<Listener>> listeners;
private final PluginLoader pluginLoader;

View File

@ -35,13 +35,13 @@ public class BlueprintClipboardManager {
private static final String LOAD_ERROR = "Could not load blueprint file - does not exist : ";
private File blueprintFolder;
private final File blueprintFolder;
private BlueprintClipboard clipboard;
private Gson gson;
private BentoBox plugin;
private final BentoBox plugin;
public BlueprintClipboardManager(BentoBox plugin, File blueprintFolder) {
this(plugin, blueprintFolder, null);

View File

@ -67,13 +67,15 @@ public class BlueprintsManager {
* Inner map's key is the uniqueId of the blueprint bundle so it's
* easy to get from a UI
*/
private @NonNull Map<GameModeAddon, List<BlueprintBundle>> blueprintBundles;
private @NonNull
final Map<GameModeAddon, List<BlueprintBundle>> blueprintBundles;
/**
* Map of blueprints. There can be many blueprints per game mode addon
* Inner map's key is the blueprint's name so it's easy to get from a UI
*/
private @NonNull Map<GameModeAddon, List<Blueprint>> blueprints;
private @NonNull
final Map<GameModeAddon, List<Blueprint>> blueprints;
/**
* Gson used for serializing/deserializing the bundle class
@ -82,7 +84,8 @@ public class BlueprintsManager {
private final @NonNull BentoBox plugin;
private @NonNull Set<GameModeAddon> blueprintsLoaded;
private @NonNull
final Set<GameModeAddon> blueprintsLoaded;
public BlueprintsManager(@NonNull BentoBox plugin) {

View File

@ -18,7 +18,7 @@ import world.bentobox.bentobox.api.commands.CompositeCommand;
public class CommandsManager {
@NonNull
private Map<@NonNull String, @NonNull CompositeCommand> commands = new HashMap<>();
private final Map<@NonNull String, @NonNull CompositeCommand> commands = new HashMap<>();
private SimpleCommandMap commandMap;
public void registerCommand(@NonNull CompositeCommand command) {

View File

@ -23,8 +23,9 @@ import world.bentobox.bentobox.lists.Flags;
*/
public class FlagsManager {
private @NonNull BentoBox plugin;
private Map<@NonNull Flag, @Nullable Addon> flags = new HashMap<>();
private @NonNull
final BentoBox plugin;
private final Map<@NonNull Flag, @Nullable Addon> flags = new HashMap<>();
/**
* Stores the flag listeners that have already been registered into Bukkit's API to avoid duplicates.
@ -32,7 +33,7 @@ public class FlagsManager {
* This helps to make sure each flag listener is loaded correctly.
* @see #registerListeners()
*/
private Map<@NonNull Listener, @NonNull Boolean> registeredListeners = new HashMap<>();
private final Map<@NonNull Listener, @NonNull Boolean> registeredListeners = new HashMap<>();
public FlagsManager(@NonNull BentoBox plugin) {
this.plugin = plugin;

View File

@ -19,7 +19,7 @@ import world.bentobox.bentobox.lists.GameModePlaceholder;
@Deprecated
public class GameModePlaceholderManager {
private BentoBox plugin;
private final BentoBox plugin;
public GameModePlaceholderManager(BentoBox plugin) {
this.plugin = plugin;

View File

@ -14,11 +14,11 @@ import world.bentobox.bentobox.api.hooks.Hook;
*/
public class HooksManager {
private BentoBox plugin;
private final BentoBox plugin;
/**
* List of successfully registered hooks.
*/
private List<Hook> hooks;
private final List<Hook> hooks;
public HooksManager(BentoBox plugin) {
this.plugin = plugin;

View File

@ -26,12 +26,12 @@ import world.bentobox.bentobox.util.Util;
*/
public class IslandDeletionManager implements Listener {
private BentoBox plugin;
private final BentoBox plugin;
/**
* Queue of islands to delete
*/
private Database<IslandDeletion> handler;
private Set<Location> inDeletion;
private final Database<IslandDeletion> handler;
private final Set<Location> inDeletion;
public IslandDeletionManager(BentoBox plugin) {
this.plugin = plugin;

View File

@ -34,11 +34,11 @@ import world.bentobox.bentobox.lists.Flags;
*/
public class IslandWorldManager {
private BentoBox plugin;
private final BentoBox plugin;
/**
* Map associating Worlds (Overworld, Nether and End) with the GameModeAddon that creates them.
*/
private Map<@NonNull World, @NonNull GameModeAddon> gameModes;
private final Map<@NonNull World, @NonNull GameModeAddon> gameModes;
/**
* Manages worlds registered with BentoBox

View File

@ -66,7 +66,7 @@ import world.bentobox.bentobox.util.teleport.SafeSpotTeleport;
*/
public class IslandsManager {
private BentoBox plugin;
private final BentoBox plugin;
// Tree species to boat material map
private static final Map<TreeSpecies, Material> TREE_TO_BOAT = ImmutableMap.<TreeSpecies, Material>builder().
@ -81,7 +81,7 @@ public class IslandsManager {
* One island can be spawn, this is the one - otherwise, this value is null
*/
@NonNull
private Map<@NonNull World, @Nullable Island> spawn;
private final Map<@NonNull World, @Nullable Island> spawn;
@NonNull
private Database<Island> handler;
@ -90,17 +90,17 @@ public class IslandsManager {
* The last locations where an island were put.
* This is not stored persistently and resets when the server starts
*/
private Map<World, Location> last;
private final Map<World, Location> last;
// Island Cache
@NonNull
private IslandCache islandCache;
// Quarantined islands
@NonNull
private Map<UUID, List<Island>> quarantineCache;
private final Map<UUID, List<Island>> quarantineCache;
// Deleted islands
@NonNull
private List<String> deletedIslands;
private final List<String> deletedIslands;
private boolean isSaveTaskRunning;

View File

@ -35,8 +35,8 @@ import world.bentobox.bentobox.util.Util;
*/
public class LocalesManager {
private BentoBox plugin;
private Map<Locale, BentoBoxLocale> languages = new HashMap<>();
private final BentoBox plugin;
private final Map<Locale, BentoBoxLocale> languages = new HashMap<>();
private static final String LOCALE_FOLDER = "locales";
private static final String BENTOBOX = "BentoBox";
private static final String SPACER = "*************************************************";

View File

@ -21,7 +21,7 @@ import world.bentobox.bentobox.lists.GameModePlaceholder;
*/
public class PlaceholdersManager {
private BentoBox plugin;
private final BentoBox plugin;
public PlaceholdersManager(BentoBox plugin) {
this.plugin = plugin;

View File

@ -28,12 +28,12 @@ import world.bentobox.bentobox.util.Util;
public class PlayersManager {
private BentoBox plugin;
private final BentoBox plugin;
private Database<Players> handler;
private Database<Names> names;
private final Database<Names> names;
private Map<UUID, Players> playerCache;
private Set<UUID> inTeleport;
private final Map<UUID, Players> playerCache;
private final Set<UUID> inTeleport;
private boolean isSaveTaskRunning;

View File

@ -34,11 +34,15 @@ import world.bentobox.bentobox.web.credits.Contributor;
*/
public class WebManager {
private @NonNull BentoBox plugin;
private @NonNull
final BentoBox plugin;
private @Nullable GitHubWebAPI gitHub;
private @NonNull List<CatalogEntry> addonsCatalog;
private @NonNull List<CatalogEntry> gamemodesCatalog;
private @NonNull Map<String, List<Contributor>> contributors;
private @NonNull
final List<CatalogEntry> addonsCatalog;
private @NonNull
final List<CatalogEntry> gamemodesCatalog;
private @NonNull
final Map<String, List<Contributor>> contributors;
public WebManager(@NonNull BentoBox plugin) {
this.plugin = plugin;

View File

@ -12,8 +12,8 @@ import world.bentobox.bentobox.database.objects.Island;
*
*/
class IslandGrid {
private TreeMap<Integer, TreeMap<Integer, Island>> grid = new TreeMap<>();
private BentoBox plugin = BentoBox.getInstance();
private final TreeMap<Integer, TreeMap<Integer, Island>> grid = new TreeMap<>();
private final BentoBox plugin = BentoBox.getInstance();
/**
* Adds island to grid

View File

@ -26,14 +26,14 @@ import world.bentobox.bentobox.managers.BlueprintsManager;
*
*/
public class NewIsland {
private BentoBox plugin;
private final BentoBox plugin;
private Island island;
private final User user;
private final Reason reason;
private final World world;
private String name;
private final boolean noPaste;
private GameModeAddon addon;
private final GameModeAddon addon;
private NewIslandLocationStrategy locationStrategy;

View File

@ -52,7 +52,7 @@ public class BlueprintManagementPanel {
public static final int MAX_BP_SLOT = 35;
private static final String INSTRUCTION = "instruction";
private Entry<Integer, Blueprint> selected;
private Map<Integer, Blueprint> blueprints = new HashMap<>();
private final Map<Integer, Blueprint> blueprints = new HashMap<>();
private final User user;
private final GameModeAddon addon;

View File

@ -21,10 +21,10 @@ import world.bentobox.bentobox.blueprints.dataobjects.BlueprintBundle;
*/
public class IconChanger implements PanelListener {
private GameModeAddon addon;
private BlueprintBundle bb;
private BlueprintManagementPanel blueprintManagementPanel;
private BentoBox plugin;
private final GameModeAddon addon;
private final BlueprintBundle bb;
private final BlueprintManagementPanel blueprintManagementPanel;
private final BentoBox plugin;
/**
* Change the icon of a blueprint bundle or blueprint

View File

@ -33,9 +33,9 @@ public class DeleteIslandChunks {
private int chunkX;
private int chunkZ;
private BukkitTask task;
private IslandDeletion di;
private final IslandDeletion di;
private boolean inDelete;
private BentoBox plugin;
private final BentoBox plugin;
private NMSAbstraction nms;
public DeleteIslandChunks(BentoBox plugin, IslandDeletion di) {

View File

@ -20,7 +20,7 @@ import org.bukkit.plugin.java.JavaPlugin;
* @author Poslovitch
*/
public class FileLister{
private Plugin plugin;
private final Plugin plugin;
public FileLister(Plugin level){
plugin = level;

View File

@ -300,7 +300,7 @@ public class SafeSpotTeleport {
private String failureMessage = "";
private Location location;
private Runnable runnable;
private CompletableFuture<Boolean> result = new CompletableFuture<>();
private final CompletableFuture<Boolean> result = new CompletableFuture<>();
public Builder(BentoBox plugin) {
this.plugin = plugin;

View File

@ -17,7 +17,7 @@ public class ServerCompatibility {
// ---- SINGLETON ----
private static ServerCompatibility instance = new ServerCompatibility();
private static final ServerCompatibility instance = new ServerCompatibility();
public static ServerCompatibility getInstance() {
return instance;
@ -54,7 +54,7 @@ public class ServerCompatibility {
*/
INCOMPATIBLE(false);
private boolean canLaunch;
private final boolean canLaunch;
Compatibility(boolean canLaunch) {
this.canLaunch = canLaunch;
@ -85,7 +85,7 @@ public class ServerCompatibility {
*/
UNKNOWN(Compatibility.INCOMPATIBLE);
private Compatibility compatibility;
private final Compatibility compatibility;
/**
* @since 1.14.0
*/
@ -190,7 +190,7 @@ public class ServerCompatibility {
V1_17_1(Compatibility.COMPATIBLE)
;
private Compatibility compatibility;
private final Compatibility compatibility;
ServerVersion(Compatibility compatibility) {
this.compatibility = compatibility;

View File

@ -13,16 +13,22 @@ import com.google.gson.JsonObject;
*/
public class CatalogEntry {
private int slot;
private final int slot;
/**
* Defaults to {@link Material#PAPER}.
*/
private @NonNull Material icon;
private @NonNull String name;
private @NonNull String description;
private @Nullable String topic;
private @Nullable String tag;
private @NonNull String repository;
private @NonNull
final Material icon;
private @NonNull
final String name;
private @NonNull
final String description;
private @Nullable
final String topic;
private @Nullable
final String tag;
private @NonNull
final String repository;
public CatalogEntry(@NonNull JsonObject object) {
this.slot = object.get("slot").getAsInt();

View File

@ -9,8 +9,9 @@ import org.eclipse.jdt.annotation.NonNull;
*/
public class Contributor {
private @NonNull String name;
private int commits;
private @NonNull
final String name;
private final int commits;
public Contributor(@NonNull String name, int commits) {
this.name = name;

View File

@ -301,7 +301,7 @@ public class AddonTest {
* Utility methods
*/
private void createJarArchive(File archiveFile, List<File> tobeJaredList) {
byte buffer[] = new byte[BUFFER_SIZE];
byte[] buffer = new byte[BUFFER_SIZE];
// Open archive file
try (FileOutputStream stream = new FileOutputStream(archiveFile)) {
try (JarOutputStream out = new JarOutputStream(stream, new Manifest())) {

View File

@ -58,7 +58,7 @@ public class AdminResetFlagsCommandTest {
@Mock
private CompositeCommand ac;
private UUID uuid = UUID.randomUUID();
private final UUID uuid = UUID.randomUUID();
@Mock
private IslandsManager im;
@Mock

View File

@ -23,7 +23,7 @@ public class LogEntryListAdapterTest {
private LogEntryListAdapter a;
private YamlConfiguration config;
private List<LogEntry> history = new LinkedList<>();
private final List<LogEntry> history = new LinkedList<>();
private UUID target;
private UUID issuer;
private List<LogEntry> toLog;

View File

@ -66,7 +66,7 @@ public class MySQLDatabaseHandlerTest {
"}";
private MySQLDatabaseHandler<Island> handler;
private Island instance;
private String UNIQUE_ID = "xyz";
private final String UNIQUE_ID = "xyz";
@Mock
private MySQLDatabaseConnector dbConn;
@Mock

View File

@ -320,7 +320,7 @@ public class BannedCommandsTest {
*/
class MyWorldSettings implements WorldSettings {
private Map<String, Boolean> worldFlags = new HashMap<>();
private final Map<String, Boolean> worldFlags = new HashMap<>();
@Override
public @NonNull List<String> getOnLeaveCommands() {

View File

@ -277,7 +277,7 @@ public class BlockEndDragonTest {
*/
class MyWorldSettings implements WorldSettings {
private Map<String, Boolean> worldFlags = new HashMap<>();
private final Map<String, Boolean> worldFlags = new HashMap<>();
@Override
public @NonNull List<String> getOnLeaveCommands() {

View File

@ -128,8 +128,8 @@ public class PanelListenerManagerTest {
class MyView extends InventoryView {
private Inventory top;
private String name;
private final Inventory top;
private final String name;
/**
* @param name

View File

@ -56,9 +56,9 @@ public class BlockInteractionListenerTest extends AbstractCommonSetup {
@Mock
private Block clickedBlock;
private Map<Material, Flag> inHandItems = new EnumMap<>(Material.class);
private final Map<Material, Flag> inHandItems = new EnumMap<>(Material.class);
private Map<Material, Flag> clickedBlocks = new EnumMap<>(Material.class);
private final Map<Material, Flag> clickedBlocks = new EnumMap<>(Material.class);
private void setFlags() {
inHandItems.put(Material.ENDER_PEARL, Flags.ENDER_PEARL);

View File

@ -61,7 +61,7 @@ public class FireListenerTest {
@Mock
private World world;
private Map<String, Boolean> worldFlags = new HashMap<>();
private final Map<String, Boolean> worldFlags = new HashMap<>();
@Before
public void setUp() {

View File

@ -58,7 +58,7 @@ public class GameModePlaceholderTest {
private IslandWorldManager iwm;
@Mock
private IslandsManager im;
private RanksManager rm = new RanksManager();
private final RanksManager rm = new RanksManager();
@Mock
private @Nullable Location location;

View File

@ -56,7 +56,7 @@ public class BlueprintClipboardManagerTest {
private File blueprintFolder;
private String json = "{\n" +
private final String json = "{\n" +
" \"name\": \"blueprint\",\n" +
" \"attached\": {},\n" +
" \"entities\": {},\n" +
@ -78,7 +78,7 @@ public class BlueprintClipboardManagerTest {
" \"bedrock\": [-2.0, -16.0, -1.0]\n" +
"}";
private String jsonNoBedrock = "{\n" +
private final String jsonNoBedrock = "{\n" +
" \"name\": \"blueprint\",\n" +
" \"attached\": {},\n" +
" \"entities\": {},\n" +

View File

@ -667,7 +667,7 @@ public class BlueprintsManagerTest {
* Utility methods
*/
private void createJarArchive(File archiveFile, File folder, List<File> tobeJaredList) {
byte buffer[] = new byte[BUFFER_SIZE];
byte[] buffer = new byte[BUFFER_SIZE];
// Open archive file
try (FileOutputStream stream = new FileOutputStream(archiveFile)) {
try (JarOutputStream out = new JarOutputStream(stream, new Manifest())) {

View File

@ -49,7 +49,7 @@ public class IslandCacheTest {
@Mock
private Island island;
// UUID
private UUID owner = UUID.randomUUID();
private final UUID owner = UUID.randomUUID();
@Mock
private Location location;
// Test class

View File

@ -93,7 +93,7 @@ public class NewIslandTest {
@Mock
private BlueprintBundle bpb;
private UUID uuid = UUID.randomUUID();
private final UUID uuid = UUID.randomUUID();
@Mock
private BlueprintsManager bpm;