Expand spawn command syntax and improve tab completion
Updated the spawn command to require an additional <mob> argument. Enhanced the tab completion functionality to provide context-sensitive suggestions based on the number of arguments.
This commit is contained in:
parent
85af552f47
commit
fb2bbb70d4
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -8,6 +8,7 @@ build/
|
|||
.idea/modules.xml
|
||||
.idea/jarRepositories.xml
|
||||
.idea/compiler.xml
|
||||
.idea/uiDesigner.xml
|
||||
.idea/libraries/
|
||||
*.iws
|
||||
*.iml
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@ import org.bukkit.World;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
|
||||
|
|
@ -122,7 +123,15 @@ public class Spawn extends SubCommand {
|
|||
|
||||
@Override
|
||||
public List<String> getTabComplete(CommandSender commandSender, String[] args) {
|
||||
return List.of();
|
||||
return switch (args.length) {
|
||||
case 2 -> MobTypes.MOB_TYPES.getAllMobTypes();
|
||||
case 3 -> Arrays.stream(EntityType.values()).map(EntityType::name).toList();
|
||||
case 4 -> Bukkit.getWorlds().stream().map(World::getName).toList();
|
||||
case 5 -> commandSender instanceof Player player ? List.of(String.valueOf(player.getX())) : List.of("0");
|
||||
case 6 -> commandSender instanceof Player player ? List.of(String.valueOf(player.getY())) : List.of("0");
|
||||
case 7 -> commandSender instanceof Player player ? List.of(String.valueOf(player.getZ())) : List.of("0");
|
||||
default -> List.of();
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ public class Messages extends AbstractConfig {
|
|||
|
||||
public static String HELP_MESSAGE_WRAPPER = "<gold>Main help:\n<commands></gold>";
|
||||
public static String HELP_MESSAGE = "<green>Show this menu: <gold>/cm help</gold></green>";
|
||||
public static String SPAWN = "<green>Spawn a mob of a specific type: <gold>/cm spawn <mob_type> [<world> <x> <y> <z>]</gold></green>";
|
||||
public static String SPAWN = "<green>Spawn a mob of a specific type: <gold>/cm spawn <mob_type> <mob> [<world> <x> <y> <z>]</gold></green>";
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
|
|
|
|||
|
|
@ -43,6 +43,10 @@ public class MobTypes extends AbstractConfig {
|
|||
return Optional.of(MOB_TYPES.get(name));
|
||||
}
|
||||
|
||||
public static List<String> getAllMobTypes() {
|
||||
return MobTypes.MOB_TYPES.MOB_TYPES.keySet().stream().toList();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
private static void load() {
|
||||
MOB_TYPES.clear();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user