Skip to content

Commit

Permalink
leaveteam fix
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohuihui1022 committed Aug 24, 2023
1 parent 6ef7d78 commit 3a2b610
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

<groupId>top.mpt.huihui</groupId>
<artifactId>HighVersionQWQ</artifactId>
<version>1.1-SNAPSHOT</version>
<version>1.2-SNAPSHOT</version>
<packaging>jar</packaging>

<name>HighVersionQWQ</name>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ public class LeaveTeam implements CommandExecutor {
@Override
public boolean onCommand(CommandSender commandSender, Command command, String s, String[] strings) {
if (strings.length != 0 && strings[0].contains("@")){
List<Entity> selectEntities = Bukkit.selectEntities(commandSender, strings[1]);
List<Entity> selectEntities = Bukkit.selectEntities(commandSender, strings[0]);
// 判断格式
if (selectEntities.toArray().length != 1){
PlayerUtils.send(commandSender, "#RED#所给选择器目标不明确,请给一个目标明确的选择器。");
Expand All @@ -33,31 +33,36 @@ else if (selectEntities.get(0) instanceof Player){
return true;
}
}
if (commandSender instanceof Player){
if (!(commandSender instanceof Player)){
PlayerUtils.send(commandSender, "#AQUA#检测到您非玩家,请选定一个玩家再执行此指令。");
return true;
}
if (GameStart){
if (commandSender.equals(teamExecutor.getPlayer(TeamExecutor.Team.BLUE))){
ChatUtils.broadcast("#BLUE#蓝队#GREEN#玩家: %s 试图在比赛开始时离开队伍,已拒绝其请求。", command.getName());
ChatUtils.broadcast("#BLUE#蓝队#GREEN#玩家: %s 试图在比赛开始时离开队伍,已拒绝其请求。", commandSender.getName());
return true;
}
else {
ChatUtils.broadcast("#RED#红队#GREEN#玩家: %s 试图在比赛开始时离开队伍,已拒绝其请求。", command.getName());
ChatUtils.broadcast("#RED#红队#GREEN#玩家: %s 试图在比赛开始时离开队伍,已拒绝其请求。", commandSender.getName());
return true;
}

}
else {
if (teamExecutor.getPlayersTeam((Player) commandSender) == TeamExecutor.Team.NONE)
{
PlayerUtils.send(commandSender, "#AQUA#您并不属于任何团队,无法执行退出操作");
return true;
}
if (commandSender.equals(teamExecutor.getPlayer(TeamExecutor.Team.BLUE))){
ChatUtils.broadcast("#BLUE#蓝队#GREEN#玩家: %s 请求离开队伍,已认可其请求。", command.getName());
ChatUtils.broadcast("#BLUE#蓝队#GREEN#玩家: %s 请求离开队伍,已认可其请求。", commandSender.getName());
teamExecutor.removeBluePlayer();
teamExecutor.showAllTeamMember();
return true;
}
else {
ChatUtils.broadcast("#RED#红队#GREEN#玩家: %s 请求离开队伍,已认可其请求。", command.getName());
teamExecutor.removeBluePlayer();
ChatUtils.broadcast("#RED#红队#GREEN#玩家: %s 请求离开队伍,已认可其请求。", commandSender.getName());
teamExecutor.removeRedPlayer();
teamExecutor.showAllTeamMember();
return true;
}
Expand Down

0 comments on commit 3a2b610

Please sign in to comment.