mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-14 14:45:31 +01:00
Fix /dxl leave outside a dungeon
This commit is contained in:
parent
b38f41851d
commit
6e43b559b6
@ -22,6 +22,7 @@ import io.github.dre2n.dungeonsxl.DungeonsXL;
|
||||
import io.github.dre2n.dungeonsxl.config.DMessages;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerEscapeEvent;
|
||||
import io.github.dre2n.dungeonsxl.event.dplayer.DPlayerLeaveDGroupEvent;
|
||||
import io.github.dre2n.dungeonsxl.player.DGlobalPlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DGroup;
|
||||
import io.github.dre2n.dungeonsxl.player.DInstancePlayer;
|
||||
import io.github.dre2n.dungeonsxl.player.DPermissions;
|
||||
@ -49,12 +50,7 @@ public class LeaveCommand extends BRCommand {
|
||||
public void onExecute(String[] args, CommandSender sender) {
|
||||
Player player = (Player) sender;
|
||||
|
||||
if (!(plugin.getDPlayers().getByPlayer(player) instanceof DInstancePlayer)) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_NOT_IN_DUNGEON.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
DInstancePlayer dPlayer = (DInstancePlayer) plugin.getDPlayers().getByPlayer(player);
|
||||
DGlobalPlayer dPlayer = plugin.getDPlayers().getByPlayer(player);
|
||||
|
||||
if (GameWorld.getByWorld(player.getWorld()) != null) {
|
||||
if (GameWorld.getByWorld(player.getWorld()).isTutorial()) {
|
||||
@ -63,28 +59,30 @@ public class LeaveCommand extends BRCommand {
|
||||
}
|
||||
}
|
||||
|
||||
if (dPlayer != null) {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
|
||||
DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent);
|
||||
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
|
||||
|
||||
if (dPlayerEscapeEvent.isCancelled() || dPlayerLeaveDGroupEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
dPlayer.leave();
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_LEAVE_SUCCESS.getMessage());
|
||||
|
||||
} else {
|
||||
DGroup dGroup = DGroup.getByPlayer(player);
|
||||
if (dGroup != null) {
|
||||
dGroup.removePlayer(player);
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_LEAVE_SUCCESS.getMessage());
|
||||
}
|
||||
if (dGroup == null) {
|
||||
MessageUtil.sendMessage(player, DMessages.ERROR_JOIN_GROUP.getMessage());
|
||||
return;
|
||||
}
|
||||
|
||||
DPlayerEscapeEvent dPlayerEscapeEvent = new DPlayerEscapeEvent(dPlayer);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerEscapeEvent);
|
||||
DPlayerLeaveDGroupEvent dPlayerLeaveDGroupEvent = new DPlayerLeaveDGroupEvent(dPlayer, dGroup);
|
||||
plugin.getServer().getPluginManager().callEvent(dPlayerLeaveDGroupEvent);
|
||||
|
||||
if (dPlayerEscapeEvent.isCancelled() || dPlayerLeaveDGroupEvent.isCancelled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (dPlayer instanceof DInstancePlayer) {
|
||||
((DInstancePlayer) dPlayer).leave();
|
||||
} else {
|
||||
dGroup.removePlayer(player);
|
||||
}
|
||||
|
||||
MessageUtil.sendMessage(player, DMessages.CMD_LEAVE_SUCCESS.getMessage());
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user