mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 04:57:18 +00:00
Merge branch 'development' into startMail
This commit is contained in:
commit
31764fe5d9
23
.github/ISSUE_TEMPLATE/a_issue_report.md
vendored
Normal file
23
.github/ISSUE_TEMPLATE/a_issue_report.md
vendored
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
---
|
||||||
|
name: Issues
|
||||||
|
about: Create an issue if you need any help
|
||||||
|
title: '[Issue] '
|
||||||
|
labels: 'help wanted, question'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
**Did you look for other closed issues that have the same problem?**
|
||||||
|
<!--- It will be easier for us to solve your problem if there is less duplication of problems -->
|
||||||
|
|
||||||
|
**Describe the issue**
|
||||||
|
<!--- A clear and concise description of what the issue is. -->
|
||||||
|
|
||||||
|
**Which branch did you use?**
|
||||||
|
<!--- Stable branch / Development branch -->
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
<!--- If applicable, add screenshots to help explain your problem. -->
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
<!--- Add any other context about the problem here. -->
|
||||||
|
|
21
.github/ISSUE_TEMPLATE/b_bug_report.md
vendored
Normal file
21
.github/ISSUE_TEMPLATE/b_bug_report.md
vendored
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
---
|
||||||
|
name: Bug report
|
||||||
|
about: Create a bug report to help us improve Grasscutter
|
||||||
|
title: '[Bug] '
|
||||||
|
labels: 'bug'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
<!--- ONLY USE this form for bug reporting. If you need help or support, please USE issue report form instead. -->
|
||||||
|
|
||||||
|
**Describe the bug**
|
||||||
|
<!--- A clear and concise description of what the bug is. -->
|
||||||
|
|
||||||
|
**Which branch did you use?**
|
||||||
|
<!--- Stable branch / Development branch -->
|
||||||
|
|
||||||
|
**Screenshots**
|
||||||
|
<!--- If applicable, add screenshots to help explain your problem. -->
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
<!--- Add any other context about the problem here. -->
|
20
.github/ISSUE_TEMPLATE/c_feature_request.md
vendored
Normal file
20
.github/ISSUE_TEMPLATE/c_feature_request.md
vendored
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
---
|
||||||
|
name: Feature request
|
||||||
|
about: Suggest an idea for Grasscutter
|
||||||
|
title: '[Feature Request] '
|
||||||
|
labels: 'enhancement, suggestion'
|
||||||
|
assignees: ''
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
|
**Is your feature request related to a problem? Please describe.**
|
||||||
|
<!--- A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] -->
|
||||||
|
|
||||||
|
**Describe the solution you'd like**
|
||||||
|
<!--- A clear and concise description of what you want to happen. -->
|
||||||
|
|
||||||
|
**Describe alternatives you've considered**
|
||||||
|
<!--- A clear and concise description of any alternative solutions or features you've considered. -->
|
||||||
|
|
||||||
|
**Additional context**
|
||||||
|
<!--- Add any other context or screenshots about the feature request here. -->
|
6
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
6
.github/ISSUE_TEMPLATE/config.yml
vendored
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
blank_issues_enabled: false
|
||||||
|
contact_links:
|
||||||
|
- name: Grasscutter Discord
|
||||||
|
url: https://discord.gg/T5vZU6UyeG
|
||||||
|
about: For support, discuss and and other things with Grasscutter.
|
||||||
|
|
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
22
.github/PULL_REQUEST_TEMPLATE.md
vendored
Normal file
@ -0,0 +1,22 @@
|
|||||||
|
## Description
|
||||||
|
|
||||||
|
Please carefully read the [Contributing note](https://github.com/Grasscutters/Grasscutter/blob/stable/CONTRIBUTING.md) and [Code of conduct](https://github.com/Grasscutters/Grasscutter/blob/development/CODE_OF_CONDUCT.md) before making any pull requests.
|
||||||
|
And, **Do not make a pull request to merge into stable unless it is a hotfix. Use the development branch instead.**
|
||||||
|
## Issues fixed by this PR
|
||||||
|
|
||||||
|
<!--- Put the links of issues that may be fixed by this PR here (if any). -->
|
||||||
|
## Type of changes
|
||||||
|
|
||||||
|
<!--- Put an `x` in all the boxes that apply your changes. -->
|
||||||
|
|
||||||
|
- [ ] Bug fix
|
||||||
|
- [ ] New feature
|
||||||
|
- [ ] Enhancement
|
||||||
|
- [ ] Documentation
|
||||||
|
|
||||||
|
## Checklist:
|
||||||
|
|
||||||
|
- [ ] My code follows the style guidelines of this project
|
||||||
|
- [ ] My pull request is unique and no other pull requests have been opened for these changes
|
||||||
|
- [ ] I have read the [Contributing note](https://github.com/Grasscutters/Grasscutter/blob/stable/CONTRIBUTING.md) and [Code of conduct](https://github.com/Grasscutters/Grasscutter/blob/development/CODE_OF_CONDUCT.md)
|
||||||
|
- [ ] I am responsible for any copyright issues with my code if it occurs in the future.
|
@ -108,12 +108,14 @@ There is a dummy user named "Server" in every player's friends list that you can
|
|||||||
| -------------- | ------------------------------------------------- | ------------------------- | ------------ | ------------------------------------------------------------ | ----------------------------------------------- |
|
| -------------- | ------------------------------------------------- | ------------------------- | ------------ | ------------------------------------------------------------ | ----------------------------------------------- |
|
||||||
| account | account <create\|delete> <username> [UID] | | Server only | Creates an account with the specified username and the in-game UID for that account. The UID will be auto generated if not set. | |
|
| account | account <create\|delete> <username> [UID] | | Server only | Creates an account with the specified username and the in-game UID for that account. The UID will be auto generated if not set. | |
|
||||||
| broadcast | broadcast <message> | server.broadcast | Both side | Sends a message to all the players. | b |
|
| broadcast | broadcast <message> | server.broadcast | Both side | Sends a message to all the players. | b |
|
||||||
|
| coop | coop <playerId> <target playerId> | server.coop | Both side | Forces someone to join the world of others. | |
|
||||||
| changescene | changescene <scene id> | player.changescene | Client only | Switch scenes by scene ID. | scene |
|
| changescene | changescene <scene id> | player.changescene | Client only | Switch scenes by scene ID. | scene |
|
||||||
| clearartifacts | clearartifacts | player.clearartifacts | Client only | Deletes all unequipped and unlocked level 0 artifacts, including 5-star rarity ones from your inventory. | clearart |
|
| clearartifacts | clearartifacts | player.clearartifacts | Client only | Deletes all unequipped and unlocked level 0 artifacts, including 5-star rarity ones from your inventory. | clearart |
|
||||||
| clearweapons | clearweapons | player.clearweapons | Client only | Deletes all unequipped and unlocked weapons, including 5-star rarity ones from your inventory. | clearwpns |
|
| clearweapons | clearweapons | player.clearweapons | Client only | Deletes all unequipped and unlocked weapons, including 5-star rarity ones from your inventory. | clearwpns |
|
||||||
| drop | drop <itemID\|itemName> [amount] | server.drop | Client only | Drops an item around you. | `d` `dropitem` |
|
| drop | drop <itemID\|itemName> [amount] | server.drop | Client only | Drops an item around you. | `d` `dropitem` |
|
||||||
| give | give [player] <itemId\|itemName> [amount] [level] | player.give | Both side | Gives item(s) to you or the specified player. | `g` `item` `giveitem` |
|
| give | give [player] <itemId\|itemName> [amount] [level] | player.give | Both side | Gives item(s) to you or the specified player. | `g` `item` `giveitem` |
|
||||||
| givechar | givechar <uid> <avatarId> [level] | player.givechar | Both side | Gives the player a specified character. | givec |
|
| givechar | givechar <uid> <avatarId> | player.givechar | Both side | Gives the player a specified character. | givec |
|
||||||
|
| giveall | giveall [uid] [amount] | player.giveall | Both side | Gives all items. | givea |
|
||||||
| godmode | godmode [uid] | player.godmode | Client only | Prevents you from taking damage. | |
|
| godmode | godmode [uid] | player.godmode | Client only | Prevents you from taking damage. | |
|
||||||
| heal | heal | player.heal | Client only | Heals all characters in your current team. | h |
|
| heal | heal | player.heal | Client only | Heals all characters in your current team. | h |
|
||||||
| help | help [command] | | Both side | Sends the help message or shows information about a specified command. | |
|
| help | help [command] | | Both side | Sends the help message or shows information about a specified command. | |
|
||||||
@ -133,6 +135,7 @@ There is a dummy user named "Server" in every player's friends list that you can
|
|||||||
| stop | stop | server.stop | Both side | Stops the server | |
|
| stop | stop | server.stop | Both side | Stops the server | |
|
||||||
| talent | talent <talentID> <value> | player.settalent | Client only | Sets talent level for your currently selected character | |
|
| talent | talent <talentID> <value> | player.settalent | Client only | Sets talent level for your currently selected character | |
|
||||||
| teleport | teleport <x> <y> <z> | player.teleport | Client only | Change the player's position. | tp |
|
| teleport | teleport <x> <y> <z> | player.teleport | Client only | Change the player's position. | tp |
|
||||||
|
| tpall | | player.tpall | Client only | Teleports all players in your world to your position | |
|
||||||
| weather | weather <weatherID> <climateID> | player.weather | Client only | Changes the weather | w |
|
| weather | weather <weatherID> <climateID> | player.weather | Client only | Changes the weather | w |
|
||||||
|
|
||||||
### Bonus
|
### Bonus
|
||||||
|
@ -109,12 +109,14 @@ chmod +x gradlew
|
|||||||
| -------------- | -------------------------------------------- | ------------------------- | -------- | ------------------------------------------ | ----------------------------------------------- |
|
| -------------- | -------------------------------------------- | ------------------------- | -------- | ------------------------------------------ | ----------------------------------------------- |
|
||||||
| account | account <create\|delete> <用户名> [uid] | | 仅服务端 | 通过指定用户名和uid增删账户 | |
|
| account | account <create\|delete> <用户名> [uid] | | 仅服务端 | 通过指定用户名和uid增删账户 | |
|
||||||
| broadcast | broadcast <消息内容> | server.broadcast | 均可使用 | 给所有玩家发送公告 | b |
|
| broadcast | broadcast <消息内容> | server.broadcast | 均可使用 | 给所有玩家发送公告 | b |
|
||||||
|
| coop | coop <uid> <目标uid> | server.coop | 均可使用 | 强制某位玩家进入指定玩家的多人世界 | |
|
||||||
| changescene | changescene <场景ID> | player.changescene | 仅客户端 | 切换到指定场景 | scene |
|
| changescene | changescene <场景ID> | player.changescene | 仅客户端 | 切换到指定场景 | scene |
|
||||||
| clearartifacts | clearartifacts | player.clearartifacts | 仅客户端 | 删除所有未装备及未解锁的圣遗物,包括五星 | clearart |
|
| clearartifacts | clearartifacts | player.clearartifacts | 仅客户端 | 删除所有未装备及未解锁的圣遗物,包括五星 | clearart |
|
||||||
| clearweapons | clearweapons | player.clearweapons | 仅客户端 | 删除所有未装备及未解锁的武器,包括五星 | clearwp |
|
| clearweapons | clearweapons | player.clearweapons | 仅客户端 | 删除所有未装备及未解锁的武器,包括五星 | clearwp |
|
||||||
| drop | drop <物品ID\|物品名称> [数量] | server.drop | 仅客户端 | 在指定玩家周围掉落指定物品 | `d` `dropitem` |
|
| drop | drop <物品ID\|物品名称> [数量] | server.drop | 仅客户端 | 在指定玩家周围掉落指定物品 | `d` `dropitem` |
|
||||||
| give | give [uid] <物品ID\|物品名称> [数量] [等级] | | | 给予指定玩家一定数量及等级的物品 | `g` `item` `giveitem` |
|
| give | give [uid] <物品ID\|物品名称> [数量] [等级] | | | 给予指定玩家一定数量及等级的物品 | `g` `item` `giveitem` |
|
||||||
| givechar | givechar <uid> <角色ID> [等级] | player.givechar | 均可使用 | 给予指定玩家对应角色 | givec |
|
| givechar | givechar <uid> <角色ID> [等级] | player.givechar | 均可使用 | 给予指定玩家对应角色 | givec |
|
||||||
|
| giveall | giveall [uid] [数量] | player.giveall | 均可使用 | 给予指定玩家全部物品 | givea |
|
||||||
| godmode | godmode [uid] | player.godmode | 仅客户端 | 保护你不受到任何伤害(依然会被击退) | |
|
| godmode | godmode [uid] | player.godmode | 仅客户端 | 保护你不受到任何伤害(依然会被击退) | |
|
||||||
| heal | heal | player.heal | 仅客户端 | 治疗队伍中所有角色 | h |
|
| heal | heal | player.heal | 仅客户端 | 治疗队伍中所有角色 | h |
|
||||||
| help | help [命令] | | 均可使用 | 显示帮助或展示指定命令的帮助 | |
|
| help | help [命令] | | 均可使用 | 显示帮助或展示指定命令的帮助 | |
|
||||||
@ -134,6 +136,7 @@ chmod +x gradlew
|
|||||||
| stop | stop | server.stop | 均可使用 | 停止服务器 | |
|
| stop | stop | server.stop | 均可使用 | 停止服务器 | |
|
||||||
| talent | talent <天赋ID> <等级> | player.settalent | 仅客户端 | 设置当前角色的天赋等级 | |
|
| talent | talent <天赋ID> <等级> | player.settalent | 仅客户端 | 设置当前角色的天赋等级 | |
|
||||||
| teleport | teleport <x> <y> <z> | player.teleport | 仅客户端 | 传送玩家到指定坐标 | tp |
|
| teleport | teleport <x> <y> <z> | player.teleport | 仅客户端 | 传送玩家到指定坐标 | tp |
|
||||||
|
| tpall | | player.tpall | 仅客户端 | 传送多人世界中所有的玩家到自身地点 | |
|
||||||
| weather | weather <天气ID> <气候ID> | player.weather | 仅客户端 | 改变天气 | w |
|
| weather | weather <天气ID> <气候ID> | player.weather | 仅客户端 | 改变天气 | w |
|
||||||
|
|
||||||
### 额外功能
|
### 额外功能
|
||||||
|
199794
data/Drop.json
199794
data/Drop.json
File diff suppressed because it is too large
Load Diff
@ -75,6 +75,8 @@ public final class Config {
|
|||||||
public String WelcomeMailContent = "Hi there!\r\nFirst of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r\n\r\nCheck out our:\r\n<type=\"browser\" text=\"Discord\" href=\"https://discord.gg/T5vZU6UyeG\"/> <type=\"browser\" text=\"GitHub\" href=\"https://github.com/Melledy/Grasscutter\"/>";
|
public String WelcomeMailContent = "Hi there!\r\nFirst of all, welcome to Grasscutter. If you have any issues, please let us know so that Lawnmower can help you! \r\n\r\nCheck out our:\r\n<type=\"browser\" text=\"Discord\" href=\"https://discord.gg/T5vZU6UyeG\"/> <type=\"browser\" text=\"GitHub\" href=\"https://github.com/Melledy/Grasscutter\"/>";
|
||||||
public int[] WelcomeMailItems = {13509};
|
public int[] WelcomeMailItems = {13509};
|
||||||
|
|
||||||
|
public boolean EnableOfficialShop = true;
|
||||||
|
|
||||||
public GameRates Game = new GameRates();
|
public GameRates Game = new GameRates();
|
||||||
|
|
||||||
public GameRates getGameRates() { return Game; }
|
public GameRates getGameRates() { return Game; }
|
||||||
|
@ -0,0 +1,36 @@
|
|||||||
|
package emu.grasscutter.command.commands;
|
||||||
|
|
||||||
|
import emu.grasscutter.command.Command;
|
||||||
|
import emu.grasscutter.command.CommandHandler;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Command(label = "coop", usage = "coop",
|
||||||
|
description = "Forces someone to join the world of others", permission = "server.coop")
|
||||||
|
public class CoopCommand implements CommandHandler {
|
||||||
|
@Override
|
||||||
|
public void execute(Player sender, List<String> args) {
|
||||||
|
if (args.size() < 2) {
|
||||||
|
CommandHandler.sendMessage(sender, "Usage: coop <playerId> <target playerId>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
int tid = Integer.parseInt(args.get(0));
|
||||||
|
int hostId = Integer.parseInt(args.get(1));
|
||||||
|
Player host = sender.getServer().getPlayerByUid(hostId);
|
||||||
|
Player want = sender.getServer().getPlayerByUid(tid);
|
||||||
|
if (host == null || want == null) {
|
||||||
|
CommandHandler.sendMessage(sender, "Player is offline.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (want.isInMultiplayer()) {
|
||||||
|
sender.getServer().getMultiplayerManager().leaveCoop(want);
|
||||||
|
}
|
||||||
|
sender.getServer().getMultiplayerManager().applyEnterMp(want, hostId);
|
||||||
|
sender.getServer().getMultiplayerManager().applyEnterMpReply(host, tid, true);
|
||||||
|
} catch (Exception e) {
|
||||||
|
CommandHandler.sendMessage(sender, "Player id is not valid.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -13,7 +13,7 @@ import emu.grasscutter.game.player.Player;
|
|||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@Command(label = "giveall", usage = "giveall [player] <amount>",
|
@Command(label = "giveall", usage = "giveall [player] [amount]",
|
||||||
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
|
description = "Gives all items", aliases = {"givea"}, permission = "player.giveall", threading = true)
|
||||||
public class GiveAllCommand implements CommandHandler {
|
public class GiveAllCommand implements CommandHandler {
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public class GiveAllCommand implements CommandHandler {
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
default: // invalid
|
default: // invalid
|
||||||
CommandHandler.sendMessage(null, "Usage: giveall [player] <amount>");
|
CommandHandler.sendMessage(null, "Usage: giveall [player] [amount]");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -142,7 +142,7 @@ public class GiveAllCommand implements CommandHandler {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (testItemsList.contains(itemId)) {
|
if (testItemsList.contains(itemId)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -175,7 +175,6 @@ public class GiveAllCommand implements CommandHandler {
|
|||||||
new Range(2017, 2029),
|
new Range(2017, 2029),
|
||||||
// new Range(108001, 108387) //food
|
// new Range(108001, 108387) //food
|
||||||
};
|
};
|
||||||
|
|
||||||
private static final Integer[] testItemsIds = new Integer[] {
|
private static final Integer[] testItemsIds = new Integer[] {
|
||||||
210, 211, 314, 315, 317, 1005, 1007, 1105, 1107, 1201, 1202, 2800,
|
210, 211, 314, 315, 317, 1005, 1007, 1105, 1107, 1201, 1202, 2800,
|
||||||
100001, 100002, 100244, 100305, 100312, 100313, 101212, 11411, 11506, 11507, 11508, 12505,
|
100001, 100002, 100244, 100305, 100312, 100313, 101212, 11411, 11506, 11507, 11508, 12505,
|
||||||
|
@ -0,0 +1,31 @@
|
|||||||
|
package emu.grasscutter.command.commands;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.command.Command;
|
||||||
|
import emu.grasscutter.command.CommandHandler;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Command(label = "resetshop", usage = "resetshop",
|
||||||
|
description = "Reset target player's shop refresh time.", permission = "server.resetshop")
|
||||||
|
public final class ResetShopLimitCommand implements CommandHandler {
|
||||||
|
@Override
|
||||||
|
public void execute(Player sender, List<String> args) {
|
||||||
|
if (args.size() < 1) {
|
||||||
|
CommandHandler.sendMessage(sender,"Usage: /resetshop <player id>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
int target = Integer.parseInt(args.get(0));
|
||||||
|
Player targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
|
||||||
|
if (targetPlayer == null) {
|
||||||
|
CommandHandler.sendMessage(sender, "Player not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
targetPlayer.getShopLimit().forEach(x -> x.setNextRefreshTime(0));
|
||||||
|
targetPlayer.save();
|
||||||
|
CommandHandler.sendMessage(sender, "Success");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,31 @@
|
|||||||
|
package emu.grasscutter.command.commands;
|
||||||
|
|
||||||
|
import emu.grasscutter.command.Command;
|
||||||
|
import emu.grasscutter.command.CommandHandler;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@Command(label = "tpall", usage = "tpall",
|
||||||
|
description = "Teleports all players in your world to your position", permission = "player.tpall")
|
||||||
|
public class TpallCommand implements CommandHandler {
|
||||||
|
@Override
|
||||||
|
public void execute(Player sender, List<String> args) {
|
||||||
|
if (sender == null) {
|
||||||
|
CommandHandler.sendMessage(null, "Run this command in-game.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (!sender.getWorld().isMultiplayer()) {
|
||||||
|
CommandHandler.sendMessage(sender, "You only can use this command in MP mode.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for (Player gp : sender.getWorld().getPlayers()) {
|
||||||
|
if (gp.equals(sender))
|
||||||
|
continue;
|
||||||
|
Position pos = sender.getPos();
|
||||||
|
|
||||||
|
gp.getWorld().transferPlayerToScene(gp, sender.getSceneId(), pos);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -62,8 +62,11 @@ public class GameData {
|
|||||||
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<RewardData> rewardDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
private static final Int2ObjectMap<WorldLevelData> worldLevelDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
|
private static final Int2ObjectMap<ShopGoodsData> shopGoodsDataMap = new Int2ObjectOpenHashMap<>();
|
||||||
|
|
||||||
// Cache
|
// Cache
|
||||||
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
private static Map<Integer, List<Integer>> fetters = new HashMap<>();
|
||||||
|
private static Map<Integer, List<ShopGoodsData>> shopGoods = new HashMap<>();
|
||||||
|
|
||||||
public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
|
public static Int2ObjectMap<?> getMapByResourceDef(Class<?> resourceDefinition) {
|
||||||
Int2ObjectMap<?> map = null;
|
Int2ObjectMap<?> map = null;
|
||||||
@ -266,5 +269,17 @@ public class GameData {
|
|||||||
return worldLevelDataMap;
|
return worldLevelDataMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static char EJWOA = 's';
|
public static char EJWOA = 's';
|
||||||
|
|
||||||
|
public static Map<Integer, List<ShopGoodsData>> getShopGoodsDataEntries() {
|
||||||
|
if (shopGoods.isEmpty()) {
|
||||||
|
shopGoodsDataMap.forEach((k, v) -> {
|
||||||
|
if (!shopGoods.containsKey(v.getShopType()))
|
||||||
|
shopGoods.put(v.getShopType(), new ArrayList<>());
|
||||||
|
shopGoods.get(v.getShopType()).add(v);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return shopGoods;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,12 @@ public class ItemParamData {
|
|||||||
private int Id;
|
private int Id;
|
||||||
private int Count;
|
private int Count;
|
||||||
|
|
||||||
|
public ItemParamData() {}
|
||||||
|
public ItemParamData(int id, int count) {
|
||||||
|
this.Id = id;
|
||||||
|
this.Count = count;
|
||||||
|
}
|
||||||
|
|
||||||
public int getId() {
|
public int getId() {
|
||||||
return Id;
|
return Id;
|
||||||
}
|
}
|
||||||
|
@ -8,13 +8,14 @@ public class GadgetData extends GameResource {
|
|||||||
private int Id;
|
private int Id;
|
||||||
|
|
||||||
private String Type;
|
private String Type;
|
||||||
private String JsonName;
|
private String JsonName;
|
||||||
private boolean IsInteractive;
|
private boolean IsInteractive;
|
||||||
private String[] Tags;
|
private String[] Tags;
|
||||||
private String ItemJsonName;
|
private String ItemJsonName;
|
||||||
private String InteeIconName;
|
private String InteeIconName;
|
||||||
private long NameTextMapHash;
|
private long NameTextMapHash;
|
||||||
private int CampID;
|
private int CampID;
|
||||||
|
private String LODPatternName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int getId() {
|
public int getId() {
|
||||||
@ -53,6 +54,8 @@ public class GadgetData extends GameResource {
|
|||||||
return CampID;
|
return CampID;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getLODPatternName() { return LODPatternName; }
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onLoad() {
|
public void onLoad() {
|
||||||
|
|
||||||
|
108
src/main/java/emu/grasscutter/data/def/ShopGoodsData.java
Normal file
108
src/main/java/emu/grasscutter/data/def/ShopGoodsData.java
Normal file
@ -0,0 +1,108 @@
|
|||||||
|
package emu.grasscutter.data.def;
|
||||||
|
|
||||||
|
import emu.grasscutter.data.GameResource;
|
||||||
|
import emu.grasscutter.data.ResourceType;
|
||||||
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
|
import emu.grasscutter.game.shop.ShopInfo;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@ResourceType(name = "ShopGoodsExcelConfigData.json")
|
||||||
|
public class ShopGoodsData extends GameResource {
|
||||||
|
private int GoodsId;
|
||||||
|
private int ShopType;
|
||||||
|
private int ItemId;
|
||||||
|
|
||||||
|
private int ItemCount;
|
||||||
|
|
||||||
|
private int CostScoin;
|
||||||
|
private int CostHcoin;
|
||||||
|
private int CostMcoin;
|
||||||
|
|
||||||
|
private List<ItemParamData> CostItems;
|
||||||
|
private int MinPlayerLevel;
|
||||||
|
private int MaxPlayerLevel;
|
||||||
|
|
||||||
|
private int BuyLimit;
|
||||||
|
private int SubTabId;
|
||||||
|
|
||||||
|
private String RefreshType;
|
||||||
|
private transient ShopInfo.ShopRefreshType RefreshTypeEnum;
|
||||||
|
|
||||||
|
private int RefreshParam;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void onLoad() {
|
||||||
|
if (this.RefreshType == null)
|
||||||
|
this.RefreshTypeEnum = ShopInfo.ShopRefreshType.NONE;
|
||||||
|
else {
|
||||||
|
this.RefreshTypeEnum = switch (this.RefreshType) {
|
||||||
|
case "SHOP_REFRESH_DAILY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_DAILY;
|
||||||
|
case "SHOP_REFRESH_WEEKLY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_WEEKLY;
|
||||||
|
case "SHOP_REFRESH_MONTHLY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_MONTHLY;
|
||||||
|
default -> ShopInfo.ShopRefreshType.NONE;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getId() {
|
||||||
|
return getGoodsId();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getGoodsId() {
|
||||||
|
return GoodsId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShopType() {
|
||||||
|
return ShopType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemId() {
|
||||||
|
return ItemId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getItemCount() {
|
||||||
|
return ItemCount;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCostScoin() {
|
||||||
|
return CostScoin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCostHcoin() {
|
||||||
|
return CostHcoin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getCostMcoin() {
|
||||||
|
return CostMcoin;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<ItemParamData> getCostItems() {
|
||||||
|
return CostItems;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMinPlayerLevel() {
|
||||||
|
return MinPlayerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMaxPlayerLevel() {
|
||||||
|
return MaxPlayerLevel;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBuyLimit() {
|
||||||
|
return BuyLimit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getSubTabId() {
|
||||||
|
return SubTabId;
|
||||||
|
}
|
||||||
|
|
||||||
|
public ShopInfo.ShopRefreshType getRefreshType() {
|
||||||
|
return RefreshTypeEnum;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getRefreshParam() {
|
||||||
|
return RefreshParam;
|
||||||
|
}
|
||||||
|
}
|
@ -7,6 +7,15 @@ public class DropData {
|
|||||||
private int minCount;
|
private int minCount;
|
||||||
private int maxCount;
|
private int maxCount;
|
||||||
private boolean share = false;
|
private boolean share = false;
|
||||||
|
private boolean give = false;
|
||||||
|
|
||||||
|
public boolean isGive() {
|
||||||
|
return give;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGive(boolean give) {
|
||||||
|
this.give = give;
|
||||||
|
}
|
||||||
|
|
||||||
public int getItemId() {
|
public int getItemId() {
|
||||||
return itemId;
|
return itemId;
|
||||||
@ -43,15 +52,4 @@ public class DropData {
|
|||||||
this.share = share;
|
this.share = share;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGive() {
|
|
||||||
return give;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean give = false;
|
|
||||||
|
|
||||||
public boolean isExp() {
|
|
||||||
return exp;
|
|
||||||
}
|
|
||||||
|
|
||||||
private boolean exp = false;
|
|
||||||
}
|
}
|
||||||
|
@ -6,7 +6,11 @@ import emu.grasscutter.data.GameData;
|
|||||||
import emu.grasscutter.data.def.ItemData;
|
import emu.grasscutter.data.def.ItemData;
|
||||||
import emu.grasscutter.game.entity.EntityItem;
|
import emu.grasscutter.game.entity.EntityItem;
|
||||||
import emu.grasscutter.game.entity.EntityMonster;
|
import emu.grasscutter.game.entity.EntityMonster;
|
||||||
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
|
import emu.grasscutter.game.inventory.ItemType;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.utils.Position;
|
import emu.grasscutter.utils.Position;
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
@ -53,31 +57,44 @@ public class DropManager {
|
|||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
private void addDropEntity(DropData dd, Scene dropScene, ItemData itemData, Position pos, int num, Player target) {
|
||||||
|
if (!dd.isGive() && (itemData.getItemType() != ItemType.ITEM_VIRTUAL || itemData.getGadgetId() != 0)) {
|
||||||
|
EntityItem entity = new EntityItem(dropScene, target, itemData, pos, num, dd.isShare());
|
||||||
|
if (!dd.isShare())
|
||||||
|
dropScene.addEntityToSingleClient(target, entity);
|
||||||
|
else
|
||||||
|
dropScene.addEntity(entity);
|
||||||
|
} else {
|
||||||
|
if (target != null) {
|
||||||
|
target.getInventory().addItem(new GameItem(itemData, num), ActionReason.SubfieldDrop, true);
|
||||||
|
} else {
|
||||||
|
// target is null if items will be added are shared. no one could pick it up because of the combination(give + shared)
|
||||||
|
// so it will be sent to all players' inventories directly.
|
||||||
|
dropScene.getPlayers().forEach(x -> {
|
||||||
|
x.getInventory().addItem(new GameItem(itemData, num), ActionReason.SubfieldDrop, true);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void processDrop(DropData dd, EntityMonster em, Player gp) {
|
private void processDrop(DropData dd, EntityMonster em, Player gp) {
|
||||||
int target = Utils.randomRange(1, 10000);
|
int target = Utils.randomRange(1, 10000);
|
||||||
if (target >= dd.getMinWeight() && target < dd.getMaxWeight()) {
|
if (target >= dd.getMinWeight() && target < dd.getMaxWeight()) {
|
||||||
ItemData itemData = GameData.getItemDataMap().get(dd.getItemId());
|
ItemData itemData = GameData.getItemDataMap().get(dd.getItemId());
|
||||||
int num = Utils.randomRange(dd.getMinCount(), dd.getMaxCount());
|
int num = Utils.randomRange(dd.getMinCount(), dd.getMaxCount());
|
||||||
if (!dd.isGive()) {
|
|
||||||
if (itemData.isEquip()) {
|
if (itemData == null) {
|
||||||
for (int i = 0; i < num; i++) {
|
return;
|
||||||
float range = (5f + (.1f * num));
|
}
|
||||||
Position pos = em.getPosition().clone().addX((float) (Math.random() * range) - (range / 2)).addY(3f).addZ((float) (Math.random() * range) - (range / 2));
|
if (itemData.isEquip()) {
|
||||||
EntityItem entity = new EntityItem(em.getScene(), gp, itemData, pos, num, dd.isShare());
|
for (int i = 0; i < num; i++) {
|
||||||
if (!dd.isShare())
|
float range = (5f + (.1f * num));
|
||||||
em.getScene().addEntityToSingleClient(gp, entity);
|
Position pos = em.getPosition().clone().addX((float) (Math.random() * range) - (range / 2)).addY(3f).addZ((float) (Math.random() * range) - (range / 2));
|
||||||
else
|
addDropEntity(dd, em.getScene(), itemData, pos, num, gp);
|
||||||
em.getScene().addEntity(entity);
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
Position pos = em.getPosition().clone().addY(3f);
|
|
||||||
EntityItem entity = new EntityItem(em.getScene(), gp, itemData, pos, num, dd.isShare());
|
|
||||||
if (!dd.isShare())
|
|
||||||
em.getScene().addEntityToSingleClient(gp, entity);
|
|
||||||
else
|
|
||||||
em.getScene().addEntity(entity);
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
Position pos = em.getPosition().clone().addY(3f);
|
||||||
|
addDropEntity(dd, em.getScene(), itemData, pos, num, gp);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
124
src/main/java/emu/grasscutter/game/entity/EntityVehicle.java
Normal file
124
src/main/java/emu/grasscutter/game/entity/EntityVehicle.java
Normal file
@ -0,0 +1,124 @@
|
|||||||
|
package emu.grasscutter.game.entity;
|
||||||
|
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.props.EntityIdType;
|
||||||
|
import emu.grasscutter.game.props.PlayerProperty;
|
||||||
|
import emu.grasscutter.game.world.Scene;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.proto.AbilitySyncStateInfoOuterClass.AbilitySyncStateInfo;
|
||||||
|
import emu.grasscutter.net.proto.AnimatorParameterValueInfoPairOuterClass.AnimatorParameterValueInfoPair;
|
||||||
|
import emu.grasscutter.net.proto.EntityAuthorityInfoOuterClass.EntityAuthorityInfo;
|
||||||
|
import emu.grasscutter.net.proto.EntityRendererChangedInfoOuterClass.EntityRendererChangedInfo;
|
||||||
|
import emu.grasscutter.net.proto.FightPropPairOuterClass.*;
|
||||||
|
import emu.grasscutter.net.proto.MotionInfoOuterClass.MotionInfo;
|
||||||
|
import emu.grasscutter.net.proto.PropPairOuterClass.PropPair;
|
||||||
|
import emu.grasscutter.net.proto.ProtEntityTypeOuterClass.ProtEntityType;
|
||||||
|
import emu.grasscutter.net.proto.SceneEntityAiInfoOuterClass.SceneEntityAiInfo;
|
||||||
|
import emu.grasscutter.net.proto.SceneEntityInfoOuterClass.SceneEntityInfo;
|
||||||
|
import emu.grasscutter.net.proto.SceneGadgetInfoOuterClass.SceneGadgetInfo;
|
||||||
|
import emu.grasscutter.net.proto.VectorOuterClass.Vector;
|
||||||
|
import emu.grasscutter.net.proto.VehicleInfoOuterClass.*;
|
||||||
|
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
|
import emu.grasscutter.utils.ProtoHelper;
|
||||||
|
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2FloatMap;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2FloatOpenHashMap;
|
||||||
|
|
||||||
|
public class EntityVehicle extends EntityGadget {
|
||||||
|
private final Player owner;
|
||||||
|
private final Int2FloatOpenHashMap fightProp;
|
||||||
|
|
||||||
|
private final Position pos;
|
||||||
|
private final Position rot;
|
||||||
|
|
||||||
|
private float curStamina;
|
||||||
|
private final int pointId;
|
||||||
|
private final int gadgetId;
|
||||||
|
|
||||||
|
public EntityVehicle(Scene scene, Player player, int gadgetId, int pointId, Position pos, Position rot) {
|
||||||
|
super(scene);
|
||||||
|
this.owner = player;
|
||||||
|
this.id = getScene().getWorld().getNextEntityId(EntityIdType.GADGET);
|
||||||
|
this.fightProp = new Int2FloatOpenHashMap();
|
||||||
|
this.pos = new Position(pos);
|
||||||
|
this.rot = new Position(rot);
|
||||||
|
this.gadgetId = gadgetId;
|
||||||
|
this.pointId = pointId;
|
||||||
|
this.curStamina = 240;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int getGadgetId() { return gadgetId; }
|
||||||
|
|
||||||
|
public Player getOwner() {
|
||||||
|
return owner;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getCurStamina() { return curStamina; }
|
||||||
|
|
||||||
|
public void setCurStamina(float stamina) { this.curStamina = stamina; }
|
||||||
|
|
||||||
|
public int getPointId() { return pointId; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Int2FloatOpenHashMap getFightProperties() {
|
||||||
|
return fightProp;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getPosition() { return this.pos; }
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Position getRotation() {
|
||||||
|
return this.rot;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public SceneEntityInfo toProto() {
|
||||||
|
|
||||||
|
VehicleInfo vehicle = VehicleInfo.newBuilder()
|
||||||
|
.setOwnerUid(this.owner.getUid())
|
||||||
|
.setCurStamina(getCurStamina())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
EntityAuthorityInfo authority = EntityAuthorityInfo.newBuilder()
|
||||||
|
.setAbilityInfo(AbilitySyncStateInfo.newBuilder())
|
||||||
|
.setRendererChangedInfo(EntityRendererChangedInfo.newBuilder())
|
||||||
|
.setAiInfo(SceneEntityAiInfo.newBuilder().setIsAiOpen(true).setBornPos(getPosition().toProto()))
|
||||||
|
.setBornPos(getPosition().toProto())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
SceneGadgetInfo.Builder gadgetInfo = SceneGadgetInfo.newBuilder()
|
||||||
|
.setGadgetId(this.getGadgetId())
|
||||||
|
.setAuthorityPeerId(this.getOwner().getPeerId())
|
||||||
|
.setIsEnableInteract(true)
|
||||||
|
.setVehicleInfo(vehicle);
|
||||||
|
|
||||||
|
SceneEntityInfo.Builder entityInfo = SceneEntityInfo.newBuilder()
|
||||||
|
.setEntityId(getId())
|
||||||
|
.setEntityType(ProtEntityType.PROT_ENTITY_GADGET)
|
||||||
|
.setMotionInfo(MotionInfo.newBuilder().setPos(getPosition().toProto()).setRot(getRotation().toProto()).setSpeed(Vector.newBuilder()))
|
||||||
|
.addAnimatorParaList(AnimatorParameterValueInfoPair.newBuilder())
|
||||||
|
.setGadget(gadgetInfo)
|
||||||
|
.setEntityAuthorityInfo(authority)
|
||||||
|
.setLifeState(1);
|
||||||
|
|
||||||
|
PropPair pair = PropPair.newBuilder()
|
||||||
|
.setType(PlayerProperty.PROP_LEVEL.getId())
|
||||||
|
.setPropValue(ProtoHelper.newPropValue(PlayerProperty.PROP_LEVEL, 47))
|
||||||
|
.build();
|
||||||
|
|
||||||
|
for (Int2FloatMap.Entry entry : getFightProperties().int2FloatEntrySet()) {
|
||||||
|
if (entry.getIntKey() == 0) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
FightPropPair fightProp = FightPropPair.newBuilder().setPropType(entry.getIntKey()).setPropValue(entry.getFloatValue()).build();
|
||||||
|
entityInfo.addFightPropList(fightProp);
|
||||||
|
}
|
||||||
|
|
||||||
|
entityInfo.addPropList(pair);
|
||||||
|
|
||||||
|
return entityInfo.build();
|
||||||
|
}
|
||||||
|
}
|
@ -168,7 +168,7 @@ public class Inventory implements Iterable<GameItem> {
|
|||||||
} else if (type == ItemType.ITEM_VIRTUAL) {
|
} else if (type == ItemType.ITEM_VIRTUAL) {
|
||||||
// Handle
|
// Handle
|
||||||
this.addVirtualItem(item.getItemId(), item.getCount());
|
this.addVirtualItem(item.getItemId(), item.getCount());
|
||||||
return null;
|
return item;
|
||||||
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_AVATAR) {
|
} else if (item.getItemData().getMaterialType() == MaterialType.MATERIAL_AVATAR) {
|
||||||
// Get avatar id
|
// Get avatar id
|
||||||
int avatarId = (item.getItemId() % 1000) + 10000000;
|
int avatarId = (item.getItemId() % 1000) + 10000000;
|
||||||
@ -218,7 +218,8 @@ public class Inventory implements Iterable<GameItem> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Set ownership and save to db
|
// Set ownership and save to db
|
||||||
item.save();
|
if (item.getItemData().getItemType() != ItemType.ITEM_VIRTUAL)
|
||||||
|
item.save();
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
@ -236,13 +237,14 @@ public class Inventory implements Iterable<GameItem> {
|
|||||||
private void addVirtualItem(int itemId, int count) {
|
private void addVirtualItem(int itemId, int count) {
|
||||||
switch (itemId) {
|
switch (itemId) {
|
||||||
case 101: // Character exp
|
case 101: // Character exp
|
||||||
for (EntityAvatar entity : getPlayer().getTeamManager().getActiveTeam()) {
|
getPlayer().getServer().getInventoryManager().upgradeAvatar(player, getPlayer().getTeamManager().getCurrentAvatarEntity().getAvatar(), count);
|
||||||
getPlayer().getServer().getInventoryManager().upgradeAvatar(player, entity.getAvatar(), count);
|
|
||||||
}
|
|
||||||
break;
|
break;
|
||||||
case 102: // Adventure exp
|
case 102: // Adventure exp
|
||||||
getPlayer().addExpDirectly(count);
|
getPlayer().addExpDirectly(count);
|
||||||
break;
|
break;
|
||||||
|
case 105: // Companionship exp
|
||||||
|
getPlayer().getServer().getInventoryManager().upgradeAvatarFetterLevel(player, getPlayer().getTeamManager().getCurrentAvatarEntity().getAvatar(), count);
|
||||||
|
break;
|
||||||
case 201: // Primogem
|
case 201: // Primogem
|
||||||
getPlayer().setPrimogems(player.getPrimogems() + count);
|
getPlayer().setPrimogems(player.getPrimogems() + count);
|
||||||
break;
|
break;
|
||||||
|
@ -23,23 +23,7 @@ import emu.grasscutter.game.player.Player;
|
|||||||
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
import emu.grasscutter.net.proto.ItemParamOuterClass.ItemParam;
|
||||||
import emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo;
|
import emu.grasscutter.net.proto.MaterialInfoOuterClass.MaterialInfo;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.packet.send.PacketAbilityChangeNotify;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarPromoteRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarPropNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarSkillChangeNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarSkillUpgradeRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarUnlockTalentNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketAvatarUpgradeRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketDestroyMaterialRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketProudSkillChangeNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketProudSkillExtraLevelNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketReliquaryUpgradeRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketSetEquipLockStateRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketUnlockAvatarTalentRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketWeaponAwakenRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketWeaponPromoteRsp;
|
|
||||||
import emu.grasscutter.server.packet.send.PacketWeaponUpgradeRsp;
|
|
||||||
import emu.grasscutter.utils.Utils;
|
import emu.grasscutter.utils.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2IntOpenHashMap;
|
||||||
@ -734,6 +718,7 @@ public class InventoryManager {
|
|||||||
avatar.save();
|
avatar.save();
|
||||||
|
|
||||||
player.sendPacket(new PacketAvatarPropNotify(avatar));
|
player.sendPacket(new PacketAvatarPropNotify(avatar));
|
||||||
|
player.sendPacket(new PacketAvatarFetterDataNotify(avatar));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void upgradeAvatarSkill(Player player, long guid, int skillId) {
|
public void upgradeAvatarSkill(Player player, long guid, int skillId) {
|
||||||
|
@ -21,6 +21,7 @@ import emu.grasscutter.game.inventory.Inventory;
|
|||||||
import emu.grasscutter.game.mail.Mail;
|
import emu.grasscutter.game.mail.Mail;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.game.props.PlayerProperty;
|
import emu.grasscutter.game.props.PlayerProperty;
|
||||||
|
import emu.grasscutter.game.shop.ShopInfo;
|
||||||
import emu.grasscutter.game.shop.ShopLimit;
|
import emu.grasscutter.game.shop.ShopLimit;
|
||||||
import emu.grasscutter.game.world.Scene;
|
import emu.grasscutter.game.world.Scene;
|
||||||
import emu.grasscutter.game.world.World;
|
import emu.grasscutter.game.world.World;
|
||||||
@ -35,6 +36,7 @@ import emu.grasscutter.net.proto.PlayerLocationInfoOuterClass.PlayerLocationInfo
|
|||||||
import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass;
|
import emu.grasscutter.net.proto.PlayerWorldLocationInfoOuterClass;
|
||||||
import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
|
import emu.grasscutter.net.proto.ProfilePictureOuterClass.ProfilePicture;
|
||||||
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
import emu.grasscutter.net.proto.SocialDetailOuterClass.SocialDetail;
|
||||||
|
import emu.grasscutter.net.proto.SocialShowAvatarInfoOuterClass;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
import emu.grasscutter.server.game.GameSession;
|
import emu.grasscutter.server.game.GameSession;
|
||||||
import emu.grasscutter.server.packet.send.*;
|
import emu.grasscutter.server.packet.send.*;
|
||||||
@ -93,6 +95,9 @@ public class Player {
|
|||||||
private int moonCardDuration;
|
private int moonCardDuration;
|
||||||
private Set<Date> moonCardGetTimes;
|
private Set<Date> moonCardGetTimes;
|
||||||
|
|
||||||
|
private List<Integer> showAvatarList;
|
||||||
|
private boolean showAvatars;
|
||||||
|
|
||||||
@Transient private boolean paused;
|
@Transient private boolean paused;
|
||||||
@Transient private int enterSceneToken;
|
@Transient private int enterSceneToken;
|
||||||
@Transient private SceneLoadState sceneState;
|
@Transient private SceneLoadState sceneState;
|
||||||
@ -513,6 +518,22 @@ public class Player {
|
|||||||
this.regionId = regionId;
|
this.regionId = regionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setShowAvatars(boolean showAvatars) {
|
||||||
|
this.showAvatars = showAvatars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isShowAvatars() {
|
||||||
|
return showAvatars;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShowAvatarList(List<Integer> showAvatarList) {
|
||||||
|
this.showAvatarList = showAvatarList;
|
||||||
|
}
|
||||||
|
|
||||||
|
public List<Integer> getShowAvatarList() {
|
||||||
|
return showAvatarList;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean inMoonCard() {
|
public boolean inMoonCard() {
|
||||||
return moonCard;
|
return moonCard;
|
||||||
}
|
}
|
||||||
@ -601,27 +622,26 @@ public class Player {
|
|||||||
return shopLimit;
|
return shopLimit;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getGoodsLimitNum(int goodsId) {
|
public ShopLimit getGoodsLimit(int goodsId) {
|
||||||
for (ShopLimit sl : getShopLimit()) {
|
Optional<ShopLimit> shopLimit = this.shopLimit.stream().filter(x -> x.getShopGoodId() == goodsId).findFirst();
|
||||||
if (sl.getShopGoodId() == goodsId)
|
if (shopLimit.isEmpty())
|
||||||
return sl.getHasBought();
|
return null;
|
||||||
}
|
return shopLimit.get();
|
||||||
return 0;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addShopLimit(int goodsId, int boughtCount) {
|
public void addShopLimit(int goodsId, int boughtCount, int nextRefreshTime) {
|
||||||
boolean found = false;
|
ShopLimit target = getGoodsLimit(goodsId);
|
||||||
for (ShopLimit sl : getShopLimit()) {
|
if (target != null) {
|
||||||
if (sl.getShopGoodId() == goodsId){
|
target.setHasBought(target.getHasBought() + boughtCount);
|
||||||
sl.setHasBought(sl.getHasBought() + boughtCount);
|
target.setHasBoughtInPeriod(target.getHasBoughtInPeriod() + boughtCount);
|
||||||
found = true;
|
target.setNextRefreshTime(nextRefreshTime);
|
||||||
}
|
} else {
|
||||||
}
|
|
||||||
if (!found) {
|
|
||||||
ShopLimit sl = new ShopLimit();
|
ShopLimit sl = new ShopLimit();
|
||||||
sl.setShopGoodId(goodsId);
|
sl.setShopGoodId(goodsId);
|
||||||
sl.setHasBought(boughtCount);
|
sl.setHasBought(boughtCount);
|
||||||
shopLimit.add(sl);
|
sl.setHasBoughtInPeriod(boughtCount);
|
||||||
|
sl.setNextRefreshTime(nextRefreshTime);
|
||||||
|
getShopLimit().add(sl);
|
||||||
}
|
}
|
||||||
this.save();
|
this.save();
|
||||||
}
|
}
|
||||||
@ -832,6 +852,38 @@ public class Player {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public SocialDetail.Builder getSocialDetail() {
|
public SocialDetail.Builder getSocialDetail() {
|
||||||
|
List<SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo> socialShowAvatarInfoList = new ArrayList<>();
|
||||||
|
if (this.isOnline()) {
|
||||||
|
if (this.getShowAvatarList() != null) {
|
||||||
|
for (int avatarId : this.getShowAvatarList()) {
|
||||||
|
socialShowAvatarInfoList.add(
|
||||||
|
socialShowAvatarInfoList.size(),
|
||||||
|
SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo.newBuilder()
|
||||||
|
.setAvatarId(avatarId)
|
||||||
|
.setLevel(getAvatars().getAvatarById(avatarId).getLevel())
|
||||||
|
.setCostumeId(getAvatars().getAvatarById(avatarId).getCostume())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
List<Integer> showAvatarList = DatabaseHelper.getPlayerById(id).getShowAvatarList();
|
||||||
|
AvatarStorage avatars = DatabaseHelper.getPlayerById(id).getAvatars();
|
||||||
|
avatars.loadFromDatabase();
|
||||||
|
if (showAvatarList != null) {
|
||||||
|
for (int avatarId : showAvatarList) {
|
||||||
|
socialShowAvatarInfoList.add(
|
||||||
|
socialShowAvatarInfoList.size(),
|
||||||
|
SocialShowAvatarInfoOuterClass.SocialShowAvatarInfo.newBuilder()
|
||||||
|
.setAvatarId(avatarId)
|
||||||
|
.setLevel(avatars.getAvatarById(avatarId).getLevel())
|
||||||
|
.setCostumeId(avatars.getAvatarById(avatarId).getCostume())
|
||||||
|
.build()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SocialDetail.Builder social = SocialDetail.newBuilder()
|
SocialDetail.Builder social = SocialDetail.newBuilder()
|
||||||
.setUid(this.getUid())
|
.setUid(this.getUid())
|
||||||
.setProfilePicture(ProfilePicture.newBuilder().setAvatarId(this.getHeadImage()))
|
.setProfilePicture(ProfilePicture.newBuilder().setAvatarId(this.getHeadImage()))
|
||||||
@ -841,6 +893,8 @@ public class Player {
|
|||||||
.setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty())
|
.setBirthday(this.getBirthday().getFilledProtoWhenNotEmpty())
|
||||||
.setWorldLevel(this.getWorldLevel())
|
.setWorldLevel(this.getWorldLevel())
|
||||||
.setNameCardId(this.getNameCardId())
|
.setNameCardId(this.getNameCardId())
|
||||||
|
.setIsShowAvatar(this.isShowAvatars())
|
||||||
|
.addAllShowAvatarInfoList(socialShowAvatarInfoList)
|
||||||
.setFinishAchievementNum(0);
|
.setFinishAchievementNum(0);
|
||||||
return social;
|
return social;
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package emu.grasscutter.game.shop;
|
package emu.grasscutter.game.shop;
|
||||||
|
|
||||||
import emu.grasscutter.data.common.ItemParamData;
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
|
import emu.grasscutter.data.def.ShopGoodsData;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -14,7 +15,6 @@ public class ShopInfo {
|
|||||||
private int buyLimit = 0;
|
private int buyLimit = 0;
|
||||||
private int beginTime = 0;
|
private int beginTime = 0;
|
||||||
private int endTime = 1924992000;
|
private int endTime = 1924992000;
|
||||||
private int nextRefreshTime = 1924992000;
|
|
||||||
private int minLevel = 0;
|
private int minLevel = 0;
|
||||||
private int maxLevel = 61;
|
private int maxLevel = 61;
|
||||||
private List<Integer> preGoodsIdList = new ArrayList<>();
|
private List<Integer> preGoodsIdList = new ArrayList<>();
|
||||||
@ -23,6 +23,43 @@ public class ShopInfo {
|
|||||||
private int disableType = 0;
|
private int disableType = 0;
|
||||||
private int secondarySheetId = 0;
|
private int secondarySheetId = 0;
|
||||||
|
|
||||||
|
private String refreshType;
|
||||||
|
|
||||||
|
public enum ShopRefreshType {
|
||||||
|
NONE(0),
|
||||||
|
SHOP_REFRESH_DAILY(1),
|
||||||
|
SHOP_REFRESH_WEEKLY(2),
|
||||||
|
SHOP_REFRESH_MONTHLY(3);
|
||||||
|
|
||||||
|
private final int value;
|
||||||
|
ShopRefreshType(int value) {
|
||||||
|
this.value = value;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int value() {
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private transient ShopRefreshType shopRefreshType;
|
||||||
|
private int shopRefreshParam;
|
||||||
|
|
||||||
|
public ShopInfo(ShopGoodsData sgd) {
|
||||||
|
this.goodsId = sgd.getGoodsId();
|
||||||
|
this.goodsItem = new ItemParamData(sgd.getItemId(), sgd.getItemCount());
|
||||||
|
this.scoin = sgd.getCostScoin();
|
||||||
|
this.mcoin = sgd.getCostMcoin();
|
||||||
|
this.hcoin = sgd.getCostHcoin();
|
||||||
|
this.buyLimit = sgd.getBuyLimit();
|
||||||
|
|
||||||
|
this.minLevel = sgd.getMinPlayerLevel();
|
||||||
|
this.maxLevel = sgd.getMaxPlayerLevel();
|
||||||
|
this.costItemList = sgd.getCostItems().stream().filter(x -> x.getId() != 0).map(x -> new ItemParamData(x.getId(), x.getCount())).toList();
|
||||||
|
this.secondarySheetId = sgd.getSubTabId();
|
||||||
|
this.shopRefreshType = sgd.getRefreshType();
|
||||||
|
this.shopRefreshParam = sgd.getRefreshParam();
|
||||||
|
}
|
||||||
|
|
||||||
public int getHcoin() {
|
public int getHcoin() {
|
||||||
return hcoin;
|
return hcoin;
|
||||||
}
|
}
|
||||||
@ -127,14 +164,6 @@ public class ShopInfo {
|
|||||||
this.endTime = endTime;
|
this.endTime = endTime;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getNextRefreshTime() {
|
|
||||||
return nextRefreshTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setNextRefreshTime(int nextRefreshTime) {
|
|
||||||
this.nextRefreshTime = nextRefreshTime;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getMinLevel() {
|
public int getMinLevel() {
|
||||||
return minLevel;
|
return minLevel;
|
||||||
}
|
}
|
||||||
@ -150,4 +179,27 @@ public class ShopInfo {
|
|||||||
public void setMaxLevel(int maxLevel) {
|
public void setMaxLevel(int maxLevel) {
|
||||||
this.maxLevel = maxLevel;
|
this.maxLevel = maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public ShopRefreshType getShopRefreshType() {
|
||||||
|
if (refreshType == null)
|
||||||
|
return ShopRefreshType.NONE;
|
||||||
|
return switch (refreshType) {
|
||||||
|
case "SHOP_REFRESH_DAILY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_DAILY;
|
||||||
|
case "SHOP_REFRESH_WEEKLY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_WEEKLY;
|
||||||
|
case "SHOP_REFRESH_MONTHLY" -> ShopInfo.ShopRefreshType.SHOP_REFRESH_MONTHLY;
|
||||||
|
default -> ShopInfo.ShopRefreshType.NONE;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopRefreshType(ShopRefreshType shopRefreshType) {
|
||||||
|
this.shopRefreshType = shopRefreshType;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getShopRefreshParam() {
|
||||||
|
return shopRefreshParam;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShopRefreshParam(int shopRefreshParam) {
|
||||||
|
this.shopRefreshParam = shopRefreshParam;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,24 @@ public class ShopLimit {
|
|||||||
this.hasBought = hasBought;
|
this.hasBought = hasBought;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getNextRefreshTime() {
|
||||||
|
return nextRefreshTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setNextRefreshTime(int nextRefreshTime) {
|
||||||
|
this.nextRefreshTime = nextRefreshTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getHasBoughtInPeriod() {
|
||||||
|
return hasBoughtInPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHasBoughtInPeriod(int hasBoughtInPeriod) {
|
||||||
|
this.hasBoughtInPeriod = hasBoughtInPeriod;
|
||||||
|
}
|
||||||
|
|
||||||
private int shopGoodId;
|
private int shopGoodId;
|
||||||
private int hasBought;
|
private int hasBought;
|
||||||
|
private int hasBoughtInPeriod = 0;
|
||||||
|
private int nextRefreshTime = 0;
|
||||||
}
|
}
|
||||||
|
@ -2,12 +2,20 @@ package emu.grasscutter.game.shop;
|
|||||||
|
|
||||||
import com.google.gson.reflect.TypeToken;
|
import com.google.gson.reflect.TypeToken;
|
||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.data.GameData;
|
||||||
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
|
import emu.grasscutter.data.def.ShopGoodsData;
|
||||||
|
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||||
|
import emu.grasscutter.net.proto.ShopGoodsOuterClass;
|
||||||
import emu.grasscutter.server.game.GameServer;
|
import emu.grasscutter.server.game.GameServer;
|
||||||
|
import emu.grasscutter.utils.Utils;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
import it.unimi.dsi.fastutil.ints.Int2ObjectOpenHashMap;
|
||||||
|
|
||||||
import java.io.FileReader;
|
import java.io.FileReader;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
public class ShopManager {
|
public class ShopManager {
|
||||||
@ -25,18 +33,57 @@ public class ShopManager {
|
|||||||
this.load();
|
this.load();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static final int REFRESH_HOUR = 4; // In GMT+8 server
|
||||||
|
private static final String TIME_ZONE = "Asia/Shanghai"; // GMT+8 Timezone
|
||||||
|
|
||||||
|
public static int getShopNextRefreshTime(ShopInfo shopInfo) {
|
||||||
|
return switch (shopInfo.getShopRefreshType()) {
|
||||||
|
case SHOP_REFRESH_DAILY -> Utils.GetNextTimestampOfThisHour(REFRESH_HOUR, TIME_ZONE, shopInfo.getShopRefreshParam());
|
||||||
|
case SHOP_REFRESH_WEEKLY -> Utils.GetNextTimestampOfThisHourInNextWeek(REFRESH_HOUR, TIME_ZONE, shopInfo.getShopRefreshParam());
|
||||||
|
case SHOP_REFRESH_MONTHLY -> Utils.GetNextTimestampOfThisHourInNextMonth(REFRESH_HOUR, TIME_ZONE, shopInfo.getShopRefreshParam());
|
||||||
|
default -> 0;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) {
|
try (FileReader fileReader = new FileReader(Grasscutter.getConfig().DATA_FOLDER + "Shop.json")) {
|
||||||
getShopData().clear();
|
getShopData().clear();
|
||||||
List<ShopTable> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopTable.class).getType());
|
List<ShopTable> banners = Grasscutter.getGsonFactory().fromJson(fileReader, TypeToken.getParameterized(Collection.class, ShopTable.class).getType());
|
||||||
if(banners.size() > 0) {
|
if(banners.size() > 0) {
|
||||||
for (ShopTable shopTable : banners) {
|
for (ShopTable shopTable : banners) {
|
||||||
|
for (ShopInfo cost : shopTable.getItems()) {
|
||||||
|
if (cost.getCostItemList() != null) {
|
||||||
|
Iterator<ItemParamData> iterator = cost.getCostItemList().iterator();
|
||||||
|
while (iterator.hasNext()) {
|
||||||
|
ItemParamData ipd = iterator.next();
|
||||||
|
if (ipd.getId() == 201) {
|
||||||
|
cost.setHcoin(cost.getHcoin() + ipd.getCount());
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
if (ipd.getId() == 203) {
|
||||||
|
cost.setMcoin(cost.getMcoin() + ipd.getCount());
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
getShopData().put(shopTable.getShopId(), shopTable.getItems());
|
getShopData().put(shopTable.getShopId(), shopTable.getItems());
|
||||||
}
|
}
|
||||||
Grasscutter.getLogger().info("Shop data successfully loaded.");
|
Grasscutter.getLogger().info("Shop data successfully loaded.");
|
||||||
} else {
|
} else {
|
||||||
Grasscutter.getLogger().error("Unable to load shop data. Shop data size is 0.");
|
Grasscutter.getLogger().error("Unable to load shop data. Shop data size is 0.");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (Grasscutter.getConfig().getGameServerOptions().EnableOfficialShop) {
|
||||||
|
GameData.getShopGoodsDataEntries().forEach((k, v) -> {
|
||||||
|
if (!getShopData().containsKey(k.intValue()))
|
||||||
|
getShopData().put(k.intValue(), new ArrayList<>());
|
||||||
|
for (ShopGoodsData sgd : v) {
|
||||||
|
var shopInfo = new ShopInfo(sgd);
|
||||||
|
getShopData().get(k.intValue()).add(shopInfo);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -1172,6 +1172,11 @@ public class PacketOpcodes {
|
|||||||
public static final int UseWidgetCreateGadgetRsp = 4290;
|
public static final int UseWidgetCreateGadgetRsp = 4290;
|
||||||
public static final int UseWidgetRetractGadgetReq = 4255;
|
public static final int UseWidgetRetractGadgetReq = 4255;
|
||||||
public static final int UseWidgetRetractGadgetRsp = 4297;
|
public static final int UseWidgetRetractGadgetRsp = 4297;
|
||||||
|
public static final int VehicleSpawnReq = 809;
|
||||||
|
public static final int VehicleSpawnRsp = 865;
|
||||||
|
public static final int VehicleInteractReq = 862;
|
||||||
|
public static final int VehicleInteractRsp = 889;
|
||||||
|
public static final int VehicleStaminaNotify = 866;
|
||||||
public static final int ViewCodexReq = 4210;
|
public static final int ViewCodexReq = 4210;
|
||||||
public static final int ViewCodexRsp = 4209;
|
public static final int ViewCodexRsp = 4209;
|
||||||
public static final int WatcherAllDataNotify = 2260;
|
public static final int WatcherAllDataNotify = 2260;
|
||||||
|
@ -189,7 +189,11 @@ public final class GameServer extends KcpServer {
|
|||||||
world.onTick();
|
world.onTick();
|
||||||
}
|
}
|
||||||
|
|
||||||
ServerTickEvent event = new ServerTickEvent(); event.call();
|
for (Player player : this.getPlayers().values()) {
|
||||||
|
player.onTick();
|
||||||
|
}
|
||||||
|
|
||||||
|
ServerTickEvent event = new ServerTickEvent(); event.call();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void registerWorld(World world) {
|
public void registerWorld(World world) {
|
||||||
|
@ -1,9 +1,13 @@
|
|||||||
package emu.grasscutter.server.packet.recv;
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
import emu.grasscutter.data.GameData;
|
import emu.grasscutter.data.GameData;
|
||||||
|
import emu.grasscutter.data.common.ItemParamData;
|
||||||
import emu.grasscutter.game.inventory.GameItem;
|
import emu.grasscutter.game.inventory.GameItem;
|
||||||
import emu.grasscutter.game.props.ActionReason;
|
import emu.grasscutter.game.props.ActionReason;
|
||||||
import emu.grasscutter.game.props.PlayerProperty;
|
import emu.grasscutter.game.props.PlayerProperty;
|
||||||
|
import emu.grasscutter.game.shop.ShopInfo;
|
||||||
|
import emu.grasscutter.game.shop.ShopLimit;
|
||||||
|
import emu.grasscutter.game.shop.ShopManager;
|
||||||
import emu.grasscutter.net.packet.Opcodes;
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
import emu.grasscutter.net.packet.PacketHandler;
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
@ -13,9 +17,11 @@ import emu.grasscutter.net.proto.ShopGoodsOuterClass;
|
|||||||
import emu.grasscutter.server.game.GameSession;
|
import emu.grasscutter.server.game.GameSession;
|
||||||
import emu.grasscutter.server.packet.send.PacketBuyGoodsRsp;
|
import emu.grasscutter.server.packet.send.PacketBuyGoodsRsp;
|
||||||
import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify;
|
import emu.grasscutter.server.packet.send.PacketStoreItemChangeNotify;
|
||||||
|
import emu.grasscutter.utils.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
import java.util.List;
|
||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Opcodes(PacketOpcodes.BuyGoodsReq)
|
@Opcodes(PacketOpcodes.BuyGoodsReq)
|
||||||
@ -24,8 +30,34 @@ public class HandlerBuyGoodsReq extends PacketHandler {
|
|||||||
@Override
|
@Override
|
||||||
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
BuyGoodsReqOuterClass.BuyGoodsReq buyGoodsReq = BuyGoodsReqOuterClass.BuyGoodsReq.parseFrom(payload);
|
BuyGoodsReqOuterClass.BuyGoodsReq buyGoodsReq = BuyGoodsReqOuterClass.BuyGoodsReq.parseFrom(payload);
|
||||||
|
List<ShopInfo> configShop = session.getServer().getShopManager().getShopData().get(buyGoodsReq.getShopType());
|
||||||
|
if (configShop == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
// Don't trust your users' input
|
||||||
|
List<Integer> targetShopGoodsId = buyGoodsReq.getGoodsListList().stream().map(ShopGoodsOuterClass.ShopGoods::getGoodsId).toList();
|
||||||
|
for (int goodsId : targetShopGoodsId) {
|
||||||
|
Optional<ShopInfo> sg2 = configShop.stream().filter(x -> x.getGoodsId() == goodsId).findFirst();
|
||||||
|
if (sg2.isEmpty())
|
||||||
|
continue;
|
||||||
|
ShopInfo sg = sg2.get();
|
||||||
|
|
||||||
|
int currentTs = Utils.getCurrentSeconds();
|
||||||
|
ShopLimit shopLimit = session.getPlayer().getGoodsLimit(sg.getGoodsId());
|
||||||
|
int bought = 0;
|
||||||
|
if (shopLimit != null) {
|
||||||
|
if (currentTs > shopLimit.getNextRefreshTime()) {
|
||||||
|
shopLimit.setNextRefreshTime(ShopManager.getShopNextRefreshTime(sg));
|
||||||
|
} else {
|
||||||
|
bought = shopLimit.getHasBoughtInPeriod();
|
||||||
|
}
|
||||||
|
session.getPlayer().save();
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bought + buyGoodsReq.getBoughtNum() > sg.getBuyLimit()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for (ShopGoodsOuterClass.ShopGoods sg : buyGoodsReq.getGoodsListList()) {
|
|
||||||
if (sg.getScoin() > 0 && session.getPlayer().getMora() < buyGoodsReq.getBoughtNum() * sg.getScoin()) {
|
if (sg.getScoin() > 0 && session.getPlayer().getMora() < buyGoodsReq.getBoughtNum() * sg.getScoin()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -37,11 +69,13 @@ public class HandlerBuyGoodsReq extends PacketHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
HashMap<GameItem, Integer> itemsCache = new HashMap<>();
|
HashMap<GameItem, Integer> itemsCache = new HashMap<>();
|
||||||
for (ItemParamOuterClass.ItemParam p : sg.getCostItemListList()) {
|
if (sg.getCostItemList() != null) {
|
||||||
Optional<GameItem> invItem = session.getPlayer().getInventory().getItems().values().stream().filter(x -> x.getItemId() == p.getItemId()).findFirst();
|
for (ItemParamData p : sg.getCostItemList()) {
|
||||||
if (invItem.isEmpty() || invItem.get().getCount() < p.getCount())
|
Optional<GameItem> invItem = session.getPlayer().getInventory().getItems().values().stream().filter(x -> x.getItemId() == p.getId()).findFirst();
|
||||||
return;
|
if (invItem.isEmpty() || invItem.get().getCount() < p.getCount())
|
||||||
itemsCache.put(invItem.get(), p.getCount() * buyGoodsReq.getBoughtNum());
|
return;
|
||||||
|
itemsCache.put(invItem.get(), p.getCount() * buyGoodsReq.getBoughtNum());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getPlayer().setMora(session.getPlayer().getMora() - buyGoodsReq.getBoughtNum() * sg.getScoin());
|
session.getPlayer().setMora(session.getPlayer().getMora() - buyGoodsReq.getBoughtNum() * sg.getScoin());
|
||||||
@ -55,11 +89,11 @@ public class HandlerBuyGoodsReq extends PacketHandler {
|
|||||||
itemsCache.clear();
|
itemsCache.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getPlayer().addShopLimit(sg.getGoodsId(), buyGoodsReq.getBoughtNum());
|
session.getPlayer().addShopLimit(sg.getGoodsId(), buyGoodsReq.getBoughtNum(), ShopManager.getShopNextRefreshTime(sg));
|
||||||
GameItem item = new GameItem(GameData.getItemDataMap().get(sg.getGoodsItem().getItemId()));
|
GameItem item = new GameItem(GameData.getItemDataMap().get(sg.getGoodsItem().getId()));
|
||||||
item.setCount(buyGoodsReq.getBoughtNum() * sg.getGoodsItem().getCount());
|
item.setCount(buyGoodsReq.getBoughtNum() * sg.getGoodsItem().getCount());
|
||||||
session.getPlayer().getInventory().addItem(item, ActionReason.Shop, true); // fix: not notify when got virtual item from shop
|
session.getPlayer().getInventory().addItem(item, ActionReason.Shop, true); // fix: not notify when got virtual item from shop
|
||||||
session.send(new PacketBuyGoodsRsp(buyGoodsReq.getShopType(), session.getPlayer().getGoodsLimitNum(sg.getGoodsId()), sg));
|
session.send(new PacketBuyGoodsRsp(buyGoodsReq.getShopType(), session.getPlayer().getGoodsLimit(sg.getGoodsId()).getHasBoughtInPeriod(), buyGoodsReq.getGoodsListList().stream().filter(x -> x.getGoodsId() == goodsId).findFirst().get()));
|
||||||
}
|
}
|
||||||
|
|
||||||
session.getPlayer().save();
|
session.getPlayer().save();
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.UpdatePlayerShowAvatarListReqOuterClass;
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketUpdatePlayerShowAvatarListRsp;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.UpdatePlayerShowAvatarListReq)
|
||||||
|
public class HandlerUpdatePlayerShowAvatarListReq extends PacketHandler {
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
UpdatePlayerShowAvatarListReqOuterClass.UpdatePlayerShowAvatarListReq req = UpdatePlayerShowAvatarListReqOuterClass.UpdatePlayerShowAvatarListReq.parseFrom(payload);
|
||||||
|
|
||||||
|
session.getPlayer().setShowAvatars(req.getIsShowAvatar());
|
||||||
|
session.getPlayer().setShowAvatarList(req.getShowAvatarIdListList());
|
||||||
|
|
||||||
|
session.send(new PacketUpdatePlayerShowAvatarListRsp(req.getIsShowAvatar(), req.getShowAvatarIdListList()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,19 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.VehicleInteractReqOuterClass;
|
||||||
|
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketVehicleInteractRsp;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.VehicleInteractReq)
|
||||||
|
public class HandlerVehicleInteractReq extends PacketHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
VehicleInteractReqOuterClass.VehicleInteractReq req = VehicleInteractReqOuterClass.VehicleInteractReq.parseFrom(payload);
|
||||||
|
session.send(new PacketVehicleInteractRsp(session.getPlayer(), req.getEntityId(), req.getInteractType()));
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,21 @@
|
|||||||
|
package emu.grasscutter.server.packet.recv;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.Opcodes;
|
||||||
|
import emu.grasscutter.net.packet.PacketHandler;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.VehicleSpawnReqOuterClass;
|
||||||
|
|
||||||
|
import emu.grasscutter.server.game.GameSession;
|
||||||
|
import emu.grasscutter.server.packet.send.PacketVehicleSpawnRsp;
|
||||||
|
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
|
|
||||||
|
@Opcodes(PacketOpcodes.VehicleSpawnReq)
|
||||||
|
public class HandlerVehicleSpawnReq extends PacketHandler {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void handle(GameSession session, byte[] header, byte[] payload) throws Exception {
|
||||||
|
VehicleSpawnReqOuterClass.VehicleSpawnReq req = VehicleSpawnReqOuterClass.VehicleSpawnReq.parseFrom(payload);
|
||||||
|
session.send(new PacketVehicleSpawnRsp(session.getPlayer(), req.getVehicleId(), req.getPointId(), new Position(req.getPos()), new Position(req.getRot())));
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,7 @@ package emu.grasscutter.server.packet.send;
|
|||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.game.player.Player;
|
import emu.grasscutter.game.player.Player;
|
||||||
import emu.grasscutter.game.shop.ShopInfo;
|
import emu.grasscutter.game.shop.ShopInfo;
|
||||||
|
import emu.grasscutter.game.shop.ShopLimit;
|
||||||
import emu.grasscutter.game.shop.ShopManager;
|
import emu.grasscutter.game.shop.ShopManager;
|
||||||
import emu.grasscutter.net.packet.BasePacket;
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
import emu.grasscutter.net.packet.PacketOpcodes;
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
@ -10,13 +11,13 @@ import emu.grasscutter.net.proto.GetShopRspOuterClass;
|
|||||||
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
import emu.grasscutter.net.proto.ItemParamOuterClass;
|
||||||
import emu.grasscutter.net.proto.ShopGoodsOuterClass.ShopGoods;
|
import emu.grasscutter.net.proto.ShopGoodsOuterClass.ShopGoods;
|
||||||
import emu.grasscutter.net.proto.ShopOuterClass.Shop;
|
import emu.grasscutter.net.proto.ShopOuterClass.Shop;
|
||||||
|
import emu.grasscutter.utils.Utils;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
public class PacketGetShopRsp extends BasePacket {
|
public class PacketGetShopRsp extends BasePacket {
|
||||||
|
|
||||||
public PacketGetShopRsp(Player inv, int shopType) {
|
public PacketGetShopRsp(Player inv, int shopType) {
|
||||||
super(PacketOpcodes.GetShopRsp);
|
super(PacketOpcodes.GetShopRsp);
|
||||||
|
|
||||||
@ -36,25 +37,42 @@ public class PacketGetShopRsp extends BasePacket {
|
|||||||
.setGoodsItem(ItemParamOuterClass.ItemParam.newBuilder().setItemId(info.getGoodsItem().getId()).setCount(info.getGoodsItem().getCount()).build())
|
.setGoodsItem(ItemParamOuterClass.ItemParam.newBuilder().setItemId(info.getGoodsItem().getId()).setCount(info.getGoodsItem().getCount()).build())
|
||||||
.setScoin(info.getScoin())
|
.setScoin(info.getScoin())
|
||||||
.setHcoin(info.getHcoin())
|
.setHcoin(info.getHcoin())
|
||||||
.setBoughtNum(inv.getGoodsLimitNum(info.getGoodsId()))
|
|
||||||
.setBuyLimit(info.getBuyLimit())
|
.setBuyLimit(info.getBuyLimit())
|
||||||
.setBeginTime(info.getBeginTime())
|
.setBeginTime(info.getBeginTime())
|
||||||
.setEndTime(info.getEndTime())
|
.setEndTime(info.getEndTime())
|
||||||
.setNextRefreshTime(info.getNextRefreshTime())
|
|
||||||
.setMinLevel(info.getMinLevel())
|
.setMinLevel(info.getMinLevel())
|
||||||
.setMaxLevel(info.getMaxLevel())
|
.setMaxLevel(info.getMaxLevel())
|
||||||
.addAllPreGoodsIdList(info.getPreGoodsIdList())
|
|
||||||
.setMcoin(info.getMcoin())
|
.setMcoin(info.getMcoin())
|
||||||
.setDisableType(info.getDisableType())
|
.setDisableType(info.getDisableType())
|
||||||
.setSecondarySheetId(info.getSecondarySheetId());
|
.setSecondarySheetId(info.getSecondarySheetId());
|
||||||
if (info.getCostItemList() != null) {
|
if (info.getCostItemList() != null) {
|
||||||
goods.addAllCostItemList(info.getCostItemList().stream().map(x -> ItemParamOuterClass.ItemParam.newBuilder().setItemId(x.getId()).setCount(x.getCount()).build()).collect(Collectors.toList()));
|
goods.addAllCostItemList(info.getCostItemList().stream().map(x -> ItemParamOuterClass.ItemParam.newBuilder().setItemId(x.getId()).setCount(x.getCount()).build()).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
if (info.getPreGoodsIdList() != null) {
|
||||||
|
goods.addAllPreGoodsIdList(info.getPreGoodsIdList());
|
||||||
|
}
|
||||||
|
|
||||||
|
int currentTs = Utils.getCurrentSeconds();
|
||||||
|
ShopLimit currentShopLimit = inv.getGoodsLimit(info.getGoodsId());
|
||||||
|
int nextRefreshTime = ShopManager.getShopNextRefreshTime(info);
|
||||||
|
if (currentShopLimit != null) {
|
||||||
|
if (currentShopLimit.getNextRefreshTime() < currentTs) { // second game day
|
||||||
|
currentShopLimit.setHasBoughtInPeriod(0);
|
||||||
|
currentShopLimit.setNextRefreshTime(nextRefreshTime);
|
||||||
|
}
|
||||||
|
goods.setBoughtNum(currentShopLimit.getHasBoughtInPeriod());
|
||||||
|
goods.setNextRefreshTime(currentShopLimit.getNextRefreshTime());
|
||||||
|
} else {
|
||||||
|
inv.addShopLimit(goods.getGoodsId(), 0, nextRefreshTime); // save generated refresh time
|
||||||
|
goods.setNextRefreshTime(nextRefreshTime);
|
||||||
|
}
|
||||||
|
|
||||||
goodsList.add(goods.build());
|
goodsList.add(goods.build());
|
||||||
}
|
}
|
||||||
shop.addAllGoodsList(goodsList);
|
shop.addAllGoodsList(goodsList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inv.save();
|
||||||
this.setData(GetShopRspOuterClass.GetShopRsp.newBuilder().setShop(shop).build());
|
this.setData(GetShopRspOuterClass.GetShopRsp.newBuilder().setShop(shop).build());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.UpdatePlayerShowAvatarListRspOuterClass.UpdatePlayerShowAvatarListRsp;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
public class PacketUpdatePlayerShowAvatarListRsp extends BasePacket {
|
||||||
|
|
||||||
|
public PacketUpdatePlayerShowAvatarListRsp(boolean isShowAvatar, List<Integer> avatarIds) {
|
||||||
|
super(PacketOpcodes.UpdatePlayerShowAvatarListRsp);
|
||||||
|
|
||||||
|
UpdatePlayerShowAvatarListRsp proto = UpdatePlayerShowAvatarListRsp.newBuilder()
|
||||||
|
.setIsShowAvatar(isShowAvatar)
|
||||||
|
.addAllShowAvatarIdList(avatarIds)
|
||||||
|
.setRetcode(0)
|
||||||
|
.build();
|
||||||
|
|
||||||
|
this.setData(proto);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,33 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.VehicleInteractTypeOuterClass.VehicleInteractType;
|
||||||
|
import emu.grasscutter.net.proto.VehicleInteractRspOuterClass.VehicleInteractRsp;
|
||||||
|
import emu.grasscutter.net.proto.VehicleMemberOuterClass.VehicleMember;
|
||||||
|
|
||||||
|
public class PacketVehicleInteractRsp extends BasePacket {
|
||||||
|
|
||||||
|
public PacketVehicleInteractRsp(Player player, int entityId, VehicleInteractType interactType) {
|
||||||
|
super(PacketOpcodes.VehicleInteractRsp);
|
||||||
|
VehicleInteractRsp.Builder proto = VehicleInteractRsp.newBuilder();
|
||||||
|
|
||||||
|
GameEntity vehicle = player.getScene().getEntityById(entityId);
|
||||||
|
if(vehicle != null) {
|
||||||
|
proto.setEntityId(vehicle.getId());
|
||||||
|
proto.setInteractType(interactType);
|
||||||
|
|
||||||
|
VehicleMember vehicleMember = VehicleMember.newBuilder()
|
||||||
|
.setUid(player.getUid())
|
||||||
|
.setAvatarGuid(player.getTeamManager().getCurrentCharacterGuid())
|
||||||
|
.build();
|
||||||
|
|
||||||
|
proto.setMember(vehicleMember);
|
||||||
|
}
|
||||||
|
this.setData(proto.build());
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package emu.grasscutter.server.packet.send;
|
||||||
|
|
||||||
|
import emu.grasscutter.Grasscutter;
|
||||||
|
import emu.grasscutter.game.player.Player;
|
||||||
|
import emu.grasscutter.game.entity.EntityVehicle;
|
||||||
|
import emu.grasscutter.game.props.FightProperty;
|
||||||
|
import emu.grasscutter.game.entity.GameEntity;
|
||||||
|
|
||||||
|
import emu.grasscutter.net.packet.BasePacket;
|
||||||
|
import emu.grasscutter.net.packet.PacketOpcodes;
|
||||||
|
import emu.grasscutter.net.proto.VehicleSpawnRspOuterClass.VehicleSpawnRsp;
|
||||||
|
|
||||||
|
import emu.grasscutter.utils.Position;
|
||||||
|
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
|
||||||
|
|
||||||
|
public class PacketVehicleSpawnRsp extends BasePacket {
|
||||||
|
|
||||||
|
public PacketVehicleSpawnRsp(Player player, int vehicleId, int pointId, Position pos, Position rot) {
|
||||||
|
super(PacketOpcodes.VehicleSpawnRsp);
|
||||||
|
VehicleSpawnRsp.Builder proto = VehicleSpawnRsp.newBuilder();
|
||||||
|
|
||||||
|
EntityVehicle vehicle = new EntityVehicle(player.getScene(), player, vehicleId, pointId, pos, rot);
|
||||||
|
|
||||||
|
switch (vehicleId) {
|
||||||
|
// TODO: Not hardcode this. Waverider (skiff)
|
||||||
|
case 45001001,45001002 -> {
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_HP, 10000);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_BASE_ATTACK, 100);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_ATTACK, 100);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_HP, 10000);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_DEFENSE, 0);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CUR_SPEED, 0);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_CHARGE_EFFICIENCY, 0);
|
||||||
|
vehicle.addFightProperty(FightProperty.FIGHT_PROP_MAX_HP, 10000);
|
||||||
|
}
|
||||||
|
default -> {}
|
||||||
|
}
|
||||||
|
|
||||||
|
player.getScene().addEntity(vehicle);
|
||||||
|
|
||||||
|
proto.setVehicleId(vehicleId);
|
||||||
|
proto.setEntityId(vehicle.getId());
|
||||||
|
|
||||||
|
this.setData(proto.build());
|
||||||
|
}
|
||||||
|
}
|
@ -3,6 +3,8 @@ package emu.grasscutter.utils;
|
|||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.StandardCopyOption;
|
import java.nio.file.StandardCopyOption;
|
||||||
|
import java.time.*;
|
||||||
|
import java.time.temporal.TemporalAdjusters;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import emu.grasscutter.Config;
|
import emu.grasscutter.Config;
|
||||||
@ -191,4 +193,40 @@ public final class Utils {
|
|||||||
|
|
||||||
if(exit) System.exit(1);
|
if(exit) System.exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static int GetNextTimestampOfThisHour(int hour, String timeZone, int param) {
|
||||||
|
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
|
||||||
|
for (int i = 0; i < param; i ++){
|
||||||
|
if (zonedDateTime.getHour() < hour) {
|
||||||
|
zonedDateTime = zonedDateTime.withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
} else {
|
||||||
|
zonedDateTime = zonedDateTime.plusDays(1).withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetNextTimestampOfThisHourInNextWeek(int hour, String timeZone, int param) {
|
||||||
|
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
|
||||||
|
for (int i = 0; i < param; i++) {
|
||||||
|
if (zonedDateTime.getDayOfWeek() == DayOfWeek.MONDAY && zonedDateTime.getHour() < hour) {
|
||||||
|
zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone)).withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
} else {
|
||||||
|
zonedDateTime = zonedDateTime.with(TemporalAdjusters.next(DayOfWeek.MONDAY)).withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static int GetNextTimestampOfThisHourInNextMonth(int hour, String timeZone, int param) {
|
||||||
|
ZonedDateTime zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone));
|
||||||
|
for (int i = 0; i < param; i++) {
|
||||||
|
if (zonedDateTime.getDayOfMonth() == 1 && zonedDateTime.getHour() < hour) {
|
||||||
|
zonedDateTime = ZonedDateTime.now(ZoneId.of(timeZone)).withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
} else {
|
||||||
|
zonedDateTime = zonedDateTime.with(TemporalAdjusters.firstDayOfNextMonth()).withHour(hour).withMinute(0).withSecond(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return (int)zonedDateTime.toInstant().atZone(ZoneOffset.UTC).toEpochSecond();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user