DBF parsers
This commit is contained in:
parent
5c8778ca96
commit
9006c0c3cd
10
pom.xml
10
pom.xml
@ -42,11 +42,6 @@
|
||||
<artifactId>protobuf-java-util</artifactId>
|
||||
<version>3.24.4</version>
|
||||
</dependency>
|
||||
<!--<dependency>
|
||||
<groupId>org.ektorp</groupId>
|
||||
<artifactId>org.ektorp</artifactId>
|
||||
<version>1.5.0</version>
|
||||
</dependency>-->
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
||||
@ -90,6 +85,11 @@
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-web</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.luaj</groupId>
|
||||
<artifactId>luaj-jse</artifactId>
|
||||
<version>3.0.1</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
@ -1,36 +0,0 @@
|
||||
package com.alterdekim;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
|
||||
@Slf4j
|
||||
public class Main {
|
||||
|
||||
// public static void main(String[] args) {
|
||||
// new Server(1119).startListening();
|
||||
/* System.out.println(Util.bytesToHex(exampleProtocol.Test.newBuilder()
|
||||
.setA(9999)
|
||||
.setB("testing")
|
||||
.setC(7777)
|
||||
.build().toByteArray()));*/
|
||||
|
||||
/* Scanner scanner = new Scanner(System.in);
|
||||
String s = "";
|
||||
while ((s = scanner.nextLine()) != null) {
|
||||
try {
|
||||
byte[] arr = Util.hexStringToByteArray(s);
|
||||
int offset = 0;
|
||||
while (offset < arr.length) {
|
||||
BattleNetPacket bp = new BattleNetPacket();
|
||||
offset += bp.Decode(arr, offset, arr.length);
|
||||
log.warn(offset + " " + arr.length);
|
||||
log.info(bp.getHeader().toString());
|
||||
log.info("Body.Length = " + bp.getBody().length);
|
||||
log.info(Util.bytesToHex(bp.getBody()));
|
||||
}
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}*/
|
||||
// }
|
||||
}
|
@ -1,35 +0,0 @@
|
||||
package com.alterdekim.db;
|
||||
|
||||
public class Database {
|
||||
|
||||
//private CouchDbConnector lobbyConnector;
|
||||
|
||||
private String host;
|
||||
private int port;
|
||||
private String lobby_name;
|
||||
|
||||
public Database( String host, int port, String lobby_name ) {
|
||||
this.host = host;
|
||||
this.port = port;
|
||||
this.lobby_name = lobby_name;
|
||||
}
|
||||
|
||||
public void start() throws Exception {
|
||||
/* HttpClient httpClient = new StdHttpClient.Builder()
|
||||
.url("http://"+host+":"+port)
|
||||
.username("admin")
|
||||
.password("")
|
||||
.build();
|
||||
CouchDbInstance dbInstance = new StdCouchDbInstance(httpClient);
|
||||
|
||||
CouchDbConnector db = new StdCouchDbConnector(lobby_name, dbInstance);
|
||||
db.createDatabaseIfNotExists();
|
||||
|
||||
this.lobbyConnector = db;
|
||||
|
||||
DesignDocument dd = new DesignDocument("test");
|
||||
|
||||
db.create(dd);*/
|
||||
|
||||
}
|
||||
}
|
@ -1,6 +1,8 @@
|
||||
package com.alterdekim.hearthhack.component;
|
||||
|
||||
import com.alterdekim.hearthhack.component.processor.*;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.Util;
|
||||
import lombok.Getter;
|
||||
@ -26,6 +28,12 @@ public class TcpConnection extends Thread {
|
||||
@Getter
|
||||
private final Map<Integer, Processor> processors;
|
||||
|
||||
@Getter
|
||||
private final ServerConfig serverConfig;
|
||||
|
||||
@Getter
|
||||
private final UserService userService;
|
||||
|
||||
public void stopListeningAndDisconnect() {
|
||||
log.warn("Tried to stopListening");
|
||||
}
|
||||
|
@ -2,9 +2,12 @@ package com.alterdekim.hearthhack.component;
|
||||
|
||||
|
||||
import com.alterdekim.hearthhack.component.processor.Processor;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.reflect.ReflectionLoader;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.Util;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@ -24,6 +27,12 @@ public class TcpServer extends ReflectionLoader<Processor> {
|
||||
private SSLServerSocket serverSocket;
|
||||
private List<TcpConnection> connections;
|
||||
|
||||
@Autowired
|
||||
private ServerConfig serverConfig;
|
||||
|
||||
@Autowired
|
||||
private UserService userService;
|
||||
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
private void start() {
|
||||
try {
|
||||
@ -42,7 +51,7 @@ public class TcpServer extends ReflectionLoader<Processor> {
|
||||
|
||||
while(true) {
|
||||
SSLSocket s = (SSLSocket) serverSocket.accept();
|
||||
TcpConnection c = new TcpConnection(s, this.getParsers());
|
||||
TcpConnection c = new TcpConnection(s, this.getParsers(), serverConfig, userService);
|
||||
connections.add(c);
|
||||
c.start();
|
||||
log.info("New Connection Established From {}", s.getInetAddress().toString());
|
||||
|
@ -121,13 +121,9 @@ public class GameUtilitiesProcessor extends Processor {
|
||||
}
|
||||
|
||||
if( packet.getHeader().getToken() == 28 ) {
|
||||
Protocol.Header header = Processor.generateResponse(0, packet.getHeader().getToken(), 0, 0);
|
||||
|
||||
// conn.send(new BattleNetPacket(header, new byte[0]));
|
||||
|
||||
byte[] b = Util.hexStringToByteArray("1252AA064F0A12094743545702000002116739AB040000000012190A170A0A08CE840110021809200012091884B6DAFCCEBDCC02121E0A1C0A0A08CE8401100218082000120E3A0C0D4743545715746174731804");
|
||||
|
||||
header = Protocol.Header.newBuilder()
|
||||
Protocol.Header header = Protocol.Header.newBuilder()
|
||||
.setServiceId(5)
|
||||
.setMethodId(6)
|
||||
.setToken(conn.nextToken())
|
||||
|
@ -2,6 +2,8 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +11,10 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateEmptyNotifica
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.ACCOUNT_LICENSES;
|
||||
|
||||
public class AccountLicensesInfo extends GenericParser {
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
// Protocol.AccountLicensesInfoResponse
|
||||
|
@ -2,6 +2,8 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
@ -14,6 +16,7 @@ import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.FEATURES;
|
||||
@Slf4j
|
||||
public class AvailableFeatures extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private Executor executor;
|
||||
|
||||
private void executeFeatures(TcpConnection conn) throws Exception {
|
||||
@ -36,6 +39,11 @@ public class AvailableFeatures extends GenericParser {
|
||||
conn.send(new BattleNetPacket(header, n.toByteArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
if( this.executor != null ) this.executor.setRunning(false);
|
||||
|
@ -2,6 +2,8 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -10,6 +12,14 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.BOOSTERS;
|
||||
|
||||
public class Boosters extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.BoosterList boosterList = Protocol.BoosterList.newBuilder()
|
||||
|
@ -2,6 +2,8 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +11,14 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.CARD_BACKS;
|
||||
|
||||
public class CardBacks extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.CardBacks cardBacks = Protocol.CardBacks.newBuilder()
|
||||
|
File diff suppressed because one or more lines are too long
@ -2,6 +2,8 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +11,14 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.CLIENT_OPTIONS;
|
||||
|
||||
public class ClientOptions extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.ClientOptions clientOptions = Protocol.ClientOptions.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,9 +12,20 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateEmptyNotifica
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.COLLECTION;
|
||||
|
||||
public class Collection extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
// Protocol.Collection collection = Protocol.Collection.newBuilder().build();
|
||||
// my collection
|
||||
Protocol.Collection collection = Protocol.Collection.newBuilder().build();
|
||||
|
||||
Protocol.Notification n = generateEmptyNotification(207);
|
||||
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.DECK_LIST;
|
||||
|
||||
public class DeckList extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.DeckList deckList = Protocol.DeckList.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -10,6 +13,15 @@ import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.ARCANE_DUST_B
|
||||
|
||||
public class DustBalance extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.ArcaneDustBalance dustBalance = Protocol.ArcaneDustBalance.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.FAVORITE_HEROES;
|
||||
|
||||
public class FavoriteHeroes extends GenericParser {
|
||||
|
||||
private UserService userService;
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.FavoriteHeroesResponse favoriteHeroesResponse = Protocol.FavoriteHeroesResponse.newBuilder()
|
||||
|
@ -19,7 +19,9 @@ public class GeneralGenericParser extends ReflectionLoader<GenericParser> {
|
||||
return;
|
||||
}
|
||||
try {
|
||||
this.getParsers().get(req.getValue()).parseGenericRequest(token, conn);
|
||||
GenericParser parser = this.getParsers().get(req.getValue());
|
||||
parser.setResources(conn.getUserService(), conn.getServerConfig());
|
||||
parser.parseGenericRequest(token, conn);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
|
@ -2,7 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.reflect.AbstractParser;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
import com.alterdekim.hearthhack.util.Util;
|
||||
@ -13,6 +15,9 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
|
||||
@NoArgsConstructor
|
||||
public abstract class GenericParser implements AbstractParser {
|
||||
|
||||
public abstract void setResources(IService service, ServerConfig config);
|
||||
|
||||
public abstract void parseGenericRequest(int token, TcpConnection conn) throws Exception;
|
||||
|
||||
@Override
|
||||
|
@ -2,13 +2,26 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.GOLD_BALANCE;
|
||||
|
||||
public class GoldBalance extends GenericParser{
|
||||
public class GoldBalance extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.GoldBalance gb = Protocol.GoldBalance.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.HERO_XP;
|
||||
|
||||
public class HeroXP extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.MEDAL_INFO;
|
||||
|
||||
public class MedalInfo extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.MedalInfo medalInfo = Protocol.MedalInfo.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.NOT_SO_MASSIVE_LOGIN;
|
||||
|
||||
public class NotSoMassiveLoginReply extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.NotSoMassiveLoginReply reply = Protocol.NotSoMassiveLoginReply.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
@ -11,6 +14,16 @@ import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.PVP_QUEUE;
|
||||
|
||||
@Slf4j
|
||||
public class PlayQueue extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.PlayQueue playQueue = Protocol.PlayQueue.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.PLAYER_RECORD;
|
||||
|
||||
public class PlayerRecords extends GenericParser {
|
||||
|
||||
private ServerConfig config;
|
||||
private UserService userService;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.PlayerRecords playerRecords = Protocol.PlayerRecords.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
import lombok.AllArgsConstructor;
|
||||
@ -18,6 +21,8 @@ import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.NOTICES;
|
||||
public class ProfileNotices extends GenericParser {
|
||||
|
||||
private Executor executor;
|
||||
private UserService userService;
|
||||
private ServerConfig config;
|
||||
|
||||
private void sendNotices(TcpConnection conn) throws Exception {
|
||||
Protocol.ProfileNotices notices = Protocol.ProfileNotices.newBuilder()
|
||||
@ -37,6 +42,12 @@ public class ProfileNotices extends GenericParser {
|
||||
conn.send(new BattleNetPacket(header, n.toByteArray()));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.config = config;
|
||||
this.userService = (UserService) service;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
if( this.executor != null ) this.executor.setRunning(false);
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -9,6 +12,16 @@ import static com.alterdekim.hearthhack.util.GameUtilities.generateNotification;
|
||||
import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.CAMPAIGN_INFO;
|
||||
|
||||
public class ProfileProgress extends GenericParser {
|
||||
|
||||
private UserService userService;
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.ProfileProgress profileProgress = Protocol.ProfileProgress.newBuilder()
|
||||
|
@ -2,6 +2,9 @@ package com.alterdekim.hearthhack.component.processor.client.request.generic;
|
||||
|
||||
import com.alterdekim.Protocol;
|
||||
import com.alterdekim.hearthhack.component.TcpConnection;
|
||||
import com.alterdekim.hearthhack.config.ServerConfig;
|
||||
import com.alterdekim.hearthhack.service.IService;
|
||||
import com.alterdekim.hearthhack.service.UserService;
|
||||
import com.alterdekim.hearthhack.util.BattleNetPacket;
|
||||
import com.alterdekim.hearthhack.util.GetAccountInfoRequest;
|
||||
|
||||
@ -10,6 +13,15 @@ import static com.alterdekim.hearthhack.util.GetAccountInfoRequest.REWARD_PROGRE
|
||||
|
||||
public class RewardProgress extends GenericParser {
|
||||
|
||||
private UserService userService;
|
||||
private ServerConfig config;
|
||||
|
||||
@Override
|
||||
public void setResources(IService service, ServerConfig config) {
|
||||
this.userService = (UserService) service;
|
||||
this.config = config;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void parseGenericRequest(int token, TcpConnection conn) throws Exception {
|
||||
Protocol.RewardProgress rewardProgress = Protocol.RewardProgress.newBuilder()
|
||||
|
@ -0,0 +1,11 @@
|
||||
package com.alterdekim.hearthhack.config;
|
||||
|
||||
import lombok.Data;
|
||||
import org.springframework.beans.factory.annotation.Value;
|
||||
import org.springframework.context.annotation.Configuration;
|
||||
|
||||
@Data
|
||||
@Configuration
|
||||
public class ServerConfig {
|
||||
@Value("${hearthhack.dbf_path}") private String dbfPath;
|
||||
}
|
17
src/main/java/com/alterdekim/hearthhack/dbf/CardsDBF.java
Normal file
17
src/main/java/com/alterdekim/hearthhack/dbf/CardsDBF.java
Normal file
@ -0,0 +1,17 @@
|
||||
package com.alterdekim.hearthhack.dbf;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ToString
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
public class CardsDBF {
|
||||
private String name;
|
||||
private String sourceFingerprint;
|
||||
private List<DBFColumn> columns;
|
||||
private List<DBFCard> records;
|
||||
}
|
14
src/main/java/com/alterdekim/hearthhack/dbf/DBFCard.java
Normal file
14
src/main/java/com/alterdekim/hearthhack/dbf/DBFCard.java
Normal file
@ -0,0 +1,14 @@
|
||||
package com.alterdekim.hearthhack.dbf;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class DBFCard {
|
||||
private List<DBFField> fields;
|
||||
}
|
13
src/main/java/com/alterdekim/hearthhack/dbf/DBFColumn.java
Normal file
13
src/main/java/com/alterdekim/hearthhack/dbf/DBFColumn.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.alterdekim.hearthhack.dbf;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class DBFColumn {
|
||||
private String name;
|
||||
private String type;
|
||||
}
|
13
src/main/java/com/alterdekim/hearthhack/dbf/DBFField.java
Normal file
13
src/main/java/com/alterdekim/hearthhack/dbf/DBFField.java
Normal file
@ -0,0 +1,13 @@
|
||||
package com.alterdekim.hearthhack.dbf;
|
||||
|
||||
import lombok.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@AllArgsConstructor
|
||||
@NoArgsConstructor
|
||||
@ToString
|
||||
public class DBFField {
|
||||
private String column;
|
||||
private String val;
|
||||
}
|
22
src/main/java/com/alterdekim/hearthhack/entity/CardBack.java
Normal file
22
src/main/java/com/alterdekim/hearthhack/entity/CardBack.java
Normal file
@ -0,0 +1,22 @@
|
||||
package com.alterdekim.hearthhack.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "card_backs")
|
||||
public class CardBack {
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Integer backId;
|
||||
}
|
53
src/main/java/com/alterdekim/hearthhack/entity/Deck.java
Normal file
53
src/main/java/com/alterdekim/hearthhack/entity/Deck.java
Normal file
@ -0,0 +1,53 @@
|
||||
package com.alterdekim.hearthhack.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "decks")
|
||||
public class Deck {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Long userId;
|
||||
|
||||
@Column(nullable=false)
|
||||
private String name;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer cardBack;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer hero;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer deckType;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long validity;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer heroPremium;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean cardBackOverride;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Boolean heroOverride;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long sortOrder;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer sourceType;
|
||||
}
|
@ -37,4 +37,12 @@ public class User {
|
||||
inverseJoinColumns={@JoinColumn(name="ROLE_ID", referencedColumnName="ID")})
|
||||
private List<Role> roles = new ArrayList<>();
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long dustBalance;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Long goldBalance;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer defaultCardBack = 0;
|
||||
}
|
||||
|
29
src/main/java/com/alterdekim/hearthhack/entity/UserCard.java
Normal file
29
src/main/java/com/alterdekim/hearthhack/entity/UserCard.java
Normal file
@ -0,0 +1,29 @@
|
||||
package com.alterdekim.hearthhack.entity;
|
||||
|
||||
import jakarta.persistence.*;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
@Entity
|
||||
@Table(name = "ucards")
|
||||
public class UserCard {
|
||||
|
||||
@Id
|
||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||
private Long id;
|
||||
|
||||
@Column(nullable=false)
|
||||
private Long userId;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer asset;
|
||||
|
||||
@Column(nullable = false)
|
||||
private Integer premium;
|
||||
}
|
101
src/main/java/com/alterdekim/hearthhack/parser/DBFParser.java
Normal file
101
src/main/java/com/alterdekim/hearthhack/parser/DBFParser.java
Normal file
@ -0,0 +1,101 @@
|
||||
package com.alterdekim.hearthhack.parser;
|
||||
|
||||
import com.alterdekim.hearthhack.dbf.CardsDBF;
|
||||
import com.alterdekim.hearthhack.dbf.DBFCard;
|
||||
import com.alterdekim.hearthhack.dbf.DBFColumn;
|
||||
import com.alterdekim.hearthhack.dbf.DBFField;
|
||||
import lombok.Getter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.xml.sax.Attributes;
|
||||
import org.xml.sax.SAXException;
|
||||
import org.xml.sax.helpers.DefaultHandler;
|
||||
|
||||
import javax.xml.parsers.ParserConfigurationException;
|
||||
import javax.xml.parsers.SAXParser;
|
||||
import javax.xml.parsers.SAXParserFactory;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class DBFParser extends DefaultHandler {
|
||||
public static CardsDBF parseCards(String path) {
|
||||
SAXParserFactory factory = SAXParserFactory.newInstance();
|
||||
try (InputStream is = new FileInputStream(path + "/CARD.xml")) {
|
||||
SAXParser saxParser = factory.newSAXParser();
|
||||
DBFParser handler = new DBFParser();
|
||||
saxParser.parse(is, handler);
|
||||
return handler.getResult();
|
||||
} catch (ParserConfigurationException | SAXException | IOException e) {
|
||||
log.error(e.getMessage());
|
||||
}
|
||||
return new CardsDBF();
|
||||
}
|
||||
|
||||
private final StringBuilder currentValue = new StringBuilder();
|
||||
|
||||
@Getter
|
||||
private CardsDBF result;
|
||||
|
||||
@Override
|
||||
public void startDocument() {
|
||||
result = new CardsDBF();
|
||||
result.setColumns(new ArrayList<>());
|
||||
result.setRecords(new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void startElement(
|
||||
String uri,
|
||||
String localName,
|
||||
String qName,
|
||||
Attributes attributes) {
|
||||
|
||||
currentValue.setLength(0);
|
||||
|
||||
switch (qName) {
|
||||
case "SourceFingerprint":
|
||||
result.setSourceFingerprint(attributes.getValue(qName));
|
||||
break;
|
||||
case "Column":
|
||||
DBFColumn column = new DBFColumn();
|
||||
column.setName(attributes.getValue("name"));
|
||||
column.setType(attributes.getValue("type"));
|
||||
result.getColumns().add(column);
|
||||
break;
|
||||
case "Record":
|
||||
result.getRecords().add(new DBFCard(new ArrayList<>()));
|
||||
break;
|
||||
case "Field":
|
||||
DBFField field = new DBFField();
|
||||
field.setColumn(attributes.getValue("column"));
|
||||
result.getRecords()
|
||||
.get(result.getRecords().size()-1)
|
||||
.getFields()
|
||||
.add(field);
|
||||
break;
|
||||
case "Dbf":
|
||||
result.setName(attributes.getValue("name"));
|
||||
}
|
||||
}
|
||||
|
||||
public void endElement(String uri,
|
||||
String localName,
|
||||
String qName) {
|
||||
if( qName.equals("Field") ) {
|
||||
List<DBFField> fields = result.getRecords()
|
||||
.get(result.getRecords().size()-1)
|
||||
.getFields();
|
||||
fields.get(fields.size()-1).setVal(currentValue.toString());
|
||||
result.getRecords()
|
||||
.get(result.getRecords().size()-1)
|
||||
.setFields(fields);
|
||||
}
|
||||
}
|
||||
|
||||
public void characters(char[] ch, int start, int length) {
|
||||
currentValue.append(ch, start, length);
|
||||
}
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
package com.alterdekim.hearthhack.service;
|
||||
|
||||
public interface IService {
|
||||
}
|
@ -9,7 +9,7 @@ import java.util.List;
|
||||
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class RoomPlayerService {
|
||||
public class RoomPlayerService implements IService {
|
||||
|
||||
private final RoomPlayerRepository repository;
|
||||
|
||||
|
@ -10,7 +10,7 @@ import java.util.Optional;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class RoomService {
|
||||
public class RoomService implements IService {
|
||||
private final RoomRepository roomRepository;
|
||||
|
||||
public List<Room> getAll() {
|
||||
|
@ -15,7 +15,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
@RequiredArgsConstructor
|
||||
@Service
|
||||
public class UserService {
|
||||
public class UserService implements IService {
|
||||
|
||||
private final UserRepository userRepository;
|
||||
private final RoleRepository roleRepository;
|
||||
|
16
src/main/java/com/alterdekim/hearthhack/xml/XmlElement.java
Normal file
16
src/main/java/com/alterdekim/hearthhack/xml/XmlElement.java
Normal file
@ -0,0 +1,16 @@
|
||||
package com.alterdekim.hearthhack.xml;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import static com.alterdekim.hearthhack.xml.XmlType.Attribute;
|
||||
|
||||
@Retention(RetentionPolicy.RUNTIME)
|
||||
@Target(ElementType.FIELD)
|
||||
public @interface XmlElement {
|
||||
String name() default "";
|
||||
XmlType type() default Attribute;
|
||||
boolean inheritName() default true;
|
||||
}
|
9
src/main/java/com/alterdekim/hearthhack/xml/XmlType.java
Normal file
9
src/main/java/com/alterdekim/hearthhack/xml/XmlType.java
Normal file
@ -0,0 +1,9 @@
|
||||
package com.alterdekim.hearthhack.xml;
|
||||
|
||||
public enum XmlType {
|
||||
Attribute,
|
||||
ChildElement,
|
||||
PlainValue,
|
||||
NestedList,
|
||||
List
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user