/
TestPlugin.java
44 lines (35 loc) · 1.47 KB
/
TestPlugin.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
package haveric.testplugin;
import org.bukkit.Bukkit;
import org.bukkit.Material;
import org.bukkit.NamespacedKey;
import org.bukkit.block.BlockState;
import org.bukkit.block.CreatureSpawner;
import org.bukkit.entity.EntityType;
import org.bukkit.event.Listener;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.ShapelessRecipe;
import org.bukkit.inventory.meta.BlockStateMeta;
import org.bukkit.plugin.java.JavaPlugin;
public class TestPlugin extends JavaPlugin implements Listener {
@Override
public void onEnable() {
ItemStack spawnerItemStack = new ItemStack(Material.SPAWNER);
BlockStateMeta blockStateMeta = (BlockStateMeta) spawnerItemStack.getItemMeta();
BlockState blockState = blockStateMeta.getBlockState();
CreatureSpawner spawner = (CreatureSpawner) blockState;
spawner.setSpawnedType(EntityType.CHICKEN);
spawner.setMinSpawnDelay(1);
spawner.setMaxSpawnDelay(3);
spawner.setMaxNearbyEntities(10);
spawner.setRequiredPlayerRange(5);
spawner.setSpawnRange(4);
spawner.setSpawnCount(3);
spawner.update();
blockStateMeta.setBlockState(spawner);
spawnerItemStack.setItemMeta(blockStateMeta);
ShapelessRecipe testRecipe = new ShapelessRecipe(new NamespacedKey(this, "test"), spawnerItemStack);
testRecipe.addIngredient(Material.DIRT);
testRecipe.addIngredient(Material.STONE);
Bukkit.addRecipe(testRecipe);
}
}