All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.cryptomorin.xseries.reflection.minecraft.MinecraftPackage Maven / Gradle / Ivy

There is a newer version: 12.1.0
Show newest version
package com.cryptomorin.xseries.reflection.minecraft;

import com.cryptomorin.xseries.reflection.XReflection;
import com.cryptomorin.xseries.reflection.jvm.classes.PackageHandle;
import org.intellij.lang.annotations.Pattern;

public enum MinecraftPackage implements PackageHandle {
    NMS(XReflection.NMS_PACKAGE), CB(XReflection.CRAFTBUKKIT_PACKAGE),
    BUKKIT("org.bukkit"), SPIGOT("org.spigotmc");

    private final String packageId;

    MinecraftPackage(String packageName) {this.packageId = packageName;}

    @Override
    public String packageId() {
        return name();
    }

    @Override
    public String getBasePackageName() {
        return packageId;
    }

    @Override
    public String getPackage(@Pattern(PackageHandle.JAVA_PACKAGE_PATTERN) String packageName) {
        if (packageName.startsWith(".") || packageName.endsWith("."))
            throw new IllegalArgumentException("Package name must not start or end with a dot: " + packageName + " (" + this + ')');
        if (!packageName.isEmpty() && (this != MinecraftPackage.NMS || XReflection.supports(17))) {
            return packageId + '.' + packageName;
        }
        return packageId;
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy