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);
|
fight.initPlayers(fightPlayers);
|
||||||
}
|
}
|
||||||
|
|
||||||
SteamwarUser.batchCache(fightPlayers.stream().map(FightPlayer::getUserID).collect(Collectors.toSet()));
|
|
||||||
return fights;
|
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 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 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){
|
public static SteamwarUser get(String userName){
|
||||||
SteamwarUser user = usersByName.get(userName.toLowerCase());
|
|
||||||
if(user != null)
|
|
||||||
return user;
|
|
||||||
return byName.select(userName);
|
return byName.select(userName);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(UUID uuid){
|
public static SteamwarUser get(UUID uuid){
|
||||||
SteamwarUser user = usersByUUID.get(uuid);
|
|
||||||
if(user != null)
|
|
||||||
return user;
|
|
||||||
return byUUID.select(uuid);
|
return byUUID.select(uuid);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(int id) {
|
public static SteamwarUser get(int id) {
|
||||||
SteamwarUser user = usersById.get(id);
|
|
||||||
if(user != null)
|
|
||||||
return user;
|
|
||||||
return byID.select(id);
|
return byID.select(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static SteamwarUser get(Long discordId) {
|
public static SteamwarUser get(Long discordId) {
|
||||||
if(usersByDiscord.containsKey(discordId))
|
|
||||||
return usersByDiscord.get(discordId);
|
|
||||||
return byDiscord.select(discordId);
|
return byDiscord.select(discordId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,16 +105,6 @@ public class SteamwarUser {
|
|||||||
return byTeam.listSelect(teamId);
|
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
|
@Getter
|
||||||
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
@Field(keys = {Table.PRIMARY}, autoincrement = true)
|
||||||
private final int id;
|
private final int id;
|
||||||
@ -186,13 +145,6 @@ public class SteamwarUser {
|
|||||||
this.locale = locale;
|
this.locale = locale;
|
||||||
this.manualLocale = manualLocale;
|
this.manualLocale = manualLocale;
|
||||||
this.discordId = discordId != null && discordId != 0 ? discordId : null;
|
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() {
|
public UUID getUUID() {
|
||||||
@ -283,12 +235,8 @@ public class SteamwarUser {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setDiscordId(Long discordId) {
|
public void setDiscordId(Long discordId) {
|
||||||
usersByDiscord.remove(this.discordId);
|
|
||||||
this.discordId = discordId;
|
this.discordId = discordId;
|
||||||
updateDiscord.update(discordId, id);
|
updateDiscord.update(discordId, id);
|
||||||
if (discordId != null) {
|
|
||||||
usersByDiscord.put(discordId, this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initPunishments() {
|
private void initPunishments() {
|
||||||
|
@ -25,12 +25,14 @@ import de.steamwar.sql.internal.Statement;
|
|||||||
import de.steamwar.sql.internal.Table;
|
import de.steamwar.sql.internal.Table;
|
||||||
import lombok.AllArgsConstructor;
|
import lombok.AllArgsConstructor;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.ToString;
|
||||||
|
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
@Getter
|
@Getter
|
||||||
|
@ToString
|
||||||
public class Token {
|
public class Token {
|
||||||
private static final Table<Token> table = new Table<>(Token.class);
|
private static final Table<Token> table = new Table<>(Token.class);
|
||||||
private static final Statement insert = table.insertFields(true, "Name", "Owner", "Hash");
|
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) {
|
public static List<Tutorial> getPage(int page, int elementsPerPage, boolean released) {
|
||||||
List<Tutorial> tutorials = by_popularity.listSelect(released, page * elementsPerPage, elementsPerPage);
|
List<Tutorial> tutorials = by_popularity.listSelect(released, page * elementsPerPage, elementsPerPage);
|
||||||
SteamwarUser.batchCache(tutorials.stream().map(tutorial -> tutorial.creator).collect(Collectors.toSet()));
|
|
||||||
return tutorials;
|
return tutorials;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -82,8 +82,11 @@ public enum UserPerm {
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public static class Prefix {
|
public static class Prefix {
|
||||||
|
private static int ordinalCounter = 0;
|
||||||
|
|
||||||
private final String colorCode;
|
private final String colorCode;
|
||||||
private final String chatPrefix;
|
private final String chatPrefix;
|
||||||
|
private final int ordinal = ordinalCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren