mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-22 17:17:37 +00:00
add block blocker
in the future, this will be it's own module or something
This commit is contained in:
parent
00d00eb4e5
commit
199832e020
@ -3,6 +3,10 @@ package dev.plex.listener.impl;
|
||||
import dev.plex.listener.PlexListener;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.block.BlockBreakEvent;
|
||||
@ -12,13 +16,45 @@ public class BlockListener extends PlexListener
|
||||
{
|
||||
public List<String> blockedPlayers = new ArrayList<>();
|
||||
|
||||
private static final List<Material> blockedBlocks = new ArrayList<>();
|
||||
|
||||
private static List<String> cachedBlockedBlocksConfig = null;
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onBlockPlace(BlockPlaceEvent event)
|
||||
{
|
||||
List<String> blockedBlocksConfig = plugin.config.getStringList("blockedBlocks");
|
||||
if (blockedBlocksConfig != cachedBlockedBlocksConfig)
|
||||
{
|
||||
blockedBlocks.clear();
|
||||
cachedBlockedBlocksConfig = blockedBlocksConfig;
|
||||
for (String block : blockedBlocksConfig)
|
||||
{
|
||||
try
|
||||
{
|
||||
blockedBlocks.add(Material.valueOf(block.toUpperCase()));
|
||||
}
|
||||
catch (IllegalArgumentException e)
|
||||
{
|
||||
//
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (blockedBlocks.contains(event.getBlock().getType()))
|
||||
{
|
||||
event.getBlock().setType(Material.COBWEB);
|
||||
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()))
|
||||
{
|
||||
event.setCancelled(true);
|
||||
|
@ -154,6 +154,12 @@ autowipe:
|
||||
# Should we allow drops from players?
|
||||
allowdrops: true
|
||||
|
||||
# What blocks should be blocked?
|
||||
blockedBlocks:
|
||||
- "SPAWNER"
|
||||
- "STRUCTURE_BLOCK"
|
||||
- "JIGSAW"
|
||||
|
||||
worlds:
|
||||
flatlands:
|
||||
name: "Flatlands"
|
||||
|
Loading…
Reference in New Issue
Block a user