Compare commits
2 Commits
b3e560d1e2
...
8dcde443ee
Author | SHA1 | Date | |
---|---|---|---|
8dcde443ee | |||
ba699f5305 |
@ -61,8 +61,6 @@ public class PlayerService {
|
||||
uuid = usernameToUuid(id).getUniqueId();
|
||||
}
|
||||
|
||||
((UniquePlayerLookupsMetric) metricService.getMetric(UniquePlayerLookupsMetric.class)).addLookup(id); // Add the lookup to the unique player lookups
|
||||
|
||||
Optional<CachedPlayer> cachedPlayer = playerCacheRepository.findById(uuid);
|
||||
if (cachedPlayer.isPresent() && EnvironmentUtils.isProduction()) { // Return the cached player if it exists
|
||||
log.info("Player {} is cached", id);
|
||||
@ -85,6 +83,7 @@ public class PlayerService {
|
||||
mojangProfile.getProperties() // Raw properties
|
||||
)
|
||||
);
|
||||
((UniquePlayerLookupsMetric) metricService.getMetric(UniquePlayerLookupsMetric.class)).addLookup(uuid); // Add the lookup to the unique player lookups
|
||||
|
||||
playerCacheRepository.save(player);
|
||||
player.getCache().setCached(false);
|
||||
|
@ -66,8 +66,6 @@ public class ServerService {
|
||||
String key = "%s-%s:%s".formatted(platformName, hostname, port);
|
||||
log.info("Getting server: {}:{}", hostname, port);
|
||||
|
||||
((UniqueServerLookupsMetric) metricService.getMetric(UniqueServerLookupsMetric.class)).addLookup(key); // Add the server lookup to the unique server lookups
|
||||
|
||||
// Check if the server is cached
|
||||
Optional<CachedMinecraftServer> cached = serverCacheRepository.findById(key);
|
||||
if (cached.isPresent() && EnvironmentUtils.isProduction()) {
|
||||
@ -102,6 +100,8 @@ public class ServerService {
|
||||
((JavaMinecraftServer) server.getServer()).setMojangBlocked(mojangService.isServerBlocked(hostname));
|
||||
}
|
||||
|
||||
((UniqueServerLookupsMetric) metricService.getMetric(UniqueServerLookupsMetric.class)).addLookup(key); // Add the server lookup to the unique server lookups
|
||||
|
||||
log.info("Found server: {}:{}", hostname, port);
|
||||
serverCacheRepository.save(server);
|
||||
server.getCache().setCached(false);
|
||||
|
@ -4,6 +4,7 @@ import xyz.mcutils.backend.service.metric.impl.IntegerMetric;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class UniquePlayerLookupsMetric extends IntegerMetric {
|
||||
private List<String> uniqueLookups = new ArrayList<>();
|
||||
@ -20,12 +21,11 @@ public class UniquePlayerLookupsMetric extends IntegerMetric {
|
||||
/**
|
||||
* Adds a lookup to the list of unique lookups.
|
||||
*
|
||||
* @param lookup the query that was used to look up a player
|
||||
* @param uuid the query that was used to look up a player
|
||||
*/
|
||||
public void addLookup(String lookup) {
|
||||
lookup = lookup.toLowerCase();
|
||||
if (!uniqueLookups.contains(lookup)) {
|
||||
uniqueLookups.add(lookup);
|
||||
public void addLookup(UUID uuid) {
|
||||
if (!uniqueLookups.contains(uuid.toString())) {
|
||||
uniqueLookups.add(uuid.toString());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -20,12 +20,12 @@ public class UniqueServerLookupsMetric extends IntegerMetric {
|
||||
/**
|
||||
* Adds a lookup to the list of unique lookups.
|
||||
*
|
||||
* @param lookup the query that was used to look up a player
|
||||
* @param hostname the query that was used to look up a player
|
||||
*/
|
||||
public void addLookup(String lookup) {
|
||||
lookup = lookup.toLowerCase();
|
||||
if (!uniqueLookups.contains(lookup)) {
|
||||
uniqueLookups.add(lookup);
|
||||
public void addLookup(String hostname) {
|
||||
hostname = hostname.toLowerCase();
|
||||
if (!uniqueLookups.contains(hostname)) {
|
||||
uniqueLookups.add(hostname);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user