diff --git a/EpicFarming-Plugin/src/main/java/com/songoda/epicfarming/EpicFarmingPlugin.java b/EpicFarming-Plugin/src/main/java/com/songoda/epicfarming/EpicFarmingPlugin.java index 4fbd599..823ba3a 100644 --- a/EpicFarming-Plugin/src/main/java/com/songoda/epicfarming/EpicFarmingPlugin.java +++ b/EpicFarming-Plugin/src/main/java/com/songoda/epicfarming/EpicFarmingPlugin.java @@ -28,6 +28,7 @@ import com.songoda.epicfarming.utils.SettingsManager; import com.songoda.epicfarming.api.EpicFarming; import org.apache.commons.lang.math.NumberUtils; import org.bukkit.Bukkit; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.command.CommandSender; @@ -70,7 +71,25 @@ public class EpicFarmingPlugin extends JavaPlugin implements EpicFarming { return INSTANCE; } + private void checkVersion() { + int workingVersion = 13; + int currentVersion = Integer.parseInt(Bukkit.getServer().getClass() + .getPackage().getName().split("\\.")[3].split("_")[1]); + + if (currentVersion < workingVersion) { + Bukkit.getScheduler().scheduleSyncDelayedTask(this, () -> { + Bukkit.getConsoleSender().sendMessage(""); + Bukkit.getConsoleSender().sendMessage(ChatColor.RED + "You installed the 1." + workingVersion + "+ only version of " + this.getDescription().getName() + " on a 1." + currentVersion + " server. Since you are on the wrong version we disabled the plugin for you. Please install correct version to continue using " + this.getDescription().getName() + "."); + Bukkit.getConsoleSender().sendMessage(""); + }, 20L); + } + } + + @Override public void onEnable() { + // Check to make sure the Bukkit version is compatible. + checkVersion(); + INSTANCE = this; Arconix.pl().hook(this);