From efc6a6337b1f680f1009d2a50f5070092231833a Mon Sep 17 00:00:00 2001 From: Mitchell Cook Date: Mon, 16 Jul 2018 17:28:23 +1000 Subject: [PATCH] Added compareTo method for easier comparison in expasions. --- .../placeholderapi/expansion/Version.java | 39 +++++++++++-------- 1 file changed, 22 insertions(+), 17 deletions(-) diff --git a/src/main/java/me/clip/placeholderapi/expansion/Version.java b/src/main/java/me/clip/placeholderapi/expansion/Version.java index a184725..3b04676 100644 --- a/src/main/java/me/clip/placeholderapi/expansion/Version.java +++ b/src/main/java/me/clip/placeholderapi/expansion/Version.java @@ -20,22 +20,27 @@ */ package me.clip.placeholderapi.expansion; -public class Version { +public final class Version { + + private boolean isSpigot; + + private String version; + + public Version(String version, boolean isSpigot) { + this.version = version; + this.isSpigot = isSpigot; + } + + public String getVersion() { + return version == null ? "unknown" : version; + } + + public boolean isSpigot() { + return isSpigot; + } + + public boolean compareTo(String version) { + return getVersion().equalsIgnoreCase(version); + } - private boolean isSpigot; - - private String version; - - public Version(String version, boolean isSpigot) { - this.version = version; - this.isSpigot = isSpigot; - } - - public String getVersion() { - return version == null ? "unknown" : version; - } - - public boolean isSpigot() { - return isSpigot; - } }