make property suggestions work
This commit is contained in:
parent
d9486acbd2
commit
74af9522ae
2 changed files with 5 additions and 4 deletions
|
@ -28,7 +28,7 @@ dependencies {
|
|||
implementation "com.github.retrooper.packetevents:spigot:2.0.0-SNAPSHOT"
|
||||
implementation "space.arim.dazzleconf:dazzleconf-ext-snakeyaml:1.2.1"
|
||||
|
||||
implementation "lol.pyr:director-adventure:2.0.6"
|
||||
implementation "lol.pyr:director-adventure:2.0.7"
|
||||
implementation project(":api")
|
||||
}
|
||||
|
||||
|
|
|
@ -8,6 +8,7 @@ import lol.pyr.znpcsplus.npc.NpcEntryImpl;
|
|||
import lol.pyr.znpcsplus.npc.NpcImpl;
|
||||
import lol.pyr.znpcsplus.npc.NpcRegistryImpl;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.format.NamedTextColor;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
@ -24,14 +25,14 @@ public class PropertiesCommand implements CommandHandler {
|
|||
// TODO: implement all the parsers for the types used in EntityPropertyImpl
|
||||
Object value = context.parse(property.getType());
|
||||
npc.UNSAFE_setProperty(property, value);
|
||||
context.send(Component.text("Set property " + property.getName() + " for NPC " + entry.getId() + " to " + value.toString()));
|
||||
context.send(Component.text("Set property " + property.getName() + " for NPC " + entry.getId() + " to " + value.toString(), NamedTextColor.GREEN));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(CommandContext context) throws CommandExecutionException {
|
||||
if (context.argSize() == 1) return context.suggestCollection(NpcRegistryImpl.get().modifiableIds());
|
||||
if (context.argSize() == 2) return context.suggestStream(context.suggestionParse(1, NpcEntryImpl.class)
|
||||
.getNpc().getType().getAllowedProperties().stream().map(EntityPropertyImpl::getName));
|
||||
if (context.argSize() == 2) return context.suggestStream(context.suggestionParse(0, NpcEntryImpl.class)
|
||||
.getNpc().getType().getAllowedProperties().stream().map(EntityPropertyImpl::getName));
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue