mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-12-01 07:03:26 +01:00
parent
f12773475b
commit
d926873992
@ -1,10 +1,15 @@
|
|||||||
package world.bentobox.bentobox.managers.island;
|
package world.bentobox.bentobox.managers.island;
|
||||||
|
|
||||||
|
<<<<<<< HEAD
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
|
|
||||||
import com.google.common.collect.Table;
|
import com.google.common.collect.Table;
|
||||||
import com.google.common.collect.TreeBasedTable;
|
import com.google.common.collect.TreeBasedTable;
|
||||||
|
|
||||||
|
=======
|
||||||
|
import com.google.common.collect.Table;
|
||||||
|
import com.google.common.collect.TreeBasedTable;
|
||||||
|
>>>>>>> parent of bfff61e... Rewrote IslandGrid.Cell
|
||||||
import world.bentobox.bentobox.database.objects.Island;
|
import world.bentobox.bentobox.database.objects.Island;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -64,12 +69,12 @@ public class IslandGrid {
|
|||||||
public Island getIslandAt(int x, int z) {
|
public Island getIslandAt(int x, int z) {
|
||||||
Table.Cell<Integer, Integer, Cell> tableCell = grid.cellSet()
|
Table.Cell<Integer, Integer, Cell> tableCell = grid.cellSet()
|
||||||
.stream()
|
.stream()
|
||||||
.filter(cell -> cell.getValue().getState().equals(CellState.OCCUPIED))
|
.filter(cell -> (cell.getValue().getState().equals(CellState.OCCUPIED)))
|
||||||
.filter(cell -> cell.getValue().getIsland().inIslandSpace(x, z))
|
.filter(cell -> ((Island) cell.getValue().getObject()).inIslandSpace(x, z))
|
||||||
.findFirst().orElse(null);
|
.findFirst().orElse(null);
|
||||||
|
|
||||||
if (tableCell != null) {
|
if (tableCell != null) {
|
||||||
return tableCell.getValue().getIsland();
|
return (Island) tableCell.getValue().getObject();
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -78,24 +83,20 @@ public class IslandGrid {
|
|||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
*/
|
*/
|
||||||
private class Cell {
|
private class Cell {
|
||||||
private final CellState state;
|
private CellState state;
|
||||||
private final Island island;
|
private Object object;
|
||||||
|
|
||||||
private Cell(CellState state, Island island) {
|
|
||||||
// Make sure the hard way that none of the parameters are null
|
|
||||||
Validate.notNull(state, "Cell state cannot be null");
|
|
||||||
Validate.notNull(island, "Island cannot be null");
|
|
||||||
|
|
||||||
|
private Cell(CellState state, Object object) {
|
||||||
this.state = state;
|
this.state = state;
|
||||||
this.island = island;
|
this.object = object;
|
||||||
}
|
}
|
||||||
|
|
||||||
private CellState getState() {
|
private CellState getState() {
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Island getIsland() {
|
private Object getObject() {
|
||||||
return island;
|
return object;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -103,6 +104,7 @@ public class IslandGrid {
|
|||||||
* @author Poslovitch
|
* @author Poslovitch
|
||||||
*/
|
*/
|
||||||
private enum CellState {
|
private enum CellState {
|
||||||
|
//RESERVED,
|
||||||
OCCUPIED
|
OCCUPIED
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user