Skip to content

Commit

Permalink
Streamline default vocal chord in preparation for speech API simplifi…
Browse files Browse the repository at this point in the history
…cation
  • Loading branch information
fullwall committed Oct 29, 2022
1 parent 45114dc commit c03160e
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
4 changes: 1 addition & 3 deletions main/src/main/java/net/citizensnpcs/Citizens.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
import net.citizensnpcs.npc.CitizensNPCRegistry;
import net.citizensnpcs.npc.CitizensTraitFactory;
import net.citizensnpcs.npc.NPCSelector;
import net.citizensnpcs.npc.ai.speech.Chat;
import net.citizensnpcs.npc.ai.speech.CitizensSpeechFactory;
import net.citizensnpcs.npc.profile.ProfileFetcher;
import net.citizensnpcs.npc.skin.Skin;
Expand Down Expand Up @@ -338,11 +337,10 @@ public void onEnable() {
return;
}

speechFactory = new CitizensSpeechFactory();
npcRegistry = new CitizensNPCRegistry(saves, "citizens");
traitFactory = new CitizensTraitFactory();
selector = new NPCSelector(this);
speechFactory = new CitizensSpeechFactory();
speechFactory.register(Chat.class, "chat");

Bukkit.getPluginManager().registerEvents(new EventListen(storedRegistries), this);
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@
public class CitizensSpeechFactory implements SpeechFactory {
private final Map<String, Class<? extends VocalChord>> registered = new HashMap<String, Class<? extends VocalChord>>();

public CitizensSpeechFactory() {
register(Chat.class, "chat");
}

@Override
public VocalChord getVocalChord(Class<? extends VocalChord> clazz) {
Preconditions.checkNotNull(clazz, "class cannot be null");
Expand All @@ -33,6 +37,9 @@ public VocalChord getVocalChord(Class<? extends VocalChord> clazz) {
public VocalChord getVocalChord(String name) {
Preconditions.checkNotNull(name, "name cannot be null");
// Check if VocalChord name is a registered type
if (name.equalsIgnoreCase("chat")) {
return new Chat();
}
if (isRegistered(name)) {
// Return a new instance of the VocalChord specified
try {
Expand Down

0 comments on commit c03160e

Please sign in to comment.