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() { public String getIp() {
if (ip.contains(":")){ if (ip.contains(":")){
return ip.split(":",1)[0]; System.out.println(ip);
return ip.split(":",2)[0];
} else { } else {
return ip; 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.db.Ban;
import app.entities.other.SteamID; import app.entities.other.SteamID;
import app.services.db.BanService; import app.services.db.BanService;
import app.services.db.DiscordAuthService;
import app.services.db.PermitionService; import app.services.db.PermitionService;
import app.services.db.UsertimeService; import app.services.db.UsertimeService;
import app.services.steam.SteamWebApi; import app.services.steam.SteamWebApi;
@ -23,17 +24,20 @@ public class ProfileService {
PermitionService permitionService; PermitionService permitionService;
StatsService statsService; StatsService statsService;
BanService banService; BanService banService;
DiscordAuthService discordAuthService;
@Autowired @Autowired
public ProfileService(SteamWebApi steamWebApi, public ProfileService(SteamWebApi steamWebApi,
UsertimeService usertimeService, UsertimeService usertimeService,
PermitionService permitionService, PermitionService permitionService,
StatsService statsService, StatsService statsService,
BanService banService) { BanService banService,
DiscordAuthService discordAuthService) {
this.steamWebApi = steamWebApi; this.steamWebApi = steamWebApi;
this.usertimeService = usertimeService; this.usertimeService = usertimeService;
this.permitionService = permitionService; this.permitionService = permitionService;
this.statsService = statsService; this.statsService = statsService;
this.banService = banService; this.banService = banService;
this.discordAuthService = discordAuthService;
} }
public PlayerProfile GetProfile(SteamID steamID, List<String> requests) { public PlayerProfile GetProfile(SteamID steamID, List<String> requests) {
@ -116,8 +120,15 @@ public class ProfileService {
} }
public SteamID GetSteamIDFromAnyData(String any) { 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 (result != null) return result;
//Проверить возможно что это ид бана //Проверить возможно что это ид бана
if (any.startsWith("#")) { 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(splitted[1]);
System.out.println("#1488".startsWith("#")); 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