Add SteamwarUser.getServerTeam #185
@ -73,6 +73,7 @@ public interface Provider {
|
||||
SteamwarUser getUserByName(String userName);
|
||||
SteamwarUser getUserByUUID(UUID uuid);
|
||||
SteamwarUser getUserByID(int id);
|
||||
List<SteamwarUser> getServerTeam();
|
||||
|
||||
void logException(String server, String message, String stacktrace);
|
||||
|
||||
|
@ -319,6 +319,17 @@ public class SQLProvider implements Provider {
|
||||
}, 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 {
|
||||
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"));
|
||||
}
|
||||
|
@ -181,6 +181,11 @@ public class StandaloneProvider implements Provider {
|
||||
return usersByUUID.values().stream().filter(user -> user.getId() == id).findAny().get();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SteamwarUser> getServerTeam() {
|
||||
return Bukkit.getOperators().stream().map(OfflinePlayer::getName).map(this::getUserByName).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void logException(String server, String message, String stacktrace) {}
|
||||
|
||||
|
@ -24,6 +24,7 @@ import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
@ -110,4 +111,8 @@ public class SteamwarUser {
|
||||
public static SteamwarUser get(Player player) {
|
||||
return get(player.getUniqueId());
|
||||
}
|
||||
|
||||
public static List<SteamwarUser> getServerTeam() {
|
||||
return Provider.impl.getServerTeam();
|
||||
}
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren