mirror of
https://github.com/Melledy/Grasscutter.git
synced 2024-11-23 03:37:38 +00:00
Add coordinate support for spawn command (monster only)
Now the spawn command is: spawn <entityID> [amount] [level(monster only)] <x> <y> <z>(monster only, optional) The coordinate is optional
This commit is contained in:
parent
73a1c5762a
commit
4119f8b787
@ -23,7 +23,7 @@ import java.util.Random;
|
|||||||
import static emu.grasscutter.Configuration.*;
|
import static emu.grasscutter.Configuration.*;
|
||||||
import static emu.grasscutter.utils.Language.translate;
|
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")
|
@Command(label = "spawn", usage = "spawn <entityId> [amount] [level(monster only)] <x> <y> <z>(monster only, optional)", permission = "server.spawn", permissionTargeted = "server.spawn.others", description = "commands.spawn.description")
|
||||||
public final class SpawnCommand implements CommandHandler {
|
public final class SpawnCommand implements CommandHandler {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -31,7 +31,16 @@ public final class SpawnCommand implements CommandHandler {
|
|||||||
int id = 0; // This is just to shut up the linter, it's not a real default
|
int id = 0; // This is just to shut up the linter, it's not a real default
|
||||||
int amount = 1;
|
int amount = 1;
|
||||||
int level = 1;
|
int level = 1;
|
||||||
|
float x = 0, y = 0, z = 0;
|
||||||
switch (args.size()) {
|
switch (args.size()) {
|
||||||
|
case 6:
|
||||||
|
try {
|
||||||
|
x = Float.parseFloat(args.get(3));
|
||||||
|
y = Float.parseFloat(args.get(4));
|
||||||
|
z = Float.parseFloat(args.get(5));
|
||||||
|
} catch (NumberFormatException ignored) {
|
||||||
|
CommandHandler.sendMessage(sender, translate(sender, "commands.execution.argument_error"));
|
||||||
|
} // Fallthrough
|
||||||
case 3:
|
case 3:
|
||||||
try {
|
try {
|
||||||
level = Integer.parseInt(args.get(2));
|
level = Integer.parseInt(args.get(2));
|
||||||
@ -77,6 +86,9 @@ public final class SpawnCommand implements CommandHandler {
|
|||||||
double maxRadius = Math.sqrt(amount * 0.2 / Math.PI);
|
double maxRadius = Math.sqrt(amount * 0.2 / Math.PI);
|
||||||
for (int i = 0; i < amount; i++) {
|
for (int i = 0; i < amount; i++) {
|
||||||
Position pos = GetRandomPositionInCircle(targetPlayer.getPos(), maxRadius).addY(3);
|
Position pos = GetRandomPositionInCircle(targetPlayer.getPos(), maxRadius).addY(3);
|
||||||
|
if(x != 0 && y != 0 && z != 0) {
|
||||||
|
pos = GetRandomPositionInCircle(new Position(x, y, z), maxRadius).addY(3);
|
||||||
|
}
|
||||||
GameEntity entity = null;
|
GameEntity entity = null;
|
||||||
if (itemData != null) {
|
if (itemData != null) {
|
||||||
entity = new EntityItem(scene, null, itemData, pos, 1, true);
|
entity = new EntityItem(scene, null, itemData, pos, 1, true);
|
||||||
|
@ -304,7 +304,7 @@
|
|||||||
"description": "Sets your world level (Relog to see proper effects)"
|
"description": "Sets your world level (Relog to see proper effects)"
|
||||||
},
|
},
|
||||||
"spawn": {
|
"spawn": {
|
||||||
"usage": "Usage: spawn <entityID> [amount] [level(monster only)]",
|
"usage": "Usage: spawn <entityID> [amount] [level(monster only)] <x> <y> <z>(monster only, optional)",
|
||||||
"success": "Spawned %s of %s.",
|
"success": "Spawned %s of %s.",
|
||||||
"limit_reached": "Scene spawn limit reached. Spawning %s entities instead.",
|
"limit_reached": "Scene spawn limit reached. Spawning %s entities instead.",
|
||||||
"description": "Spawns an entity near you"
|
"description": "Spawns an entity near you"
|
||||||
|
Loading…
Reference in New Issue
Block a user