Search in sources :

Example 1 with UserStorage

use of com.bencodez.advancedcore.api.user.UserStorage in project AdvancedCore by BenCodez.

the class AdvancedCorePlugin method loadTabComplete.

public void loadTabComplete() {
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(AllPlayer)", new ArrayList<String>()) {

        @Override
        public void reload() {
            ArrayList<String> players = new ArrayList<String>();
            for (String name : getUuidNameCache().values()) {
                if (!players.contains(name)) {
                    players.add(name);
                }
            }
            setReplace(players);
        }

        @Override
        public void updateReplacements() {
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (!getReplace().contains(player.getName())) {
                    getReplace().add(player.getName());
                }
            }
        }
    });
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(Player)", new ArrayList<String>()) {

        @Override
        public void reload() {
        }

        @Override
        public void updateReplacements() {
            ArrayList<String> list = new ArrayList<String>();
            for (Player player : Bukkit.getOnlinePlayers()) {
                list.add(player.getName());
            }
            setReplace(list);
        }
    });
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(PlayerExact)", new ArrayList<String>()) {

        @Override
        public void reload() {
        }

        @Override
        public void updateReplacements() {
            ArrayList<String> list = new ArrayList<String>();
            for (Player player : Bukkit.getOnlinePlayers()) {
                list.add(player.getName());
            }
            setReplace(list);
        }
    });
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(uuid)", new ArrayList<String>()) {

        @Override
        public void reload() {
            ArrayList<String> uuids = new ArrayList<String>();
            for (String name : getUuidNameCache().keySet()) {
                if (!uuids.contains(name)) {
                    uuids.add(name);
                }
            }
            setReplace(uuids);
        }

        @Override
        public void updateReplacements() {
            for (Player player : Bukkit.getOnlinePlayers()) {
                if (!getReplace().contains(player.getUniqueId().toString())) {
                    getReplace().add(player.getUniqueId().toString());
                }
            }
        }
    });
    ArrayList<String> options = new ArrayList<String>();
    options.add("True");
    options.add("False");
    TabCompleteHandler.getInstance().addTabCompleteOption("(Boolean)", options);
    options = new ArrayList<String>();
    TabCompleteHandler.getInstance().addTabCompleteOption("(List)", options);
    TabCompleteHandler.getInstance().addTabCompleteOption("(String)", options);
    TabCompleteHandler.getInstance().addTabCompleteOption("(Text)", options);
    TabCompleteHandler.getInstance().addTabCompleteOption("(Number)", options);
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(Reward)", options) {

        @Override
        public void reload() {
            ArrayList<String> rewards = new ArrayList<String>();
            for (Reward reward : rewardHandler.getRewards()) {
                if (!reward.getConfig().isDirectlyDefinedReward()) {
                    rewards.add(reward.getRewardName());
                }
            }
            setReplace(rewards);
        }

        @Override
        public void updateReplacements() {
        }
    });
    TabCompleteHandler.getInstance().addTabCompleteOption(new TabCompleteHandle("(ChoiceReward)", options) {

        @Override
        public void reload() {
            ArrayList<String> rewards = new ArrayList<String>();
            for (Reward reward : rewardHandler.getRewards()) {
                if (reward.getConfig().getEnableChoices()) {
                    rewards.add(reward.getRewardName());
                }
            }
            setReplace(rewards);
        }

        @Override
        public void updateReplacements() {
        }
    });
    ArrayList<String> method = new ArrayList<String>();
    for (InputMethod me : InputMethod.values()) {
        method.add(me.toString());
    }
    TabCompleteHandler.getInstance().addTabCompleteOption("(RequestMethod)", method);
    ArrayList<String> userStorage = new ArrayList<String>();
    for (UserStorage storage : UserStorage.values()) {
        userStorage.add(storage.toString());
    }
    TabCompleteHandler.getInstance().addTabCompleteOption("(UserStorage)", userStorage);
    ArrayList<String> times = new ArrayList<String>();
    for (TimeType ty : TimeType.values()) {
        times.add(ty.toString());
    }
    TabCompleteHandler.getInstance().addTabCompleteOption("(TimeType)", times);
}
Also used : Player(org.bukkit.entity.Player) OfflinePlayer(org.bukkit.OfflinePlayer) InputMethod(com.bencodez.advancedcore.api.valuerequest.InputMethod) TabCompleteHandle(com.bencodez.advancedcore.api.command.TabCompleteHandle) ArrayList(java.util.ArrayList) EditGUIValueString(com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString) RequirementInjectString(com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectString) Reward(com.bencodez.advancedcore.api.rewards.Reward) UserStorage(com.bencodez.advancedcore.api.user.UserStorage) TimeType(com.bencodez.advancedcore.api.time.TimeType)

Aggregations

TabCompleteHandle (com.bencodez.advancedcore.api.command.TabCompleteHandle)1 EditGUIValueString (com.bencodez.advancedcore.api.inventory.editgui.valuetypes.EditGUIValueString)1 Reward (com.bencodez.advancedcore.api.rewards.Reward)1 RequirementInjectString (com.bencodez.advancedcore.api.rewards.injectedrequirement.RequirementInjectString)1 TimeType (com.bencodez.advancedcore.api.time.TimeType)1 UserStorage (com.bencodez.advancedcore.api.user.UserStorage)1 InputMethod (com.bencodez.advancedcore.api.valuerequest.InputMethod)1 ArrayList (java.util.ArrayList)1 OfflinePlayer (org.bukkit.OfflinePlayer)1 Player (org.bukkit.entity.Player)1