Skip to content

Commit

Permalink
( Patch for Citizens2#1455 ) Add NPCDataStore#reloadFromSource()
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Mar 23, 2018
1 parent 1be8ad3 commit ac5c649
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 6 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Expand Up @@ -101,5 +101,5 @@
</configuration>
</plugin>
</plugins>
</build>
</build>
</project>
Expand Up @@ -31,4 +31,8 @@ public void store(NPC npc) {
@Override
public void storeAll(NPCRegistry registry) {
}

@Override
public void reloadFromSource() {
}
}
15 changes: 10 additions & 5 deletions src/main/java/net/citizensnpcs/api/npc/NPCDataStore.java
Expand Up @@ -3,7 +3,7 @@
public interface NPCDataStore {
/**
* Clears all data about the given {@link NPC} from storage. Called when the NPC is removed.
*
*
* @param npc
* The NPC to clear data from
*/
Expand All @@ -18,7 +18,7 @@ public interface NPCDataStore {

/**
* Loads NPCs from disk into the given {@link NPCRegistry}. The registry should be cleared before this is called.
*
*
* @param registry
* The NPCRegistry to load NPCs into
*/
Expand All @@ -36,17 +36,22 @@ public interface NPCDataStore {

/**
* Stores the given {@link NPC} into memory or to a disk representation.
*
*
* @param npc
* The NPC to store
*/
void store(NPC npc);

/**
* Stores all {@link NPC}s in the given {@link NPCRegistry} to disk.
*
*
* @param registry
* The registry to store NPCs from
*/
void storeAll(NPCRegistry registry);
}

/**
* Reloads the data store from source (such as a file on disk).
*/
void reloadFromSource();
}
Expand Up @@ -118,6 +118,11 @@ private static <T extends Enum<?>> T matchEnum(T[] values, String toMatch) {
return type;
}

@Override
public void reloadFromSource() {
root.load();
}

private static final String LOAD_NAME_NOT_FOUND = "citizens.notifications.npc-name-not-found";
private static final String LOAD_UNKNOWN_NPC_TYPE = "citizens.notifications.unknown-npc-type";
}

0 comments on commit ac5c649

Please sign in to comment.