Prepare the project for javadocs
This commit is contained in:
@@ -3,6 +3,8 @@ package fr.xephi.authme.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class ListUtils {
|
||||
|
||||
/**
|
||||
@@ -11,8 +13,8 @@ public class ListUtils {
|
||||
* @param elements The elements to implode.
|
||||
* @param separator The separator to use.
|
||||
*
|
||||
* @return The result string.
|
||||
*/
|
||||
|
||||
* @return The result string. */
|
||||
public static String implode(List<String> elements, String separator) {
|
||||
// Create a string builder
|
||||
StringBuilder sb = new StringBuilder();
|
||||
@@ -42,8 +44,8 @@ public class ListUtils {
|
||||
* @param otherElements The second list of elements to implode.
|
||||
* @param separator The separator to use.
|
||||
*
|
||||
* @return The result string.
|
||||
*/
|
||||
|
||||
* @return The result string. */
|
||||
public static String implode(List<String> elements, List<String> otherElements, String separator) {
|
||||
// Combine the lists
|
||||
List<String> combined = new ArrayList<>();
|
||||
@@ -61,8 +63,8 @@ public class ListUtils {
|
||||
* @param otherElement The second element to implode.
|
||||
* @param separator The separator to use.
|
||||
*
|
||||
* @return The result string.
|
||||
*/
|
||||
|
||||
* @return The result string. */
|
||||
public static String implode(String element, String otherElement, String separator) {
|
||||
// Combine the lists
|
||||
List<String> combined = new ArrayList<>();
|
||||
|
||||
@@ -2,6 +2,8 @@ package fr.xephi.authme.util;
|
||||
|
||||
import java.text.DecimalFormat;
|
||||
|
||||
/**
|
||||
*/
|
||||
@SuppressWarnings("UnusedDeclaration")
|
||||
public class Profiler {
|
||||
|
||||
@@ -31,9 +33,9 @@ public class Profiler {
|
||||
/**
|
||||
* Start the profiler.
|
||||
*
|
||||
|
||||
* @return True if the profiler was started, false otherwise possibly due to an error.
|
||||
* True will also be returned if the profiler was started already.
|
||||
*/
|
||||
* True will also be returned if the profiler was started already. */
|
||||
public boolean start() {
|
||||
// Make sure the timer isn't started already
|
||||
if(isActive())
|
||||
@@ -47,8 +49,8 @@ public class Profiler {
|
||||
/**
|
||||
* This will start the profiler if it's not active, or will stop the profiler if it's currently active.
|
||||
*
|
||||
* @return True if the profiler has been started, false if the profiler has been stopped.
|
||||
*/
|
||||
|
||||
* @return True if the profiler has been started, false if the profiler has been stopped. */
|
||||
public boolean pause() {
|
||||
// Toggle the profiler state
|
||||
if(isStarted())
|
||||
@@ -63,9 +65,9 @@ public class Profiler {
|
||||
/**
|
||||
* Stop the profiler if it's active.
|
||||
*
|
||||
|
||||
* @return True will be returned if the profiler was stopped while it was active. False will be returned if the
|
||||
* profiler was stopped already.
|
||||
*/
|
||||
* profiler was stopped already. */
|
||||
public boolean stop() {
|
||||
// Make sure the profiler is active
|
||||
if(!isActive())
|
||||
@@ -80,8 +82,8 @@ public class Profiler {
|
||||
/**
|
||||
* Check whether the profiler has been started. The profiler doesn't need to be active right now.
|
||||
*
|
||||
* @return True if the profiler was started, false otherwise.
|
||||
*/
|
||||
|
||||
* @return True if the profiler was started, false otherwise. */
|
||||
public boolean isStarted() {
|
||||
return isActive() || this.time > 0;
|
||||
}
|
||||
@@ -89,8 +91,8 @@ public class Profiler {
|
||||
/**
|
||||
* Check whether the profiler is currently active.
|
||||
*
|
||||
* @return True if the profiler is active, false otherwise.
|
||||
*/
|
||||
|
||||
* @return True if the profiler is active, false otherwise. */
|
||||
public boolean isActive() {
|
||||
return this.start >= 0;
|
||||
}
|
||||
@@ -98,8 +100,8 @@ public class Profiler {
|
||||
/**
|
||||
* Get the passed time in milliseconds.
|
||||
*
|
||||
* @return The passed time in milliseconds.
|
||||
*/
|
||||
|
||||
* @return The passed time in milliseconds. */
|
||||
public long getTime() {
|
||||
// Check whether the profiler is currently active
|
||||
if(isActive())
|
||||
@@ -110,8 +112,8 @@ public class Profiler {
|
||||
/**
|
||||
* Get the passed time in a formatted string.
|
||||
*
|
||||
* @return The passed time in a formatted string.
|
||||
*/
|
||||
|
||||
* @return The passed time in a formatted string. */
|
||||
public String getTimeFormatted() {
|
||||
// Get the passed time
|
||||
long time = getTime();
|
||||
|
||||
@@ -4,6 +4,8 @@ import net.ricecode.similarity.LevenshteinDistanceStrategy;
|
||||
import net.ricecode.similarity.StringSimilarityService;
|
||||
import net.ricecode.similarity.StringSimilarityServiceImpl;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class StringUtils {
|
||||
|
||||
/**
|
||||
@@ -12,8 +14,8 @@ public class StringUtils {
|
||||
* @param first First string.
|
||||
* @param second Second string.
|
||||
*
|
||||
* @return The difference value.
|
||||
*/
|
||||
|
||||
* @return The difference value. */
|
||||
public static double getDifference(String first, String second) {
|
||||
// Make sure the strings are valid.
|
||||
if(first == null || second == null)
|
||||
@@ -26,6 +28,12 @@ public class StringUtils {
|
||||
return Math.abs(service.score(first, second) - 1.0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method containsAny.
|
||||
* @param str String
|
||||
* @param pieces String[]
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean containsAny(String str, String... pieces) {
|
||||
if (str == null) {
|
||||
return false;
|
||||
|
||||
@@ -24,6 +24,8 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.zip.GZIPInputStream;
|
||||
|
||||
/**
|
||||
*/
|
||||
public class Utils {
|
||||
|
||||
public static AuthMe plugin;
|
||||
@@ -43,6 +45,10 @@ public class Utils {
|
||||
}
|
||||
|
||||
// Check and Download GeoIP data if not exist
|
||||
/**
|
||||
* Method checkGeoIP.
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean checkGeoIP() {
|
||||
if (lookupService != null) {
|
||||
return true;
|
||||
@@ -89,6 +95,11 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getCountryCode.
|
||||
* @param ip String
|
||||
* @return String
|
||||
*/
|
||||
public static String getCountryCode(String ip) {
|
||||
if (checkGeoIP()) {
|
||||
return lookupService.getCountry(ip).getCode();
|
||||
@@ -96,6 +107,11 @@ public class Utils {
|
||||
return "--";
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getCountryName.
|
||||
* @param ip String
|
||||
* @return String
|
||||
*/
|
||||
public static String getCountryName(String ip) {
|
||||
if (checkGeoIP()) {
|
||||
return lookupService.getCountry(ip).getName();
|
||||
@@ -103,6 +119,11 @@ public class Utils {
|
||||
return "N/A";
|
||||
}
|
||||
|
||||
/**
|
||||
* Method setGroup.
|
||||
* @param player Player
|
||||
* @param group GroupType
|
||||
*/
|
||||
public static void setGroup(Player player, GroupType group) {
|
||||
if (!Settings.isPermissionCheckEnabled)
|
||||
return;
|
||||
@@ -148,6 +169,12 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method addNormal.
|
||||
* @param player Player
|
||||
* @param group String
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean addNormal(Player player, String group) {
|
||||
if (!useGroupSystem()) {
|
||||
return false;
|
||||
@@ -167,6 +194,11 @@ public class Utils {
|
||||
}
|
||||
|
||||
// TODO: Move to a Manager
|
||||
/**
|
||||
* Method checkAuth.
|
||||
* @param player Player
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean checkAuth(Player player) {
|
||||
if (player == null || Utils.isUnrestricted(player)) {
|
||||
return true;
|
||||
@@ -186,15 +218,32 @@ public class Utils {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isUnrestricted.
|
||||
* @param player Player
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isUnrestricted(Player player) {
|
||||
return Settings.isAllowRestrictedIp && !Settings.getUnrestrictedName.isEmpty()
|
||||
&& (Settings.getUnrestrictedName.contains(player.getName()));
|
||||
}
|
||||
|
||||
/**
|
||||
* Method useGroupSystem.
|
||||
* @return boolean
|
||||
*/
|
||||
private static boolean useGroupSystem() {
|
||||
return Settings.isPermissionCheckEnabled && !Settings.getUnloggedinGroup.isEmpty();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method packCoords.
|
||||
* @param x double
|
||||
* @param y double
|
||||
* @param z double
|
||||
* @param w String
|
||||
* @param pl Player
|
||||
*/
|
||||
public static void packCoords(double x, double y, double z, String w,
|
||||
final Player pl) {
|
||||
World theWorld;
|
||||
@@ -224,11 +273,17 @@ public class Utils {
|
||||
/*
|
||||
* Used for force player GameMode
|
||||
*/
|
||||
/**
|
||||
* Method forceGM.
|
||||
* @param player Player
|
||||
*/
|
||||
public static void forceGM(Player player) {
|
||||
if (!plugin.getPermissionsManager().hasPermission(player, "authme.bypassforcesurvival"))
|
||||
player.setGameMode(GameMode.SURVIVAL);
|
||||
}
|
||||
|
||||
/**
|
||||
*/
|
||||
public enum GroupType {
|
||||
UNREGISTERED,
|
||||
REGISTERED,
|
||||
@@ -236,6 +291,10 @@ public class Utils {
|
||||
LOGGEDIN
|
||||
}
|
||||
|
||||
/**
|
||||
* Method purgeDirectory.
|
||||
* @param file File
|
||||
*/
|
||||
public static void purgeDirectory(File file) {
|
||||
if (!file.isDirectory()) {
|
||||
return;
|
||||
@@ -254,6 +313,10 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getOnlinePlayers.
|
||||
* @return Collection<? extends Player>
|
||||
*/
|
||||
@SuppressWarnings("unchecked")
|
||||
public static Collection<? extends Player> getOnlinePlayers() {
|
||||
if (getOnlinePlayersIsCollection) {
|
||||
@@ -273,12 +336,22 @@ public class Utils {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
/**
|
||||
* Method getPlayer.
|
||||
* @param name String
|
||||
* @return Player
|
||||
*/
|
||||
@SuppressWarnings("deprecation")
|
||||
public static Player getPlayer(String name) {
|
||||
name = name.toLowerCase();
|
||||
return plugin.getServer().getPlayer(name);
|
||||
}
|
||||
|
||||
/**
|
||||
* Method isNPC.
|
||||
* @param player Entity
|
||||
* @return boolean
|
||||
*/
|
||||
public static boolean isNPC(final Entity player) {
|
||||
try {
|
||||
if (player.hasMetadata("NPC")) {
|
||||
@@ -294,6 +367,10 @@ public class Utils {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Method teleportToSpawn.
|
||||
* @param player Player
|
||||
*/
|
||||
public static void teleportToSpawn(Player player) {
|
||||
if (Settings.isTeleportToSpawnEnabled && !Settings.noTeleport) {
|
||||
Location spawn = plugin.getSpawnLocation(player);
|
||||
|
||||
Reference in New Issue
Block a user