001package fr.aumgn.dac2.arena.regions; 002 003import org.bukkit.Location; 004import org.bukkit.Material; 005import org.bukkit.World; 006import org.bukkit.entity.Player; 007 008import fr.aumgn.bukkitutils.geom.Vector2D; 009import fr.aumgn.dac2.shape.FlatShape; 010import fr.aumgn.dac2.shape.Shape; 011import fr.aumgn.dac2.shape.column.Column; 012 013public class Pool extends Region { 014 015 private final FlatShape shape; 016 017 // Constructor used with reflection 018 @SuppressWarnings("unused") 019 private Pool(Shape shape) { 020 this((FlatShape) shape); 021 } 022 023 public Pool(FlatShape shape) { 024 this.shape = shape; 025 } 026 027 @Override 028 public FlatShape getShape() { 029 return shape; 030 } 031 032 public int size2D() { 033 int size = 0; 034 for (@SuppressWarnings("unused") Column _: shape) { 035 size++; 036 } 037 038 return size; 039 } 040 041 public Column getColumn(Vector2D pt) { 042 return new Column(shape, pt); 043 } 044 045 public Column getColumn(Player player) { 046 Location location = player.getLocation(); 047 return new Column(shape, new Vector2D(location.getBlockX(), 048 location.getBlockZ())); 049 } 050 051 public void reset(World world) { 052 fill(world, Material.STATIONARY_WATER); 053 } 054 055 public void fill(World world, Material material) { 056 fill(world, material, (byte) 0); 057 } 058 059 public void fill(World world, Material material, byte data) { 060 for (Column column : shape) { 061 column.set(world, material, data); 062 } 063 } 064 065 public boolean isFilled(World world) { 066 for (Column column : shape) { 067 if (column.isWater(world)) { 068 return false; 069 } 070 } 071 072 return true; 073 } 074}