Skip to content

Commit c7668c1

Browse files
committed
Switched API to singleton
1 parent dc08e64 commit c7668c1

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

src/main/java/com/hiddentech/playerstorage/PlayerStorageAPI.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,9 @@ public PlayerRegistry getRegistry() {
5555
}
5656

5757
private final PlayerRegistry registry;
58+
private static PlayerStorageAPI instance;
5859

59-
public PlayerStorageAPI(JavaPlugin plugin) {
60+
private PlayerStorageAPI(JavaPlugin plugin) {
6061
this.plugin = plugin;
6162
this.registry = new PlayerRegistry(this);
6263
new PlayerJoinListener(this);
@@ -79,6 +80,12 @@ public PlayerStorageAPI(JavaPlugin plugin) {
7980
});
8081

8182
}
83+
public PlayerStorageAPI getInstance(JavaPlugin plugin){
84+
if(instance==null){
85+
instance = new PlayerStorageAPI(plugin);
86+
}
87+
return instance;
88+
}
8289

8390
private void enableMongo(boolean mongoEnabled) {
8491
File file = new File(getPlugin().getDataFolder() + "/Database.yml");

0 commit comments

Comments
 (0)