forked from SteamWar/SteamWar
Improve non final variables to be final now
This commit is contained in:
+6
-3
@@ -46,13 +46,16 @@ public abstract class DynamicRegion implements Region {
|
||||
this.id = id;
|
||||
this.minX = minX;
|
||||
this.minZ = minZ;
|
||||
init();
|
||||
}
|
||||
|
||||
/**
|
||||
* This method must be called from the super constructor in a way that everything is already initialized.
|
||||
*/
|
||||
protected final void finishInit() {
|
||||
DynamicRegionSystem.INSTANCE.add(this);
|
||||
save();
|
||||
}
|
||||
|
||||
public abstract void init();
|
||||
|
||||
public final void updateNeighbours() {
|
||||
List<Pair<PathRegion, NeighbourDirection>> list = DynamicRegionSystem.INSTANCE.getNeighbours(this)
|
||||
.filter(data -> data.getKey() instanceof PathRegion)
|
||||
|
||||
+3
-6
@@ -46,18 +46,15 @@ public class MiWG7DisplayRegion extends DynamicRegion {
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/microwargear_7/display");
|
||||
private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY);
|
||||
|
||||
private Area area;
|
||||
private Tile tile;
|
||||
private final Area area;
|
||||
private final Tile tile;
|
||||
|
||||
public MiWG7DisplayRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, 1, 1, this, SELECTOR);
|
||||
regionData = new DisplayRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-9
@@ -53,20 +53,14 @@ public class MiWG7PlotRegion extends DynamicRegion {
|
||||
private static final VariantSelector TESTBLOCK = VariantSelector.Get(new File(DIRECTORY, "testblock"));
|
||||
private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe"));
|
||||
|
||||
private AreaTile area;
|
||||
private Area northArea;
|
||||
private Area southArea;
|
||||
private final AreaTile area;
|
||||
private final Area northArea;
|
||||
private final Area southArea;
|
||||
private final RegionHistory history;
|
||||
private final RegionBackups backups;
|
||||
|
||||
public MiWG7PlotRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Tile tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION);
|
||||
// northArea = new AreaBlock();
|
||||
@@ -74,6 +68,9 @@ public class MiWG7PlotRegion extends DynamicRegion {
|
||||
northArea = Area.EMPTY; // TODO: Replace!
|
||||
southArea = Area.EMPTY; // TODO: Replace!
|
||||
regionData = new PlotRegionData(this);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -49,18 +49,15 @@ public class MWGDisplayRegion extends DynamicRegion {
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/miniwargear/display");
|
||||
private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY);
|
||||
|
||||
private Area area;
|
||||
private Tile tile;
|
||||
private final Area area;
|
||||
private final Tile tile;
|
||||
|
||||
public MWGDisplayRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, SELECTOR);
|
||||
regionData = new DisplayRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-7
@@ -53,9 +53,9 @@ public class MWGPlotRegion extends DynamicRegion {
|
||||
private static final VariantSelector TESTBLOCK = VariantSelector.Get(new File(DIRECTORY, "testblock"));
|
||||
private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe"));
|
||||
|
||||
private AreaTile area;
|
||||
private Area northArea;
|
||||
private Area southArea;
|
||||
private final AreaTile area;
|
||||
private final Area northArea;
|
||||
private final Area southArea;
|
||||
private final RegionHistory history;
|
||||
private final RegionBackups backups;
|
||||
|
||||
@@ -63,10 +63,6 @@ public class MWGPlotRegion extends DynamicRegion {
|
||||
super(id, minX, minZ);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Tile tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION);
|
||||
// northArea = new AreaBlock();
|
||||
@@ -74,6 +70,7 @@ public class MWGPlotRegion extends DynamicRegion {
|
||||
northArea = Area.EMPTY; // TODO: Replace!
|
||||
southArea = Area.EMPTY; // TODO: Replace!
|
||||
regionData = new PlotRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -49,18 +49,15 @@ public class WG45DisplayRegion extends DynamicRegion {
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/wargear_45/display");
|
||||
private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY);
|
||||
|
||||
private Area area;
|
||||
private Tile tile;
|
||||
private final Area area;
|
||||
private final Tile tile;
|
||||
|
||||
public WG45DisplayRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, SELECTOR);
|
||||
regionData = new DisplayRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-9
@@ -55,20 +55,14 @@ public class WG45PlotRegion extends DynamicRegion {
|
||||
private static final VariantSelector TESTBLOCK = VariantSelector.Get(new File(DIRECTORY, "testblock"));
|
||||
private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe"));
|
||||
|
||||
private AreaTile area;
|
||||
private Area northArea;
|
||||
private Area southArea;
|
||||
private final AreaTile area;
|
||||
private final Area northArea;
|
||||
private final Area southArea;
|
||||
private final RegionHistory history;
|
||||
private final RegionBackups backups;
|
||||
|
||||
public WG45PlotRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Tile tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION);
|
||||
// northArea = new AreaBlock();
|
||||
@@ -76,6 +70,9 @@ public class WG45PlotRegion extends DynamicRegion {
|
||||
northArea = Area.EMPTY; // TODO: Replace!
|
||||
southArea = Area.EMPTY; // TODO: Replace!
|
||||
regionData = new PlotRegionData(this);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -49,18 +49,15 @@ public class WS175DisplayRegion extends DynamicRegion {
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/warship_175/display");
|
||||
private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY);
|
||||
|
||||
private Area area;
|
||||
private Tile tile;
|
||||
private final Area area;
|
||||
private final Tile tile;
|
||||
|
||||
public WS175DisplayRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, SELECTOR);
|
||||
regionData = new DisplayRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-9
@@ -54,20 +54,14 @@ public class WS175PlotRegion extends DynamicRegion {
|
||||
private static final VariantSelector TESTBLOCK = VariantSelector.Get(new File(DIRECTORY, "testblock"));
|
||||
private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe"));
|
||||
|
||||
private AreaTile area;
|
||||
private Area northArea;
|
||||
private Area southArea;
|
||||
private final AreaTile area;
|
||||
private final Area northArea;
|
||||
private final Area southArea;
|
||||
private final RegionHistory history;
|
||||
private final RegionBackups backups;
|
||||
|
||||
public WS175PlotRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Tile tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION);
|
||||
// northArea = new AreaBlock();
|
||||
@@ -75,6 +69,9 @@ public class WS175PlotRegion extends DynamicRegion {
|
||||
northArea = Area.EMPTY; // TODO: Replace!
|
||||
southArea = Area.EMPTY; // TODO: Replace!
|
||||
regionData = new PlotRegionData(this);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+3
-6
@@ -49,18 +49,15 @@ public class WS230DisplayRegion extends DynamicRegion {
|
||||
private static final File DIRECTORY = new File(Bukkit.getWorlds().get(0).getWorldFolder(), "sections/warship_230/display");
|
||||
private static final VariantSelector SELECTOR = VariantSelector.Get(DIRECTORY);
|
||||
|
||||
private Area area;
|
||||
private Tile tile;
|
||||
private final Area area;
|
||||
private final Tile tile;
|
||||
|
||||
public WS230DisplayRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, SELECTOR);
|
||||
regionData = new DisplayRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+6
-9
@@ -54,20 +54,14 @@ public class WS230PlotRegion extends DynamicRegion {
|
||||
private static final VariantSelector TESTBLOCK = VariantSelector.Get(new File(DIRECTORY, "testblock"));
|
||||
private static final VariantSelector WIREFRAME = VariantSelector.Get(new File(DIRECTORY, "wireframe"));
|
||||
|
||||
private AreaTile area;
|
||||
private Area northArea;
|
||||
private Area southArea;
|
||||
private final AreaTile area;
|
||||
private final Area northArea;
|
||||
private final Area southArea;
|
||||
private final RegionHistory history;
|
||||
private final RegionBackups backups;
|
||||
|
||||
public WS230PlotRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
Tile tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new AreaTile(tile, TILE_X, TILE_Z, this, REGION);
|
||||
// northArea = new AreaBlock();
|
||||
@@ -75,6 +69,9 @@ public class WS230PlotRegion extends DynamicRegion {
|
||||
northArea = Area.EMPTY; // TODO: Replace!
|
||||
southArea = Area.EMPTY; // TODO: Replace!
|
||||
regionData = new PlotRegionData(this);
|
||||
history = new RegionHistory.Impl(10);
|
||||
backups = new PlotRegionBackups(this, PlotRegionData::new);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+4
-7
@@ -37,19 +37,16 @@ import java.util.UUID;
|
||||
)
|
||||
public class PathRegion extends DynamicRegion {
|
||||
|
||||
private PathArea area;
|
||||
private Tile tile;
|
||||
private final PathArea area;
|
||||
private final Tile tile;
|
||||
|
||||
public PathRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
calculateGardenState();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
tile = Tile.fromXZ(minX, minZ).orElseThrow();
|
||||
area = new PathArea(tile, this);
|
||||
regionData = new PathRegionData(this);
|
||||
finishInit();
|
||||
calculateGardenState();
|
||||
}
|
||||
|
||||
public void update(DynamicRegion updateFrom, NeighbourDirection direction) {
|
||||
|
||||
+2
-5
@@ -46,16 +46,13 @@ public class DryRegion extends DynamicRegion {
|
||||
|
||||
private static final VariantSelector DRY = VariantSelector.Get(new File(SPECIAL_PATH_DIR, "dry"));
|
||||
|
||||
private SpecialArea area;
|
||||
private final SpecialArea area;
|
||||
|
||||
public DryRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
area = new SpecialArea(Tile.fromXZ(minX, minZ).orElseThrow(), this, DRY);
|
||||
regionData = new SpecialRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
+2
-5
@@ -45,16 +45,13 @@ public class WetRegion extends DynamicRegion {
|
||||
|
||||
private static final VariantSelector WET = VariantSelector.Get(new File(SPECIAL_PATH_DIR, "wet"));
|
||||
|
||||
private SpecialArea area;
|
||||
private final SpecialArea area;
|
||||
|
||||
public WetRegion(UUID id, int minX, int minZ) {
|
||||
super(id, minX, minZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() {
|
||||
area = new SpecialArea(Tile.fromXZ(minX, minZ).orElseThrow(), this, WET);
|
||||
regionData = new WetRegionData(this);
|
||||
finishInit();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user