SteamWar/MissileWars
Archiviert
13
0

Merge pull request 'Add TeamChat with '+'' (#29) from TeamChat into master

Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
YoyoNow 2021-01-26 11:52:49 +01:00
Commit b4de509e10
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;
players.remove(p);
p.setDisplayName("§7" + p.getName());
sbteam.removePlayer(p);
if (players.isEmpty() && MissileWars.getFightState() == FightState.FIGHTING)
MissileWars.end(WinReasons.NO_ENEMY, enemy());
@ -135,7 +136,6 @@ public class MWTeam {
public void invitePlayer(Player p) {
if (enemy().openInvitations.contains(p)) return;
openInvitations.add(p);
}

Datei anzeigen

@ -20,7 +20,10 @@
package de.steamwar.misslewars.listener;
import de.steamwar.misslewars.FightState;
import de.steamwar.misslewars.MWTeam;
import de.steamwar.misslewars.MissileWars;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.player.AsyncPlayerChatEvent;
@ -33,8 +36,21 @@ public class ChatListener extends BasicListener {
}
@EventHandler
public void onChat(AsyncPlayerChatEvent e){
Bukkit.broadcastMessage(e.getPlayer().getDisplayName() + "§8» §7" + e.getMessage());
public void onChat(AsyncPlayerChatEvent e) {
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)
public void onJoin(PlayerJoinEvent e) {
e.getPlayer().setDisplayName("§7" + e.getPlayer().getName());
e.getPlayer().setGameMode(GameMode.SPECTATOR);
}