mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-26 07:06:44 +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() {
|
public Location getHome() {
|
||||||
BlockLoc home = this.getPosition();
|
BlockLoc home = this.getPosition();
|
||||||
if (home == null || home.x == 0 && home.z == 0) {
|
if (home == null || home.x == 0 && home.z == 0) {
|
||||||
return this.getDefaultHome();
|
return this.getDefaultHome(true);
|
||||||
} else {
|
} else {
|
||||||
Location bot = this.getBottomAbs();
|
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);
|
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
|
* @return
|
||||||
*/
|
*/
|
||||||
public Location getDefaultHome() {
|
public Location getDefaultHome() {
|
||||||
|
return getDefaultHome(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Location getDefaultHome(boolean member) {
|
||||||
Plot plot = this.getBasePlot(false);
|
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 x;
|
||||||
int z;
|
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
|
// center
|
||||||
RegionWrapper largest = plot.getLargestRegion();
|
RegionWrapper largest = plot.getLargestRegion();
|
||||||
x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
x = (largest.maxX >> 1) - (largest.minX >> 1) + largest.minX;
|
||||||
@ -1194,8 +1199,8 @@ public class Plot {
|
|||||||
} else {
|
} else {
|
||||||
// specific
|
// specific
|
||||||
Location bot = plot.getBottomAbs();
|
Location bot = plot.getBottomAbs();
|
||||||
x = bot.getX() + this.area.DEFAULT_HOME.x;
|
x = bot.getX() + loc.x;
|
||||||
z = bot.getZ() + this.area.DEFAULT_HOME.z;
|
z = bot.getZ() + loc.z;
|
||||||
}
|
}
|
||||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 64;
|
int y = isLoaded() ? WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z) : 64;
|
||||||
return new Location(plot.getWorldName(), x, y + 1, z);
|
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())) {
|
if (this.area.HOME_ALLOW_NONMEMBER || plot.isAdded(player.getUUID())) {
|
||||||
location = this.getHome();
|
location = this.getHome();
|
||||||
} else {
|
} else {
|
||||||
location = this.getDefaultHome();
|
location = this.getDefaultHome(false);
|
||||||
}
|
}
|
||||||
if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
if (Settings.Teleport.DELAY == 0 || Permissions.hasPermission(player, "plots.teleport.delay.bypass")) {
|
||||||
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
MainUtil.sendMessage(player, C.TELEPORTED_TO_PLOT);
|
||||||
|
@ -68,6 +68,7 @@ public abstract class PlotArea {
|
|||||||
public int TYPE = 0;
|
public int TYPE = 0;
|
||||||
public int TERRAIN = 0;
|
public int TERRAIN = 0;
|
||||||
public boolean HOME_ALLOW_NONMEMBER = false;
|
public boolean HOME_ALLOW_NONMEMBER = false;
|
||||||
|
public PlotLoc NONMEMBER_HOME;
|
||||||
public PlotLoc DEFAULT_HOME;
|
public PlotLoc DEFAULT_HOME;
|
||||||
public int MAX_BUILD_HEIGHT = 256;
|
public int MAX_BUILD_HEIGHT = 256;
|
||||||
public int MIN_BUILD_HEIGHT = 1;
|
public int MIN_BUILD_HEIGHT = 1;
|
||||||
@ -265,8 +266,17 @@ public abstract class PlotArea {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.HOME_ALLOW_NONMEMBER = config.getBoolean("home.allow-nonmembers");
|
String homeNonMembers = config.getString("home.nonmembers");
|
||||||
String homeDefault = config.getString("home.default");
|
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)) {
|
if ("side".equalsIgnoreCase(homeDefault)) {
|
||||||
this.DEFAULT_HOME = null;
|
this.DEFAULT_HOME = null;
|
||||||
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
|
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
|
||||||
@ -338,7 +348,8 @@ public abstract class PlotArea {
|
|||||||
options.put("world.border", this.WORLD_BORDER);
|
options.put("world.border", this.WORLD_BORDER);
|
||||||
options.put("limits.max-members", this.MAX_PLOT_MEMBERS);
|
options.put("limits.max-members", this.MAX_PLOT_MEMBERS);
|
||||||
options.put("home.default", "side");
|
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.max_height", this.MAX_BUILD_HEIGHT);
|
||||||
options.put("world.min_height", this.MIN_BUILD_HEIGHT);
|
options.put("world.min_height", this.MIN_BUILD_HEIGHT);
|
||||||
options.put("world.gamemode", this.GAMEMODE.name().toLowerCase());
|
options.put("world.gamemode", this.GAMEMODE.name().toLowerCase());
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package com.intellectualcrafters.plot.object;
|
package com.intellectualcrafters.plot.object;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
|
|
||||||
public class PlotLoc {
|
public class PlotLoc {
|
||||||
public int x;
|
public int x;
|
||||||
public int z;
|
public int z;
|
||||||
@ -9,6 +11,21 @@ public class PlotLoc {
|
|||||||
this.z = z;
|
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
|
@Override
|
||||||
public int hashCode() {
|
public int hashCode() {
|
||||||
int prime = 31;
|
int prime = 31;
|
||||||
|
Loading…
Reference in New Issue
Block a user