mirror of
https://github.com/songoda/EpicEnchants.git
synced 2024-12-31 21:48:28 +01:00
Added auto complete.
This commit is contained in:
parent
204f16886a
commit
93e16c7332
@ -6,12 +6,15 @@ import com.songoda.epicenchants.command.AbstractCommand;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.utils.Tuple;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE;
|
||||
import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult;
|
||||
@ -84,6 +87,24 @@ public class CommandApply extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
return instance.getEnchantManager().getValues()
|
||||
.stream().map(Enchant::getIdentifier).collect(Collectors.toList());
|
||||
} else if (args.length == 3) {
|
||||
Enchant enchant = instance.getEnchantManager().getValues()
|
||||
.stream().findFirst().orElse(null);
|
||||
List<String> levels = new ArrayList<>();
|
||||
if (enchant != null) {
|
||||
for (int i = 1; i <= enchant.getMaxLevel(); i ++)
|
||||
levels.add(String.valueOf(i));
|
||||
}
|
||||
return levels;
|
||||
} else if (args.length == 4 || args.length == 5) {
|
||||
List<String> rates = new ArrayList<>();
|
||||
for (int i = 1; i <= 100; i ++)
|
||||
rates.add(String.valueOf(i));
|
||||
return rates;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3,20 +3,16 @@ package com.songoda.epicenchants.command.commands;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.command.AbstractCommand;
|
||||
import com.songoda.epicenchants.enums.EnchantResult;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import com.songoda.epicenchants.utils.Tuple;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
import static com.songoda.epicenchants.enums.EnchantResult.BROKEN_FAILURE;
|
||||
import static com.songoda.epicenchants.utils.single.GeneralUtils.getMessageFromResult;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandGiveBook extends AbstractCommand {
|
||||
|
||||
@ -52,7 +48,7 @@ public class CommandGiveBook extends AbstractCommand {
|
||||
if (args.length > 3) {
|
||||
if (!CommandCommons.isInt(args[3], sender))
|
||||
return ReturnType.FAILURE;
|
||||
level = Integer.parseInt(args[3]);
|
||||
level = Integer.parseInt(args[3]);
|
||||
}
|
||||
|
||||
if (args.length > 4) {
|
||||
@ -88,6 +84,26 @@ public class CommandGiveBook extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
} else if (args.length == 3) {
|
||||
return instance.getEnchantManager().getValues()
|
||||
.stream().map(Enchant::getIdentifier).collect(Collectors.toList());
|
||||
} else if (args.length == 4) {
|
||||
Enchant enchant = instance.getEnchantManager().getValues()
|
||||
.stream().findFirst().orElse(null);
|
||||
List<String> levels = new ArrayList<>();
|
||||
if (enchant != null) {
|
||||
for (int i = 1; i <= enchant.getMaxLevel(); i ++)
|
||||
levels.add(String.valueOf(i));
|
||||
}
|
||||
return levels;
|
||||
} else if (args.length == 5 || args.length == 6) {
|
||||
List<String> rates = new ArrayList<>();
|
||||
for (int i = 1; i <= 100; i ++)
|
||||
rates.add(String.valueOf(i));
|
||||
return rates;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -8,7 +8,10 @@ import com.songoda.epicenchants.objects.Group;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.configuration.file.FileConfiguration;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.stream.Collectors;
|
||||
@ -68,6 +71,23 @@ public class CommandGiveItemDust extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
} else if (args.length == 3) {
|
||||
return instance.getGroupManager().getValues().stream()
|
||||
.map(Group::getIdentifier).collect(Collectors.toList());
|
||||
} else if (args.length == 4) {
|
||||
List<String> dusts = new ArrayList<>();
|
||||
|
||||
FileConfiguration dustConfig = instance.getFileManager().getConfiguration("items/dusts");
|
||||
dusts.addAll(dustConfig.getConfigurationSection("dusts").getKeys(false));
|
||||
return dusts;
|
||||
} else if (args.length == 5) {
|
||||
List<String> rates = new ArrayList<>();
|
||||
for (int i = 1; i <= 100; i ++)
|
||||
rates.add(String.valueOf(i));
|
||||
return rates;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -3,11 +3,16 @@ package com.songoda.epicenchants.command.commands;
|
||||
import com.songoda.epicenchants.CommandCommons;
|
||||
import com.songoda.epicenchants.EpicEnchants;
|
||||
import com.songoda.epicenchants.command.AbstractCommand;
|
||||
import com.songoda.epicenchants.objects.Enchant;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class CommandGiveScroll extends AbstractCommand {
|
||||
|
||||
@ -72,6 +77,16 @@ public class CommandGiveScroll extends AbstractCommand {
|
||||
|
||||
@Override
|
||||
protected List<String> onTab(EpicEnchants instance, CommandSender sender, String... args) {
|
||||
if (args.length == 2) {
|
||||
return Arrays.asList("whitescroll", "blackscroll");
|
||||
} else if (args.length == 3) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
} else if (args.length == 4 || args.length == 5) {
|
||||
List<String> rates = new ArrayList<>();
|
||||
for (int i = 1; i <= (args.length == 4 ? 10 : 100); i ++)
|
||||
rates.add(String.valueOf(i));
|
||||
return rates;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user