Complete removal of /info entity, it's correspondent carpet and two small changes (#1047)
* Remove no longer needed language packet mixin * Make StringArgument properly return a StringArgument supplier, so `string` isn't `term` Fixes gnembon/fabric-carpet#1044 * Complete removal of `/info entity` and it's correspondent carpet Resolves gnembon/fabric-carpet#1033 * Remove yet another no longer needed mixin
This commit is contained in:
1 parent
4d9c5eb391
commit
d8c10c6e4a
9 files changed
+10
-231
No files matched your search
@@ -3,19 +3,14 @@ package carpet.commands;
|
||||
import carpet.CarpetSettings;
|
||||
import carpet.settings.SettingsManager;
|
||||
import carpet.utils.BlockInfo;
|
||||
import carpet.utils.EntityInfo;
|
||||
import carpet.utils.Messenger;
|
||||
import com.mojang.brigadier.CommandDispatcher;
|
||||
import com.mojang.brigadier.builder.LiteralArgumentBuilder;
|
||||
import net.minecraft.text.BaseText;
|
||||
import net.minecraft.server.command.ServerCommandSource;
|
||||
import net.minecraft.command.argument.BlockPosArgumentType;
|
||||
import net.minecraft.command.argument.EntityArgumentType;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.math.BlockPos;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.regex.Matcher;
|
||||
import java.util.regex.Pattern;
|
||||
@@ -41,52 +36,11 @@ public class InfoCommand
|
||||
executes( (c) -> infoBlock(
|
||||
c.getSource(),
|
||||
BlockPosArgumentType.getBlockPos(c, "block position"),
|
||||
getString(c, "regexp"))))))).
|
||||
then(literal("entity").
|
||||
then(argument("entity selector", EntityArgumentType.entities()).
|
||||
executes( (c) -> infoEntities(
|
||||
c.getSource(), EntityArgumentType.getEntities(c,"entity selector"), null)).
|
||||
then(literal("grep").
|
||||
then(argument("regexp",greedyString()).
|
||||
executes( (c) -> infoEntities(
|
||||
c.getSource(),
|
||||
EntityArgumentType.getEntities(c,"entity selector"),
|
||||
getString(c, "regexp")))))));
|
||||
|
||||
dispatcher.register(command);
|
||||
}
|
||||
|
||||
public static void printEntity(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
List<BaseText> actual = new ArrayList<>();
|
||||
if (grep != null)
|
||||
{
|
||||
Pattern p = Pattern.compile(grep);
|
||||
actual.add(messages.get(0));
|
||||
boolean empty = true;
|
||||
for (int i = 1; i<messages.size(); i++)
|
||||
{
|
||||
BaseText line = messages.get(i);
|
||||
Matcher m = p.matcher(line.getString());
|
||||
if (m.find())
|
||||
{
|
||||
empty = false;
|
||||
actual.add(line);
|
||||
}
|
||||
}
|
||||
if (empty)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
actual = messages;
|
||||
}
|
||||
Messenger.m(source, "");
|
||||
Messenger.send(source, actual);
|
||||
}
|
||||
|
||||
public static void printBlock(List<BaseText> messages, ServerCommandSource source, String grep)
|
||||
{
|
||||
Messenger.m(source, "");
|
||||
@@ -110,17 +64,6 @@ public class InfoCommand
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static int infoEntities(ServerCommandSource source, Collection<? extends Entity> entities, String grep)
|
||||
{
|
||||
for (Entity e: entities)
|
||||
{
|
||||
List<BaseText> report = EntityInfo.entityInfo(e, source.getWorld());
|
||||
printEntity(report, source, grep);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
private static int infoBlock(ServerCommandSource source, BlockPos pos, String grep)
|
||||
{
|
||||
printBlock(BlockInfo.blockInfo(pos, source.getWorld()),source, grep);
|
||||
|
||||
Reference in new issue
Block a user