SteamWar/SpigotCore
Archiviert
13
0

Add BauweltMember TypeMapper
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2021-12-09 21:37:17 +01:00
Ursprung 415a002cad
Commit 5f7f7673f0

Datei anzeigen

@ -19,6 +19,7 @@
package de.steamwar.command;
import de.steamwar.sql.BauweltMember;
import de.steamwar.sql.SchematicNode;
import de.steamwar.sql.SteamwarUser;
import org.bukkit.Bukkit;
@ -78,6 +79,32 @@ public class SWCommandUtils {
return SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
}
});
MAPPER_FUNCTIONS.put(BauweltMember.class.getTypeName(), new TypeMapper<BauweltMember>() {
@Override
public BauweltMember map(CommandSender commandSender, String[] previousArguments, String s) {
if (!(commandSender instanceof Player)) {
return null;
}
Player player = (Player) commandSender;
return BauweltMember.getMembers(player.getUniqueId())
.stream()
.filter(member -> SteamwarUser.get(member.getMemberID()).getUserName().equalsIgnoreCase(s))
.findAny()
.orElse(null);
}
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] previousArguments, String s) {
if (!(commandSender instanceof Player)) {
return new ArrayList<>();
}
Player player = (Player) commandSender;
return BauweltMember.getMembers(player.getUniqueId())
.stream()
.map(m -> SteamwarUser.get(m.getMemberID()).getUserName())
.collect(Collectors.toList());
}
});
}
private static void addMapper(Class<?> clazz, Class<?> alternativeClazz, TypeMapper<?> mapper) {