mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-12-16 08:56:04 +01:00
Extend spawn command (#1777)
* add missing EntityTypes * small command refactorings and improvements * move common command patterns and methods to CommandHelpers * let the spawn command detect the entityType instead of spawning every entity as EntityVehicle * add extra options for spawning gadgets for better debuging and testing * More spawn command additions and cleanups+EntityVehicle changes * Moved remaining patterns from GiveCommand and ClearCommand to CommandHelpers * Added patterns for hp, maxhp, atk, def and (monster)ai for the spawn command * Moved intParam parsing via regex to the CommandHelpers * Read most of EntityVehicle stats from the ConfigGadget instead of hardcoding them Co-authored-by: hartie95 <mail@hartie95.de>
This commit is contained in:
committed by
GitHub
parent
9671a76af2
commit
08f361954a
@@ -62,19 +62,32 @@ public enum EntityType {
|
||||
MiracleRing (51),
|
||||
Foundation (52),
|
||||
WidgetGadget (53),
|
||||
Vehicle (54),
|
||||
SubEquip (55),
|
||||
FishRod (56),
|
||||
CustomTile (57),
|
||||
FishPool (58),
|
||||
CustomGadget (59),
|
||||
BlackMud (60),
|
||||
RoguelikeOperatorGadget (61),
|
||||
NightCrowGadget (62),
|
||||
Projector (63),
|
||||
Screen (64),
|
||||
EchoShell (65),
|
||||
UIInteractGadget (66),
|
||||
PlaceHolder (99);
|
||||
|
||||
|
||||
private final int value;
|
||||
private static final Int2ObjectMap<EntityType> map = new Int2ObjectOpenHashMap<>();
|
||||
private static final Map<String, EntityType> stringMap = new HashMap<>();
|
||||
|
||||
|
||||
static {
|
||||
Stream.of(values()).forEach(e -> {
|
||||
map.put(e.getValue(), e);
|
||||
stringMap.put(e.name(), e);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
private EntityType(int value) {
|
||||
this.value = value;
|
||||
}
|
||||
@@ -82,11 +95,11 @@ public enum EntityType {
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
|
||||
public static EntityType getTypeByValue(int value) {
|
||||
return map.getOrDefault(value, None);
|
||||
}
|
||||
|
||||
|
||||
public static EntityType getTypeByName(String name) {
|
||||
return stringMap.getOrDefault(name, None);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user