WIP: Add SchemSearch #146
@ -162,6 +162,14 @@ COMMAND_FIX_MANUAL=manually fix
|
|||||||
COMMAND_FIX_ERROR=§cError while fixing the schematic, please contact a developer
|
COMMAND_FIX_ERROR=§cError while fixing the schematic, please contact a developer
|
||||||
COMMAND_FIX_WRONG_VERSION=§cThis feature is only available for version 1.15 and greater
|
COMMAND_FIX_WRONG_VERSION=§cThis feature is only available for version 1.15 and greater
|
||||||
|
|
||||||
|
COMMAND_MATCH_HELP_HEAD=§7---===(§eSchematic Match§7)===---
|
||||||
|
COMMAND_MATCH_HELP_0=§7Schematic Match allows you to search for a pattern in your schematics
|
||||||
|
COMMAND_MATCH_HELP_1=§7The search is done by a simple pattern, which must be a schematic in your schematic list
|
||||||
|
COMMAND_MATCH_HELP_2=§7Parameters:
|
||||||
|
COMMAND_MATCH_HELP_3=§8• §e-d §8(§e-ignoreData§8): §7Ignore block data values, just search for the block type
|
||||||
|
COMMAND_MATCH_HELP_4=§8• §e-a §8(§e-airAsAny§8): §7Air blocks in the pattern are ignored
|
||||||
|
COMMAND_MATCH_HELP_5=§8• §e-A §8(§e-ignoreAir§8): §7Air blocks in the schematic are ignored
|
||||||
|
|
||||||
HELP_HEADER=§e§lSchematicSystem §8§lHelp
|
HELP_HEADER=§e§lSchematicSystem §8§lHelp
|
||||||
HELP_VIEW=Find & Load
|
HELP_VIEW=Find & Load
|
||||||
HELP_VIEW_HOVER=Search or download schematics
|
HELP_VIEW_HOVER=Search or download schematics
|
||||||
@ -173,6 +181,7 @@ HELP_VIEW_5=§8/§7schem §eload §8[§7schematic§8] - §7Loads a schematic
|
|||||||
HELP_VIEW_6=§8/§7schem §edownload §8[§7schematic§8] - §7Gives you a download link (valid for 1 min)
|
HELP_VIEW_6=§8/§7schem §edownload §8[§7schematic§8] - §7Gives you a download link (valid for 1 min)
|
||||||
HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current clipboard (valid for 1 min)
|
HELP_VIEW_7=§8/§7download §8- §7Gives you a download link for your current clipboard (valid for 1 min)
|
||||||
HELP_VIEW_8=§8/§7schem §echeck §8[§7schematic§8|§7selection§8|§7clipboard§8] [§7schematictype§8] - §7Checks the schematic for errors
|
HELP_VIEW_8=§8/§7schem §echeck §8[§7schematic§8|§7selection§8|§7clipboard§8] [§7schematictype§8] - §7Checks the schematic for errors
|
||||||
|
HELP_VIEW_9=§8/§7schem §ematch §8[§7schematic§8] - §7Searches for a pattern in your schematics
|
||||||
HELP_EDIT=Save & Edit
|
HELP_EDIT=Save & Edit
|
||||||
HELP_EDIT_HOVER=Modification of schematics and folders
|
HELP_EDIT_HOVER=Modification of schematics and folders
|
||||||
HELP_EDIT_1=§8/§7schem §esave §8[§7schematic§8] - §7Saves your clipboard as a schematic
|
HELP_EDIT_1=§8/§7schem §esave §8[§7schematic§8] - §7Saves your clipboard as a schematic
|
||||||
|
@ -147,6 +147,13 @@ COMMAND_FIX_MANUAL=Manuel Fixen
|
|||||||
COMMAND_FIX_ERROR=§cFehler beim Fixen der Schematic, bitte kontaktiere einen Developer
|
COMMAND_FIX_ERROR=§cFehler beim Fixen der Schematic, bitte kontaktiere einen Developer
|
||||||
COMMAND_FIX_WRONG_VERSION=§cDiese Funktion ist nur für Version 1.15 und höher verfügbar
|
COMMAND_FIX_WRONG_VERSION=§cDiese Funktion ist nur für Version 1.15 und höher verfügbar
|
||||||
|
|
||||||
|
COMMAND_MATCH_HELP_0=§7Schematic Match erlaubt es dir, nach Schematics zu suchen, die mit deiner Schematic übereinstimmen
|
||||||
|
COMMAND_MATCH_HELP_1=§7Die Suche arbeitet mit einem Muster, welches eine deiner Schematics ist.
|
||||||
|
COMMAND_MATCH_HELP_2=§7Parameter:
|
||||||
|
COMMAND_MATCH_HELP_3=§8• §e-d §8(§e-ignoreData§8): §7Block-Data wird ignoriert, es wird nur nach dem Block-Typ gesucht
|
||||||
|
COMMAND_MATCH_HELP_4=§8• §e-a §8(§e-airAsAny§8): §7Luftblöcke werden im Mustern als beliebige Blöcke behandelt
|
||||||
|
COMMAND_MATCH_HELP_5=§8• §e-A §8(§e-ignoreAir§8): §7Luftblöcke werden in der durchsuchten Schematic ignoriert
|
||||||
|
|
||||||
HELP_HEADER=§e§lSchematicSystem §8§lHilfe
|
HELP_HEADER=§e§lSchematicSystem §8§lHilfe
|
||||||
HELP_VIEW=Finden & Laden
|
HELP_VIEW=Finden & Laden
|
||||||
HELP_VIEW_HOVER=Suche oder lade Schematics
|
HELP_VIEW_HOVER=Suche oder lade Schematics
|
||||||
|
@ -57,7 +57,8 @@ public class SchematicCommandHelp {
|
|||||||
"HELP_VIEW_5",
|
"HELP_VIEW_5",
|
||||||
"HELP_VIEW_6",
|
"HELP_VIEW_6",
|
||||||
"HELP_VIEW_7",
|
"HELP_VIEW_7",
|
||||||
"HELP_VIEW_8"
|
"HELP_VIEW_8",
|
||||||
|
"HELP_VIEW_9"
|
||||||
}),
|
}),
|
||||||
BEARBEITUNG("HELP_EDIT", "HELP_EDIT_HOVER", new String[]{
|
BEARBEITUNG("HELP_EDIT", "HELP_EDIT_HOVER", new String[]{
|
||||||
"HELP_EDIT_1",
|
"HELP_EDIT_1",
|
||||||
|
@ -20,17 +20,23 @@
|
|||||||
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
package de.steamwar.schematicsystem.commands.schematiccommand.parts;
|
||||||
|
|
||||||
import de.steamwar.command.*;
|
import de.steamwar.command.*;
|
||||||
|
import de.steamwar.network.NetworkSender;
|
||||||
|
import de.steamwar.network.packets.client.RequestSchematicSearchPacket;
|
||||||
import de.steamwar.schematicsystem.SchematicSystem;
|
import de.steamwar.schematicsystem.SchematicSystem;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommandUtils;
|
||||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||||
import de.steamwar.sql.SchematicNode;
|
import de.steamwar.sql.SchematicNode;
|
||||||
import de.steamwar.sql.SchematicType;
|
import de.steamwar.sql.SchematicType;
|
||||||
import de.steamwar.sql.SteamwarUser;
|
import de.steamwar.sql.SteamwarUser;
|
||||||
|
import de.steamwar.sql.UserConfig;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
import lombok.Getter;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
import java.util.function.Consumer;
|
||||||
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;
|
||||||
@ -43,7 +49,6 @@ public class SearchPart extends SWCommand {
|
|||||||
|
|
||||||
private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>();
|
private static final Map<String, AbstractTypeMapper<CommandSender, ?>> searchMapper = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
searchMapper.put("-type", SWCommandUtils.createMapper(SchematicType.values().stream().map(SchematicType::name).toArray(String[]::new)));
|
||||||
searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
searchMapper.put("-owner", SWCommandUtils.createMapper(Function.identity(), (commandSender, s) -> Collections.singletonList(s)));
|
||||||
@ -130,6 +135,24 @@ public class SearchPart extends SWCommand {
|
|||||||
}).build());
|
}).build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register("match")
|
||||||
|
public void schematicMatchHelp(Player player) {
|
||||||
|
SchematicSystem.MESSAGE.sendPrefixless("COMMAND_MATCH_HELP_HEAD", player);
|
||||||
|
for (int i = 0; i < 6; i++) {
|
||||||
|
SchematicSystem.MESSAGE.sendPrefixless("COMMAND_MATCH_HELP_" + i, player);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Register("match")
|
||||||
|
public void schematicMatch(Player player, SchematicNode node, SearchParameter... parameter) {
|
||||||
|
SteamwarUser user = getUser(player);
|
||||||
|
RequestSchematicSearchPacket.RequestSchematicSearchPacketBuilder builder = RequestSchematicSearchPacket.builder().schematicId(node.getId()).playerId(user.getId());
|
||||||
|
for (SearchParameter searchParameter : parameter) {
|
||||||
|
searchParameter.builder.accept(builder);
|
||||||
|
}
|
||||||
|
NetworkSender.send(builder.build());
|
||||||
|
}
|
||||||
|
|
||||||
@Mapper(value = "searchMapper", local = true)
|
@Mapper(value = "searchMapper", local = true)
|
||||||
public TypeMapper<String> searchTypeMapper() {
|
public TypeMapper<String> searchTypeMapper() {
|
||||||
return new TypeMapper<String>() {
|
return new TypeMapper<String>() {
|
||||||
@ -162,4 +185,34 @@ public class SearchPart extends SWCommand {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ClassMapper(SearchParameter.class)
|
||||||
|
public TypeMapper<SearchParameter> searchParameterTypeMapper() {
|
||||||
|
return new TypeMapper<SearchParameter>() {
|
||||||
|
@Override
|
||||||
|
public SearchParameter map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||||
|
return Arrays.stream(SearchParameter.values()).filter(searchParameter -> searchParameter.getFlag().equals(s) || searchParameter.getLongFlag().equalsIgnoreCase(s)).findFirst().orElse(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
|
||||||
|
return Arrays.stream(SearchParameter.values()).flatMap(parameter -> Arrays.stream(new String[] {parameter.getFlag(), parameter.getLongFlag()})).collect(Collectors.toList());
|
||||||
|
}
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
private enum SearchParameter {
|
||||||
|
AIR_AS_ANY(requestSchematicSearchPacketBuilder -> requestSchematicSearchPacketBuilder.airAsAny(true),"-a", "-airAsAny"),
|
||||||
|
IGNORE_AIR(requestSchematicSearchPacketBuilder -> requestSchematicSearchPacketBuilder.ignoreAir(true), "-A", "-ignoreAir"),
|
||||||
|
IGNORE_BLOCK_DATA(requestSchematicSearchPacketBuilder -> requestSchematicSearchPacketBuilder.ignoreBlockData(true), "-d", "-ignoreData");
|
||||||
|
|
||||||
|
private final Consumer<RequestSchematicSearchPacket.RequestSchematicSearchPacketBuilder> builder;
|
||||||
|
@Getter
|
||||||
|
private final String flag;
|
||||||
|
@Getter
|
||||||
|
private final String longFlag;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren