House inventory update
This commit is contained in:
parent
11c0c3d97b
commit
dde0d8fa38
@ -319,11 +319,21 @@ public class GameServer {
|
|||||||
int type = message.getArguments().get(1).getInt();
|
int type = message.getArguments().get(1).getInt();
|
||||||
if( type == -2 ) { // home
|
if( type == -2 ) { // home
|
||||||
Map<String, AMFObject> info = (Map<String, AMFObject>) message.getArguments().get(2).getRaw();
|
Map<String, AMFObject> info = (Map<String, AMFObject>) message.getArguments().get(2).getRaw();
|
||||||
Map<String, AMFObject> additions = (Map<String, AMFObject>) info.get("Add").getRaw();
|
|
||||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, additions);
|
|
||||||
|
|
||||||
Map<String, AMFObject> changes = (Map<String, AMFObject>) info.get("Changes").getRaw();
|
if( info.containsKey("Add") ) {
|
||||||
this.homeInventoryService.addFurnitureToCurrentHome(playerId, changes);
|
Map<String, AMFObject> additions = (Map<String, AMFObject>) info.get("Add").getRaw();
|
||||||
|
this.homeInventoryService.addFurnitureToCurrentHome(playerId, additions);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( info.containsKey("Changes") ) {
|
||||||
|
Map<String, AMFObject> changes = (Map<String, AMFObject>) info.get("Changes").getRaw();
|
||||||
|
this.homeInventoryService.addFurnitureToCurrentHome(playerId, changes);
|
||||||
|
}
|
||||||
|
|
||||||
|
if( info.containsKey("Remove") ) {
|
||||||
|
Map<String, Object> remove = (Map<String, Object>) info.get("Remove").getRaw();
|
||||||
|
this.homeInventoryService.removeFurnitureFromHome(playerId, remove.keySet());
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// club
|
// club
|
||||||
|
@ -26,6 +26,7 @@ public enum AvatarInventoryType {
|
|||||||
Smile(-5),
|
Smile(-5),
|
||||||
House(34),
|
House(34),
|
||||||
HouseFurniture(20),
|
HouseFurniture(20),
|
||||||
|
HouseFurnitureWall(22),
|
||||||
Club(58),
|
Club(58),
|
||||||
ClubFacade(63),
|
ClubFacade(63),
|
||||||
ClubShow(78),
|
ClubShow(78),
|
||||||
|
@ -8,6 +8,7 @@ import lombok.Getter;
|
|||||||
public enum CommandType {
|
public enum CommandType {
|
||||||
UserCommand("$"),
|
UserCommand("$"),
|
||||||
SetLocation("_LS"),
|
SetLocation("_LS"),
|
||||||
|
LocationChanges("_LC"),
|
||||||
RemoveUserFromLocation("_UL"),
|
RemoveUserFromLocation("_UL"),
|
||||||
AddUserToLocation("_UE"),
|
AddUserToLocation("_UE"),
|
||||||
SetUserAvatarState("_S"),
|
SetUserAvatarState("_S"),
|
||||||
|
@ -108,6 +108,8 @@ public class SignUpController {
|
|||||||
avatarInventoryService.addPhoneToInventory(userId, 1L);
|
avatarInventoryService.addPhoneToInventory(userId, 1L);
|
||||||
avatarInventoryService.addBackgroundToInventory(userId, 339L);
|
avatarInventoryService.addBackgroundToInventory(userId, 339L);
|
||||||
|
|
||||||
|
avatarInventoryService.addGoodToInventory(new AvatarInventory(referenceLoader.getUserReference(userId), 102L, true, AvatarInventoryType.House));
|
||||||
|
|
||||||
try {
|
try {
|
||||||
av.getInventory()
|
av.getInventory()
|
||||||
.stream()
|
.stream()
|
||||||
|
@ -51,9 +51,6 @@ public class StaticController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ReferenceLoader referenceLoader;
|
private ReferenceLoader referenceLoader;
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AvatarInventoryService avatarInventoryService;
|
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private GoodsService goodsService;
|
private GoodsService goodsService;
|
||||||
|
|
||||||
@ -101,8 +98,7 @@ public class StaticController {
|
|||||||
model.addAttribute("user_id", userId);
|
model.addAttribute("user_id", userId);
|
||||||
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
|
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
|
||||||
|
|
||||||
AvatarInventory av = new AvatarInventory(referenceLoader.getUserReference(userId), goodId, false, AvatarInventoryType.fromGoodId(goodsService, goodId), 0);
|
userService.pushToInventory(userId, AvatarInventoryType.fromGoodId(goodsService, goodId), goodId);
|
||||||
avatarInventoryService.addGoodToInventory(av);
|
|
||||||
|
|
||||||
return "redirect:/panel_inventory?id="+userId;
|
return "redirect:/panel_inventory?id="+userId;
|
||||||
}
|
}
|
||||||
|
@ -57,6 +57,9 @@ public class LocationObjectInstance implements ApiResult {
|
|||||||
@Column(nullable = false)
|
@Column(nullable = false)
|
||||||
private String comment;
|
private String comment;
|
||||||
|
|
||||||
|
@JacksonXmlProperty(isAttribute = true, localName = "Frame")
|
||||||
|
private Integer frame;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public LocationObjectInstanceResult toAPIResult() {
|
public LocationObjectInstanceResult toAPIResult() {
|
||||||
return new LocationObjectInstanceResult(this.id, this.objectTypeId, this.objectId, this.objectReferenceId, this.mediaResourceId, this.locationId, this.x, this.y, this.options, this.comment);
|
return new LocationObjectInstanceResult(this.id, this.objectTypeId, this.objectId, this.objectReferenceId, this.mediaResourceId, this.locationId, this.x, this.y, this.options, this.comment);
|
||||||
|
@ -72,7 +72,9 @@ public class AMFDeserializer {
|
|||||||
a.clear();
|
a.clear();
|
||||||
if( keyLen == 0 ) {
|
if( keyLen == 0 ) {
|
||||||
endMarker = true;
|
endMarker = true;
|
||||||
bytes.remove();
|
if( !bytes.isEmpty() ) {
|
||||||
|
bytes.remove();
|
||||||
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
a = bytes.subList(0, Math.min(keyLen, bytes.size()));
|
a = bytes.subList(0, Math.min(keyLen, bytes.size()));
|
||||||
|
@ -23,4 +23,9 @@ public interface HouseInventoryRepository extends JpaRepository<HouseInventory,
|
|||||||
|
|
||||||
@Query(value = "SELECT h FROM HouseInventory h WHERE h.user.id = :uid AND h.homeId = :houseId")
|
@Query(value = "SELECT h FROM HouseInventory h WHERE h.user.id = :uid AND h.homeId = :houseId")
|
||||||
List<HouseInventory> findByUserIdAndHouseId(@Param("uid") Integer userId, @Param("houseId") Long houseId);
|
List<HouseInventory> findByUserIdAndHouseId(@Param("uid") Integer userId, @Param("houseId") Long houseId);
|
||||||
|
|
||||||
|
@Transactional
|
||||||
|
@Modifying
|
||||||
|
@Query(value = "UPDATE HouseInventory h SET h.homeId = -1 WHERE h.id = :uid")
|
||||||
|
void resetHomeId(@Param("uid") Long id);
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,12 @@ public class HomeInventoryService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private GoodRepository goodRepository;
|
private GoodRepository goodRepository;
|
||||||
|
|
||||||
|
public void removeFurnitureFromHome(int userId, Set<String> ids) {
|
||||||
|
for( String id : ids ) {
|
||||||
|
houseInventoryRepository.resetHomeId(Long.parseLong(id));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void addFurnitureToCurrentHome(int userId, Map<String, AMFObject> additions) {
|
public void addFurnitureToCurrentHome(int userId, Map<String, AMFObject> additions) {
|
||||||
Set<String> ids = additions.keySet();
|
Set<String> ids = additions.keySet();
|
||||||
long houseId = getCurrentHouseId(userId);
|
long houseId = getCurrentHouseId(userId);
|
||||||
|
@ -87,7 +87,8 @@ public class LocationService {
|
|||||||
houseInventoryRepository.findByUserIdAndHouseId(userId, avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getId).orElse(-1L))
|
houseInventoryRepository.findByUserIdAndHouseId(userId, avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getId).orElse(-1L))
|
||||||
.stream()
|
.stream()
|
||||||
.map(h -> new LocationObjectInstance(
|
.map(h -> new LocationObjectInstance(
|
||||||
2,
|
h.getId(),
|
||||||
|
1,
|
||||||
h.getId().intValue(),
|
h.getId().intValue(),
|
||||||
h.getGoodId().intValue(),
|
h.getGoodId().intValue(),
|
||||||
goodRepository.findById(h.getGoodId()).get().getMRId().longValue(),
|
goodRepository.findById(h.getGoodId()).get().getMRId().longValue(),
|
||||||
@ -95,7 +96,8 @@ public class LocationService {
|
|||||||
h.getX(),
|
h.getX(),
|
||||||
h.getY(),
|
h.getY(),
|
||||||
"",
|
"",
|
||||||
""
|
"",
|
||||||
|
h.getFrame()
|
||||||
))
|
))
|
||||||
.collect(Collectors.toList())
|
.collect(Collectors.toList())
|
||||||
);
|
);
|
||||||
|
@ -362,7 +362,7 @@ public class UserService {
|
|||||||
if( !this.inventoryService.isSpecificItemExists(userId, type, goodId) ) {
|
if( !this.inventoryService.isSpecificItemExists(userId, type, goodId) ) {
|
||||||
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), goodId, false, type));
|
this.inventoryService.addGoodToInventory(new AvatarInventory(userRepository.getReferenceById(userId), goodId, false, type));
|
||||||
}
|
}
|
||||||
if( type == AvatarInventoryType.HouseFurniture ) {
|
if( type == AvatarInventoryType.HouseFurniture || type == AvatarInventoryType.HouseFurnitureWall ) {
|
||||||
houseInventoryRepository.save(new HouseInventory(userRepository.getReferenceById(userId), goodId, -1L, 0.0, 0.0, 0));
|
houseInventoryRepository.save(new HouseInventory(userRepository.getReferenceById(userId), goodId, -1L, 0.0, 0.0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user