Code householding

- Move console initialization for tests into TestHelper
- Remove unused properties in legacy Settings
- Add issue number to TODO comments where applicable
This commit is contained in:
ljacqu
2016-04-14 12:28:19 +02:00
parent 3bb7ff2b85
commit ca0cbe6caf
23 changed files with 82 additions and 101 deletions
+6 -4
View File
@@ -106,23 +106,25 @@ public class AuthMe extends JavaPlugin {
private static Server server;
/*
* Maps and stuff
* TODO: Clean up and Move into a manager
*/
// TODO #601: Integrate CaptchaManager
public final ConcurrentHashMap<String, BukkitTask> sessions = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, Integer> captcha = new ConcurrentHashMap<>();
public final ConcurrentHashMap<String, String> cap = new ConcurrentHashMap<>();
/*
* Public Instances
* TODO #432: Encapsulation
*/
public NewAPI api;
// TODO #655: Encapsulate mail
public SendMailSSL mail;
// TODO #656: Encapsulate data manager
public DataManager dataManager;
/*
* Plugin Hooks
* TODO: Move into modules
* Private instances
* TODO #432: Move instantiation and management of these services
*/
// TODO #604: Encapsulate ProtocolLib members
public AuthMeInventoryPacketAdapter inventoryProtector;
public AuthMeTabCompletePacketAdapter tabComplete;
public AuthMeTablistPacketAdapter tablistHider;
@@ -122,69 +122,85 @@ public interface DataSource {
void close();
/**
* Method purgeBanned.
* Purge all given players, i.e. delete all players whose name is in the list.
*
* @param banned List of String
* @param banned the list of players to delete
*/
void purgeBanned(List<String> banned);
/**
* Method getType.
* Return the data source type.
*
* @return DataSourceType
* @return the data source type
*/
DataSourceType getType();
/**
* Method isLogged.
* Query the datasource whether the player is logged in or not.
*
* @param user String
*
* @return boolean
* @param user The name of the player to verify
* @return True if logged in, false otherwise
*/
boolean isLogged(String user);
/**
* Method setLogged.
* Set a player as logged in.
*
* @param user String
* @param user The name of the player to change
*/
void setLogged(String user);
/**
* Method setUnlogged.
* Set a player as unlogged (not logged in).
*
* @param user String
* @param user The name of the player to change
*/
void setUnlogged(String user);
/**
* Set all players who are marked as logged in as NOT logged in.
*/
void purgeLogged();
/**
* Method getAccountsRegistered.
* Return all players which are logged in.
*
* @return int
* @return All logged in players
*/
List<PlayerAuth> getLoggedPlayers();
/**
* Return the number of registered accounts.
*
* @return Total number of accounts
*/
int getAccountsRegistered();
/**
* Update a player's real name (capitalization).
*
* @param user The name of the user (lowercase)
* @param realName The real name of the user (proper casing)
* @return True upon success, false upon failure
*/
boolean updateRealName(String user, String realName);
/**
* Update a player's IP address.
*
* @param user The name of the user (lowercase)
* @param ip The IP address to save
* @return True upon success, false upon failure
*/
boolean updateIp(String user, String ip);
/**
* Method getAllAuths.
* Return all players of the database.
*
* @return List of PlayerAuth
* @return List of all players
*/
List<PlayerAuth> getAllAuths();
/**
* Method getLoggedPlayers.
*
* @return List of PlayerAuth
*/
List<PlayerAuth> getLoggedPlayers();
/**
* Reload the data source.
*/
@@ -33,7 +33,7 @@ public class AuthMeEntityListener implements Listener {
}
}
// TODO #360: npc status can be used to bypass security!!!
// Note #360: npc status can be used to bypass security!!!
@EventHandler(ignoreCancelled = true, priority = EventPriority.LOWEST)
public void onEntityDamage(EntityDamageEvent event) {
if (shouldCancelEvent(event)) {
@@ -24,7 +24,6 @@ import java.util.regex.Pattern;
public final class Settings {
public static final File PLUGIN_FOLDER = Wrapper.getInstance().getDataFolder();
public static final File MODULE_FOLDER = new File(PLUGIN_FOLDER, "modules");
public static final File CACHE_FOLDER = new File(PLUGIN_FOLDER, "cache");
public static List<String> allowCommands;
public static List<String> getJoinPermissions;
@@ -62,7 +61,7 @@ public final class Settings {
spawnPriority, crazyloginFileName, sendPlayerTo;
public static int getWarnMessageInterval, getSessionTimeout,
getRegistrationTimeout, getMaxNickLength, getMinNickLength,
getPasswordMinLen, getMovementRadius, getNonActivatedGroup, passwordMaxLength,
getMovementRadius, getNonActivatedGroup,
maxLoginTry, captchaLength, saltLength,
bCryptLog2Rounds, getMaxLoginPerIp, getMaxJoinPerIp;
protected static FileConfiguration configFile;
@@ -88,7 +87,6 @@ public final class Settings {
isChatAllowed = load(RestrictionSettings.ALLOW_CHAT);
getMaxNickLength = configFile.getInt("settings.restrictions.maxNicknameLength", 20);
getMinNickLength = configFile.getInt("settings.restrictions.minNicknameLength", 3);
getPasswordMinLen = configFile.getInt("settings.security.minPasswordLength", 4);
getNickRegex = configFile.getString("settings.restrictions.allowedNicknameCharacters", "[a-zA-Z0-9_?]*");
nickPattern = Pattern.compile(getNickRegex);
isAllowRestrictedIp = load(RestrictionSettings.ENABLE_RESTRICTED_USERS);
@@ -120,7 +118,6 @@ public final class Settings {
denyTabcompleteBeforeLogin = load(RestrictionSettings.DENY_TABCOMPLETE_BEFORE_LOGIN);
hideTablistBeforeLogin = load(RestrictionSettings.HIDE_TABLIST_BEFORE_LOGIN);
passwordMaxLength = load(SecuritySettings.MAX_PASSWORD_LENGTH);
backupWindowsPath = configFile.getString("BackupSystem.MysqlWindowsPath", "C:\\Program Files\\MySQL\\MySQL Server 5.1\\");
isStopEnabled = configFile.getBoolean("Security.SQLProblem.stopServer", true);
reloadSupport = configFile.getBoolean("Security.ReloadCommand.useReloadCommandSupport", true);