2021-04-01 19:00:18 +02:00
|
|
|
/*
|
|
|
|
* 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
|
|
|
|
* 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,
|
|
|
|
* 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.bausystem;
|
|
|
|
|
|
|
|
import de.steamwar.bausystem.tracer.show.ShowModeParameterType;
|
|
|
|
import de.steamwar.command.SWCommandUtils;
|
|
|
|
import de.steamwar.command.TypeMapper;
|
2021-04-02 17:03:58 +02:00
|
|
|
import de.steamwar.sql.BauweltMember;
|
|
|
|
import de.steamwar.sql.SteamwarUser;
|
2021-04-01 19:00:18 +02:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Map;
|
2021-04-02 17:03:58 +02:00
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
2021-04-01 19:00:18 +02:00
|
|
|
|
|
|
|
public class Mapper {
|
|
|
|
|
|
|
|
private Mapper() {
|
|
|
|
throw new IllegalStateException("Utility Class");
|
|
|
|
}
|
|
|
|
|
|
|
|
public static void init() {
|
|
|
|
SWCommandUtils.addMapper(ShowModeParameterType.class, showModeParameterTypesTypeMapper());
|
2021-04-02 17:03:58 +02:00
|
|
|
SWCommandUtils.addMapper(BauweltMember.class, bauweltMemberTypeMapper());
|
2021-04-01 19:00:18 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
private static TypeMapper<ShowModeParameterType> showModeParameterTypesTypeMapper() {
|
|
|
|
Map<String, ShowModeParameterType> showModeParameterTypesMap = new HashMap<>();
|
|
|
|
showModeParameterTypesMap.put("-water", ShowModeParameterType.WATER);
|
|
|
|
|
|
|
|
showModeParameterTypesMap.put("-interpolatey", ShowModeParameterType.INTERPOLATE_Y);
|
|
|
|
showModeParameterTypesMap.put("-interpolate-y", ShowModeParameterType.INTERPOLATE_Y);
|
|
|
|
showModeParameterTypesMap.put("-interpolate_y", ShowModeParameterType.INTERPOLATE_Y);
|
|
|
|
showModeParameterTypesMap.put("-y", ShowModeParameterType.INTERPOLATE_Y);
|
|
|
|
|
|
|
|
showModeParameterTypesMap.put("-interpolatex", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate-x", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate_x", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-x", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
|
|
|
|
showModeParameterTypesMap.put("-interpolatez", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate-z", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate_z", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-z", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
|
|
|
|
showModeParameterTypesMap.put("-interpolatexz", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate-xz", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-interpolate_xz", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
showModeParameterTypesMap.put("-xz", ShowModeParameterType.INTERPOLATE_XZ);
|
|
|
|
|
|
|
|
showModeParameterTypesMap.put("-advanced", ShowModeParameterType.ADVANCED);
|
|
|
|
showModeParameterTypesMap.put("advanced", ShowModeParameterType.ADVANCED);
|
|
|
|
showModeParameterTypesMap.put("a", ShowModeParameterType.ADVANCED);
|
|
|
|
|
|
|
|
List<String> tabCompletes = new ArrayList<>(showModeParameterTypesMap.keySet());
|
|
|
|
return SWCommandUtils.createMapper(s -> showModeParameterTypesMap.getOrDefault(s, null), s -> tabCompletes);
|
|
|
|
}
|
|
|
|
|
2021-04-02 17:03:58 +02:00
|
|
|
private static TypeMapper<BauweltMember> bauweltMemberTypeMapper() {
|
|
|
|
return SWCommandUtils.createMapper(s -> BauweltMember.getMembers(BauSystem.getOwnerID())
|
|
|
|
.stream()
|
|
|
|
.filter(m -> SteamwarUser.get(m.getMemberID()).getUserName().equals(s)).findFirst().orElse(null),
|
|
|
|
s -> BauweltMember.getMembers(BauSystem.getOwnerID())
|
|
|
|
.stream()
|
|
|
|
.map(m -> SteamwarUser.get(m.getMemberID()).getUserName())
|
|
|
|
.collect(Collectors.toList()));
|
|
|
|
}
|
2021-04-01 19:00:18 +02:00
|
|
|
}
|