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;
// TODO: Investigate if this one is really needed to be static.
// 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
private volatile MultiverseCoreConfiguration config;

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -16,10 +16,9 @@ import org.bukkit.event.HandlerList;
* Called when a player is respawning.
*/
public class MVRespawnEvent extends Event {
private Player player;
private final Player player;
private final String respawnMethod;
private Location location;
private String respawnMethod;
public MVRespawnEvent(Location spawningAt, Player p, String respawnMethod) {
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.
*/
public class MVTeleportEvent extends Event implements Cancellable {
private Player teleportee;
private CommandSender teleporter;
private MVDestination dest;
private boolean useSafeTeleport;
private final Player teleportee;
private final CommandSender teleporter;
private final MVDestination dest;
private final boolean useSafeTeleport;
private boolean isCancelled;
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.
*/
public class MVWorldPropertyChangeEvent<T> extends Event implements Cancellable {
private MultiverseWorld world;
private CommandSender changer;
private boolean isCancelled = false;
private String name;
private final MultiverseWorld world;
private final CommandSender changer;
private final String name;
private T value;
private boolean isCancelled = false;
public MVWorldPropertyChangeEvent(MultiverseWorld world, CommandSender changer, String name, T value) {
this.world = world;

View File

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

View File

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

View File

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

View File

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

View File

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