Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions src/main/java/net/thenextlvl/portals/PortalsPlugin.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package net.thenextlvl.portals;

import core.file.FileIO;
import core.file.format.GsonFile;
import core.i18n.file.ComponentBundle;
import core.io.IO;
import io.papermc.paper.math.Position;
import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.kyori.adventure.key.Key;
Expand Down Expand Up @@ -43,11 +46,16 @@ public final class PortalsPlugin extends JavaPlugin {
public static final String ISSUES = "https://github.com/TheNextLvl-net/portals/issues/new";

private final PaperPortalProvider portalProvider = new PaperPortalProvider(this);
private final PortalConfig portalConfig = SimplePortalConfig.INSTANCE;
private EconomyProvider economyProvider = new EmptyEconomyProvider();

private final Metrics metrics = new Metrics(this, 27514);

private final FileIO<SimplePortalConfig> portalConfig = new GsonFile<>(
IO.of(getDataPath().resolve("config.json")),
new SimplePortalConfig(true, false, true, 0.3),
SimplePortalConfig.class
).validate().saveIfAbsent();

private final ComponentBundle bundle = ComponentBundle.builder(
Key.key("portals", "translations"),
getDataPath().resolve("translations")
Expand All @@ -59,7 +67,7 @@ public final class PortalsPlugin extends JavaPlugin {
public PortalsPlugin() {
StaticBinder.getInstance(ActionTypes.class.getClassLoader()).bind(ActionTypes.class, SimpleActionTypes.INSTANCE);
StaticBinder.getInstance(ActionTypeRegistry.class.getClassLoader()).bind(ActionTypeRegistry.class, SimpleActionTypeRegistry.INSTANCE);
StaticBinder.getInstance(PortalConfig.class.getClassLoader()).bind(PortalConfig.class, portalConfig);
StaticBinder.getInstance(PortalConfig.class.getClassLoader()).bind(PortalConfig.class, portalConfig.getRoot());
StaticBinder.getInstance(PortalProvider.class.getClassLoader()).bind(PortalProvider.class, portalProvider);

registerCommands();
Expand Down Expand Up @@ -109,7 +117,7 @@ public ComponentBundle bundle() {

@Contract(pure = true)
public PortalConfig config() {
return portalConfig;
return portalConfig.getRoot();
}

@Contract(value = "_ -> new", pure = true)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,4 @@ public record SimplePortalConfig(
boolean pushBackOnEntryDenied,
double pushbackSpeed
) implements PortalConfig {
public static final SimplePortalConfig INSTANCE = new SimplePortalConfig(
true, false, true, 0.3
);
}