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