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

cn.nukkit.command.data.CommandEnum Maven / Gradle / Ivy

Go to download

A Minecraft Bedrock Edition server software implementation made in Java from scratch which supports all new features.

There is a newer version: 1.6.0.1-PN
Show newest version
package cn.nukkit.command.data;

import cn.nukkit.api.Since;
import cn.nukkit.block.BlockID;
import cn.nukkit.item.ItemID;
import com.google.common.collect.ImmutableList;

import java.lang.reflect.Field;
import java.util.Arrays;
import java.util.List;

/**
 * @author CreeperFace
 */
public class CommandEnum {
    
    @Since("1.3.2.0-PN")
    public static final CommandEnum ENUM_BOOLEAN = new CommandEnum("Boolean", ImmutableList.of("true", "false"));

    @Since("1.3.2.0-PN")
    public static final CommandEnum ENUM_GAMEMODE = new CommandEnum("GameMode",
            ImmutableList.of("survival", "creative", "s", "c", "adventure", "a", "spectator", "view", "v", "spc"));

    @Since("1.3.2.0-PN")
    public static final CommandEnum ENUM_BLOCK;

    @Since("1.3.2.0-PN")
    public static final CommandEnum ENUM_ITEM;

    static {
        ImmutableList.Builder blocks = ImmutableList.builder();
        for (Field field : BlockID.class.getDeclaredFields()) {
            blocks.add(field.getName().toLowerCase());
        }
        ENUM_BLOCK = new CommandEnum("Block", blocks.build());

        ImmutableList.Builder items = ImmutableList.builder();
        for (Field field : ItemID.class.getDeclaredFields()) {
            items.add(field.getName().toLowerCase());
        }
        items.addAll(ENUM_BLOCK.getValues());
        ENUM_ITEM = new CommandEnum("Item", items.build());
    }

    private String name;
    private List values;

    @Since("1.3.2.0-PN")
    public CommandEnum(String name, String... values) {
        this(name, Arrays.asList(values));
    }

    public CommandEnum(String name, List values) {
        this.name = name;
        this.values = values;
    }

    public String getName() {
        return name;
    }

    public List getValues() {
        return values;
    }

    public int hashCode() {
        return name.hashCode();
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy