mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-11-07 11:20:11 +01:00
Fixed Customized resource lookup
The method was not looking at the right directory Affects issues: - Fixed #1379
This commit is contained in:
parent
74bec0c25f
commit
8203e85f77
@ -20,12 +20,13 @@ import com.djrapitops.plan.PlanPlugin;
|
|||||||
import com.djrapitops.plan.SubSystem;
|
import com.djrapitops.plan.SubSystem;
|
||||||
import com.djrapitops.plan.exceptions.EnableException;
|
import com.djrapitops.plan.exceptions.EnableException;
|
||||||
import com.djrapitops.plugin.utilities.Verify;
|
import com.djrapitops.plugin.utilities.Verify;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
|
||||||
|
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
import javax.inject.Singleton;
|
import javax.inject.Singleton;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.UncheckedIOException;
|
||||||
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@ -62,9 +63,13 @@ public class PlanFiles implements SubSystem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public File getLogsFolder() {
|
public File getLogsFolder() {
|
||||||
File folder = getFileFromPluginFolder("logs");
|
try {
|
||||||
folder.mkdirs();
|
File folder = getFileFromPluginFolder("logs");
|
||||||
return folder;
|
Files.createDirectories(folder.toPath());
|
||||||
|
return folder;
|
||||||
|
} catch (IOException e) {
|
||||||
|
throw new UncheckedIOException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getConfigFile() {
|
public File getConfigFile() {
|
||||||
@ -118,24 +123,6 @@ public class PlanFiles implements SubSystem {
|
|||||||
return new FileResource(resourceName, getFileFromPluginFolder(resourceName));
|
return new FileResource(resourceName, getFileFromPluginFolder(resourceName));
|
||||||
}
|
}
|
||||||
|
|
||||||
private Optional<File> attemptToFind(String resourceName) {
|
|
||||||
if (dataFolder.exists() && dataFolder.isDirectory()) {
|
|
||||||
|
|
||||||
String[] path = StringUtils.split(resourceName, '/');
|
|
||||||
|
|
||||||
Path toFile = dataFolder.getAbsoluteFile().toPath().toAbsolutePath();
|
|
||||||
for (String next : path) {
|
|
||||||
toFile = toFile.resolve(next);
|
|
||||||
}
|
|
||||||
|
|
||||||
File found = toFile.toFile();
|
|
||||||
if (found.exists()) {
|
|
||||||
return Optional.of(found);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return Optional.empty();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Optional<Resource> getCustomizableResource(String resourceName) {
|
public Optional<Resource> getCustomizableResource(String resourceName) {
|
||||||
return Optional.ofNullable(ResourceCache.getOrCache(resourceName,
|
return Optional.ofNullable(ResourceCache.getOrCache(resourceName,
|
||||||
() -> attemptToFind(resourceName)
|
() -> attemptToFind(resourceName)
|
||||||
@ -143,4 +130,16 @@ public class PlanFiles implements SubSystem {
|
|||||||
.orElse(null)
|
.orElse(null)
|
||||||
));
|
));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Optional<File> attemptToFind(String resourceName) {
|
||||||
|
Path dir = getCustomizationDirectory();
|
||||||
|
if (dir.toFile().exists() && dir.toFile().isDirectory()) {
|
||||||
|
Path asPath = dir.resolve(resourceName);
|
||||||
|
File found = asPath.toFile();
|
||||||
|
if (found.exists()) {
|
||||||
|
return Optional.of(found);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user