SteamWar/MissileWars
Archiviert
13
0

Add TeamChat with '+'

Dieser Commit ist enthalten in:
jojo 2021-01-26 11:14:46 +01:00
Ursprung 96632cbb0c
Commit b937903ee1
3 geänderte Dateien mit 20 neuen und 3 gelöschten Zeilen

Datei anzeigen

@ -128,6 +128,7 @@ public class MWTeam {
if (!players.contains(p)) return; if (!players.contains(p)) return;
players.remove(p); players.remove(p);
p.setDisplayName("§7" + p.getName());
sbteam.removePlayer(p); sbteam.removePlayer(p);
if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING) if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING)
MissileWars.end(WinReasons.NO_ENEMY, enemy()); MissileWars.end(WinReasons.NO_ENEMY, enemy());
@ -135,7 +136,6 @@ public class MWTeam {
public void invitePlayer(Player p) { public void invitePlayer(Player p) {
if (enemy().openInvitations.contains(p)) return; if (enemy().openInvitations.contains(p)) return;
openInvitations.add(p); openInvitations.add(p);
} }

Datei anzeigen

@ -20,7 +20,10 @@
package de.steamwar.misslewars.listener; package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState; import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent; import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -33,8 +36,21 @@ public class ChatListener extends BasicListener {
} }
@EventHandler @EventHandler
public void onChat(AsyncPlayerChatEvent e){ public void onChat(AsyncPlayerChatEvent e) {
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
e.setCancelled(true); e.setCancelled(true);
Player p = e.getPlayer();
MWTeam team = MissileWars.getTeam(p);
String message = e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage();
if (team == null) {
Bukkit.broadcastMessage(message);
} else {
if (e.getMessage().startsWith("+")) {
String teamMessage = "§8[" + team.getColorCode() + "TEAM§8] " + message;
team.getPlayers().forEach(player -> player.sendMessage(teamMessage));
} else {
Bukkit.broadcastMessage(message);
}
}
} }
} }

Datei anzeigen

@ -38,6 +38,7 @@ public class ConnectionListener extends BasicListener{
@EventHandler(priority = EventPriority.HIGH) @EventHandler(priority = EventPriority.HIGH)
public void onJoin(PlayerJoinEvent e) { public void onJoin(PlayerJoinEvent e) {
e.getPlayer().setDisplayName("§7" + e.getPlayer().getName());
e.getPlayer().setGameMode(GameMode.SPECTATOR); e.getPlayer().setGameMode(GameMode.SPECTATOR);
} }