From 1567e480e1bacfbb3b17a01802523012fd51f1b6 Mon Sep 17 00:00:00 2001 From: BaiSugar Date: Mon, 25 Apr 2022 15:17:55 +0800 Subject: [PATCH] remove test avatar --- .../command/commands/GiveAllCommand.java | 27 +++++++++++-------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java b/src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java index 4a7777565..b994fe419 100644 --- a/src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java +++ b/src/main/java/emu/grasscutter/command/commands/GiveAllCommand.java @@ -9,25 +9,24 @@ import emu.grasscutter.data.def.ItemData; import emu.grasscutter.game.GenshinPlayer; import emu.grasscutter.game.avatar.GenshinAvatar; import emu.grasscutter.game.inventory.GenshinItem; +import emu.grasscutter.game.inventory.ItemType; import java.util.*; @Command(label = "giveall", usage = "giveall [player] ", description = "Gives all items", aliases = {"givea"}, permission = "player.giveall",threading = true) public class GiveAllCommand implements CommandHandler { - @Override public void execute(GenshinPlayer sender, List args) { int target,amount=99999; + if(sender == null){ + CommandHandler.sendMessage(null, "Run this command in-game"); + return; + } switch (args.size()) { default: // *no args* - try { - target = sender.getUid(); - }catch (NullPointerException ignored){ - CommandHandler.sendMessage(sender, "Player not found."); - return; - } + target = sender.getUid(); break; case 1: // [player] try { @@ -44,7 +43,7 @@ public class GiveAllCommand implements CommandHandler { case 2: // [player] [amount] try { target = Integer.parseInt(args.get(0)); - if (Grasscutter.getGameServer().getPlayerByUid(target) == null && sender != null) { + if (Grasscutter.getGameServer().getPlayerByUid(target) == null) { target = sender.getUid(); amount = Integer.parseInt(args.get(0)); } else { @@ -56,8 +55,8 @@ public class GiveAllCommand implements CommandHandler { } break; } - GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); + GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target); if (targetPlayer == null) { CommandHandler.sendMessage(sender, "Player not found."); return; @@ -68,14 +67,19 @@ public class GiveAllCommand implements CommandHandler { } public void GetAllItem(GenshinPlayer player, int amount){ - CommandHandler.sendMessage(player, "Getting all items…"); + CommandHandler.sendMessage(player, "Getting all item...."); Collection genshinItemList =new LinkedList<>(); for (ItemData itemdata: GenshinData.getItemDataMap().values()) { if(itemdata.getId() > 1000 && itemdata.getId() <= 1099)continue;//is avatar if (itemdata.isEquip()) { for (int i = 0; i < 20; i++) { - genshinItemList.add(new GenshinItem(itemdata)); + GenshinItem genshinItem = new GenshinItem(itemdata); + if(itemdata.getItemType() == ItemType.ITEM_WEAPON){ + genshinItem.setLevel(90); + genshinItem.setPromoteLevel(6); + } + genshinItemList.add(genshinItem); } } else { GenshinItem genshinItem = new GenshinItem(itemdata); @@ -86,6 +90,7 @@ public class GiveAllCommand implements CommandHandler { player.getInventory().addItems(genshinItemList); for(AvatarData avatarData:GenshinData.getAvatarDataMap().values()) { + if(avatarData.getId() == 10000001 || avatarData.getId() >= 10000099)continue; // Calculate ascension level. int ascension = (int) Math.ceil(90 / 10f) - 3; GenshinAvatar avatar = new GenshinAvatar(avatarData);