mirror of
https://github.com/plexusorg/Plex.git
synced 2024-12-23 09:37:37 +00:00
add command sign blocking
todo: move all these blockings to blackout
This commit is contained in:
parent
3666379645
commit
d10f738304
@ -2,19 +2,24 @@ package dev.plex.listener.impl;
|
|||||||
|
|
||||||
import dev.plex.listener.PlexListener;
|
import dev.plex.listener.PlexListener;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import dev.plex.util.PlexUtils;
|
import dev.plex.util.PlexUtils;
|
||||||
import net.kyori.adventure.sound.Sound;
|
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.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.block.Block;
|
||||||
|
import org.bukkit.block.Sign;
|
||||||
import org.bukkit.entity.Player;
|
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;
|
||||||
import org.bukkit.event.block.BlockPlaceEvent;
|
import org.bukkit.event.block.BlockPlaceEvent;
|
||||||
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
|
|
||||||
public class BlockListener extends PlexListener
|
public class BlockListener extends PlexListener
|
||||||
{
|
{
|
||||||
@ -24,6 +29,8 @@ public class BlockListener extends PlexListener
|
|||||||
|
|
||||||
private static List<String> cachedBlockedBlocksConfig = null;
|
private static List<String> cachedBlockedBlocksConfig = null;
|
||||||
|
|
||||||
|
private static final List<Material> SIGNS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SIGN")).toList();
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
public void onBlockPlace(BlockPlaceEvent event)
|
public void onBlockPlace(BlockPlaceEvent event)
|
||||||
{
|
{
|
||||||
@ -57,6 +64,26 @@ public class BlockListener extends PlexListener
|
|||||||
block.setType(Material.CAKE);
|
block.setType(Material.CAKE);
|
||||||
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5,0.5,0.5));
|
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5,0.5,0.5));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(SIGNS.contains(block.getType()))
|
||||||
|
{
|
||||||
|
Sign sign = (Sign) block.getState(false);
|
||||||
|
boolean anythingChanged = false;
|
||||||
|
for (int i = 0; i < sign.lines().size(); i++)
|
||||||
|
{
|
||||||
|
Component line = sign.line(i);
|
||||||
|
if(line.clickEvent() != null)
|
||||||
|
{
|
||||||
|
anythingChanged = true;
|
||||||
|
sign.line(i, line.clickEvent(null));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (anythingChanged)
|
||||||
|
{
|
||||||
|
sign.update(true);
|
||||||
|
PlexUtils.disabledEffect(event.getPlayer(), block.getLocation().add(0.5, 0.5, 0.5));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler(priority = EventPriority.LOW)
|
@EventHandler(priority = EventPriority.LOW)
|
||||||
|
@ -12,7 +12,6 @@ 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.entity.EntitySpawnEvent;
|
||||||
import org.bukkit.event.player.PlayerInteractEvent;
|
import org.bukkit.event.player.PlayerInteractEvent;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
@ -23,7 +22,7 @@ import java.util.List;
|
|||||||
|
|
||||||
public class SpawnListener extends PlexListener
|
public class SpawnListener extends PlexListener
|
||||||
{
|
{
|
||||||
public static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
private static final List<Material> SPAWN_EGGS = Arrays.stream(Material.values()).filter((mat) -> mat.name().endsWith("_SPAWN_EGG")).toList();
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onEntitySpawn(EntitySpawnEvent event)
|
public void onEntitySpawn(EntitySpawnEvent event)
|
||||||
|
Loading…
Reference in New Issue
Block a user