From 1206f4d75e5c72a415fbcd7f11ca38ab344c950f Mon Sep 17 00:00:00 2001 From: Chaoscaot Date: Tue, 6 Apr 2021 01:56:37 +0200 Subject: [PATCH] Reverting RabbitListener.java --- .../lobby/listener/PlayerSeatListener.java | 6 +- .../lobby/listener/RabbitListener.java | 113 ------------------ 2 files changed, 3 insertions(+), 116 deletions(-) delete mode 100644 src/de/steamwar/lobby/listener/RabbitListener.java diff --git a/src/de/steamwar/lobby/listener/PlayerSeatListener.java b/src/de/steamwar/lobby/listener/PlayerSeatListener.java index 025e316..a0ac093 100644 --- a/src/de/steamwar/lobby/listener/PlayerSeatListener.java +++ b/src/de/steamwar/lobby/listener/PlayerSeatListener.java @@ -88,7 +88,7 @@ public class PlayerSeatListener implements Listener { if (((Stairs) event.getClickedBlock().getBlockData()).getShape() != Stairs.Shape.STRAIGHT) return; - if (event.getPlayer().isInsideVehicle() && event.getPlayer().getVehicle().getType() == EntityType.ARROW) + if (event.getPlayer().isInsideVehicle()) event.getPlayer().getVehicle().remove(); if (event.getClickedBlock().getRelative(0, 1, 0).getType() != Material.AIR) @@ -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.PLAYER) return; event.getDismounted().remove(); @@ -119,7 +119,7 @@ public class PlayerSeatListener implements Listener { @EventHandler public void onPlayerQuit(PlayerQuitEvent event) { - if (event.getPlayer().isInsideVehicle() && event.getPlayer().getVehicle().getType() == EntityType.ARROW) + if (event.getPlayer().isInsideVehicle()) event.getPlayer().getVehicle().remove(); } diff --git a/src/de/steamwar/lobby/listener/RabbitListener.java b/src/de/steamwar/lobby/listener/RabbitListener.java deleted file mode 100644 index 2a420a2..0000000 --- a/src/de/steamwar/lobby/listener/RabbitListener.java +++ /dev/null @@ -1,113 +0,0 @@ -package de.steamwar.lobby.listener; - -import com.mojang.authlib.GameProfile; -import com.mojang.authlib.properties.Property; -import de.steamwar.lobby.LobbySystem; -import de.steamwar.lobby.utils.Config; -import org.bukkit.*; -import org.bukkit.entity.EntityType; -import org.bukkit.entity.Firework; -import org.bukkit.entity.Player; -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.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.time.Instant; -import java.util.*; - -public class RabbitListener implements Listener { - - private static final List EGGS = new ArrayList<>(); - - static { - EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvMjkxYzQyYjE3MWZlZDZiZWE2ZmRmNGQ4NzJkNThiZDMzZDdjZTA5ZWVlZGRhMzZlNTQxNTFmODg5MDY2YmU0ZSJ9fX0="); - EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTMwNGJkMzE2MTFmODYzYTZiMDFlNmUzZjVhN2MwOWQwYWU1YzA3YTA5NDEyZmNhYTMxYmM1Mzc2OGYzYjI4OSJ9fX0="); - EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvOWIyY2VkNGU1NjYwNWFiZDJhNjA4YjZkNzE1MDE2NzhjNjBjNTcyMjYwNGZlYWE3MjEwNjc2OWIwZDNhYzc1OSJ9fX0="); - EGGS.add("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYzQyZWFlM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RabbitListener() { - Bukkit.getPluginManager().registerEvents(this, LobbySystem.getInstance()); - World world = Bukkit.getWorlds().get(0); - spreadRabbits(250, world); - Bukkit.getScheduler().runTaskTimer(LobbySystem.getInstance(), () -> { - Rabbit rabbit = world.getEntitiesByClass(Rabbit.class).iterator().next(); - world.spawn(rabbit.getLocation(), Firework.class, firework -> { - FireworkMeta meta = firework.getFireworkMeta(); - meta.clearEffects(); - meta.addEffects(FireworkEffect.builder().with(FireworkEffect.Type.BURST).trail(true).withColor(Color.WHITE).build()); - meta.setPower(1); - firework.setFireworkMeta(meta); - }); - }, 60*20, 60*20); - } - - 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 + 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); - }); - } - } - - @EventHandler - public void onEntityDamage(EntityDamageEvent event) { - if(event.getEntityType() == EntityType.RABBIT) { - event.setCancelled(true); - } - } - - @EventHandler - public void onPlayerInteractEntity(PlayerInteractEntityEvent event) { - if(event.getRightClicked().getType() == EntityType.RABBIT) { - Player p = event.getPlayer(); - event.setCancelled(true); - event.getRightClicked().addPassenger(p); - } - } - - public static ItemStack getEggHead() { - return getCustomTextureHead(new ItemStack(Material.PLAYER_HEAD), - EGGS.get(Math.toIntExact(Instant.now().getEpochSecond() % EGGS.size()))); - } - - private static ItemStack getCustomTextureHead(ItemStack head, String value) { - SkullMeta meta = (SkullMeta) head.getItemMeta(); - meta.setDisplayName("§eEierkopf"); - GameProfile profile = new GameProfile(UUID.randomUUID(), ""); - profile.getProperties().put("textures", new Property("textures", value)); - Field profileField = null; - try { - profileField = meta.getClass().getDeclaredField("profile"); - profileField.setAccessible(true); - profileField.set(meta, profile); - } catch (IllegalArgumentException | IllegalAccessException | NoSuchFieldException | SecurityException e) { - e.printStackTrace(); - } - head.setItemMeta(meta); - return head; - } -}