Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @EventHandler
- public void onPlayerInteractFood(PlayerInteractEvent e) {
- Player p = e.getPlayer();
- Block clicked = e.getClickedBlock();
- Button button = (Button) clicked.getState().getData();
- if (!e.getAction().equals(Action.RIGHT_CLICK_BLOCK)) {
- return;
- }
- if ((!clicked.getType().equals(Material.STONE_BUTTON))
- && (!clicked.getType().equals(Material.WOOD_BUTTON))) {
- return;
- }
- if (button.isPowered())
- return;
- World w = Bukkit.getServer().getWorld(
- FileM.getCfg().getString("food.button.w"));
- double x = FileM.getCfg().getDouble("food.button.x");
- double y = FileM.getCfg().getDouble("food.button.y");
- double z = FileM.getCfg().getDouble("food.button.z");
- if (clicked.getLocation().getWorld() == w
- || clicked.getLocation().getBlockX() == x
- || clicked.getLocation().getBlockY() == y
- || clicked.getLocation().getBlockZ() == z) {
- World w2 = Bukkit.getServer().getWorld(
- FileM.getCfg().getString("food.spawned.w"));
- double x2 = FileM.getCfg().getDouble("food.spawned.x");
- double y2 = FileM.getCfg().getDouble("food.spawned.y");
- double z2 = FileM.getCfg().getDouble("food.spawned.z");
- Location loc2 = new Location(w2, x2, y2, z2);
- Util.sendMessage(p, "debug");
- e.setCancelled(true);
- for (int i = 0; i < 10; i++) {
- LivingEntity pig = (LivingEntity) w.spawnEntity(loc2,
- EntityType.PIG);
- pig.setCustomName(ColorUtil.fixColors("&2&lNEVERALD&7.PL"));
- pig.setCustomNameVisible(true);
- pig.setVelocity(pig.getVelocity().multiply(2));
- pig.setFireTicks(400);
- }
- for (int i = 0; i < 5; i++) {
- LivingEntity cow = (LivingEntity) w.spawnEntity(loc2,
- EntityType.COW);
- cow.setCustomName(ColorUtil.fixColors("&2&lNEVERALD&7.PL"));
- cow.setCustomNameVisible(true);
- cow.setVelocity(cow.getVelocity().multiply(2));
- cow.setFireTicks(400);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement