-
Notifications
You must be signed in to change notification settings - Fork 8
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
1 parent
05cdc70
commit b4513bb
Showing
5 changed files
with
54 additions
and
37 deletions.
There are no files selected for viewing
29 changes: 2 additions & 27 deletions
29
...in/java/github/kasuminova/stellarcore/client/model/ParallelModelLoaderAsyncBlackList.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 |
---|---|---|
@@ -1,43 +1,18 @@ | ||
package github.kasuminova.stellarcore.client.model; | ||
|
||
import github.kasuminova.stellarcore.client.util.ClassBlackList; | ||
import github.kasuminova.stellarcore.common.config.StellarCoreConfig; | ||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; | ||
|
||
import java.util.Arrays; | ||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public class ParallelModelLoaderAsyncBlackList { | ||
public class ParallelModelLoaderAsyncBlackList extends ClassBlackList { | ||
|
||
public static final ParallelModelLoaderAsyncBlackList INSTANCE = new ParallelModelLoaderAsyncBlackList(); | ||
|
||
private final Set<Class<?>> blackList = new ReferenceOpenHashSet<>(); | ||
|
||
public ParallelModelLoaderAsyncBlackList() { | ||
reload(); | ||
} | ||
|
||
public void reload() { | ||
blackList.clear(); | ||
|
||
Arrays.stream(StellarCoreConfig.PERFORMANCE.vanilla.parallelModelLoaderBlackList) | ||
.forEach(className -> findClass(className).ifPresent(this::add)); | ||
} | ||
|
||
public void add(Class<?> clazz) { | ||
blackList.add(clazz); | ||
} | ||
|
||
public boolean isInBlackList(Class<?> clazz) { | ||
return blackList.contains(clazz); | ||
} | ||
|
||
private static Optional<Class<?>> findClass(String name) { | ||
try { | ||
return Optional.of(Class.forName(name)); | ||
} catch (ClassNotFoundException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
} |
36 changes: 36 additions & 0 deletions
36
src/main/java/github/kasuminova/stellarcore/client/util/ClassBlackList.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,36 @@ | ||
package github.kasuminova.stellarcore.client.util; | ||
|
||
import github.kasuminova.stellarcore.client.model.ParallelModelLoaderAsyncBlackList; | ||
import it.unimi.dsi.fastutil.objects.ReferenceOpenHashSet; | ||
|
||
import java.util.Optional; | ||
import java.util.Set; | ||
|
||
public abstract class ClassBlackList { | ||
|
||
|
||
protected final Set<Class<?>> blackList = new ReferenceOpenHashSet<>(); | ||
|
||
public ClassBlackList() { | ||
reload(); | ||
} | ||
|
||
public abstract void reload(); | ||
|
||
public void add(Class<?> clazz) { | ||
blackList.add(clazz); | ||
} | ||
|
||
public boolean isInBlackList(Class<?> clazz) { | ||
return blackList.contains(clazz); | ||
} | ||
|
||
public static Optional<Class<?>> findClass(String name) { | ||
try { | ||
return Optional.of(Class.forName(name)); | ||
} catch (ClassNotFoundException e) { | ||
return Optional.empty(); | ||
} | ||
} | ||
|
||
} |
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