Dieser Commit ist enthalten in:
Ursprung
9b22e77f9b
Commit
fa04945595
0
build.gradle
Ausführbare Datei → Normale Datei
0
build.gradle
Ausführbare Datei → Normale Datei
0
gradlew
vendored
Ausführbare Datei → Normale Datei
0
gradlew
vendored
Ausführbare Datei → Normale Datei
@ -46,7 +46,6 @@ public class Fight {
|
||||
fight.initPlayers(fightPlayers);
|
||||
}
|
||||
|
||||
SteamwarUser.batchCache(fightPlayers.stream().map(FightPlayer::getUserID).collect(Collectors.toSet()));
|
||||
return fights;
|
||||
}
|
||||
|
||||
|
@ -59,50 +59,19 @@ public class SteamwarUser {
|
||||
private static final Statement getPlaytime = new Statement("SELECT SUM(UNIX_TIMESTAMP(EndTime) - UNIX_TIMESTAMP(StartTime)) as Playtime FROM Session WHERE UserID = ?");
|
||||
private static final Statement getFirstjoin = new Statement("SELECT MIN(StartTime) AS FirstJoin FROM Session WHERE UserID = ?");
|
||||
|
||||
private static final Map<Integer, SteamwarUser> usersById = new HashMap<>();
|
||||
private static final Map<UUID, SteamwarUser> usersByUUID = new HashMap<>();
|
||||
private static final Map<String, SteamwarUser> usersByName = new HashMap<>();
|
||||
private static final Map<Long, SteamwarUser> usersByDiscord = new HashMap<>();
|
||||
public static void clear() {
|
||||
usersById.clear();
|
||||
usersByName.clear();
|
||||
usersByUUID.clear();
|
||||
usersByDiscord.clear();
|
||||
}
|
||||
|
||||
public static void invalidate(int userId) {
|
||||
SteamwarUser user = usersById.remove(userId);
|
||||
if (user == null)
|
||||
return;
|
||||
usersByName.remove(user.getUserName());
|
||||
usersByUUID.remove(user.getUUID());
|
||||
usersByDiscord.remove(user.getDiscordId());
|
||||
}
|
||||
|
||||
public static SteamwarUser get(String userName){
|
||||
SteamwarUser user = usersByName.get(userName.toLowerCase());
|
||||
if(user != null)
|
||||
return user;
|
||||
return byName.select(userName);
|
||||
}
|
||||
|
||||
public static SteamwarUser get(UUID uuid){
|
||||
SteamwarUser user = usersByUUID.get(uuid);
|
||||
if(user != null)
|
||||
return user;
|
||||
return byUUID.select(uuid);
|
||||
}
|
||||
|
||||
public static SteamwarUser get(int id) {
|
||||
SteamwarUser user = usersById.get(id);
|
||||
if(user != null)
|
||||
return user;
|
||||
return byID.select(id);
|
||||
}
|
||||
|
||||
public static SteamwarUser get(Long discordId) {
|
||||
if(usersByDiscord.containsKey(discordId))
|
||||
return usersByDiscord.get(discordId);
|
||||
return byDiscord.select(discordId);
|
||||
}
|
||||
|
||||
@ -136,16 +105,6 @@ public class SteamwarUser {
|
||||
return byTeam.listSelect(teamId);
|
||||
}
|
||||
|
||||
public static void batchCache(Set<Integer> ids) {
|
||||
ids.removeIf(usersById::containsKey);
|
||||
if(ids.isEmpty())
|
||||
return;
|
||||
|
||||
try (SelectStatement<SteamwarUser> batch = new SelectStatement<>(table, "SELECT * FROM UserData WHERE id IN (" + ids.stream().map(Object::toString).collect(Collectors.joining(", ")) + ")")) {
|
||||
batch.listSelect();
|
||||
}
|
||||
}
|
||||
|
||||
@Getter
|
||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||
private final int id;
|
||||
@ -186,13 +145,6 @@ public class SteamwarUser {
|
||||
this.locale = locale;
|
||||
this.manualLocale = manualLocale;
|
||||
this.discordId = discordId != null && discordId != 0 ? discordId : null;
|
||||
|
||||
usersById.put(id, this);
|
||||
usersByName.put(userName.toLowerCase(), this);
|
||||
usersByUUID.put(uuid, this);
|
||||
if (this.discordId != null) {
|
||||
usersByDiscord.put(discordId, this);
|
||||
}
|
||||
}
|
||||
|
||||
public UUID getUUID() {
|
||||
@ -283,12 +235,8 @@ public class SteamwarUser {
|
||||
}
|
||||
|
||||
public void setDiscordId(Long discordId) {
|
||||
usersByDiscord.remove(this.discordId);
|
||||
this.discordId = discordId;
|
||||
updateDiscord.update(discordId, id);
|
||||
if (discordId != null) {
|
||||
usersByDiscord.put(discordId, this);
|
||||
}
|
||||
}
|
||||
|
||||
private void initPunishments() {
|
||||
|
@ -25,12 +25,14 @@ import de.steamwar.sql.internal.Statement;
|
||||
import de.steamwar.sql.internal.Table;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.ToString;
|
||||
|
||||
import java.sql.Timestamp;
|
||||
import java.util.List;
|
||||
|
||||
@AllArgsConstructor
|
||||
@Getter
|
||||
@ToString
|
||||
public class Token {
|
||||
private static final Table<Token> table = new Table<>(Token.class);
|
||||
private static final Statement insert = table.insertFields(true, "Name", "Owner", "Hash");
|
||||
|
@ -44,7 +44,6 @@ public class Tutorial {
|
||||
|
||||
public static List<Tutorial> getPage(int page, int elementsPerPage, boolean released) {
|
||||
List<Tutorial> tutorials = by_popularity.listSelect(released, page * elementsPerPage, elementsPerPage);
|
||||
SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
|
||||
return tutorials;
|
||||
}
|
||||
|
||||
|
@ -82,8 +82,11 @@ public enum UserPerm {
|
||||
@Getter
|
||||
@AllArgsConstructor
|
||||
public static class Prefix {
|
||||
private static int ordinalCounter = 0;
|
||||
|
||||
private final String colorCode;
|
||||
private final String chatPrefix;
|
||||
private final int ordinal = ordinalCounter++;
|
||||
}
|
||||
|
||||
@AllArgsConstructor
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren