Misuse Prevention

This commit is contained in:
Brianna O'Keefe 2018-09-01 20:47:09 -04:00
parent df14eebecc
commit af1091017c
4 changed files with 22 additions and 4 deletions

View File

@ -22,6 +22,7 @@ import com.songoda.epicanchors.utils.Methods;
import com.songoda.epicanchors.utils.SettingsManager;
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;
@ -48,7 +49,25 @@ public class EpicAnchorsPlugin extends JavaPlugin implements EpicAnchors {
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;
CommandSender console = Bukkit.getConsoleSender();
console.sendMessage(TextComponent.formatText("&a============================="));

View File

@ -71,7 +71,7 @@ public class AnchorHandler {
for (int z = cz; z < cz + 16; z++) {
for (int y = 0; y < location.getWorld().getMaxHeight(); y++) {
Block block = location.getWorld().getBlockAt(x, y, z);
if (block.getType() != Material.SPAWNER) continue;
if (block.getType() != Material.MOB_SPAWNER) continue;
Spawner spawner = EpicSpawnersAPI.getSpawnerManager().getSpawnerFromWorld(block.getLocation());
if (!delays.containsKey(block.getLocation())) {
if (block == null || block.getLocation() == null || spawner == null) continue;

View File

@ -22,7 +22,7 @@ public class SettingsManager implements Listener {
}
public enum settings {
o8("Main.Anchor Block Material", "END_PORTAL_FRAME"),
o8("Main.Anchor Block Material", "ENDER_PORTAL_FRAME"),
o11("Interfaces.Glass Type 1", 7),
o12("Interfaces.Glass Type 2", 11),
o13("Interfaces.Glass Type 3", 3);

View File

@ -4,10 +4,9 @@ version: 1
depend: [Arconix]
main: com.songoda.epicanchors.EpicAnchorsPlugin
author: songoda
api-version: 1.13
commands:
EpicAnchors:
description: I have no idea.
default: true
aliases: [eca]
aliases: [ea]
usage: /<command> [reload]