mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-29 12:02:45 +00:00
Bug fix & Cleanup
This commit is contained in:
parent
2369f92cb4
commit
d23050ffa5
@ -3,15 +3,10 @@ package emu.grasscutter.command.commands;
|
|||||||
import emu.grasscutter.Grasscutter;
|
import emu.grasscutter.Grasscutter;
|
||||||
import emu.grasscutter.command.Command;
|
import emu.grasscutter.command.Command;
|
||||||
import emu.grasscutter.command.CommandHandler;
|
import emu.grasscutter.command.CommandHandler;
|
||||||
import emu.grasscutter.data.GenshinData;
|
|
||||||
import emu.grasscutter.data.def.ItemData;
|
|
||||||
import emu.grasscutter.game.GenshinPlayer;
|
import emu.grasscutter.game.GenshinPlayer;
|
||||||
import emu.grasscutter.game.inventory.GenshinItem;
|
|
||||||
import emu.grasscutter.game.inventory.Inventory;
|
import emu.grasscutter.game.inventory.Inventory;
|
||||||
import emu.grasscutter.game.inventory.ItemType;
|
import emu.grasscutter.game.inventory.ItemType;
|
||||||
|
|
||||||
import java.util.Collection;
|
|
||||||
import java.util.LinkedList;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@Command(label = "clear", usage = "clear <all|wp|art|mat>", //Merged /clearartifacts and /clearweapons to /clear <args> [uid]
|
@Command(label = "clear", usage = "clear <all|wp|art|mat>", //Merged /clearartifacts and /clearweapons to /clear <args> [uid]
|
||||||
@ -33,34 +28,34 @@ public final class ClearCommand implements CommandHandler {
|
|||||||
try {
|
try {
|
||||||
target = Integer.parseInt(args.get(0));
|
target = Integer.parseInt(args.get(0));
|
||||||
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
|
GenshinPlayer targetPlayer = Grasscutter.getGameServer().getPlayerByUid(target);
|
||||||
if (targetPlayer == null && sender != null) {
|
if (targetPlayer == null) {
|
||||||
target = sender.getUid();
|
target = sender.getUid();
|
||||||
} else {
|
} else {
|
||||||
switch (cmdSwitch){
|
switch (cmdSwitch) {
|
||||||
case "wp":
|
case "wp" -> {
|
||||||
playerInventory.getItems().values().stream()
|
playerInventory.getItems().values().stream()
|
||||||
.filter(item -> item.getItemType() == ItemType.ITEM_WEAPON)
|
.filter(item -> item.getItemType() == ItemType.ITEM_WEAPON)
|
||||||
.filter(item -> !item.isLocked() && !item.isEquipped())
|
.filter(item -> !item.isLocked() && !item.isEquipped())
|
||||||
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
||||||
sender.dropMessage("Cleared weapons for " + targetPlayer.getNickname() + " .");
|
sender.dropMessage("Cleared weapons for " + targetPlayer.getNickname() + " .");
|
||||||
break;
|
}
|
||||||
case "art":
|
case "art" -> {
|
||||||
playerInventory.getItems().values().stream()
|
playerInventory.getItems().values().stream()
|
||||||
.filter(item -> item.getItemType() == ItemType.ITEM_RELIQUARY)
|
.filter(item -> item.getItemType() == ItemType.ITEM_RELIQUARY)
|
||||||
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
|
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
|
||||||
.filter(item -> !item.isLocked() && !item.isEquipped())
|
.filter(item -> !item.isLocked() && !item.isEquipped())
|
||||||
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
||||||
sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " .");
|
sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " .");
|
||||||
break;
|
}
|
||||||
case "mat":
|
case "mat" -> {
|
||||||
playerInventory.getItems().values().stream()
|
playerInventory.getItems().values().stream()
|
||||||
.filter(item -> item.getItemType() == ItemType.ITEM_MATERIAL)
|
.filter(item -> item.getItemType() == ItemType.ITEM_MATERIAL)
|
||||||
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
|
.filter(item -> item.getLevel() == 1 && item.getExp() == 0)
|
||||||
.filter(item -> !item.isLocked() && !item.isEquipped())
|
.filter(item -> !item.isLocked() && !item.isEquipped())
|
||||||
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
.forEach(item -> playerInventory.removeItem(item, item.getCount()));
|
||||||
sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " .");
|
sender.dropMessage("Cleared artifacts for " + targetPlayer.getNickname() + " .");
|
||||||
break;
|
}
|
||||||
case "all":
|
case "all" -> {
|
||||||
playerInventory.getItems().values().stream()
|
playerInventory.getItems().values().stream()
|
||||||
.filter(item1 -> item1.getItemType() == ItemType.ITEM_RELIQUARY)
|
.filter(item1 -> item1.getItemType() == ItemType.ITEM_RELIQUARY)
|
||||||
.filter(item1 -> item1.getLevel() == 1 && item1.getExp() == 0)
|
.filter(item1 -> item1.getLevel() == 1 && item1.getExp() == 0)
|
||||||
@ -88,7 +83,7 @@ public final class ClearCommand implements CommandHandler {
|
|||||||
.filter(item6 -> !item6.isLocked() && !item6.isEquipped())
|
.filter(item6 -> !item6.isLocked() && !item6.isEquipped())
|
||||||
.forEach(item6 -> playerInventory.removeItem(item6, item6.getCount()));
|
.forEach(item6 -> playerInventory.removeItem(item6, item6.getCount()));
|
||||||
sender.dropMessage("Cleared everything for " + targetPlayer.getNickname() + " .");
|
sender.dropMessage("Cleared everything for " + targetPlayer.getNickname() + " .");
|
||||||
break;
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
|
@ -43,7 +43,7 @@ public final class SetFetterLevelCommand implements CommandHandler {
|
|||||||
sender.sendPacket(new PacketAvatarFetterDataNotify(avatar));
|
sender.sendPacket(new PacketAvatarFetterDataNotify(avatar));
|
||||||
CommandHandler.sendMessage(sender, "Fetter level set to " + fetterLevel);
|
CommandHandler.sendMessage(sender, "Fetter level set to " + fetterLevel);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
CommandHandler.sendMessage(null, "Invalid fetter level.");
|
CommandHandler.sendMessage(sender, "Invalid fetter level.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user