v0.4.1
fixed city size calculation implemented /metropolis-home-list command to show all homes
This commit is contained in:
@@ -128,10 +128,12 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
|
|
||||||
private void fillOccupiedHomes() {
|
private void fillOccupiedHomes() {
|
||||||
_occupiedHomes = new ArrayList<PlayerHome>();
|
_occupiedHomes = new ArrayList<PlayerHome>();
|
||||||
|
|
||||||
for(ProtectedRegion region : regionManager.getRegions().values()){
|
for(ProtectedRegion region : regionManager.getRegions().values()){
|
||||||
if(region instanceof ProtectedCuboidRegion && region.getId().startsWith("h_")){
|
if(region instanceof ProtectedCuboidRegion && region.getId().startsWith("h_")){
|
||||||
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) region;
|
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) region;
|
||||||
PlayerHome home = new PlayerHome(cuboidRegion);
|
PlayerHome home = new PlayerHome(cuboidRegion);
|
||||||
|
|
||||||
_occupiedHomes.add(home);
|
_occupiedHomes.add(home);
|
||||||
/*
|
/*
|
||||||
if(getDatabase().find(PlayerHome.class).where().eq("regionName", home.getRegionName()).findRowCount() == 0){
|
if(getDatabase().find(PlayerHome.class).where().eq("regionName", home.getRegionName()).findRowCount() == 0){
|
||||||
@@ -141,6 +143,9 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
size = calculateCitySize();
|
||||||
|
//log.info(String.valueOf(iSize));
|
||||||
|
|
||||||
/*
|
/*
|
||||||
for(PlayerHome home : getDatabase().find(PlayerHome.class).findList()){
|
for(PlayerHome home : getDatabase().find(PlayerHome.class).findList()){
|
||||||
_occupiedHomes.add(home);
|
_occupiedHomes.add(home);
|
||||||
@@ -340,7 +345,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void expandCityRegion() {
|
private void expandCityRegion() {
|
||||||
size+=2;
|
size=calculateCitySize();
|
||||||
ProtectedRegion cityRegion = regionManager.getRegion("City");
|
ProtectedRegion cityRegion = regionManager.getRegion("City");
|
||||||
if(cityRegion instanceof ProtectedCuboidRegion){
|
if(cityRegion instanceof ProtectedCuboidRegion){
|
||||||
ProtectedCuboidRegion region = (ProtectedCuboidRegion)cityRegion;
|
ProtectedCuboidRegion region = (ProtectedCuboidRegion)cityRegion;
|
||||||
@@ -348,10 +353,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
BlockVector min;
|
BlockVector min;
|
||||||
BlockVector max;
|
BlockVector max;
|
||||||
|
|
||||||
//min = region.getMinimumPoint();
|
|
||||||
//max = region.getMaximumPoint();
|
|
||||||
//min = new BlockVector(min.getBlockX() - plotSizeX, min.getBlockY(), min.getBlockZ() - plotSizeZ);
|
|
||||||
//max = new BlockVector(max.getBlockX() + plotSizeX, max.getBlockY(), max.getBlockZ() + plotSizeZ);
|
|
||||||
min = getPlotMin(-size/2, -size/2);
|
min = getPlotMin(-size/2, -size/2);
|
||||||
max = getPlotMax(size/2, size/2);
|
max = getPlotMax(size/2, size/2);
|
||||||
|
|
||||||
@@ -360,6 +361,21 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int calculateCitySize() {
|
||||||
|
int iSize = 0;
|
||||||
|
|
||||||
|
for(PlayerHome home: _occupiedHomes){
|
||||||
|
int plotCol=Math.abs(getPlotXFromMin(home.getCuboid()));
|
||||||
|
int plotRow=Math.abs(getPlotZFromMin(home.getCuboid()));
|
||||||
|
//log.info(String.format("iSize: %d, plotRow: %d, plotCol: %d", iSize, plotCol, plotRow));
|
||||||
|
iSize = Math.max(Math.max(plotRow*2+1, plotCol*2+1), iSize);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
//log.info(String.format("iSize: %d", iSize));
|
||||||
|
return iSize;
|
||||||
|
}
|
||||||
|
|
||||||
public BlockVector getPlotMin(int row, int col){
|
public BlockVector getPlotMin(int row, int col){
|
||||||
return new BlockVector(col * plotSizeX, 0, row * plotSizeZ);
|
return new BlockVector(col * plotSizeX, 0, row * plotSizeZ);
|
||||||
}
|
}
|
||||||
@@ -368,6 +384,18 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
return new BlockVector(col * plotSizeX + plotSizeX-1, 128, row * plotSizeZ + plotSizeZ-1);
|
return new BlockVector(col * plotSizeX + plotSizeX-1, 128, row * plotSizeZ + plotSizeZ-1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private int getPlotXFromMin(Cuboid cuboid) {
|
||||||
|
int minX = cuboid.getMin().getBlockX() - roadWidth/2;
|
||||||
|
|
||||||
|
return minX/plotSizeX;
|
||||||
|
}
|
||||||
|
|
||||||
|
private int getPlotZFromMin(Cuboid cuboid) {
|
||||||
|
int minZ = cuboid.getMin().getBlockZ() - roadWidth/2;
|
||||||
|
|
||||||
|
return minZ/plotSizeZ;
|
||||||
|
}
|
||||||
|
|
||||||
private void setHomeOccupied(String owner, BlockVector minimumPoint, BlockVector maximumPoint) {
|
private void setHomeOccupied(String owner, BlockVector minimumPoint, BlockVector maximumPoint) {
|
||||||
|
|
||||||
PlayerHome home = new PlayerHome(owner, minimumPoint, maximumPoint);
|
PlayerHome home = new PlayerHome(owner, minimumPoint, maximumPoint);
|
||||||
@@ -377,15 +405,6 @@ public class MetropolisPlugin extends JavaPlugin {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public Cuboid getSpawnCuboid(){
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Cuboid getNextUnusedHome(){
|
|
||||||
// TODO Auto-generated method stub
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlayerHome generateHome(String playerName) {
|
public PlayerHome generateHome(String playerName) {
|
||||||
log.info(String.format("Generating home for %s", playerName));
|
log.info(String.format("Generating home for %s", playerName));
|
||||||
|
|||||||
@@ -103,7 +103,15 @@ public class PlayerHome implements Comparable<PlayerHome>{
|
|||||||
public String toString(){
|
public String toString(){
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
sb.append(String.format("{PlayerHome "));
|
sb.append(String.format("{PlayerHome }"));
|
||||||
|
|
||||||
|
return sb.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public String toFriendlyString() {
|
||||||
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
|
sb.append(String.format("Metropolis Home {Owner: %s min: (%d, %d, %d) max: (%d, %d, %d)}", getPlayerName(), getCuboid().getMinX(), getCuboid().getMinY(), getCuboid().getMinZ(), getCuboid().getMaxX(), getCuboid().getMaxY(), getCuboid().getMaxZ()));
|
||||||
|
|
||||||
return sb.toString();
|
return sb.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ public class MetropolisHomeListCommand implements CommandExecutor {
|
|||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||||
for(PlayerHome cityBlock : _plugin.getCityBlocks()){
|
for(PlayerHome cityBlock : _plugin.getCityBlocks()){
|
||||||
sender.sendMessage(String.format("%s", cityBlock.toString()));
|
sender.sendMessage(String.format("%s", cityBlock.toFriendlyString()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
name: Metropolis
|
name: Metropolis
|
||||||
main: com.majinnaibu.bukkit.plugins.metropolis.MetropolisPlugin
|
main: com.majinnaibu.bukkit.plugins.metropolis.MetropolisPlugin
|
||||||
depend: [WorldEdit, WorldGuard]
|
depend: [WorldEdit, WorldGuard]
|
||||||
version: 0.4
|
version: 0.4.1
|
||||||
database: false
|
database: false
|
||||||
commands:
|
commands:
|
||||||
metropolis-home-generate:
|
metropolis-home-generate:
|
||||||
|
|||||||
Reference in New Issue
Block a user