13
0

Add Search Ignore Case and AutoChecker outside Materials
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
Chaoscaot 2024-05-17 13:49:43 +02:00
Ursprung 1eeb45a293
Commit ec17a6b2d0
8 geänderte Dateien mit 67 neuen und 67 gelöschten Zeilen

Datei anzeigen

@ -90,7 +90,6 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ for(int x = min.getBlockX(); x <= max.getBlockX(); x++){
for(int y = min.getBlockY(); y <= max.getBlockY(); y++) { for(int y = min.getBlockY(); y <= max.getBlockY(); y++) {
for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) {
final BlockPos pos = new BlockPos(x, y, z);
final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z)); final BaseBlock block = clipboard.getFullBlock(BlockVector3.at(x, y, z));
final Material material = Material.matchMaterial(block.getBlockType().getId()); final Material material = Material.matchMaterial(block.getBlockType().getId());
if(material == null) { if(material == null) {
@ -100,7 +99,11 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
result.getBlockCounts().merge(material, 1, Integer::sum); result.getBlockCounts().merge(material, 1, Integer::sum);
if(INVENTORY.contains(material)) { if(INVENTORY.contains(material)) {
checkInventory(result, block, material, pos); checkInventory(result, block, material, new BlockPos(x, y, z));
}
if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) {
result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z));
} }
} }
} }
@ -160,18 +163,12 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
@Override @Override
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) { public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
AutoChecker.BlockScanResult blockScanResult = scan(clipboard);
return AutoCheckerResult.builder() return AutoCheckerResult.builder()
.type(type) .type(type)
.height(clipboard.getDimensions().getBlockY()) .height(clipboard.getDimensions().getBlockY())
.width(clipboard.getDimensions().getBlockX()) .width(clipboard.getDimensions().getBlockX())
.depth(clipboard.getDimensions().getBlockZ()) .depth(clipboard.getDimensions().getBlockZ())
.blockCounts(blockScanResult.getBlockCounts()) .blockScanResult(scan(clipboard))
.defunctNbt(blockScanResult.getDefunctNbt())
.dispenserItems(blockScanResult.getDispenserItems())
.records(blockScanResult.getRecords())
.forbiddenItems(blockScanResult.getForbiddenItems())
.forbiddenNbt(blockScanResult.getForbiddenNbt())
.entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList()))
.build(); .build();
} }

Datei anzeigen

@ -74,12 +74,17 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker {
for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){ for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){
final BaseBlock block = clipboard.getBlock(new Vector(x, y, z)); final BaseBlock block = clipboard.getBlock(new Vector(x, y, z));
final int blockId = block.getId(); final int blockId = block.getId();
final Material material = Material.getMaterial(blockId);
result.getBlockCounts().merge(Material.getMaterial(blockId), 1, Integer::sum); result.getBlockCounts().merge(material, 1, Integer::sum);
if(INVENTORY.contains(blockId)){ if(INVENTORY.contains(blockId)){
checkInventory(result, block, blockId, new BlockPos(x, y, z)); checkInventory(result, block, blockId, new BlockPos(x, y, z));
} }
if(x == 0 || x == max.getBlockX() - 1 || y == max.getBlockY() - 1 || z == 0 || z == max.getBlockZ() - 1) {
result.getDesignBlocks().computeIfAbsent(material, m -> new ArrayList<>()).add(new BlockPos(x, y, z));
}
} }
} }
} }
@ -152,12 +157,7 @@ public class AutoChecker8 implements AutoChecker.IAutoChecker {
.height(clipboard.getDimensions().getBlockY()) .height(clipboard.getDimensions().getBlockY())
.width(clipboard.getDimensions().getBlockX()) .width(clipboard.getDimensions().getBlockX())
.depth(clipboard.getDimensions().getBlockZ()) .depth(clipboard.getDimensions().getBlockZ())
.blockCounts(blockScanResult.getBlockCounts()) .blockScanResult(blockScanResult)
.defunctNbt(blockScanResult.getDefunctNbt())
.dispenserItems(blockScanResult.getDispenserItems())
.records(blockScanResult.getRecords())
.forbiddenItems(blockScanResult.getForbiddenItems())
.forbiddenNbt(blockScanResult.getForbiddenNbt())
.entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList())) .entities(clipboard.getEntities().stream().map(Entity::getLocation).map(blockVector3 -> new BlockPos(blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ())).collect(Collectors.toList()))
.build(); .build();
} }

Datei anzeigen

@ -255,6 +255,7 @@ AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2}
AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Forbidden block: §c{0} AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Forbidden block: §c{0}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Forbidden Item: [{0}, {1}, {2}] -> §c{3} AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Forbidden Item: [{0}, {1}, {2}] -> §c{3}
AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Defunct NBT: §7[{0}, {1}, {2}] AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Defunct NBT: §7[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} in Design: [{1}, {2}, {3}]
AUTO_CHECKER_RESULT_ENTITY=§7Entity: §7[{0}, {1}, {2}] AUTO_CHECKER_RESULT_ENTITY=§7Entity: §7[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_RECORD=§7Record: §c[{0}, {1}, {2}] AUTO_CHECKER_RESULT_RECORD=§7Record: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4} AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7items, Max: §e{4}

Datei anzeigen

@ -235,6 +235,7 @@ AUTO_CHECKER_RESULT_TOO_MANY_BLOCK=§7{0}: §c{1}§7, Max: §e{2}
AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Verbotener Block: §c{0} AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK=§7Verbotener Block: §c{0}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Verbotener gegenstand: [{0}, {1}, {2}] -> §c{3} AUTO_CHECKER_RESULT_FORBIDDEN_ITEM=§7Verbotener gegenstand: [{0}, {1}, {2}] -> §c{3}
AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Keine NBT-Daten: §c[{0}, {1}, {2}] AUTO_CHECKER_RESULT_DEFUNCT_NBT=§7Keine NBT-Daten: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_DESIGN_BLOCK=§7{0} im Design: [{1}, {2}, {3}]
AUTO_CHECKER_RESULT_RECORD=§7Schallplatte: §c[{0}, {1}, {2}] AUTO_CHECKER_RESULT_RECORD=§7Schallplatte: §c[{0}, {1}, {2}]
AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7gegenstände, Max: §e{4} AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS=§7Dispenser: §c[{0}, {1}, {2}]§7, §c{3} §7gegenstände, Max: §e{4}
AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Verbotene NBT-Daten: [{0}, {1}, {2}] -> §c{3} AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT=§7Verbotene NBT-Daten: [{0}, {1}, {2}] -> §c{3}

Datei anzeigen

@ -20,6 +20,7 @@
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
import de.steamwar.sql.SchematicType; import de.steamwar.sql.SchematicType;
import lombok.Getter;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@ -30,6 +31,7 @@ import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
import java.util.*; import java.util.*;
@Getter
public class CheckSchemType { public class CheckSchemType {
private static final Map<SchematicType, CheckSchemType> types = new HashMap<>(); private static final Map<SchematicType, CheckSchemType> types = new HashMap<>();
@ -43,6 +45,7 @@ public class CheckSchemType {
private final int maxBlocks; private final int maxBlocks;
private final Date deadline; private final Date deadline;
private final float maxBlastResistance;
private CheckSchemType(ConfigurationSection section) { private CheckSchemType(ConfigurationSection section) {
String name = section.getString("Schematic.Type"); String name = section.getString("Schematic.Type");
@ -53,6 +56,8 @@ public class CheckSchemType {
maxDispenserItems = section.getInt("Schematic.MaxDispenserItems", 128); maxDispenserItems = section.getInt("Schematic.MaxDispenserItems", 128);
maxBlocks = section.getInt("Schematic.MaxBlocks", 0); maxBlocks = section.getInt("Schematic.MaxBlocks", 0);
maxBlastResistance = (float) section.getDouble("Schematic.MaxDesignBlastResistance", 0.0);
limits = new HashMap<>(); limits = new HashMap<>();
for(Map<?, ?> entry : section.getMapList("Schematic.Limited")) { for(Map<?, ?> entry : section.getMapList("Schematic.Limited")) {
int amount = (Integer) entry.get("Amount"); int amount = (Integer) entry.get("Amount");
@ -98,26 +103,6 @@ public class CheckSchemType {
return types.get(type); return types.get(type);
} }
public int getWidth() {
return width;
}
public int getHeight() {
return height;
}
public int getDepth() {
return depth;
}
public int getMaxDispenserItems() {
return maxDispenserItems;
}
public int getMaxBlocks(){
return maxBlocks;
}
public Map<Set<String>, Integer> getLimits() { public Map<Set<String>, Integer> getLimits() {
return new HashMap<>(limits); return new HashMap<>(limits);
} }
@ -125,8 +110,4 @@ public class CheckSchemType {
public boolean isAfterDeadline() { public boolean isAfterDeadline() {
return deadline != null && deadline.before(Date.from(Instant.now())); return deadline != null && deadline.before(Date.from(Instant.now()));
} }
public Date getDeadline() {
return deadline;
}
} }

Datei anzeigen

@ -52,6 +52,7 @@ public class AutoChecker {
private final Map<Material, Integer> blockCounts = new EnumMap<>(Material.class); private final Map<Material, Integer> blockCounts = new EnumMap<>(Material.class);
private final List<BlockPos> defunctNbt = new ArrayList<>(); private final List<BlockPos> defunctNbt = new ArrayList<>();
private final List<BlockPos> records = new ArrayList<>(); private final List<BlockPos> records = new ArrayList<>();
private final Map<Material, List<BlockPos>> designBlocks = new EnumMap<>(Material.class);
private final Map<BlockPos, Integer> dispenserItems = new HashMap<>(); private final Map<BlockPos, Integer> dispenserItems = new HashMap<>();
private final Map<BlockPos, Set<Material>> forbiddenItems = new HashMap<>(); private final Map<BlockPos, Set<Material>> forbiddenItems = new HashMap<>();
private final Map<BlockPos, Set<Material>> forbiddenNbt = new HashMap<>(); private final Map<BlockPos, Set<Material>> forbiddenNbt = new HashMap<>();

Datei anzeigen

@ -28,10 +28,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Collection; import java.util.*;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Builder @Builder
@Getter @Getter
@ -41,24 +38,20 @@ public class AutoCheckerResult {
private final int width; private final int width;
private final int height; private final int height;
private final int depth; private final int depth;
private final Map<Material, Integer> blockCounts; private final AutoChecker.BlockScanResult blockScanResult;
private final List<BlockPos> defunctNbt;
private final Map<BlockPos, Integer> dispenserItems;
private final List<BlockPos> records;
private final Map<BlockPos, Set<Material>> forbiddenItems;
private final Map<BlockPos, Set<Material>> forbiddenNbt;
private final List<BlockPos> entities; private final List<BlockPos> entities;
public boolean isOk() { public boolean isOk() {
return records.isEmpty() && return blockScanResult.getRecords().isEmpty() &&
forbiddenItems.isEmpty() && blockScanResult.getForbiddenItems().isEmpty() &&
forbiddenNbt.isEmpty() && blockScanResult.getForbiddenNbt().isEmpty() &&
isSizeOk() && isSizeOk() &&
isBlockCountOk() && isBlockCountOk() &&
isLimitedBlocksOK() && isLimitedBlocksOK() &&
isDispenserItemsOK() && isDispenserItemsOK() &&
!type.isAfterDeadline() && !type.isAfterDeadline() &&
entities.isEmpty(); entities.isEmpty() &&
isDesignBlastResistanceOK();
} }
public boolean fastOk() { public boolean fastOk() {
@ -67,11 +60,11 @@ public class AutoCheckerResult {
} }
public boolean isDispenserItemsOK() { public boolean isDispenserItemsOK() {
return dispenserItems.values().stream().allMatch(i -> i <= type.getMaxDispenserItems()); return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.getMaxDispenserItems());
} }
public boolean hasWarnings() { public boolean hasWarnings() {
return defunctNbt.isEmpty(); return blockScanResult.getDefunctNbt().isEmpty();
} }
public boolean isSizeOk() { public boolean isSizeOk() {
@ -91,42 +84,46 @@ public class AutoCheckerResult {
} }
public boolean isBlockCountOk() { public boolean isBlockCountOk() {
return type.getMaxBlocks() == 0 || blockCounts.entrySet().stream().filter(entry -> entry.getKey() != Material.AIR).map(Map.Entry::getValue).reduce(Integer::sum).map(i -> i <= type.getMaxBlocks()).orElse(false); return type.getMaxBlocks() == 0 || blockScanResult.getBlockCounts().entrySet().stream().filter(entry -> entry.getKey() != Material.AIR).map(Map.Entry::getValue).reduce(Integer::sum).map(i -> i <= type.getMaxBlocks()).orElse(false);
} }
public boolean isLimitedBlocksOK() { public boolean isLimitedBlocksOK() {
try { try {
return type.getLimits().entrySet().stream() return type.getLimits().entrySet().stream()
.map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(Material::getMaterial).map(blockCounts::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false)) .map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(Material::getMaterial).map(blockScanResult.getBlockCounts()::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false))
.reduce(Boolean::logicalAnd).orElse(true); .reduce(Boolean::logicalAnd).orElse(true);
} catch (NullPointerException e) { } catch (NullPointerException e) {
return false; return false;
} }
} }
public boolean isDesignBlastResistanceOK() {
return blockScanResult.getDesignBlocks().keySet().stream().map(Material::getBlastResistance).noneMatch(i -> i > type.getMaxBlastResistance());
}
public void sendErrorMessage(Player p, String schemName) { public void sendErrorMessage(Player p, String schemName) {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEADER", p, schemName);
if(isTooWide()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.getWidth()); if(isTooWide()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_WIDTH", p, width, type.getWidth());
if(isTooHigh()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.getHeight()); if(isTooHigh()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_HEIGHT", p, height, type.getHeight());
if(isTooDeep()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.getDepth()); if(isTooDeep()) SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_LENGTH", p, depth, type.getDepth());
if(type.getMaxBlocks() != 0 && !isBlockCountOk()) { if(type.getMaxBlocks() != 0 && !isBlockCountOk()) {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockCounts.values().stream().reduce(Integer::sum).orElse(0), type.getMaxBlocks()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.getMaxBlocks());
} }
if(!isLimitedBlocksOK()) { if(!isLimitedBlocksOK()) {
type.getLimits().forEach((strings, integer) -> { type.getLimits().forEach((strings, integer) -> {
for (String string : strings) { for (String string : strings) {
Material mat = Material.matchMaterial(string); Material mat = Material.matchMaterial(string);
if(mat != null && blockCounts.getOrDefault(mat, 0) > integer) { if(mat != null && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) {
if(integer == 0) { if(integer == 0) {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_BLOCK", p, mat.name());
} else { } else {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), blockCounts.getOrDefault(mat, 0), integer); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), blockScanResult.getBlockCounts().getOrDefault(mat, 0), integer);
} }
} }
} }
}); });
} }
dispenserItems.entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.getMaxDispenserItems()).forEach(blockVector3IntegerEntry -> { blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.getMaxDispenserItems()).forEach(blockVector3IntegerEntry -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()), SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_DISPENSER_ITEMS", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3IntegerEntry.getKey()),
blockVector3IntegerEntry.getKey().getBlockX(), blockVector3IntegerEntry.getKey().getBlockX(),
blockVector3IntegerEntry.getKey().getBlockY(), blockVector3IntegerEntry.getKey().getBlockY(),
@ -134,18 +131,25 @@ public class AutoCheckerResult {
blockVector3IntegerEntry.getValue(), blockVector3IntegerEntry.getValue(),
type.getMaxDispenserItems()); type.getMaxDispenserItems());
}); });
records.forEach(blockVector3 -> { blockScanResult.getRecords().forEach(blockVector3 -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_RECORD", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getBlockX(), blockVector3.getBlockY(), blockVector3.getBlockZ());
}); });
forbiddenItems.forEach((blockVector3, materials) -> { blockScanResult.getForbiddenItems().forEach((blockVector3, materials) -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials)); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials));
}); });
forbiddenNbt.forEach((blockVector3, materials) -> { blockScanResult.getForbiddenNbt().forEach((blockVector3, materials) -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials)); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_FORBIDDEN_ITEM_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ(), setToString(materials));
}); });
defunctNbt.forEach(blockVector3 -> { blockScanResult.getDefunctNbt().forEach(blockVector3 -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DEFUNCT_NBT", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockVector3), blockVector3.getX(), blockVector3.getY(), blockVector3.getZ());
}); });
blockScanResult.getDesignBlocks().forEach((material, poss) -> {
if(material.getBlastResistance() > type.getMaxBlastResistance()) {
poss.forEach(pos -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_DESIGN_BLOCK", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(pos), material.name(), pos.getBlockX(), pos.getBlockY(), pos.getBlockZ());
});
}
});
entities.forEach(blockPos -> { entities.forEach(blockPos -> {
SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_ENTITY", p, SchematicSystem.MESSAGE.parse("AUTO_CHECKER_RESULT_TELEPORT_HERE", p), tpCommandTo(blockPos), blockPos.getX(), blockPos.getY(), blockPos.getZ());
}); });

Datei anzeigen

@ -31,6 +31,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.*; import java.util.*;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.function.Function; import java.util.function.Function;
import java.util.function.Predicate; import java.util.function.Predicate;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -50,6 +51,7 @@ public class SearchPart extends SWCommand {
Class<?> clazz = Material.class; Class<?> clazz = Material.class;
searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz)); searchMapper.put("-item", SWCommandUtils.createEnumMapper((Class<Enum<?>>) clazz));
searchMapper.put("-public", null); searchMapper.put("-public", null);
searchMapper.put("-ignoreCase", null);
searchMapper.put("-exclude", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s))); searchMapper.put("-exclude", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
searchMapper.put("-excludeType", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new))); searchMapper.put("-excludeType", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
searchMapper.put("-excludeOwner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s))); searchMapper.put("-excludeOwner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
@ -59,6 +61,13 @@ public class SearchPart extends SWCommand {
super(null); super(null);
} }
public boolean containsCheckCase(String s, String s2, AtomicBoolean isIgnoreCase) {
if (isIgnoreCase.get()) {
return s.toLowerCase().contains(s2.toLowerCase());
}
return s.contains(s2);
}
@Register("search") @Register("search")
public void schemSearch(Player player, @OptionalValue("1") int page, @Mapper("searchMapper") String... query) { public void schemSearch(Player player, @OptionalValue("1") int page, @Mapper("searchMapper") String... query) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
@ -66,6 +75,7 @@ public class SearchPart extends SWCommand {
List<Predicate<SchematicNode>> predicates = new ArrayList<>(); List<Predicate<SchematicNode>> predicates = new ArrayList<>();
List<String> nameList = new ArrayList<>(); List<String> nameList = new ArrayList<>();
int i = 0; int i = 0;
AtomicBoolean isIgnoreCase = new AtomicBoolean(false);
while (i < query.length) { while (i < query.length) {
String current = query[i]; String current = query[i];
if (searchMapper.containsKey(current)) { if (searchMapper.containsKey(current)) {
@ -104,11 +114,16 @@ public class SearchPart extends SWCommand {
} }
predicates.add(node -> node.getOwner() != steamwarUser1.getId()); predicates.add(node -> node.getOwner() != steamwarUser1.getId());
break; break;
case "-ignoreCase":
isIgnoreCase.set(true);
break;
default:
throw new IllegalStateException("Unexpected value: " + current);
} }
i++; i++;
} }
} else { } else {
predicates.add(node -> node.getName().contains(current)); predicates.add(node -> containsCheckCase(node.getName(), current, isIgnoreCase));
nameList.add(current); nameList.add(current);
} }
i++; i++;