001package net.tnemc.item.providers; 002 003/* 004 * The New Item Library Minecraft Server Plugin 005 * 006 * Copyright (C) 2022 - 2025 Daniel "creatorfromhell" Vidmar 007 * 008 * This program is free software; you can redistribute it and/or 009 * modify it under the terms of the GNU Lesser General Public 010 * License as published by the Free Software Foundation; either 011 * currentVersion 3 of the License, or (at your option) any later currentVersion. 012 * 013 * This program is distributed in the hope that it will be useful, 014 * but WITHOUT ANY WARRANTY; without even the implied warranty of 015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 016 * Lesser General Public License for more details. 017 * 018 * You should have received a copy of the GNU Lesser General Public License 019 * along with this program; if not, write to the Free Software Foundation, 020 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 021 */ 022 023import com.vdurmont.semver4j.Semver; 024 025public class VersionUtil { 026 027 /** 028 * @return Whether the bukkit in use is for MC >= 1.8 029 */ 030 public static boolean isVersion(final String currentVersion, final String compare) { 031 032 return new Semver(currentVersion, Semver.SemverType.LOOSE).isGreaterThanOrEqualTo(compare); 033 } 034 035 public static boolean isLessThan(final String currentVersion, final String compare) { 036 037 return new Semver(currentVersion, Semver.SemverType.LOOSE).isLowerThan(compare); 038 } 039 040 /** 041 * @return Whether the bukkit in use is for MC >= 1.7 042 */ 043 public static boolean isOneSeven(final String currentVersion) { 044 045 return isVersion(currentVersion, "1.7.0"); 046 } 047 048 /** 049 * @return Whether the bukkit in use is for MC >= 1.8 050 */ 051 public static boolean isOneEight(final String currentVersion) { 052 053 return isVersion(currentVersion, "1.8.0"); 054 } 055 056 /** 057 * @return Whether the bukkit in use is for MC >= 1.9 058 */ 059 public static boolean isOneNine(final String currentVersion) { 060 061 return isVersion(currentVersion, "1.9.0"); 062 } 063 064 /** 065 * @return Whether the bukkit in use is for MC >= 1.10 066 */ 067 public static boolean isOneTen(final String currentVersion) { 068 069 return isVersion(currentVersion, "1.10.0"); 070 } 071 072 /** 073 * @return Whether the bukkit in use is for MC >= 1.11 074 */ 075 public static boolean isOneEleven(final String currentVersion) { 076 077 return isVersion(currentVersion, "1.11.0"); 078 } 079 080 /** 081 * @return Whether the bukkit in use is for MC >= 1.12 082 */ 083 public static boolean isOneTwelve(final String currentVersion) { 084 085 return isVersion(currentVersion, "1.12.0"); 086 } 087 088 /** 089 * @return Whether the bukkit in use is for MC >= 1.13 090 */ 091 public static boolean isOneThirteen(final String currentVersion) { 092 093 return isVersion(currentVersion, "1.13.0"); 094 } 095 096 /** 097 * @return Whether the bukkit in use is for MC >= 1.14 098 */ 099 public static boolean isOneFourteen(final String currentVersion) { 100 101 return isVersion(currentVersion, "1.14.0"); 102 } 103 104 /** 105 * @return Whether the bukkit in use is for MC >= 1.15 106 */ 107 public static boolean isOneFifteen(final String currentVersion) { 108 109 return isVersion(currentVersion, "1.15.0"); 110 } 111 112 /** 113 * @return Whether the bukkit in use is for MC >= 1.16 114 */ 115 public static boolean isOneSixteen(final String currentVersion) { 116 117 return isVersion(currentVersion, "1.16.0"); 118 } 119 120 /** 121 * @return Whether the bukkit in use is for MC >= 1.17 122 */ 123 public static boolean isOneSeventeen(final String currentVersion) { 124 125 return isVersion(currentVersion, "1.17.0"); 126 } 127 128 /** 129 * @return Whether the bukkit in use is for MC >= 1.20 130 */ 131 public static boolean isOneTwenty(final String currentVersion) { 132 133 return isVersion(currentVersion, "1.20.0"); 134 } 135 136 /** 137 * @return Whether the bukkit in use is for MC >= 1.21 138 */ 139 public static boolean isOneTwentyOne(final String currentVersion) { 140 141 return isVersion(currentVersion, "1.21.0"); 142 } 143 144 /** 145 * @return Whether the bukkit in use is for MC >= 1.21.2 146 */ 147 public static boolean isOneTwentyOneTwo(final String currentVersion) { 148 149 return isVersion(currentVersion, "1.21.2"); 150 } 151 152 /** 153 * @return Whether the bukkit in use is for MC >= 1.21.3 154 */ 155 public static boolean isOneTwentyOneThree(final String currentVersion) { 156 157 return isVersion(currentVersion, "1.21.3"); 158 } 159 160 /** 161 * @return Whether the bukkit in use is for MC >= 1.21.4 162 */ 163 public static boolean isOneTwentyOneFour(final String currentVersion) { 164 165 return isVersion(currentVersion, "1.21.4"); 166 } 167 168 /** 169 * @return Whether the bukkit in use is for MC >= 1.21.5 170 */ 171 public static boolean isOneTwentyOneFive(final String currentVersion) { 172 173 return isVersion(currentVersion, "1.21.5"); 174 } 175 176 /** 177 * @return Whether the bukkit in use is for MC >= 1.22 178 */ 179 public static boolean isOneTwentyTwo(final String currentVersion) { 180 181 return isVersion(currentVersion, "1.22.0"); 182 } 183 184 /** 185 * @return Whether the bukkit in use is for MC >= 1.23 186 */ 187 public static boolean isOneTwentyThree(final String currentVersion) { 188 189 return isVersion(currentVersion, "1.23.0"); 190 } 191}