SteamWar/FightSystem
Archiviert
13
1

Using Chat-ChatMessageType for chat messages

Dieser Commit ist enthalten in:
Lixfel 2019-11-21 11:03:55 +01:00 committet von Gitea
Ursprung 20d228567e
Commit 1b8682807f
4 geänderte Dateien mit 29 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -13,6 +13,10 @@ class BasicListener_12 {
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
}
static void toChat(Player player, BaseComponent... components){
player.spigot().sendMessage(ChatMessageType.CHAT, components);
}
static void setAttackSpeed(Player player){
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
attribute.setBaseValue(16);

Datei anzeigen

@ -9,4 +9,8 @@ class BasicListener_8 {
static void toActionbar(Player player, BaseComponent... components){
player.spigot().sendMessage(components);
}
static void toChat(Player player, BaseComponent... components){
player.spigot().sendMessage(components);
}
}

Datei anzeigen

@ -63,4 +63,14 @@ public abstract class BasicListener implements Listener {
BasicListener_12.setAttackSpeed(player);
}
}
public static void toChat(Player player, BaseComponent... components){
switch(Core.getVersion()){
case 8:
BasicListener_8.toChat(player, components);
break;
default:
BasicListener_12.toChat(player, components);
}
}
}

Datei anzeigen

@ -1,9 +1,11 @@
package de.steamwar.fightsystem.listener;
import de.steamwar.fightsystem.Config;
import de.steamwar.fightsystem.FightSystem;
import de.steamwar.fightsystem.fight.Fight;
import de.steamwar.fightsystem.fight.FightTeam;
import de.steamwar.fightsystem.Config;
import net.md_5.bungee.api.chat.BaseComponent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
@ -23,15 +25,20 @@ public class PlayerChatListener extends BasicListener {
if(message.startsWith(Config.TeamChatDetection)) {
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
} else {
Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message);
broadcastChat(teamName + " " + player.getName() + "§8» §7" + message);
}
}else if(player == FightSystem.getEventLeiter()){
Bukkit.broadcastMessage("§e" + player.getName() + "§8» §e" + message);
broadcastChat("§e" + player.getName() + "§8» §e" + message);
}else{
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
broadcastChat("§7" + player.getName() + "§8» §7" + message);
}
event.setCancelled(true);
}
private void broadcastChat(String message){
BaseComponent[] msg = TextComponent.fromLegacyText(message);
for(Player p : Bukkit.getOnlinePlayers())
toChat(p, msg);
}
}