mirror of
https://github.com/VolmitSoftware/Iris.git
synced 2025-07-18 10:12:53 +00:00
Run raw commands for entity spawns
This commit is contained in:
parent
8539bc5ade
commit
7878b05030
@ -176,6 +176,10 @@ public class IrisEntity extends IrisRegistrant {
|
||||
@RegistryListResource(IrisScript.class)
|
||||
private KList<String> postSpawnScripts = new KList<>();
|
||||
|
||||
@ArrayType(min = 1, type = String.class)
|
||||
@Desc("Run raw commands when this entity is spawned. Use {x}, {y}, and {z} for location. /summon pig {x} {y} {z}")
|
||||
private KList<String> rawCommands = new KList<>();
|
||||
|
||||
public Entity spawn(Engine gen, Location at) {
|
||||
return spawn(gen, at, new RNG(at.hashCode()));
|
||||
}
|
||||
@ -357,6 +361,17 @@ public class IrisEntity extends IrisRegistrant {
|
||||
}
|
||||
}
|
||||
|
||||
if (rawCommands.isNotEmpty()) {
|
||||
synchronized (this) {
|
||||
for (String rawCommand : rawCommands) {
|
||||
rawCommand.replaceAll("\\Q{x}\\E", String.valueOf(at.getBlockX()));
|
||||
rawCommand.replaceAll("\\Q{y}\\E", String.valueOf(at.getBlockY()));
|
||||
rawCommand.replaceAll("\\Q{z}\\E", String.valueOf(at.getBlockZ()));
|
||||
Bukkit.getServer().dispatchCommand(Bukkit.getConsoleSender(), rawCommand);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Location finalAt1 = at;
|
||||
|
||||
J.s(() -> {
|
||||
|
Loading…
x
Reference in New Issue
Block a user