Search in sources :

Example 1 with MenuItemDecimal

use of au.com.mineauz.minigames.menu.MenuItemDecimal in project Minigames by AddstarMC.

the class PlaySoundAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Play Sound", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
    List<String> sounds = new ArrayList<>();
    for (Sound s : Sound.values()) sounds.add(MinigameUtils.capitalize(s.toString().replace("_", " ")));
    m.addItem(new MenuItemList("Sound", Material.NOTE_BLOCK, new Callback<String>() {

        @Override
        public void setValue(String value) {
            sound.setFlag(value.toUpperCase().replace(" ", "_"));
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(sound.getFlag().replace("_", " "));
        }
    }, sounds));
    m.addItem(priv.getMenuItem("Private Playback", Material.ENDER_PEARL));
    m.addItem(new MenuItemDecimal("Volume", Material.JUKEBOX, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            vol.setFlag(value.floatValue());
        }

        @Override
        public Double getValue() {
            return vol.getFlag().doubleValue();
        }
    }, 0.1, 1d, 0.5, null));
    m.addItem(new MenuItemDecimal("Pitch", Material.EYE_OF_ENDER, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            pit.setFlag(value.floatValue());
        }

        @Override
        public Double getValue() {
            return pit.getFlag().doubleValue();
        }
    }, 0.05, 0.1, 0d, 2d));
    m.displayMenu(player);
    return true;
}
Also used : Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) Sound(org.bukkit.Sound) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemDecimal(au.com.mineauz.minigames.menu.MenuItemDecimal)

Example 2 with MenuItemDecimal

use of au.com.mineauz.minigames.menu.MenuItemDecimal in project Minigames by AddstarMC.

the class SpawnEntityAction method displayMenu.

@Override
public boolean displayMenu(MinigamePlayer player, Menu previous) {
    Menu m = new Menu(3, "Spawn Entity", player);
    m.addItem(new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, previous), m.getSize() - 9);
    List<String> options = new ArrayList<>();
    for (EntityType type : EntityType.values()) {
        if (type != EntityType.ITEM_FRAME && type != EntityType.LEASH_HITCH && type != EntityType.PLAYER && type != EntityType.COMPLEX_PART && type != EntityType.WEATHER && type != EntityType.LIGHTNING && type != EntityType.PAINTING && type != EntityType.UNKNOWN && type != EntityType.DROPPED_ITEM)
            options.add(MinigameUtils.capitalize(type.toString().replace("_", " ")));
    }
    m.addItem(new MenuItemList("Entity Type", Material.SKULL_ITEM, new Callback<String>() {

        @Override
        public void setValue(String value) {
            type.setFlag(value.toUpperCase().replace(" ", "_"));
            settings.clear();
            addBaseSettings();
        }

        @Override
        public String getValue() {
            return MinigameUtils.capitalize(type.getFlag().replace("_", " "));
        }
    }, options));
    m.addItem(new MenuItemDecimal("X Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityx", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityx"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemDecimal("Y Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityy", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityy"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemDecimal("Z Velocity", Material.ARROW, new Callback<Double>() {

        @Override
        public void setValue(Double value) {
            settings.put("velocityz", value.toString());
        }

        @Override
        public Double getValue() {
            return Double.valueOf(settings.get("velocityz"));
        }
    }, 0.5, 1, null, null));
    m.addItem(new MenuItemNewLine());
    final Menu eSet = new Menu(3, "Settings", player);
    final MenuItemPage backButton = new MenuItemPage("Back", Material.REDSTONE_TORCH_ON, m);
    final MenuItemCustom cus = new MenuItemCustom("Entity Settings", Material.CHEST);
    final MinigamePlayer fply = player;
    cus.setClick(new InteractionInterface() {

        @Override
        public Object interact(Object object) {
            if (type.getFlag().equals("ZOMBIE")) {
                eSet.clearMenu();
                eSet.addItem(backButton, eSet.getSize() - 9);
                livingEntitySettings(eSet);
                eSet.displayMenu(fply);
                return null;
            }
            return cus.getItem();
        }
    });
    m.addItem(cus);
    m.displayMenu(player);
    return true;
}
Also used : MinigamePlayer(au.com.mineauz.minigames.MinigamePlayer) MenuItemPage(au.com.mineauz.minigames.menu.MenuItemPage) ArrayList(java.util.ArrayList) MenuItemNewLine(au.com.mineauz.minigames.menu.MenuItemNewLine) MenuItemString(au.com.mineauz.minigames.menu.MenuItemString) MenuItemCustom(au.com.mineauz.minigames.menu.MenuItemCustom) EntityType(org.bukkit.entity.EntityType) Callback(au.com.mineauz.minigames.menu.Callback) MenuItemList(au.com.mineauz.minigames.menu.MenuItemList) InteractionInterface(au.com.mineauz.minigames.menu.InteractionInterface) Menu(au.com.mineauz.minigames.menu.Menu) MenuItemDecimal(au.com.mineauz.minigames.menu.MenuItemDecimal)

Aggregations

Callback (au.com.mineauz.minigames.menu.Callback)2 Menu (au.com.mineauz.minigames.menu.Menu)2 MenuItemDecimal (au.com.mineauz.minigames.menu.MenuItemDecimal)2 MenuItemList (au.com.mineauz.minigames.menu.MenuItemList)2 MenuItemPage (au.com.mineauz.minigames.menu.MenuItemPage)2 ArrayList (java.util.ArrayList)2 MinigamePlayer (au.com.mineauz.minigames.MinigamePlayer)1 InteractionInterface (au.com.mineauz.minigames.menu.InteractionInterface)1 MenuItemCustom (au.com.mineauz.minigames.menu.MenuItemCustom)1 MenuItemNewLine (au.com.mineauz.minigames.menu.MenuItemNewLine)1 MenuItemString (au.com.mineauz.minigames.menu.MenuItemString)1 Sound (org.bukkit.Sound)1 EntityType (org.bukkit.entity.EntityType)1