fix baby mobs, clean a few imports

This commit is contained in:
ayunami2000 2022-04-07 23:47:32 -04:00
parent a89cca1baa
commit 294f8db528
5 changed files with 29 additions and 11 deletions

View File

@ -33,7 +33,6 @@ import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.io.InputStream;
import java.util.Properties;
import java.util.UUID;
@Getter
@Setter

View File

@ -8,7 +8,6 @@ import dev.plex.rank.enums.Rank;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.text.Component;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.World;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.*;

View File

@ -6,20 +6,14 @@ import java.util.Arrays;
import java.util.List;
import dev.plex.util.PlexUtils;
import net.kyori.adventure.sound.Sound;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.event.ClickEvent;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.block.Block;
import org.bukkit.block.Sign;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.EventPriority;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.metadata.FixedMetadataValue;
public class BlockListener extends PlexListener
{

View File

@ -5,8 +5,9 @@ import dev.plex.util.PlexUtils;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.Dispenser;
import org.bukkit.block.data.Directional;
import org.bukkit.entity.Ageable;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -15,8 +16,8 @@ import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDispenseEvent;
import org.bukkit.event.entity.CreatureSpawnEvent;
import org.bukkit.event.entity.EntitySpawnEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.ItemStack;
import java.util.Arrays;
@ -64,6 +65,27 @@ public class SpawnListener extends PlexListener
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onEntityClick(PlayerInteractEntityEvent event)
{
Material handItem = event.getPlayer().getEquipment().getItem(event.getHand()).getType();
if (event.getRightClicked() instanceof Ageable entity)
{
if (SPAWN_EGGS.contains(handItem))
{
EntityType eggType = spawnEggToEntityType(handItem);
if (eggType != null)
{
Entity spawned = entity.getWorld().spawnEntity(entity.getLocation(), eggType);
if (spawned instanceof Ageable ageable)
{
ageable.setBaby();
}
}
}
}
}
@EventHandler(priority = EventPriority.HIGH)
public void onPlayerInteract(PlayerInteractEvent event)
{

View File

@ -9,7 +9,6 @@ import dev.plex.storage.StorageType;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.kyori.adventure.text.serializer.plain.PlainTextComponentSerializer;
import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.*;
import org.bukkit.command.Command;
@ -392,6 +391,11 @@ public class PlexUtils extends PlexBase
return Collections.unmodifiableSet(classes);
}
public static boolean randomBoolean()
{
return ThreadLocalRandom.current().nextBoolean();
}
public static int randomNum()
{
return ThreadLocalRandom.current().nextInt();