Use final fields where needed.

This commit is contained in:
benwoo1110 2020-12-15 11:26:59 +08:00
parent d93def8b5b
commit a4e87b13d2
23 changed files with 34 additions and 35 deletions

View File

@ -128,9 +128,9 @@ public class MultiverseCore extends JavaPlugin implements MVPlugin, Core {
private static final int PROTOCOL = 24; private static final int PROTOCOL = 24;
// TODO: Investigate if this one is really needed to be static. // TODO: Investigate if this one is really needed to be static.
// Doubt it. -- FernFerret // Doubt it. -- FernFerret
private static Map<String, String> teleportQueue = new HashMap<String, String>(); private static final Map<String, String> teleportQueue = new HashMap<String, String>();
private AnchorManager anchorManager = new AnchorManager(this); private final AnchorManager anchorManager = new AnchorManager(this);
// TODO please let's make this non-static // TODO please let's make this non-static
private volatile MultiverseCoreConfiguration config; private volatile MultiverseCoreConfiguration config;

View File

@ -20,7 +20,7 @@ import com.onarandombox.MultiverseCore.api.MVWorldManager;
* Creates a clone of a world. * Creates a clone of a world.
*/ */
public class CloneCommand extends MultiverseCommand { public class CloneCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public CloneCommand(MultiverseCore plugin) { public CloneCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -19,6 +19,7 @@ import java.util.Map;
* Allows you to set Global MV Variables. * Allows you to set Global MV Variables.
*/ */
public class ConfigCommand extends MultiverseCommand { public class ConfigCommand extends MultiverseCommand {
public ConfigCommand(MultiverseCore plugin) { public ConfigCommand(MultiverseCore plugin) {
super(plugin); super(plugin);
this.setName("Configuration"); this.setName("Configuration");

View File

@ -24,7 +24,7 @@ import java.util.List;
* Returns detailed information on the Players where abouts. * Returns detailed information on the Players where abouts.
*/ */
public class CoordCommand extends MultiverseCommand { public class CoordCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public CoordCommand(MultiverseCore plugin) { public CoordCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -26,7 +26,7 @@ import java.util.List;
* Creates a new world and loads it. * Creates a new world and loads it.
*/ */
public class CreateCommand extends MultiverseCommand { public class CreateCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public CreateCommand(MultiverseCore plugin) { public CreateCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -30,7 +30,7 @@ import java.util.List;
* Returns detailed information about a world. * Returns detailed information about a world.
*/ */
public class InfoCommand extends MultiverseCommand { public class InfoCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public InfoCommand(MultiverseCore plugin) { public InfoCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -25,7 +25,7 @@ import java.util.List;
* Used to modify various aspects of worlds. * Used to modify various aspects of worlds.
*/ */
public class ModifyAddCommand extends MultiverseCommand { public class ModifyAddCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public ModifyAddCommand(MultiverseCore plugin) { public ModifyAddCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -22,7 +22,7 @@ import java.util.List;
* Removes all values from a world-property. * Removes all values from a world-property.
*/ */
public class ModifyClearCommand extends MultiverseCommand { public class ModifyClearCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public ModifyClearCommand(MultiverseCore plugin) { public ModifyClearCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -22,7 +22,7 @@ import java.util.List;
* Removes values from a world-property. * Removes values from a world-property.
*/ */
public class ModifyRemoveCommand extends MultiverseCommand { public class ModifyRemoveCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public ModifyRemoveCommand(MultiverseCore plugin) { public ModifyRemoveCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -23,7 +23,7 @@ import java.util.List;
* Used to set world-properties. * Used to set world-properties.
*/ */
public class ModifySetCommand extends MultiverseCommand { public class ModifySetCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public ModifySetCommand(MultiverseCore plugin) { public ModifySetCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -24,7 +24,7 @@ import java.util.List;
* Removes a type of mob from a world. * Removes a type of mob from a world.
*/ */
public class PurgeCommand extends MultiverseCommand { public class PurgeCommand extends MultiverseCommand {
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public PurgeCommand(MultiverseCore plugin) { public PurgeCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -34,7 +34,7 @@ import java.util.logging.Level;
* Used to teleport players. * Used to teleport players.
*/ */
public class TeleportCommand extends MultiverseCommand { public class TeleportCommand extends MultiverseCommand {
private SafeTTeleporter playerTeleporter; private final SafeTTeleporter playerTeleporter;
public TeleportCommand(MultiverseCore plugin) { public TeleportCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -23,8 +23,7 @@ import java.util.List;
* States who is in what world. * States who is in what world.
*/ */
public class WhoCommand extends MultiverseCommand { public class WhoCommand extends MultiverseCommand {
private final MVWorldManager worldManager;
private MVWorldManager worldManager;
public WhoCommand(MultiverseCore plugin) { public WhoCommand(MultiverseCore plugin) {
super(plugin); super(plugin);

View File

@ -16,7 +16,7 @@ import java.util.List;
* Called when the Multiverse-config should be reloaded. * Called when the Multiverse-config should be reloaded.
*/ */
public class MVConfigReloadEvent extends Event { public class MVConfigReloadEvent extends Event {
private List<String> configsLoaded; private final List<String> configsLoaded;
public MVConfigReloadEvent(List<String> configsLoaded) { public MVConfigReloadEvent(List<String> configsLoaded) {
this.configsLoaded = configsLoaded; this.configsLoaded = configsLoaded;

View File

@ -17,8 +17,8 @@ import org.bukkit.event.HandlerList;
* This event is thrown when a portal is touched. * This event is thrown when a portal is touched.
*/ */
public class MVPlayerTouchedPortalEvent extends Event implements Cancellable { public class MVPlayerTouchedPortalEvent extends Event implements Cancellable {
private Player p; private final Player p;
private Location l; private final Location l;
private boolean isCancelled; private boolean isCancelled;
private boolean canUse = true; private boolean canUse = true;

View File

@ -16,10 +16,9 @@ import org.bukkit.event.HandlerList;
* Called when a player is respawning. * Called when a player is respawning.
*/ */
public class MVRespawnEvent extends Event { public class MVRespawnEvent extends Event {
private Player player; private final Player player;
private final String respawnMethod;
private Location location; private Location location;
private String respawnMethod;
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) { public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
this.player = p; this.player = p;

View File

@ -21,10 +21,10 @@ import org.bukkit.event.HandlerList;
* Event that gets called when a player use the /mvtp command. * Event that gets called when a player use the /mvtp command.
*/ */
public class MVTeleportEvent extends Event implements Cancellable { public class MVTeleportEvent extends Event implements Cancellable {
private Player teleportee; private final Player teleportee;
private CommandSender teleporter; private final CommandSender teleporter;
private MVDestination dest; private final MVDestination dest;
private boolean useSafeTeleport; private final boolean useSafeTeleport;
private boolean isCancelled; private boolean isCancelled;
public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) { public MVTeleportEvent(MVDestination dest, Player teleportee, CommandSender teleporter, boolean safeTeleport) {

View File

@ -24,11 +24,11 @@ import org.bukkit.event.HandlerList;
* @param <T> The type of the property that was set. * @param <T> The type of the property that was set.
*/ */
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable { public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
private MultiverseWorld world; private final MultiverseWorld world;
private CommandSender changer; private final CommandSender changer;
private boolean isCancelled = false; private final String name;
private String name;
private T value; private T value;
private boolean isCancelled = false;
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) { public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) {
this.world = world; this.world = world;

View File

@ -28,8 +28,8 @@ import java.util.logging.Level;
* Multiverse's Entity {@link Listener}. * Multiverse's Entity {@link Listener}.
*/ */
public class MVEntityListener implements Listener { public class MVEntityListener implements Listener {
private MultiverseCore plugin; private final MultiverseCore plugin;
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public MVEntityListener(MultiverseCore plugin) { public MVEntityListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -26,7 +26,7 @@ import java.util.logging.Level;
*/ */
public class MVPortalListener implements Listener { public class MVPortalListener implements Listener {
private MultiverseCore plugin; private final MultiverseCore plugin;
public MVPortalListener(MultiverseCore core) { public MVPortalListener(MultiverseCore core) {
this.plugin = core; this.plugin = core;

View File

@ -18,7 +18,7 @@ import org.bukkit.event.weather.WeatherChangeEvent;
* Multiverse's Weather {@link Listener}. * Multiverse's Weather {@link Listener}.
*/ */
public class MVWeatherListener implements Listener { public class MVWeatherListener implements Listener {
private MultiverseCore plugin; private final MultiverseCore plugin;
public MVWeatherListener(MultiverseCore plugin) { public MVWeatherListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -14,7 +14,7 @@ import org.bukkit.event.world.WorldInitEvent;
public class MVWorldInitListener implements Listener { public class MVWorldInitListener implements Listener {
MultiverseCore plugin; private final MultiverseCore plugin;
public MVWorldInitListener(MultiverseCore plugin) { public MVWorldInitListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;

View File

@ -20,8 +20,8 @@ import org.bukkit.event.world.WorldUnloadEvent;
* Multiverse's World {@link Listener}. * Multiverse's World {@link Listener}.
*/ */
public class MVWorldListener implements Listener { public class MVWorldListener implements Listener {
private MultiverseCore plugin; private final MultiverseCore plugin;
private MVWorldManager worldManager; private final MVWorldManager worldManager;
public MVWorldListener(MultiverseCore plugin) { public MVWorldListener(MultiverseCore plugin) {
this.plugin = plugin; this.plugin = plugin;