/dxl enter: Allow player names instead of group names

This commit is contained in:
Daniel Saukel 2016-08-02 23:03:24 +02:00
parent 6d543c22be
commit 7abca6543b

View File

@ -24,6 +24,7 @@ import io.github.dre2n.dungeonsxl.game.Game;
import io.github.dre2n.dungeonsxl.player.DGamePlayer;
import io.github.dre2n.dungeonsxl.player.DGroup;
import io.github.dre2n.dungeonsxl.player.DPermissions;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
@ -51,6 +52,13 @@ public class EnterCommand extends BRCommand {
DGroup joining = args.length == 3 ? DGroup.getByName(args[1]) : DGroup.getByPlayer(captain);
DGroup target = DGroup.getByName(targetName);
if (target == null) {
Player targetPlayer = Bukkit.getPlayer(targetName);
if (targetPlayer != null) {
target = DGroup.getByPlayer(targetPlayer);
}
}
if (target == null) {
MessageUtil.sendMessage(sender, DMessages.ERROR_NO_SUCH_GROUP.getMessage(targetName));
return;