Archiviert
13
0
Dieser Commit ist enthalten in:
Chaoscaot 2021-04-03 20:30:05 +02:00
Ursprung a652a8f83e
Commit 0f06b5ff20
2 geänderte Dateien mit 12 neuen und 10 gelöschten Zeilen

Datei anzeigen

@ -111,7 +111,7 @@ public class PlayerSeatListener implements Listener {
public void onEntityDismount(EntityDismountEvent event) { public void onEntityDismount(EntityDismountEvent event) {
seats.remove(getSeatLocation(event.getDismounted().getLocation())); seats.remove(getSeatLocation(event.getDismounted().getLocation()));
if (event.getEntityType() == EntityType.ARROW) if (event.getEntityType() != EntityType.ARROW)
return; return;
event.getDismounted().remove(); event.getDismounted().remove();

Datei anzeigen

@ -12,20 +12,18 @@ import org.bukkit.entity.Rabbit;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.EntityDeathEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.inventory.meta.SkullMeta;
import java.lang.reflect.Field; import java.lang.reflect.Field;
import java.util.HashSet; import java.time.Instant;
import java.util.Random; import java.util.*;
import java.util.UUID;
public class RabbitListener implements Listener { public class RabbitListener implements Listener {
private static final HashSet<String> EGGS = new HashSet<>(); private static final List<String> EGGS = new ArrayList<>();
static { static {
EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkxYzQyYjE3MWZlZDZiZWE2ZmRmNGQ4NzJkNThiZDMzZDdjZTA5ZWVlZGRhMzZlNTQxNTFmODg5MDY2YmU0ZSJ9fX0="); EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkxYzQyYjE3MWZlZDZiZWE2ZmRmNGQ4NzJkNThiZDMzZDdjZTA5ZWVlZGRhMzZlNTQxNTFmODg5MDY2YmU0ZSJ9fX0=");
@ -42,7 +40,7 @@ public class RabbitListener implements Listener {
public RabbitListener() { public RabbitListener() {
Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance());
World world = Bukkit.getWorlds().get(0); World world = Bukkit.getWorlds().get(0);
spreadRabbits(125, world); spreadRabbits(250, world);
Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> {
Rabbit rabbit = world.getEntitiesByClass(Rabbit.class).iterator().next(); Rabbit rabbit = world.getEntitiesByClass(Rabbit.class).iterator().next();
world.spawn(rabbit.getLocation(), Firework.class, firework -> { world.spawn(rabbit.getLocation(), Firework.class, firework -> {
@ -56,17 +54,21 @@ public class RabbitListener implements Listener {
} }
public static void spreadRabbits(int count, World world) { public static void spreadRabbits(int count, World world) {
world.setAmbientSpawnLimit(count);
world.setAnimalSpawnLimit(count);
world.setMonsterSpawnLimit(count);
Random rand = new Random(); Random rand = new Random();
int boundX = Config.BorderMaxX - Config.BorderMinX; int boundX = Config.BorderMaxX - Config.BorderMinX;
int boundZ = Config.BorderMaxZ - Config.BorderMinZ; int boundZ = Config.BorderMaxZ - Config.BorderMinZ;
for (int i = 0; i < count; i++) { for (int i = 0; i < count; i++) {
int relX = rand.nextInt(boundX); int relX = rand.nextInt(boundX);
int relZ = rand.nextInt(boundZ); 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 -> { world.spawn(loc, Rabbit.class, rabbit -> {
rabbit.setRabbitType(Rabbit.Type.WHITE); rabbit.setRabbitType(Rabbit.Type.WHITE);
rabbit.setInvulnerable(true); rabbit.setInvulnerable(true);
rabbit.setCustomName("§fOsterhase"); rabbit.setCustomName("§fOsterhase");
rabbit.setPersistent(true);
}); });
} }
} }
@ -82,14 +84,14 @@ public class RabbitListener implements Listener {
public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { public void onPlayerInteractEntity(PlayerInteractEntityEvent event) {
if(event.getRightClicked().getType() == EntityType.RABBIT) { if(event.getRightClicked().getType() == EntityType.RABBIT) {
Player p = event.getPlayer(); Player p = event.getPlayer();
event.getRightClicked().addPassenger(p);
event.setCancelled(true); event.setCancelled(true);
event.getRightClicked().addPassenger(p);
} }
} }
public static ItemStack getEggHead() { public static ItemStack getEggHead() {
return getCustomTextureHead(new ItemStack(Material.PLAYER_HEAD), 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) { private static ItemStack getCustomTextureHead(ItemStack head, String value) {