Skip to content

Commit

Permalink
improve IHandlerInitializer.java
Browse files Browse the repository at this point in the history
  • Loading branch information
caoli5288 committed Jan 7, 2021
1 parent fb0a0f3 commit b9b8574
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
7 changes: 6 additions & 1 deletion src/main/java/com/mengcraft/simpleorm/EbeanManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public EbeanHandler getHandler(String name) {
}

private EbeanHandler build(JavaPlugin plugin, boolean shared, IHandlerInitializer initializer) {
if (shared || plugin.getConfig().getBoolean("dataSource.disabled", false)) {
if (shared || !initializer.isEnabled(plugin)) {
return new EbeanHandler(plugin, true, ORM.getSharedDs());
}

Expand Down Expand Up @@ -130,5 +130,10 @@ public void initialize(Plugin plugin, EbeanHandler handler) {
handler.setUser(user);
handler.setPassword(password);
}

@Override
public boolean isEnabled(Plugin plugin) {
return !plugin.getConfig().getBoolean("dataSource.disabled", false);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,8 @@
public interface IHandlerInitializer {

void initialize(Plugin plugin, EbeanHandler handler);

default boolean isEnabled(Plugin plugin) {
return true;
}
}

0 comments on commit b9b8574

Please sign in to comment.