mirror of
https://github.com/CitizensDev/Citizens2.git
synced 2025-01-14 04:02:01 +01:00
Change version checking to be rename based
This commit is contained in:
parent
f0ee7e7cfa
commit
20dcfd0a22
@ -257,10 +257,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
CitizensAPI.setImplementation(this);
|
||||
config = new Settings(getDataFolder());
|
||||
// Disable if the server is not using the compatible Minecraft version
|
||||
String mcVersion = Util.getMinecraftVersion();
|
||||
for (String version : COMPATIBLE_MC_VERSIONS) {
|
||||
compatible |= mcVersion.startsWith(version);
|
||||
}
|
||||
String mcVersion = Util.getMinecraftRevision();
|
||||
compatible = COMPATIBLE_MC_REVISION.equals(mcVersion);
|
||||
if (Setting.CHECK_MINECRAFT_VERSION.asBoolean() && !compatible) {
|
||||
Messaging.severeTr(Messages.CITIZENS_INCOMPATIBLE, getDescription().getVersion(), mcVersion);
|
||||
getServer().getPluginManager().disablePlugin(this);
|
||||
@ -456,5 +454,8 @@ public class Citizens extends JavaPlugin implements CitizensPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private static final String[] COMPATIBLE_MC_VERSIONS = { "1.8.5", "1.8.6", "1.8.7" };
|
||||
public static void main(String[] args) {
|
||||
}
|
||||
|
||||
private static final String COMPATIBLE_MC_REVISION = "1_8_R3";
|
||||
}
|
||||
|
@ -2,13 +2,10 @@ package net.citizensnpcs.util;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCCollisionEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.craftbukkit.v1_8_R3.CraftServer;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
@ -18,6 +15,10 @@ import org.bukkit.util.Vector;
|
||||
import com.google.common.base.Joiner;
|
||||
import com.google.common.base.Splitter;
|
||||
|
||||
import net.citizensnpcs.api.event.NPCCollisionEvent;
|
||||
import net.citizensnpcs.api.event.NPCPushEvent;
|
||||
import net.citizensnpcs.api.npc.NPC;
|
||||
|
||||
public class Util {
|
||||
// Static class for small (emphasis small) utility methods
|
||||
private Util() {
|
||||
@ -73,14 +74,9 @@ public class Util {
|
||||
return new XORShiftRNG();
|
||||
}
|
||||
|
||||
public static String getMinecraftVersion() {
|
||||
String raw = Bukkit.getVersion();
|
||||
int start = raw.indexOf("MC:");
|
||||
if (start == -1)
|
||||
return raw;
|
||||
start += 4;
|
||||
int end = raw.indexOf(')', start);
|
||||
return raw.substring(start, end);
|
||||
public static String getMinecraftRevision() {
|
||||
String raw = CraftServer.class.getPackage().getName();
|
||||
return raw.substring(raw.lastIndexOf('.') + 2);
|
||||
}
|
||||
|
||||
public static boolean isAlwaysFlyable(EntityType type) {
|
||||
|
Loading…
Reference in New Issue
Block a user