mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-26 04:25:37 +01:00
Should fix issue where gamemode/flight change on /reload of server due to permission issues.
This commit is contained in:
parent
360c63fad9
commit
07a38e3e58
@ -336,36 +336,37 @@ public class MVPlayerListener implements Listener {
|
|||||||
public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) {
|
public void handleGameModeAndFlight(final Player player, final MultiverseWorld world) {
|
||||||
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
// We perform this task one tick later to MAKE SURE that the player actually reaches the
|
||||||
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
|
// destination world, otherwise we'd be changing the player mode if they havent moved anywhere.
|
||||||
if (!this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
|
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
||||||
this.plugin.getServer().getScheduler().scheduleSyncDelayedTask(this.plugin,
|
|
||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
if (!MVPlayerListener.this.pt.playerCanIgnoreGameModeRestriction(world, player)) {
|
||||||
if (player.getWorld() == world.getCBWorld()) {
|
// Check that the player is in the new world and they haven't been teleported elsewhere or the event cancelled.
|
||||||
Logging.fine("Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString());
|
if (player.getWorld() == world.getCBWorld()) {
|
||||||
Logging.finest("From World: %s", player.getWorld());
|
Logging.fine("Handling gamemode for player: %s, Changing to %s", player.getName(), world.getGameMode().toString());
|
||||||
Logging.finest("To World: %s", world);
|
Logging.finest("From World: %s", player.getWorld());
|
||||||
player.setGameMode(world.getGameMode());
|
Logging.finest("To World: %s", world);
|
||||||
|
player.setGameMode(world.getGameMode());
|
||||||
|
// Check if their flight mode should change
|
||||||
|
// TODO need a override permission for this
|
||||||
|
if (player.getAllowFlight() && !world.getAllowFlight() && player.getGameMode() != GameMode.CREATIVE) {
|
||||||
|
player.setAllowFlight(false);
|
||||||
|
if (player.isFlying()) {
|
||||||
|
player.setFlying(false);
|
||||||
|
}
|
||||||
|
} else if (world.getAllowFlight()) {
|
||||||
|
if (player.getGameMode() == GameMode.CREATIVE) {
|
||||||
|
player.setAllowFlight(true);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
Logging.fine("The gamemode/allowfly was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
|
||||||
|
player.getName(), player.getWorld().getName(), world.getName());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
Logging.fine("The gamemode was NOT changed for player '%s' because he is now in world '%s' instead of world '%s'",
|
MVPlayerListener.this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
||||||
player.getName(), player.getWorld().getName(), world.getName());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}, 1L);
|
}, 1L);
|
||||||
} else {
|
|
||||||
this.plugin.log(Level.FINE, "Player: " + player.getName() + " is IMMUNE to gamemode changes!");
|
|
||||||
}
|
|
||||||
// TODO need a override permission for this
|
|
||||||
if (player.getAllowFlight() && !world.getAllowFlight() && player.getGameMode() != GameMode.CREATIVE) {
|
|
||||||
player.setAllowFlight(false);
|
|
||||||
if (player.isFlying()) {
|
|
||||||
player.setFlying(false);
|
|
||||||
}
|
|
||||||
} else if (world.getAllowFlight()) {
|
|
||||||
if (player.getGameMode() == GameMode.CREATIVE) {
|
|
||||||
player.setAllowFlight(true);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user