command changes

This commit is contained in:
Pyrbu 2023-05-10 14:42:23 +01:00
parent 252498c3e4
commit bd22453f76
7 changed files with 12 additions and 21 deletions

@ -15,8 +15,8 @@ import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class CreateCommand implements CommandHandler { public class CreateCommand implements CommandHandler {
@Override @Override
@ -58,15 +58,8 @@ public class CreateCommand implements CommandHandler {
@Override @Override
public List<String> suggest(CommandContext context) throws CommandExecutionException { public List<String> suggest(CommandContext context) throws CommandExecutionException {
if (context.argSize() == 1) { if (context.argSize() == 1) return context.suggestCollection(NpcRegistryImpl.get().modifiableIds());
return context.suggestLiteral("<npc_id>"); if (context.argSize() == 2) return context.suggestStream(NpcTypeImpl.values().stream().map(NpcTypeImpl::getName));
} return Collections.emptyList();
if (context.argSize() == 2) {
return context.suggestCollection(NpcTypeImpl.values().stream().map(NpcTypeImpl::getName).collect(Collectors.toList()));
}
if (context.argSize() == 3) {
return context.suggestLiteral("<npc_name>");
}
return CommandHandler.super.suggest(context);
} }
} }

@ -9,8 +9,8 @@ import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
import net.kyori.adventure.text.Component; import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.format.NamedTextColor;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
public class DeleteCommand implements CommandHandler { public class DeleteCommand implements CommandHandler {
@Override @Override
@ -31,9 +31,7 @@ public class DeleteCommand implements CommandHandler {
@Override @Override
public List<String> suggest(CommandContext context) throws CommandExecutionException { public List<String> suggest(CommandContext context) throws CommandExecutionException {
if (context.argSize() == 1) { if (context.argSize() == 1) return context.suggestCollection(NpcRegistryImpl.get().modifiableIds());
return context.suggestCollection(NpcRegistryImpl.get().ids().stream().filter(s -> !s.startsWith(ZNpcsPlus.DEBUG_NPC_PREFIX)).collect(Collectors.toList())); return Collections.emptyList();
}
return CommandHandler.super.suggest(context);
} }
} }

@ -1,4 +1,4 @@
package lol.pyr.znpcsplus.commands; package lol.pyr.znpcsplus.commands.hologram;
import lol.pyr.director.adventure.command.CommandContext; import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.command.CommandHandler; import lol.pyr.director.adventure.command.CommandHandler;

@ -1,4 +1,4 @@
package lol.pyr.znpcsplus.commands; package lol.pyr.znpcsplus.commands.hologram;
import lol.pyr.director.adventure.command.CommandContext; import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.command.CommandHandler; import lol.pyr.director.adventure.command.CommandHandler;

@ -1,4 +1,4 @@
package lol.pyr.znpcsplus.commands; package lol.pyr.znpcsplus.commands.hologram;
import lol.pyr.director.adventure.command.CommandContext; import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.command.CommandHandler; import lol.pyr.director.adventure.command.CommandHandler;

@ -1,4 +1,4 @@
package lol.pyr.znpcsplus.commands; package lol.pyr.znpcsplus.commands.hologram;
import lol.pyr.director.adventure.command.CommandContext; import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.command.CommandHandler; import lol.pyr.director.adventure.command.CommandHandler;

@ -1,4 +1,4 @@
package lol.pyr.znpcsplus.commands; package lol.pyr.znpcsplus.commands.hologram;
import lol.pyr.director.adventure.command.CommandContext; import lol.pyr.director.adventure.command.CommandContext;
import lol.pyr.director.adventure.command.CommandHandler; import lol.pyr.director.adventure.command.CommandHandler;