Fixing Rabbits
Dieser Commit ist enthalten in:
Ursprung
a652a8f83e
Commit
0f06b5ff20
@ -111,7 +111,7 @@ public class PlayerSeatListener implements Listener {
|
||||
public void onEntityDismount(EntityDismountEvent event) {
|
||||
seats.remove(getSeatLocation(event.getDismounted().getLocation()));
|
||||
|
||||
if (event.getEntityType() == EntityType.ARROW)
|
||||
if (event.getEntityType() != EntityType.ARROW)
|
||||
return;
|
||||
|
||||
event.getDismounted().remove();
|
||||
|
@ -12,20 +12,18 @@ import org.bukkit.entity.Rabbit;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.EntityDeathEvent;
|
||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.inventory.meta.SkullMeta;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashSet;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.time.Instant;
|
||||
import java.util.*;
|
||||
|
||||
public class RabbitListener implements Listener {
|
||||
|
||||
private static final HashSet<String> EGGS = new HashSet<>();
|
||||
private static final List<String> EGGS = new ArrayList<>();
|
||||
|
||||
static {
|
||||
EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkxYzQyYjE3MWZlZDZiZWE2ZmRmNGQ4NzJkNThiZDMzZDdjZTA5ZWVlZGRhMzZlNTQxNTFmODg5MDY2YmU0ZSJ9fX0=");
|
||||
@ -42,7 +40,7 @@ public class RabbitListener implements Listener {
|
||||
public RabbitListener() {
|
||||
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance());
|
||||
World world = Bukkit.getWorlds().get(0);
|
||||
spreadRabbits(125, world);
|
||||
spreadRabbits(250, world);
|
||||
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
|
||||
Rabbit rabbit = world.getEntitiesByClass(Rabbit.class).iterator().next();
|
||||
world.spawn(rabbit.getLocation(), Firework.class, firework -> {
|
||||
@ -56,17 +54,21 @@ public class RabbitListener implements Listener {
|
||||
}
|
||||
|
||||
public static void spreadRabbits(int count, World world) {
|
||||
world.setAmbientSpawnLimit(count);
|
||||
world.setAnimalSpawnLimit(count);
|
||||
world.setMonsterSpawnLimit(count);
|
||||
Random rand = new Random();
|
||||
int boundX = Config.BorderMaxX - Config.BorderMinX;
|
||||
int boundZ = Config.BorderMaxZ - Config.BorderMinZ;
|
||||
for (int i = 0; i < count; i++) {
|
||||
int relX = rand.nextInt(boundX);
|
||||
int relZ = rand.nextInt(boundZ);
|
||||
Location loc = new Location(world, relX, 255, relZ);
|
||||
Location loc = new Location(world, relX + Config.BorderMinX, 255, relZ + Config.BorderMinZ);
|
||||
world.spawn(loc, Rabbit.class, rabbit -> {
|
||||
rabbit.setRabbitType(Rabbit.Type.WHITE);
|
||||
rabbit.setInvulnerable(true);
|
||||
rabbit.setCustomName("§fOsterhase");
|
||||
rabbit.setPersistent(true);
|
||||
});
|
||||
}
|
||||
}
|
||||
@ -82,14 +84,14 @@ public class RabbitListener implements Listener {
|
||||
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
|
||||
if(event.getRightClicked().getType() == EntityType.RABBIT) {
|
||||
Player p = event.getPlayer();
|
||||
event.getRightClicked().addPassenger(p);
|
||||
event.setCancelled(true);
|
||||
event.getRightClicked().addPassenger(p);
|
||||
}
|
||||
}
|
||||
|
||||
public static ItemStack getEggHead() {
|
||||
return getCustomTextureHead(new ItemStack(Material.PLAYER_HEAD),
|
||||
EGGS.iterator().next());
|
||||
EGGS.get(Math.toIntExact(Instant.now().getEpochSecond() % EGGS.size())));
|
||||
}
|
||||
|
||||
private static ItemStack getCustomTextureHead(ItemStack head, String value) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren