@Override public void invert() { List<Point> inverted = new ArrayList<>(); this.iterate( point -> { for (Point target : this.blocked) { if (target.isSimilar(point)) { inverted.add(point); break; } } }); this.blocked = inverted; this.clearElements(); this.createButtons(); }
private void createButtons() { this.iterate( (point) -> { for (Point target : blocked) { if (target.isSimilar(point)) { ElementItem element = this.elementCreator().newItem(); element.setPoint(point); element.setIcon(new Icon(Material.STAINED_GLASS_PANE, 14)); return; } } ElementButton element = this.elementCreator().newButton(); element.setPoint(point); element.setIcon(new Icon(Material.STAINED_GLASS_PANE, 13)); element .getEventManager() .registerListener(ButtonPressEvent.class, new ActionHandler()) .addAfter(); }); }