This commit is contained in:
2012-02-14 10:55:37 -08:00
parent edf3c8556e
commit a9b5fa47f2
8 changed files with 252 additions and 64 deletions

View File

@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?> <?xml version="1.0" encoding="WINDOWS-1252" standalone="no"?>
<jardesc> <jardesc>
<jar path="C:/Users/Tom/Desktop/MC Servers/plugins/Metropolis-0.4.jar"/> <jar path="C:/Users/Tom/Desktop/MC Servers/City/plugins/Metropolis.jar"/>
<options buildIfNeeded="true" compress="true" descriptionLocation="/Metropolis/Plugin.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/> <options buildIfNeeded="true" compress="true" descriptionLocation="/Metropolis/Plugin.jardesc" exportErrors="true" exportWarnings="true" includeDirectoryEntries="false" overwrite="false" saveDescription="true" storeRefactorings="false" useSourceFolders="false"/>
<storedRefactorings deprecationInfo="true" structuralOnly="false"/> <storedRefactorings deprecationInfo="true" structuralOnly="false"/>
<selectedProjects/> <selectedProjects/>

View File

@@ -1,5 +1,7 @@
package com.majinnaibu.bukkit.plugins.metropolis; package com.majinnaibu.bukkit.plugins.metropolis;
import java.util.logging.Logger;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
@@ -44,6 +46,15 @@ public class Cuboid implements Comparable<Cuboid> {
this.maxZ = max.getBlockZ(); this.maxZ = max.getBlockZ();
} }
public Cuboid() {
this.minX = 0;
this.minY = 0;
this.minZ = 0;
this.maxX = 0;
this.maxY = 0;
this.maxZ = 0;
}
public BlockVector getMin(){ public BlockVector getMin(){
return new BlockVector(minX, minY, minZ); return new BlockVector(minX, minY, minZ);
} }
@@ -74,18 +85,33 @@ public class Cuboid implements Comparable<Cuboid> {
} }
} }
public static int compareBlockVectors(BlockVector min, BlockVector otherMin){ public static int compareBlockVectors(BlockVector v1, BlockVector v2){
if(min.getBlockX() < otherMin.getBlockX()){ Logger log = Logger.getLogger("Minecraft");
return -1;
}else if(min.getBlockX() > otherMin.getBlockX()){ if(v1 == null){
if(v2 == null){
log.info("in Cuboid.compareBlockVectors v1 and v2 are null");
return 0;
}else{
log.info("in Cubiod.compareBlockVectors v1 is null");
return -1;
}
}else if(v2 == null){
log.info("in Cubiod.compareBlockVectors v2 is null");
return 1; return 1;
}else if(min.getBlockZ() < otherMin.getBlockZ()){ }
log.info(String.format("v1.x: %d, v1.y: %d, v1.z: %d, v2.x: %d, v2.y: %d, v2.z: %d", v1.getBlockX(), v1.getBlockY(), v1.getBlockZ(), v2.getBlockX(), v2.getBlockY(), v2.getBlockZ()));
if(v1.getBlockX() < v2.getBlockX()){
return -1; return -1;
}else if(min.getBlockZ() > otherMin.getBlockZ()){ }else if(v1.getBlockX() > v2.getBlockX()){
return 1; return 1;
}else if(min.getBlockY() < otherMin.getBlockY()){ }else if(v1.getBlockZ() < v2.getBlockZ()){
return -1; return -1;
}else if(min.getBlockY() > otherMin.getBlockY()){ }else if(v1.getBlockZ() > v2.getBlockZ()){
return 1;
}else if(v1.getBlockY() < v2.getBlockY()){
return -1;
}else if(v1.getBlockY() > v2.getBlockY()){
return 1; return 1;
}else{ }else{
return 0; return 0;
@@ -103,4 +129,21 @@ public class Cuboid implements Comparable<Cuboid> {
public Cuboid inset(int x, int y, int z){ public Cuboid inset(int x, int y, int z){
return new Cuboid(this.minX + x, this.minY, this.minZ + z, this.maxX - x, this.maxY, this.maxZ - z); return new Cuboid(this.minX + x, this.minY, this.minZ + z, this.maxX - x, this.maxY, this.maxZ - z);
} }
public int getVolume() {
return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
}
public int getMinX(){return minX;}
public void setMinX(int minX){this.minX = minX;}
public int getMinY(){return minY;}
public void setMinY(int minY){this.minY = minY;}
public int getMinZ(){return minZ;}
public void setMinZ(int minZ){this.minZ = minZ;}
public int getMaxX(){return maxX;}
public void setMaxX(int maxX){this.maxX = maxX;}
public int getMaxY(){return maxY;}
public void setMaxY(int maxY){this.maxY = maxY;}
public int getMaxZ(){return maxZ;}
public void setMaxZ(int maxZ){this.maxZ = maxZ;}
} }

View File

@@ -14,16 +14,19 @@ public class LoginListener implements Listener {
plugin.getServer().getPluginManager().registerEvents(this, plugin); plugin.getServer().getPluginManager().registerEvents(this, plugin);
} }
@EventHandler(priority=EventPriority.MONITOR) @EventHandler(priority=EventPriority.MONITOR)
public void onPlayerLogin(PlayerLoginEvent event){ public void onPlayerLogin(PlayerLoginEvent event){
MetropolisPlugin.log.info("Metropolis: player login");
Player player = event.getPlayer(); Player player = event.getPlayer();
if(player == null){ if(player == null){
return; return;
} }
_plugin.getPlayerHome(player); PlayerHome home = _plugin.getPlayerHome(player);
if(home == null || home.getCuboid() == null || home.getCuboid().getVolume() == 0){
MetropolisPlugin.log.info(String.format("Metropolis: Unable to get or create home for player %s", player.getName()));
}
Cuboid cuboid = home.getCuboid();
player.sendMessage(String.format("Metropolis: Welcome %s your home is between (%d, %d, %d) and (%d, %d, %d)", player.getName(), cuboid.getMinX(), cuboid.getMinY(), cuboid.getMinZ(), cuboid.getMaxX(), cuboid.getMaxY(), cuboid.getMaxZ()));
} }
} }

View File

@@ -1,11 +1,14 @@
package com.majinnaibu.bukkit.plugins.metropolis; package com.majinnaibu.bukkit.plugins.metropolis;
import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.persistence.PersistenceException;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.configuration.Configuration; import org.bukkit.configuration.Configuration;
@@ -15,8 +18,8 @@ import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import com.majinnaibu.bukkit.plugins.metropolis.commands.MetropolisHomeGenerateCommand; import com.majinnaibu.bukkit.plugins.metropolis.commands.MetropolisHomeGenerateCommand;
import com.majinnaibu.bukkit.plugins.metropolis.commands.MetropolisHomeListCommand;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
import com.sk89q.worldguard.bukkit.WorldGuardPlugin; import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
import com.sk89q.worldguard.domains.DefaultDomain; import com.sk89q.worldguard.domains.DefaultDomain;
import com.sk89q.worldguard.protection.managers.RegionManager; import com.sk89q.worldguard.protection.managers.RegionManager;
@@ -28,7 +31,7 @@ public class MetropolisPlugin extends JavaPlugin {
public PluginDescriptionFile pdf = null; public PluginDescriptionFile pdf = null;
public WorldGuardPlugin worldGuard = null; public WorldGuardPlugin worldGuard = null;
public WorldEditPlugin worldEdit = null; //public WorldEditPlugin worldEdit = null;
public World world = null; public World world = null;
public RegionManager regionManager = null; public RegionManager regionManager = null;
@@ -36,7 +39,7 @@ public class MetropolisPlugin extends JavaPlugin {
private LoginListener _loginListener = null; private LoginListener _loginListener = null;
int size = 0; int size = 1;
int plotSizeX = 24; int plotSizeX = 24;
int plotSizeZ = 24; int plotSizeZ = 24;
@@ -66,9 +69,9 @@ public class MetropolisPlugin extends JavaPlugin {
roadLevel = config.getInt("road.level"); roadLevel = config.getInt("road.level");
roadMaterial = config.getInt("road.material"); roadMaterial = config.getInt("road.material");
worldName =config.getString("worldname"); worldName =config.getString("worldname");
saveConfig(); saveConfig();
log.info(String.format("Metropolis: world name is %s", worldName));
Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard"); Plugin plugin = getServer().getPluginManager().getPlugin("WorldGuard");
if(plugin == null || !(plugin instanceof WorldGuardPlugin)){ if(plugin == null || !(plugin instanceof WorldGuardPlugin)){
@@ -77,20 +80,21 @@ public class MetropolisPlugin extends JavaPlugin {
worldGuard = (WorldGuardPlugin) plugin; worldGuard = (WorldGuardPlugin) plugin;
/*
plugin = getServer().getPluginManager().getPlugin("WorldEdit"); plugin = getServer().getPluginManager().getPlugin("WorldEdit");
if(plugin == null || !(plugin instanceof WorldEditPlugin)){ if(plugin == null || !(plugin instanceof WorldEditPlugin)){
throw new RuntimeException("WorldEdit must be loaded first"); throw new RuntimeException("WorldEdit must be loaded first");
} }
worldEdit = (WorldEditPlugin) plugin; worldEdit = (WorldEditPlugin) plugin;
*/
world = getServer().getWorld(worldName); world = getServer().getWorld(worldName);
// for(World world: getServer().getWorlds()){
// log.info(String.format("name: %s", world.getName()));
// }
regionManager = worldGuard.getRegionManager(world); regionManager = worldGuard.getRegionManager(world);
_occupiedHomes = new ArrayList<PlayerHome>();
fillOccupiedHomes();
ProtectedRegion cityRegion = regionManager.getRegion("City"); ProtectedRegion cityRegion = regionManager.getRegion("City");
if(cityRegion == null){ if(cityRegion == null){
cityRegion = new ProtectedCuboidRegion("City", getPlotMin(0, 0), this.getPlotMax(0, 0)); cityRegion = new ProtectedCuboidRegion("City", getPlotMin(0, 0), this.getPlotMax(0, 0));
@@ -101,34 +105,19 @@ public class MetropolisPlugin extends JavaPlugin {
//setupDatabase(); //setupDatabase();
_occupiedHomes = new ArrayList<PlayerHome>();
fillOccupiedHomes();
if(_loginListener == null){ if(_loginListener == null){
_loginListener = new LoginListener(this); _loginListener = new LoginListener(this);
} }
Map<String, ProtectedRegion> regions = regionManager.getRegions();
for(ProtectedRegion region: regions.values()){
if(region.getId().startsWith("h_")){
setHomeOccupied(region.getId().substring(2), region.getMinimumPoint(), region.getMaximumPoint());
}
}
log.info(String.format("%s enabled", pdf.getFullName())); log.info(String.format("%s enabled", pdf.getFullName()));
getCommand("metropolis-home-generate").setExecutor(new MetropolisHomeGenerateCommand(this)); getCommand("metropolis-home-generate").setExecutor(new MetropolisHomeGenerateCommand(this));
getCommand("metropolis-home-list").setExecutor(new MetropolisHomeListCommand(this));
/*
Set<String>strings = config.getKeys(true);
log.info(String.valueOf(strings.size()));
for(String str : strings){
log.info(str);
}
*/
} }
/*
private void setupDatabase() { private void setupDatabase() {
try{ try{
getDatabase().find(PlayerHome.class).findRowCount(); getDatabase().find(PlayerHome.class).findRowCount();
@@ -137,17 +126,36 @@ public class MetropolisPlugin extends JavaPlugin {
installDDL(); installDDL();
} }
} }
/**/
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;
_occupiedHomes.add(new PlayerHome(cuboidRegion)); PlayerHome home = new PlayerHome(cuboidRegion);
_occupiedHomes.add(home);
/*
if(getDatabase().find(PlayerHome.class).where().eq("regionName", home.getRegionName()).findRowCount() == 0){
getDatabase().insert(home);
}
/**/
} }
} }
/*
for(PlayerHome home : getDatabase().find(PlayerHome.class).findList()){
_occupiedHomes.add(home);
}
/**/
Map<String, ProtectedRegion> map = regionManager.getRegions();
for(String regionId : map.keySet()){
//log.info(String.format("key: %s, id: %s", regionId, map.get(regionId).getId()));
}
log.info(String.format("Metropolis: %d occupied homes", _occupiedHomes.size()));
Collections.sort(_occupiedHomes); Collections.sort(_occupiedHomes);
} }
@@ -156,25 +164,26 @@ public class MetropolisPlugin extends JavaPlugin {
String regionName = "h_" + player.getName(); String regionName = "h_" + player.getName();
ProtectedRegion homeRegion = regionManager.getRegion(regionName); ProtectedRegion homeRegion = regionManager.getRegion(regionName);
log.info(homeRegion == null? "null" : homeRegion.toString()); log.info(homeRegion == null? "null" : homeRegion.toString());
if(homeRegion == null){ if(homeRegion == null){
log.info(String.format("Creating home for player %s", player.getName()));
home = generateHome(player.getName()); home = generateHome(player.getName());
} }
return home; return home;
} }
/*
@Override @Override
public List<Class<?>> getDatabaseClasses(){ public List<Class<?>> getDatabaseClasses(){
List<Class<?>> list = new ArrayList<Class<?>>(); List<Class<?>> list = new ArrayList<Class<?>>();
list.add(PlayerHome.class); list.add(PlayerHome.class);
list.add(Cuboid.class);
return list; return list;
} }
/**/
private void createRoads(Cuboid plotCuboid) { private void createRoads(Cuboid plotCuboid) {
if(roadWidth>0){ if(roadWidth>0){
@@ -234,28 +243,84 @@ public class MetropolisPlugin extends JavaPlugin {
} }
private Cuboid findNextUnownedHomeRegion() { private Cuboid findNextUnownedHomeRegion() {
if(size <= 2){size=3;}
int homeIndex = 0;
int rowMin = -size/2;
int rowMax = size/2;
int colMin = -size/2;
int colMax = size/2;
log.info(String.format("size: %d, rowMin: %d, rowMax: %d, colMin: %d, colMax: %d", size, rowMin, rowMax, colMin, colMax));
int row = rowMin;
int col = colMin;
if(_occupiedHomes.size() == 0){return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));}
PlayerHome home = _occupiedHomes.get(homeIndex);
for(col=colMin; col <= colMax; col++){
for(row=rowMin; row<= rowMax; row++){
if(row != 0 || col != 0){
log.info(String.format("row: %d, col: %d", row, col));
if(home == null){
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
}
else if(Cuboid.isBlockLessThan(getPlotMin(row, col), home.getPlotMin(roadWidth))){
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
}else{
homeIndex++;
if(homeIndex < _occupiedHomes.size()){
home = _occupiedHomes.get(homeIndex);
}else{
home = null;
}
}
}
}
}
expandCityRegion();
return new Cuboid(getPlotMin(-size/2, -size/2), getPlotMax(-size/2, -size/2));
/*
log.info(String.valueOf(size));
int homeIndex = 0; int homeIndex = 0;
if(_occupiedHomes.size() == 0){ if(_occupiedHomes.size() == 0){
log.info("_occupiedHomes.size is 0");
if(size < 1){ if(size < 1){
size=1; size=1;
} }
expandCityRegion(); expandCityRegion();
log.info(String.format("row: %d, col: %d", -1, -1));
return new Cuboid(getPlotMin(-1, -1), getPlotMax(-1, -1)); return new Cuboid(getPlotMin(-1, -1), getPlotMax(-1, -1));
} }
PlayerHome home = _occupiedHomes.get(homeIndex); PlayerHome home = _occupiedHomes.get(homeIndex);
int row=0;
for(int row = -size/2; row<=size/2; row++){ int col=0;
for(int col = -size/2; col <= size/2; col++){ log.info(String.format("row-min: %d, row-max: %d, col-min: %d, col-max: %d", -size/2, size/2, -size/2, size/2));
for(row = -size/2; row<=size/2; row++){
for(col = -size/2; col <= size/2; col++){
log.info(String.format(
"checking row: %d, col: %d, homeIndex: %d, home is %s",
row,
col,
homeIndex,
home==null?"null":"not null"));
if(home == null){ if(home == null){
log.info("home is null");
expandCityRegion(); expandCityRegion();
log.info(String.format("row: %d, col: %d", row, col));
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col)); return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
}else if(Cuboid.isBlockLessThan(getPlotMin(row, col), home.getCuboid().getMin())){ }else if(Cuboid.isBlockLessThan(getPlotMin(row, col), home.getCuboid().getMin())){
log.info("Cuboid.isBlockLessThan(getPlotMin(row, col), home.getCuboid().getMin())");
log.info(String.format("row: %d, col: %d", row, col));
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col)); return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
}else{ }else{
log.info("else");
homeIndex++; homeIndex++;
if(homeIndex < _occupiedHomes.size()){ if(homeIndex < _occupiedHomes.size()){
home = _occupiedHomes.get(homeIndex); home = _occupiedHomes.get(homeIndex);
@@ -266,19 +331,30 @@ public class MetropolisPlugin extends JavaPlugin {
} }
} }
size++; size+=2;
return new Cuboid(getPlotMin(-size/2, -size/2), getPlotMax(-size/2, -size/2));
log.info(String.format("row: %d, col: %d", row, col));
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
//log.info(String.format("row: %d, col: %d", -size/2, -size/2));
//return new Cuboid(getPlotMin(-size/2, -size/2), getPlotMax(-size/2, -size/2));
/**/
} }
private void expandCityRegion() { private void expandCityRegion() {
size+=2;
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;
BlockVector min = region.getMinimumPoint();
BlockVector max = region.getMaximumPoint();
min = new BlockVector(min.getBlockX() - plotSizeX, min.getBlockY(), min.getBlockZ() - plotSizeZ); BlockVector min;
max = new BlockVector(max.getBlockX() + plotSizeX, max.getBlockY(), max.getBlockZ() + plotSizeZ); 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);
max = getPlotMax(size/2, size/2);
region.setMinimumPoint(min); region.setMinimumPoint(min);
region.setMaximumPoint(max); region.setMaximumPoint(max);
@@ -312,23 +388,38 @@ public class MetropolisPlugin extends JavaPlugin {
return null; return null;
} }
public PlayerHome generateHome(String string) { public PlayerHome generateHome(String playerName) {
log.info(String.format("Generating home for %s", playerName));
Cuboid plotCuboid = null; Cuboid plotCuboid = null;
Cuboid homeCuboid = null; Cuboid homeCuboid = null;
ProtectedRegion homeRegion = null; ProtectedRegion homeRegion = null;
String regionName = "h_" + string; String regionName = "h_" + playerName;
plotCuboid = findNextUnownedHomeRegion(); plotCuboid = findNextUnownedHomeRegion();
homeCuboid = plotCuboid.inset(roadWidth/2, roadWidth/2); homeCuboid = plotCuboid.inset(roadWidth/2, roadWidth/2);
homeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax()); homeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
DefaultDomain d = homeRegion.getOwners(); DefaultDomain d = homeRegion.getOwners();
d.addPlayer(string); d.addPlayer(playerName);
homeRegion.setPriority(1); homeRegion.setPriority(1);
regionManager.addRegion(homeRegion); regionManager.addRegion(homeRegion);
try {
regionManager.save();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
setHomeOccupied(playerName, homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint());
createRoads(plotCuboid); createRoads(plotCuboid);
log.info(String.format("Done generating home for %s", playerName));
return new PlayerHome(homeRegion); return new PlayerHome(homeRegion);
} }
public List<PlayerHome> getCityBlocks() {
return Collections.unmodifiableList(_occupiedHomes);
}
} }

View File

@@ -22,13 +22,19 @@ public class PlayerHome implements Comparable<PlayerHome>{
@NotNull @NotNull
private Cuboid cuboid; private Cuboid cuboid;
@NotNull
private String regionName;
public PlayerHome(String owner, BlockVector min, BlockVector max) { public PlayerHome(String owner, BlockVector min, BlockVector max) {
cuboid = new Cuboid(min, max); this.cuboid = new Cuboid(min, max);
playerName = owner; this.playerName = owner;
this.regionName = "h_" + owner;
} }
public PlayerHome() { public PlayerHome() {
// TODO Auto-generated constructor stub this.cuboid = new Cuboid();
this.playerName = "";
this.regionName = "";
} }
public PlayerHome(ProtectedRegion homeRegion){ public PlayerHome(ProtectedRegion homeRegion){
@@ -62,6 +68,9 @@ public class PlayerHome implements Comparable<PlayerHome>{
public Cuboid getCuboid(){return this.cuboid;} public Cuboid getCuboid(){return this.cuboid;}
public void setCuboid(Cuboid cuboid){this.cuboid = cuboid;} public void setCuboid(Cuboid cuboid){this.cuboid = cuboid;}
public String getRegionName(){return this.regionName;}
public void setRegionName(String regionName){this.regionName = regionName;}
@Override @Override
public boolean equals(Object other) { public boolean equals(Object other) {
if(!(other instanceof PlayerHome)){ if(!(other instanceof PlayerHome)){
@@ -85,4 +94,17 @@ public class PlayerHome implements Comparable<PlayerHome>{
public int compareTo(PlayerHome another) { public int compareTo(PlayerHome another) {
return cuboid.compareTo(another.cuboid); return cuboid.compareTo(another.cuboid);
} }
public BlockVector getPlotMin(int roadWidth) {
return new BlockVector(this.cuboid.minX - roadWidth/2, this.cuboid.minY, this.cuboid.minZ - roadWidth/2);
}
@Override
public String toString(){
StringBuilder sb = new StringBuilder();
sb.append(String.format("{PlayerHome "));
return sb.toString();
}
} }

View File

@@ -23,7 +23,7 @@ public class MetropolisHomeGenerateCommand implements CommandExecutor {
} }
if(player != null){ if(player != null){
if(player.hasPermission("metropolis.generate")){ if(!player.hasPermission("metropolis.generate")){
return false; return false;
} }
} }

View File

@@ -0,0 +1,25 @@
package com.majinnaibu.bukkit.plugins.metropolis.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.majinnaibu.bukkit.plugins.metropolis.MetropolisPlugin;
import com.majinnaibu.bukkit.plugins.metropolis.PlayerHome;
public class MetropolisHomeListCommand implements CommandExecutor {
private MetropolisPlugin _plugin;
public MetropolisHomeListCommand(MetropolisPlugin plugin){
_plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
for(PlayerHome cityBlock : _plugin.getCityBlocks()){
sender.sendMessage(String.format("%s", cityBlock.toString()));
}
return true;
}
}

View File

@@ -1,10 +1,14 @@
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.3 version: 0.4
database: false database: false
commands: commands:
metropolis-home-generate: metropolis-home-generate:
description: This command generates a home for a user as if they'd just logged in. description: This command generates a home for a user as if they'd just logged in.
permission: metropolis.generate permission: metropolis.generate
usage: /metropolis-home-generate <playername> usage: /metropolis-home-generate <playername>
metropolis-home-list:
description: This lists the regions managed by Metropolis
permission: metropolis.list
usage: /metropolis-home-list