Skip to content

Commit

Permalink
Added MCUtils#getDataFolder
Browse files Browse the repository at this point in the history
  • Loading branch information
xDec0de committed Oct 30, 2024
1 parent 0699041 commit 0d1eb98
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
Expand All @@ -44,6 +45,12 @@ public SpigotUtils(@NotNull P plugin) {
this.console = new SpigotConsole(Bukkit.getConsoleSender());
}

@NotNull
@Override
public File getDataFolder() {
return getPlugin().getDataFolder();
}

@NotNull
public SpigotUtils<P> setPlayerProvider(@NotNull PlayerProvider<Player> playerProvider) {
this.playerProvider = Objects.requireNonNull(playerProvider, "Player provider cannot be null");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.nio.file.Path;
import java.util.Objects;
import java.util.UUID;

Expand All @@ -23,11 +25,13 @@ public class VelocityUtils<P> extends ProxyUtils<P> {
private final ProxyServer proxy;
private final VelocityConsole console;
private PlayerProvider<Player> playerProvider;
private final Path dataDirectory;

public VelocityUtils(@NotNull P plugin, @NotNull ProxyServer proxy) {
public VelocityUtils(@NotNull P plugin, @NotNull ProxyServer proxy, @NotNull Path dataDirectory) {
super(plugin);
this.proxy = Objects.requireNonNull(proxy);
this.console = new VelocityConsole(proxy.getConsoleCommandSource());
this.dataDirectory = dataDirectory;
}

@NotNull
Expand All @@ -46,6 +50,12 @@ public PlayerProvider<Player> getPlayerProvider() {
return playerProvider;
}

@NotNull
@Override
public File getDataFolder() {
return this.dataDirectory.toFile();
}

@Nullable
public MCPlayer getPlayer(@NotNull UUID uuid) {
return playerProvider.getPlayer(uuid);
Expand Down
4 changes: 4 additions & 0 deletions shared/src/main/java/net/codersky/mcutils/MCUtils.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

import java.io.File;
import java.util.HashSet;
import java.util.Objects;
import java.util.Set;
Expand Down Expand Up @@ -43,6 +44,9 @@ public final P getPlugin() {
return plugin;
}

@NotNull
public abstract File getDataFolder();

@Nullable
public abstract MCPlayer getPlayer(@NotNull UUID uuid);

Expand Down

0 comments on commit 0d1eb98

Please sign in to comment.