mirror of
https://github.com/essentials/Essentials.git
synced 2025-08-13 10:04:51 +02:00
Unnecessary RegEx is unnecessary. Also storing Patterns in their classes for reuse.
437b01e371
c4e10da646
This commit is contained in:
@@ -12,6 +12,7 @@ import java.util.regex.Pattern;
|
||||
public class PastieUpload
|
||||
{
|
||||
private final transient PostToUrl connection;
|
||||
private final Pattern pattern = Pattern.compile("(?s).*\\?key=([a-z0-9]+).*");
|
||||
|
||||
public PastieUpload() throws MalformedURLException
|
||||
{
|
||||
@@ -26,7 +27,7 @@ public class PastieUpload
|
||||
map.put("paste[body]", data);
|
||||
map.put("paste[restricted]", "1");
|
||||
final String html = connection.send(map);
|
||||
final Matcher matcher = Pattern.compile("(?s).*\\?key=([a-z0-9]+).*").matcher(html);
|
||||
final Matcher matcher = pattern.matcher(html);
|
||||
if (matcher.matches())
|
||||
{
|
||||
final String key = matcher.group(1);
|
||||
|
@@ -20,6 +20,7 @@ public class UpdateCheck
|
||||
private final static int CHECK_INTERVAL = 20 * 60 * 60 * 6;
|
||||
private final transient Plugin plugin;
|
||||
private transient boolean essentialsInstalled;
|
||||
private final Pattern bukkitVersionPattern = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*");
|
||||
|
||||
public UpdateCheck(final Plugin plugin)
|
||||
{
|
||||
@@ -188,8 +189,7 @@ public class UpdateCheck
|
||||
|
||||
private int getBukkitVersion()
|
||||
{
|
||||
final Matcher versionMatch = Pattern.compile("git-Bukkit-(?:(?:[0-9]+)\\.)+[0-9]+-R[\\.0-9]+-(?:[0-9]+-g[0-9a-f]+-)?b([0-9]+)jnks.*").matcher(
|
||||
plugin.getServer().getVersion());
|
||||
final Matcher versionMatch = bukkitVersionPattern.matcher(plugin.getServer().getVersion());
|
||||
if (versionMatch.matches())
|
||||
{
|
||||
return Integer.parseInt(versionMatch.group(1));
|
||||
|
Reference in New Issue
Block a user