Compare commits
12 Commits
f9ed658ed9
...
e1d2c8751a
| Author | SHA1 | Date | |
|---|---|---|---|
| e1d2c8751a | |||
| 012e1f15a3 | |||
| dd6f91e9e2 | |||
| 487e745870 | |||
| 4f2adc52b0 | |||
| c7ee4f8382 | |||
| 4018ff1cc1 | |||
| dcfdc2be60 | |||
| ad2b7b5bf6 | |||
| 3c46c0879a | |||
| 89bd6f3a2c | |||
| 5b81e6b8b2 |
0
Metropolis/.gitignore → .gitignore
vendored
0
Metropolis/.gitignore → .gitignore
vendored
@@ -22,10 +22,12 @@
|
||||
</scm>
|
||||
|
||||
<repositories>
|
||||
<!--
|
||||
<repository>
|
||||
<id>wg</id>
|
||||
<url>http://files.zachsthings.com/repo</url>
|
||||
</repository>
|
||||
-->
|
||||
<repository>
|
||||
<id>sk89q</id>
|
||||
<url>http://mvn2.sk89q.com/repo</url>
|
||||
@@ -35,6 +37,18 @@
|
||||
<id>bukkit-repo</id>
|
||||
<url>http://repo.bukkit.org/content/groups/public</url>
|
||||
</repository>
|
||||
|
||||
<repository>
|
||||
<id>sonatype-nexus-releases</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/releases</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>sonatype-nexus-snapshots</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<dependencies>
|
||||
@@ -42,21 +56,21 @@
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldedit</artifactId>
|
||||
<version>5.2</version>
|
||||
<version>5.6.3</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Bukkit -->
|
||||
<dependency>
|
||||
<groupId>org.bukkit</groupId>
|
||||
<artifactId>bukkit</artifactId>
|
||||
<version>1.1-R6</version>
|
||||
<version>1.7.9-R0.2</version>
|
||||
</dependency>
|
||||
|
||||
<!-- WorldGuard -->
|
||||
<dependency>
|
||||
<groupId>com.sk89q</groupId>
|
||||
<artifactId>worldguard</artifactId>
|
||||
<version>5.5</version>
|
||||
<version>5.9</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
@@ -1,11 +1,17 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.World;
|
||||
import org.bukkit.block.Block;
|
||||
@@ -21,6 +27,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
||||
import org.bukkit.plugin.PluginManager;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisDebugGenerateTestHomesCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisFlagResetCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeEvictCommand;
|
||||
@@ -31,12 +38,11 @@ import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisHomeMoveComman
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotGoCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.commands.MetropolisPlotReserveCommand;
|
||||
import com.majinnaibu.bukkitplugins.metropolis.eventlisteners.PlayerJoinListener;
|
||||
import com.sk89q.util.yaml.YAMLProcessor;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
import com.sk89q.worldguard.bukkit.WorldGuardPlugin;
|
||||
import com.sk89q.worldguard.domains.DefaultDomain;
|
||||
import com.sk89q.worldguard.domains.Domain;
|
||||
import com.sk89q.worldguard.protection.databases.ProtectionDatabaseException;
|
||||
import com.sk89q.worldguard.protection.flags.DefaultFlag;
|
||||
import com.sk89q.worldguard.protection.flags.StateFlag;
|
||||
import com.sk89q.worldguard.protection.managers.RegionManager;
|
||||
@@ -44,7 +50,7 @@ import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
public class MetropolisPlugin extends JavaPlugin {
|
||||
public static final boolean DEBUG = true;
|
||||
public static final boolean DEBUG = false;
|
||||
public static final Logger log=Logger.getLogger("Minecraft");
|
||||
private static final int version = 1;
|
||||
|
||||
@@ -60,13 +66,16 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
public RegionManager regionManager = null;
|
||||
|
||||
private List<Plot> _occupiedPlots;
|
||||
private HashMap<String, List<Plot>> _ownedPlots;
|
||||
private HashMap<String, UserOverride> _userOverrides;
|
||||
private HashMap<String, Integer> _currentHomes;
|
||||
|
||||
private PlayerJoinListener _playerJoinListener = null;
|
||||
|
||||
int size = 1;
|
||||
|
||||
private int plotSizeX = 24;
|
||||
private int plotSizeY = 256;
|
||||
//private int plotSizeY = 256;
|
||||
private int plotSizeZ = 24;
|
||||
private int gridSizeX = 28;
|
||||
private int gridSizeY = 256;
|
||||
@@ -90,6 +99,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
private boolean generateWall = false;
|
||||
private Material wallMaterial = Material.GLASS;
|
||||
private int wallHeight = 128;
|
||||
int _maxPlots = 1;
|
||||
int _plotMultiplier = 1;
|
||||
|
||||
private Cuboid _spawnCuboid = null;
|
||||
private Cuboid _cityCuboid = null;
|
||||
@@ -106,6 +117,11 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
public void onEnable() {
|
||||
pdf = getDescription();
|
||||
|
||||
_ownedPlots = new HashMap<String, List<Plot>>();
|
||||
_userOverrides = new HashMap<String, UserOverride>();
|
||||
_currentHomes = new HashMap<String, Integer>();
|
||||
loadCurrentHomes();
|
||||
|
||||
if(DEBUG){log.info("Checking config");}
|
||||
Configuration config = getConfig();
|
||||
if(!config.contains("version")){
|
||||
@@ -113,13 +129,15 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
if(DEBUG){log.info("No config exists. Assuming new installation.");}
|
||||
}else{
|
||||
int configVersion = safeGetIntFromConfig(config, "version");
|
||||
if(DEBUG){log.info(String.format("Updating config from version v%s to v%s.", configVersion, version));}
|
||||
if(configVersion != version){
|
||||
//upgrade config
|
||||
config.set("version", version);
|
||||
if(configVersion < version){
|
||||
if(DEBUG){log.info(String.format("Updating config from version v%s to v%s.", configVersion, version));}
|
||||
if(configVersion != version){
|
||||
//upgrade config
|
||||
config.set("version", version);
|
||||
}
|
||||
saveConfig();
|
||||
if(DEBUG){log.info("Config updated");}
|
||||
}
|
||||
saveConfig();
|
||||
if(DEBUG){log.info("Config updated");}
|
||||
}
|
||||
|
||||
config.set("version", version);
|
||||
@@ -149,6 +167,11 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
wallMaterial = safeGetMaterialFromConfig(config, "wall.material");
|
||||
wallHeight = safeGetIntFromConfig(config, "wall.material");
|
||||
worldName = safeGetStringFromConfig(config, "worldname");
|
||||
_maxPlots = safeGetIntFromConfig(config, "plot.multiplier");
|
||||
_plotMultiplier = safeGetIntFromConfig(config, "plot.maxPerPlayer");
|
||||
|
||||
buildUserOverrides();
|
||||
|
||||
saveConfig();
|
||||
if(DEBUG){log.info("Done reading config.");}
|
||||
|
||||
@@ -192,7 +215,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
_cityRegion = regionManager.getRegion("City");
|
||||
if(_cityRegion == null){
|
||||
_cityRegion = new ProtectedCuboidRegion("City", getPlotMin(0, 0), this.getPlotMax(0, 0));
|
||||
_cityRegion = new ProtectedCuboidRegion("City", getPlotMin(0, 0, 1), this.getPlotMax(0, 0, 1));
|
||||
_cityRegion.setPriority(0);
|
||||
_cityRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
_cityRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
@@ -210,7 +233,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
_spawnRegion = regionManager.getRegion("Spawn");
|
||||
if(_spawnRegion == null){
|
||||
_spawnRegion = new ProtectedCuboidRegion("Spawn", getPlotMin(0, 0), getPlotMax(0, 0));
|
||||
_spawnRegion = new ProtectedCuboidRegion("Spawn", getPlotMin(0, 0, 1), getPlotMax(0, 0, 1));
|
||||
_spawnRegion.setPriority(1);
|
||||
_spawnRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
_spawnRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
@@ -233,16 +256,21 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
_spawnCuboid = new Cuboid(_spawnRegion.getMinimumPoint(), _spawnRegion.getMaximumPoint());
|
||||
|
||||
if(DEBUG){
|
||||
log.info("Metropolis: first 9 plots");
|
||||
/*
|
||||
log.info("Metropolis: first 25 plots");
|
||||
|
||||
for (int ix=-1; ix<=1;ix++){
|
||||
for (int iz=-1; iz<=1; iz++){
|
||||
int n = 5;
|
||||
|
||||
for (int ix=-n; ix<=n; ix++){
|
||||
for (int iz=-n; iz<=n; iz++){
|
||||
log.info(getCuboid(iz, ix).toString());
|
||||
}
|
||||
}
|
||||
*/
|
||||
|
||||
log.info(String.format("roadWidth = %d", roadWidth));
|
||||
}
|
||||
|
||||
|
||||
_occupiedPlots = new ArrayList<Plot>();
|
||||
fillOccupiedPlots();
|
||||
resizeCityRegion();
|
||||
@@ -253,12 +281,9 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
log.info(String.format("%s enabled", pdf.getFullName()));
|
||||
|
||||
PluginCommand command = getCommand("metropolis-debug-generatetesthomes");
|
||||
if(command != null){
|
||||
command.setExecutor(new MetropolisDebugGenerateTestHomesCommand(this));
|
||||
}else{
|
||||
throw new RuntimeException("The metropolis-debug-generatetesthomes command does not appear to exist");
|
||||
}
|
||||
RegisterCommandHandler("metropolis", new MetropolisCommand(this));
|
||||
|
||||
RegisterCommandHandler("metropolis-debug-generatetesthomes", new MetropolisDebugGenerateTestHomesCommand(this));
|
||||
|
||||
RegisterCommandHandler("metropolis-flag-reset", new MetropolisFlagResetCommand(this));
|
||||
|
||||
@@ -272,9 +297,65 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
RegisterCommandHandler("metropolis-plot-reserve", new MetropolisPlotReserveCommand(this));
|
||||
}
|
||||
|
||||
private void loadCurrentHomes() {
|
||||
YAMLProcessor processor = new YAMLProcessor(new File(getDataFolder(), "currentHomes.yml"), true);
|
||||
try {
|
||||
processor.load();
|
||||
} catch (IOException e) {
|
||||
log.info(e.toString());
|
||||
return;
|
||||
}
|
||||
|
||||
Set<String> keys = processor.getMap().keySet();
|
||||
|
||||
_currentHomes.clear();
|
||||
for(String username : keys){
|
||||
_currentHomes.put(username, processor.getInt(username, 0));
|
||||
}
|
||||
}
|
||||
|
||||
private void buildUserOverrides() {
|
||||
if(getConfig().isList("userOverrides")){
|
||||
List<?> list = getConfig().getList("userOverrides");
|
||||
|
||||
for(Object o2 : list){
|
||||
if(o2 instanceof HashMap<?, ?>){
|
||||
HashMap<?, ?>map = (HashMap<?, ?>)o2;
|
||||
String username = "";
|
||||
if(map.containsKey("username")){
|
||||
Object o3 = map.get("username");
|
||||
if(o3 instanceof String){
|
||||
username = (String)o3;
|
||||
}
|
||||
}
|
||||
|
||||
int plotMultiplier = _plotMultiplier;
|
||||
if(map.containsKey("plotMultiplier")){
|
||||
Object o3 = map.get("plotMultiplier");
|
||||
if(o3 instanceof Integer){
|
||||
plotMultiplier = (Integer)o3;
|
||||
}
|
||||
}
|
||||
|
||||
int maxPlots = _maxPlots;
|
||||
if(map.containsKey("maxPlots")){
|
||||
Object o3 = map.get("maxPlots");
|
||||
if(o3 instanceof Integer){
|
||||
maxPlots = (Integer)o3;
|
||||
}
|
||||
}
|
||||
|
||||
UserOverride override = new UserOverride(username, plotMultiplier, maxPlots);
|
||||
_userOverrides.put(username, override);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Cuboid getCuboid(int row, int col) {
|
||||
BlockVector min = getPlotMin(row, col);
|
||||
BlockVector max = getPlotMax(row, col);
|
||||
//This is only used for debug info
|
||||
BlockVector min = getPlotMin(row, col, 1);
|
||||
BlockVector max = getPlotMax(row, col, 1);
|
||||
return new Cuboid(min, max);
|
||||
}
|
||||
|
||||
@@ -366,13 +447,19 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
private void fillOccupiedPlots(){
|
||||
_occupiedPlots.clear();
|
||||
_ownedPlots.clear();
|
||||
|
||||
for(ProtectedRegion region: regionManager.getRegions().values()){
|
||||
if(region instanceof ProtectedCuboidRegion){
|
||||
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) region;
|
||||
if(cuboidRegion.getId().startsWith("h_")){
|
||||
PlayerHome home = PlayerHome.get(region);
|
||||
if(!_currentHomes.containsKey(home.getPlayerName()))
|
||||
{
|
||||
_currentHomes.put(home.getPlayerName(), home.getNumber());
|
||||
}
|
||||
_occupiedPlots.add(home);
|
||||
addOwnedPlot(home.getPlayerName(), home);
|
||||
}else if(cuboidRegion.getId().startsWith("r_")){
|
||||
_occupiedPlots.add(Plot.get(cuboidRegion));
|
||||
}
|
||||
@@ -382,6 +469,17 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
size=calculateCitySize();
|
||||
}
|
||||
|
||||
private void addOwnedPlot(String substring, Plot plot) {
|
||||
if(_ownedPlots.containsKey(substring)){
|
||||
List<Plot> plots = _ownedPlots.get(substring);
|
||||
plots.add(plot);
|
||||
}else{
|
||||
List<Plot> plots = new ArrayList<Plot>();
|
||||
plots.add(plot);
|
||||
_ownedPlots.put(substring, plots);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
return super.onCommand(sender, command, label, args);
|
||||
@@ -409,29 +507,42 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
int x=0;
|
||||
int y=roadLevel;
|
||||
int z=0;
|
||||
|
||||
|
||||
for(x = plotCuboid.minX; x <= plotCuboid.maxX; x++){
|
||||
for(z=plotCuboid.minZ; z<=plotCuboid.maxZ; z++){
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
//Set the floor block
|
||||
block.setType(floorMaterial);
|
||||
setFloor(x, y, z);
|
||||
|
||||
//Set the support
|
||||
if(generateFloorSupports && isPhysicsMaterial(block.getType())){
|
||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||
if(!isSolidMaterial(blockUnder.getType())){
|
||||
blockUnder.setType(floorSupportMaterial);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i=0; i<spaceAboveFloor; i++){
|
||||
block = world.getBlockAt(x, y+1+i, z);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
clearSpaceAbove(x, y, z);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void clearSpaceAbove(int x, int y, int z) {
|
||||
Block block = null;
|
||||
|
||||
for(int i=0; i<spaceAboveFloor; i++){
|
||||
block = world.getBlockAt(x, y+1+i, z);
|
||||
block.setType(Material.AIR);
|
||||
}
|
||||
}
|
||||
|
||||
private void setFloor(int x, int y, int z) {
|
||||
//if(DEBUG){log.info(String.format("setting road at (%d, %d, %d)", x, y, z));}
|
||||
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
|
||||
//Set the floor block
|
||||
block.setType(floorMaterial);
|
||||
|
||||
//Set the support
|
||||
if(generateFloorSupports && isPhysicsMaterial(block.getType())){
|
||||
Block blockUnder = world.getBlockAt(x, y-1, z);
|
||||
if(!isSolidMaterial(blockUnder.getType())){
|
||||
blockUnder.setType(floorSupportMaterial);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void createRoads(Cuboid plotCuboid, int roadMask){
|
||||
if(roadWidth>0){
|
||||
int x=0;
|
||||
@@ -527,6 +638,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
private void setRoad(int x, int y, int z) {
|
||||
//if(DEBUG){log.info(String.format("setting road at (%d, %d, %d)", x, y, z));}
|
||||
|
||||
Block block = world.getBlockAt(x, y, z);
|
||||
//Set the road block
|
||||
block.setType(roadMaterial);
|
||||
@@ -562,7 +675,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
public boolean isBlockOccupied(int row, int col){
|
||||
Cuboid cuboid = new Cuboid(getGridMin(row, col), getGridMax(row, col));
|
||||
Cuboid cuboid = new Cuboid(getGridMin(row, col, 1), getGridMax(row, col, 1));
|
||||
for(Plot plot: _occupiedPlots){
|
||||
if(plot.getCuboid().intersects(cuboid)){
|
||||
return true;
|
||||
@@ -576,60 +689,74 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return false;
|
||||
}
|
||||
|
||||
private Cuboid findNextUnownedHomeRegion() {
|
||||
private boolean areBlocksOccupied(int row, int col, int i) {
|
||||
for(int ix = col; ix < col+i; ix++){
|
||||
for(int iy = row; iy < row+i; iy++){
|
||||
if(isBlockOccupied(iy, ix)){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private Cuboid findNextUnownedHomeRegion(int plotMultiplier) {
|
||||
int row = 0;
|
||||
int col = 0;
|
||||
int ring = 0;
|
||||
int min = -ring;
|
||||
int max = ring - (plotMultiplier-1);
|
||||
boolean done = false;
|
||||
|
||||
while(!done){
|
||||
row = -ring;
|
||||
col = -ring;
|
||||
|
||||
for(col = -ring; col <= ring; col++){
|
||||
if(!isBlockOccupied(row, col)){
|
||||
if(row != 0 || col != 0){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
|
||||
}
|
||||
row = min;
|
||||
col = min;
|
||||
|
||||
//Top
|
||||
for(col = min; col <= max; col++){
|
||||
if(!areBlocksOccupied(row, col, plotMultiplier)){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col, plotMultiplier), getPlotMax(row, col, plotMultiplier));
|
||||
}
|
||||
}
|
||||
|
||||
col = ring;
|
||||
for(row=-ring + 1; row < ring; row++){
|
||||
if(!isBlockOccupied(row, col)){
|
||||
if(row != 0 || col != 0){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
|
||||
}
|
||||
//Right side
|
||||
col = max;
|
||||
for(row=min + 1; row < max; row++){
|
||||
if(!areBlocksOccupied(row, col, plotMultiplier)){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col, plotMultiplier), getPlotMax(row, col, plotMultiplier));
|
||||
}
|
||||
}
|
||||
|
||||
row = ring;
|
||||
for(col = ring; col >= -ring; col--){
|
||||
if(!isBlockOccupied(row, col)){
|
||||
if(row != 0 || col != 0){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col), getPlotMax(row, col));
|
||||
}
|
||||
//Bottom
|
||||
row = max;
|
||||
for(col = max; col >= min; col--){
|
||||
if(!areBlocksOccupied(row, col, plotMultiplier)){
|
||||
if(DEBUG){log.info(String.format("row: %d, col: %d", row, col));}
|
||||
return new Cuboid(getPlotMin(row, col, plotMultiplier), getPlotMax(row, col, plotMultiplier));
|
||||
}
|
||||
}
|
||||
|
||||
col = -ring;
|
||||
for(row = ring; row > -ring; row--){
|
||||
if(!isBlockOccupied(row, col)){
|
||||
//Left
|
||||
col = min;
|
||||
for(row = max; row > min; row--){
|
||||
if(!areBlocksOccupied(row, col, plotMultiplier)){
|
||||
if(row != 0 || col != 0){
|
||||
if(DEBUG){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, plotMultiplier), getPlotMax(row, col, plotMultiplier));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ring++;
|
||||
min = -ring;
|
||||
max = ring - (plotMultiplier-1);
|
||||
}
|
||||
|
||||
if(DEBUG){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, plotMultiplier), getPlotMax(row, col, plotMultiplier));
|
||||
}
|
||||
|
||||
private void resizeCityRegion() {
|
||||
@@ -641,8 +768,8 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
BlockVector min;
|
||||
BlockVector max;
|
||||
|
||||
min = getPlotMin(-size/2, -size/2);
|
||||
max = getPlotMax(size/2, size/2);
|
||||
min = getPlotMin(-size/2, -size/2, 1);
|
||||
max = getPlotMax(size/2, size/2, 1);
|
||||
|
||||
region.setMinimumPoint(min);
|
||||
region.setMaximumPoint(max);
|
||||
@@ -663,28 +790,36 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return iSize;
|
||||
}
|
||||
|
||||
public BlockVector getPlotMin(int row, int col){
|
||||
BlockVector gridMin = getGridMin(row, col);
|
||||
public BlockVector getPlotMin(int row, int col, int plotMultiplier){
|
||||
BlockVector gridMin = getGridMin(row, col, plotMultiplier);
|
||||
|
||||
return new BlockVector(gridMin.getBlockX() + roadWidth/2, gridMin.getBlockY(), gridMin.getBlockZ() + roadWidth/2);
|
||||
BlockVector bv = new BlockVector(gridMin.getBlockX() + roadWidth/2, gridMin.getBlockY(), gridMin.getBlockZ() + roadWidth/2);
|
||||
log.info(String.format("getPlotMin (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getGridMin(int row, int col){
|
||||
public BlockVector getPlotMax(int row, int col, int plotMultiplier){
|
||||
BlockVector gridMax = getGridMax(row, col, plotMultiplier);
|
||||
|
||||
BlockVector bv = new BlockVector(gridMax.getBlockX() - (roadWidth - roadWidth/2), gridMax.getBlockY(), gridMax.getBlockZ() - (roadWidth-roadWidth/2));
|
||||
log.info(String.format("getPlotMax (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getGridMin(int row, int col, int plotMultiplier){
|
||||
int level = 0;
|
||||
|
||||
return new BlockVector(col * gridSizeX, level * gridSizeY, row * gridSizeZ);
|
||||
BlockVector bv = new BlockVector(col * gridSizeX, level * gridSizeY, row * gridSizeZ);
|
||||
log.info(String.format("getGridMin (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
public BlockVector getPlotMax(int row, int col){
|
||||
BlockVector gridMax = getGridMax(row, col);
|
||||
|
||||
return new BlockVector(gridMax.getBlockX() - (int)Math.ceil(roadWidth/2.0f), gridMax.getBlockY(), gridMax.getBlockZ()-(int)Math.ceil(roadWidth/2.0f));
|
||||
}
|
||||
|
||||
public BlockVector getGridMax(int row, int col) {
|
||||
public BlockVector getGridMax(int row, int col, int plotMultiplier){
|
||||
int level = 0;
|
||||
|
||||
return new BlockVector((col+1) * gridSizeX - 1, (level+1) * gridSizeY - 1, (row+1) * gridSizeZ - 1);
|
||||
BlockVector bv = new BlockVector((col+plotMultiplier) * gridSizeX*plotMultiplier-1, (level+1/*plotMultiplier*/) * gridSizeY-1, (row+plotMultiplier) * gridSizeZ-1);
|
||||
log.info(String.format("getGridMax (%d, %d, %d)", bv.getBlockX(), bv.getBlockY(), bv.getBlockZ()));
|
||||
return bv;
|
||||
}
|
||||
|
||||
private int getPlotXFromMin(Cuboid cuboid) {
|
||||
@@ -704,38 +839,59 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
}
|
||||
|
||||
public PlayerHome generateHome(String playerName) {
|
||||
int multiplier = getPlotMultiplier(playerName);
|
||||
|
||||
if(DEBUG){log.info(String.format("Generating home for %s", playerName));}
|
||||
Cuboid homeCuboid = null;
|
||||
ProtectedRegion homeRegion = null;
|
||||
String regionName = "h_" + playerName;
|
||||
homeRegion = regionManager.getRegion("h_" + playerName);
|
||||
if(homeRegion != null){
|
||||
return PlayerHome.get(homeRegion);
|
||||
ProtectedRegion phomeRegion = null;
|
||||
String regionName = "h_1_" + playerName;
|
||||
phomeRegion = regionManager.getRegion(regionName);
|
||||
if(phomeRegion != null){
|
||||
return PlayerHome.get(phomeRegion);
|
||||
}
|
||||
|
||||
homeCuboid = findNextUnownedHomeRegion();
|
||||
homeCuboid = findNextUnownedHomeRegion(multiplier);
|
||||
|
||||
log.info("Metropolis Generating home in " + homeCuboid.toString());
|
||||
homeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
|
||||
homeRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
homeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
|
||||
DefaultDomain d = homeRegion.getOwners();
|
||||
|
||||
ProtectedCuboidRegion newHomeRegion = new ProtectedCuboidRegion(regionName, homeCuboid.getMin(), homeCuboid.getMax());
|
||||
newHomeRegion.setFlag(DefaultFlag.PVP, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.MOB_DAMAGE, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.MOB_SPAWNING, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.CREEPER_EXPLOSION, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.ENDER_BUILD, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.GHAST_FIREBALL, StateFlag.State.DENY);
|
||||
newHomeRegion.setFlag(DefaultFlag.TNT, StateFlag.State.DENY);
|
||||
|
||||
DefaultDomain d = newHomeRegion.getOwners();
|
||||
d.addPlayer(playerName);
|
||||
homeRegion.setPriority(1);
|
||||
regionManager.addRegion(homeRegion);
|
||||
newHomeRegion.setPriority(1);
|
||||
|
||||
regionManager.addRegion(newHomeRegion);
|
||||
try {
|
||||
regionManager.save();
|
||||
} catch (ProtectionDatabaseException e) {
|
||||
} catch (Exception e) {
|
||||
log.info("Metropolis: ERROR Problem saving region");
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
try {
|
||||
regionManager.save();
|
||||
} catch (Exception e) {
|
||||
log.info("Metropolis: ERROR Problem saving region");
|
||||
e.printStackTrace();
|
||||
}
|
||||
log.info(String.format(
|
||||
"New home region (%d, %d, %d) (%d, %d, %d)",
|
||||
newHomeRegion.getMinimumPoint().getBlockX(),
|
||||
newHomeRegion.getMinimumPoint().getBlockY(),
|
||||
newHomeRegion.getMinimumPoint().getBlockZ(),
|
||||
newHomeRegion.getMaximumPoint().getBlockX(),
|
||||
newHomeRegion.getMaximumPoint().getBlockY(),
|
||||
newHomeRegion.getMaximumPoint().getBlockZ()
|
||||
));
|
||||
|
||||
setHomeOccupied(playerName, homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint());
|
||||
setHomeOccupied(playerName, newHomeRegion.getMinimumPoint(), newHomeRegion.getMaximumPoint());
|
||||
|
||||
createRoads(homeCuboid);
|
||||
|
||||
@@ -750,7 +906,7 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
|
||||
if(DEBUG){log.info(String.format("Done generating home for %s", playerName));}
|
||||
|
||||
return new PlayerHome(homeRegion);
|
||||
return new PlayerHome(newHomeRegion);
|
||||
}
|
||||
|
||||
private void generateSign(Cuboid plotCuboid, String playerName) {
|
||||
@@ -809,39 +965,124 @@ public class MetropolisPlugin extends JavaPlugin {
|
||||
return wallHeight;
|
||||
}
|
||||
|
||||
public int getMaxPlots(String name) {
|
||||
Player player = null;
|
||||
// TODO Auto-generated method stub
|
||||
return 0;
|
||||
public ProtectedRegion getRegion(String regionName) {
|
||||
if(regionManager == null){
|
||||
return null;
|
||||
}
|
||||
|
||||
return regionManager.getRegion(regionName);
|
||||
}
|
||||
|
||||
public void removeRegion(String regionId) {
|
||||
if(regionManager == null){
|
||||
return;
|
||||
}
|
||||
|
||||
try{
|
||||
regionManager.removeRegion(regionId);
|
||||
}catch(Exception ex){
|
||||
log.info(String.format("[ERROR] Metropolis: Unable to remove region {%s}.", regionId));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public void saveRegions() {
|
||||
try {
|
||||
regionManager.save();
|
||||
} catch (Exception ex) {
|
||||
log.info(String.format("[SEVERE] Metropolis: Unable to save WorldGuard regions."));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
public int getNumPlots(String name) {
|
||||
// TODO Auto-generated method stub
|
||||
return 1;
|
||||
if(_ownedPlots.containsKey(name)){
|
||||
List<Plot> plots = _ownedPlots.get(name);
|
||||
if(plots == null){
|
||||
return 0;
|
||||
}else{
|
||||
return plots.size();
|
||||
}
|
||||
}else{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
public void assignPlot(Player player) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
public int getMaxPlots(String name) {
|
||||
if(_userOverrides.containsKey(name)){
|
||||
return _userOverrides.get(name).getMaxPlots();
|
||||
}else{
|
||||
return _maxPlots;
|
||||
}
|
||||
}
|
||||
|
||||
public String setCurrentHome(Player player, int homeNumber) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public void assignPlot(OfflinePlayer player) {
|
||||
//PlayerHome home = generateHome(player.getName());
|
||||
generateHome(player.getName());
|
||||
}
|
||||
|
||||
private int getPlotMultiplier(String name) {
|
||||
if(_userOverrides.containsKey(name)){
|
||||
return _userOverrides.get(name).getPlotMultiplier();
|
||||
}else{
|
||||
return _plotMultiplier;
|
||||
}
|
||||
}
|
||||
|
||||
public Plot getPlot(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
/**
|
||||
* string is the name of the region to get a plot for
|
||||
*
|
||||
* loop through all regions and find one with the specified name return null if there is none
|
||||
*/
|
||||
for(Plot plot : _occupiedPlots){
|
||||
if(plot.getRegionName().equals(string)){
|
||||
return plot;
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Player getPlayer(String string) {
|
||||
// TODO Auto-generated method stub
|
||||
return null;
|
||||
public Player getPlayer(String name) {
|
||||
return getServer().getPlayer(name);
|
||||
}
|
||||
|
||||
public OfflinePlayer getOfflinePlayer(String name){
|
||||
return getServer().getOfflinePlayer(name);
|
||||
}
|
||||
|
||||
public String teleportPlayerToPlot(Player player, Plot plot) {
|
||||
// TODO Auto-generated method stub
|
||||
Location loc = plot.getViableSpawnLocation(world);
|
||||
|
||||
if(loc != null){
|
||||
player.teleport(loc);
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean homeExists(String playerName, int homeNumber) {
|
||||
for(Plot plot: _occupiedPlots){
|
||||
if(plot.getRegionName().equalsIgnoreCase(String.format("h_%d_%s", homeNumber, playerName))){
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setHome(String name, int newHomeNumber) {
|
||||
_currentHomes.put(name, newHomeNumber);
|
||||
saveCurrentHomes();
|
||||
}
|
||||
|
||||
private void saveCurrentHomes() {
|
||||
File outFile = new File(getDataFolder(), "currentHomes.yml");
|
||||
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
//YAMLProcessor processor = new YAMLProcessor(new File(getDataFolder(), "currentHomes.yml"), true);
|
||||
//processor.save();
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,6 @@ import javax.persistence.Table;
|
||||
import com.avaje.ebean.validation.NotNull;
|
||||
import com.sk89q.worldedit.BlockVector;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedCuboidRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedPolygonalRegion;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
@Entity()
|
||||
@@ -16,6 +15,8 @@ public class PlayerHome extends Plot{
|
||||
private String playerName;
|
||||
public String getPlayerName(){return this.playerName;}
|
||||
public void setPlayerName(String playerName){this.playerName = playerName;}
|
||||
|
||||
private int number;
|
||||
|
||||
public PlayerHome(String owner, BlockVector min, BlockVector max) {
|
||||
super("h_" + owner, min, max);
|
||||
@@ -27,24 +28,30 @@ public class PlayerHome extends Plot{
|
||||
}
|
||||
|
||||
public PlayerHome(ProtectedRegion homeRegion){
|
||||
if(homeRegion instanceof ProtectedCuboidRegion){
|
||||
ProtectedCuboidRegion cuboidRegion = (ProtectedCuboidRegion) homeRegion;
|
||||
if(cuboidRegion.getId().startsWith("h_") && cuboidRegion.getId().length() > 2){
|
||||
this.playerName = cuboidRegion.getId().substring(2);
|
||||
}else{
|
||||
this.playerName = cuboidRegion.getId();
|
||||
}
|
||||
try{
|
||||
String rname = homeRegion.getId();
|
||||
|
||||
setCuboid(new Cuboid(cuboidRegion.getMinimumPoint(), cuboidRegion.getMaximumPoint()));
|
||||
}else if(homeRegion instanceof ProtectedPolygonalRegion){
|
||||
ProtectedPolygonalRegion polygonalRegion = (ProtectedPolygonalRegion)homeRegion;
|
||||
if(polygonalRegion.getId().startsWith("h_") && polygonalRegion.getId().length() > 2){
|
||||
this.playerName = polygonalRegion.getId().substring(2);
|
||||
}else{
|
||||
this.playerName = polygonalRegion.getId();
|
||||
if(rname.startsWith("h_")){
|
||||
int secondUnderscore = rname.indexOf('_', 2);
|
||||
if(secondUnderscore > 2){
|
||||
try{
|
||||
this.number = Integer.parseInt(rname.substring(2, secondUnderscore));
|
||||
this.playerName = rname.substring(secondUnderscore+1);
|
||||
}catch(Exception ex){
|
||||
this.number = 0;
|
||||
}
|
||||
}else{
|
||||
this.number = 0;
|
||||
this.playerName = rname.substring(2);
|
||||
}
|
||||
|
||||
setCuboid(new Cuboid(homeRegion.getMinimumPoint(), homeRegion.getMaximumPoint()));
|
||||
}
|
||||
|
||||
setCuboid(new Cuboid(polygonalRegion.getMinimumPoint(), polygonalRegion.getMaximumPoint()));
|
||||
else{
|
||||
throw new RuntimeException("Method not implemented.");
|
||||
}
|
||||
}catch(Exception ex){
|
||||
throw new RuntimeException("Method not implemented.", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,4 +89,12 @@ public class PlayerHome extends Plot{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Integer getNumber() {
|
||||
return number;
|
||||
}
|
||||
|
||||
public void setNumber(int number){
|
||||
this.number = number;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis;
|
||||
|
||||
public class UserOverride {
|
||||
private String _username;
|
||||
private int _plotMultiplier;
|
||||
private int _maxPlots;
|
||||
|
||||
public String getUsername(){return _username;}
|
||||
public int getPlotMultiplier(){return _plotMultiplier;}
|
||||
public int getMaxPlots(){return _maxPlots;}
|
||||
|
||||
public UserOverride(String username, int plotMultiplier, int maxPlots){
|
||||
_username = username;
|
||||
_plotMultiplier = plotMultiplier;
|
||||
_maxPlots = maxPlots;
|
||||
}
|
||||
}
|
||||
@@ -1,23 +1,24 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
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 MetropolisCommand implements CommandExecutor {
|
||||
private MetropolisPlugin _plugin;
|
||||
|
||||
public MetropolisCommand(MetropolisPlugin plugin){
|
||||
_plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
|
||||
sender.sendMessage("Metropolis: version "+ _plugin.pdf.getVersion());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
import com.majinnaibu.bukkitplugins.metropolis.MetropolisPlugin;
|
||||
import com.sk89q.worldguard.protection.regions.ProtectedRegion;
|
||||
|
||||
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) {
|
||||
//get the player and region
|
||||
String playerName = "";
|
||||
|
||||
if(args.length == 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
if(args.length >= 1){
|
||||
playerName = args[0];
|
||||
}
|
||||
|
||||
OfflinePlayer player = _plugin.getServer().getOfflinePlayer(playerName);
|
||||
if(player == null){
|
||||
sender.sendMessage(String.format("The requested player {%s}does not appear to exist.", playerName));
|
||||
return false;
|
||||
}
|
||||
|
||||
ProtectedRegion region = _plugin.getRegion(String.format("h_%s", player.getName()));
|
||||
if(region == null){
|
||||
sender.sendMessage(String.format("The player {%s} has no home to be evicted from."));
|
||||
return false;
|
||||
}
|
||||
|
||||
//remove the player as owner and/or member of the region
|
||||
region.getMembers().removePlayer(playerName);
|
||||
region.getOwners().removePlayer(playerName);
|
||||
|
||||
//if the region has no owners delete the region
|
||||
if(region.getMembers().size() == 0 && region.getOwners().size() == 0){
|
||||
_plugin.removeRegion(region.getId());
|
||||
}
|
||||
|
||||
_plugin.saveRegions();
|
||||
|
||||
//?optionally regen the region
|
||||
//_plugin.worldEdit.getCommand("regen").execute(_plugin.getServer().getConsoleSender(), "regen", new String[]{});
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,9 +1,9 @@
|
||||
package com.majinnaibu.bukkitplugins.metropolis.commands;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
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;
|
||||
|
||||
@@ -16,40 +16,38 @@ public class MetropolisHomeMoveCommand implements CommandExecutor {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
Player player = null;
|
||||
int homeNumber = 0;
|
||||
OfflinePlayer player = null;
|
||||
int newHomeNumber = 0;
|
||||
|
||||
if(sender instanceof Player){
|
||||
player = (Player) sender;
|
||||
if(sender instanceof OfflinePlayer){
|
||||
player = (OfflinePlayer)sender;
|
||||
}
|
||||
|
||||
|
||||
if(args.length == 1 && player != null){
|
||||
if(args.length == 1){
|
||||
try{
|
||||
homeNumber = Integer.parseInt(args[0]);
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
}else if(args.length >= 2){
|
||||
try{
|
||||
homeNumber = Integer.parseInt(args[0]);
|
||||
newHomeNumber = Integer.parseInt(args[0]);
|
||||
}catch(NumberFormatException ex){
|
||||
return false;
|
||||
}
|
||||
|
||||
player = _plugin.getOfflinePlayer(args[1]);
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
|
||||
if(homeNumber <= 0){
|
||||
return false;
|
||||
}
|
||||
|
||||
String errorMessage = _plugin.setCurrentHome(player, homeNumber);
|
||||
if(errorMessage != null){
|
||||
sender.sendMessage(errorMessage);
|
||||
if(player == null || !_plugin.homeExists(player.getName(), newHomeNumber)){
|
||||
return false;
|
||||
}
|
||||
|
||||
_plugin.setHome(player.getName(), newHomeNumber);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
plot:
|
||||
sizeX: 24
|
||||
sizeZ: 24
|
||||
sizeX: 32
sizeY: 256
|
||||
sizeZ: 32
offsetX: 0
offsetY: 0
offsetZ: 0
multiplier: 1
maxPerPlayer: 1
initial: 1
|
||||
floor:
|
||||
generate: true
|
||||
clearSpaceAbove: 66
|
||||
@@ -9,8 +9,7 @@ plot:
|
||||
generate: true
|
||||
material: 1
|
||||
sign:
|
||||
generate: true
|
||||
road:
|
||||
generate: true
road:
|
||||
width: 4
|
||||
clearSpaceAbove: 66
|
||||
level: 62
|
||||
@@ -27,3 +26,10 @@ wall:
|
||||
material: 7
|
||||
height: 66
|
||||
worldname: world
|
||||
userOverrides:
|
||||
- username: majinnaibu
|
||||
plotMultiplier: 2
|
||||
maxPlots: 2
|
||||
- username: hoggrim
|
||||
plotMultiplier: 2
|
||||
maxPlots: 2
|
||||
@@ -4,4 +4,7 @@ depend: [WorldGuard]
|
||||
softdepend: [WorldEdit,CommandBook]
|
||||
version: 0.5
|
||||
database: false
|
||||
commands:
metropolis-home-acquire:
description: This command allocates a home.
permission: metropolis.home.acquire
usage: /metropolis-home-acquire
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-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>
metropolis-home-go:
description: Teleports the user or another player to his home.
permission: metropolis.home.go
usage: /metropolis-home-go
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-plot-go:
description: This command teleports the user or another player to a plot.
permission: metropolis.plot.go
usage: /metropolis-plot-go <plotName> [playerName]
metropolis-debug-generatetesthomes:
description: This command is ignored on non-debug builds.
permission: metropolis.debug
usage: /metropolis-debug-gentesthomes
|
||||
commands:
|
||||
metropolis:
|
||||
description: This command displays the current metropolis version.
|
||||
usage: /metropolis
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-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 <newHomeNumber> [player]
metropolis-home-go:
description: Teleports the user or another player to his home.
permission: metropolis.home.go
usage: /metropolis-home-go
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-plot-go:
description: This command teleports the user or another player to a plot.
permission: metropolis.plot.go
usage: /metropolis-plot-go <plotName> [playerName]
metropolis-debug-generatetesthomes:
description: This command is ignored on non-debug builds.
permission: metropolis.debug
usage: /metropolis-debug-gentesthomes
|
||||
Reference in New Issue
Block a user