mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-09-07 01:08:40 +02:00
Fixes
Fix plot time / gamemode on teleport to another plot. Fix gamemode bypass on plot leave
This commit is contained in:
parent
fead432dbc
commit
404933c3a7
@ -105,7 +105,7 @@ public enum C {
|
||||
WORLDEDIT_UNMASKED("$1Your WorldEdit is now unrestricted.", "WorldEdit Masks"),
|
||||
WORLDEDIT_RESTRICTED("$1Your WorldEdit is now restricted.", "WorldEdit Masks"),
|
||||
|
||||
GAMEMODE_WAS_BYPASSED("$1You bypassed the gamemode ($2{gamemode}$1) $1set for this plot", "Gamemode"),
|
||||
GAMEMODE_WAS_BYPASSED("$1You bypassed the gamemode ($2{gamemode}$1) $1set for $2{plot}", "Gamemode"),
|
||||
HEIGHT_LIMIT("$1This plot world has a height limit of $2{limit}", "Height Limit"),
|
||||
/*
|
||||
* Records
|
||||
|
@ -453,15 +453,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, getInt(to.getZ()));
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotId lastId = (PlotId) pp.getMeta("lastplotid");
|
||||
Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
if (lastId == null) {
|
||||
if (lastPlot == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(worldname, lastId);
|
||||
if (!plotExit(pp, plot)) {
|
||||
if (!plotExit(pp, lastPlot)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
|
||||
if (plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
player.teleport(from);
|
||||
}
|
||||
else {
|
||||
@ -471,7 +470,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (id.equals(lastId)) {
|
||||
else if (lastPlot != null && id.equals(lastPlot.id)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
@ -516,15 +515,14 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
PlotId id = plotManager.getPlotId(plotworld, x2, 0, z2);
|
||||
Player player = event.getPlayer();
|
||||
PlotPlayer pp = BukkitUtil.getPlayer(player);
|
||||
PlotId lastId = (PlotId) pp.getMeta("lastplotid");
|
||||
Plot lastPlot = (Plot) pp.getMeta("lastplot");
|
||||
if (id == null) {
|
||||
if (lastId == null) {
|
||||
if (lastPlot == null) {
|
||||
return;
|
||||
}
|
||||
Plot plot = MainUtil.getPlot(worldname, lastId);
|
||||
if (!plotExit(pp, plot)) {
|
||||
if (!plotExit(pp, lastPlot)) {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION, "plots.admin.exit.denied");
|
||||
if (plot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
if (lastPlot.equals(MainUtil.getPlot(BukkitUtil.getLocation(from)))) {
|
||||
player.teleport(from);
|
||||
}
|
||||
else {
|
||||
@ -534,7 +532,7 @@ public class PlayerEvents extends com.intellectualcrafters.plot.listeners.PlotLi
|
||||
return;
|
||||
}
|
||||
}
|
||||
else if (id.equals(lastId)) {
|
||||
else if (lastPlot != null && id.equals(lastPlot.id)) {
|
||||
return;
|
||||
}
|
||||
else {
|
||||
|
@ -104,7 +104,11 @@ public class PlotListener extends APlotListener {
|
||||
if (plot.isDenied(pp.getUUID()) && !Permissions.hasPermission(pp, "plots.admin.entry.denied")) {
|
||||
return false;
|
||||
}
|
||||
pp.setMeta("lastplotid", plot.id);
|
||||
Plot last = (Plot) pp.getMeta("lastplot");
|
||||
if (last != null && !last.id.equals(plot.id)) {
|
||||
plotExit(pp, last);
|
||||
}
|
||||
pp.setMeta("lastplot", plot);
|
||||
final Player player = ((BukkitPlayer) pp).player;
|
||||
if (plot.hasOwner()) {
|
||||
final PlayerEnterPlotEvent callEvent = new PlayerEnterPlotEvent(player, plot);
|
||||
@ -130,14 +134,13 @@ public class PlotListener extends APlotListener {
|
||||
|
||||
final Flag gamemodeFlag = flags.get("gamemode");
|
||||
if (gamemodeFlag != null) {
|
||||
if (!player.hasPermission("plots.gamemode.bypass")) {
|
||||
player.setGameMode(getGameMode(gamemodeFlag.getValueString()));
|
||||
} else {
|
||||
MainUtil.sendMessage(
|
||||
pp,
|
||||
C.GAMEMODE_WAS_BYPASSED.s().replace("{plot}", plot.getId().toString()).replace("{gamemode}", gamemodeFlag.getValueString()),
|
||||
true
|
||||
);
|
||||
if (player.getGameMode() != getGameMode(gamemodeFlag.getValueString())) {
|
||||
if (!player.hasPermission("plots.gamemode.bypass")) {
|
||||
player.setGameMode(getGameMode(gamemodeFlag.getValueString()));
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.id, "{gamemode}", gamemodeFlag.getValue()));
|
||||
}
|
||||
}
|
||||
}
|
||||
final Flag flyFlag = flags.get("fly");
|
||||
@ -221,7 +224,7 @@ public class PlotListener extends APlotListener {
|
||||
}
|
||||
|
||||
public boolean plotExit(final PlotPlayer pp, final Plot plot) {
|
||||
pp.deleteMeta("lastplotid");
|
||||
pp.deleteMeta("lastplot");
|
||||
Player player = ((BukkitPlayer) pp).player;
|
||||
final PlayerLeavePlotEvent callEvent = new PlayerLeavePlotEvent(player, plot);
|
||||
Bukkit.getPluginManager().callEvent(callEvent);
|
||||
@ -229,7 +232,14 @@ public class PlotListener extends APlotListener {
|
||||
player.setAllowFlight(Bukkit.getAllowFlight());
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "gamemode") != null) {
|
||||
player.setGameMode(Bukkit.getDefaultGameMode());
|
||||
if (player.getGameMode() != Bukkit.getDefaultGameMode()) {
|
||||
if (!player.hasPermission("plots.gamemode.bypass")) {
|
||||
player.setGameMode(Bukkit.getDefaultGameMode());
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(pp, StringMan.replaceAll(C.GAMEMODE_WAS_BYPASSED.s(), "{plot}", plot.world, "{gamemode}", Bukkit.getDefaultGameMode().name().toLowerCase()));
|
||||
}
|
||||
}
|
||||
}
|
||||
if (FlagManager.getPlotFlag(plot, "time") != null) {
|
||||
player.resetPlayerTime();
|
||||
|
Loading…
Reference in New Issue
Block a user