Browse Source

фикс ошибки с ип, оказывается лимит надо брать с запасом

теперь можно по дискорд ид запрашивать данные
master
gsd 2 years ago
parent
commit
05b3bd487e
  1. 3
      src/main/java/app/entities/server/PlayOn.java
  2. 15
      src/main/java/app/services/ProfileService.java
  3. 6
      src/test/java/app/servers/TestString.java

3
src/main/java/app/entities/server/PlayOn.java

@ -13,7 +13,8 @@ public class PlayOn {
public String getIp() {
if (ip.contains(":")){
return ip.split(":",1)[0];
System.out.println(ip);
return ip.split(":",2)[0];
} else {
return ip;
}

15
src/main/java/app/services/ProfileService.java

@ -5,6 +5,7 @@ import app.entities.Stats;
import app.entities.db.Ban;
import app.entities.other.SteamID;
import app.services.db.BanService;
import app.services.db.DiscordAuthService;
import app.services.db.PermitionService;
import app.services.db.UsertimeService;
import app.services.steam.SteamWebApi;
@ -23,17 +24,20 @@ public class ProfileService {
PermitionService permitionService;
StatsService statsService;
BanService banService;
DiscordAuthService discordAuthService;
@Autowired
public ProfileService(SteamWebApi steamWebApi,
UsertimeService usertimeService,
PermitionService permitionService,
StatsService statsService,
BanService banService) {
BanService banService,
DiscordAuthService discordAuthService) {
this.steamWebApi = steamWebApi;
this.usertimeService = usertimeService;
this.permitionService = permitionService;
this.statsService = statsService;
this.banService = banService;
this.discordAuthService = discordAuthService;
}
public PlayerProfile GetProfile(SteamID steamID, List<String> requests) {
@ -116,8 +120,15 @@ public class ProfileService {
}
public SteamID GetSteamIDFromAnyData(String any) {
SteamID result;
//Проверить что это дискорд ид
if (any.startsWith("<@") && any.endsWith(">")) {
String discord_id = any.split("<@", 2)[1].split(">", 2)[0];
result = discordAuthService.getSteamIDofDiscordID(discord_id);
if (result != null) return result;
}
//Проверить не играет ли чел с таким именем на сервере
SteamID result = statsService.searchPlayer(any);
result = statsService.searchPlayer(any);
if (result != null) return result;
//Проверить возможно что это ид бана
if (any.startsWith("#")) {

6
src/test/java/app/servers/TestString.java

@ -11,4 +11,10 @@ public class TestString {
System.out.println(splitted[1]);
System.out.println("#1488".startsWith("#"));
}
@Test
public void discord_id(){
String test_string = "<@43242342342342342>";
System.out.println(test_string.split("<@", 2)[1].split(">", 2)[0]);
}
}

Loading…
Cancel
Save