mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 13:16:45 +01:00
Allow configuring a separate nonmember home position
This commit is contained in:
parent
c645c4a6cb
commit
6b55b8cd67
@ -1147,7 +1147,7 @@ public class Plot {
|
||||
public Location getHome() {
|
||||
BlockLoc home = this.getPosition();
|
||||
if (home == null || home.x == 0 && home.z == 0) {
|
||||
return this.getDefaultHome();
|
||||
return this.getDefaultHome(true);
|
||||
} else {
|
||||
Location bot = this.getBottomAbs();
|
||||
Location loc = new Location(bot.getWorld(), bot.getX() + home.x, bot.getY() + home.y, bot.getZ() + home.z, home.yaw, home.pitch);
|
||||
@ -1182,11 +1182,16 @@ public class Plot {
|
||||
* @return
|
||||
*/
|
||||
public Location getDefaultHome() {
|
||||
return getDefaultHome(false);
|
||||
}
|
||||
|
||||
public Location getDefaultHome(boolean member) {
|
||||
Plot plot = this.getBasePlot(false);
|
||||
if (this.area.DEFAULT_HOME != null) {
|
||||
PlotLoc loc = member ? area.DEFAULT_HOME : area.NONMEMBER_HOME;
|
||||
if (loc != null) {
|
||||
int x;
|
||||
int z;
|
||||
if (this.area.DEFAULT_HOME.x == Integer.MAX_VALUE && this.area.DEFAULT_HOME.z == Integer.MAX_VALUE) {
|
||||
if (loc.x == Integer.MAX_VALUE && loc.z == Integer.MAX_VALUE) {
|
||||
// center
|
||||
RegionWrapper largest = plot.getLargestRegion();
|
||||
x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
||||
@ -1194,8 +1199,8 @@ public class Plot {
|
||||
} else {
|
||||
// specific
|
||||
Location bot = plot.getBottomAbs();
|
||||
x = bot.getX() + this.area.DEFAULT_HOME.x;
|
||||
z = bot.getZ() + this.area.DEFAULT_HOME.z;
|
||||
x = bot.getX() + loc.x;
|
||||
z = bot.getZ() + loc.z;
|
||||
}
|
||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 64;
|
||||
return new Location(plot.getWorldName(), x, y + 1, z);
|
||||
@ -2600,7 +2605,7 @@ public class Plot {
|
||||
if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||
location = this.getHome();
|
||||
} else {
|
||||
location = this.getDefaultHome();
|
||||
location = this.getDefaultHome(false);
|
||||
}
|
||||
if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||
|
@ -68,6 +68,7 @@ public abstract class PlotArea {
|
||||
public int TYPE = 0;
|
||||
public int TERRAIN = 0;
|
||||
public boolean HOME_ALLOW_NONMEMBER = false;
|
||||
public PlotLoc NONMEMBER_HOME;
|
||||
public PlotLoc DEFAULT_HOME;
|
||||
public int MAX_BUILD_HEIGHT = 256;
|
||||
public int MIN_BUILD_HEIGHT = 1;
|
||||
@ -265,8 +266,17 @@ public abstract class PlotArea {
|
||||
break;
|
||||
}
|
||||
|
||||
this.HOME_ALLOW_NONMEMBER = config.getBoolean("home.allow-nonmembers");
|
||||
String homeNonMembers = config.getString("home.nonmembers");
|
||||
String homeDefault = config.getString("home.default");
|
||||
this.DEFAULT_HOME = PlotLoc.fromString(homeDefault);
|
||||
this.HOME_ALLOW_NONMEMBER = homeNonMembers.equalsIgnoreCase(homeDefault);
|
||||
if (this.HOME_ALLOW_NONMEMBER) {
|
||||
this.NONMEMBER_HOME = DEFAULT_HOME;
|
||||
} else {
|
||||
this.NONMEMBER_HOME = PlotLoc.fromString(homeNonMembers);
|
||||
}
|
||||
|
||||
|
||||
if ("side".equalsIgnoreCase(homeDefault)) {
|
||||
this.DEFAULT_HOME = null;
|
||||
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
|
||||
@ -338,7 +348,8 @@ public abstract class PlotArea {
|
||||
options.put("world.border", this.WORLD_BORDER);
|
||||
options.put("limits.max-members", this.MAX_PLOT_MEMBERS);
|
||||
options.put("home.default", "side");
|
||||
options.put("home.allow-nonmembers", false);
|
||||
String position = config.getString("home.nonmembers", config.getBoolean("home.allow-nonmembers", false) ? config.getString("home.default", "side") : "side");
|
||||
options.put("home.nonmembers", position);
|
||||
options.put("world.max_height", this.MAX_BUILD_HEIGHT);
|
||||
options.put("world.min_height", this.MIN_BUILD_HEIGHT);
|
||||
options.put("world.gamemode", this.GAMEMODE.name().toLowerCase());
|
||||
|
@ -1,5 +1,7 @@
|
||||
package com.intellectualcrafters.plot.object;
|
||||
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
|
||||
public class PlotLoc {
|
||||
public int x;
|
||||
public int z;
|
||||
@ -9,6 +11,21 @@ public class PlotLoc {
|
||||
this.z = z;
|
||||
}
|
||||
|
||||
public static PlotLoc fromString(String input) {
|
||||
if ("side".equalsIgnoreCase(input)) {
|
||||
return null;
|
||||
} else if (StringMan.isEqualIgnoreCaseToAny(input, "center", "middle")) {
|
||||
return new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
||||
} else {
|
||||
try {
|
||||
String[] split = input.split(",");
|
||||
return new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));
|
||||
} catch (NumberFormatException ignored) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
int prime = 31;
|
||||
|
Loading…
Reference in New Issue
Block a user