Merge upstream/master into ljacqu/enums

This commit is contained in:
ljacqu
2015-11-23 23:31:26 +01:00
137 changed files with 4848 additions and 4477 deletions
@@ -12,9 +12,10 @@ import java.util.zip.GZIPInputStream;
public class GeoLiteAPI {
private static final String GEOIP_URL = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry"
+ "/GeoIP.dat.gz";
private static final String GEOIP_URL = "http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry" +
"/GeoIP.dat.gz";
private static final Wrapper wrapper = new Wrapper(AuthMe.getInstance());
private static final AuthMe plugin = AuthMe.getInstance();
private static LookupService lookupService;
/**
@@ -30,9 +31,8 @@ public class GeoLiteAPI {
if (data.exists()) {
try {
lookupService = new LookupService(data);
// TODO ljacqu 20151123: Should this not be output over the ConsoleLogger service?
wrapper.getLogger().info("[LICENSE] This product uses data from the GeoLite API created by MaxMind, " +
"available at http://www.maxmind.com");
plugin.getLogger().info("[LICENSE] This product uses data from the GeoLite API created by MaxMind, " +
"available at http://www.maxmind.com");
return true;
} catch (IOException e) {
// TODO ljacqu 20151123: Log the exception instead of just swallowing it
@@ -73,6 +73,7 @@ public class GeoLiteAPI {
* Get the country code of the given IP address.
*
* @param ip Ip address
*
* @return String
*/
public static String getCountryCode(String ip) {
@@ -86,6 +87,7 @@ public class GeoLiteAPI {
* Get the country name of the given IP address.
*
* @param ip Ip address
*
* @return String
*/
public static String getCountryName(String ip) {
@@ -19,6 +19,7 @@ public class StringUtils {
*
* @param first First string
* @param second Second string
*
* @return The difference value
*/
public static double getDifference(String first, String second) {
@@ -38,6 +39,7 @@ public class StringUtils {
*
* @param str the string to analyze
* @param pieces the items to check the string for
*
* @return true if the string contains at least one of the items
*/
public static boolean containsAny(String str, String... pieces) {
@@ -57,6 +59,7 @@ public class StringUtils {
* is trimmed, so this method also considers a string with whitespace as empty.
*
* @param str the string to verify
*
* @return true if the string is empty, false otherwise
*/
public static boolean isEmpty(String str) {
@@ -68,6 +71,7 @@ public class StringUtils {
*
* @param delimiter the delimiter to use
* @param elements the elements to join
*
* @return a new String that is composed of the elements separated by the delimiter
*/
public static String join(String delimiter, Iterable<String> elements) {
@@ -89,6 +93,7 @@ public class StringUtils {
* Get a full stack trace of an exception as a string.
*
* @param exception The exception.
*
* @return Stack trace as a string.
*/
public static String getStackTrace(Exception exception) {
+11 -8
View File
@@ -31,7 +31,7 @@ import java.util.zip.GZIPInputStream;
*/
public final class Utils {
private static AuthMe plugin;
private static final AuthMe plugin;
private static Wrapper wrapper;
private static boolean getOnlinePlayersIsCollection = false;
@@ -60,7 +60,7 @@ public final class Utils {
try {
lookupService = new LookupService(data);
ConsoleLogger.info("[LICENSE] This product uses data from the GeoLite API created by MaxMind, " +
"available at http://www.maxmind.com");
"available at http://www.maxmind.com");
return true;
} catch (IOException e) {
return false;
@@ -102,7 +102,8 @@ public final class Utils {
*
* @param player The player.
* @param group The group type.
* @return True if succeed, false otherwise. False is also returned if groups aren't supported
*
* @return True if succeeded, false otherwise. False is also returned if groups aren't supported
* with the current permissions system.
*/
public static boolean setGroup(Player player, GroupType group) {
@@ -156,11 +157,12 @@ public final class Utils {
/**
* TODO: This method requires better explanation.
* <p>
* <p/>
* Set the normal group of a player.
*
* @param player The player.
* @param group The normal group.
*
* @return True on success, false on failure.
*/
public static boolean addNormal(Player player, String group) {
@@ -203,7 +205,7 @@ public final class Utils {
public static boolean isUnrestricted(Player player) {
return Settings.isAllowRestrictedIp && !Settings.getUnrestrictedName.isEmpty()
&& (Settings.getUnrestrictedName.contains(player.getName()));
&& (Settings.getUnrestrictedName.contains(player.getName()));
}
/**
@@ -280,6 +282,7 @@ public final class Utils {
* Bukkit#getOnlinePlayers()} directly.
*
* @return collection of online players
*
* @see <a href="https://www.spigotmc.org/threads/solved-cant-use-new-getonlineplayers.33061/">SpigotMC
* forum</a>
* @see <a href="http://stackoverflow.com/questions/32130851/player-changed-from-array-to-collection">StackOverflow</a>
@@ -305,7 +308,7 @@ public final class Utils {
}
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException e) {
ConsoleLogger.showError("Could not retrieve list of online players: ["
+ e.getClass().getName() + "] " + e.getMessage());
+ e.getClass().getName() + "] " + e.getMessage());
}
return Collections.emptyList();
}
@@ -337,8 +340,8 @@ public final class Utils {
return true;
} else if (plugin.combatTagPlus != null
// TODO ljacqu 20151123: Use a getter for combatTagPlus in AuthMe instead of using direct field access
&& player instanceof Player
&& plugin.combatTagPlus.getNpcPlayerHelper().isNpc((Player) player)) {
&& player instanceof Player
&& plugin.combatTagPlus.getNpcPlayerHelper().isNpc((Player) player)) {
return true;
}
return false;