mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 09:37:37 +00:00
mob blocker
yay :D
This commit is contained in:
parent
bb78816dec
commit
e9e5db7c2b
@ -35,7 +35,7 @@ public class EntityWipeCMD extends PlexCommand
|
|||||||
|
|
||||||
EntityType[] entityTypes = EntityType.values();
|
EntityType[] entityTypes = EntityType.values();
|
||||||
entityWhitelist.removeIf(name -> {
|
entityWhitelist.removeIf(name -> {
|
||||||
boolean res = Arrays.stream(entityTypes).noneMatch(entityType -> entityType.name().equalsIgnoreCase(name));
|
boolean res = Arrays.stream(entityTypes).noneMatch(entityType -> name.equalsIgnoreCase(entityType.name()));
|
||||||
if (res)
|
if (res)
|
||||||
{
|
{
|
||||||
sender.sendMessage(messageComponent("invalidEntityType", name));
|
sender.sendMessage(messageComponent("invalidEntityType", name));
|
||||||
|
@ -4,9 +4,13 @@ import dev.plex.listener.PlexListener;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.sound.Sound;
|
import net.kyori.adventure.sound.Sound;
|
||||||
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.Particle;
|
import org.bukkit.Particle;
|
||||||
|
import org.bukkit.block.Block;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.BlockBreakEvent;
|
import org.bukkit.event.block.BlockBreakEvent;
|
||||||
@ -41,24 +45,18 @@ public class BlockListener extends PlexListener
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (blockedBlocks.contains(event.getBlock().getType()))
|
Block block = event.getBlock();
|
||||||
{
|
|
||||||
event.getBlock().setType(Material.CAKE);
|
|
||||||
Particle.CLOUD.builder().location(event.getBlock().getLocation().add(0.5,0.5,0.5)).receivers(event.getPlayer()).extra(0).offset(0.5,0.5,0.5).count(5).spawn();
|
|
||||||
Particle.FLAME.builder().location(event.getBlock().getLocation().add(0.5,0.5,0.5)).receivers(event.getPlayer()).extra(0).offset(0.5,0.5,0.5).count(3).spawn();
|
|
||||||
Particle.SOUL_FIRE_FLAME.builder().location(event.getBlock().getLocation().add(0.5,0.5,0.5)).receivers(event.getPlayer()).offset(0.5,0.5,0.5).extra(0).count(2).spawn();
|
|
||||||
event.getPlayer().playSound(Sound.sound(org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH.key(), Sound.Source.BLOCK, 0.5f, 0.5f));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockedPlayers.size() == 0)
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (blockedPlayers.contains(event.getPlayer().getName()))
|
if (blockedPlayers.contains(event.getPlayer().getName()))
|
||||||
{
|
{
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (blockedBlocks.contains(block.getType()))
|
||||||
|
{
|
||||||
|
block.setType(Material.CAKE);
|
||||||
|
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5,0.5,0.5));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -1,15 +1,19 @@
|
|||||||
package dev.plex.listener.impl;
|
package dev.plex.listener.impl;
|
||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
|
import dev.plex.util.PlexUtils;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.block.Block;
|
import org.bukkit.block.Block;
|
||||||
import org.bukkit.block.data.Directional;
|
import org.bukkit.block.data.Directional;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.block.Action;
|
import org.bukkit.event.block.Action;
|
||||||
import org.bukkit.event.block.BlockDispenseEvent;
|
import org.bukkit.event.block.BlockDispenseEvent;
|
||||||
|
import org.bukkit.event.entity.CreatureSpawnEvent;
|
||||||
|
import org.bukkit.event.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
@ -18,10 +22,22 @@ import java.util.List;
|
|||||||
|
|
||||||
public class SpawnListener extends PlexListener
|
public class SpawnListener extends PlexListener
|
||||||
{
|
{
|
||||||
// TODO: CONFIGURABILITY!!!
|
|
||||||
|
|
||||||
public static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
public static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onEntitySpawn(EntitySpawnEvent event)
|
||||||
|
{
|
||||||
|
if(plugin.config.getStringList("blockedEntities").stream().anyMatch(type -> type.equalsIgnoreCase(event.getEntityType().name())))
|
||||||
|
{
|
||||||
|
event.setCancelled(true);
|
||||||
|
Location location = event.getLocation();
|
||||||
|
for (Player player : location.getNearbyEntitiesByType(Player.class, 10))
|
||||||
|
{
|
||||||
|
PlexUtils.disabledEffect(player, location);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onDispense(BlockDispenseEvent event)
|
public void onDispense(BlockDispenseEvent event)
|
||||||
{
|
{
|
||||||
|
@ -66,6 +66,14 @@ public class PlexUtils extends PlexBase
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void disabledEffect(Player player, Location location)
|
||||||
|
{
|
||||||
|
Particle.CLOUD.builder().location(location).receivers(player).extra(0).offset(0.5,0.5,0.5).count(5).spawn();
|
||||||
|
Particle.FLAME.builder().location(location).receivers(player).extra(0).offset(0.5,0.5,0.5).count(3).spawn();
|
||||||
|
Particle.SOUL_FIRE_FLAME.builder().location(location).receivers(player).offset(0.5,0.5,0.5).extra(0).count(2).spawn();
|
||||||
|
player.playSound(net.kyori.adventure.sound.Sound.sound(org.bukkit.Sound.BLOCK_FIRE_EXTINGUISH.key(), net.kyori.adventure.sound.Sound.Source.BLOCK, 0.5f, 0.5f));
|
||||||
|
}
|
||||||
|
|
||||||
public static ChatColor randomChatColor()
|
public static ChatColor randomChatColor()
|
||||||
{
|
{
|
||||||
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
|
return CHAT_COLOR_POOL.get(RANDOM.nextInt(CHAT_COLOR_POOL.size()));
|
||||||
|
@ -160,6 +160,11 @@ blockedBlocks:
|
|||||||
- "STRUCTURE_BLOCK"
|
- "STRUCTURE_BLOCK"
|
||||||
- "JIGSAW"
|
- "JIGSAW"
|
||||||
|
|
||||||
|
# What entities should be blocked?
|
||||||
|
blockedEntities:
|
||||||
|
- "WITHER"
|
||||||
|
- "ENDER_DRAGON"
|
||||||
|
|
||||||
worlds:
|
worlds:
|
||||||
flatlands:
|
flatlands:
|
||||||
name: "Flatlands"
|
name: "Flatlands"
|
||||||
|
Loading…
Reference in New Issue
Block a user