Search in sources :

Example 1 with AeveonProjectUser

use of gg.projecteden.nexus.models.aeveonproject.AeveonProjectUser in project Nexus by ProjectEdenGG.

the class ClientsideBlocks method update.

public static void update(Player player, String region) {
    if (!service.hasStarted(player))
        return;
    AeveonProjectUser user = service.get(player);
    // Any Ship Color Region
    if (region.contains("shipcolor")) {
        Color shipColor = user.getShipColor();
        ColorType colorType;
        Material concreteType = Material.BLACK_CONCRETE;
        Material bedType = Material.BLACK_BED;
        if (shipColor != null) {
            colorType = ColorType.of(shipColor);
            if (colorType != null) {
                concreteType = colorType.getConcrete();
                bedType = colorType.getBed();
            }
        }
        List<Block> blocks = worldedit().getBlocks(worldguard().getRegion(getShipColorRegion(region)));
        for (Block block : blocks) {
            if (block.getType().equals(Material.WHITE_CONCRETE))
                user.getOnlinePlayer().sendBlockChange(block.getLocation(), concreteType.createBlockData());
            else if (block.getType().equals(Material.WHITE_BED)) {
                BlockData blockData = bedType.createBlockData();
                Bed newBed = (Bed) blockData;
                Bed oldBed = (Bed) block.getBlockData();
                if (oldBed.getPart().equals(Bed.Part.HEAD))
                    newBed.setPart(Bed.Part.HEAD);
                else
                    newBed.setPart(Bed.Part.FOOT);
                newBed.setFacing(oldBed.getFacing());
                blockData = newBed;
                user.getOnlinePlayer().sendBlockChange(block.getLocation(), blockData);
            }
        }
    }
    // Any Docking Ports Region
    if (region.contains("dockingport") || region.contains("vent_door")) {
        List<Block> blocks = worldedit().getBlocks(worldguard().getRegion(region));
        for (Block block : blocks) {
            if (block.getType().equals(Material.WATER))
                player.sendBlockChange(block.getLocation(), Material.AIR.createBlockData());
        }
    }
}
Also used : Bed(org.bukkit.block.data.type.Bed) Color(org.bukkit.Color) AeveonProjectUser(gg.projecteden.nexus.models.aeveonproject.AeveonProjectUser) ColorType(gg.projecteden.nexus.utils.ColorType) Block(org.bukkit.block.Block) Material(org.bukkit.Material) BlockData(org.bukkit.block.data.BlockData)

Aggregations

AeveonProjectUser (gg.projecteden.nexus.models.aeveonproject.AeveonProjectUser)1 ColorType (gg.projecteden.nexus.utils.ColorType)1 Color (org.bukkit.Color)1 Material (org.bukkit.Material)1 Block (org.bukkit.block.Block)1 BlockData (org.bukkit.block.data.BlockData)1 Bed (org.bukkit.block.data.type.Bed)1