This repository has been archived by the owner on Aug 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
BuildTools
committed
Nov 26, 2023
1 parent
b7d7ff3
commit c301ea4
Showing
33 changed files
with
666 additions
and
142 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
NexEngine/src/main/java/su/nexmedia/engine/api/config/ConfigKey.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
package su.nexmedia.engine.api.config; | ||
|
||
import org.jetbrains.annotations.NotNull; | ||
|
||
public class ConfigKey<T> { | ||
|
||
private final String path; | ||
private final JOption.Writer<T> writer; | ||
private final JOption.Reader<T> reader; | ||
|
||
public ConfigKey(@NotNull String path, JOption.Writer<T> writer, JOption.Reader<T> reader) { | ||
this.path = path; | ||
this.writer = writer; | ||
this.reader = reader; | ||
} | ||
|
||
public static ConfigKey<Integer> asInt(@NotNull String path) { | ||
return new ConfigKey<>(path, JYML::set, JOption.READER_INT); | ||
} | ||
|
||
public T read(@NotNull JYML cfg, @NotNull T defaultValue) { | ||
return this.getReader().read(cfg, this.getPath(), defaultValue); | ||
} | ||
|
||
public void write(@NotNull JYML cfg, @NotNull T obj) { | ||
this.getWriter().write(cfg, this.getPath(), obj); | ||
} | ||
|
||
@NotNull | ||
public String getPath() { | ||
return path; | ||
} | ||
|
||
@NotNull | ||
public JOption.Reader<T> getReader() { | ||
return reader; | ||
} | ||
|
||
@NotNull | ||
public JOption.Writer<T> getWriter() { | ||
return writer; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.