Implemented MetropolisHomeGoCommand
This commit is contained in:
5
Metropolis/.settings/org.eclipse.core.resources.prefs
Normal file
5
Metropolis/.settings/org.eclipse.core.resources.prefs
Normal 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
|
||||
@@ -1,207 +1,221 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class Cuboid implements Comparable<Cuboid> {
|
||||
private int id;
|
||||
|
||||
public int minX;
|
||||
public int minY;
|
||||
public int minZ;
|
||||
|
||||
public int maxX;
|
||||
public int maxY;
|
||||
public int maxZ;
|
||||
|
||||
public int getId(){
|
||||
return 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;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public Cuboid(BlockVector min, BlockVector max) {
|
||||
this.minX = min.getBlockX();
|
||||
this.minY = min.getBlockY();
|
||||
this.minZ = min.getBlockZ();
|
||||
this.maxX = max.getBlockX();
|
||||
this.maxY = max.getBlockY();
|
||||
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 Cuboid(Selection selection) {
|
||||
this.minX = selection.getMinimumPoint().getBlockX();
|
||||
this.minY = selection.getMinimumPoint().getBlockY();
|
||||
this.minZ = selection.getMinimumPoint().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 getMax(){
|
||||
return new BlockVector(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Cuboid o) {
|
||||
BlockVector min = getMin();
|
||||
BlockVector otherMin = o.getMin();
|
||||
|
||||
if(min.getBlockX() < otherMin.getBlockX()){
|
||||
return -1;
|
||||
}else if(min.getBlockX() > otherMin.getBlockX()){
|
||||
return 1;
|
||||
}else if(min.getBlockZ() < otherMin.getBlockZ()){
|
||||
return -1;
|
||||
}else if(min.getBlockZ() > otherMin.getBlockZ()){
|
||||
return 1;
|
||||
}else if(min.getBlockY() < otherMin.getBlockY()){
|
||||
return -1;
|
||||
}else if(min.getBlockY() > otherMin.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareBlockVectors(BlockVector v1, BlockVector v2){
|
||||
Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}else if(v1.getBlockX() > v2.getBlockX()){
|
||||
return 1;
|
||||
}else if(v1.getBlockZ() < v2.getBlockZ()){
|
||||
return -1;
|
||||
}else if(v1.getBlockZ() > v2.getBlockZ()){
|
||||
return 1;
|
||||
}else if(v1.getBlockY() < v2.getBlockY()){
|
||||
return -1;
|
||||
}else if(v1.getBlockY() > v2.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 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 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 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;}
|
||||
|
||||
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 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 getCenterY(){
|
||||
return (this.minY + this.maxY)/2;
|
||||
}
|
||||
|
||||
public int getCenterZ(){
|
||||
return (this.minZ + this.maxZ)/2;
|
||||
}
|
||||
|
||||
public boolean intersects(Cuboid other) {
|
||||
if (this.maxX >= other.minX && this.minX <= other.maxX)
|
||||
{
|
||||
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ)
|
||||
{
|
||||
if (this.maxY >= other.minY && this.minY <= other.maxY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||
|
||||
public class Cuboid implements Comparable<Cuboid> {
|
||||
private int id;
|
||||
|
||||
public int minX;
|
||||
public int minY;
|
||||
public int minZ;
|
||||
|
||||
public int maxX;
|
||||
public int maxY;
|
||||
public int maxZ;
|
||||
|
||||
public int getId(){
|
||||
return 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;
|
||||
this.minZ = minZ;
|
||||
this.maxX = maxX;
|
||||
this.maxY = maxY;
|
||||
this.maxZ = maxZ;
|
||||
}
|
||||
|
||||
public Cuboid(BlockVector min, BlockVector max) {
|
||||
this.minX = min.getBlockX();
|
||||
this.minY = min.getBlockY();
|
||||
this.minZ = min.getBlockZ();
|
||||
this.maxX = max.getBlockX();
|
||||
this.maxY = max.getBlockY();
|
||||
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 Cuboid(Selection selection) {
|
||||
this.minX = selection.getMinimumPoint().getBlockX();
|
||||
this.minY = selection.getMinimumPoint().getBlockY();
|
||||
this.minZ = selection.getMinimumPoint().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 getMax(){
|
||||
return new BlockVector(maxX, maxY, maxZ);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int compareTo(Cuboid o) {
|
||||
BlockVector min = getMin();
|
||||
BlockVector otherMin = o.getMin();
|
||||
|
||||
if(min.getBlockX() < otherMin.getBlockX()){
|
||||
return -1;
|
||||
}else if(min.getBlockX() > otherMin.getBlockX()){
|
||||
return 1;
|
||||
}else if(min.getBlockZ() < otherMin.getBlockZ()){
|
||||
return -1;
|
||||
}else if(min.getBlockZ() > otherMin.getBlockZ()){
|
||||
return 1;
|
||||
}else if(min.getBlockY() < otherMin.getBlockY()){
|
||||
return -1;
|
||||
}else if(min.getBlockY() > otherMin.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public static int compareBlockVectors(BlockVector v1, BlockVector v2){
|
||||
Logger log = Logger.getLogger("Minecraft");
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}else if(v1.getBlockX() > v2.getBlockX()){
|
||||
return 1;
|
||||
}else if(v1.getBlockZ() < v2.getBlockZ()){
|
||||
return -1;
|
||||
}else if(v1.getBlockZ() > v2.getBlockZ()){
|
||||
return 1;
|
||||
}else if(v1.getBlockY() < v2.getBlockY()){
|
||||
return -1;
|
||||
}else if(v1.getBlockY() > v2.getBlockY()){
|
||||
return 1;
|
||||
}else{
|
||||
return 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 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 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;}
|
||||
|
||||
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 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 getCenterY(){
|
||||
return (this.minY + this.maxY)/2;
|
||||
}
|
||||
|
||||
public int getCenterZ(){
|
||||
return (this.minZ + this.maxZ)/2;
|
||||
}
|
||||
|
||||
public boolean intersects(Cuboid other) {
|
||||
if (this.maxX >= other.minX && this.minX <= other.maxX)
|
||||
{
|
||||
if (this.maxZ >= other.minZ && this.minZ <= other.maxZ)
|
||||
{
|
||||
if (this.maxY >= other.minY && this.minY <= other.maxY)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,12 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand;
|
||||
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.MetropolisHomeGoCommand;
|
||||
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.eventlisteners.PlayerJoinListener;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
@@ -37,6 +41,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
public class MetropolisPlugin extends JavaPlugin {
|
||||
public static final boolean DEBUG = true;
|
||||
public static final Logger log=Logger.getLogger("Minecraft");
|
||||
private static final int version = 1;
|
||||
|
||||
public PluginDescriptionFile pdf = null;
|
||||
public WorldGuardPlugin worldGuard = null;
|
||||
@@ -88,29 +93,52 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
pdf = getDescription();
|
||||
|
||||
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);
|
||||
|
||||
plotSizeX = config.getInt("plot.sizeX");
|
||||
plotSizeZ = config.getInt("plot.sizeZ");
|
||||
generateFloor = config.getBoolean("plot.floor.generate");
|
||||
floorMaterial = config.getInt("plot.floor.material");
|
||||
spaceAboveFloor = config.getInt("plot.floor.clearSpaceAbove");
|
||||
generateFloorSupports = config.getBoolean("plot.floor.supports.generate");
|
||||
floorSupportMaterial = config.getInt("plot.floor.supports.material");
|
||||
generateSign = config.getBoolean("plot.sign.generate");
|
||||
roadWidth = config.getInt("road.width");
|
||||
spaceAboveRoad = config.getInt("road.clearSpaceAbove");
|
||||
roadLevel = config.getInt("road.level");
|
||||
roadMaterial = config.getInt("road.material");
|
||||
generateRoadSupports = config.getBoolean("road.supports.generate");
|
||||
roadSupportMaterial = config.getInt("road.supports.material");
|
||||
generateSpawn = config.getBoolean("spawn.generate");
|
||||
setWorldSpawn = config.getBoolean("spawn.setAsWorldSpawn");
|
||||
spawnFloorMaterial = config.getInt("spawn.material");
|
||||
generateWall = config.getBoolean("wall.generate");
|
||||
wallMaterial = config.getInt("wall.material");
|
||||
wallHeight = config.getInt("wall.material");
|
||||
worldName =config.getString("worldname");
|
||||
plotSizeX = safeGetIntFromConfig(config, "plot.sizeX");
|
||||
plotSizeZ = safeGetIntFromConfig(config, "plot.sizeZ");
|
||||
generateFloor = safeGetBooleanFromConfig(config, "plot.floor.generate");
|
||||
floorMaterial = safeGetIntFromConfig(config, "plot.floor.material");
|
||||
spaceAboveFloor = safeGetIntFromConfig(config, "plot.floor.clearSpaceAbove");
|
||||
generateFloorSupports = safeGetBooleanFromConfig(config, "plot.floor.supports.generate");
|
||||
floorSupportMaterial = safeGetIntFromConfig(config, "plot.floor.supports.material");
|
||||
generateSign = safeGetBooleanFromConfig(config, "plot.sign.generate");
|
||||
roadWidth = safeGetIntFromConfig(config, "road.width");
|
||||
spaceAboveRoad = safeGetIntFromConfig(config, "road.clearSpaceAbove");
|
||||
roadLevel = safeGetIntFromConfig(config, "road.level");
|
||||
roadMaterial = safeGetIntFromConfig(config, "road.material");
|
||||
generateRoadSupports = safeGetBooleanFromConfig(config, "road.supports.generate");
|
||||
roadSupportMaterial = safeGetIntFromConfig(config, "road.supports.material");
|
||||
generateSpawn = safeGetBooleanFromConfig(config, "spawn.generate");
|
||||
setWorldSpawn = safeGetBooleanFromConfig(config, "spawn.setAsWorldSpawn");
|
||||
spawnFloorMaterial = safeGetIntFromConfig(config, "spawn.material");
|
||||
generateWall = safeGetBooleanFromConfig(config, "wall.generate");
|
||||
wallMaterial = safeGetIntFromConfig(config, "wall.material");
|
||||
wallHeight = safeGetIntFromConfig(config, "wall.material");
|
||||
worldName = safeGetStringFromConfig(config, "worldname");
|
||||
saveConfig();
|
||||
|
||||
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()));
|
||||
|
||||
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){
|
||||
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() {
|
||||
BlockVector min = getPlotMin(0, 0);
|
||||
BlockVector max = getPlotMax(0, 0);
|
||||
@@ -203,6 +271,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
block.setTypeId(0);
|
||||
}
|
||||
|
||||
y=roadLevel;
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
block.setTypeId(spawnFloorMaterial);
|
||||
@@ -557,7 +626,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
try {
|
||||
regionManager.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
// TODO Auto-generated catch block
|
||||
log.info("Metropolis: ERROR Problem saving region");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.majinnaibu.bukkitplugins.metropolis;
|
||||
import javax.persistence.Entity;
|
||||
import javax.persistence.Table;
|
||||
|
||||
import org.bukkit.Location;
|
||||
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
|
||||
@@ -4,6 +4,11 @@ import javax.persistence.Entity;
|
||||
import javax.persistence.Id;
|
||||
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.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
@@ -99,4 +104,26 @@ public class Plot implements Comparable<Plot>{
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
public class MetropolisCommand {
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -4,32 +4,4 @@ depend: [WorldGuard]
|
||||
softdepend: [WorldEdit,CommandBook]
|
||||
version: 0.5
|
||||
database: false
|
||||
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
|
||||
commands:
|
||||
Reference in New Issue
Block a user