Quick cleanup

This commit is contained in:
kashike
2015-06-27 09:37:10 -07:00
parent 26781df8f4
commit f51efcfab2
13 changed files with 28 additions and 29 deletions
@@ -49,11 +49,11 @@ public class PlayerVaults extends JavaPlugin {
private static PlayerVaults instance; private static PlayerVaults instance;
private boolean update = false; private boolean update = false;
private String newVersion = ""; private String newVersion = "";
private HashMap<String, SignSetInfo> setSign = new HashMap<>(); private final HashMap<String, SignSetInfo> setSign = new HashMap<>();
// Player name - VaultViewInfo // Player name - VaultViewInfo
private HashMap<String, VaultViewInfo> inVault = new HashMap<>(); private final HashMap<String, VaultViewInfo> inVault = new HashMap<>();
// VaultViewInfo - Inventory // VaultViewInfo - Inventory
private HashMap<String, Inventory> openInventories = new HashMap<>(); private final HashMap<String, Inventory> openInventories = new HashMap<>();
private Economy economy = null; private Economy economy = null;
private boolean useVault = false; private boolean useVault = false;
private YamlConfiguration signs; private YamlConfiguration signs;
@@ -62,7 +62,7 @@ public class PlayerVaults extends JavaPlugin {
private boolean backupsEnabled; private boolean backupsEnabled;
private File backupsFolder = null; private File backupsFolder = null;
private File vaultData; private File vaultData;
private Set<Material> blockedMats = new HashSet<>(); private final Set<Material> blockedMats = new HashSet<>();
@Override @Override
public void onEnable() { public void onEnable() {
@@ -17,8 +17,8 @@ import java.util.*;
public class ConvertCommand implements CommandExecutor { public class ConvertCommand implements CommandExecutor {
private List<Converter> converters = new ArrayList<>(); private final List<Converter> converters = new ArrayList<>();
private ServiceProvider uuidProvider; private final ServiceProvider uuidProvider;
public ConvertCommand() { public ConvertCommand() {
converters.add(new BackpackConverter()); converters.add(new BackpackConverter());
@@ -23,7 +23,7 @@ package com.drtshock.playervaults.commands;
public class SignSetInfo { public class SignSetInfo {
private String owner; private String owner;
private int number; private final int number;
private boolean self = false; private boolean self = false;
/** /**
@@ -18,7 +18,7 @@ public interface Converter {
* *
* @return the number of vaults converted. Returns 0 on none converted or -1 if no vaults were converted. * @return the number of vaults converted. Returns 0 on none converted or -1 if no vaults were converted.
*/ */
public int run(CommandSender initiator, ServiceProvider uuidProvider); int run(CommandSender initiator, ServiceProvider uuidProvider);
/** /**
* Determines if this converter is applicable for converting to PlayerVaults. This may check for the existance of a * Determines if this converter is applicable for converting to PlayerVaults. This may check for the existance of a
@@ -26,13 +26,13 @@ public interface Converter {
* *
* @return true if this converter can convert, false otherwise * @return true if this converter can convert, false otherwise
*/ */
public boolean canConvert(); boolean canConvert();
/** /**
* Gets the name of this converter * Gets the name of this converter
* *
* @return the converter name * @return the converter name
*/ */
public String getName(); String getName();
} }
@@ -44,8 +44,8 @@ import java.io.IOException;
public class Listeners implements Listener { public class Listeners implements Listener {
public PlayerVaults plugin; public final PlayerVaults plugin;
UUIDVaultManager vm = UUIDVaultManager.getInstance(); final UUIDVaultManager vm = UUIDVaultManager.getInstance();
public Listeners(PlayerVaults playerVaults) { public Listeners(PlayerVaults playerVaults) {
this.plugin = playerVaults; this.plugin = playerVaults;
@@ -12,7 +12,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import java.util.UUID; import java.util.UUID;
public class VaultPreloadListener implements Listener { public class VaultPreloadListener implements Listener {
UUIDVaultManager vm = UUIDVaultManager.getInstance(); final UUIDVaultManager vm = UUIDVaultManager.getInstance();
@EventHandler(priority = EventPriority.MONITOR) @EventHandler(priority = EventPriority.MONITOR)
public void onPlayerJoin(PlayerJoinEvent event) { public void onPlayerJoin(PlayerJoinEvent event) {
@@ -6,7 +6,7 @@ import java.io.File;
public class Cleanup implements Runnable { public class Cleanup implements Runnable {
private long diff; private final long diff;
public Cleanup(int diff) { public Cleanup(int diff) {
this.diff = diff * 86400; this.diff = diff * 86400;
@@ -53,8 +53,8 @@ public enum Lang {
HELP("help", "/pv <number>"), HELP("help", "/pv <number>"),
BLOCKED_ITEM("blocked-item", "&6%m &cis blocked from vaults"); BLOCKED_ITEM("blocked-item", "&6%m &cis blocked from vaults");
private String path; private final String path;
private String def; private final String def;
private static YamlConfiguration LANG; private static YamlConfiguration LANG;
/** /**
@@ -406,7 +406,7 @@ public class Updater {
String version = plugin.getDescription().getVersion(); String version = plugin.getDescription().getVersion();
if (title.split("v").length == 2) { if (title.split("v").length == 2) {
String remoteVersion = title.split("v")[1].split(" ")[0]; // Get the newest file's version number String remoteVersion = title.split("v")[1].split(" ")[0]; // Get the newest file's version number
int remVer = -1, curVer = 0; int remVer, curVer = 0;
try { try {
remVer = calVer(remoteVersion); remVer = calVer(remoteVersion);
curVer = calVer(version); curVer = calVer(version);
@@ -30,8 +30,8 @@ import java.io.File;
* A class that handles all economy operations. * A class that handles all economy operations.
*/ */
public class EconomyOperations { public class EconomyOperations {
private static PlayerVaults PLUGIN = PlayerVaults.getInstance(); private static final PlayerVaults PLUGIN = PlayerVaults.getInstance();
private static FileConfiguration BUKKIT_CONFIG = PLUGIN.getConfig(); private static final FileConfiguration BUKKIT_CONFIG = PLUGIN.getConfig();
/** /**
* Have a player pay to open a vault. * Have a player pay to open a vault.
@@ -5,7 +5,6 @@ import com.drtshock.playervaults.util.Lang;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.Inventory; import org.bukkit.inventory.Inventory;
@@ -228,11 +227,13 @@ public class UUIDVaultManager {
}.runTaskAsynchronously(PlayerVaults.getInstance()); }.runTaskAsynchronously(PlayerVaults.getInstance());
OfflinePlayer player = Bukkit.getPlayer(holder); OfflinePlayer player = Bukkit.getPlayer(holder);
if (player != null && sender.getName().equalsIgnoreCase(player.getName())) { if (player != null) {
if (sender.getName().equalsIgnoreCase(player.getName())) {
sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_VAULT.toString().replace("%v", String.valueOf(number))); sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_VAULT.toString().replace("%v", String.valueOf(number)));
} else { } else {
sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_OTHER_VAULT.toString().replace("%v", String.valueOf(number)).replaceAll("%p", player.getName())); sender.sendMessage(Lang.TITLE.toString() + Lang.DELETE_OTHER_VAULT.toString().replace("%v", String.valueOf(number)).replaceAll("%p", player.getName()));
} }
}
PlayerVaults.getInstance().getOpenInventories().remove(new VaultViewInfo(holder.toString(), number).toString()); PlayerVaults.getInstance().getOpenInventories().remove(new VaultViewInfo(holder.toString(), number).toString());
} }
@@ -282,8 +283,6 @@ public class UUIDVaultManager {
* *
* @param holder The vault holder of whose file to save. * @param holder The vault holder of whose file to save.
* @param yaml The config to save. * @param yaml The config to save.
*
* @throws IOException Uh oh!
*/ */
public void saveFile(final UUID holder, final YamlConfiguration yaml) { public void saveFile(final UUID holder, final YamlConfiguration yaml) {
if (cachedVaultFiles.containsKey(holder)) { if (cachedVaultFiles.containsKey(holder)) {
@@ -30,7 +30,7 @@ import java.util.concurrent.atomic.AtomicBoolean;
public class VaultOperations { public class VaultOperations {
private static AtomicBoolean LOCKED = new AtomicBoolean(false); private static final AtomicBoolean LOCKED = new AtomicBoolean(false);
/** /**
* Gets whether or not player vaults are locked * Gets whether or not player vaults are locked
@@ -26,8 +26,8 @@ import java.util.UUID;
public class VaultViewInfo { public class VaultViewInfo {
UUID uuid; UUID uuid;
String holder; final String holder;
int number; final int number;
/** /**
* Make a VaultViewObject * Make a VaultViewObject