diff --git a/README.md b/README.md index 9d5595853..623baf68b 100644 --- a/README.md +++ b/README.md @@ -115,7 +115,7 @@ There is a dummy user named "Server" in every player's friends list that you can | drop | drop [amount] | server.drop | Client only | Drops an item around you. | `d` `dropitem` | | give | give [player] [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 \ \ | player.givechar | Both side | Gives the player a specified character. | givec | -| giveart | giveart [player] \ \ [\[,\]]... [level] | player.giveart | Both side | Gives the player a specified reliquary. | givea | +| giveart | giveart [player] \ \ [\[,\]]... [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 | diff --git a/README_zh-CN.md b/README_zh-CN.md index a386f0d23..6216cf3eb 100644 --- a/README_zh-CN.md +++ b/README_zh-CN.md @@ -116,7 +116,7 @@ chmod +x gradlew | drop | drop <物品ID\|物品名称> [数量] | server.drop | 仅客户端 | 在指定玩家周围掉落指定物品 | `d` `dropitem` | | give | give [uid] <物品ID\|物品名称> [数量] [等级] [精炼等级] | | | 给予指定玩家一定数量及等级的物品 (精炼等级仅适用于武器) | `g` `item` `giveitem` | | givechar | givechar \ <角色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 | diff --git a/src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java index 299a14f40..382c55ec2 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveArtifactCommand.java @@ -14,13 +14,13 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; -@Command(label = "giveart", usage = "giveart [player] [[,]]... [level]", description = "Gives the player a specified reliquary", aliases = {"givea"}, permission = "player.giveart") +@Command(label = "giveart", usage = "giveart [player] [[,]]... [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 args) { - int size = args.size(), target, itemId, mainPropId, level; + int size = args.size(), target, itemId, mainPropId, level = 1; ArrayList appendPropIdList = new ArrayList<>(); - String msg = "Usage: giveart|givea [player] [[,]]... [level]"; + String msg = "Usage: giveart|gart [player] [[,]]... [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);