Search in sources :

Example 1 with ServerVersion

use of simple.brainsynder.utils.ServerVersion in project SimplePets by brainsynder-Dev.

the class PetCore method reloadSpawner.

private void reloadSpawner() {
    ServerVersion version = ServerVersion.getVersion();
    try {
        Class<?> clazz = Class.forName("simplepets.brainsynder.nms." + version.name() + ".entities.SpawnUtil");
        if (clazz == null)
            return;
        if (ISpawner.class.isAssignableFrom(clazz)) {
            spawner = (ISpawner) clazz.getConstructor().newInstance();
            debug("Successfully Linked to " + version.name() + " SpawnUtil Class");
        }
    } catch (Exception e) {
        debug("Could not link to a SpawnUtil Class... Possible Wrong version?");
    }
}
Also used : ServerVersion(simple.brainsynder.utils.ServerVersion)

Example 2 with ServerVersion

use of simple.brainsynder.utils.ServerVersion in project SimplePets by brainsynder-Dev.

the class VersionNMS method registerPets.

public void registerPets() {
    ServerVersion version = ServerVersion.getVersion();
    if (!(version == ServerVersion.v1_11_R1 || version == ServerVersion.v1_12_R1))
        return;
    PetCore.get().debug("Registering Pets...");
    try {
        Class<?> clazz = Class.forName("simplepets.brainsynder.nms." + version.name() + ".registry.Registry");
        if (clazz == null)
            return;
        IPetRegistry registry = (IPetRegistry) clazz.getConstructor().newInstance();
        PetCore.get().debug("Registering Mobs/Pets...");
        registry.registerPets();
    } catch (Exception e) {
        PetCore.get().debug("Could not link to a version for PetRegister. Possibly an Unsupported NMS version.");
        e.printStackTrace();
    }
}
Also used : ServerVersion(simple.brainsynder.utils.ServerVersion)

Example 3 with ServerVersion

use of simple.brainsynder.utils.ServerVersion in project SimplePets by brainsynder-Dev.

the class PetCore method fetchSupportedVersions.

// GETTERS
private void fetchSupportedVersions() {
    supportedVersions.clear();
    String current = Reflection.getVersion();
    boolean supported = false;
    String packageName = "simplepets.brainsynder.nms.<VER>.anvil.HandleAnvilGUI";
    for (ServerVersion version : ServerVersion.values()) {
        if (version.name().equals(current) && (!supported))
            supported = true;
        try {
            Class<?> clazz = Class.forName(packageName.replace("<VER>", version.name()), false, getClassLoader());
            if (clazz != null)
                supportedVersions.add(version.name());
        } catch (Exception e) {
        }
    }
    if (!supported) {
        try {
            Class<?> clazz = Class.forName(packageName.replace("<VER>", current), false, getClassLoader());
            if (clazz != null)
                supportedVersions.add(current);
        } catch (Exception e) {
        }
    }
    if (!supportedVersions.isEmpty())
        debug("Found support for version(s): " + supportedVersions.toString());
}
Also used : ServerVersion(simple.brainsynder.utils.ServerVersion)

Aggregations

ServerVersion (simple.brainsynder.utils.ServerVersion)3