mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Allow pitch and yaw to be used in default home location (#3304)
This commit is contained in:
parent
be85708e5a
commit
804228fa6c
@ -44,7 +44,6 @@ import com.plotsquared.core.listener.PlotListener;
|
|||||||
import com.plotsquared.core.location.BlockLoc;
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
|
||||||
import com.plotsquared.core.permissions.Permission;
|
import com.plotsquared.core.permissions.Permission;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -1506,7 +1505,7 @@ public class Plot {
|
|||||||
@Deprecated
|
@Deprecated
|
||||||
public Location getDefaultHomeSynchronous(final boolean member) {
|
public Location getDefaultHomeSynchronous(final boolean member) {
|
||||||
Plot plot = this.getBasePlot(false);
|
Plot plot = this.getBasePlot(false);
|
||||||
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
BlockLoc loc = member ? area.defaultHome() : area.nonmemberHome();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
int x;
|
int x;
|
||||||
int z;
|
int z;
|
||||||
@ -1525,10 +1524,10 @@ public class Plot {
|
|||||||
x = bot.getX() + loc.getX();
|
x = bot.getX() + loc.getX();
|
||||||
z = bot.getZ() + loc.getZ();
|
z = bot.getZ() + loc.getZ();
|
||||||
}
|
}
|
||||||
int y = loc.getY() < 1
|
int y = loc.getY() == Integer.MIN_VALUE
|
||||||
? (isLoaded() ? this.worldUtil.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 : 63)
|
? (isLoaded() ? this.worldUtil.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 : 63)
|
||||||
: loc.getY();
|
: loc.getY();
|
||||||
return Location.at(plot.getWorldName(), x, y, z);
|
return Location.at(plot.getWorldName(), x, y, z, loc.getYaw(), loc.getPitch());
|
||||||
}
|
}
|
||||||
// Side
|
// Side
|
||||||
return plot.getSideSynchronous();
|
return plot.getSideSynchronous();
|
||||||
@ -1545,7 +1544,7 @@ public class Plot {
|
|||||||
));
|
));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotLoc loc = member ? area.getDefaultHome() : area.getNonmemberHome();
|
BlockLoc loc = member ? area.defaultHome() : area.nonmemberHome();
|
||||||
if (loc != null) {
|
if (loc != null) {
|
||||||
int x;
|
int x;
|
||||||
int z;
|
int z;
|
||||||
@ -1564,7 +1563,7 @@ public class Plot {
|
|||||||
x = bot.getX() + loc.getX();
|
x = bot.getX() + loc.getX();
|
||||||
z = bot.getZ() + loc.getZ();
|
z = bot.getZ() + loc.getZ();
|
||||||
}
|
}
|
||||||
if (loc.getY() < 1) {
|
if (loc.getY() == Integer.MIN_VALUE) {
|
||||||
if (isLoaded()) {
|
if (isLoaded()) {
|
||||||
this.worldUtil.getHighestBlock(
|
this.worldUtil.getHighestBlock(
|
||||||
plot.getWorldName(),
|
plot.getWorldName(),
|
||||||
@ -1573,10 +1572,10 @@ public class Plot {
|
|||||||
y -> result.accept(Location.at(plot.getWorldName(), x, y + 1, z))
|
y -> result.accept(Location.at(plot.getWorldName(), x, y + 1, z))
|
||||||
);
|
);
|
||||||
} else {
|
} else {
|
||||||
result.accept(Location.at(plot.getWorldName(), x, 63, z));
|
result.accept(Location.at(plot.getWorldName(), x, 63, z, loc.getYaw(), loc.getPitch()));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
result.accept(Location.at(plot.getWorldName(), x, loc.getY(), z));
|
result.accept(Location.at(plot.getWorldName(), x, loc.getY(), z, loc.getYaw(), loc.getPitch()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -41,6 +41,7 @@ import com.plotsquared.core.configuration.file.YamlConfiguration;
|
|||||||
import com.plotsquared.core.generator.GridPlotWorld;
|
import com.plotsquared.core.generator.GridPlotWorld;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.inject.annotations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
@ -123,6 +124,7 @@ public abstract class PlotArea {
|
|||||||
new FlagContainer(GlobalFlagContainer.getInstance());
|
new FlagContainer(GlobalFlagContainer.getInstance());
|
||||||
private final YamlConfiguration worldConfiguration;
|
private final YamlConfiguration worldConfiguration;
|
||||||
private final GlobalBlockQueue globalBlockQueue;
|
private final GlobalBlockQueue globalBlockQueue;
|
||||||
|
private final boolean roadFlags = false;
|
||||||
private boolean autoMerge = false;
|
private boolean autoMerge = false;
|
||||||
private boolean allowSigns = true;
|
private boolean allowSigns = true;
|
||||||
private boolean miscSpawnUnowned = false;
|
private boolean miscSpawnUnowned = false;
|
||||||
@ -140,14 +142,13 @@ public abstract class PlotArea {
|
|||||||
private PlotAreaType type = PlotAreaType.NORMAL;
|
private PlotAreaType type = PlotAreaType.NORMAL;
|
||||||
private PlotAreaTerrainType terrain = PlotAreaTerrainType.NONE;
|
private PlotAreaTerrainType terrain = PlotAreaTerrainType.NONE;
|
||||||
private boolean homeAllowNonmember = false;
|
private boolean homeAllowNonmember = false;
|
||||||
private PlotLoc nonmemberHome;
|
private BlockLoc nonmemberHome;
|
||||||
private PlotLoc defaultHome;
|
private BlockLoc defaultHome;
|
||||||
private int maxBuildHeight = 256;
|
private int maxBuildHeight = 256;
|
||||||
private int minBuildHeight = 1;
|
private int minBuildHeight = 1;
|
||||||
private GameMode gameMode = GameModes.CREATIVE;
|
private GameMode gameMode = GameModes.CREATIVE;
|
||||||
private Map<String, PlotExpression> prices = new HashMap<>();
|
private Map<String, PlotExpression> prices = new HashMap<>();
|
||||||
private List<String> schematics = new ArrayList<>();
|
private List<String> schematics = new ArrayList<>();
|
||||||
private final boolean roadFlags = false;
|
|
||||||
private boolean worldBorder = false;
|
private boolean worldBorder = false;
|
||||||
private boolean useEconomy = false;
|
private boolean useEconomy = false;
|
||||||
private int hash;
|
private int hash;
|
||||||
@ -370,24 +371,24 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
String homeNonMembers = config.getString("home.nonmembers");
|
String homeNonMembers = config.getString("home.nonmembers");
|
||||||
String homeDefault = config.getString("home.default");
|
String homeDefault = config.getString("home.default");
|
||||||
this.defaultHome = PlotLoc.fromString(homeDefault);
|
this.defaultHome = BlockLoc.fromString(homeDefault);
|
||||||
this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
|
this.homeAllowNonmember = homeNonMembers.equalsIgnoreCase(homeDefault);
|
||||||
if (this.homeAllowNonmember) {
|
if (this.homeAllowNonmember) {
|
||||||
this.nonmemberHome = defaultHome;
|
this.nonmemberHome = defaultHome;
|
||||||
} else {
|
} else {
|
||||||
this.nonmemberHome = PlotLoc.fromString(homeNonMembers);
|
this.nonmemberHome = BlockLoc.fromString(homeNonMembers);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ("side".equalsIgnoreCase(homeDefault)) {
|
if ("side".equalsIgnoreCase(homeDefault)) {
|
||||||
this.defaultHome = null;
|
this.defaultHome = null;
|
||||||
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
|
} else if (StringMan.isEqualIgnoreCaseToAny(homeDefault, "center", "middle")) {
|
||||||
this.defaultHome = new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE);
|
this.defaultHome = new BlockLoc(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
/*String[] split = homeDefault.split(",");
|
/*String[] split = homeDefault.split(",");
|
||||||
this.DEFAULT_HOME =
|
this.DEFAULT_HOME =
|
||||||
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
|
new PlotLoc(Integer.parseInt(split[0]), Integer.parseInt(split[1]));*/
|
||||||
this.defaultHome = PlotLoc.fromString(homeDefault);
|
this.defaultHome = BlockLoc.fromString(homeDefault);
|
||||||
} catch (NumberFormatException ignored) {
|
} catch (NumberFormatException ignored) {
|
||||||
this.defaultHome = null;
|
this.defaultHome = null;
|
||||||
}
|
}
|
||||||
@ -1351,15 +1352,38 @@ public abstract class PlotArea {
|
|||||||
return this.homeAllowNonmember;
|
return this.homeAllowNonmember;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotLoc getNonmemberHome() {
|
/**
|
||||||
|
* Get the location for non-members to be teleported to.
|
||||||
|
*/
|
||||||
|
public BlockLoc nonmemberHome() {
|
||||||
return this.nonmemberHome;
|
return this.nonmemberHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotLoc getDefaultHome() {
|
/**
|
||||||
|
* Get the default location for players to be teleported to. May be overriden by {@link #nonmemberHome} if the player is
|
||||||
|
* not a member of the plot.
|
||||||
|
*/
|
||||||
|
public BlockLoc defaultHome() {
|
||||||
return this.defaultHome;
|
return this.defaultHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setDefaultHome(PlotLoc defaultHome) {
|
/**
|
||||||
|
* @deprecated Use {@link #nonmemberHome}
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
public PlotLoc getNonmemberHome() {
|
||||||
|
return new PlotLoc(this.defaultHome.getX(), this.defaultHome.getY(), this.defaultHome.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @deprecated Use {@link #defaultHome}
|
||||||
|
*/
|
||||||
|
@Deprecated(forRemoval = true)
|
||||||
|
public PlotLoc getDefaultHome() {
|
||||||
|
return new PlotLoc(this.defaultHome.getX(), this.defaultHome.getY(), this.defaultHome.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDefaultHome(BlockLoc defaultHome) {
|
||||||
this.defaultHome = defaultHome;
|
this.defaultHome = defaultHome;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,6 +35,7 @@ import com.plotsquared.core.generator.GridPlotWorld;
|
|||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
import com.plotsquared.core.inject.annotations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.location.PlotLoc;
|
import com.plotsquared.core.location.PlotLoc;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
@ -74,7 +75,7 @@ public class SinglePlotArea extends GridPlotWorld {
|
|||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
this.plotListener = plotListener;
|
this.plotListener = plotListener;
|
||||||
this.setAllowSigns(false);
|
this.setAllowSigns(false);
|
||||||
this.setDefaultHome(new PlotLoc(Integer.MAX_VALUE, Integer.MAX_VALUE));
|
this.setDefaultHome(new BlockLoc(Integer.MAX_VALUE, Integer.MIN_VALUE, Integer.MAX_VALUE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@NonNull
|
@NonNull
|
||||||
|
Loading…
Reference in New Issue
Block a user