Implemented MetropolisHomeGoCommand

This commit is contained in:
2012-02-28 14:23:58 -08:00
parent 8d20bf9d98
commit 26d7188dbb
11 changed files with 495 additions and 268 deletions

View File

@@ -0,0 +1,5 @@
#Tue Feb 28 07:18:32 PST 2012
eclipse.preferences.version=1
encoding//src/main/java=UTF-8
encoding//src/main/resources=UTF-8
encoding/<project>=UTF-8

View File

@@ -1,207 +1,221 @@
package com.majinnaibu.bukkitplugins.metropolis; package com.majinnaibu.bukkitplugins.metropolis;
import java.util.logging.Logger; import java.util.logging.Logger;
import org.bukkit.Location;
import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldedit.bukkit.selections.Selection;
import com.sk89q.worldedit.BlockVector;
public class Cuboid implements Comparable<Cuboid> { import com.sk89q.worldedit.bukkit.selections.Selection;
private int id;
public class Cuboid implements Comparable<Cuboid> {
public int minX; private int id;
public int minY;
public int minZ; public int minX;
public int minY;
public int maxX; public int minZ;
public int maxY;
public int maxZ; public int maxX;
public int maxY;
public int getId(){ public int maxZ;
return id;
} public int getId(){
return id;
public void setId(int id){ }
this.id = id;
} public void setId(int id){
this.id = id;
public Cuboid(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){ }
this.minX = minX;
this.minY = minY; public Cuboid(int minX, int minY, int minZ, int maxX, int maxY, int maxZ){
this.minZ = minZ; this.minX = minX;
this.maxX = maxX; this.minY = minY;
this.maxY = maxY; this.minZ = minZ;
this.maxZ = maxZ; this.maxX = maxX;
} this.maxY = maxY;
this.maxZ = maxZ;
public Cuboid(BlockVector min, BlockVector max) { }
this.minX = min.getBlockX();
this.minY = min.getBlockY(); public Cuboid(BlockVector min, BlockVector max) {
this.minZ = min.getBlockZ(); this.minX = min.getBlockX();
this.maxX = max.getBlockX(); this.minY = min.getBlockY();
this.maxY = max.getBlockY(); this.minZ = min.getBlockZ();
this.maxZ = max.getBlockZ(); this.maxX = max.getBlockX();
} this.maxY = max.getBlockY();
this.maxZ = max.getBlockZ();
public Cuboid() { }
this.minX = 0;
this.minY = 0; public Cuboid() {
this.minZ = 0; this.minX = 0;
this.maxX = 0; this.minY = 0;
this.maxY = 0; this.minZ = 0;
this.maxZ = 0; this.maxX = 0;
} this.maxY = 0;
this.maxZ = 0;
public Cuboid(Selection selection) { }
this.minX = selection.getMinimumPoint().getBlockX();
this.minY = selection.getMinimumPoint().getBlockY(); public Cuboid(Selection selection) {
this.minZ = selection.getMinimumPoint().getBlockZ(); this.minX = selection.getMinimumPoint().getBlockX();
this.maxX = selection.getMaximumPoint().getBlockX(); this.minY = selection.getMinimumPoint().getBlockY();
this.maxY = selection.getMaximumPoint().getBlockY(); this.minZ = selection.getMinimumPoint().getBlockZ();
this.maxZ = selection.getMaximumPoint().getBlockZ(); this.maxX = selection.getMaximumPoint().getBlockX();
} this.maxY = selection.getMaximumPoint().getBlockY();
this.maxZ = selection.getMaximumPoint().getBlockZ();
public BlockVector getMin(){ }
return new BlockVector(minX, minY, minZ);
} public BlockVector getMin(){
return new BlockVector(minX, minY, minZ);
public BlockVector getMax(){ }
return new BlockVector(maxX, maxY, maxZ);
} public BlockVector getMax(){
return new BlockVector(maxX, maxY, maxZ);
@Override }
public int compareTo(Cuboid o) {
BlockVector min = getMin(); @Override
BlockVector otherMin = o.getMin(); public int compareTo(Cuboid o) {
BlockVector min = getMin();
if(min.getBlockX() < otherMin.getBlockX()){ BlockVector otherMin = o.getMin();
return -1;
}else if(min.getBlockX() > otherMin.getBlockX()){ if(min.getBlockX() < otherMin.getBlockX()){
return 1; return -1;
}else if(min.getBlockZ() < otherMin.getBlockZ()){ }else if(min.getBlockX() > otherMin.getBlockX()){
return -1; return 1;
}else if(min.getBlockZ() > otherMin.getBlockZ()){ }else if(min.getBlockZ() < otherMin.getBlockZ()){
return 1; return -1;
}else if(min.getBlockY() < otherMin.getBlockY()){ }else if(min.getBlockZ() > otherMin.getBlockZ()){
return -1; return 1;
}else if(min.getBlockY() > otherMin.getBlockY()){ }else if(min.getBlockY() < otherMin.getBlockY()){
return 1; return -1;
}else{ }else if(min.getBlockY() > otherMin.getBlockY()){
return 0; return 1;
} }else{
} return 0;
}
public static int compareBlockVectors(BlockVector v1, BlockVector v2){ }
Logger log = Logger.getLogger("Minecraft");
public static int compareBlockVectors(BlockVector v1, BlockVector v2){
if(v1 == null){ Logger log = Logger.getLogger("Minecraft");
if(v2 == null){
log.info("in Cuboid.compareBlockVectors v1 and v2 are null"); if(v1 == null){
return 0; if(v2 == null){
}else{ log.info("in Cuboid.compareBlockVectors v1 and v2 are null");
log.info("in Cubiod.compareBlockVectors v1 is null"); return 0;
return -1; }else{
} log.info("in Cubiod.compareBlockVectors v1 is null");
}else if(v2 == null){ return -1;
log.info("in Cubiod.compareBlockVectors v2 is null"); }
return 1; }else if(v2 == null){
} log.info("in Cubiod.compareBlockVectors v2 is null");
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())); return 1;
if(v1.getBlockX() < v2.getBlockX()){ }
return -1; 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()));
}else if(v1.getBlockX() > v2.getBlockX()){ if(v1.getBlockX() < v2.getBlockX()){
return 1; return -1;
}else if(v1.getBlockZ() < v2.getBlockZ()){ }else if(v1.getBlockX() > v2.getBlockX()){
return -1; return 1;
}else if(v1.getBlockZ() > v2.getBlockZ()){ }else if(v1.getBlockZ() < v2.getBlockZ()){
return 1; return -1;
}else if(v1.getBlockY() < v2.getBlockY()){ }else if(v1.getBlockZ() > v2.getBlockZ()){
return -1; return 1;
}else if(v1.getBlockY() > v2.getBlockY()){ }else if(v1.getBlockY() < v2.getBlockY()){
return 1; return -1;
}else{ }else if(v1.getBlockY() > v2.getBlockY()){
return 0; return 1;
} }else{
} return 0;
}
public static boolean isBlockLessThan(BlockVector v1, BlockVector v2) { }
return compareBlockVectors(v1, v2) < 0;
} public static boolean isBlockLessThan(BlockVector v1, BlockVector v2) {
return compareBlockVectors(v1, v2) < 0;
public Cuboid inset(int amount){ }
return inset(amount, amount, amount);
} public Cuboid inset(int amount){
return inset(amount, amount, amount);
public Cuboid inset(int x, int z){ }
return inset(x, 0, z);
} public Cuboid inset(int x, int z){
return inset(x, 0, 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);
} 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);
public int getVolume() { }
return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
} public int getVolume() {
public int getMinX(){return minX;} return (this.maxX - this.minX) * (this.maxY - this.minY) * (this.maxZ - this.minZ);
public void setMinX(int minX){this.minX = minX;} }
public int getMinY(){return minY;} public int getMinX(){return minX;}
public void setMinY(int minY){this.minY = minY;} public void setMinX(int minX){this.minX = minX;}
public int getMinZ(){return minZ;} public int getMinY(){return minY;}
public void setMinZ(int minZ){this.minZ = minZ;} public void setMinY(int minY){this.minY = minY;}
public int getMaxX(){return maxX;} public int getMinZ(){return minZ;}
public void setMaxX(int maxX){this.maxX = maxX;} public void setMinZ(int minZ){this.minZ = minZ;}
public int getMaxY(){return maxY;} public int getMaxX(){return maxX;}
public void setMaxY(int maxY){this.maxY = maxY;} public void setMaxX(int maxX){this.maxX = maxX;}
public int getMaxZ(){return maxZ;} public int getMaxY(){return maxY;}
public void setMaxZ(int maxZ){this.maxZ = maxZ;} public void setMaxY(int maxY){this.maxY = maxY;}
public int getMaxZ(){return maxZ;}
public Cuboid outset(int amount) { public void setMaxZ(int maxZ){this.maxZ = maxZ;}
return outset(amount, amount, amount);
} public Cuboid outset(int amount) {
return outset(amount, amount, amount);
public Cuboid outset(int x, int z){ }
return outset(x, 0, z);
} public Cuboid outset(int x, int z){
return outset(x, 0, z);
public Cuboid outset(int x, int y, int z) { }
return new Cuboid(this.minX - x, this.minY - y, this.minZ - z, this.maxX + x, this.maxY + y, this.maxZ + z);
} public Cuboid outset(int x, int y, int z) {
return new Cuboid(this.minX - x, this.minY - y, this.minZ - z, this.maxX + x, this.maxY + y, this.maxZ + z);
public int getCenterX(){ }
return (this.minX + this.maxX) /2;
} public int getCenterX(){
return (this.minX + this.maxX) /2;
public int getCenterY(){ }
return (this.minY + this.maxY)/2;
} public int getCenterY(){
return (this.minY + this.maxY)/2;
public int getCenterZ(){ }
return (this.minZ + this.maxZ)/2;
} public int getCenterZ(){
return (this.minZ + this.maxZ)/2;
public boolean intersects(Cuboid other) { }
if (this.maxX >= other.minX && this.minX <= other.maxX)
{ public boolean intersects(Cuboid other) {
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ) if (this.maxX >= other.minX && this.minX <= other.maxX)
{ {
if (this.maxY >= other.minY && this.minY <= other.maxY) if (this.maxZ >= other.minZ && this.minZ <= other.maxZ)
{ {
return true; if (this.maxY >= other.minY && this.minY <= other.maxY)
} {
else return true;
{ }
return false; else
} {
} return false;
else }
{ }
return false; else
} {
} return false;
else }
{ }
return false; else
} {
} return false;
} }
}
public boolean contains(Location bedSpawn) {
if(this.minX > bedSpawn.getBlockX() || this.maxX < bedSpawn.getBlockX()){
return false;
}else if(this.minZ > bedSpawn.getBlockZ() || this.maxZ < bedSpawn.getBlockZ()){
return false;
}else if(this.minY > bedSpawn.getBlockY() || this.maxY < bedSpawn.getBlockY()){
return false;
}
return true;
}
}

View File

@@ -19,8 +19,12 @@ import org.bukkit.plugin.java.JavaPlugin;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand; import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisFlagResetCommand; import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisFlagResetCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeEvictCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeGenerateCommand; import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeGenerateCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeGoCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeListCommand; import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeListCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeMoveCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotGoCommand;
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand; import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand;
import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener; import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
@@ -37,6 +41,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
public class MetropolisPlugin extends JavaPlugin { public class MetropolisPlugin extends JavaPlugin {
public static final boolean DEBUG = true; public static final boolean DEBUG = true;
public static final Logger log=Logger.getLogger("Minecraft"); public static final Logger log=Logger.getLogger("Minecraft");
private static final int version = 1;
public PluginDescriptionFile pdf = null; public PluginDescriptionFile pdf = null;
public WorldGuardPlugin worldGuard = null; public WorldGuardPlugin worldGuard = null;
@@ -88,29 +93,52 @@ public class MetropolisPlugin extends JavaPlugin {
pdf = getDescription(); pdf = getDescription();
Configuration config = getConfig(); Configuration config = getConfig();
if(!config.contains("version")){
//new or upgrading from ancient
if(config.contains("plot.sizeX")){
//upgrading from ancient
int oldSizeX = safeGetIntFromConfig(config, "plot.sizeX");
int oldSizeZ = safeGetIntFromConfig(config, "plot.sizeZ");
int oldRoadWidth = safeGetIntFromConfig(config, "road.width");
oldSizeX -= oldRoadWidth;
oldSizeZ -= oldRoadWidth;
config.set("plot.sizeX", oldSizeX);
config.set("plot.sizeZ", oldSizeZ);
}else{
//new
}
}else{
int configVersion = safeGetIntFromConfig(config, "version");
if(configVersion != version){
//upgrade config
config.set("version", version);
}
}
config.options().copyDefaults(true); config.options().copyDefaults(true);
plotSizeX = config.getInt("plot.sizeX"); plotSizeX = safeGetIntFromConfig(config, "plot.sizeX");
plotSizeZ = config.getInt("plot.sizeZ"); plotSizeZ = safeGetIntFromConfig(config, "plot.sizeZ");
generateFloor = config.getBoolean("plot.floor.generate"); generateFloor = safeGetBooleanFromConfig(config, "plot.floor.generate");
floorMaterial = config.getInt("plot.floor.material"); floorMaterial = safeGetIntFromConfig(config, "plot.floor.material");
spaceAboveFloor = config.getInt("plot.floor.clearSpaceAbove"); spaceAboveFloor = safeGetIntFromConfig(config, "plot.floor.clearSpaceAbove");
generateFloorSupports = config.getBoolean("plot.floor.supports.generate"); generateFloorSupports = safeGetBooleanFromConfig(config, "plot.floor.supports.generate");
floorSupportMaterial = config.getInt("plot.floor.supports.material"); floorSupportMaterial = safeGetIntFromConfig(config, "plot.floor.supports.material");
generateSign = config.getBoolean("plot.sign.generate"); generateSign = safeGetBooleanFromConfig(config, "plot.sign.generate");
roadWidth = config.getInt("road.width"); roadWidth = safeGetIntFromConfig(config, "road.width");
spaceAboveRoad = config.getInt("road.clearSpaceAbove"); spaceAboveRoad = safeGetIntFromConfig(config, "road.clearSpaceAbove");
roadLevel = config.getInt("road.level"); roadLevel = safeGetIntFromConfig(config, "road.level");
roadMaterial = config.getInt("road.material"); roadMaterial = safeGetIntFromConfig(config, "road.material");
generateRoadSupports = config.getBoolean("road.supports.generate"); generateRoadSupports = safeGetBooleanFromConfig(config, "road.supports.generate");
roadSupportMaterial = config.getInt("road.supports.material"); roadSupportMaterial = safeGetIntFromConfig(config, "road.supports.material");
generateSpawn = config.getBoolean("spawn.generate"); generateSpawn = safeGetBooleanFromConfig(config, "spawn.generate");
setWorldSpawn = config.getBoolean("spawn.setAsWorldSpawn"); setWorldSpawn = safeGetBooleanFromConfig(config, "spawn.setAsWorldSpawn");
spawnFloorMaterial = config.getInt("spawn.material"); spawnFloorMaterial = safeGetIntFromConfig(config, "spawn.material");
generateWall = config.getBoolean("wall.generate"); generateWall = safeGetBooleanFromConfig(config, "wall.generate");
wallMaterial = config.getInt("wall.material"); wallMaterial = safeGetIntFromConfig(config, "wall.material");
wallHeight = config.getInt("wall.material"); wallHeight = safeGetIntFromConfig(config, "wall.material");
worldName =config.getString("worldname"); worldName = safeGetStringFromConfig(config, "worldname");
saveConfig(); saveConfig();
log.info(String.format("Metropolis: world name is %s", worldName)); log.info(String.format("Metropolis: world name is %s", worldName));
@@ -179,15 +207,55 @@ public class MetropolisPlugin extends JavaPlugin {
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-list").setExecutor(new MetropolisHomeListCommand(this));
getCommand("metropolis-flag-reset").setExecutor(new MetropolisFlagResetCommand(this));
getCommand("metropolis-plot-reserve").setExecutor(new MetropolisPlotReserveCommand(this));
if(DEBUG){ if(DEBUG){
getCommand("gentesthomes").setExecutor(new MetropolisDebugGenerateTestHomesCommand(this)); getCommand("metropolis-debug-generatetesthomes").setExecutor(new MetropolisDebugGenerateTestHomesCommand(this));
} }
getCommand("metropolis-flag-reset").setExecutor(new MetropolisFlagResetCommand(this));
getCommand("metropolis-home-evict").setExecutor(new MetropolisHomeEvictCommand(this));
getCommand("metropolis-home-generate").setExecutor(new MetropolisHomeGenerateCommand(this));
getCommand("metropolis-home-go").setExecutor(new MetropolisHomeGoCommand(this));
getCommand("metropolis-home-list").setExecutor(new MetropolisHomeListCommand(this));
getCommand("metropolis-home-move").setExecutor(new MetropolisHomeMoveCommand(this));
getCommand("metropolis-plot-go").setExecutor(new MetropolisPlotGoCommand(this));
getCommand("metropolis-plot-reserve").setExecutor(new MetropolisPlotReserveCommand(this));
} }
private String safeGetStringFromConfig(Configuration config, String name) {
if(config.isString(name)){
return config.getString(name);
}else{
throwInvalidConfigException();
return null;
}
}
private boolean safeGetBooleanFromConfig(Configuration config, String name) {
if(config.isBoolean(name)){
return config.getBoolean(name);
}else{
throwInvalidConfigException();
return false;
}
}
private int safeGetIntFromConfig(Configuration config, String name) {
if(config.isInt(name)){
return config.getInt(name);
}else{
throwInvalidConfigException();
return 0;
}
}
private void throwInvalidConfigException() {
log.info("Metropolis: ERROR config file is invalid. Please correct Metropolis/config.yml and restart the server.");
throw new RuntimeException("Config file is invalid.");
}
private void setupSpawn() { private void setupSpawn() {
BlockVector min = getPlotMin(0, 0); BlockVector min = getPlotMin(0, 0);
BlockVector max = getPlotMax(0, 0); BlockVector max = getPlotMax(0, 0);
@@ -203,6 +271,7 @@ public class MetropolisPlugin extends JavaPlugin {
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
block.setTypeId(0); block.setTypeId(0);
} }
y=roadLevel; y=roadLevel;
Block block = world.getBlockAt(x, y, z); Block block = world.getBlockAt(x, y, z);
block.setTypeId(spawnFloorMaterial); block.setTypeId(spawnFloorMaterial);
@@ -557,7 +626,7 @@ public class MetropolisPlugin extends JavaPlugin {
try { try {
regionManager.save(); regionManager.save();
} catch (ProtectionDatabaseException e) { } catch (ProtectionDatabaseException e) {
// TODO Auto-generated catch block log.info("Metropolis: ERROR Problem saving region");
e.printStackTrace(); e.printStackTrace();
} }

View File

@@ -3,6 +3,8 @@ package com.majinnaibu.bukkitplugins.metropolis;
import javax.persistence.Entity; import javax.persistence.Entity;
import javax.persistence.Table; import javax.persistence.Table;
import org.bukkit.Location;
import com.avaje.ebean.validation.NotNull; import com.avaje.ebean.validation.NotNull;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;

View File

@@ -4,6 +4,11 @@ import javax.persistence.Entity;
import javax.persistence.Id; import javax.persistence.Id;
import javax.persistence.Table; import javax.persistence.Table;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.World;
import org.bukkit.block.Block;
import com.avaje.ebean.validation.NotNull; import com.avaje.ebean.validation.NotNull;
import com.sk89q.worldedit.BlockVector; import com.sk89q.worldedit.BlockVector;
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion; import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
@@ -99,4 +104,26 @@ public class Plot implements Comparable<Plot>{
return sb.toString(); return sb.toString();
} }
public boolean contains(Location bedSpawn) {
return _cuboid.contains(bedSpawn);
}
public Location getViableSpawnLocation(World world) {
Cuboid cuboid = getCuboid();
for(int y=cuboid.maxY-1; y>= cuboid.minY; y--){
for(int x=cuboid.minX; x<= cuboid.maxX; x++){
for(int z=cuboid.minZ; z<= cuboid.maxZ; z++){
Block block = world.getBlockAt(x, y, z);
Block blockAbove = world.getBlockAt(x, y+1, z);
Block blockUnder = world.getBlockAt(x, y-1, z);
if(block.getType() == Material.AIR & blockAbove.getType() == Material.AIR && blockUnder.getType() != Material.AIR){
return new Location(world, x, y, z);
}
}
}
}
return null;
}
} }

View File

@@ -1,5 +0,0 @@
package com.majinnaibu.bukkitplugins.metropolis.commands;
public class MetropolisCommand {
}

View File

@@ -0,0 +1,23 @@
package com.majinnaibu.bukkitplugins.metropolis.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
public class MetropolisHomeEvictCommand implements CommandExecutor {
MetropolisPlugin _plugin = null;
public MetropolisHomeEvictCommand(MetropolisPlugin plugin){
_plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
// TODO Auto-generated method stub
return false;
}
}

View File

@@ -0,0 +1,76 @@
package com.majinnaibu.bukkitplugins.metropolis.commands;
import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
import com.majinnaibu.bukkitplugins.metropolis.PlayerHome;
public class MetropolisHomeGoCommand implements CommandExecutor {
MetropolisPlugin _plugin = null;
public MetropolisHomeGoCommand(MetropolisPlugin plugin){
_plugin = plugin;
}
@Override
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
Player player = null;
if(sender instanceof Player){
player = (Player)sender;
if(args.length >= 1){
if(player.hasPermission("")){
player = _plugin.getServer().getPlayer(args[0]);
if(player == null){
sender.sendMessage(String.format("Unable to find player %s", args[0]));
return false;
}
}else{
sender.sendMessage("Permission denied");
return false;
}
}
}else{
if(args.length >= 1){
player = _plugin.getServer().getPlayer(args[0]);
if(player == null){
sender.sendMessage(String.format("Unable to find player %s", args[0]));
return false;
}
}else{
sender.sendMessage("You must be a player");
return false;
}
}
PlayerHome home = _plugin.getPlayerHome(player);
Location loc = null;
Location bedSpawn = player.getBedSpawnLocation();
if(home.contains(bedSpawn)){
loc = bedSpawn;
}else {
loc = home.getViableSpawnLocation(_plugin.getWorld());
}
if(loc != null){
player.teleport(loc);
}else{
if(sender == player){
sender.sendMessage("There is no valid spawn location in your home");
}else{
sender.sendMessage(String.format("There is no valid spawn location in %s's home", player.getName()));
}
return false;
}
return true;
}
}

View File

@@ -0,0 +1,22 @@
package com.majinnaibu.bukkitplugins.metropolis.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
public class MetropolisHomeMoveCommand implements CommandExecutor {
public MetropolisHomeMoveCommand(MetropolisPlugin metropolisPlugin) {
// TODO Auto-generated constructor stub
}
@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2,
String[] arg3) {
// TODO Auto-generated method stub
return false;
}
}

View File

@@ -0,0 +1,22 @@
package com.majinnaibu.bukkitplugins.metropolis.commands;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
public class MetropolisPlotGoCommand implements CommandExecutor {
public MetropolisPlotGoCommand(MetropolisPlugin metropolisPlugin) {
// TODO Auto-generated constructor stub
}
@Override
public boolean onCommand(CommandSender arg0, Command arg1, String arg2,
String[] arg3) {
// TODO Auto-generated method stub
return false;
}
}

View File

@@ -4,32 +4,4 @@ depend: [WorldGuard]
softdepend: [WorldEdit,CommandBook] softdepend: [WorldEdit,CommandBook]
version: 0.5 version: 0.5
database: false database: false
commands: commands:
metropolis-home-generate:
description: This command generates a home for a user as if they'd just logged in.
permission: metropolis.home.generate
usage: /metropolis-home-generate <playername>
metropolis-home-list:
description: This lists the regions managed by Metropolis
permission: metropolis.home.list
usage: /metropolis-home-list
metropolis-flag-reset:
description: This command resets the WorldGuard flags for all managed regions (city and h_*).
permission: metropolis.flag.reset
usage: /metropolis-flag-reset
metropolis-plot-reserve:
description: This command reserves a plot so it won't be assigned as a home.
permission: metropolis.plot.reserve
usage: /metropolis-plot-reserve <name> <minX> <minY> <minZ> <maxX> <maxY> <maxZ>
metropolis-home-evict:
description: This unassigns a player's current home.
permission: metropolis.home.evict
usage: /metropolis-home-evict <playerName>
metropolis-home-move:
description: This command swaps a player's current home with a reserved plot.
permission: metropolis.home.move
usage: /metropolis-home-move <newRegionName>
gentesthomes:
description: This command is ignored on non-debug builds.
permission: metropolis.debug
usage: /gentesthomes