mirror of
https://github.com/songoda/EpicFarming.git
synced 2025-01-06 08:18:43 +01:00
Misuse prevention
This commit is contained in:
parent
7a97c45fa1
commit
502fd92318
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user