Skip to content

Commit

Permalink
Updated configuration path type
Browse files Browse the repository at this point in the history
- Updated ImageRenderer class
- Updated CsvConfiguration class
- Updated YamipaPlugin class
  • Loading branch information
josemmo committed Dec 29, 2023
1 parent d25fcb3 commit 0d8dbaf
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/main/java/io/josemmo/bukkit/plugin/YamipaPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public void onEnable() {
boolean animateImages = getConfig().getBoolean("animate-images", true);
FakeImage.configure(animateImages);
LOGGER.info(animateImages ? "Enabled image animation support" : "Image animation support is disabled");
renderer = new ImageRenderer(basePath.resolve(dataPath).toString());
renderer = new ImageRenderer(basePath.resolve(dataPath));
renderer.start();

// Create image item service
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
import org.jetbrains.annotations.Nullable;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ConcurrentMap;
Expand All @@ -28,7 +28,7 @@
public class ImageRenderer implements Listener {
private static final long SAVE_INTERVAL = 20L * 90; // In server ticks
private static final Logger LOGGER = Logger.getLogger("ImageRenderer");
private final String configPath;
private final Path configPath;
private BukkitTask saveTask;
private final AtomicBoolean hasConfigChanged = new AtomicBoolean(false);
private final ConcurrentMap<WorldAreaId, Set<FakeImage>> images = new ConcurrentHashMap<>();
Expand All @@ -39,7 +39,7 @@ public class ImageRenderer implements Listener {
* Class constructor
* @param configPath Path to configuration file
*/
public ImageRenderer(@NotNull String configPath) {
public ImageRenderer(@NotNull Path configPath) {
this.configPath = configPath;
}

Expand Down Expand Up @@ -82,7 +82,7 @@ public void stop() {
* Load configuration from disk
*/
private void loadConfig() {
if (!Files.isRegularFile(Paths.get(configPath))) {
if (!Files.isRegularFile(configPath)) {
LOGGER.info("No placed fake images configuration file found");
return;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import java.nio.charset.Charset;
import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.stream.Stream;
Expand Down Expand Up @@ -42,8 +42,8 @@ public void addRow(@NotNull String[] row) {
* @param path File path
* @throws IOException if failed to read file
*/
public void load(@NotNull String path) throws IOException {
try (Stream<String> stream = Files.lines(Paths.get(path), CHARSET)) {
public void load(@NotNull Path path) throws IOException {
try (Stream<String> stream = Files.lines(path, CHARSET)) {
stream.forEach(line -> {
line = line.trim();

Expand All @@ -68,8 +68,8 @@ public void load(@NotNull String path) throws IOException {
* @param path File path
* @throws IOException if failed to write file
*/
public void save(@NotNull String path) throws IOException {
try (OutputStreamWriter writer = new OutputStreamWriter(Files.newOutputStream(Paths.get(path)), CHARSET)) {
public void save(@NotNull Path path) throws IOException {
try (OutputStreamWriter writer = new OutputStreamWriter(Files.newOutputStream(path), CHARSET)) {
for (String[] row : getRows()) {
writer.write(String.join(COLUMN_DELIMITER, row) + "\n");
}
Expand Down

0 comments on commit 0d8dbaf

Please sign in to comment.