Cleanup/Implement some todos (#5660)
This commit is contained in:
parent
e868739675
commit
c0aa4c8517
5 changed files with 28 additions and 22 deletions
|
@ -88,16 +88,10 @@ public class WorldWorkerManager
|
|||
{
|
||||
boolean hasWork();
|
||||
|
||||
default void work() {}; //TODO: Remove in 1.13.
|
||||
|
||||
/**
|
||||
* Perform a task, returning true from this will have the manager call this function again this tick if there is time left.
|
||||
* Returning false will skip calling this worker until next tick.
|
||||
*/
|
||||
default boolean doWork()
|
||||
{
|
||||
work();
|
||||
return true;
|
||||
}
|
||||
boolean doWork();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@ import net.minecraft.tileentity.TileEntity;
|
|||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
import net.minecraft.world.World;
|
||||
import net.minecraft.world.dimension.DimensionType;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.registries.ForgeRegistries;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -133,7 +135,7 @@ public class BlockSnapshot
|
|||
World world = this.world != null ? this.world.get() : null;
|
||||
if (world == null)
|
||||
{
|
||||
world = null; // TODO Server static access? FMLCommonHandler.instance().getMinecraftServerInstance().getWorld(getDimId());
|
||||
world = ServerLifecycleHooks.getCurrentServer().getWorld(DimensionType.getById(getDimId()));
|
||||
this.world = new WeakReference<World>(world);
|
||||
}
|
||||
return world;
|
||||
|
|
|
@ -23,6 +23,7 @@ import javax.annotation.Nullable;
|
|||
import java.util.function.Predicate;
|
||||
|
||||
import net.minecraft.resources.IResourceManagerReloadListener;
|
||||
import net.minecraftforge.common.ForgeConfig;
|
||||
|
||||
/**
|
||||
* Handles reload parameters for selective loaders.
|
||||
|
@ -58,7 +59,7 @@ public enum SelectiveReloadStateHandler
|
|||
*/
|
||||
public Predicate<IResourceType> get()
|
||||
{
|
||||
if (this.currentPredicate == null || true) // TODO configs || !ForgeMod.selectiveResourceReloadEnabled)
|
||||
if (this.currentPredicate == null || !ForgeConfig.CLIENT.selectiveResourceReloadEnabled.get())
|
||||
{
|
||||
return ReloadRequirements.all();
|
||||
}
|
||||
|
|
|
@ -19,23 +19,24 @@
|
|||
|
||||
package net.minecraftforge.server.console;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import com.mojang.brigadier.ParseResults;
|
||||
import com.mojang.brigadier.StringReader;
|
||||
import com.mojang.brigadier.suggestion.Suggestion;
|
||||
import com.mojang.brigadier.suggestion.Suggestions;
|
||||
import net.minecraft.command.CommandSource;
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.apache.logging.log4j.LogManager;
|
||||
import org.apache.logging.log4j.Logger;
|
||||
|
||||
import net.minecraft.server.dedicated.DedicatedServer;
|
||||
import org.jline.reader.Candidate;
|
||||
import org.jline.reader.Completer;
|
||||
import org.jline.reader.LineReader;
|
||||
import org.jline.reader.ParsedLine;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.ExecutionException;
|
||||
|
||||
import static com.google.common.base.Preconditions.checkNotNull;
|
||||
|
||||
final class ConsoleCommandCompleter implements Completer
|
||||
{
|
||||
private static final Logger logger = LogManager.getLogger();
|
||||
|
@ -62,12 +63,18 @@ final class ConsoleCommandCompleter implements Completer
|
|||
}
|
||||
|
||||
final String input = buffer;
|
||||
Future<List<String>> tabComplete = new FutureTask<>(() -> Collections.emptyList());// TODO commands this.server.callFromMainThread(() -> this.server.getTabCompletions(this.server, input, this.server.getPosition(), false));
|
||||
//See NetHandlerPlayServer#processTabComplete
|
||||
StringReader stringReader = new StringReader(input);
|
||||
if (stringReader.canRead() && stringReader.peek() == '/')
|
||||
stringReader.skip();
|
||||
|
||||
try
|
||||
{
|
||||
for (String completion : tabComplete.get())
|
||||
ParseResults<CommandSource> results = this.server.callFromMainThread(() -> this.server.getCommandManager().getDispatcher().parse(stringReader, this.server.getCommandSource())).get();
|
||||
Suggestions tabComplete = this.server.getCommandManager().getDispatcher().getCompletionSuggestions(results).get();
|
||||
for (Suggestion suggestion : tabComplete.getList())
|
||||
{
|
||||
String completion = suggestion.getText();
|
||||
if (!completion.isEmpty())
|
||||
{
|
||||
boolean hasPrefix = prefix || completion.charAt(0) != '/';
|
||||
|
|
|
@ -21,6 +21,8 @@ package net.minecraftforge.server.permission;
|
|||
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import net.minecraft.server.MinecraftServer;
|
||||
import net.minecraftforge.fml.server.ServerLifecycleHooks;
|
||||
import net.minecraftforge.fml.server.ServerModLoader;
|
||||
import net.minecraftforge.server.permission.context.IContext;
|
||||
|
||||
import javax.annotation.Nullable;
|
||||
|
@ -71,7 +73,7 @@ public enum DefaultPermissionHandler implements IPermissionHandler
|
|||
return true;
|
||||
}
|
||||
|
||||
MinecraftServer server = null; // TODO FMLCommonHandler FMLCommonHandler.instance().getMinecraftServerInstance();
|
||||
MinecraftServer server = ServerLifecycleHooks.getCurrentServer();
|
||||
return server != null && server.getPlayerList().canSendCommands(profile);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue