mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 02:34:07 +00:00
Give Artifact: Fix error & Rename alias (#370)
* Give Artifact: Fix error & Rename alias * Update README.md
This commit is contained in:
parent
dd38814209
commit
2fd73e043a
@ -115,7 +115,7 @@ There is a dummy user named "Server" in every player's friends list that you can
|
||||
| drop | drop <itemID\|itemName> [amount] | server.drop | Client only | Drops an item around you. | `d` `dropitem` |
|
||||
| give | give [player] <itemId\|itemName> [amount] [level] [finement] | player.give | Both side | Gives item(s) to you or the specified player. (finement option only weapon.) | `g` `item` `giveitem` |
|
||||
| givechar | givechar \<uid> \<avatarId> | player.givechar | Both side | Gives the player a specified character. | givec |
|
||||
| giveart | giveart [player] \<artifactId> \<mainPropId> [\<appendPropId>[,\<times>]]... [level] | player.giveart | Both side | Gives the player a specified reliquary. | givea |
|
||||
| giveart | giveart [player] \<artifactId> \<mainPropId> [\<appendPropId>[,\<times>]]... [level] | player.giveart | Both side | Gives the player a specified artifact. | gart |
|
||||
| giveall | giveall [uid] [amount] | player.giveall | Both side | Gives all items. | givea |
|
||||
| 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 |
|
||||
|
@ -116,7 +116,7 @@ chmod +x gradlew
|
||||
| drop | drop <物品ID\|物品名称> [数量] | server.drop | 仅客户端 | 在指定玩家周围掉落指定物品 | `d` `dropitem` |
|
||||
| give | give [uid] <物品ID\|物品名称> [数量] [等级] [精炼等级] | | | 给予指定玩家一定数量及等级的物品 (精炼等级仅适用于武器) | `g` `item` `giveitem` |
|
||||
| givechar | givechar \<uid> <角色ID> [等级] | player.givechar | 均可使用 | 给予指定玩家对应角色 | givec |
|
||||
| giveart | giveart [uid] \<圣遗物ID> \<主属性ID> [\<副属性ID>[,<次数>]]... [等级] | player.giveart | 均可使用 | 给予玩家指定属性的圣遗物 | givea |
|
||||
| giveart | giveart [uid] \<圣遗物ID> \<主属性ID> [\<副属性ID>[,<次数>]]... [等级] | player.giveart | 均可使用 | 给予玩家指定属性的圣遗物 | gart |
|
||||
| giveall | giveall [uid] [数量] | player.giveall | 均可使用 | 给予指定玩家全部物品 | givea |
|
||||
| godmode | godmode [uid] | player.godmode | 仅客户端 | 保护你不受到任何伤害(依然会被击退) | |
|
||||
| heal | heal | player.heal | 仅客户端 | 治疗队伍中所有角色 | h |
|
||||
|
@ -14,13 +14,13 @@ import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
@Command(label = "giveart", usage = "giveart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", description = "Gives the player a specified reliquary", aliases = {"givea"}, permission = "player.giveart")
|
||||
@Command(label = "giveart", usage = "giveart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]", description = "Gives the player a specified artifact", aliases = {"gart"}, permission = "player.giveart")
|
||||
public final class GiveArtifactCommand implements CommandHandler {
|
||||
@Override
|
||||
public void execute(Player sender, List<String> args) {
|
||||
int size = args.size(), target, itemId, mainPropId, level;
|
||||
int size = args.size(), target, itemId, mainPropId, level = 1;
|
||||
ArrayList<Integer> appendPropIdList = new ArrayList<>();
|
||||
String msg = "Usage: giveart|givea [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]";
|
||||
String msg = "Usage: giveart|gart [player] <artifactId> <mainPropId> [<appendPropId>[,<times>]]... [level]";
|
||||
|
||||
if (sender == null && size < 2) {
|
||||
CommandHandler.sendMessage(null, msg);
|
||||
@ -29,9 +29,14 @@ public final class GiveArtifactCommand implements CommandHandler {
|
||||
|
||||
if (size >= 2) {
|
||||
try {
|
||||
level = Integer.parseInt(args.get(size - 1));
|
||||
if (level <= 21) size--;
|
||||
else level = 1;
|
||||
try {
|
||||
int last = Integer.parseInt(args.get(size - 1));
|
||||
if (last >= 1 && last <= 21) {
|
||||
level = last;
|
||||
size--;
|
||||
}
|
||||
} catch (NumberFormatException ignored) {
|
||||
}
|
||||
target = Integer.parseInt(args.get(0));
|
||||
int fromIdx;
|
||||
if (Grasscutter.getGameServer().getPlayerByUid(target) == null && sender != null) {
|
||||
@ -79,7 +84,7 @@ public final class GiveArtifactCommand implements CommandHandler {
|
||||
GameItem item = new GameItem(itemData);
|
||||
item.setLevel(level);
|
||||
item.setMainPropId(mainPropId);
|
||||
item.getAppendPropIdList().clear();//Clear default random props first
|
||||
item.getAppendPropIdList().clear();
|
||||
item.getAppendPropIdList().addAll(appendPropIdList);
|
||||
targetPlayer.getInventory().addItem(item, ActionReason.SubfieldDrop);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user