SteamWar/SpigotCore
Archiviert
13
0

Merge pull request 'Add SteamwarUser.getServerTeam' (#185) from ServerTeam into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Reviewed-on: #185
Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Lixfel 2022-03-26 11:54:18 +01:00
Commit 59102edf34
4 geänderte Dateien mit 22 neuen und 0 gelöschten Zeilen

Datei anzeigen

@ -73,6 +73,7 @@ public interface Provider {
SteamwarUser getUserByName(String userName); SteamwarUser getUserByName(String userName);
SteamwarUser getUserByUUID(UUID uuid); SteamwarUser getUserByUUID(UUID uuid);
SteamwarUser getUserByID(int id); SteamwarUser getUserByID(int id);
List<SteamwarUser> getServerTeam();
void logException(String server, String message, String stacktrace); void logException(String server, String message, String stacktrace);

Datei anzeigen

@ -319,6 +319,17 @@ public class SQLProvider implements Provider {
}, id); }, id);
} }
private static final Statement getServerTeam = new Statement("SELECT * FROM UserData WHERE UserGroup != 'Member' AND UserGroup != 'YouTuber'");
@Override
public List<SteamwarUser> getServerTeam() {
return getServerTeam.select(rs -> {
List<SteamwarUser> users = new ArrayList<>();
while(rs.next())
users.add(newSteamwarUser(rs));
return users;
});
}
private SteamwarUser newSteamwarUser(ResultSet rs) throws SQLException { private SteamwarUser newSteamwarUser(ResultSet rs) throws SQLException {
return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock")); return new SteamwarUser(rs.getInt("id"), UUID.fromString(rs.getString("UUID")), rs.getString("UserName"), UserGroup.getUsergroup(rs.getString("UserGroup")), rs.getInt("Team"), rs.getBoolean("Bedrock"));
} }

Datei anzeigen

@ -181,6 +181,11 @@ public class StandaloneProvider implements Provider {
return usersByUUID.values().stream().filter(user -> user.getId() == id).findAny().get(); return usersByUUID.values().stream().filter(user -> user.getId() == id).findAny().get();
} }
@Override
public List<SteamwarUser> getServerTeam() {
return Bukkit.getOperators().stream().map(OfflinePlayer::getUniqueId).map(this::getUserByUUID).collect(Collectors.toList());
}
@Override @Override
public void logException(String server, String message, String stacktrace) {} public void logException(String server, String message, String stacktrace) {}

Datei anzeigen

@ -24,6 +24,7 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.UUID; import java.util.UUID;
@ -110,4 +111,8 @@ public class SteamwarUser {
public static SteamwarUser get(Player player) { public static SteamwarUser get(Player player) {
return get(player.getUniqueId()); return get(player.getUniqueId());
} }
public static List<SteamwarUser> getServerTeam() {
return Provider.impl.getServerTeam();
}
} }