13
0

Commits vergleichen

..

1 Commits

Autor SHA1 Nachricht Datum
Chaoscaot
184e2e7480
Add NoCheck
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
2023-09-27 22:41:58 +02:00
12 geänderte Dateien mit 238 neuen und 250 gelöschten Zeilen

Datei anzeigen

@ -90,6 +90,7 @@ 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) {
@ -99,11 +100,7 @@ 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, new BlockPos(x, y, z)); checkInventory(result, block, material, pos);
}
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));
} }
} }
} }
@ -163,12 +160,18 @@ 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())
.blockScanResult(scan(clipboard)) .blockCounts(blockScanResult.getBlockCounts())
.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

@ -43,15 +43,15 @@ import java.util.stream.Collectors;
public class SchematicCommand15 implements SchematicCommand.ISchematicCommand { public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
@Override @Override
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception { public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) { for (BlockPos blockPos : result.getRecords()) {
BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ()); BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ());
clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap()))); clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap())));
} }
Map<BlockPos, Set<Material>> toBeCheckedInvs = new HashMap<>(); Map<BlockPos, Set<Material>> toBeCheckedInvs = new HashMap<>();
toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenItems()); toBeCheckedInvs.putAll(result.getForbiddenItems());
toBeCheckedInvs.putAll(result.getBlockScanResult().getForbiddenNbt()); toBeCheckedInvs.putAll(result.getForbiddenNbt());
for (Map.Entry<BlockPos, Set<Material>> entry: toBeCheckedInvs.entrySet()) { for (Map.Entry<BlockPos, Set<Material>> entry: toBeCheckedInvs.entrySet()) {
BlockPos pos = entry.getKey(); BlockPos pos = entry.getKey();
@ -77,7 +77,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
} }
if(type.getMaxDispenserItems() > 0 ) { if(type.getMaxDispenserItems() > 0 ) {
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) { for (Map.Entry<BlockPos, Integer> entry : result.getDispenserItems().entrySet()) {
if(entry.getValue() <= type.getMaxDispenserItems()) { if(entry.getValue() <= type.getMaxDispenserItems()) {
continue; continue;
} }

Datei anzeigen

@ -74,17 +74,12 @@ 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, 1, Integer::sum); result.getBlockCounts().merge(Material.getMaterial(blockId), 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));
}
} }
} }
} }
@ -157,7 +152,12 @@ 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())
.blockScanResult(blockScanResult) .blockCounts(blockScanResult.getBlockCounts())
.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

@ -92,6 +92,7 @@ UTIL_TYPE_FIGHT_ALREADY=§cYou have already submitted this schematic
UTIL_TYPE_AFTER_DEADLINE=§cSchematics of this type can no longer be submitted. Deadline was: {0} UTIL_TYPE_AFTER_DEADLINE=§cSchematics of this type can no longer be submitted. Deadline was: {0}
UTIL_TYPE_ERROR=§cThe Schematic is not compliant with the rules UTIL_TYPE_ERROR=§cThe Schematic is not compliant with the rules
UTIL_TYPE_EXTEND=§aThe preparation server is starting UTIL_TYPE_EXTEND=§aThe preparation server is starting
UTIL_TYPE_CANNOT_EXTEND=§cThis schematic type cannot be extended
UTIL_SUBMIT_TITLE=Extend Schematic UTIL_SUBMIT_TITLE=Extend Schematic
UTIL_SUBMIT_REPLAY_ON=§aReplay allowed UTIL_SUBMIT_REPLAY_ON=§aReplay allowed
UTIL_SUBMIT_REPLAY_OFF=§cReplay locked UTIL_SUBMIT_REPLAY_OFF=§cReplay locked
@ -100,6 +101,7 @@ UTIL_SUBMIT_COLOR_OFF=§cDo not replace pink
UTIL_SUBMIT_DIRECT=§eSubmit directly UTIL_SUBMIT_DIRECT=§eSubmit directly
UTIL_SUBMIT_DIRECT_DONE=§aThe Schematic will be reviewed in a timely manner UTIL_SUBMIT_DIRECT_DONE=§aThe Schematic will be reviewed in a timely manner
UTIL_SUBMIT_EXTEND=§eExtend Schematic UTIL_SUBMIT_EXTEND=§eExtend Schematic
UTIL_SUBMIT_EXTEND_NO=§cYou cannot extend this schematic
UTIL_SUBMIT_EXTEND_DONE=§aThe preparation server is starting UTIL_SUBMIT_EXTEND_DONE=§aThe preparation server is starting
UTIL_CHECK_TYPE_NOT_FOUND=§cThe type {0} was not found UTIL_CHECK_TYPE_NOT_FOUND=§cThe type {0} was not found
UTIL_CHECK_SUCCESS=§aThe schematic was checked successfully UTIL_CHECK_SUCCESS=§aThe schematic was checked successfully
@ -255,7 +257,6 @@ 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

@ -79,6 +79,7 @@ UTIL_TYPE_FIGHT_ALREADY=§cDu hast diese Schematic bereits eingesendet
UTIL_TYPE_AFTER_DEADLINE=§cVon diesem Typen können keine Schematics mehr eingesendet werden. Einsendeschluss war: {0} UTIL_TYPE_AFTER_DEADLINE=§cVon diesem Typen können keine Schematics mehr eingesendet werden. Einsendeschluss war: {0}
UTIL_TYPE_ERROR=§cDie Schematic ist nicht regelkonform UTIL_TYPE_ERROR=§cDie Schematic ist nicht regelkonform
UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet UTIL_TYPE_EXTEND=§aDer Vorbereitungsserver wird gestartet
UTIL_TYPE_CANNOT_EXTEND=§cDieser Schematictyp kann nicht ausgefahren werden
UTIL_SUBMIT_TITLE=Schematic ausfahren UTIL_SUBMIT_TITLE=Schematic ausfahren
UTIL_SUBMIT_REPLAY_ON=§aReplay erlaubt UTIL_SUBMIT_REPLAY_ON=§aReplay erlaubt
UTIL_SUBMIT_REPLAY_OFF=§cReplay gesperrt UTIL_SUBMIT_REPLAY_OFF=§cReplay gesperrt
@ -87,6 +88,7 @@ UTIL_SUBMIT_COLOR_OFF=§cPink nicht ersetzen
UTIL_SUBMIT_DIRECT=§eDirekt einsenden UTIL_SUBMIT_DIRECT=§eDirekt einsenden
UTIL_SUBMIT_DIRECT_DONE=§aDie Schematic wird zeitnah überprüft UTIL_SUBMIT_DIRECT_DONE=§aDie Schematic wird zeitnah überprüft
UTIL_SUBMIT_EXTEND=§eSchematic ausfahren UTIL_SUBMIT_EXTEND=§eSchematic ausfahren
UTIL_SUBMIT_EXTEND_NO=§cDiese Schematic kann nicht ausgefahren werden
UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet UTIL_SUBMIT_EXTEND_DONE=§aDer Vorbereitungsserver wird gestartet
COMMAND_INVALID_NODE=§cDie Schematic konnte nicht gefunden werden COMMAND_INVALID_NODE=§cDie Schematic konnte nicht gefunden werden
@ -235,7 +237,6 @@ 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

@ -1,21 +1,21 @@
/* /*
This file is a part of the SteamWar software. This file is a part of the SteamWar software.
Copyright (C) 2020 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify Copyright (C) 2023 SteamWar.de-Serverteam
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful, This program is free software: you can redistribute it and/or modify
but WITHOUT ANY WARRANTY; without even the implied warranty of it under the terms of the GNU Affero General Public License as published by
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the the Free Software Foundation, either version 3 of the License, or
GNU Affero General Public License for more details. (at your option) any later version.
You should have received a copy of the GNU Affero General Public License This program is distributed in the hope that it will be useful,
along with this program. If not, see <https://www.gnu.org/licenses/>. but WITHOUT ANY WARRANTY; without even the implied warranty of
*/ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.schematicsystem; package de.steamwar.schematicsystem;
@ -25,7 +25,6 @@ import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
import java.io.File; import java.io.File;
import java.text.DateFormat;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.time.Instant; import java.time.Instant;
@ -43,11 +42,12 @@ public class CheckSchemType {
private final Map<Set<String>, Integer> limits; private final Map<Set<String>, Integer> limits;
private final int maxBlocks; private final int maxBlocks;
private final Date deadline; private final Date deadline;
private final float maxBlastResistance; private final boolean hasCheckQuestions;
private CheckSchemType(ConfigurationSection section) { private CheckSchemType(ConfigurationSection section) {
hasCheckQuestions = section.isList("CheckQuestions");
String name = section.getString("Schematic.Type"); String name = section.getString("Schematic.Type");
width = section.getInt("Schematic.Size.x"); width = section.getInt("Schematic.Size.x");
height = section.getInt("Schematic.Size.y"); height = section.getInt("Schematic.Size.y");
@ -56,8 +56,6 @@ 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", Double.MAX_VALUE);
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");
@ -91,7 +89,7 @@ public class CheckSchemType {
if(folder.exists()) { if(folder.exists()) {
for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) { for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) {
YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile);
if (!config.isList("CheckQuestions") && config.getBoolean("Schematic.ManualCheck", true)) if (!config.isList("CheckQuestions"))
continue; continue;
new CheckSchemType(config); new CheckSchemType(config);

Datei anzeigen

@ -52,7 +52,6 @@ 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,7 +28,10 @@ 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.*; import java.util.Collection;
import java.util.List;
import java.util.Map;
import java.util.Set;
@Builder @Builder
@Getter @Getter
@ -38,20 +41,23 @@ 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 AutoChecker.BlockScanResult blockScanResult; private final Map<Material, Integer> blockCounts;
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 blockScanResult.getRecords().isEmpty() && return records.isEmpty() &&
blockScanResult.getForbiddenItems().isEmpty() && forbiddenItems.isEmpty() &&
blockScanResult.getForbiddenNbt().isEmpty() && forbiddenNbt.isEmpty() &&
isSizeOk() && isSizeOk() &&
isBlockCountOk() && isBlockCountOk() &&
isLimitedBlocksOK() && isLimitedBlocksOK() &&
isDispenserItemsOK() && isDispenserItemsOK() &&
!type.isAfterDeadline() && !type.isAfterDeadline();
entities.isEmpty() &&
isDesignBlastResistanceOK();
} }
public boolean fastOk() { public boolean fastOk() {
@ -60,11 +66,11 @@ public class AutoCheckerResult {
} }
public boolean isDispenserItemsOK() { public boolean isDispenserItemsOK() {
return blockScanResult.getDispenserItems().values().stream().allMatch(i -> i <= type.getMaxDispenserItems()); return dispenserItems.values().stream().allMatch(i -> i <= type.getMaxDispenserItems());
} }
public boolean hasWarnings() { public boolean hasWarnings() {
return blockScanResult.getDefunctNbt().isEmpty(); return defunctNbt.isEmpty();
} }
public boolean isSizeOk() { public boolean isSizeOk() {
@ -84,46 +90,42 @@ public class AutoCheckerResult {
} }
public boolean isBlockCountOk() { public boolean isBlockCountOk() {
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); 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);
} }
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(blockScanResult.getBlockCounts()::get).map(i -> i == null || i <= setIntegerEntry.getValue()).reduce(Boolean::logicalAnd).orElse(false)) .map(setIntegerEntry -> setIntegerEntry.getKey().stream().map(Material::getMaterial).map(blockCounts::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, blockScanResult.getBlockCounts().values().stream().reduce(Integer::sum).orElse(0), type.getMaxBlocks()); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_BLOCKS", p, blockCounts.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 && blockScanResult.getBlockCounts().getOrDefault(mat, 0) > integer) { if(mat != null && blockCounts.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(), blockScanResult.getBlockCounts().getOrDefault(mat, 0), integer); SchematicSystem.MESSAGE.sendPrefixless("AUTO_CHECKER_RESULT_TOO_MANY_BLOCK", p, mat.name(), blockCounts.getOrDefault(mat, 0), integer);
} }
} }
} }
}); });
} }
blockScanResult.getDispenserItems().entrySet().stream().filter(blockVector3IntegerEntry -> blockVector3IntegerEntry.getValue() > type.getMaxDispenserItems()).forEach(blockVector3IntegerEntry -> { dispenserItems.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(),
@ -131,25 +133,18 @@ public class AutoCheckerResult {
blockVector3IntegerEntry.getValue(), blockVector3IntegerEntry.getValue(),
type.getMaxDispenserItems()); type.getMaxDispenserItems());
}); });
blockScanResult.getRecords().forEach(blockVector3 -> { records.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());
}); });
blockScanResult.getForbiddenItems().forEach((blockVector3, materials) -> { forbiddenItems.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));
}); });
blockScanResult.getForbiddenNbt().forEach((blockVector3, materials) -> { forbiddenNbt.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));
}); });
blockScanResult.getDefunctNbt().forEach(blockVector3 -> { defunctNbt.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

@ -1,149 +1,150 @@
/* /*
This file is a part of the SteamWar software. This file is a part of the SteamWar software.
Copyright (C) 2023 SteamWar.de-Serverteam Copyright (C) 2023 SteamWar.de-Serverteam
This program is free software: you can redistribute it and/or modify This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or the Free Software Foundation, either version 3 of the License, or
(at your option) any later version. (at your option) any later version.
This program is distributed in the hope that it will be useful, This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details. GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>. along with this program. If not, see <https://www.gnu.org/licenses/>.
*/ */
package de.steamwar.schematicsystem.commands.schematiccommand; package de.steamwar.schematicsystem.commands.schematiccommand;
import com.sk89q.worldedit.*; import com.sk89q.worldedit.*;
import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.extent.clipboard.Clipboard;
import de.steamwar.command.*; import de.steamwar.command.*;
import de.steamwar.core.VersionDependent; import de.steamwar.core.VersionDependent;
import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.CheckSchemType;
import de.steamwar.schematicsystem.SchematicSystem; import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult; import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
import de.steamwar.sql.*; import de.steamwar.sql.*;
import org.bukkit.command.CommandSender; import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*;
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*; import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandHelp.*;
import static de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils.*;
@SuppressWarnings("unused")
public class SchematicCommand extends SWCommand { @SuppressWarnings("unused")
public class SchematicCommand extends SWCommand {
public SchematicCommand() {
super("schematic", new String[] {"schem", "/schem", "/schematic"}); public SchematicCommand() {
} super("schematic", Bukkit.getPluginManager().getPlugin("Teamserver") == null ? new String[] {"schem", "/schem", "/schematic"} : new String[]{"schem"});
}
@Register("help")
public void pagedHelp(Player player, HelpPage page) { @Register("help")
printHelpPage(player, page); public void pagedHelp(Player player, HelpPage page) {
} printHelpPage(player, page);
}
@Register
public void genericHelp(Player player, String... args) { @Register
printHelpMainPage(player); public void genericHelp(Player player, String... args) {
} printHelpMainPage(player);
}
@Register(value = "togglepublic", noTabComplete = true)
public void togglePublicMode(Player player) { @Register(value = "togglepublic", noTabComplete = true)
SteamwarUser user = SteamwarUser.get(player.getUniqueId()); public void togglePublicMode(Player player) {
if (!user.hasPerm(UserPerm.MODERATION)) { SteamwarUser user = SteamwarUser.get(player.getUniqueId());
genericHelp(player); if (!user.hasPerm(UserPerm.MODERATION)) {
return; genericHelp(player);
} return;
}
if (togglePublic(player)) {
SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_ON", player); if (togglePublic(player)) {
} else { SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_ON", player);
SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_OFF", player); } else {
} SchematicSystem.MESSAGE.send("COMMAND_PUBLIC_OFF", player);
} }
}
@Mapper("publicMapper")
public TypeMapper<SchematicNode> publicNodeTypeMapper() { @Mapper("publicMapper")
return SchematicMapper.publicNodeTypeMapper(); public TypeMapper<SchematicNode> publicNodeTypeMapper() {
} return SchematicMapper.publicNodeTypeMapper();
}
@Mapper("memberMapper")
public static TypeMapper<NodeMember> nodeMemberTypeMapper() { @Mapper("memberMapper")
return SchematicMapper.nodeMemberTypeMapper(); public static TypeMapper<NodeMember> nodeMemberTypeMapper() {
} return SchematicMapper.nodeMemberTypeMapper();
}
@Mapper("dirMapper")
public static TypeMapper<SchematicNode> dirNodeTypeMapper() { @Mapper("dirMapper")
return SchematicMapper.dirNodeTypeMapper(); public static TypeMapper<SchematicNode> dirNodeTypeMapper() {
} return SchematicMapper.dirNodeTypeMapper();
}
@Mapper("publicDirMapper")
public static TypeMapper<SchematicNode> publicDirNodeTypeMapper() { @Mapper("publicDirMapper")
return SchematicMapper.publicDirNodeTypeMapper(); public static TypeMapper<SchematicNode> publicDirNodeTypeMapper() {
} return SchematicMapper.publicDirNodeTypeMapper();
}
@Mapper("dirStringMapper")
public static TypeMapper<String> stringTabMapper() { @Mapper("dirStringMapper")
return SchematicMapper.stringTabMapper(); public static TypeMapper<String> stringTabMapper() {
} return SchematicMapper.stringTabMapper();
}
@Mapper("stringMapper")
public static TypeMapper<String> stringMapper() { @Mapper("stringMapper")
return SchematicMapper.stringMapper(); public static TypeMapper<String> stringMapper() {
} return SchematicMapper.stringMapper();
}
@ClassMapper(SchematicType.class)
public static TypeMapper<SchematicType> typeTypeMapper() { @ClassMapper(SchematicType.class)
return SchematicMapper.typeTypeMapper(); public static TypeMapper<SchematicType> typeTypeMapper() {
} return SchematicMapper.typeTypeMapper();
}
@AbstractSWCommand.ClassMapper(value = SchematicNode.class, local = true)
public static TypeMapper<SchematicNode> nodeTypeMapper() { @AbstractSWCommand.ClassMapper(value = SchematicNode.class, local = true)
return SchematicMapper.nodeTypeMapper(); public static TypeMapper<SchematicNode> nodeTypeMapper() {
} return SchematicMapper.nodeTypeMapper();
}
@ClassMapper(value = CheckSchemType.class, local = true)
public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() { @ClassMapper(value = CheckSchemType.class, local = true)
return SchematicMapper.checkSchemTypeTypeMapper(); public static TypeMapper<CheckSchemType> checkSchemTypeTypeMapper() {
} return SchematicMapper.checkSchemTypeTypeMapper();
}
@Override
protected void sendMessage(CommandSender sender, String message, Object[] args) { @Override
SchematicSystem.MESSAGE.send(message, sender, args); protected void sendMessage(CommandSender sender, String message, Object[] args) {
} SchematicSystem.MESSAGE.send(message, sender, args);
}
@Validator(value = "isSchemValidator", local = true)
public static TypeValidator<SchematicNode> isSchemValidator() { @Validator(value = "isSchemValidator", local = true)
return SchematicValidator.isSchemValidator(); public static TypeValidator<SchematicNode> isSchemValidator() {
} return SchematicValidator.isSchemValidator();
}
@Validator(value = "isDirValidator", local = true)
public static TypeValidator<SchematicNode> isDirValidator() { @Validator(value = "isDirValidator", local = true)
return SchematicValidator.isDirValidator(); public static TypeValidator<SchematicNode> isDirValidator() {
} return SchematicValidator.isDirValidator();
}
@Validator(value = "isOwnerValidator", local = true)
public static TypeValidator<SchematicNode> isOwnerValidator() { @Validator(value = "isOwnerValidator", local = true)
return SchematicValidator.isOwnerValidator(); public static TypeValidator<SchematicNode> isOwnerValidator() {
} return SchematicValidator.isOwnerValidator();
}
@Validator(value = "isOwnerSchematicValidator", local = true)
public static TypeValidator<SchematicNode> isOwnerSchematicValidator() { @Validator(value = "isOwnerSchematicValidator", local = true)
return SchematicValidator.isOwnerSchematicValidator(); public static TypeValidator<SchematicNode> isOwnerSchematicValidator() {
} return SchematicValidator.isOwnerSchematicValidator();
}
public enum Extend {
AUSFAHREN, public enum Extend {
NORMAL AUSFAHREN,
} NORMAL
}
public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
public static final ISchematicCommand impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
public interface ISchematicCommand {
Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception; public interface ISchematicCommand {
void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException; Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception;
} void createCopy(EditSession editSession, Clipboard clipboard) throws WorldEditException;
} }
}

Datei anzeigen

@ -458,6 +458,11 @@ public class SchematicCommandUtils {
if (extend == null) { if (extend == null) {
submitSchemGUI(player, node, type); submitSchemGUI(player, node, type);
} else if (extend == SchematicCommand.Extend.AUSFAHREN) { } else if (extend == SchematicCommand.Extend.AUSFAHREN) {
if (checkSchemType.isHasCheckQuestions()) {
SchematicSystem.MESSAGE.send("UTIL_TYPE_CANNOT_EXTEND", player);
return;
}
NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB())); NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB()));
SchematicSystem.MESSAGE.send("UTIL_TYPE_EXTEND", player); SchematicSystem.MESSAGE.send("UTIL_TYPE_EXTEND", player);
} }
@ -479,11 +484,15 @@ public class SchematicCommandUtils {
SchematicSystem.MESSAGE.send("UTIL_SUBMIT_DIRECT_DONE", player); SchematicSystem.MESSAGE.send("UTIL_SUBMIT_DIRECT_DONE", player);
player.closeInventory(); player.closeInventory();
}); });
inv.setItem(8, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_EXTEND", player), click -> { if (CheckSchemType.get(type).isHasCheckQuestions()) {
NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB())); inv.setItem(8, SWItem.getDye(8), (byte) 8, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_EXTEND_NO", player), clickType -> {});
SchematicSystem.MESSAGE.send("UTIL_SUBMIT_EXTEND_DONE", player); } else {
player.closeInventory(); inv.setItem(8, SWItem.getDye(10), (byte) 10, SchematicSystem.MESSAGE.parse("UTIL_SUBMIT_EXTEND", player), click -> {
}); NetworkSender.send(new PrepareSchemPacket(SteamwarUser.get(player.getUniqueId()).getId(), node.getId(), type.toDB()));
SchematicSystem.MESSAGE.send("UTIL_SUBMIT_EXTEND_DONE", player);
player.closeInventory();
});
}
inv.setCallback(-999, click -> player.closeInventory()); inv.setCallback(-999, click -> player.closeInventory());
inv.open(); inv.open();
} }

Datei anzeigen

@ -116,7 +116,7 @@ public class MemberPart extends SWCommand {
public void addTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) { public void addTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if (team == null || team.getTeamId() == 0) { if (team == null) {
SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_IN_TEAM", player); SchematicSystem.MESSAGE.send("COMMAND_ADD_TEAM_NOT_IN_TEAM", player);
return; return;
} }
@ -128,7 +128,7 @@ public class MemberPart extends SWCommand {
public void remTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) { public void remTeam(Player player, @Validator("isOwnerValidator") SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
Team team = Team.get(user.getTeam()); Team team = Team.get(user.getTeam());
if (team == null || team.getTeamId() == 0) { if (team == null) {
SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_IN_TEAM", player); SchematicSystem.MESSAGE.send("COMMAND_DEL_TEAM_NOT_IN_TEAM", player);
return; return;
} }

Datei anzeigen

@ -31,7 +31,6 @@ 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;
@ -51,7 +50,6 @@ 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)));
@ -61,13 +59,6 @@ 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);
@ -75,20 +66,12 @@ 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)) {
if (searchMapper.get(current) == null) { if (searchMapper.get(current) == null) {
switch (current) { if (current.equals("-public")) {
case "-public": userId = 0;
userId = 0;
break;
case "-ignoreCase":
isIgnoreCase.set(true);
break;
default:
throw new IllegalStateException("Unexpected value: " + current);
} }
} else if (i + 1 < query.length) { } else if (i + 1 < query.length) {
int finalI = i; int finalI = i;
@ -121,13 +104,11 @@ public class SearchPart extends SWCommand {
} }
predicates.add(node -> node.getOwner() != steamwarUser1.getId()); predicates.add(node -> node.getOwner() != steamwarUser1.getId());
break; break;
default:
throw new IllegalStateException("Unexpected value: " + current);
} }
i++; i++;
} }
} else { } else {
predicates.add(node -> containsCheckCase(node.getName(), current, isIgnoreCase)); predicates.add(node -> node.getName().contains(current));
nameList.add(current); nameList.add(current);
} }
i++; i++;