mirror of
https://github.com/songoda/EpicBuckets.git
synced 2024-11-22 10:15:49 +01:00
Added command completions for give command
This commit is contained in:
parent
0c51507c3f
commit
bc72b101c7
@ -2,6 +2,7 @@ package com.songoda.epicbuckets;
|
||||
|
||||
import co.aikar.commands.BukkitCommandManager;
|
||||
import com.songoda.epicbuckets.command.CommandGenbucket;
|
||||
import com.songoda.epicbuckets.command.CommandTabbing;
|
||||
import com.songoda.epicbuckets.file.ConfigManager;
|
||||
import com.songoda.epicbuckets.genbucket.GenbucketManager;
|
||||
import com.songoda.epicbuckets.listener.GenbucketPlaceListener;
|
||||
@ -61,6 +62,7 @@ public class EpicBuckets extends ExtendedJavaPlugin {
|
||||
inventoryManager = new InventoryManager(this);
|
||||
inventoryManager.init();
|
||||
|
||||
CommandTabbing.registerCommandCompletions();
|
||||
commandManager.registerCommand(new CommandGenbucket());
|
||||
|
||||
getServer().getPluginManager().registerEvents(new GenbucketPlaceListener(), this);
|
||||
|
@ -2,6 +2,7 @@ package com.songoda.epicbuckets.command;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
import co.aikar.commands.contexts.OnlinePlayer;
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.gui.GUIMain;
|
||||
import com.songoda.epicbuckets.gui.GUIPanel;
|
||||
@ -38,8 +39,9 @@ public class CommandGenbucket extends BaseCommand {
|
||||
}
|
||||
|
||||
@Subcommand("give")
|
||||
@CommandCompletion("@players @traits @genitems")
|
||||
@Description("Gives a genbucket to a player")
|
||||
public void give(CommandSender sender, ) {
|
||||
public void give(CommandSender sender, OnlinePlayer onlinePlayer, String trait, String genitem, @Optional int cost) {
|
||||
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,45 @@ package com.songoda.epicbuckets.command;
|
||||
import co.aikar.commands.BukkitCommandCompletionContext;
|
||||
import co.aikar.commands.CommandCompletions;
|
||||
import com.songoda.epicbuckets.EpicBuckets;
|
||||
import com.songoda.epicbuckets.shop.Shop;
|
||||
import com.songoda.epicbuckets.shop.SubShop;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class CommandTabbing {
|
||||
|
||||
public static void registerCommandCompletions() {
|
||||
CommandCompletions<BukkitCommandCompletionContext> commandCompletions = EpicBuckets.getInstance().getCommandManager().getCommandCompletions();
|
||||
|
||||
commandCompletions.registerCompletion("")
|
||||
commandCompletions.registerCompletion("traits", c -> {
|
||||
if (c.getSender() instanceof Player) {
|
||||
List<String> traits = new ArrayList<>();
|
||||
for (Shop shop : EpicBuckets.getInstance().getShopManager().getShops()) {
|
||||
if (!traits.contains(shop.getTrait().name())) {
|
||||
traits.add(shop.getTrait().name());
|
||||
}
|
||||
}
|
||||
return traits;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
|
||||
commandCompletions.registerCompletion("genitems", c -> {
|
||||
if (c.getSender() instanceof Player) {
|
||||
List<String> genitems = new ArrayList<>();
|
||||
for (Shop shop : EpicBuckets.getInstance().getShopManager().getShops()) {
|
||||
for (SubShop subShop : shop.getSubShops()) {
|
||||
if (!genitems.contains(subShop.getGenItem().getType().name())) {
|
||||
genitems.add(subShop.getGenItem().getType().name());
|
||||
}
|
||||
}
|
||||
}
|
||||
return genitems;
|
||||
}
|
||||
return null;
|
||||
});
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user