Changed playerIds from Long to Integer
This commit is contained in:
parent
b999f34e1c
commit
9c8de427ef
@ -57,7 +57,7 @@ public class GameServer {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
|
|
||||||
private final Map<Long, Player> players;
|
private final Map<Integer, Player> players;
|
||||||
|
|
||||||
private final ObjectMapper xmlMapper;
|
private final ObjectMapper xmlMapper;
|
||||||
|
|
||||||
@ -66,7 +66,7 @@ public class GameServer {
|
|||||||
this.xmlMapper = new XmlMapper().registerModule(new JavaTimeModule());
|
this.xmlMapper = new XmlMapper().registerModule(new JavaTimeModule());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onConnect(long playerId, String hwId, ConnectedProcessor connectedProcessor) {
|
public void onConnect(int playerId, String hwId, ConnectedProcessor connectedProcessor) {
|
||||||
log.warn("GameServer.onConnect() connect: {}", playerId);
|
log.warn("GameServer.onConnect() connect: {}", playerId);
|
||||||
Optional<String> username = users.getUsernameById(playerId);
|
Optional<String> username = users.getUsernameById(playerId);
|
||||||
if( username.isEmpty() || !AuthenticationUtil.hwIdAuth(users.findByUsername(username.get()), hwId) || this.players.containsKey(playerId) ) {
|
if( username.isEmpty() || !AuthenticationUtil.hwIdAuth(users.findByUsername(username.get()), hwId) || this.players.containsKey(playerId) ) {
|
||||||
@ -76,7 +76,7 @@ public class GameServer {
|
|||||||
this.players.put(playerId, new Player(connectedProcessor, username.get()));
|
this.players.put(playerId, new Player(connectedProcessor, username.get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onMessage(long playerId, List<AMFObject> params ) {
|
public void onMessage(int playerId, List<AMFObject> params ) {
|
||||||
try {
|
try {
|
||||||
log.info("GameServer.onMessage() pid: {}, params: {}", playerId, params);
|
log.info("GameServer.onMessage() pid: {}, params: {}", playerId, params);
|
||||||
switch(CommandType.fromString( (String) params.get(0).getValue() )) {
|
switch(CommandType.fromString( (String) params.get(0).getValue() )) {
|
||||||
@ -100,7 +100,7 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPlayerAvatarPosition(long playerId, SetPlayerAvatarPosition message) {
|
private void setPlayerAvatarPosition(int playerId, SetPlayerAvatarPosition message) {
|
||||||
if( message.getCoordinates() != null ) {
|
if( message.getCoordinates() != null ) {
|
||||||
players.get(playerId).setX((Double) message.getCoordinates().get("x").getValue());
|
players.get(playerId).setX((Double) message.getCoordinates().get("x").getValue());
|
||||||
players.get(playerId).setY((Double) message.getCoordinates().get("y").getValue());
|
players.get(playerId).setY((Double) message.getCoordinates().get("y").getValue());
|
||||||
@ -114,14 +114,14 @@ public class GameServer {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPlayerAvatarState(long playerId, SetPlayerAvatarState message) {
|
private void setPlayerAvatarState(int playerId, SetPlayerAvatarState message) {
|
||||||
players.get(playerId).setState(message.getState());
|
players.get(playerId).setState(message.getState());
|
||||||
this.sendInPlayersLocation(playerId, CommandType.SetUserAvatarState,
|
this.sendInPlayersLocation(playerId, CommandType.SetUserAvatarState,
|
||||||
new SetPlayerState(playerId, message.getState())
|
new SetPlayerState(playerId, message.getState())
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void processUserMessage(long playerId, UserMessage message) throws JsonProcessingException {
|
private void processUserMessage(int playerId, UserMessage message) throws JsonProcessingException {
|
||||||
log.info("GameServer.processUserMessage() message: {}", message);
|
log.info("GameServer.processUserMessage() message: {}", message);
|
||||||
switch (UserCommandType.fromString(message.getCommandType())) {
|
switch (UserCommandType.fromString(message.getCommandType())) {
|
||||||
case GetUserInitData -> {
|
case GetUserInitData -> {
|
||||||
@ -131,8 +131,8 @@ public class GameServer {
|
|||||||
case UserFriendsGet, GetOnlineUserFriends -> this.sendResult(playerId, message.getTransactionId(), users.getFriendsOfUser(playerId, players));
|
case UserFriendsGet, GetOnlineUserFriends -> this.sendResult(playerId, message.getTransactionId(), users.getFriendsOfUser(playerId, players));
|
||||||
case UserFriendsRequests -> this.sendResult(playerId, message.getTransactionId(), users.getRequestsOfUser(playerId, players));
|
case UserFriendsRequests -> this.sendResult(playerId, message.getTransactionId(), users.getRequestsOfUser(playerId, players));
|
||||||
case RevokeUserFriendship -> {
|
case RevokeUserFriendship -> {
|
||||||
users.removeFriendshipWithUser(playerId, Long.parseLong((String) message.getArguments().get(0).getValue()));
|
users.removeFriendshipWithUser(playerId, Integer.parseInt((String) message.getArguments().get(0).getValue()));
|
||||||
this.call(Long.parseLong((String) message.getArguments().get(0).getValue()), CommandType.OnFriendsRemoved, playerId);
|
this.call(Integer.parseInt((String) message.getArguments().get(0).getValue()), CommandType.OnFriendsRemoved, playerId);
|
||||||
}
|
}
|
||||||
case ApplyUserFriendship -> this.applyUserFriendship(playerId, (String) message.getArguments().get(0).getValue(), (String) message.getArguments().get(1).getValue());
|
case ApplyUserFriendship -> this.applyUserFriendship(playerId, (String) message.getArguments().get(0).getValue(), (String) message.getArguments().get(1).getValue());
|
||||||
case GetClubMap -> // todo: implement
|
case GetClubMap -> // todo: implement
|
||||||
@ -152,7 +152,9 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
long requestedLocation = ((Number) message.getArguments().get(1).getValue()).longValue();
|
long requestedLocation = ((Number) message.getArguments().get(1).getValue()).longValue();
|
||||||
if( requestedLocation == -1L ) {
|
if( requestedLocation == -1L ) {
|
||||||
this.sendResult(playerId, message.getTransactionId(), xmlMapper.writeValueAsString(locationService.getHomeByUserId(playerId)));
|
int homePlayerId = Integer.parseInt((String) message.getArguments().get(0).getValue());
|
||||||
|
this.players.get(playerId).setHomeId(homePlayerId);
|
||||||
|
this.sendResult(playerId, message.getTransactionId(), xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if( requestedLocation == -2L ) {
|
if( requestedLocation == -2L ) {
|
||||||
@ -184,14 +186,14 @@ public class GameServer {
|
|||||||
);
|
);
|
||||||
this.users.setWeaponsCount(playerId, this.users.getIntegerUserProperty(playerId, PlayerProperties.WeaponsCount, 15) - 1);
|
this.users.setWeaponsCount(playerId, this.users.getIntegerUserProperty(playerId, PlayerProperties.WeaponsCount, 15) - 1);
|
||||||
}
|
}
|
||||||
case GetUserInfo -> getUserInfo(playerId, ((Double) message.getArguments().get(0).getValue()).longValue(), message);
|
case GetUserInfo -> getUserInfo(playerId, ((Double) message.getArguments().get(0).getValue()).intValue(), message);
|
||||||
case GetUserAvatar -> getAvatar(playerId, message);
|
case GetUserAvatar -> getAvatar(playerId, message);
|
||||||
case SaveUserAvatarChanges -> saveAvatar(playerId, message);
|
case SaveUserAvatarChanges -> saveAvatar(playerId, message);
|
||||||
case GetUserUnlocks -> this.sendResult(playerId, message.getTransactionId(), "123");
|
case GetUserUnlocks -> this.sendResult(playerId, message.getTransactionId(), "123");
|
||||||
case GetSnInvitePanelData -> {}
|
case GetSnInvitePanelData -> {}
|
||||||
case GetGrantBlocks -> {}
|
case GetGrantBlocks -> {}
|
||||||
case UseMagicAbility -> this.sendInPlayersLocation(playerId, CommandType.UseMagicAbility, new UseMagicAbility(
|
case UseMagicAbility -> this.sendInPlayersLocation(playerId, CommandType.UseMagicAbility, new UseMagicAbility(
|
||||||
Long.parseLong((String) message.getArguments().get(0).getValue()),
|
Integer.parseInt((String) message.getArguments().get(0).getValue()),
|
||||||
((Double) message.getArguments().get(1).getValue()).intValue()
|
((Double) message.getArguments().get(1).getValue()).intValue()
|
||||||
));
|
));
|
||||||
case SetDefaultUserPhone -> {
|
case SetDefaultUserPhone -> {
|
||||||
@ -203,7 +205,7 @@ public class GameServer {
|
|||||||
this.users.setDefaultBackground(playerId, bgId);
|
this.users.setDefaultBackground(playerId, bgId);
|
||||||
}
|
}
|
||||||
case QueryUserFriendship -> {
|
case QueryUserFriendship -> {
|
||||||
long participantId = ((Double) message.getArguments().get(0).getValue()).longValue();
|
int participantId = ((Double) message.getArguments().get(0).getValue()).intValue();
|
||||||
relationshipService.sendRequest(playerId, participantId);
|
relationshipService.sendRequest(playerId, participantId);
|
||||||
this.call(participantId, CommandType.OnFriendshipRequestAdded,
|
this.call(participantId, CommandType.OnFriendshipRequestAdded,
|
||||||
new OneFR(
|
new OneFR(
|
||||||
@ -216,7 +218,7 @@ public class GameServer {
|
|||||||
this.sendResult(playerId, message.getTransactionId(), balance);
|
this.sendResult(playerId, message.getTransactionId(), balance);
|
||||||
}
|
}
|
||||||
case PhoneMessage -> {
|
case PhoneMessage -> {
|
||||||
long receiverId = message.getArguments().get(0).getType() == AMFValueType.NUMBER ? ((Double) message.getArguments().get(0).getValue()).longValue() : Long.parseLong((String) message.getArguments().get(0).getValue());
|
int receiverId = message.getArguments().get(0).getType() == AMFValueType.NUMBER ? ((Double) message.getArguments().get(0).getValue()).intValue() : Integer.parseInt((String) message.getArguments().get(0).getValue());
|
||||||
if (receiverId <= 0) return;
|
if (receiverId <= 0) return;
|
||||||
String messageText = ((String) message.getArguments().get(1).getValue());
|
String messageText = ((String) message.getArguments().get(1).getValue());
|
||||||
PhoneMessage pm = new PhoneMessage();
|
PhoneMessage pm = new PhoneMessage();
|
||||||
@ -239,7 +241,7 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
case CardMessage -> {
|
case CardMessage -> {
|
||||||
if( !subtractUsualTickets(playerId, 20) ) return;
|
if( !subtractUsualTickets(playerId, 20) ) return;
|
||||||
long receiverId = ((Number) message.getArguments().get(0).getValue()).longValue();
|
int receiverId = ((Number) message.getArguments().get(0).getValue()).intValue();
|
||||||
int postcardId = ((Number) message.getArguments().get(1).getValue()).intValue();
|
int postcardId = ((Number) message.getArguments().get(1).getValue()).intValue();
|
||||||
Postcard postcard = new Postcard();
|
Postcard postcard = new Postcard();
|
||||||
postcard.setIsNew(true);
|
postcard.setIsNew(true);
|
||||||
@ -264,7 +266,7 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void lockSomething(long playerId, int what2Lock, Boolean state, UserMessage message) {
|
private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) {
|
||||||
if( what2Lock == -2 ) {
|
if( what2Lock == -2 ) {
|
||||||
this.users.pushUserProperty(playerId, PlayerProperties.IsClubLocked, state);
|
this.users.pushUserProperty(playerId, PlayerProperties.IsClubLocked, state);
|
||||||
} else {
|
} else {
|
||||||
@ -273,12 +275,12 @@ public class GameServer {
|
|||||||
this.sendResult(playerId, message.getTransactionId(), state);
|
this.sendResult(playerId, message.getTransactionId(), state);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buySomething(long playerId, AMFObject obj, UserMessage message) {
|
private void buySomething(int playerId, AMFObject obj, UserMessage message) {
|
||||||
List<AMFObject> array = (List<AMFObject>) obj.getValue();
|
List<AMFObject> array = (List<AMFObject>) obj.getValue();
|
||||||
array.forEach(i -> this.buyOne(playerId, i, message));
|
array.forEach(i -> this.buyOne(playerId, i, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void buyOne(long playerId, AMFObject item, UserMessage message) {
|
private void buyOne(int playerId, AMFObject item, UserMessage message) {
|
||||||
Map<String, AMFObject> obj = (Map<String, AMFObject>) item.getValue();
|
Map<String, AMFObject> obj = (Map<String, AMFObject>) item.getValue();
|
||||||
long goodId = Long.parseLong((String) obj.get("GoodId").getValue());
|
long goodId = Long.parseLong((String) obj.get("GoodId").getValue());
|
||||||
boolean isMagic = ((Number) obj.get("Currency").getValue()).longValue() == 2;
|
boolean isMagic = ((Number) obj.get("Currency").getValue()).longValue() == 2;
|
||||||
@ -306,7 +308,7 @@ public class GameServer {
|
|||||||
this.sendResult(playerId, message.getTransactionId(), new BuyGoodResultGood(true, new ArrayList<>()));
|
this.sendResult(playerId, message.getTransactionId(), new BuyGoodResultGood(true, new ArrayList<>()));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean subtractUsualTickets(long userId, int amount) {
|
private boolean subtractUsualTickets(int userId, int amount) {
|
||||||
int val = this.users.getUsualTickets(userId);
|
int val = this.users.getUsualTickets(userId);
|
||||||
if ( val >= amount ) {
|
if ( val >= amount ) {
|
||||||
val -= amount;
|
val -= amount;
|
||||||
@ -317,7 +319,7 @@ public class GameServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean subtractMagicTickets(long userId, int amount) {
|
private boolean subtractMagicTickets(int userId, int amount) {
|
||||||
int val = this.users.getMagicTickets(userId);
|
int val = this.users.getMagicTickets(userId);
|
||||||
if ( val >= amount ) {
|
if ( val >= amount ) {
|
||||||
val -= amount;
|
val -= amount;
|
||||||
@ -328,14 +330,14 @@ public class GameServer {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void applyUserFriendship(Long userId, String acceptString, String denyString) {
|
private void applyUserFriendship(Integer userId, String acceptString, String denyString) {
|
||||||
List<Long> accepted = Arrays.stream(acceptString.split(","))
|
List<Integer> accepted = Arrays.stream(acceptString.split(","))
|
||||||
.filter(s -> !s.isEmpty())
|
.filter(s -> !s.isEmpty())
|
||||||
.map(Long::parseLong)
|
.map(Integer::parseInt)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
List<Long> denied = Arrays.stream(denyString.split(","))
|
List<Integer> denied = Arrays.stream(denyString.split(","))
|
||||||
.filter(s -> !s.isEmpty())
|
.filter(s -> !s.isEmpty())
|
||||||
.map(Long::parseLong)
|
.map(Integer::parseInt)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
users.acceptFriendshipWithUsers(userId, accepted);
|
users.acceptFriendshipWithUsers(userId, accepted);
|
||||||
users.denyFriendshipsWithUsers(userId, denied);
|
users.denyFriendshipsWithUsers(userId, denied);
|
||||||
@ -344,7 +346,7 @@ public class GameServer {
|
|||||||
accepted.forEach(uid -> this.call(uid, CommandType.OnFriendsAdded, m));
|
accepted.forEach(uid -> this.call(uid, CommandType.OnFriendsAdded, m));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void saveAvatar(long playerId, UserMessage message) {
|
private void saveAvatar(int playerId, UserMessage message) {
|
||||||
Map<String, AMFObject> changes = (Map<String, AMFObject>) message.getArguments().get(0).getValue();
|
Map<String, AMFObject> changes = (Map<String, AMFObject>) message.getArguments().get(0).getValue();
|
||||||
|
|
||||||
List<AMFObject> bodyParts = (List<AMFObject>) changes.get("BodyParts").getValue();
|
List<AMFObject> bodyParts = (List<AMFObject>) changes.get("BodyParts").getValue();
|
||||||
@ -369,22 +371,21 @@ public class GameServer {
|
|||||||
this.updateLocationPlayers(playerId, this.players.get(playerId).getLocationId());
|
this.updateLocationPlayers(playerId, this.players.get(playerId).getLocationId());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getAvatar(long playerId, UserMessage message) throws JsonProcessingException {
|
private void getAvatar(int playerId, UserMessage message) throws JsonProcessingException {
|
||||||
String r = xmlMapper.writeValueAsString(users.getUserAvatarByUserId(playerId));
|
String r = xmlMapper.writeValueAsString(users.getUserAvatarByUserId(playerId));
|
||||||
r = r.substring(13);
|
r = r.substring(13);
|
||||||
r = r.substring(0, r.length() - 14);
|
r = r.substring(0, r.length() - 14);
|
||||||
log.info("getAvatar: {}", r);
|
|
||||||
this.sendResult(playerId, message.getTransactionId(), r);
|
this.sendResult(playerId, message.getTransactionId(), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void getUserInfo(long playerId, long targetId, UserMessage message) throws JsonProcessingException {
|
private void getUserInfo(int playerId, int targetId, UserMessage message) throws JsonProcessingException {
|
||||||
String r = xmlMapper.writeValueAsString(new GetUserInfo(users.getUserInfoByUserId(targetId, false, playerId), users.getOtherUserAvatar(targetId)));
|
String r = xmlMapper.writeValueAsString(new GetUserInfo(users.getUserInfoByUserId(targetId, false, playerId), users.getOtherUserAvatar(targetId)));
|
||||||
r = r.substring(11);
|
r = r.substring(11);
|
||||||
r = r.substring(0, r.length()-12);
|
r = r.substring(0, r.length()-12);
|
||||||
this.sendResult(playerId, message.getTransactionId(), r);
|
this.sendResult(playerId, message.getTransactionId(), r);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setPlayerLocation(long playerId, SetLocationMessage message) {
|
private void setPlayerLocation(int playerId, SetLocationMessage message) {
|
||||||
Player p = this.players.get(playerId);
|
Player p = this.players.get(playerId);
|
||||||
this.deleteSelf(playerId, p.getLocationId());
|
this.deleteSelf(playerId, p.getLocationId());
|
||||||
int prevLocation = p.getLocationId();
|
int prevLocation = p.getLocationId();
|
||||||
@ -392,23 +393,22 @@ public class GameServer {
|
|||||||
p.setX((Double) message.getCoordinates().get("x").getValue());
|
p.setX((Double) message.getCoordinates().get("x").getValue());
|
||||||
p.setY((Double) message.getCoordinates().get("y").getValue());
|
p.setY((Double) message.getCoordinates().get("y").getValue());
|
||||||
p.setState(message.getStartState());
|
p.setState(message.getStartState());
|
||||||
log.info("updateLocationPlayers: {} => {}", prevLocation, p.getLocationId());
|
|
||||||
this.updateLocationPlayers(playerId, prevLocation);
|
this.updateLocationPlayers(playerId, prevLocation);
|
||||||
this.sendResult(playerId, message.getTransactionId(), "");
|
this.sendResult(playerId, message.getTransactionId(), "");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void deleteSelf(long playerId, int locationId) {
|
private void deleteSelf(int playerId, int locationId) {
|
||||||
this.sendInLocation(locationId, CommandType.RemoveUserFromLocation, playerId);
|
Player p = this.players.get(playerId);
|
||||||
|
this.sendInLocation(locationId, p.getHomeId(), CommandType.RemoveUserFromLocation, playerId);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void updateLocationPlayers(long playerId, int prevLocation) {
|
private void updateLocationPlayers(int playerId, int prevLocation) {
|
||||||
int locationId = this.players.get(playerId).getLocationId();
|
int locationId = this.players.get(playerId).getLocationId();
|
||||||
log.info("removeUserFromLocation {}", locationId);
|
long homeId = this.players.get(playerId).getHomeId();
|
||||||
this.sendInLocation(prevLocation, CommandType.RemoveUserFromLocation, playerId);
|
this.sendInLocation(prevLocation, homeId, CommandType.RemoveUserFromLocation, playerId);
|
||||||
for( int i = 0; i < 3; i++ ) {
|
for( int i = 0; i < 3; i++ ) {
|
||||||
try {
|
try {
|
||||||
Thread.sleep(300);
|
Thread.sleep(300);
|
||||||
log.info("addUserToLocation1");
|
|
||||||
this.sendInPlayersLocation(playerId, CommandType.AddUserToLocation, new AddUserToLocation(
|
this.sendInPlayersLocation(playerId, CommandType.AddUserToLocation, new AddUserToLocation(
|
||||||
playerId,
|
playerId,
|
||||||
users.getAvatarById(playerId, this.players.get(playerId))
|
users.getAvatarById(playerId, this.players.get(playerId))
|
||||||
@ -420,7 +420,7 @@ public class GameServer {
|
|||||||
this.players.keySet().forEach(pid -> {
|
this.players.keySet().forEach(pid -> {
|
||||||
Player p = this.players.get(pid);
|
Player p = this.players.get(pid);
|
||||||
if( p.getLocationId() != locationId ) return;
|
if( p.getLocationId() != locationId ) return;
|
||||||
log.info("addUserToLocation2");
|
if( p.getLocationId() == -1 && p.getHomeId() != homeId ) return;
|
||||||
this.call(playerId, CommandType.AddUserToLocation, new AddUserToLocation(
|
this.call(playerId, CommandType.AddUserToLocation, new AddUserToLocation(
|
||||||
pid,
|
pid,
|
||||||
users.getAvatarById(pid, this.players.get(pid))
|
users.getAvatarById(pid, this.players.get(pid))
|
||||||
@ -432,26 +432,28 @@ public class GameServer {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendInPlayersLocation(long playerId, CommandType type, Object obj) {
|
private void sendInPlayersLocation(int playerId, CommandType type, Object obj) {
|
||||||
this.sendInLocation(players.get(playerId).getLocationId(), type, obj);
|
Player player = this.players.get(playerId);
|
||||||
|
this.sendInLocation(player.getLocationId(), player.getHomeId(), type, obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendInLocation(int locationId, CommandType type, Object obj) {
|
private void sendInLocation(int locationId, long playersHome, CommandType type, Object obj) {
|
||||||
players.keySet().forEach(k -> {
|
players.keySet().forEach(k -> {
|
||||||
if( locationId != players.get(k).getLocationId() ) return;
|
if( locationId != players.get(k).getLocationId() ) return;
|
||||||
|
if( locationId == -1 && players.get(k).getHomeId() != playersHome) return;
|
||||||
this.call(k, type, obj);
|
this.call(k, type, obj);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendResult(long playerId, double tid, Object obj) {
|
private void sendResult(int playerId, double tid, Object obj) {
|
||||||
this.sendMessage(playerId, new CallMessage("_result", tid, null, obj));
|
this.sendMessage(playerId, new CallMessage("_result", tid, null, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void call(long playerId, CommandType function, Object obj) {
|
private void call(int playerId, CommandType function, Object obj) {
|
||||||
this.sendMessage(playerId, new CallMessage(function.getValue(), 0d, null, obj));
|
this.sendMessage(playerId, new CallMessage(function.getValue(), 0d, null, obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendMessage(long playerId, Object obj) {
|
private void sendMessage(int playerId, Object obj) {
|
||||||
try {
|
try {
|
||||||
this.players.get(playerId)
|
this.players.get(playerId)
|
||||||
.getConnection()
|
.getConnection()
|
||||||
@ -461,7 +463,7 @@ public class GameServer {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onDisconnect(long playerId) {
|
public void onDisconnect(int playerId) {
|
||||||
log.warn("GameServer.onDisconnect() close: {}", playerId);
|
log.warn("GameServer.onDisconnect() close: {}", playerId);
|
||||||
if( !this.players.containsKey(playerId) ) return;
|
if( !this.players.containsKey(playerId) ) return;
|
||||||
this.deleteSelf(playerId, this.players.get(playerId).getLocationId());
|
this.deleteSelf(playerId, this.players.get(playerId).getLocationId());
|
||||||
|
@ -10,7 +10,7 @@ public class ReferenceLoader {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private UserRepository userRepository;
|
private UserRepository userRepository;
|
||||||
|
|
||||||
public User getUserReference(Long userId) {
|
public User getUserReference(Integer userId) {
|
||||||
return userRepository.getReferenceById(userId);
|
return userRepository.getReferenceById(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,6 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class ChatMessage {
|
public class ChatMessage {
|
||||||
private Long playerId;
|
private Integer playerId;
|
||||||
private String text;
|
private String text;
|
||||||
}
|
}
|
@ -15,4 +15,5 @@ public class Player {
|
|||||||
private double y;
|
private double y;
|
||||||
private int locationId;
|
private int locationId;
|
||||||
private double state;
|
private double state;
|
||||||
|
private long homeId;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SetPlayerPosition {
|
public class SetPlayerPosition {
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
private Point point;
|
private Point point;
|
||||||
private Long tweenerId;
|
private Long tweenerId;
|
||||||
}
|
}
|
||||||
|
@ -6,6 +6,6 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class SetPlayerState {
|
public class SetPlayerState {
|
||||||
private Long playerId;
|
private Integer playerId;
|
||||||
private Double state;
|
private Double state;
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,7 @@ import lombok.Getter;
|
|||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class Shoot {
|
public class Shoot {
|
||||||
private Long playerId;
|
private Integer playerId;
|
||||||
private Double x;
|
private Double x;
|
||||||
private Double y;
|
private Double y;
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,6 @@ import lombok.AllArgsConstructor;
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class UseMagicAbility {
|
public class UseMagicAbility {
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
private Integer magicId;
|
private Integer magicId;
|
||||||
}
|
}
|
||||||
|
@ -8,7 +8,7 @@ import lombok.NoArgsConstructor;
|
|||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class UserFriend {
|
public class UserFriend {
|
||||||
@AMFKey(name = "UserId")
|
@AMFKey(name = "UserId")
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
|
|
||||||
@AMFKey(name = "SnName")
|
@AMFKey(name = "SnName")
|
||||||
private String snName;
|
private String snName;
|
||||||
|
@ -24,10 +24,10 @@ import java.util.List;
|
|||||||
@JacksonXmlRootElement(localName = "user")
|
@JacksonXmlRootElement(localName = "user")
|
||||||
public class UserInfo {
|
public class UserInfo {
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "UserId")
|
@JacksonXmlProperty(isAttribute = true, localName = "UserId")
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
@JacksonXmlProperty(isAttribute = true, localName = "Id")
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "RoleFlags")
|
@JacksonXmlProperty(isAttribute = true, localName = "RoleFlags")
|
||||||
@JsonSerialize(using = RoleFlagsSerializer.class)
|
@JsonSerialize(using = RoleFlagsSerializer.class)
|
||||||
|
@ -5,6 +5,6 @@ import lombok.AllArgsConstructor;
|
|||||||
|
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public class AddUserToLocation {
|
public class AddUserToLocation {
|
||||||
private Long playerId;
|
private Integer playerId;
|
||||||
private PlayerAvatar avatar;
|
private PlayerAvatar avatar;
|
||||||
}
|
}
|
||||||
|
@ -49,7 +49,7 @@ public class LocationObject {
|
|||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "OwnerId")
|
@JacksonXmlProperty(isAttribute = true, localName = "OwnerId")
|
||||||
private Long ownerId;
|
private Integer ownerId;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "OwnerName")
|
@JacksonXmlProperty(isAttribute = true, localName = "OwnerName")
|
||||||
private String ownerName;
|
private String ownerName;
|
||||||
|
@ -21,7 +21,7 @@ public class ConnectedProcessor extends ConnectionProcessor {
|
|||||||
private final List<Byte> message;
|
private final List<Byte> message;
|
||||||
private byte lastStreamId;
|
private byte lastStreamId;
|
||||||
private final GameServer gameServer;
|
private final GameServer gameServer;
|
||||||
private Long playerId;
|
private Integer playerId;
|
||||||
private final RTMPSession rtmpSessionInfo;
|
private final RTMPSession rtmpSessionInfo;
|
||||||
|
|
||||||
public ConnectedProcessor(InputStream inputStream, OutputStream outputStream, Socket sock, GameServer gameServer) {
|
public ConnectedProcessor(InputStream inputStream, OutputStream outputStream, Socket sock, GameServer gameServer) {
|
||||||
@ -167,7 +167,7 @@ public class ConnectedProcessor extends ConnectionProcessor {
|
|||||||
if( !mr.isEmpty() &&
|
if( !mr.isEmpty() &&
|
||||||
mr.get(0).getType() == AMFValueType.STRING &&
|
mr.get(0).getType() == AMFValueType.STRING &&
|
||||||
mr.get(0).getValue().equals("connect") ) {
|
mr.get(0).getValue().equals("connect") ) {
|
||||||
this.playerId = Long.parseLong((String) mr.get(3).getValue());
|
this.playerId = Integer.parseInt((String) mr.get(3).getValue());
|
||||||
this.gameServer.onConnect(this.playerId, (String) mr.get(5).getValue(), this);
|
this.gameServer.onConnect(this.playerId, (String) mr.get(5).getValue(), this);
|
||||||
|
|
||||||
this.getOutputStream().write( StringUtils.hexStringToByteArray("020000000000040500000000002625A0020000000000050600000000002625A00202000000000004010000000000001000030000000000F214000000000200075F726573756C74003FF0000000000000030006666D7356657202000E464D532F342C302C302C31313231000C6361706162696C697469657300406FE0000000000000046D6F6465003FF00000000000000000090300056C6576656C0200067374617475730004636F646502001D4E6574436F6E6E656374696F6E2E436F6E6E6563742E53756363657373000B6465736372697074696F6E020015436F6E6E656374696F6E207375636365656465642E000E6F626A656374456E636F64696E670000000000000000000004646174610800000000000776657273696F6E02000A342C302C302C31313231000009000009") );
|
this.getOutputStream().write( StringUtils.hexStringToByteArray("020000000000040500000000002625A0020000000000050600000000002625A00202000000000004010000000000001000030000000000F214000000000200075F726573756C74003FF0000000000000030006666D7356657202000E464D532F342C302C302C31313231000C6361706162696C697469657300406FE0000000000000046D6F6465003FF00000000000000000090300056C6576656C0200067374617475730004636F646502001D4E6574436F6E6E656374696F6E2E436F6E6E6563742E53756363657373000B6465736372697074696F6E020015436F6E6E656374696F6E207375636365656465642E000E6F626A656374456E636F64696E670000000000000000000004646174610800000000000776657273696F6E02000A342C302C302C31313231000009000009") );
|
||||||
|
@ -103,7 +103,7 @@ public class SignUpController {
|
|||||||
return ResponseEntity.badRequest().body("bad_credentials_format");
|
return ResponseEntity.badRequest().body("bad_credentials_format");
|
||||||
}
|
}
|
||||||
|
|
||||||
long userId = userService.saveUser(username, password, Role.RoleType.RoleUser);
|
int userId = userService.saveUser(username, password, Role.RoleType.RoleUser);
|
||||||
|
|
||||||
avatarInventoryService.addPhoneToInventory(userId, 1L);
|
avatarInventoryService.addPhoneToInventory(userId, 1L);
|
||||||
avatarInventoryService.addBackgroundToInventory(userId, 339L);
|
avatarInventoryService.addBackgroundToInventory(userId, 339L);
|
||||||
|
@ -17,7 +17,7 @@ import java.time.LocalDateTime;
|
|||||||
public class ServerActionUser extends ServerActionCData {
|
public class ServerActionUser extends ServerActionCData {
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "UserId")
|
@JacksonXmlProperty(isAttribute = true, localName = "UserId")
|
||||||
private Long userId;
|
private Integer userId;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true)
|
@JacksonXmlProperty(isAttribute = true)
|
||||||
private String hwId;
|
private String hwId;
|
||||||
|
@ -30,11 +30,11 @@ public class PhoneMessage {
|
|||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "SenderId")
|
@JacksonXmlProperty(isAttribute = true, localName = "SenderId")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long senderId;
|
private Integer senderId;
|
||||||
|
|
||||||
@JsonIgnore
|
@JsonIgnore
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long receiverId;
|
private Integer receiverId;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "SenderName")
|
@JacksonXmlProperty(isAttribute = true, localName = "SenderName")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@ -30,10 +30,10 @@ public class Postcard {
|
|||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "SenderId")
|
@JacksonXmlProperty(isAttribute = true, localName = "SenderId")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long senderId;
|
private Integer senderId;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long receiverId;
|
private Integer receiverId;
|
||||||
|
|
||||||
@JacksonXmlProperty(isAttribute = true, localName = "SenderName")
|
@JacksonXmlProperty(isAttribute = true, localName = "SenderName")
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
|
@ -16,10 +16,10 @@ public class Relationship {
|
|||||||
private Long id;
|
private Long id;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long senderId;
|
private Integer senderId;
|
||||||
|
|
||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Long recepientId;
|
private Integer recepientId;
|
||||||
|
|
||||||
@Enumerated(value = EnumType.STRING)
|
@Enumerated(value = EnumType.STRING)
|
||||||
private FriendshipStatus status;
|
private FriendshipStatus status;
|
||||||
|
@ -30,7 +30,7 @@ public class User {
|
|||||||
|
|
||||||
@Id
|
@Id
|
||||||
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
@GeneratedValue(strategy = GenerationType.IDENTITY)
|
||||||
private Long id;
|
private Integer id;
|
||||||
|
|
||||||
@Column(nullable = false, unique = true)
|
@Column(nullable = false, unique = true)
|
||||||
private String username;
|
private String username;
|
||||||
@ -49,7 +49,7 @@ public class User {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private Boolean isBanned = false;
|
private Boolean isBanned = false;
|
||||||
|
|
||||||
public User(Long id, String username) {
|
public User(Integer id, String username) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.username = username;
|
this.username = username;
|
||||||
}
|
}
|
||||||
|
@ -21,28 +21,28 @@ import java.util.Optional;
|
|||||||
public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory, Long> {
|
public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory, Long> {
|
||||||
|
|
||||||
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type")
|
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type")
|
||||||
List<AvatarInventory> findItemsByUserIdAndType(@Param("uid") Long userId, @Param("type") AvatarInventoryType type);
|
List<AvatarInventory> findItemsByUserIdAndType(@Param("uid") Integer userId, @Param("type") AvatarInventoryType type);
|
||||||
|
|
||||||
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type AND a.isUsed = true")
|
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type AND a.isUsed = true")
|
||||||
List<AvatarInventory> findUsedItemsByUserIdAndType(@Param("uid") Long userId, @Param("type") AvatarInventoryType type);
|
List<AvatarInventory> findUsedItemsByUserIdAndType(@Param("uid") Integer userId, @Param("type") AvatarInventoryType type);
|
||||||
|
|
||||||
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type AND a.goodId = :good_id")
|
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = :type AND a.goodId = :good_id")
|
||||||
Optional<AvatarInventory> findSpecificitem(@Param("uid") Long userId, @Param("type") AvatarInventoryType type, @Param("good_id") Long goodId);
|
Optional<AvatarInventory> findSpecificitem(@Param("uid") Integer userId, @Param("type") AvatarInventoryType type, @Param("good_id") Long goodId);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "UPDATE AvatarInventory a SET a.isUsed = false WHERE a.user.id = :userId AND a.type = :type")
|
@Query(value = "UPDATE AvatarInventory a SET a.isUsed = false WHERE a.user.id = :userId AND a.type = :type")
|
||||||
void resetUsed(@Param("userId") Long userId, @Param("type") AvatarInventoryType type);
|
void resetUsed(@Param("userId") Integer userId, @Param("type") AvatarInventoryType type);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "UPDATE AvatarInventory a SET a.isUsed = true WHERE a.user.id = :userId AND a.type = :type AND a.goodId = :goodId")
|
@Query(value = "UPDATE AvatarInventory a SET a.isUsed = true WHERE a.user.id = :userId AND a.type = :type AND a.goodId = :goodId")
|
||||||
void setUsed(@Param("userId") Long userId, @Param("goodId") Long goodId, @Param("type") AvatarInventoryType type);
|
void setUsed(@Param("userId") Integer userId, @Param("goodId") Long goodId, @Param("type") AvatarInventoryType type);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "UPDATE AvatarInventory a SET a.color = :color WHERE a.user.id = :userId AND a.type = :type AND a.goodId = :goodId")
|
@Query(value = "UPDATE AvatarInventory a SET a.color = :color WHERE a.user.id = :userId AND a.type = :type AND a.goodId = :goodId")
|
||||||
void setColor(@Param("userId") Long userId, @Param("goodId") Long goodId, @Param("type") AvatarInventoryType type, @Param("color") Integer color);
|
void setColor(@Param("userId") Integer userId, @Param("goodId") Long goodId, @Param("type") AvatarInventoryType type, @Param("color") Integer color);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -62,7 +62,7 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
JOIN goods AS g
|
JOIN goods AS g
|
||||||
ON a.good_id = g.id
|
ON a.good_id = g.id
|
||||||
WHERE a.user_id = :uid AND a.type = :#{#goodTypeId.getVal().name()}""", nativeQuery = true)
|
WHERE a.user_id = :uid AND a.type = :#{#goodTypeId.getVal().name()}""", nativeQuery = true)
|
||||||
List<InventoryItem> findInventoryItems(@Param("uid") Long userId, @Param("goodTypeId") GoodClothType goodClothType);
|
List<InventoryItem> findInventoryItems(@Param("uid") Integer userId, @Param("goodTypeId") GoodClothType goodClothType);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -81,7 +81,7 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
FROM backgrounds b
|
FROM backgrounds b
|
||||||
JOIN (SELECT a.good_id, a.is_used FROM avatar_inventory a WHERE a.`type` = 'Backgrounds' AND a.user_id = :uid) AS a
|
JOIN (SELECT a.good_id, a.is_used FROM avatar_inventory a WHERE a.`type` = 'Backgrounds' AND a.user_id = :uid) AS a
|
||||||
ON a.good_id = b.id""", nativeQuery = true)
|
ON a.good_id = b.id""", nativeQuery = true)
|
||||||
List<InventoryItem> findBackgrounds(@Param("uid") Long userId);
|
List<InventoryItem> findBackgrounds(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -100,7 +100,7 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
FROM phone_icons p
|
FROM phone_icons p
|
||||||
JOIN (SELECT a.good_id, a.is_used FROM avatar_inventory a WHERE a.`type` = 'Phones' AND a.user_id = :uid) AS a
|
JOIN (SELECT a.good_id, a.is_used FROM avatar_inventory a WHERE a.`type` = 'Phones' AND a.user_id = :uid) AS a
|
||||||
ON a.good_id = p.id""", nativeQuery = true)
|
ON a.good_id = p.id""", nativeQuery = true)
|
||||||
List<InventoryItem> findPhones(@Param("uid") Long userId);
|
List<InventoryItem> findPhones(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -116,7 +116,7 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
FROM bodyparts b
|
FROM bodyparts b
|
||||||
JOIN (SELECT a.color, a.good_id FROM avatar_inventory a WHERE a.user_id = :uid AND a.`type` = 'BodyParts' AND a.is_used = true) AS a
|
JOIN (SELECT a.color, a.good_id FROM avatar_inventory a WHERE a.user_id = :uid AND a.`type` = 'BodyParts' AND a.is_used = true) AS a
|
||||||
ON a.good_id = b.id""", nativeQuery = true)
|
ON a.good_id = b.id""", nativeQuery = true)
|
||||||
List<IBodyAvatarItem> findUsedBodyPartsByUserId(@Param("uid") Long userId);
|
List<IBodyAvatarItem> findUsedBodyPartsByUserId(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT
|
SELECT
|
||||||
@ -132,7 +132,7 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
FROM goods g
|
FROM goods g
|
||||||
JOIN (SELECT a.good_id FROM avatar_inventory a WHERE a.user_id = :uid AND a.`type` = :#{#goodTypeId.getVal().name()} AND a.is_used = true) AS a
|
JOIN (SELECT a.good_id FROM avatar_inventory a WHERE a.user_id = :uid AND a.`type` = :#{#goodTypeId.getVal().name()} AND a.is_used = true) AS a
|
||||||
ON a.good_id = g.id""", nativeQuery = true)
|
ON a.good_id = g.id""", nativeQuery = true)
|
||||||
List<IBodyAvatarItem> findUsedClothesByUserId(@Param("uid") Long userId, @Param("goodTypeId") GoodClothType goodClothType);
|
List<IBodyAvatarItem> findUsedClothesByUserId(@Param("uid") Integer userId, @Param("goodTypeId") GoodClothType goodClothType);
|
||||||
|
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
@ -143,8 +143,8 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
|
|||||||
FROM gms g
|
FROM gms g
|
||||||
JOIN (SELECT a.good_id FROM avatar_inventory a WHERE a.`type` = 'Magic' AND a.user_id = :uid) a
|
JOIN (SELECT a.good_id FROM avatar_inventory a WHERE a.`type` = 'Magic' AND a.user_id = :uid) a
|
||||||
ON g.id = a.good_id""", nativeQuery = true)
|
ON g.id = a.good_id""", nativeQuery = true)
|
||||||
List<InitMagicAbility> findMagicAbilitiesByUserId(@Param("uid") Long userId);
|
List<InitMagicAbility> findMagicAbilitiesByUserId(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Query(value = "SELECT s FROM Smile s WHERE s.id IN (SELECT a.goodId FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = 'Smile')")
|
@Query(value = "SELECT s FROM Smile s WHERE s.id IN (SELECT a.goodId FROM AvatarInventory a WHERE a.user.id = :uid AND a.type = 'Smile')")
|
||||||
List<Smile> findSmilesByUserId(@Param("uid") Long userId);
|
List<Smile> findSmilesByUserId(@Param("uid") Integer userId);
|
||||||
}
|
}
|
||||||
|
@ -57,5 +57,5 @@ public interface BodyPartRepository extends JpaRepository<BodyPart, Long> {
|
|||||||
) AS a
|
) AS a
|
||||||
WHERE a.`type` = :#{#type.name()}
|
WHERE a.`type` = :#{#type.name()}
|
||||||
GROUP BY a.id, a.`type`, a.media_resource_id, a.is_colorable""", nativeQuery = true)
|
GROUP BY a.id, a.`type`, a.media_resource_id, a.is_colorable""", nativeQuery = true)
|
||||||
List<InventoryItem> findInventoryItems(@Param("uid") Long userId, @Param("type") BodyPartType type);
|
List<InventoryItem> findInventoryItems(@Param("uid") Integer userId, @Param("type") BodyPartType type);
|
||||||
}
|
}
|
@ -15,7 +15,7 @@ import java.util.Optional;
|
|||||||
public interface OnlineStatusRepository extends JpaRepository<OnlineStatus, Long> {
|
public interface OnlineStatusRepository extends JpaRepository<OnlineStatus, Long> {
|
||||||
|
|
||||||
@Query(value = "SELECT o FROM OnlineStatus o WHERE o.user.id = :userId")
|
@Query(value = "SELECT o FROM OnlineStatus o WHERE o.user.id = :userId")
|
||||||
List<OnlineStatus> findByUserId(@Param("userId") Long userId);
|
List<OnlineStatus> findByUserId(@Param("userId") Integer userId);
|
||||||
|
|
||||||
@Query(value = "SELECT o FROM OnlineStatus o WHERE o.lastPingUnix < :pingTime")
|
@Query(value = "SELECT o FROM OnlineStatus o WHERE o.lastPingUnix < :pingTime")
|
||||||
List<OnlineStatus> listPingsOlderThan(@Param("pingTime") Long pingTime);
|
List<OnlineStatus> listPingsOlderThan(@Param("pingTime") Long pingTime);
|
||||||
|
@ -17,7 +17,7 @@ public interface PhoneMessageRepository extends JpaRepository<PhoneMessage, Long
|
|||||||
Optional<PhoneMessage> findById(Long id);
|
Optional<PhoneMessage> findById(Long id);
|
||||||
|
|
||||||
@Query(value = "SELECT p FROM PhoneMessage p WHERE p.receiverId = :uid")
|
@Query(value = "SELECT p FROM PhoneMessage p WHERE p.receiverId = :uid")
|
||||||
List<PhoneMessage> findByReceiverId(@Param("uid") Long id);
|
List<PhoneMessage> findByReceiverId(@Param("uid") Integer id);
|
||||||
|
|
||||||
List<PhoneMessage> findAll();
|
List<PhoneMessage> findAll();
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public interface PostcardRepository extends JpaRepository<Postcard, Long> {
|
|||||||
List<Postcard> findAll();
|
List<Postcard> findAll();
|
||||||
|
|
||||||
@Query(value = "SELECT p FROM Postcard p WHERE p.receiverId = :user_id")
|
@Query(value = "SELECT p FROM Postcard p WHERE p.receiverId = :user_id")
|
||||||
List<Postcard> findByReceiverId(@Param("user_id") Long userId);
|
List<Postcard> findByReceiverId(@Param("user_id") Integer userId);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
|
@ -15,7 +15,7 @@ import java.util.Optional;
|
|||||||
@Repository
|
@Repository
|
||||||
public interface RelationshipRepository extends JpaRepository<Relationship, Long> {
|
public interface RelationshipRepository extends JpaRepository<Relationship, Long> {
|
||||||
@Query(value = "SELECT r FROM Relationship r WHERE ((r.senderId = :userf AND r.recepientId = :users) OR (r.senderId = :users AND r.recepientId = :userf)) AND r.status = :rel")
|
@Query(value = "SELECT r FROM Relationship r WHERE ((r.senderId = :userf AND r.recepientId = :users) OR (r.senderId = :users AND r.recepientId = :userf)) AND r.status = :rel")
|
||||||
Optional<Relationship> findRelation(@Param("userf") Long userId, @Param("users") Long userId1, @Param("rel") Relationship.FriendshipStatus state);
|
Optional<Relationship> findRelation(@Param("userf") Integer userId, @Param("users") Integer userId1, @Param("rel") Relationship.FriendshipStatus state);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@ -40,7 +40,7 @@ public interface RelationshipRepository extends JpaRepository<Relationship, Long
|
|||||||
) r
|
) r
|
||||||
ON r.userId = u.id
|
ON r.userId = u.id
|
||||||
""")
|
""")
|
||||||
List<User> findFriendsOfUserById(@Param("uid") Long userId);
|
List<User> findFriendsOfUserById(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Query(value = """
|
@Query(value = """
|
||||||
SELECT new User(r.userId, u.username)
|
SELECT new User(r.userId, u.username)
|
||||||
@ -53,12 +53,12 @@ public interface RelationshipRepository extends JpaRepository<Relationship, Long
|
|||||||
) r
|
) r
|
||||||
ON r.userId = u.id
|
ON r.userId = u.id
|
||||||
""")
|
""")
|
||||||
List<User> findRequestsOfUserById(@Param("uid") Long userId);
|
List<User> findRequestsOfUserById(@Param("uid") Integer userId);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "DELETE FROM Relationship r WHERE ((r.senderId = :uidf AND r.recepientId = :uids) OR (r.senderId = :uids AND r.recepientId = :uidf)) AND r.status = com.alterdekim.game.entity.Relationship$FriendshipStatus.Friendship")
|
@Query(value = "DELETE FROM Relationship r WHERE ((r.senderId = :uidf AND r.recepientId = :uids) OR (r.senderId = :uids AND r.recepientId = :uidf)) AND r.status = com.alterdekim.game.entity.Relationship$FriendshipStatus.Friendship")
|
||||||
void deleteFriendshipByUserIds(@Param("uidf") Long userId1, @Param("uids") Long userId2);
|
void deleteFriendshipByUserIds(@Param("uidf") Integer userId1, @Param("uids") Integer userId2);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@ -71,7 +71,7 @@ public interface RelationshipRepository extends JpaRepository<Relationship, Long
|
|||||||
(r.recepientId = :uid AND r.senderId IN :l) OR
|
(r.recepientId = :uid AND r.senderId IN :l) OR
|
||||||
(r.senderId = :uid AND r.recepientId IN :l)
|
(r.senderId = :uid AND r.recepientId IN :l)
|
||||||
)""")
|
)""")
|
||||||
void acceptFriendshipWithUsers(@Param("uid") Long userId, @Param("l") List<Long> users);
|
void acceptFriendshipWithUsers(@Param("uid") Integer userId, @Param("l") List<Integer> users);
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@ -82,5 +82,5 @@ public interface RelationshipRepository extends JpaRepository<Relationship, Long
|
|||||||
(r.recepientId = :uid AND r.senderId IN :l) OR
|
(r.recepientId = :uid AND r.senderId IN :l) OR
|
||||||
(r.senderId = :uid AND r.recepientId IN :l)
|
(r.senderId = :uid AND r.recepientId IN :l)
|
||||||
)""")
|
)""")
|
||||||
void denyFriendshipsWithUsers(@Param("uid") Long userId, @Param("l") List<Long> users);
|
void denyFriendshipsWithUsers(@Param("uid") Integer userId, @Param("l") List<Integer> users);
|
||||||
}
|
}
|
||||||
|
@ -17,12 +17,12 @@ public interface UserPropertyRepository extends JpaRepository<UserProperty, Long
|
|||||||
Optional<UserProperty> findById(Long id);
|
Optional<UserProperty> findById(Long id);
|
||||||
|
|
||||||
@Query(value = "SELECT u FROM UserProperty u WHERE u.user.id = :uid AND u.type = :type")
|
@Query(value = "SELECT u FROM UserProperty u WHERE u.user.id = :uid AND u.type = :type")
|
||||||
Optional<UserProperty> findByUserIdAndTag(@Param("uid") Long userId, @Param("type") PlayerProperties property);
|
Optional<UserProperty> findByUserIdAndTag(@Param("uid") Integer userId, @Param("type") PlayerProperties property);
|
||||||
|
|
||||||
List<UserProperty> findAll();
|
List<UserProperty> findAll();
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Modifying
|
@Modifying
|
||||||
@Query(value = "DELETE FROM UserProperty u WHERE u.user.id = :uid AND u.type = :type")
|
@Query(value = "DELETE FROM UserProperty u WHERE u.user.id = :uid AND u.type = :type")
|
||||||
void deleteByUserIdAndType(@Param("uid") Long userId, @Param("type") PlayerProperties properties);
|
void deleteByUserIdAndType(@Param("uid") Integer userId, @Param("type") PlayerProperties properties);
|
||||||
}
|
}
|
||||||
|
@ -9,7 +9,7 @@ import org.springframework.data.repository.query.Param;
|
|||||||
import org.springframework.stereotype.Repository;
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
@Repository
|
@Repository
|
||||||
public interface UserRepository extends JpaRepository<User, Long> {
|
public interface UserRepository extends JpaRepository<User, Integer> {
|
||||||
User findByUsername(String username);
|
User findByUsername(String username);
|
||||||
|
|
||||||
@Query(value = "SELECT COUNT(u) FROM User u")
|
@Query(value = "SELECT COUNT(u) FROM User u")
|
||||||
|
@ -57,28 +57,28 @@ public class AvatarInventoryService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private PhoneIconService phoneIconService;
|
private PhoneIconService phoneIconService;
|
||||||
|
|
||||||
public void setDefault(Long userId, Long goodId, AvatarInventoryType type) {
|
public void setDefault(Integer userId, Long goodId, AvatarInventoryType type) {
|
||||||
this.inventoryRepository.resetUsed(userId, type);
|
this.inventoryRepository.resetUsed(userId, type);
|
||||||
this.inventoryRepository.setUsed(userId, goodId, type);
|
this.inventoryRepository.setUsed(userId, goodId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsed(Long userId, Long goodId, AvatarInventoryType type) {
|
public void setUsed(Integer userId, Long goodId, AvatarInventoryType type) {
|
||||||
this.inventoryRepository.setUsed(userId, goodId, type);
|
this.inventoryRepository.setUsed(userId, goodId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetUsed(Long userId, AvatarInventoryType type) {
|
public void resetUsed(Integer userId, AvatarInventoryType type) {
|
||||||
this.inventoryRepository.resetUsed(userId, type);
|
this.inventoryRepository.resetUsed(userId, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Long userId, Long goodId, AvatarInventoryType type, Integer color) {
|
public void setColor(Integer userId, Long goodId, AvatarInventoryType type, Integer color) {
|
||||||
this.inventoryRepository.setColor(userId, goodId, type, color);
|
this.inventoryRepository.setColor(userId, goodId, type, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSpecificItemExists(Long userId, AvatarInventoryType type, Long goodId) {
|
public boolean isSpecificItemExists(Integer userId, AvatarInventoryType type, Long goodId) {
|
||||||
return this.inventoryRepository.findSpecificitem(userId, type, goodId).isPresent();
|
return this.inventoryRepository.findSpecificitem(userId, type, goodId).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryGroup getBodyPartInventoryGroup(Long userId, BodyPartType type, boolean addEmpty) {
|
public InventoryGroup getBodyPartInventoryGroup(Integer userId, BodyPartType type, boolean addEmpty) {
|
||||||
return new InventoryGroup(
|
return new InventoryGroup(
|
||||||
type.getValue(),
|
type.getValue(),
|
||||||
type.getTextResourceId(),
|
type.getTextResourceId(),
|
||||||
@ -149,7 +149,7 @@ public class AvatarInventoryService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public InventoryGroup getClothInventoryGroup(Long userId, GoodClothType type) {
|
public InventoryGroup getClothInventoryGroup(Integer userId, GoodClothType type) {
|
||||||
return new InventoryGroup(
|
return new InventoryGroup(
|
||||||
type.getVal().getGoodType(),
|
type.getVal().getGoodType(),
|
||||||
type.getTextResourceId(),
|
type.getTextResourceId(),
|
||||||
@ -160,7 +160,7 @@ public class AvatarInventoryService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IBodyAvatarItem> getWholeAvatarByUserId(Long userId) {
|
public List<IBodyAvatarItem> getWholeAvatarByUserId(Integer userId) {
|
||||||
return Stream.of(this.inventoryRepository.findUsedBodyPartsByUserId(userId),
|
return Stream.of(this.inventoryRepository.findUsedBodyPartsByUserId(userId),
|
||||||
this.inventoryRepository.findUsedClothesByUserId(userId, GoodClothType.Clothes),
|
this.inventoryRepository.findUsedClothesByUserId(userId, GoodClothType.Clothes),
|
||||||
this.inventoryRepository.findUsedClothesByUserId(userId, GoodClothType.Caps),
|
this.inventoryRepository.findUsedClothesByUserId(userId, GoodClothType.Caps),
|
||||||
@ -171,27 +171,27 @@ public class AvatarInventoryService {
|
|||||||
.flatMap(List::stream).collect(Collectors.toList());
|
.flatMap(List::stream).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InitMagicAbility> getMagicAbilitiesItemsByUserId(Long userId) {
|
public List<InitMagicAbility> getMagicAbilitiesItemsByUserId(Integer userId) {
|
||||||
return this.inventoryRepository.findMagicAbilitiesByUserId(userId); // todo: implement expiration ability
|
return this.inventoryRepository.findMagicAbilitiesByUserId(userId); // todo: implement expiration ability
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Smile> getSmilesByUserId(Long userId) {
|
public List<Smile> getSmilesByUserId(Integer userId) {
|
||||||
return this.inventoryRepository.findSmilesByUserId(userId);
|
return this.inventoryRepository.findSmilesByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryItem> getBackgroundsByUserId(Long userId) {
|
public List<InventoryItem> getBackgroundsByUserId(Integer userId) {
|
||||||
return this.inventoryRepository.findBackgrounds(userId);
|
return this.inventoryRepository.findBackgrounds(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<InventoryItem> getPhonesByUserId(Long userId) {
|
public List<InventoryItem> getPhonesByUserId(Integer userId) {
|
||||||
return this.inventoryRepository.findPhones(userId);
|
return this.inventoryRepository.findPhones(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addPhoneToInventory(Long userId, Long phoneId) {
|
public void addPhoneToInventory(Integer userId, Long phoneId) {
|
||||||
this.inventoryRepository.save(new AvatarInventory(referenceLoader.getUserReference(userId), phoneId, true, AvatarInventoryType.Phones, 0));
|
this.inventoryRepository.save(new AvatarInventory(referenceLoader.getUserReference(userId), phoneId, true, AvatarInventoryType.Phones, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addBackgroundToInventory(Long userId, Long backgroundId) {
|
public void addBackgroundToInventory(Integer userId, Long backgroundId) {
|
||||||
this.inventoryRepository.save(new AvatarInventory(referenceLoader.getUserReference(userId), backgroundId, true, AvatarInventoryType.Backgrounds, 0));
|
this.inventoryRepository.save(new AvatarInventory(referenceLoader.getUserReference(userId), backgroundId, true, AvatarInventoryType.Backgrounds, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,28 +213,28 @@ public class AvatarInventoryService {
|
|||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getSelectedPhoneId(Long userId) {
|
public Long getSelectedPhoneId(Integer userId) {
|
||||||
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.Phones)
|
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.Phones)
|
||||||
.stream()
|
.stream()
|
||||||
.map(AvatarInventory::getGoodId)
|
.map(AvatarInventory::getGoodId)
|
||||||
.findFirst().orElse(0L);
|
.findFirst().orElse(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUsedBackground(Long userId) {
|
public Long getUsedBackground(Integer userId) {
|
||||||
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.Backgrounds)
|
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.Backgrounds)
|
||||||
.stream()
|
.stream()
|
||||||
.map(AvatarInventory::getGoodId)
|
.map(AvatarInventory::getGoodId)
|
||||||
.findFirst().orElse(0L);
|
.findFirst().orElse(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Long getUsedHouse(Long userId) {
|
public Long getUsedHouse(Integer userId) {
|
||||||
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House)
|
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House)
|
||||||
.stream()
|
.stream()
|
||||||
.map(AvatarInventory::getGoodId)
|
.map(AvatarInventory::getGoodId)
|
||||||
.findFirst().orElse(0L);
|
.findFirst().orElse(0L);
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getAchievementsByUserId(Long userId) {
|
public String getAchievementsByUserId(Integer userId) {
|
||||||
return this.inventoryRepository.findItemsByUserIdAndType(userId, AvatarInventoryType.Achievements)
|
return this.inventoryRepository.findItemsByUserIdAndType(userId, AvatarInventoryType.Achievements)
|
||||||
.stream()
|
.stream()
|
||||||
.map(a -> a.getGoodId().toString())
|
.map(a -> a.getGoodId().toString())
|
||||||
|
@ -46,7 +46,7 @@ public class LocationService {
|
|||||||
Optional<Location> l = this.repository.findDefaultLocation();
|
Optional<Location> l = this.repository.findDefaultLocation();
|
||||||
if( l.isPresent() ) {
|
if( l.isPresent() ) {
|
||||||
Location r = l.get();
|
Location r = l.get();
|
||||||
return new LocationObject(r.getLocationId(), false, false, false, true, r.getMediaResourceId(), r.getX(), r.getY(), r.getName(), 0L, "", this.locationObjectInstanceRepository.findObjectsForLocationById(r.getLocationId()));
|
return new LocationObject(r.getLocationId(), false, false, false, true, r.getMediaResourceId(), r.getX(), r.getY(), r.getName(), 0, "", this.locationObjectInstanceRepository.findObjectsForLocationById(r.getLocationId()));
|
||||||
}
|
}
|
||||||
return new LocationObject();
|
return new LocationObject();
|
||||||
}
|
}
|
||||||
@ -55,7 +55,7 @@ public class LocationService {
|
|||||||
Optional<Location> l = this.repository.findLocationById(locationId);
|
Optional<Location> l = this.repository.findLocationById(locationId);
|
||||||
if( l.isPresent() ) {
|
if( l.isPresent() ) {
|
||||||
Location r = l.get();
|
Location r = l.get();
|
||||||
return new LocationObject(r.getLocationId(), false, false, false, true, r.getMediaResourceId(), r.getX(), r.getY(), r.getName(), 0L, "", this.locationObjectInstanceRepository.findObjectsForLocationById(locationId));
|
return new LocationObject(r.getLocationId(), false, false, false, true, r.getMediaResourceId(), r.getX(), r.getY(), r.getName(), 0, "", this.locationObjectInstanceRepository.findObjectsForLocationById(locationId));
|
||||||
}
|
}
|
||||||
return getDefaultLocation();
|
return getDefaultLocation();
|
||||||
}
|
}
|
||||||
@ -77,7 +77,7 @@ public class LocationService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public LocationObject getHomeByUserId(Long userId) {
|
public LocationObject getHomeByUserId(Integer userId) {
|
||||||
Long goodId = goodRepository.findById(avatarInventoryService.getUsedHouse(userId)).map(Good::getId).orElse(102L);
|
Long goodId = goodRepository.findById(avatarInventoryService.getUsedHouse(userId)).map(Good::getId).orElse(102L);
|
||||||
var house = this.houseLocationRepository.findDefaultHouseLocationByGoodId(goodId).get();
|
var house = this.houseLocationRepository.findDefaultHouseLocationByGoodId(goodId).get();
|
||||||
return new LocationObject(-1L, true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(), Collections.emptyList());
|
return new LocationObject(-1L, true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(), Collections.emptyList());
|
||||||
|
@ -21,15 +21,15 @@ public class OnlineStatusService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ReferenceLoader referenceLoader;
|
private ReferenceLoader referenceLoader;
|
||||||
|
|
||||||
public List<OnlineStatus> findByUserId(Long userId) {
|
public List<OnlineStatus> findByUserId(Integer userId) {
|
||||||
return this.repository.findByUserId(userId);
|
return this.repository.findByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOnlineFor(Long userId) {
|
public void setOnlineFor(Integer userId) {
|
||||||
this.repository.save(new OnlineStatus(referenceLoader.getUserReference(userId), System.currentTimeMillis() / 1000L));
|
this.repository.save(new OnlineStatus(referenceLoader.getUserReference(userId), System.currentTimeMillis() / 1000L));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isOnline(Long userId) {
|
public Boolean isOnline(Integer userId) {
|
||||||
return !this.findByUserId(userId).isEmpty();
|
return !this.findByUserId(userId).isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@ public class PhoneMessageService {
|
|||||||
return repository.findAll();
|
return repository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<PhoneMessage> getAllByReceiverId(Long id) {
|
public List<PhoneMessage> getAllByReceiverId(Integer id) {
|
||||||
return repository.findByReceiverId(id);
|
return repository.findByReceiverId(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@ public class PostcardService {
|
|||||||
return repository.findAll();
|
return repository.findAll();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<Postcard> getAllPostcardsOfUser(Long userId) {
|
public List<Postcard> getAllPostcardsOfUser(Integer userId) {
|
||||||
return this.repository.findByReceiverId(userId);
|
return this.repository.findByReceiverId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,11 +19,11 @@ public class RelationshipService {
|
|||||||
this.repository.save(relationship);
|
this.repository.save(relationship);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean isFriends(Long userId, Long userId1) {
|
public Boolean isFriends(Integer userId, Integer userId1) {
|
||||||
return this.repository.findRelation(userId, userId1, Relationship.FriendshipStatus.Friendship).isPresent();
|
return this.repository.findRelation(userId, userId1, Relationship.FriendshipStatus.Friendship).isPresent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Relationship> isRequestSent(Long userId, Long userId1) {
|
public Optional<Relationship> isRequestSent(Integer userId, Integer userId1) {
|
||||||
return this.repository.findRelation(userId, userId1, Relationship.FriendshipStatus.Request);
|
return this.repository.findRelation(userId, userId1, Relationship.FriendshipStatus.Request);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -35,7 +35,7 @@ public class RelationshipService {
|
|||||||
this.repository.acceptRequestById(id);
|
this.repository.acceptRequestById(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendRequest(Long sender, Long receiver) {
|
public void sendRequest(Integer sender, Integer receiver) {
|
||||||
if( this.isFriends(sender, receiver) ) return;
|
if( this.isFriends(sender, receiver) ) return;
|
||||||
if( this.isRequestSent(sender, receiver).isPresent() ) {
|
if( this.isRequestSent(sender, receiver).isPresent() ) {
|
||||||
Relationship r = this.isRequestSent(sender, receiver).get();
|
Relationship r = this.isRequestSent(sender, receiver).get();
|
||||||
@ -46,23 +46,23 @@ public class RelationshipService {
|
|||||||
this.repository.save(new Relationship(null, sender, receiver, Relationship.FriendshipStatus.Request));
|
this.repository.save(new Relationship(null, sender, receiver, Relationship.FriendshipStatus.Request));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deleteFriendshipByUserIds(Long userId1, Long userId2) {
|
public void deleteFriendshipByUserIds(Integer userId1, Integer userId2) {
|
||||||
this.repository.deleteFriendshipByUserIds(userId1, userId2);
|
this.repository.deleteFriendshipByUserIds(userId1, userId2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getFriendsOfUser(Long userId) {
|
public List<User> getFriendsOfUser(Integer userId) {
|
||||||
return this.repository.findFriendsOfUserById(userId);
|
return this.repository.findFriendsOfUserById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<User> getRequestsOfUser(Long userId) {
|
public List<User> getRequestsOfUser(Integer userId) {
|
||||||
return this.repository.findRequestsOfUserById(userId);
|
return this.repository.findRequestsOfUserById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acceptFriendshipWithUsers(Long userId, List<Long> users) {
|
public void acceptFriendshipWithUsers(Integer userId, List<Integer> users) {
|
||||||
this.repository.acceptFriendshipWithUsers(userId, users);
|
this.repository.acceptFriendshipWithUsers(userId, users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void denyFriendshipsWithUsers(Long userId, List<Long> users) {
|
public void denyFriendshipsWithUsers(Integer userId, List<Integer> users) {
|
||||||
this.repository.denyFriendshipsWithUsers(userId, users);
|
this.repository.denyFriendshipsWithUsers(userId, users);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -58,7 +58,7 @@ public class UserService {
|
|||||||
return userRepository.findByUsername(username);
|
return userRepository.findByUsername(username);
|
||||||
}
|
}
|
||||||
|
|
||||||
public long saveUser(String username, String password, Role.RoleType role) {
|
public int saveUser(String username, String password, Role.RoleType role) {
|
||||||
User user = new User();
|
User user = new User();
|
||||||
user.setUsername(username);
|
user.setUsername(username);
|
||||||
user.setPassword(passwordEncoder.encode(password));
|
user.setPassword(passwordEncoder.encode(password));
|
||||||
@ -74,7 +74,7 @@ public class UserService {
|
|||||||
return roleRepository.save(new Role(role));
|
return roleRepository.save(new Role(role));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<Object> findUserProperty(Long userId, PlayerProperties type) {
|
public Optional<Object> findUserProperty(Integer userId, PlayerProperties type) {
|
||||||
Optional<UserProperty> res = this.propertyRepository.findByUserIdAndTag(userId, type);
|
Optional<UserProperty> res = this.propertyRepository.findByUserIdAndTag(userId, type);
|
||||||
if( res.isEmpty() ) return Optional.empty();
|
if( res.isEmpty() ) return Optional.empty();
|
||||||
UserProperty property = res.get();
|
UserProperty property = res.get();
|
||||||
@ -87,7 +87,7 @@ public class UserService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushUserProperty(Long userId, PlayerProperties type, Object val) {
|
public void pushUserProperty(Integer userId, PlayerProperties type, Object val) {
|
||||||
this.propertyRepository.deleteByUserIdAndType(userId, type);
|
this.propertyRepository.deleteByUserIdAndType(userId, type);
|
||||||
this.propertyRepository.save(switch (type.getValueType()) {
|
this.propertyRepository.save(switch (type.getValueType()) {
|
||||||
case String -> new UserProperty(userRepository.getReferenceById(userId), (String) val, type);
|
case String -> new UserProperty(userRepository.getReferenceById(userId), (String) val, type);
|
||||||
@ -98,7 +98,7 @@ public class UserService {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public RoleFlags getRoleFlags(Long userId) {
|
public RoleFlags getRoleFlags(Integer userId) {
|
||||||
Optional<Object> res = this.findUserProperty(userId, PlayerProperties.RoleFlags);
|
Optional<Object> res = this.findUserProperty(userId, PlayerProperties.RoleFlags);
|
||||||
if( res.isEmpty() ) {
|
if( res.isEmpty() ) {
|
||||||
this.pushUserProperty(userId, PlayerProperties.RoleFlags, RoleFlags.SA);
|
this.pushUserProperty(userId, PlayerProperties.RoleFlags, RoleFlags.SA);
|
||||||
@ -107,12 +107,12 @@ public class UserService {
|
|||||||
return (RoleFlags) res.get();
|
return (RoleFlags) res.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIsClubPresent(Long userId) {
|
public Boolean getIsClubPresent(Integer userId) {
|
||||||
// todo: Implement clubs;
|
// todo: Implement clubs;
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ClubAccessType getClubAccessType(Long userId) {
|
public ClubAccessType getClubAccessType(Integer userId) {
|
||||||
Optional<Object> res = this.findUserProperty(userId, PlayerProperties.ClubAccessType);
|
Optional<Object> res = this.findUserProperty(userId, PlayerProperties.ClubAccessType);
|
||||||
if( res.isEmpty() ) {
|
if( res.isEmpty() ) {
|
||||||
this.pushUserProperty(userId, PlayerProperties.ClubAccessType, ClubAccessType.CLOSED);
|
this.pushUserProperty(userId, PlayerProperties.ClubAccessType, ClubAccessType.CLOSED);
|
||||||
@ -121,31 +121,31 @@ public class UserService {
|
|||||||
return (ClubAccessType) res.get();
|
return (ClubAccessType) res.get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getIsFriend(Long userId, Long userId2) {
|
public Boolean getIsFriend(Integer userId, Integer userId2) {
|
||||||
return relationshipService.isFriends(userId, userId2);
|
return relationshipService.isFriends(userId, userId2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setWeaponsCount(Long userId, Integer count) {
|
public void setWeaponsCount(Integer userId, Integer count) {
|
||||||
this.pushUserProperty(userId, PlayerProperties.WeaponsCount, count);
|
this.pushUserProperty(userId, PlayerProperties.WeaponsCount, count);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getUsualTickets(Long userId) {
|
public Integer getUsualTickets(Integer userId) {
|
||||||
return this.getIntegerUserProperty(userId, PlayerProperties.UsualTickets, 1000);
|
return this.getIntegerUserProperty(userId, PlayerProperties.UsualTickets, 1000);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setUsualTickets(Long userId, Integer amount) {
|
public void setUsualTickets(Integer userId, Integer amount) {
|
||||||
this.pushUserProperty(userId, PlayerProperties.UsualTickets, amount);
|
this.pushUserProperty(userId, PlayerProperties.UsualTickets, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getMagicTickets(Long userId) {
|
public Integer getMagicTickets(Integer userId) {
|
||||||
return getIntegerUserProperty(userId, PlayerProperties.MagicTickets, 200);
|
return getIntegerUserProperty(userId, PlayerProperties.MagicTickets, 200);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMagicTickets(Long userId, Integer amount) {
|
public void setMagicTickets(Integer userId, Integer amount) {
|
||||||
this.pushUserProperty(userId, PlayerProperties.MagicTickets, amount);
|
this.pushUserProperty(userId, PlayerProperties.MagicTickets, amount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Integer getIntegerUserProperty(Long userId, PlayerProperties prop, Integer def) {
|
public Integer getIntegerUserProperty(Integer userId, PlayerProperties prop, Integer def) {
|
||||||
Optional<Object> res = this.findUserProperty(userId, prop);
|
Optional<Object> res = this.findUserProperty(userId, prop);
|
||||||
if( res.isEmpty() ) {
|
if( res.isEmpty() ) {
|
||||||
this.pushUserProperty(userId, prop, def);
|
this.pushUserProperty(userId, prop, def);
|
||||||
@ -154,7 +154,7 @@ public class UserService {
|
|||||||
return res.map(o -> (Integer) o).get();
|
return res.map(o -> (Integer) o).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Boolean getBooleanUserProperty(Long userId, PlayerProperties prop, Boolean def) {
|
public Boolean getBooleanUserProperty(Integer userId, PlayerProperties prop, Boolean def) {
|
||||||
Optional<Object> res = this.findUserProperty(userId, prop);
|
Optional<Object> res = this.findUserProperty(userId, prop);
|
||||||
if( res.isEmpty() ) {
|
if( res.isEmpty() ) {
|
||||||
this.pushUserProperty(userId, prop, def);
|
this.pushUserProperty(userId, prop, def);
|
||||||
@ -163,11 +163,11 @@ public class UserService {
|
|||||||
return res.map(o -> (Boolean) o).get();
|
return res.map(o -> (Boolean) o).get();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<String> getUsernameById(Long userId) {
|
public Optional<String> getUsernameById(Integer userId) {
|
||||||
return this.userRepository.findById(userId).map(User::getUsername);
|
return this.userRepository.findById(userId).map(User::getUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserAccount getUserAccountByUserId(Long userId) {
|
public UserAccount getUserAccountByUserId(Integer userId) {
|
||||||
return new UserAccount(
|
return new UserAccount(
|
||||||
getIntegerUserProperty(userId, PlayerProperties.PhoneCardBalance, 10),
|
getIntegerUserProperty(userId, PlayerProperties.PhoneCardBalance, 10),
|
||||||
getIntegerUserProperty(userId, PlayerProperties.WeaponsCount, 15),
|
getIntegerUserProperty(userId, PlayerProperties.WeaponsCount, 15),
|
||||||
@ -175,19 +175,19 @@ public class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultPhone(Long userId, Long phoneId) {
|
public void setDefaultPhone(Integer userId, Long phoneId) {
|
||||||
this.setDefault(userId, phoneId, AvatarInventoryType.Phones);
|
this.setDefault(userId, phoneId, AvatarInventoryType.Phones);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultBackground(Long userId, Long bgId) {
|
public void setDefaultBackground(Integer userId, Long bgId) {
|
||||||
this.setDefault(userId, bgId, AvatarInventoryType.Backgrounds);
|
this.setDefault(userId, bgId, AvatarInventoryType.Backgrounds);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setDefault(Long userId, Long gid, AvatarInventoryType type) {
|
private void setDefault(Integer userId, Long gid, AvatarInventoryType type) {
|
||||||
this.inventoryService.setDefault(userId, gid, type);
|
this.inventoryService.setDefault(userId, gid, type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDefaultInventoryItem(Long userId, Long gid, AvatarInventoryType type, Integer color) {
|
public void setDefaultInventoryItem(Integer userId, Long gid, AvatarInventoryType type, Integer color) {
|
||||||
if( !this.inventoryService.isSpecificItemExists(userId, type, gid) ) {
|
if( !this.inventoryService.isSpecificItemExists(userId, type, gid) ) {
|
||||||
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), gid, true, type, color));
|
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), gid, true, type, color));
|
||||||
} else {
|
} else {
|
||||||
@ -196,7 +196,7 @@ public class UserService {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void resetUsedClothes(Long userId) {
|
public void resetUsedClothes(Integer userId) {
|
||||||
this.inventoryService.resetUsed(userId, AvatarInventoryType.BodyParts);
|
this.inventoryService.resetUsed(userId, AvatarInventoryType.BodyParts);
|
||||||
this.inventoryService.resetUsed(userId, AvatarInventoryType.Clothes_);
|
this.inventoryService.resetUsed(userId, AvatarInventoryType.Clothes_);
|
||||||
this.inventoryService.resetUsed(userId, AvatarInventoryType.Caps);
|
this.inventoryService.resetUsed(userId, AvatarInventoryType.Caps);
|
||||||
@ -206,7 +206,7 @@ public class UserService {
|
|||||||
this.inventoryService.resetUsed(userId, AvatarInventoryType.Boots);
|
this.inventoryService.resetUsed(userId, AvatarInventoryType.Boots);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserPhone getUserPhoneByUserId(Long userId) {
|
public UserPhone getUserPhoneByUserId(Integer userId) {
|
||||||
Long phoneId = inventoryService.getSelectedPhoneId(userId);
|
Long phoneId = inventoryService.getSelectedPhoneId(userId);
|
||||||
return new UserPhone(
|
return new UserPhone(
|
||||||
999,
|
999,
|
||||||
@ -216,7 +216,7 @@ public class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Inventory getUserAvatarByUserId(Long userId) {
|
public Inventory getUserAvatarByUserId(Integer userId) {
|
||||||
return new Inventory(
|
return new Inventory(
|
||||||
new InventoryTab(199, List.of(
|
new InventoryTab(199, List.of(
|
||||||
inventoryService.getBodyPartInventoryGroup(userId, BodyPartType.Body, false),
|
inventoryService.getBodyPartInventoryGroup(userId, BodyPartType.Body, false),
|
||||||
@ -245,7 +245,7 @@ public class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInfo getUserInfoByUserId(Long userId, boolean isForUserInit, Long plId) {
|
public UserInfo getUserInfoByUserId(Integer userId, boolean isForUserInit, Integer plId) {
|
||||||
// todo: implement hardcoded stuff
|
// todo: implement hardcoded stuff
|
||||||
return new UserInfo(
|
return new UserInfo(
|
||||||
userId,
|
userId,
|
||||||
@ -286,11 +286,11 @@ public class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<IBodyAvatarItem> getOtherUserAvatar(Long userId) {
|
public List<IBodyAvatarItem> getOtherUserAvatar(Integer userId) {
|
||||||
return this.inventoryService.getWholeAvatarByUserId(userId);
|
return this.inventoryService.getWholeAvatarByUserId(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UserInitInfo getUserInitInfoByUserId(Long userId) {
|
public UserInitInfo getUserInitInfoByUserId(Integer userId) {
|
||||||
return new UserInitInfo(
|
return new UserInitInfo(
|
||||||
getUserAccountByUserId(userId),
|
getUserAccountByUserId(userId),
|
||||||
getUserInfoByUserId(userId, true, userId),
|
getUserInfoByUserId(userId, true, userId),
|
||||||
@ -300,7 +300,7 @@ public class UserService {
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlayerAvatar getAvatarById(long userId, Player p) {
|
public PlayerAvatar getAvatarById(int userId, Player p) {
|
||||||
Map<String, BodyAvatarItem> body = new HashMap<>();
|
Map<String, BodyAvatarItem> body = new HashMap<>();
|
||||||
List<BodyAvatarItem> i = inventoryService.getWholeAvatarByUserId(userId).stream().map(BodyAvatarItem::fromInterface).collect(Collectors.toList());
|
List<BodyAvatarItem> i = inventoryService.getWholeAvatarByUserId(userId).stream().map(BodyAvatarItem::fromInterface).collect(Collectors.toList());
|
||||||
IntStream.range(0, i.size()).boxed().forEach(g -> body.put(String.valueOf(g+1), i.get(g)));
|
IntStream.range(0, i.size()).boxed().forEach(g -> body.put(String.valueOf(g+1), i.get(g)));
|
||||||
@ -308,7 +308,7 @@ public class UserService {
|
|||||||
return new PlayerAvatar(String.valueOf(getRoleFlags(userId).getValue()), a);
|
return new PlayerAvatar(String.valueOf(getRoleFlags(userId).getValue()), a);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeUser(long userId) {
|
public void removeUser(int userId) {
|
||||||
this.userRepository.deleteById(userId);
|
this.userRepository.deleteById(userId);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -316,15 +316,15 @@ public class UserService {
|
|||||||
return this.userRepository.findUsersCount();
|
return this.userRepository.findUsersCount();
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, UserFriend> getFriendsOfUser(Long userId, Map<Long, Player> players) {
|
public Map<String, UserFriend> getFriendsOfUser(Integer userId, Map<Integer, Player> players) {
|
||||||
return this.convertUsersToFriends(relationshipService.getFriendsOfUser(userId), players);
|
return this.convertUsersToFriends(relationshipService.getFriendsOfUser(userId), players);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Map<String, UserFriend> getRequestsOfUser(Long userId, Map<Long, Player> players) {
|
public Map<String, UserFriend> getRequestsOfUser(Integer userId, Map<Integer, Player> players) {
|
||||||
return this.convertUsersToFriends(relationshipService.getRequestsOfUser(userId), players);
|
return this.convertUsersToFriends(relationshipService.getRequestsOfUser(userId), players);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Map<String, UserFriend> convertUsersToFriends(List<User> l, Map<Long, Player> players) {
|
private Map<String, UserFriend> convertUsersToFriends(List<User> l, Map<Integer, Player> players) {
|
||||||
Map<String, UserFriend> m = new HashMap<>();
|
Map<String, UserFriend> m = new HashMap<>();
|
||||||
for( int i = 0, u = 1; i < l.size(); i++, u++ ) {
|
for( int i = 0, u = 1; i < l.size(); i++, u++ ) {
|
||||||
User user = l.get(i);
|
User user = l.get(i);
|
||||||
@ -333,19 +333,19 @@ public class UserService {
|
|||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeFriendshipWithUser(Long userId, Long friendId) {
|
public void removeFriendshipWithUser(Integer userId, Integer friendId) {
|
||||||
relationshipService.deleteFriendshipByUserIds(userId, friendId);
|
relationshipService.deleteFriendshipByUserIds(userId, friendId);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void acceptFriendshipWithUsers(Long userId, List<Long> users) {
|
public void acceptFriendshipWithUsers(Integer userId, List<Integer> users) {
|
||||||
relationshipService.acceptFriendshipWithUsers(userId, users);
|
relationshipService.acceptFriendshipWithUsers(userId, users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void denyFriendshipsWithUsers(Long userId, List<Long> users) {
|
public void denyFriendshipsWithUsers(Integer userId, List<Integer> users) {
|
||||||
relationshipService.denyFriendshipsWithUsers(userId, users);
|
relationshipService.denyFriendshipsWithUsers(userId, users);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void pushToInventory(long userId, AvatarInventoryType type, long goodId) {
|
public void pushToInventory(int userId, AvatarInventoryType type, long goodId) {
|
||||||
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), goodId, false, type));
|
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), goodId, false, type));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user