Skip to content
/ Geyser Public
forked from GeyserMC/Geyser

Commit

Permalink
Move extensions folder to Geyser's config folder (GeyserMC#3202)
Browse files Browse the repository at this point in the history
* Move extensions folder to Geyser's config folder

* Move directory field
  • Loading branch information
Konicai authored Aug 4, 2022
1 parent 684b9c2 commit 67e3bf1
Showing 1 changed file with 4 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,19 +43,18 @@
import java.util.HashMap;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Objects;
import java.util.regex.Pattern;
import java.util.stream.Stream;

@RequiredArgsConstructor
public class GeyserExtensionLoader extends ExtensionLoader {
private static final Path EXTENSION_DIRECTORY = Paths.get("extensions");
private static final Pattern API_VERSION_PATTERN = Pattern.compile("^\\d+\\.\\d+\\.\\d+$");
private static final Pattern[] EXTENSION_FILTERS = new Pattern[] { Pattern.compile("^.+\\.jar$") };

private final Object2ReferenceMap<String, Class<?>> classes = new Object2ReferenceOpenHashMap<>();
private final Map<String, GeyserExtensionClassLoader> classLoaders = new HashMap<>();
private final Map<Extension, GeyserExtensionContainer> extensionContainers = new HashMap<>();
private final Path extensionsDirectory = GeyserImpl.getInstance().getBootstrap().getConfigFolder().resolve("extensions");

public GeyserExtensionContainer loadExtension(Path path, GeyserExtensionDescription description) throws InvalidExtensionException, InvalidDescriptionException {
if (path == null) {
Expand Down Expand Up @@ -127,15 +126,15 @@ void setClass(String name, final Class<?> clazz) {
@Override
protected void loadAllExtensions(@NonNull ExtensionManager extensionManager) {
try {
if (Files.notExists(EXTENSION_DIRECTORY)) {
Files.createDirectory(EXTENSION_DIRECTORY);
if (Files.notExists(extensionsDirectory)) {
Files.createDirectory(extensionsDirectory);
}

Map<String, Path> extensions = new LinkedHashMap<>();
Map<String, GeyserExtensionContainer> loadedExtensions = new LinkedHashMap<>();

Pattern[] extensionFilters = this.extensionFilters();
try (Stream<Path> entries = Files.walk(EXTENSION_DIRECTORY)) {
try (Stream<Path> entries = Files.walk(extensionsDirectory)) {
entries.forEach(path -> {
if (Files.isDirectory(path)) {
return;
Expand Down

0 comments on commit 67e3bf1

Please sign in to comment.