Prepare the project for javadocs
This commit is contained in:
@@ -13,10 +13,16 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import fr.xephi.authme.AuthMe;
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class CustomConfiguration extends YamlConfiguration {
|
||||
|
||||
private File configFile;
|
||||
|
||||
/**
|
||||
* Constructor for CustomConfiguration.
|
||||
* @param file File
|
||||
*/
|
||||
public CustomConfiguration(File file) {
|
||||
this.configFile = file;
|
||||
load();
|
||||
@@ -35,6 +41,10 @@ public class CustomConfiguration extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method reLoad.
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean reLoad() {
|
||||
boolean out = true;
|
||||
if (!configFile.exists()) {
|
||||
@@ -53,10 +63,19 @@ public class CustomConfiguration extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getConfigFile.
|
||||
* @return File
|
||||
*/
|
||||
public File getConfigFile() {
|
||||
return configFile;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method loadResource.
|
||||
* @param file File
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean loadResource(File file) {
|
||||
if (!file.exists()) {
|
||||
try {
|
||||
|
||||
@@ -6,11 +6,18 @@ import org.bukkit.command.CommandSender;
|
||||
|
||||
import fr.xephi.authme.ConsoleLogger;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Messages extends CustomConfiguration {
|
||||
|
||||
private static Messages singleton = null;
|
||||
private String lang = "en";
|
||||
|
||||
/**
|
||||
* Constructor for Messages.
|
||||
* @param file File
|
||||
* @param lang String
|
||||
*/
|
||||
public Messages(File file, String lang) {
|
||||
super(file);
|
||||
load();
|
||||
@@ -18,6 +25,11 @@ public class Messages extends CustomConfiguration {
|
||||
this.lang = lang;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method send.
|
||||
* @param sender CommandSender
|
||||
* @param msg String
|
||||
*/
|
||||
public void send(CommandSender sender, String msg) {
|
||||
if (!Settings.messagesLanguage.equalsIgnoreCase(singleton.lang))
|
||||
singleton.reloadMessages();
|
||||
@@ -31,6 +43,11 @@ public class Messages extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method send.
|
||||
* @param msg String
|
||||
* @return String[]
|
||||
*/
|
||||
public String[] send(String msg) {
|
||||
if (!Settings.messagesLanguage.equalsIgnoreCase(singleton.lang)) {
|
||||
singleton.reloadMessages();
|
||||
@@ -54,6 +71,10 @@ public class Messages extends CustomConfiguration {
|
||||
return loc;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
* @return Messages
|
||||
*/
|
||||
public static Messages getInstance() {
|
||||
if (singleton == null) {
|
||||
singleton = new Messages(Settings.messageFile, Settings.messagesLanguage);
|
||||
|
||||
@@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class OtherAccounts extends CustomConfiguration {
|
||||
|
||||
@@ -23,11 +24,19 @@ public class OtherAccounts extends CustomConfiguration {
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method clear.
|
||||
* @param uuid UUID
|
||||
*/
|
||||
public void clear(UUID uuid) {
|
||||
set(uuid.toString(), new ArrayList<String>());
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
* @return OtherAccounts
|
||||
*/
|
||||
public static OtherAccounts getInstance() {
|
||||
if (others == null) {
|
||||
others = new OtherAccounts();
|
||||
@@ -35,6 +44,10 @@ public class OtherAccounts extends CustomConfiguration {
|
||||
return others;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method addPlayer.
|
||||
* @param uuid UUID
|
||||
*/
|
||||
public void addPlayer(UUID uuid) {
|
||||
try {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
@@ -49,6 +62,10 @@ public class OtherAccounts extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method removePlayer.
|
||||
* @param uuid UUID
|
||||
*/
|
||||
public void removePlayer(UUID uuid) {
|
||||
try {
|
||||
Player player = Bukkit.getPlayer(uuid);
|
||||
@@ -63,6 +80,11 @@ public class OtherAccounts extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getAllPlayersByUUID.
|
||||
* @param uuid UUID
|
||||
* @return List<String>
|
||||
*/
|
||||
public List<String> getAllPlayersByUUID(UUID uuid) {
|
||||
return this.getStringList(uuid.toString());
|
||||
}
|
||||
|
||||
@@ -18,6 +18,8 @@ import fr.xephi.authme.datasource.DataSource;
|
||||
import fr.xephi.authme.datasource.DataSource.DataSourceType;
|
||||
import fr.xephi.authme.security.HashAlgorithm;
|
||||
|
||||
/**
|
||||
*/
|
||||
public final class Settings extends YamlConfiguration {
|
||||
|
||||
private static AuthMe plugin;
|
||||
@@ -104,12 +106,20 @@ public final class Settings extends YamlConfiguration {
|
||||
|
||||
protected static YamlConfiguration configFile;
|
||||
|
||||
/**
|
||||
* Constructor for Settings.
|
||||
* @param pl AuthMe
|
||||
*/
|
||||
public Settings(AuthMe pl) {
|
||||
instance = this;
|
||||
plugin = pl;
|
||||
configFile = (YamlConfiguration) plugin.getConfig();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method reload.
|
||||
* @throws Exception
|
||||
*/
|
||||
public static void reload() throws Exception {
|
||||
plugin.getLogger().info("Loading Configuration File...");
|
||||
boolean exist = SETTINGS_FILE.exists();
|
||||
@@ -502,11 +512,20 @@ public final class Settings extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setValue.
|
||||
* @param key String
|
||||
* @param value Object
|
||||
*/
|
||||
public static void setValue(String key, Object value) {
|
||||
instance.set(key, value);
|
||||
save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPasswordHash.
|
||||
* @return HashAlgorithm
|
||||
*/
|
||||
private static HashAlgorithm getPasswordHash() {
|
||||
String key = "settings.security.passwordHash";
|
||||
try {
|
||||
@@ -517,6 +536,10 @@ public final class Settings extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getDataSource.
|
||||
* @return DataSourceType
|
||||
*/
|
||||
private static DataSourceType getDataSource() {
|
||||
String key = "DataSource.backend";
|
||||
try {
|
||||
@@ -531,6 +554,9 @@ public final class Settings extends YamlConfiguration {
|
||||
* Config option for setting and check restricted user by username;ip ,
|
||||
* return false if ip and name doesnt amtch with player that join the
|
||||
* server, so player has a restricted access
|
||||
* @param name String
|
||||
* @param ip String
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean getRestrictedIp(String name, String ip) {
|
||||
|
||||
@@ -554,8 +580,8 @@ public final class Settings extends YamlConfiguration {
|
||||
/**
|
||||
* Saves the configuration to disk
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
|
||||
* @return True if saved successfully */
|
||||
public static boolean save() {
|
||||
try {
|
||||
instance.save(SETTINGS_FILE);
|
||||
@@ -570,8 +596,8 @@ public final class Settings extends YamlConfiguration {
|
||||
* <p>
|
||||
* If defaults and configuration are empty, saves blank file.
|
||||
*
|
||||
* @return True if saved successfully
|
||||
*/
|
||||
|
||||
* @return True if saved successfully */
|
||||
public final boolean saveDefaults() {
|
||||
options().copyDefaults(true);
|
||||
options().copyHeader(true);
|
||||
@@ -581,6 +607,11 @@ public final class Settings extends YamlConfiguration {
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method checkLang.
|
||||
* @param lang String
|
||||
* @return String
|
||||
*/
|
||||
public static String checkLang(String lang) {
|
||||
if (new File(PLUGIN_FOLDER, "messages" + File.separator + "messages_" + lang + ".yml").exists()) {
|
||||
ConsoleLogger.info("Set Language to: " + lang);
|
||||
@@ -594,6 +625,10 @@ public final class Settings extends YamlConfiguration {
|
||||
return "en";
|
||||
}
|
||||
|
||||
/**
|
||||
* Method switchAntiBotMod.
|
||||
* @param mode boolean
|
||||
*/
|
||||
public static void switchAntiBotMod(boolean mode) {
|
||||
if (mode) {
|
||||
isKickNonRegisteredEnabled = true;
|
||||
@@ -635,6 +670,11 @@ public final class Settings extends YamlConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isEmailCorrect.
|
||||
* @param email String
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isEmailCorrect(String email) {
|
||||
if (!email.contains("@"))
|
||||
return false;
|
||||
|
||||
@@ -8,6 +8,7 @@ import org.bukkit.Location;
|
||||
/**
|
||||
*
|
||||
* @author Xephi59
|
||||
* @version $Revision: 1.0 $
|
||||
*/
|
||||
public class Spawn extends CustomConfiguration {
|
||||
|
||||
@@ -42,6 +43,10 @@ public class Spawn extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getInstance.
|
||||
* @return Spawn
|
||||
*/
|
||||
public static Spawn getInstance() {
|
||||
if (spawn == null) {
|
||||
spawn = new Spawn();
|
||||
@@ -49,6 +54,11 @@ public class Spawn extends CustomConfiguration {
|
||||
return spawn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setSpawn.
|
||||
* @param location Location
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setSpawn(Location location) {
|
||||
try {
|
||||
set("spawn.world", location.getWorld().getName());
|
||||
@@ -64,6 +74,11 @@ public class Spawn extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setFirstSpawn.
|
||||
* @param location Location
|
||||
* @return boolean
|
||||
*/
|
||||
public boolean setFirstSpawn(Location location) {
|
||||
try {
|
||||
set("firstspawn.world", location.getWorld().getName());
|
||||
@@ -79,11 +94,19 @@ public class Spawn extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getLocation.
|
||||
* @return Location
|
||||
*/
|
||||
@Deprecated
|
||||
public Location getLocation() {
|
||||
return getSpawn();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getSpawn.
|
||||
* @return Location
|
||||
*/
|
||||
public Location getSpawn() {
|
||||
try {
|
||||
if (this.getString("spawn.world").isEmpty() || this.getString("spawn.world").equals(""))
|
||||
@@ -95,6 +118,10 @@ public class Spawn extends CustomConfiguration {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getFirstSpawn.
|
||||
* @return Location
|
||||
*/
|
||||
public Location getFirstSpawn() {
|
||||
try {
|
||||
if (this.getString("firstspawn.world").isEmpty() || this.getString("firstspawn.world").equals(""))
|
||||
|
||||
Reference in New Issue
Block a user