Compare commits

..

No commits in common. "master" and "retro" have entirely different histories.

52 changed files with 96 additions and 1149 deletions

View File

@ -1,11 +1,6 @@
<p align="center">
<img align="center" src="https://w0n.zip/file/5eVXOb">
</p>
<p align="center">Feels like a distant memory</p> <p align="center">Feels like a distant memory</p>
# WhimsyWorld
![Gitea Last Commit](https://img.shields.io/gitea/last-commit/alterwain/WhimsyWorld?gitea_url=https%3A%2F%2Fgitea.awain.net) ![Gitea Last Commit](https://img.shields.io/gitea/last-commit/alterwain/WhimsyWorld?gitea_url=https%3A%2F%2Fgitea.awain.net)
![Jenkins Build](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fjenkins.awain.net%2Fjob%2FWhimsyWorld&link=https%3A%2F%2Fjenkins.awain.net%2Fjob%2FWhimsyWorld) ![Jenkins Build](https://img.shields.io/jenkins/build?jobUrl=https%3A%2F%2Fjenkins.awain.net%2Fjob%2FWhimsyWorld&link=https%3A%2F%2Fjenkins.awain.net%2Fjob%2FWhimsyWorld)
![Contact](https://img.shields.io/badge/xmpp-alterwain-red?link=xmpp%3Aalterwain%40awain.net%3Fomemo-sid-687809972%3Dfc938d0c120affd1f011a1f1e53449b8b773ac7c322667f1dca2b2539987b86c) ![Contact](https://img.shields.io/badge/xmpp-alterwain-red?link=xmpp%3Aalterwain%40awain.net%3Fomemo-sid-687809972%3Dfc938d0c120affd1f011a1f1e53449b8b773ac7c322667f1dca2b2539987b86c)

View File

@ -3,14 +3,8 @@ package com.alterdekim.game.component;
import com.alterdekim.game.component.game.*; import com.alterdekim.game.component.game.*;
import com.alterdekim.game.component.game.friends.OneFR; import com.alterdekim.game.component.game.friends.OneFR;
import com.alterdekim.game.component.game.friends.UserFriend; import com.alterdekim.game.component.game.friends.UserFriend;
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
import com.alterdekim.game.component.game.home.HomeLocation;
import com.alterdekim.game.component.game.home.HomeStuff;
import com.alterdekim.game.component.game.inventory.BuyGoodResult; import com.alterdekim.game.component.game.inventory.BuyGoodResult;
import com.alterdekim.game.component.game.inventory.BuyGoodResultGood; import com.alterdekim.game.component.game.inventory.BuyGoodResultGood;
import com.alterdekim.game.component.game.minigame.MiniGameAction;
import com.alterdekim.game.component.game.minigame.MultiplayerMinigameLaunch;
import com.alterdekim.game.component.game.minigame.MultiplayerMinigameWaiting;
import com.alterdekim.game.component.game.response.init.GetUserInfo; import com.alterdekim.game.component.game.response.init.GetUserInfo;
import com.alterdekim.game.component.game.response.location.AddUserToLocation; import com.alterdekim.game.component.game.response.location.AddUserToLocation;
import com.alterdekim.game.component.rtmp.ConnectedProcessor; import com.alterdekim.game.component.rtmp.ConnectedProcessor;
@ -66,9 +60,6 @@ public class GameServer {
@Autowired @Autowired
private MiniGameService miniGameService; private MiniGameService miniGameService;
@Autowired
private HomeInventoryService homeInventoryService;
private final Map<Integer, Player> players; private final Map<Integer, Player> players;
private final ObjectMapper xmlMapper; private final ObjectMapper xmlMapper;
@ -165,7 +156,6 @@ public class GameServer {
long requestedLocation = message.getArguments().get(1).getLong(); long requestedLocation = message.getArguments().get(1).getLong();
if( requestedLocation == -1L ) { if( requestedLocation == -1L ) {
int homePlayerId = message.getArguments().get(0).getInt(); int homePlayerId = message.getArguments().get(0).getInt();
log.info("HOME: {}", xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)).replace("&lt;", "<"));
this.sendResult(playerId, message.getTransactionId(), xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)).replace("&lt;", "<")); this.sendResult(playerId, message.getTransactionId(), xmlMapper.writeValueAsString(locationService.getHomeByUserId(homePlayerId)).replace("&lt;", "<"));
return; return;
} }
@ -284,60 +274,6 @@ public class GameServer {
case SendGameClose, GameStatistics -> { case SendGameClose, GameStatistics -> {
this.sendResult(playerId, message.getTransactionId(), "0"); this.sendResult(playerId, message.getTransactionId(), "0");
} }
case RegisterGameWaiting -> {
Map<String, List<MultiplayerMinigameWaiting.Players>> m = new HashMap<>();
List<MultiplayerMinigameWaiting.Players> players1 = new ArrayList<>();
players1.add(new MultiplayerMinigameWaiting.Players(2, "jerk"));
m.put("0", players1);
this.call(playerId, CommandType.UpdateRoomTeam, new MultiplayerMinigameWaiting(m, 1, false));
players1.add(new MultiplayerMinigameWaiting.Players(3, "dullard"));
m.put("0", players1);
this.call(playerId, CommandType.UpdateRoomTeam, new MultiplayerMinigameWaiting(m, 1, false));
this.call(playerId, CommandType.LaunchRoomSession, new MultiplayerMinigameLaunch(m, "222"));
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("onAddUser", 1, "3"));
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("DisplayAvatar", 1, "3"));
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("onAddUser", 1, "2"));
this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("DisplayAvatar", 1, "2"));
log.info("Players: {}", players);
//this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("OnReady", 0, "2"));
//this.call(playerId, CommandType.MiniGameAction, new MiniGameAction("OnReady", 0, "3"));
}
case GetUserHomeLocationData -> {
String xs = xmlMapper.writeValueAsString(
new HomeStuff(
this.homeInventoryService.getHomeInventoryOfUser(playerId),
List.of(new HomeLocation(102, 2, 102L, 54, 708, 0, true, false, true, true, false, ClubAccessType.OPEN, 0, 0, 0.0, 0.0, 0, 0, true, true, true, true))
)
);
log.info("Output: {}", xs);
this.sendResult(playerId, message.getTransactionId(), xs);
}
case SaveLocationChanges -> {
if( message.getArguments().size() != 3 ) return;
int type = message.getArguments().get(1).getInt();
if( type == -2 ) { // home
Map<String, AMFObject> info = (Map<String, AMFObject>) message.getArguments().get(2).getRaw();
if( info.containsKey("Add") ) {
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;
}
// club
}
} }
} }
@ -347,7 +283,7 @@ public class GameServer {
} }
private void getGame(int playerId, long gameId, double transactionId) throws JsonProcessingException { private void getGame(int playerId, long gameId, double transactionId) throws JsonProcessingException {
this.sendResult(playerId, transactionId, xmlMapper.writeValueAsString(miniGameService.findGameById(gameId).get()).replace("&lt;", "<")); this.sendResult(playerId, transactionId, xmlMapper.writeValueAsString(miniGameService.findGameById(gameId).get()));
} }
private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) { private void lockSomething(int playerId, int what2Lock, Boolean state, UserMessage message) {

View File

@ -196,23 +196,23 @@ public class StartUpListener {
} }
private void pushMiniGames() { private void pushMiniGames() {
miniGameService.save(new MiniGame(0L, "Рентген", 0, 0, 4250, 1d, 2, true, true, false, 0L, 0L, "1", "", "")); miniGameService.save(new MiniGame(0L, "Рентген", 0, 0, 4250, 1d, 2, true, true, false, 0L, 0L, "1", ""));
miniGameService.save(new MiniGame(1L, "Дары леса", 10120, 1291, 1749, 10d, 1, true, false, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(1L, "Дары леса", 10120, 1291, 1749, 10d, 1, true, false, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(2L, "Катер", 10089, 516, 4265, 100d, 1, true, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(2L, "Катер", 10089, 516, 4265, 100d, 1, true, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(3L, "Волейбол", 10087, 513, 301, 100d, 1, true, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(3L, "Волейбол", 10087, 513, 301, 100d, 1, true, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(4L, "Кафе", 10088, 515, 310, 1d, 0, true, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(4L, "Кафе", 10088, 515, 310, 1d, 0, true, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(5L, "Труба", 10084, 1104, 11763, 1d, 0, false, true, true, 0L, 0L, "1", "", "")); miniGameService.save(new MiniGame(5L, "Труба", 10084, 1104, 11763, 1d, 0, false, true, true, 0L, 0L, "1", ""));
miniGameService.save(new MiniGame(6L, "Секретики", 10097, 806, 763, 1d, 0, true, false, true, 1000L, 10000L, "1", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>")); miniGameService.save(new MiniGame(6L, "Секретики", 10097, 806, 763, 1d, 0, true, false, true, 1000L, 10000L, "1", ""));
miniGameService.save(new MiniGame(7L, "Смешарики", 10086, 510, 3126, 1d, 1, true, true, true, 1000L, 10000L, "0", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>")); miniGameService.save(new MiniGame(7L, "Смешарики", 10086, 510, 3126, 1d, 1, true, true, true, 1000L, 10000L, "0", ""));
miniGameService.save(new MiniGame(8L, "Модельер", 10101, 948, 4300, 5d, 0, false, false, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(8L, "Модельер", 10101, 948, 4300, 5d, 0, false, false, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(9L, "Горки", 10095, 557, 341, 40d, 1, true, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(9L, "Горки", 10095, 557, 341, 40d, 1, true, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(10L, "Скачки", 10093, 518, 319, 1d, 0, true, true, true, 1000L, 10000L, "0", "", "<Groups><item ID=\"0\" MaxUsersCount=\"2\" MinUsersCount=\"2\" /></Groups>")); miniGameService.save(new MiniGame(10L, "Скачки", 10093, 518, 319, 1d, 0, true, true, true, 1000L, 10000L, "0", ""));
miniGameService.save(new MiniGame(11L, "Футбол", 10112, 1212, 4247, 1d, 3, true, true, true, 1000L, 30000L, "0", "", "")); miniGameService.save(new MiniGame(11L, "Футбол", 10112, 1212, 4247, 1d, 3, true, true, true, 1000L, 30000L, "0", ""));
miniGameService.save(new MiniGame(12L, "Няня", 10083, 505, 4241, 30d, 0, false, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(12L, "Няня", 10083, 505, 4241, 30d, 0, false, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(13L, "Двигатель", 10094, 519, 322, 5d, 0, false, true, true, 0L, 0L, "0", "", "")); miniGameService.save(new MiniGame(13L, "Двигатель", 10094, 519, 322, 5d, 0, false, true, true, 0L, 0L, "0", ""));
miniGameService.save(new MiniGame(14L, "Шарабудка", 8054, 3218, 1127, 1d, 0, false, true, true, 0L, 0L, "1", "", "")); miniGameService.save(new MiniGame(14L, "Шарабудка", 8054, 3218, 1127, 1d, 0, false, true, true, 0L, 0L, "1", ""));
miniGameService.save(new MiniGame(92L, "Трасса", 0, 0, 4267, 1d, 1, false, false, true, 0L, 0L, "1", "", "")); miniGameService.save(new MiniGame(92L, "Трасса", 0, 0, 4267, 1d, 1, false, false, true, 0L, 0L, "1", ""));
miniGameService.save(new MiniGame(206L, "Муравей", 2148, 2148, 3170, 1d, 0, true, false, true, 0L, 0L, "1", "", "")); miniGameService.save(new MiniGame(206L, "Муравей", 2148, 2148, 3170, 1d, 0, true, false, true, 0L, 0L, "1", ""));
} }
private void pushPhoneSkins() { private void pushPhoneSkins() {

View File

@ -26,7 +26,6 @@ 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),

View File

@ -8,7 +8,6 @@ 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"),
@ -22,9 +21,6 @@ public enum CommandType {
AddNewPhoneMessage("_MP"), AddNewPhoneMessage("_MP"),
CardMessage("_MC"), CardMessage("_MC"),
UpdateTickets("_NNT"), UpdateTickets("_NNT"),
UpdateRoomTeam("_GU"),
LaunchRoomSession("_GL"),
MiniGameAction("_G"),
Unknown(""); Unknown("");
private final String value; private final String value;

View File

@ -8,7 +8,6 @@ import lombok.Getter;
public enum RoleFlags { public enum RoleFlags {
NONE(0), NONE(0),
MEMBER(2), MEMBER(2),
BOSS(4),
SA(8), SA(8),
MODERATOR(131072), MODERATOR(131072),
ADMINISTRATOR(262144), ADMINISTRATOR(262144),

View File

@ -43,9 +43,6 @@ public enum UserCommandType {
GameScore("_GS"), GameScore("_GS"),
SendGameClose("_GC"), SendGameClose("_GC"),
GameStatistics("_GT"), GameStatistics("_GT"),
RegisterGameWaiting("_GR"),
GetUserHomeLocationData("_LDH"),
SaveLocationChanges("_LC"),
Unknown(""); Unknown("");
private final String value; private final String value;

View File

@ -1,39 +0,0 @@
package com.alterdekim.game.component.game.home;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@AllArgsConstructor
public class HomeInventoryGroup {
@JacksonXmlProperty(isAttribute = true, localName = "ID")
@Getter
private String id;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
private Integer objectTypeId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
@Getter
@Setter
private Long objectId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefTypeId")
private Integer objectRefTypeId;
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
private Integer mediaResourceID;
@JacksonXmlProperty(isAttribute = true, localName = "TextResourceID")
private Integer textResourceID;
@JacksonXmlProperty(isAttribute = false, localName = "object")
@JacksonXmlElementWrapper(useWrapping = false, localName = "object")
@Getter
private List<HomeInventoryObject> object;
}

View File

@ -1,16 +0,0 @@
package com.alterdekim.game.component.game.home;
import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class HomeInventoryObject {
@JacksonXmlProperty(isAttribute = true, localName = "ID")
private Integer id;
@JacksonXmlProperty(isAttribute = true, localName = "IsActive")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isActive;
}

View File

@ -1,88 +0,0 @@
package com.alterdekim.game.component.game.home;
import com.alterdekim.game.component.game.ClubAccessType;
import com.alterdekim.game.xml.ClubAccessTypeSerializer;
import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class HomeLocation {
@JacksonXmlProperty(isAttribute = true, localName = "ID")
private Integer id;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
private Integer objectTypeId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
private Long objectId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefTypeId")
private Integer objectRefTypeId;
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
private Integer mediaResourceID;
@JacksonXmlProperty(isAttribute = true, localName = "TextResourceID")
private Integer textResourceID;
@JacksonXmlProperty(isAttribute = true, localName = "IsHome")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isHome;
@JacksonXmlProperty(isAttribute = true, localName = "IsClub")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isClub;
@JacksonXmlProperty(isAttribute = true, localName = "IsVisaAccessPermitted")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean IsVisaAccessPermitted;
@JacksonXmlProperty(isAttribute = true, localName = "IsCurrent")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isCurrent;
@JacksonXmlProperty(isAttribute = true, localName = "IsLocked")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isLocked;
@JacksonXmlProperty(isAttribute = true, localName = "ClubAccessType")
@JsonSerialize(using = ClubAccessTypeSerializer.class)
private ClubAccessType clubAccessType;
@JacksonXmlProperty(isAttribute = true, localName = "ClubCost")
private Integer clubCost;
@JacksonXmlProperty(isAttribute = true, localName = "ClubRate")
private Integer clubRate;
@JacksonXmlProperty(isAttribute = true)
private Double x;
@JacksonXmlProperty(isAttribute = true)
private Double y;
@JacksonXmlProperty(isAttribute = true, localName = "Frame")
private Integer frame;
@JacksonXmlProperty(isAttribute = true, localName = "TweenerId")
private Integer tweenerId;
@JacksonXmlProperty(isAttribute = true, localName = "IsVisible")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isVisible;
@JacksonXmlProperty(isAttribute = true, localName = "IsEnabled")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isEnabled;
@JacksonXmlProperty(isAttribute = true, localName = "IsPositionHeld")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isPositionHeld;
@JacksonXmlProperty(isAttribute = true, localName = "IsDraggable")
@JsonSerialize(using = NumericBooleanSerializer.class)
private Boolean isDraggable;
}

View File

@ -1,21 +0,0 @@
package com.alterdekim.game.component.game.home;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlRootElement;
import lombok.AllArgsConstructor;
import java.util.List;
@AllArgsConstructor
@JacksonXmlRootElement(localName = "root")
public class HomeStuff {
@JacksonXmlProperty(isAttribute = false, localName = "inventory")
@JacksonXmlElementWrapper(useWrapping = true, localName = "inventory")
private List<HomeInventoryGroup> inventory;
@JacksonXmlProperty(isAttribute = false, localName = "locations")
@JacksonXmlElementWrapper(useWrapping = true, localName = "locations")
private List<HomeLocation> locations;
}

View File

@ -1,10 +0,0 @@
package com.alterdekim.game.component.game.minigame;
import lombok.AllArgsConstructor;
@AllArgsConstructor
public class MiniGameAction {
private String actionName;
private Integer number;
private String id;
}

View File

@ -1,12 +0,0 @@
package com.alterdekim.game.component.game.minigame;
import lombok.AllArgsConstructor;
import java.util.List;
import java.util.Map;
@AllArgsConstructor
public class MultiplayerMinigameLaunch {
private Map<String, List<MultiplayerMinigameWaiting.Players>> players;
private String sessionDescriptor;
}

View File

@ -1,23 +0,0 @@
package com.alterdekim.game.component.game.minigame;
import com.alterdekim.game.message.amf.AMFKey;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.util.List;
import java.util.Map;
@AllArgsConstructor
public class MultiplayerMinigameWaiting {
private Map<String, List<Players>> players;
private Integer number;
private Boolean flag;
@AllArgsConstructor
public static class Players {
@AMFKey(name = "ID")
private Integer id;
@AMFKey(name = "Name")
private String name;
}
}

View File

@ -7,7 +7,6 @@ import org.springframework.context.annotation.Configuration;
@Data @Data
@Configuration @Configuration
public class ServerConfig { public class ServerConfig {
@Value("${srv.oldMode}") private Boolean oldMode;
@Value("${srv.publicDomain}") private String publicDomain; @Value("${srv.publicDomain}") private String publicDomain;
@Value("${srv.rtmpPort}") private Integer gameServerPort; @Value("${srv.rtmpPort}") private Integer gameServerPort;
@Value("${srv.resPathSWF}") private String defaultResourcesPath; @Value("${srv.resPathSWF}") private String defaultResourcesPath;

View File

@ -7,14 +7,11 @@ import com.alterdekim.game.component.game.ClubAccessType;
import com.alterdekim.game.component.game.PlayerProperties; import com.alterdekim.game.component.game.PlayerProperties;
import com.alterdekim.game.component.game.PlayerPropertyType; import com.alterdekim.game.component.game.PlayerPropertyType;
import com.alterdekim.game.component.game.RoleFlags; import com.alterdekim.game.component.game.RoleFlags;
import com.alterdekim.game.component.game.avatar.GoodClothType;
import com.alterdekim.game.component.game.inventory.InventoryItem;
import com.alterdekim.game.controller.result.api.ApiResult; import com.alterdekim.game.controller.result.api.ApiResult;
import com.alterdekim.game.controller.result.api.PreloaderResult; import com.alterdekim.game.controller.result.api.PreloaderResult;
import com.alterdekim.game.controller.result.api.PromotionBannerResult; import com.alterdekim.game.controller.result.api.PromotionBannerResult;
import com.alterdekim.game.controller.result.api.PromotionResult; import com.alterdekim.game.controller.result.api.PromotionResult;
import com.alterdekim.game.entity.*; import com.alterdekim.game.entity.*;
import com.alterdekim.game.repository.AvatarInventoryRepository;
import com.alterdekim.game.service.*; import com.alterdekim.game.service.*;
import com.alterdekim.game.utils.DateUtils; import com.alterdekim.game.utils.DateUtils;
import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.annotation.JsonProperty;
@ -22,7 +19,6 @@ import jakarta.servlet.http.HttpServletRequest;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment; import org.springframework.core.env.Environment;
@ -73,21 +69,6 @@ public class ApiController {
@Autowired @Autowired
private LocationService locationService; private LocationService locationService;
@Autowired
private GoodsService goodsService;
@Autowired
private MRService mrService;
@Autowired
private MRTService mrtService;
@Autowired
private TRService trService;
@Autowired
private AvatarInventoryRepository avatarInventoryRepository;
@PostMapping("/delete_row") @PostMapping("/delete_row")
public ResponseEntity deleteRow(@RequestParam("table") APITable table, @RequestParam("row") Long rowId) { public ResponseEntity deleteRow(@RequestParam("table") APITable table, @RequestParam("row") Long rowId) {
switch (table) { switch (table) {
@ -224,74 +205,6 @@ public class ApiController {
return ResponseEntity.ok(results); return ResponseEntity.ok(results);
} }
@RequestMapping(value = "/get_goods", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<GoodResult>> getGoods() {
List<GoodResult> results = new LinkedList<>();
for( Good good : goodsService.getAll() ) {
GoodResult result = new GoodResult();
long goodId = good.getId();
result.setGoodId(goodId);
Integer iconId = -good.getMRId();
Integer trId = good.getTRId();
var icon = mrService.findById(iconId.longValue());
if( icon.isPresent() ) {
String url = mrtService.findById(icon.get().getTId().longValue()).getVal() + icon.get().getUrl();
result.setUrl(url);
}
var name = trService.findById(trId.longValue());
if( name.isPresent() ) {
String text = name.get().getH();
result.setName(text);
}
results.add(result);
}
return ResponseEntity.ok(results);
}
@RequestMapping(value = "/get_avatar_inventory", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<List<GoodResult>> getInventory(@RequestParam("id") Integer userId) {
List<GoodResult> results = new LinkedList<>();
List<InventoryItem> items = Arrays.stream(GoodClothType.values())
.map(type -> this.avatarInventoryRepository.findInventoryItems(userId, type))
.flatMap(Collection::stream)
.collect(Collectors.toList());
for( InventoryItem avatarInventory : items) {
var og = goodsService.findById(avatarInventory.getId());
if( og.isPresent() ) {
var good = og.get();
GoodResult result = new GoodResult();
long goodId = good.getId();
result.setGoodId(goodId);
Integer iconId = -good.getMRId();
Integer trId = good.getTRId();
var icon = mrService.findById(iconId.longValue());
if (icon.isPresent()) {
String url = mrtService.findById(icon.get().getTId().longValue()).getVal() + icon.get().getUrl();
result.setUrl(url);
}
var name = trService.findById(trId.longValue());
if (name.isPresent()) {
String text = name.get().getH();
result.setName(text);
}
results.add(result);
}
}
return ResponseEntity.ok(results);
}
@Setter
@NoArgsConstructor
public static class GoodResult {
@JsonProperty
private String url;
@JsonProperty
private Long goodId;
@JsonProperty
private String name;
}
@AllArgsConstructor @AllArgsConstructor
public static class UserPropertyResult { public static class UserPropertyResult {
@JsonProperty @JsonProperty

View File

@ -2,12 +2,7 @@ package com.alterdekim.game.controller;
import com.alterdekim.game.config.ServerConfig; import com.alterdekim.game.config.ServerConfig;
import com.alterdekim.game.controller.result.async.*; import com.alterdekim.game.controller.result.async.*;
import com.alterdekim.game.controller.result.async.old.ResourcesResult;
import com.alterdekim.game.controller.result.async.old.ServerActionCDataOld;
import com.alterdekim.game.controller.result.async.old.ServerActionMRTS;
import com.alterdekim.game.controller.result.async.old.ServerActionResultOld;
import com.alterdekim.game.entity.User; import com.alterdekim.game.entity.User;
import com.alterdekim.game.repository.MagicAbilityRepository;
import com.alterdekim.game.security.AuthenticationUtil; import com.alterdekim.game.security.AuthenticationUtil;
import com.alterdekim.game.service.*; import com.alterdekim.game.service.*;
import com.fasterxml.jackson.annotation.JsonAutoDetect; import com.fasterxml.jackson.annotation.JsonAutoDetect;
@ -58,24 +53,9 @@ public class AsyncController {
@Autowired @Autowired
private ServerConfig serverConfig; private ServerConfig serverConfig;
@Autowired
private MRService mrService;
@Autowired
private TRService trService;
@Autowired
private ROService roService;
@Autowired @Autowired
private OnlineStatusService onlineStatusService; private OnlineStatusService onlineStatusService;
@Autowired
private MAService maService;
@Autowired
private MRTService mrtService;
@PostMapping("/async/Ping") @PostMapping("/async/Ping")
@ResponseBody @ResponseBody
public ResponseEntity<String> ping() { public ResponseEntity<String> ping() {
@ -88,90 +68,6 @@ public class AsyncController {
@ResponseBody @ResponseBody
public ResponseEntity<String> serverAction() { public ResponseEntity<String> serverAction() {
try { try {
if( !serverConfig.getOldMode() ) {
return newMode();
}
return oldMode();
} catch (JsonProcessingException e) {
log.error(e.getMessage(), e);
}
return ResponseEntity.noContent().build();
}
private ResponseEntity<String> oldMode() throws JsonProcessingException {
User user = AuthenticationUtil.authProfile(userService).get();
XmlMapper xmlMapper = new XmlMapper();
xmlMapper.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE);
xmlMapper.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY);
ServerActionResultOld serverActionResult = new ServerActionResultOld();
serverActionResult.setMagicAbilities(maService.getAll());
serverActionResult.setSnStatus(new SnStatus(false));
serverActionResult.setUsername(new UserName(user.getUsername()));
serverActionResult.setFlags(new Flags(true, 13));
serverActionResult.setRequests(new Grants(0));
serverActionResult.setGrants(new Grants(0));
List<ConfigItem> items = new ArrayList<>();
items.add(new ConfigItem(1, ServerActionConfigType.IsPreloaderEnabled, "1", "bool")); // play with it
items.add(new ConfigItem(2, ServerActionConfigType.SynchronizeAvatarRotation, "1", "bool"));
items.add(new ConfigItem(3, ServerActionConfigType.InitialVolumeValue, "30", "number"));
items.add(new ConfigItem(4, ServerActionConfigType.IsStartupHomeLocation, "0", "bool"));
items.add(new ConfigItem(5, ServerActionConfigType.AccessRoleFlags, "0", "number"));
items.add(new ConfigItem(6, ServerActionConfigType.IsInternational, "0", "bool")); // play with it
items.add(new ConfigItem(7, ServerActionConfigType.TypeWeapon, "1", "number"));
items.add(new ConfigItem(8, ServerActionConfigType.StatisticsSendInterval, "300", "number"));
items.add(new ConfigItem(9, ServerActionConfigType.SwfVersion, "", "string"));
items.add(new ConfigItem(10, ServerActionConfigType.LanguageId, "1", "number")); // play with it
items.add(new ConfigItem(11, ServerActionConfigType.SnId, "1", "number"));
items.add(new ConfigItem(12, ServerActionConfigType.AutoServerSelectionAllowed, "0", "bool"));
List<ServerItem> s_items = new ArrayList<>();
s_items.add(new ServerItem(1, 202, 5, "rtmp://"+serverConfig.getPublicDomain()+":"+serverConfig.getGameServerPort()+"/shararam", 0, 1, 5, 5.1));
serverActionResult.setPhone(new PhoneMessages(phoneMessageService.getAllByReceiverId(user.getId())));
serverActionResult.setMiniquest(miniquestService.getAllMiniquests());
serverActionResult.setPostcard(new PostcardMessages(postcardService.getAllPostcardsOfUser(user.getId())));
serverActionResult.setPreloader(preloaderService.getSelected());
serverActionResult.setPromotion(promotionService.getSelected());
serverActionResult.setPromotionBanners(promotionBannerService.getSelected());
List<Tutorial> tutorials = new ArrayList<>();
tutorials.add(new Tutorial(-1, 1));
tutorials.add(new Tutorial(1, 1));
tutorials.add(new Tutorial(2, 1));
tutorials.add(new Tutorial(3, 1));
tutorials.add(new Tutorial(4, 1));
tutorials.add(new Tutorial(5, 1));
serverActionResult.setTutorial(tutorials);
serverActionResult.setResources(new ResourcesResult(mrService.getAll(), trService.getAll(), roService.getAll()));
var config = new ServerActionConfig(items);
var system = new ServerActionSystem(1, "cache/resources.swf"); // swf/cache/rus/resources[19].swf
ServerActionUser userdata = null;
ServerActionServers servers = null;
if( !user.getIsBanned() ) {
userdata = new ServerActionUser(user.getId(), AuthenticationUtil.getToken(user), AuthenticationUtil.getToken(user), 2, null, null);
servers = new ServerActionServers(s_items);
} else {
userdata = new ServerActionUser(user.getId(), null, null, 0, LocalDateTime.now(), 162L);
}
List<ServerActionCData> cdatas = new ArrayList<>();
cdatas.add(userdata);
cdatas.add(config);
cdatas.add(system);
cdatas.add(servers);
cdatas.add(new ServerActionMRTS(mrtService.getAll()));
//serverActionResult.setCdata(new ServerActionCDataOld(userdata, config, system, servers, mrtService.getAll()));
log.info("serverActionResult: {}", serverActionResult);
serverActionResult.setCdata(cdatas);
return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_XML)
.body(xmlMapper.writeValueAsString(serverActionResult));
}
private ResponseEntity<String> newMode() throws JsonProcessingException {
User user = AuthenticationUtil.authProfile(userService).get(); User user = AuthenticationUtil.authProfile(userService).get();
XmlMapper xmlMapper = new XmlMapper(); XmlMapper xmlMapper = new XmlMapper();
@ -229,5 +125,9 @@ public class AsyncController {
return ResponseEntity.ok() return ResponseEntity.ok()
.contentType(MediaType.APPLICATION_XML) .contentType(MediaType.APPLICATION_XML)
.body(xmlMapper.writeValueAsString(serverActionResult)); .body(xmlMapper.writeValueAsString(serverActionResult));
} catch (JsonProcessingException e) {
log.error(e.getMessage(), e);
}
return ResponseEntity.noContent().build();
} }
} }

View File

@ -108,8 +108,6 @@ 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()

View File

@ -1,13 +1,9 @@
package com.alterdekim.game.controller; package com.alterdekim.game.controller;
import com.alterdekim.game.component.ReferenceLoader;
import com.alterdekim.game.component.game.AvatarInventoryType;
import com.alterdekim.game.config.ServerConfig; import com.alterdekim.game.config.ServerConfig;
import com.alterdekim.game.entity.AvatarInventory;
import com.alterdekim.game.entity.Role; import com.alterdekim.game.entity.Role;
import com.alterdekim.game.entity.User; import com.alterdekim.game.entity.User;
import com.alterdekim.game.security.AuthenticationUtil; import com.alterdekim.game.security.AuthenticationUtil;
import com.alterdekim.game.service.AvatarInventoryService;
import com.alterdekim.game.service.GoodsService; import com.alterdekim.game.service.GoodsService;
import com.alterdekim.game.service.UserService; import com.alterdekim.game.service.UserService;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
@ -48,12 +44,6 @@ public class StaticController {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private ReferenceLoader referenceLoader;
@Autowired
private GoodsService goodsService;
@GetMapping("/main") @GetMapping("/main")
public String mainPage(Model model) { public String mainPage(Model model) {
User user = AuthenticationUtil.authProfile(userService).get(); User user = AuthenticationUtil.authProfile(userService).get();
@ -82,32 +72,9 @@ public class StaticController {
public String panelUser(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId) { public String panelUser(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId) {
model.addAttribute("user_id", userId); model.addAttribute("user_id", userId);
model.addAttribute("user_name", userService.getUsernameById(userId).get()); model.addAttribute("user_name", userService.getUsernameById(userId).get());
model.addAttribute("inventory_link", "/panel_inventory?id="+userId);
return "panel_user"; return "panel_user";
} }
@GetMapping("/panel_inventory")
public String panelInventory(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId) {
model.addAttribute("user_id", userId);
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
return "panel_inventory";
}
@PostMapping("/panel_inventory")
public String panelInventory(Model model, @RequestParam(value = "id", defaultValue = "1") Integer userId, @RequestParam(value = "good_id") Long goodId) {
model.addAttribute("user_id", userId);
model.addAttribute("user_name", "Inventory of " + userService.getUsernameById(userId).get());
userService.pushToInventory(userId, AvatarInventoryType.fromGoodId(goodsService, goodId), goodId);
return "redirect:/panel_inventory?id="+userId;
}
@GetMapping("/goods")
public String goodsPage() {
return "goods";
}
public enum PanelSection { public enum PanelSection {
Dashboard, Dashboard,
Locations, Locations,

View File

@ -3,9 +3,7 @@ package com.alterdekim.game.controller.result.async;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
import lombok.ToString;
@ToString
@AllArgsConstructor @AllArgsConstructor
public class UserName { public class UserName {
@JacksonXmlProperty(isAttribute = true, localName = "Value") @JacksonXmlProperty(isAttribute = true, localName = "Value")

View File

@ -1,28 +0,0 @@
package com.alterdekim.game.controller.result.async.old;
import com.alterdekim.game.entity.MediaResource;
import com.alterdekim.game.entity.ResourceObject;
import com.alterdekim.game.entity.TextResource;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
import lombok.NoArgsConstructor;
import java.util.List;
@AllArgsConstructor
@NoArgsConstructor
public class ResourcesResult {
@JacksonXmlProperty(isAttribute = false, localName = "MediaResources")
@JacksonXmlElementWrapper(useWrapping = true, localName = "MediaResources")
private List<MediaResource> mediaResources;
@JacksonXmlProperty(isAttribute = false, localName = "TextResources")
@JacksonXmlElementWrapper(useWrapping = true, localName = "TextResources")
private List<TextResource> textResources;
@JacksonXmlProperty(isAttribute = false, localName = "ResourcesOptions")
@JacksonXmlElementWrapper(useWrapping = true, localName = "ResourcesOptions")
private List<ResourceObject> resourceOptions;
}

View File

@ -1,32 +0,0 @@
package com.alterdekim.game.controller.result.async.old;
import com.alterdekim.game.controller.result.async.ServerActionConfig;
import com.alterdekim.game.controller.result.async.ServerActionServers;
import com.alterdekim.game.controller.result.async.ServerActionSystem;
import com.alterdekim.game.controller.result.async.ServerActionUser;
import com.alterdekim.game.entity.MediaResourcePath;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
import java.util.List;
@AllArgsConstructor
public class ServerActionCDataOld {
@JacksonXmlProperty(isAttribute = false, localName = "user")
private ServerActionUser user;
@JacksonXmlProperty(isAttribute = false, localName = "config")
private ServerActionConfig config;
@JacksonXmlProperty(isAttribute = false, localName = "system")
private ServerActionSystem system;
@JacksonXmlProperty(isAttribute = false, localName = "servers")
private ServerActionServers servers;
@JacksonXmlProperty(isAttribute = false, localName = "mrtroot")
@JacksonXmlElementWrapper(useWrapping = true, localName = "mrtroot")
private List<MediaResourcePath> mrtRoot;
}

View File

@ -1,23 +0,0 @@
package com.alterdekim.game.controller.result.async.old;
import com.alterdekim.game.controller.result.async.ServerActionCData;
import com.alterdekim.game.entity.MediaResourcePath;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@JsonRootName(value = "mrtroot")
public class ServerActionMRTS extends ServerActionCData {
@JacksonXmlElementWrapper(useWrapping = false, localName = "mrtroot")
private List<MediaResourcePath> mrtRoot;
}

View File

@ -1,71 +0,0 @@
package com.alterdekim.game.controller.result.async.old;
import com.alterdekim.game.controller.result.async.*;
import com.alterdekim.game.entity.*;
import com.alterdekim.game.xml.CryptoSerializer;
import com.fasterxml.jackson.annotation.JsonRootName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlElementWrapper;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import lombok.*;
import java.util.List;
@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
@ToString
@JsonRootName(value = "response")
public class ServerActionResultOld {
@JacksonXmlProperty(isAttribute = false, localName = "user_name")
private UserName username;
@JacksonXmlProperty(isAttribute = false, localName = "sn_status")
private SnStatus snStatus;
@JacksonXmlProperty
private List<Preloader> preloader;
@JacksonXmlProperty(localName = "magic_abilities")
@JacksonXmlElementWrapper(useWrapping = true, localName = "magic_abilities")
private List<MagicAbility> magicAbilities;
@JacksonXmlProperty
private Flags flags;
@JacksonXmlProperty(localName = "tutorial")
@JacksonXmlElementWrapper(useWrapping = true, localName = "tutorial")
private List<Tutorial> tutorial;
@JacksonXmlProperty
private Grants grants;
@JacksonXmlProperty
private Grants requests;
@JacksonXmlProperty
private List<Promotion> promotion;
@JacksonXmlProperty(localName = "promotion_banner")
private List<PromotionBanner> promotionBanners;
@JacksonXmlProperty
private PhoneMessages phone;
@JacksonXmlProperty
private PostcardMessages postcard;
@JacksonXmlProperty
@JacksonXmlElementWrapper(useWrapping = true, localName = "miniquest")
private List<Miniquest> miniquest;
@JacksonXmlProperty(localName = "resources")
private ResourcesResult resources;
@JacksonXmlProperty(localName = "cdata")
@JsonSerialize(using = CryptoSerializer.class)
@JacksonXmlElementWrapper(useWrapping = false, localName = "cdata")
private List<ServerActionCData> cdata;
}

View File

@ -1,47 +0,0 @@
package com.alterdekim.game.entity;
import jakarta.persistence.*;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@Entity
@Table(name="house_inventory")
public class HouseInventory {
@jakarta.persistence.Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long Id;
@OneToOne
@JoinColumn(referencedColumnName = "id")
private User user;
@Column(nullable = false)
private Long goodId;
@Column(nullable = false)
private Long homeId;
@Column(nullable = false)
private Double x;
@Column(nullable = false)
private Double y;
@Column(nullable = false)
private Integer frame;
public HouseInventory(User user, Long goodId, Long homeId, Double x, Double y, Integer frame) {
this.user = user;
this.goodId = goodId;
this.homeId = homeId;
this.x = x;
this.y = y;
this.frame = frame;
}
}

View File

@ -22,44 +22,32 @@ public class LocationObjectInstance implements ApiResult {
private Long id; private Long id;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId") @JacksonXmlProperty(isAttribute = true, localName = "AObjectTypeId")
@Column(nullable = false)
private Integer objectTypeId; private Integer objectTypeId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectId") @JacksonXmlProperty(isAttribute = true, localName = "AObjectId")
@Column(nullable = false)
private Integer objectId; private Integer objectId;
@JacksonXmlProperty(isAttribute = true, localName = "AObjectRefId") @JacksonXmlProperty(isAttribute = true, localName = "AObjectRefId")
@Column(nullable = false)
private Integer objectReferenceId; private Integer objectReferenceId;
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID") @JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
@Column(nullable = false)
private Long mediaResourceId; private Long mediaResourceId;
@JsonIgnore @JsonIgnore
@Column(nullable = false)
private Long locationId; private Long locationId;
@JacksonXmlProperty(isAttribute = true, localName = "x") @JacksonXmlProperty(isAttribute = true, localName = "x")
@Column(nullable = false)
private Double x; private Double x;
@JacksonXmlProperty(isAttribute = true, localName = "y") @JacksonXmlProperty(isAttribute = true, localName = "y")
@Column(nullable = false)
private Double y; private Double y;
@JacksonXmlText @JacksonXmlText
@Column(nullable = false)
private String options; private String options;
@JsonIgnore @JsonIgnore
@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);

View File

@ -4,7 +4,6 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashField; import com.alterdekim.flash.decompiler.mapper.FlashField;
import com.alterdekim.flash.decompiler.mapper.FlashValue; import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType; import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -22,32 +21,26 @@ import lombok.*;
public class MagicAbility { public class MagicAbility {
@Id @Id
@FlashValue(type = FlashValueType.Id) @FlashValue(type = FlashValueType.Id)
@JacksonXmlProperty(isAttribute = true, localName = "Id")
private Long id; private Long id;
@Column(nullable = false) @Column(nullable = false)
@FlashField(name = "TypeId") @FlashField(name = "TypeId")
@JacksonXmlProperty(isAttribute = true, localName = "TypeId")
private Integer typeId; private Integer typeId;
@Column(nullable = true) @Column(nullable = true)
@FlashField(name = "duration") @FlashField(name = "duration")
@JacksonXmlProperty(isAttribute = true, localName = "Duration")
private Integer duration; private Integer duration;
@Column(nullable = true) @Column(nullable = true)
@FlashField(name = "TweenerId") @FlashField(name = "TweenerId")
@JacksonXmlProperty(isAttribute = true, localName = "TweenerId")
private Integer tweenerId; private Integer tweenerId;
@Column(nullable = false) @Column(nullable = false)
@FlashField(name = "MRId") @FlashField(name = "MRId")
@JacksonXmlProperty(isAttribute = true, localName = "MediaResourceID")
private Integer mediaResourceId; private Integer mediaResourceId;
@Column(nullable = false) @Column(nullable = false)
@FlashField(name = "TRId") @FlashField(name = "TRId")
@JacksonXmlProperty(isAttribute = true, localName = "TRId")
private Integer textResourceId; private Integer textResourceId;
@Column(nullable = false) @Column(nullable = false)
@ -60,6 +53,5 @@ public class MagicAbility {
@Column(nullable = true) @Column(nullable = true)
@FlashField(name = "IsMovable") @FlashField(name = "IsMovable")
@JacksonXmlProperty(isAttribute = true, localName = "IsMovable")
private Boolean isMovable; private Boolean isMovable;
} }

View File

@ -4,7 +4,6 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashField; import com.alterdekim.flash.decompiler.mapper.FlashField;
import com.alterdekim.flash.decompiler.mapper.FlashValue; import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType; import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -21,21 +20,17 @@ import lombok.*;
@FlashClass(name = "mr") @FlashClass(name = "mr")
public class MediaResource { public class MediaResource {
@Id @Id
@JacksonXmlProperty(isAttribute = true, localName = "Id")
@FlashValue(type = FlashValueType.Id) @FlashValue(type = FlashValueType.Id)
private Long id; private Long id;
@JacksonXmlProperty(isAttribute = true, localName = "TId")
@FlashField(name = "TId") @FlashField(name = "TId")
@Column(nullable = false) @Column(nullable = false)
private Integer tId; private Integer tId;
@JacksonXmlProperty(isAttribute = true, localName = "Url")
@FlashField(name = "Url") @FlashField(name = "Url")
@Column(nullable = false) @Column(nullable = false)
private String url; private String url;
@JacksonXmlProperty(isAttribute = true, localName = "V")
@FlashField(name = "V") @FlashField(name = "V")
@Column(nullable = true) @Column(nullable = true)
private String v; private String v;

View File

@ -3,7 +3,6 @@ package com.alterdekim.game.entity;
import com.alterdekim.flash.decompiler.mapper.FlashClass; import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashValue; import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType; import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -20,12 +19,10 @@ import lombok.*;
@FlashClass(name = "mrt") @FlashClass(name = "mrt")
public class MediaResourcePath { public class MediaResourcePath {
@Id @Id
@JacksonXmlProperty(isAttribute = true, localName = "Id")
@FlashValue(type = FlashValueType.Id) @FlashValue(type = FlashValueType.Id)
private Long id; private Long id;
@Column(nullable = false) @Column(nullable = false)
@FlashValue(type = FlashValueType.Value) @FlashValue(type = FlashValueType.Value)
@JacksonXmlProperty(isAttribute = true, localName = "Url")
private String val; private String val;
} }

View File

@ -5,7 +5,6 @@ import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.alterdekim.game.xml.NumericBooleanSerializer; import com.alterdekim.game.xml.NumericBooleanSerializer;
import com.fasterxml.jackson.databind.annotation.JsonSerialize; import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty; import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlText;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -78,8 +77,4 @@ public class MiniGame {
@Column(nullable = false) @Column(nullable = false)
@JacksonXmlProperty(isAttribute = true, localName = "Token") @JacksonXmlProperty(isAttribute = true, localName = "Token")
private String token; private String token;
@Column(nullable = false)
@JacksonXmlText
private String groups_list;
} }

View File

@ -4,7 +4,6 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashField; import com.alterdekim.flash.decompiler.mapper.FlashField;
import com.alterdekim.flash.decompiler.mapper.FlashValue; import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType; import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -22,27 +21,22 @@ import lombok.*;
public class ResourceObject { public class ResourceObject {
@Id @Id
@FlashValue(type = FlashValueType.Id) @FlashValue(type = FlashValueType.Id)
@JacksonXmlProperty(isAttribute = true, localName = "Id")
private Long id; private Long id;
@FlashField(name = "X") @FlashField(name = "X")
@JacksonXmlProperty(isAttribute = true, localName = "X")
@Column(nullable = true) @Column(nullable = true)
private Double x; private Double x;
@FlashField(name = "Y") @FlashField(name = "Y")
@Column(nullable = true) @Column(nullable = true)
@JacksonXmlProperty(isAttribute = true, localName = "Y")
private Double y; private Double y;
@FlashField(name = "Width") @FlashField(name = "Width")
@Column(nullable = true) @Column(nullable = true)
@JacksonXmlProperty(isAttribute = true, localName = "Width")
private Double width; private Double width;
@FlashField(name = "Height") @FlashField(name = "Height")
@Column(nullable = true) @Column(nullable = true)
@JacksonXmlProperty(isAttribute = true, localName = "Height")
private Double height; private Double height;
@FlashField(name = "IsCloseHide") @FlashField(name = "IsCloseHide")

View File

@ -4,7 +4,6 @@ import com.alterdekim.flash.decompiler.mapper.FlashClass;
import com.alterdekim.flash.decompiler.mapper.FlashField; import com.alterdekim.flash.decompiler.mapper.FlashField;
import com.alterdekim.flash.decompiler.mapper.FlashValue; import com.alterdekim.flash.decompiler.mapper.FlashValue;
import com.alterdekim.flash.decompiler.mapper.FlashValueType; import com.alterdekim.flash.decompiler.mapper.FlashValueType;
import com.fasterxml.jackson.dataformat.xml.annotation.JacksonXmlProperty;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.Id; import jakarta.persistence.Id;
@ -22,16 +21,13 @@ import lombok.*;
public class TextResource { public class TextResource {
@Id @Id
@FlashValue(type = FlashValueType.Id) @FlashValue(type = FlashValueType.Id)
@JacksonXmlProperty(isAttribute = true, localName = "Id")
private Long id; private Long id;
@FlashField(name = "OId") @FlashField(name = "OId")
@Column(nullable = true) @Column(nullable = true)
@JacksonXmlProperty(isAttribute = true, localName = "OId")
private Integer oId; private Integer oId;
@FlashField(name = "H") @FlashField(name = "H")
@Column(nullable = false, length = 65555) @Column(nullable = false, length = 65555)
@JacksonXmlProperty(isAttribute = true, localName = "H")
private String h; private String h;
} }

View File

@ -72,9 +72,7 @@ public class AMFDeserializer {
a.clear(); a.clear();
if( keyLen == 0 ) { if( keyLen == 0 ) {
endMarker = true; endMarker = true;
if( !bytes.isEmpty() ) {
bytes.remove(); bytes.remove();
}
continue; continue;
} }
a = bytes.subList(0, Math.min(keyLen, bytes.size())); a = bytes.subList(0, Math.min(keyLen, bytes.size()));
@ -106,9 +104,7 @@ public class AMFDeserializer {
a.clear(); a.clear();
if( keyLen == 0 ) { if( keyLen == 0 ) {
endMarker = true; endMarker = true;
if( !bytes.isEmpty() ) {
bytes.remove(); bytes.remove();
}
continue; continue;
} }
bytes.subList(0, Math.min(keyLen, bytes.size())).clear(); bytes.subList(0, Math.min(keyLen, bytes.size())).clear();

View File

@ -64,9 +64,6 @@ public interface AvatarInventoryRepository extends JpaRepository<AvatarInventory
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") Integer userId, @Param("goodTypeId") GoodClothType goodClothType); List<InventoryItem> findInventoryItems(@Param("uid") Integer userId, @Param("goodTypeId") GoodClothType goodClothType);
@Query(value = "SELECT a FROM AvatarInventory a WHERE a.user.id = :uid")
List<AvatarInventory> findAllByUserId(@Param("uid") Integer userId);
@Query(value = """ @Query(value = """
SELECT SELECT
b.id AS id, b.id AS id,

View File

@ -1,31 +0,0 @@
package com.alterdekim.game.repository;
import com.alterdekim.game.entity.HouseInventory;
import jakarta.transaction.Transactional;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;
import java.util.List;
@Repository
public interface HouseInventoryRepository extends JpaRepository<HouseInventory, Long> {
@Query(value = "SELECT h FROM HouseInventory h WHERE h.user.id = :uid")
List<HouseInventory> findByUserId(@Param("uid") int userId);
@Transactional
@Modifying
@Query(value = "UPDATE HouseInventory h SET h.homeId = :houseId, h.x = :x, h.y = :y, h.frame = :frame WHERE h.id = :uid")
void updateInfoById(@Param("uid") Long id, @Param("houseId") Long houseId, @Param("x") Double x, @Param("y") Double y, @Param("frame") Integer frame);
@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);
@Transactional
@Modifying
@Query(value = "UPDATE HouseInventory h SET h.homeId = -1 WHERE h.id = :uid")
void resetHomeId(@Param("uid") Long id);
}

View File

@ -38,8 +38,6 @@ public class SpringSecurity {
.requestMatchers("/login").permitAll() .requestMatchers("/login").permitAll()
.requestMatchers("/panel").hasAuthority(Role.RoleType.RoleAdmin.name()) .requestMatchers("/panel").hasAuthority(Role.RoleType.RoleAdmin.name())
.requestMatchers("/panel_user").hasAuthority(Role.RoleType.RoleAdmin.name()) .requestMatchers("/panel_user").hasAuthority(Role.RoleType.RoleAdmin.name())
.requestMatchers("/panel_inventory").hasAuthority(Role.RoleType.RoleAdmin.name())
.requestMatchers("/goods").hasAuthority(Role.RoleType.RoleAdmin.name())
.requestMatchers("/api/**").hasAuthority(Role.RoleType.RoleAdmin.name()) .requestMatchers("/api/**").hasAuthority(Role.RoleType.RoleAdmin.name())
.requestMatchers("/main").hasAnyAuthority(Role.RoleType.RoleUser.name(), Role.RoleType.RoleAdmin.name()) .requestMatchers("/main").hasAnyAuthority(Role.RoleType.RoleUser.name(), Role.RoleType.RoleAdmin.name())
.requestMatchers("/"+ FileServerController.URL_PATH +"/**").permitAll() .requestMatchers("/"+ FileServerController.URL_PATH +"/**").permitAll()

View File

@ -6,8 +6,6 @@ import com.alterdekim.game.component.game.avatar.IBodyAvatarItem;
import com.alterdekim.game.component.game.avatar.BodyPartType; import com.alterdekim.game.component.game.avatar.BodyPartType;
import com.alterdekim.game.component.game.avatar.GoodClothType; import com.alterdekim.game.component.game.avatar.GoodClothType;
import com.alterdekim.game.component.game.avatar.InitMagicAbility; import com.alterdekim.game.component.game.avatar.InitMagicAbility;
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
import com.alterdekim.game.component.game.home.HomeInventoryObject;
import com.alterdekim.game.component.game.inventory.InventoryGroup; import com.alterdekim.game.component.game.inventory.InventoryGroup;
import com.alterdekim.game.component.game.inventory.InventoryItem; import com.alterdekim.game.component.game.inventory.InventoryItem;
import com.alterdekim.game.controller.result.signup.AvatarBodyPart; import com.alterdekim.game.controller.result.signup.AvatarBodyPart;
@ -229,9 +227,11 @@ public class AvatarInventoryService {
.findFirst().orElse(0L); .findFirst().orElse(0L);
} }
public Optional<AvatarInventory> getUsedHouse(Integer userId) { public Long getUsedHouse(Integer userId) {
return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House) return this.inventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House)
.stream().findFirst(); .stream()
.map(AvatarInventory::getGoodId)
.findFirst().orElse(0L);
} }
public String getAchievementsByUserId(Integer userId) { public String getAchievementsByUserId(Integer userId) {

View File

@ -7,7 +7,6 @@ import lombok.AllArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
import java.util.Optional; import java.util.Optional;
@ -26,8 +25,4 @@ public class GoodsService implements OutputObjectCallback {
public Optional<Good> findById(Long id) { public Optional<Good> findById(Long id) {
return this.repository.findById(id); return this.repository.findById(id);
} }
public List<Good> getAll() {
return this.repository.findAll();
}
} }

View File

@ -1,90 +0,0 @@
package com.alterdekim.game.service;
import com.alterdekim.game.component.ReferenceLoader;
import com.alterdekim.game.component.game.AvatarInventoryType;
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
import com.alterdekim.game.component.game.home.HomeInventoryObject;
import com.alterdekim.game.entity.AvatarInventory;
import com.alterdekim.game.entity.Good;
import com.alterdekim.game.entity.HouseInventory;
import com.alterdekim.game.message.amf.AMFObject;
import com.alterdekim.game.repository.AvatarInventoryRepository;
import com.alterdekim.game.repository.GoodRepository;
import com.alterdekim.game.repository.HouseInventoryRepository;
import lombok.extern.slf4j.Slf4j;
import org.javatuples.Pair;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
@Slf4j
@Service
public class HomeInventoryService {
@Autowired
private HouseInventoryRepository houseInventoryRepository;
@Autowired
private AvatarInventoryRepository avatarInventoryRepository;
@Autowired
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) {
Set<String> ids = additions.keySet();
long houseId = getCurrentHouseId(userId);
for( String id : ids ) {
Map<String, AMFObject> obj = (Map<String, AMFObject>) additions.get(id).getRaw();
Integer frame = obj.containsKey("Frame") ? obj.get("Frame").getInt() : 0;
houseInventoryRepository.updateInfoById(Long.parseLong(id), houseId, obj.get("x").getDouble(), obj.get("y").getDouble(), frame);
}
}
private long getCurrentHouseId(int userId) {
return avatarInventoryRepository.findUsedItemsByUserIdAndType(userId, AvatarInventoryType.House).stream()
.findFirst()
.map(AvatarInventory::getId)
.orElse(-1L);
}
public List<HomeInventoryGroup> getHomeInventoryOfUser(int userId) {
List<HomeInventoryGroup> groups = this.houseInventoryRepository.findByUserId(userId)
.stream()
.map(HouseInventory::getGoodId)
.distinct()
.map(i -> goodRepository.findById(i))
.filter(Optional::isPresent)
.map(Optional::get)
.map(i -> new HomeInventoryGroup("1$"+i.getId(),
1,
i.getId(),
i.getGoodTypeId(),
i.getMRId(),
i.getTRId(),
new ArrayList<>()))
.collect(Collectors.toList());
this.houseInventoryRepository.findByUserId(userId)
.forEach(i -> {
for( HomeInventoryGroup group : groups ) {
if( group.getObjectId() == i.getGoodId().longValue() ) {
group.getObject().add(new HomeInventoryObject(i.getId().intValue(), i.getHomeId() != -1));
break;
}
}
});
return groups;
}
}

View File

@ -2,8 +2,14 @@ package com.alterdekim.game.service;
import com.alterdekim.game.component.game.PlayerProperties; import com.alterdekim.game.component.game.PlayerProperties;
import com.alterdekim.game.component.game.response.location.LocationObject; import com.alterdekim.game.component.game.response.location.LocationObject;
import com.alterdekim.game.entity.*; import com.alterdekim.game.entity.Good;
import com.alterdekim.game.repository.*; import com.alterdekim.game.entity.HouseLocation;
import com.alterdekim.game.entity.Location;
import com.alterdekim.game.entity.LocationObjectInstance;
import com.alterdekim.game.repository.GoodRepository;
import com.alterdekim.game.repository.HouseLocationRepository;
import com.alterdekim.game.repository.LocationObjectInstanceRepository;
import com.alterdekim.game.repository.LocationRepository;
import com.alterdekim.game.utils.GameUtils; import com.alterdekim.game.utils.GameUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
@ -11,7 +17,6 @@ import org.springframework.stereotype.Service;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Optional; import java.util.Optional;
import java.util.stream.Collectors;
@Service @Service
public class LocationService { public class LocationService {
@ -34,9 +39,6 @@ public class LocationService {
@Autowired @Autowired
private UserService userService; private UserService userService;
@Autowired
private HouseInventoryRepository houseInventoryRepository;
public List<LocationObjectInstance> getAllLocationObjects() { public List<LocationObjectInstance> getAllLocationObjects() {
return this.locationObjectInstanceRepository.findAll(); return this.locationObjectInstanceRepository.findAll();
} }
@ -81,26 +83,9 @@ public class LocationService {
public LocationObject getHomeByUserId(Integer userId) { public LocationObject getHomeByUserId(Integer userId) {
Long goodId = avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getGoodId).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(GameUtils.convertToSpecialLocation(userId, true), true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(), return new LocationObject(GameUtils.convertToSpecialLocation(userId, true), true, false, userService.getBooleanUserProperty(userId, PlayerProperties.IsHomeLocked, true), true, house.getMediaResourceId().longValue(), 300.0, 300.0, "", userId, userService.getUsernameById(userId).get(), Collections.emptyList());
houseInventoryRepository.findByUserIdAndHouseId(userId, avatarInventoryService.getUsedHouse(userId).map(AvatarInventory::getId).orElse(-1L))
.stream()
.map(h -> new LocationObjectInstance(
h.getId(),
1,
h.getId().intValue(),
h.getGoodId().intValue(),
goodRepository.findById(h.getGoodId()).get().getMRId().longValue(),
null,
h.getX(),
h.getY(),
"",
"",
h.getFrame()
))
.collect(Collectors.toList())
);
} }
public void addHouseLocation(HouseLocation house) { public void addHouseLocation(HouseLocation house) {

View File

@ -7,8 +7,6 @@ import lombok.NoArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List;
@Service @Service
@NoArgsConstructor @NoArgsConstructor
public class MAService implements OutputObjectCallback { public class MAService implements OutputObjectCallback {
@ -20,8 +18,4 @@ public class MAService implements OutputObjectCallback {
public void onOutputObjectReady(Object o) { public void onOutputObjectReady(Object o) {
this.repository.save((MagicAbility) o); this.repository.save((MagicAbility) o);
} }
public List<MagicAbility> getAll() {
return this.repository.findAll();
}
} }

View File

@ -28,8 +28,4 @@ public class MRTService implements OutputObjectCallback {
public List<MediaResourcePath> getAll() { public List<MediaResourcePath> getAll() {
return this.repository.findAll(); return this.repository.findAll();
} }
public MediaResourcePath findById(Long id) {
return this.repository.findById(id).get();
}
} }

View File

@ -8,7 +8,6 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.List; import java.util.List;
import java.util.Optional;
@NoArgsConstructor @NoArgsConstructor
@Service @Service
@ -25,8 +24,4 @@ public class TRService implements OutputObjectCallback {
public List<TextResource> getAll() { public List<TextResource> getAll() {
return this.repository.findAll(); return this.repository.findAll();
} }
public Optional<TextResource> findById(Long id) {
return this.repository.findById(id);
}
} }

View File

@ -3,7 +3,6 @@ package com.alterdekim.game.service;
import com.alterdekim.game.component.game.*; import com.alterdekim.game.component.game.*;
import com.alterdekim.game.component.game.avatar.*; import com.alterdekim.game.component.game.avatar.*;
import com.alterdekim.game.component.game.friends.UserFriend; import com.alterdekim.game.component.game.friends.UserFriend;
import com.alterdekim.game.component.game.home.HomeInventoryGroup;
import com.alterdekim.game.component.game.inventory.Inventory; import com.alterdekim.game.component.game.inventory.Inventory;
import com.alterdekim.game.component.game.inventory.InventoryList; import com.alterdekim.game.component.game.inventory.InventoryList;
import com.alterdekim.game.component.game.inventory.InventoryTab; import com.alterdekim.game.component.game.inventory.InventoryTab;
@ -12,7 +11,6 @@ import com.alterdekim.game.component.game.response.init.UserInfo;
import com.alterdekim.game.component.game.response.init.UserInitInfo; import com.alterdekim.game.component.game.response.init.UserInitInfo;
import com.alterdekim.game.component.game.response.init.UserPhone; import com.alterdekim.game.component.game.response.init.UserPhone;
import com.alterdekim.game.entity.*; import com.alterdekim.game.entity.*;
import com.alterdekim.game.repository.HouseInventoryRepository;
import com.alterdekim.game.repository.RoleRepository; import com.alterdekim.game.repository.RoleRepository;
import com.alterdekim.game.repository.UserPropertyRepository; import com.alterdekim.game.repository.UserPropertyRepository;
import com.alterdekim.game.repository.UserRepository; import com.alterdekim.game.repository.UserRepository;
@ -55,9 +53,6 @@ public class UserService {
@Autowired @Autowired
private IncompatibleService incompatibleService; private IncompatibleService incompatibleService;
@Autowired
private HouseInventoryRepository houseInventoryRepository;
public User findByUsername(String username) { public User findByUsername(String username) {
return userRepository.findByUsername(username); return userRepository.findByUsername(username);
@ -362,8 +357,5 @@ 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 || type == AvatarInventoryType.HouseFurnitureWall ) {
houseInventoryRepository.save(new HouseInventory(userRepository.getReferenceById(userId), goodId, -1L, 0.0, 0.0, 0));
}
} }
} }

View File

@ -1,35 +0,0 @@
function initGoodTable(tag, data) {
if( data.length <= 0 ) return;
let keys = Object.keys(data[0]);
let header = "";
for( let i = 0; i < keys.length; i++ ) {
header += "<th>" + keys[i] + "</th>";
}
$($(tag).children("thead")[0]).html("<tr>"+header+"</tr>");
for( let i = 0; i < data.length; i++ ) {
header = "";
let row_id = data[i]["id"];
for( let u = 0; u < keys.length; u++ ) {
if( keys[u] == "url" ) {
header += "<td><img class=\"good-img\" src=\"/"+data[i][keys[u]]+"\"></td>";
} else {
header += "<td>" + data[i][keys[u]] + "</td>";
}
}
let tabName = tag.substring(1);
$($(tag).children("tbody")[0]).append("<tr data-rownum=\""+row_id+"\" data-table=\""+tabName[0].toUpperCase()+tabName.substring(1)+"\">"+header+"</tr>");
}
}
function getUserGoods() {
$.get( "/api/get_goods", function( data ) {
initGoodTable("#goods", data);
set_loading("#goods", false);
});
}
function set_loading(obj, state) {
$(obj).attr("aria-busy", state);
}
getUserGoods();

View File

@ -1,35 +0,0 @@
function initGoodTable(tag, data) {
if( data.length <= 0 ) return;
let keys = Object.keys(data[0]);
let header = "";
for( let i = 0; i < keys.length; i++ ) {
header += "<th>" + keys[i] + "</th>";
}
$($(tag).children("thead")[0]).html("<tr>"+header+"</tr>");
for( let i = 0; i < data.length; i++ ) {
header = "";
let row_id = data[i]["id"];
for( let u = 0; u < keys.length; u++ ) {
if( keys[u] == "url" ) {
header += "<td><img class=\"good-img\" src=\"/"+data[i][keys[u]]+"\"></td>";
} else {
header += "<td>" + data[i][keys[u]] + "</td>";
}
}
let tabName = tag.substring(1);
$($(tag).children("tbody")[0]).append("<tr data-rownum=\""+row_id+"\" data-table=\""+tabName[0].toUpperCase()+tabName.substring(1)+"\">"+header+"</tr>");
}
}
function getUserGoods() {
$.get( "/api/get_avatar_inventory?id="+$("#user_init_info").attr("data-id"), function( data ) {
initGoodTable("#inventory", data);
set_loading("#inventory", false);
});
}
function set_loading(obj, state) {
$(obj).attr("aria-busy", state);
}
getUserGoods();

View File

@ -1,7 +1,6 @@
const roleFlags = [ const roleFlags = [
"NONE", "NONE",
"MEMBER", "MEMBER",
"BOSS",
"SA", "SA",
"MODERATOR", "MODERATOR",
"ADMINISTRATOR", "ADMINISTRATOR",

View File

@ -18,8 +18,3 @@ td > img {
height: 28px; height: 28px;
cursor: pointer; cursor: pointer;
} }
.good-img {
width: 125px;
height: 100px;
}

View File

@ -7,9 +7,13 @@
<li><a href="/panel?section=Games">Games</a></li> <li><a href="/panel?section=Games">Games</a></li>
<li><a href="/panel?section=Preloaders">Preloaders</a></li> <li><a href="/panel?section=Preloaders">Preloaders</a></li>
<li><a href="/panel?section=Users">Users</a></li> <li><a href="/panel?section=Users">Users</a></li>
<li><a href="/goods">Goods</a></li> <li><a href="/panel?section=Banlist">Banlist</a></li>
<li><a href="/panel?section=Cache">Cache</a></li>
<li><a href="/panel?section=Goods">Goods</a></li>
<li><a href="/panel?section=Items">Items list</a></li> <li><a href="/panel?section=Items">Items list</a></li>
<li><a href="/panel?section=Actions">Actions</a></li> <li><a href="/panel?section=Actions">Actions</a></li>
<li><a href="/panel?section=Support">Support</a></li>
<li><a href="/panel?section=Settings">Settings</a></li>
</ul> </ul>
</nav> </nav>
</aside> </aside>

View File

@ -1,20 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<th:block th:insert="~{fragments/head}"></th:block>
</head>
<body>
<th:block th:insert="~{fragments/header}"></th:block>
<main class="container grid" style="grid-template-columns: 1fr 6fr;">
<th:block th:insert="~{fragments/aside}"></th:block>
<div class="container-fluid">
<h2>Goods with names</h2>
<table id="goods" aria-busy="true">
<thead></thead>
<tbody></tbody>
</table>
</div>
</main>
</body>
<script type="text/javascript" src="/file/_js/goods.js"></script>
</html>

View File

@ -1,31 +0,0 @@
<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.w3.org/1999/xhtml">
<head>
<th:block th:insert="~{fragments/head}"></th:block>
</head>
<body>
<th:block th:insert="~{fragments/header}"></th:block>
<main class="container grid" style="grid-template-columns: 1fr 6fr;">
<th:block th:insert="~{fragments/aside}"></th:block>
<div class="container-fluid">
<h2 id="user_init_info" th:data-id="${user_id}" th:text="${user_name}"></h2>
<form method="POST" action="/panel_inventory">
<fieldset role="group">
<input type="hidden" name="id" th:value="${user_id}">
<input
type="number"
name="good_id"
placeholder="Enter good id"
/>
<input type="submit" value="Add to inventory" />
</fieldset>
</form>
<table id="inventory" aria-busy="true">
<thead></thead>
<tbody></tbody>
</table>
</div>
</main>
</body>
<script type="text/javascript" src="/file/_js/inventory.js"></script>
</html>

View File

@ -9,7 +9,6 @@
<th:block th:insert="~{fragments/aside}"></th:block> <th:block th:insert="~{fragments/aside}"></th:block>
<div class="container-fluid"> <div class="container-fluid">
<h2 id="user_init_info" th:data-id="${user_id}" th:text="${user_name}"></h2> <h2 id="user_init_info" th:data-id="${user_id}" th:text="${user_name}"></h2>
<a th:href="${inventory_link}"><button class="primary">Inventory</button></a>
<table id="properties" aria-busy="true"> <table id="properties" aria-busy="true">
<thead></thead> <thead></thead>
<tbody></tbody> <tbody></tbody>