Update SWCommandUtils SteamwarUser mapper
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Dieser Commit ist enthalten in:
Ursprung
2bac163e57
Commit
cd90cba7d5
@ -72,17 +72,23 @@ public class SWCommandUtils {
|
||||
if (s.equals("a") || s.equals("adventure") || s.equals("2")) return GameMode.ADVENTURE;
|
||||
return null;
|
||||
}, s -> Arrays.asList("s", "survival", "0", "c", "creative", "1", "sp", "spectator", "3", "a", "adventure", "2")));
|
||||
MAPPER_FUNCTIONS.put(SteamwarUser.class.getTypeName(), createMapper(SteamwarUser::get, s -> Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList())));
|
||||
MAPPER_FUNCTIONS.put(SchematicNode.class.getTypeName(), new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
|
||||
MAPPER_FUNCTIONS.put(SteamwarUser.class.getTypeName(), createMapper(SteamwarUser::get, s -> {
|
||||
if (s.length() < 1) {
|
||||
return Bukkit.getOnlinePlayers().stream().map(Player::getName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
List<SteamwarUser> steamwarUsers = SteamwarUser.startsWithName(s);
|
||||
return steamwarUsers.stream().map(SteamwarUser::getUserName).limit(40).collect(Collectors.toList());
|
||||
}));
|
||||
MAPPER_FUNCTIONS.put(SchematicNode.class.getTypeName(), new TypeMapper<SchematicNode>() {
|
||||
@Override
|
||||
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
|
||||
return SchematicNode.getNodeFromPath(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
|
||||
return SchematicNode.getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), s);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -32,6 +32,7 @@ public class SteamwarUser {
|
||||
private static final SQL.Statement getId = new SQL.Statement("SELECT * FROM UserData WHERE id = ?");
|
||||
private static final SQL.Statement getUUID = new SQL.Statement("SELECT * FROM UserData WHERE UUID = ?");
|
||||
private static final SQL.Statement getName = new SQL.Statement("SELECT * FROM UserData WHERE lower(UserName) = ?");
|
||||
private static final SQL.Statement startWithName = new SQL.Statement("SELECT * FROM UserData WHERE lower(UserName) LIKE ?");
|
||||
|
||||
private static final Map<UUID, SteamwarUser> byUUID = new HashMap<>();
|
||||
private static final Map<String, SteamwarUser> byName = new HashMap<>();
|
||||
@ -93,6 +94,16 @@ public class SteamwarUser {
|
||||
return bedrock;
|
||||
}
|
||||
|
||||
public static List<SteamwarUser> startsWithName(String userName){
|
||||
return startWithName.select(rs -> {
|
||||
List<SteamwarUser> steamwarUsers = new ArrayList<>();
|
||||
while (rs.next()) {
|
||||
steamwarUsers.add(new SteamwarUser(rs));
|
||||
}
|
||||
return steamwarUsers;
|
||||
}, userName.toLowerCase() + "%");
|
||||
}
|
||||
|
||||
public static SteamwarUser get(String userName){
|
||||
SteamwarUser user = byName.get(userName.toLowerCase());
|
||||
if(user == null)
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren