Fix PAPI registration.

This commit is contained in:
Jeremy Wood 2023-03-26 14:48:30 -04:00
parent 44dacdceb1
commit edea4aff4b
No known key found for this signature in database
GPG Key ID: C5BAD04C77B91B4B
2 changed files with 10 additions and 6 deletions

View File

@ -66,8 +66,6 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
@Inject
private Provider<MetricsConfigurator> metricsConfiguratorProvider;
@Inject
private Provider<MultiverseCorePlaceholders> placeholdersProvider;
@Inject
private Provider<MVEconomist> economistProvider;
// Counter for the number of plugins that have registered with us
@ -135,7 +133,7 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
this.setUpLocales();
this.registerDestinations();
this.setupMetrics();
this.setupPlaceholderAPI();
this.loadPlaceholderAPIIntegration();
this.saveMVConfig();
this.logEnableMessage();
}
@ -259,10 +257,9 @@ public class MultiverseCore extends JavaPlugin implements MVCore {
}
}
private void setupPlaceholderAPI() {
private void loadPlaceholderAPIIntegration() {
if(getServer().getPluginManager().getPlugin("PlaceholderAPI") != null) {
Try.of(() -> placeholdersProvider.get())
.onSuccess(MultiverseCorePlaceholders::register)
Try.run(() -> serviceLocator.createAndInitialize(MultiverseCorePlaceholders.class))
.onFailure(e -> Logging.severe("Failed to load PlaceholderAPI integration.", e));
}
}

View File

@ -6,6 +6,7 @@ import com.onarandombox.MultiverseCore.MultiverseCore;
import com.onarandombox.MultiverseCore.api.MVWorld;
import com.onarandombox.MultiverseCore.api.MVWorldManager;
import com.onarandombox.MultiverseCore.economy.MVEconomist;
import jakarta.annotation.PostConstruct;
import jakarta.inject.Inject;
import me.clip.placeholderapi.expansion.PlaceholderExpansion;
import org.bukkit.OfflinePlayer;
@ -28,6 +29,12 @@ public class MultiverseCorePlaceholders extends PlaceholderExpansion {
this.economist = economist;
}
@PostConstruct
@Override
public boolean register() {
return super.register();
}
@Override
public @NotNull String getIdentifier() {
return "multiverse-core";