mirror of
https://github.com/Grasscutters/Grasscutter.git
synced 2025-01-25 03:12:52 +08:00
Limit spawn amount if too many entities are in the world
Can be controlled in the config with `sceneEntityLimit`
This commit is contained in:
parent
18721758cc
commit
184eec82b3
@ -20,6 +20,7 @@ import javax.swing.text.html.parser.Entity;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
import static emu.grasscutter.Configuration.*;
|
||||
import static emu.grasscutter.utils.Language.translate;
|
||||
|
||||
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)]", permission = "server.spawn", permissionTargeted = "server.spawn.others", description = "commands.spawn.description")
|
||||
@ -54,7 +55,7 @@ public final class SpawnCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.spawn.usage"));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
MonsterData monsterData = GameData.getMonsterDataMap().get(id);
|
||||
GadgetData gadgetData = GameData.getGadgetDataMap().get(id);
|
||||
ItemData itemData = GameData.getItemDataMap().get(id);
|
||||
@ -62,7 +63,16 @@ public final class SpawnCommand implements CommandHandler {
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.generic.invalid.entityId"));
|
||||
return;
|
||||
}
|
||||
|
||||
Scene scene = targetPlayer.getScene();
|
||||
|
||||
if (scene.getEntities().size() + amount > GAME_OPTIONS.sceneEntityLimit) {
|
||||
amount = Math.max(Math.min(GAME_OPTIONS.sceneEntityLimit - scene.getEntities().size(), amount), 0);
|
||||
CommandHandler.sendMessage(sender, translate(sender, "commands.spawn.limit_reached", amount));
|
||||
if (amount <= 0) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
double maxRadius = Math.sqrt(amount * 0.2 / Math.PI);
|
||||
for (int i = 0; i < amount; i++) {
|
||||
|
@ -171,7 +171,7 @@ public class ConfigContainer {
|
||||
public static class GameOptions {
|
||||
public InventoryLimits inventoryLimits = new InventoryLimits();
|
||||
public AvatarLimits avatarLimits = new AvatarLimits();
|
||||
public int worldEntityLimit = 1000; // Unenforced. TODO: Implement.
|
||||
public int sceneEntityLimit = 1000; // Unenforced. TODO: Implement.
|
||||
|
||||
public boolean watchGachaConfig = false;
|
||||
public boolean enableShopItems = true;
|
||||
|
@ -306,6 +306,7 @@
|
||||
"spawn": {
|
||||
"usage": "Usage: spawn <entityID> [amount] [level(monster only)]",
|
||||
"success": "Spawned %s of %s.",
|
||||
"limit_reached": "Scene spawn limit reached. Spawning %s entities instead.",
|
||||
"description": "Spawns an entity near you"
|
||||
},
|
||||
"stop": {
|
||||
|
Loading…
Reference in New Issue
Block a user