mirror of
https://github.com/DRE2N/DungeonsXL.git
synced 2024-11-24 19:45:43 +01:00
Don't send leave notifications when players finish the dungeon
This commit is contained in:
parent
1e7e44f224
commit
01c869f897
@ -362,6 +362,14 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
/* Actions */
|
||||
@Override
|
||||
public void leave() {
|
||||
leave(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void leave(boolean message) {
|
||||
GameRules rules = Game.getByWorld(getWorld()).getRules();
|
||||
delete();
|
||||
|
||||
@ -380,7 +388,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
|
||||
DGroup dGroup = DGroup.getByPlayer(getPlayer());
|
||||
if (dGroup != null) {
|
||||
dGroup.removePlayer(getPlayer());
|
||||
dGroup.removePlayer(getPlayer(), message);
|
||||
}
|
||||
|
||||
GameWorld gameWorld = GameWorld.getByWorld(getWorld());
|
||||
@ -436,7 +444,9 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
// Captain here!
|
||||
Player newCaptain = dGroup.getPlayers().get(0);
|
||||
dGroup.setCaptain(newCaptain);
|
||||
if (message) {
|
||||
MessageUtil.sendMessage(newCaptain, DMessages.PLAYER_NEW_CAPTAIN.getMessage());
|
||||
}
|
||||
// ...*flies away*
|
||||
}
|
||||
}
|
||||
@ -608,6 +618,12 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* The DGamePlayer finishs the current floor.
|
||||
*
|
||||
* @param specifiedFloor
|
||||
* the name of the next floor
|
||||
*/
|
||||
public void finishFloor(String specifiedFloor) {
|
||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||
finished = true;
|
||||
@ -679,10 +695,17 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
dGroup.startGame(game);
|
||||
}
|
||||
|
||||
/**
|
||||
* The DGamePlayer finishs the current game.
|
||||
*/
|
||||
public void finish() {
|
||||
finish(true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param message
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void finish(boolean message) {
|
||||
if (message) {
|
||||
MessageUtil.sendMessage(getPlayer(), DMessages.PLAYER_FINISHED_DUNGEON.getMessage());
|
||||
@ -737,7 +760,7 @@ public class DGamePlayer extends DInstancePlayer {
|
||||
plugin.getServer().getPluginManager().callEvent(dGroupRewardEvent);
|
||||
for (Player player : dGroup.getPlayers()) {
|
||||
DGamePlayer dPlayer = getByPlayer(player);
|
||||
dPlayer.leave();
|
||||
dPlayer.leave(false);
|
||||
|
||||
if (!dGroupRewardEvent.isCancelled()) {
|
||||
for (Reward reward : dGroup.getRewards()) {
|
||||
|
@ -157,33 +157,59 @@ public class DGroup {
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages by default.
|
||||
*
|
||||
* @param player
|
||||
* the player to add
|
||||
*/
|
||||
public void addPlayer(Player player) {
|
||||
addPlayer(player, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* the player to add
|
||||
* @param message
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void addPlayer(Player player, boolean message) {
|
||||
DPlayerJoinDGroupEvent event = new DPlayerJoinDGroupEvent(DGamePlayer.getByPlayer(player), false, this);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled()) {
|
||||
sendMessage(plugin.getMessageConfig().getMessage(DMessages.GROUP_PLAYER_JOINED, player.getName()));
|
||||
MessageUtil.sendMessage(player, plugin.getMessageConfig().getMessage(DMessages.PLAYER_JOIN_GROUP));
|
||||
if (message) {
|
||||
sendMessage(DMessages.GROUP_PLAYER_JOINED.getMessage(player.getName()));
|
||||
MessageUtil.sendMessage(player, DMessages.PLAYER_JOIN_GROUP.getMessage());
|
||||
}
|
||||
|
||||
players.add(player);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Sends messages by default.
|
||||
*
|
||||
* @param player
|
||||
* the player to remove
|
||||
*/
|
||||
public void removePlayer(Player player) {
|
||||
removePlayer(player, true);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param player
|
||||
* the player to remove
|
||||
* @param message
|
||||
* if messages should be sent
|
||||
*/
|
||||
public void removePlayer(Player player, boolean message) {
|
||||
players.remove(player);
|
||||
GroupSign.updatePerGroup(this);
|
||||
|
||||
// Send message
|
||||
if (message) {
|
||||
sendMessage(plugin.getMessageConfig().getMessage(DMessages.PLAYER_LEFT_GROUP, player.getName()));
|
||||
}
|
||||
|
||||
// Check group
|
||||
if (isEmpty()) {
|
||||
DGroupDisbandEvent event = new DGroupDisbandEvent(this, player, DGroupDisbandEvent.Cause.GROUP_IS_EMPTY);
|
||||
plugin.getServer().getPluginManager().callEvent(event);
|
||||
|
Loading…
Reference in New Issue
Block a user