From ab8eee3be91e63a85027e7380a84242ce4e326dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Vis=C3=A9e?= Date: Sun, 1 Nov 2015 15:38:49 +0100 Subject: [PATCH] Added string utilities class, fixed some imports --- .../authme/command/help/HelpPrinter.java | 8 ++++---- .../fr/xephi/authme/util/StringUtils.java | 19 +++++++++++++++++++ 2 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 src/main/java/fr/xephi/authme/util/StringUtils.java diff --git a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java index 73948920..d3d8f78d 100644 --- a/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java +++ b/src/main/java/fr/xephi/authme/command/help/HelpPrinter.java @@ -1,10 +1,10 @@ package fr.xephi.authme.command.help; import com.timvisee.dungeonmaze.Core; -import fr.xephi.authme.commands.CommandArgumentDescription; -import fr.xephi.authme.commands.CommandDescription; -import fr.xephi.authme.commands.CommandParts; -import fr.xephi.authme.commands.CommandPermissions; +import fr.xephi.authme.command.CommandArgumentDescription; +import fr.xephi.authme.command.CommandDescription; +import fr.xephi.authme.command.CommandParts; +import fr.xephi.authme.command.CommandPermissions; import com.timvisee.dungeonmaze.util.StringUtils; import org.bukkit.ChatColor; import org.bukkit.command.CommandSender; diff --git a/src/main/java/fr/xephi/authme/util/StringUtils.java b/src/main/java/fr/xephi/authme/util/StringUtils.java new file mode 100644 index 00000000..92b14c5c --- /dev/null +++ b/src/main/java/fr/xephi/authme/util/StringUtils.java @@ -0,0 +1,19 @@ +package fr.xephi.authme.util; + +import net.ricecode.similarity.LevenshteinDistanceStrategy; +import net.ricecode.similarity.StringSimilarityService; +import net.ricecode.similarity.StringSimilarityServiceImpl; + +public class StringUtils { + + public static double getDifference(String first, String second) { + if(first == null || second == null) + return 1.0; + + StringSimilarityService service = new StringSimilarityServiceImpl(new LevenshteinDistanceStrategy()); + + double score = service.score(first, second); + + return Math.abs(score - 1.0); + } +}