Package net.minecraft.server.function
Class FunctionLoader
java.lang.Object
net.minecraft.server.function.FunctionLoader
- All Implemented Interfaces:
ResourceReloader
public class FunctionLoader extends Object implements ResourceReloader
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.minecraft.resource.ResourceReloader
ResourceReloader.Synchronizer -
Field Summary
Fields Modifier and Type Field Description private com.mojang.brigadier.CommandDispatcher<ServerCommandSource>commandDispatcherprivate Map<Identifier,CommandFunction>functionsprivate intlevelprivate static LoggerLOGGERprivate static intPATH_PREFIX_LENGTHprivate static intPATH_SUFFIX_LENGTHprivate TagGroupLoader<CommandFunction>tagLoaderprivate TagGroup<CommandFunction>tags -
Constructor Summary
Constructors Constructor Description FunctionLoader(int level, com.mojang.brigadier.CommandDispatcher<ServerCommandSource> commandDispatcher) -
Method Summary
Modifier and Type Method Description Optional<CommandFunction>get(Identifier id)Map<Identifier,CommandFunction>getFunctions()Tag<CommandFunction>getOrCreateTag(Identifier id)TagGroup<CommandFunction>getTags()private static List<String>readLines(ResourceManager resourceManager, Identifier id)CompletableFuture<Void>reload(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor)Performs a reload.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.minecraft.resource.ResourceReloader
getName
-
Field Details
-
LOGGER
-
PATH_PREFIX_LENGTH
private static final int PATH_PREFIX_LENGTH -
PATH_SUFFIX_LENGTH
private static final int PATH_SUFFIX_LENGTH -
functions
-
tagLoader
-
tags
-
level
private final int level -
commandDispatcher
-
-
Constructor Details
-
FunctionLoader
public FunctionLoader(int level, com.mojang.brigadier.CommandDispatcher<ServerCommandSource> commandDispatcher)
-
-
Method Details
-
get
-
getFunctions
-
getTags
-
getOrCreateTag
-
reload
public CompletableFuture<Void> reload(ResourceReloader.Synchronizer synchronizer, ResourceManager manager, Profiler prepareProfiler, Profiler applyProfiler, Executor prepareExecutor, Executor applyExecutor)Performs a reload. Returns a future that is completed when the reload is completed.In a reload, there is a prepare stage and an apply stage. For the prepare stage, you should create completable futures with CompletableFuture.supplyAsync(..., prepareExecutor) to ensure the prepare actions are done with the prepare executor. Then, you should have a completable future for all the prepared actions, and call combinedPrepare.thenCompose(synchronizer::waitFor) to notify the
synchronizer. Finally, you should run CompletableFuture.thenAcceptAsync(..., applyExecutor) for apply actions. In the end, returns the result ofthenAcceptAsync.- Specified by:
reloadin interfaceResourceReloader- Parameters:
synchronizer- the synchronizermanager- the resource managerprepareProfiler- the profiler for prepare stageapplyProfiler- the profiler for apply stageprepareExecutor- the executor for prepare stageapplyExecutor- the executor for apply stage- Returns:
- a future for the reload
- See Also:
ReloadableResourceManager.reload(Executor, Executor, CompletableFuture, List)
-
readLines
-