diff options
author | Senmori <thesenmori@gmail.com> | 2018-01-24 17:18:25 +1100 |
---|---|---|
committer | md_5 <git@md-5.net> | 2018-01-24 17:19:41 +1100 |
commit | c7656468e4601fb70e0d7049c4b947e16034546f (patch) | |
tree | caaa12658e0a97b97048a327b476e18b9734aba3 /src/main | |
parent | 4a030536cd41e839fe494c442d763fd5feef0037 (diff) | |
download | craftbukkit-c7656468e4601fb70e0d7049c4b947e16034546f.tar craftbukkit-c7656468e4601fb70e0d7049c4b947e16034546f.tar.gz craftbukkit-c7656468e4601fb70e0d7049c4b947e16034546f.tar.lz craftbukkit-c7656468e4601fb70e0d7049c4b947e16034546f.tar.xz craftbukkit-c7656468e4601fb70e0d7049c4b947e16034546f.zip |
Expand CreatureSpawner API
Diffstat (limited to 'src/main')
-rw-r--r-- | src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java index 67f4c730..2ec70843 100644 --- a/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java +++ b/src/main/java/org/bukkit/craftbukkit/block/CraftCreatureSpawner.java @@ -1,5 +1,6 @@ package org.bukkit.craftbukkit.block; +import com.google.common.base.Preconditions; import net.minecraft.server.MinecraftKey; import net.minecraft.server.TileEntityMobSpawner; import org.bukkit.Material; @@ -57,4 +58,67 @@ public class CraftCreatureSpawner extends CraftBlockEntityState<TileEntityMobSpa public void setDelay(int delay) { this.getSnapshot().getSpawner().spawnDelay = delay; } + + @Override + public int getMinSpawnDelay() { + return this.getSnapshot().getSpawner().minSpawnDelay; + } + + @Override + public void setMinSpawnDelay(int spawnDelay) { + Preconditions.checkArgument(spawnDelay <= getMaxSpawnDelay(), "Minimum Spawn Delay must be less than or equal to Maximum Spawn Delay"); + this.getSnapshot().getSpawner().minSpawnDelay = spawnDelay; + } + + @Override + public int getMaxSpawnDelay() { + return this.getSnapshot().getSpawner().maxSpawnDelay; + } + + @Override + public void setMaxSpawnDelay(int spawnDelay) { + Preconditions.checkArgument(spawnDelay > 0, "Maximum Spawn Delay must be greater than 0."); + Preconditions.checkArgument(spawnDelay >= getMinSpawnDelay(), "Maximum Spawn Delay must be greater than or equal to Minimum Spawn Delay"); + this.getSnapshot().getSpawner().maxSpawnDelay = spawnDelay; + } + + @Override + public int getMaxNearbyEntities() { + return this.getSnapshot().getSpawner().maxNearbyEntities; + } + + @Override + public void setMaxNearbyEntities(int maxNearbyEntities) { + this.getSnapshot().getSpawner().maxNearbyEntities = maxNearbyEntities; + } + + @Override + public int getSpawnCount() { + return this.getSnapshot().getSpawner().spawnCount; + } + + @Override + public void setSpawnCount(int count) { + this.getSnapshot().getSpawner().spawnCount = count; + } + + @Override + public int getRequiredPlayerRange() { + return this.getSnapshot().getSpawner().requiredPlayerRange; + } + + @Override + public void setRequiredPlayerRange(int requiredPlayerRange) { + this.getSnapshot().getSpawner().requiredPlayerRange = requiredPlayerRange; + } + + @Override + public int getSpawnRange() { + return this.getSnapshot().getSpawner().spawnRange; + } + + @Override + public void setSpawnRange(int spawnRange) { + this.getSnapshot().getSpawner().spawnRange = spawnRange; + } } |