From bf417916b3478ab8fe19142f11dbf2619a3945a0 Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 20 Dec 2020 14:10:23 +0100 Subject: [PATCH 1/2] Add Invite message Add Decline message Add Accept message --- .../misslewars/commands/CommandAcceptDecline.java | 11 +++++++++++ .../steamwar/misslewars/commands/CommandInvite.java | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java b/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java index cc8def7..0744699 100644 --- a/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java +++ b/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java @@ -24,6 +24,7 @@ package de.steamwar.misslewars.commands; import de.steamwar.misslewars.Config; import de.steamwar.misslewars.MWTeam; import de.steamwar.misslewars.MissileWars; +import org.bukkit.Bukkit; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; @@ -48,10 +49,20 @@ public class CommandAcceptDecline implements CommandExecutor { if (command.getName().equalsIgnoreCase("accept")) { teamInvitation.acceptInvite(player); + message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist deinem Team §abeigetreten§7."); } else { MWTeam.removeInvitations(player); + message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat deine Einladung §cabgelehnt§7."); } return false; } + private void message(MWTeam mwTeam, String s) { + if (mwTeam == MissileWars.getRedTeam()) { + Bukkit.getPlayer(Config.RedLeader).sendMessage(s); + } else { + Bukkit.getPlayer(Config.BlueLeader).sendMessage(s); + } + } + } diff --git a/src/de/steamwar/misslewars/commands/CommandInvite.java b/src/de/steamwar/misslewars/commands/CommandInvite.java index 0e01215..1f7414d 100644 --- a/src/de/steamwar/misslewars/commands/CommandInvite.java +++ b/src/de/steamwar/misslewars/commands/CommandInvite.java @@ -72,7 +72,8 @@ public class CommandInvite implements CommandExecutor, TabCompleter { } team.invitePlayer(invitedPlayer); - invitedPlayer.sendMessage("§7Du wurdest von §6" + player.getName() + "§7 in das Team §6" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen."); + player.sendMessage("§7Du hast §e" + invitedPlayer.getName() + " §7eingeladen."); + invitedPlayer.sendMessage("§7Du wurdest von §e" + player.getName() + "§7 in das Team §e" + MissileWars.getTeam(player).getColoredName() + "§7 eingeladen."); invitedPlayer.sendMessage("§8/§6accept §8- §7Zum akzeptieren."); invitedPlayer.sendMessage("§8/§6decline §8- §7Zum ablehnen."); return false; From 78dd982e4b92382000b304a27b1e801862ca38af Mon Sep 17 00:00:00 2001 From: jojo Date: Sun, 20 Dec 2020 14:19:42 +0100 Subject: [PATCH 2/2] Add send message to whole team --- src/de/steamwar/misslewars/MWTeam.java | 4 ++++ .../misslewars/commands/CommandAcceptDecline.java | 10 +++------- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/de/steamwar/misslewars/MWTeam.java b/src/de/steamwar/misslewars/MWTeam.java index 310dac4..760a393 100644 --- a/src/de/steamwar/misslewars/MWTeam.java +++ b/src/de/steamwar/misslewars/MWTeam.java @@ -167,6 +167,10 @@ public class MWTeam { return color.toString() + teamName; } + public LinkedList getPlayers() { + return players; + } + public static void removeInvitations(Player p) { MissileWars.getRedTeam().openInvitations.remove(p); MissileWars.getBlueTeam().openInvitations.remove(p); diff --git a/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java b/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java index 0744699..2245310 100644 --- a/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java +++ b/src/de/steamwar/misslewars/commands/CommandAcceptDecline.java @@ -49,20 +49,16 @@ public class CommandAcceptDecline implements CommandExecutor { if (command.getName().equalsIgnoreCase("accept")) { teamInvitation.acceptInvite(player); - message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist deinem Team §abeigetreten§7."); + message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 ist dem Team §abeigetreten§7."); } else { MWTeam.removeInvitations(player); - message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat deine Einladung §cabgelehnt§7."); + message(teamInvitation, "§7Der Spieler §e" + player.getName() + "§7 hat die Einladung §cabgelehnt§7."); } return false; } private void message(MWTeam mwTeam, String s) { - if (mwTeam == MissileWars.getRedTeam()) { - Bukkit.getPlayer(Config.RedLeader).sendMessage(s); - } else { - Bukkit.getPlayer(Config.BlueLeader).sendMessage(s); - } + mwTeam.getPlayers().forEach(player -> player.sendMessage(s)); } }