Using Chat-ChatMessageType for chat messages
Dieser Commit ist enthalten in:
Ursprung
20d228567e
Commit
1b8682807f
@ -13,6 +13,10 @@ class BasicListener_12 {
|
|||||||
player.spigot().sendMessage(ChatMessageType.ACTION_BAR, components);
|
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){
|
static void setAttackSpeed(Player player){
|
||||||
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
AttributeInstance attribute = player.getAttribute(Attribute.GENERIC_ATTACK_SPEED);
|
||||||
attribute.setBaseValue(16);
|
attribute.setBaseValue(16);
|
||||||
|
@ -9,4 +9,8 @@ class BasicListener_8 {
|
|||||||
static void toActionbar(Player player, BaseComponent... components){
|
static void toActionbar(Player player, BaseComponent... components){
|
||||||
player.spigot().sendMessage(components);
|
player.spigot().sendMessage(components);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void toChat(Player player, BaseComponent... components){
|
||||||
|
player.spigot().sendMessage(components);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -63,4 +63,14 @@ public abstract class BasicListener implements Listener {
|
|||||||
BasicListener_12.setAttackSpeed(player);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package de.steamwar.fightsystem.listener;
|
package de.steamwar.fightsystem.listener;
|
||||||
|
|
||||||
|
import de.steamwar.fightsystem.Config;
|
||||||
import de.steamwar.fightsystem.FightSystem;
|
import de.steamwar.fightsystem.FightSystem;
|
||||||
import de.steamwar.fightsystem.fight.Fight;
|
import de.steamwar.fightsystem.fight.Fight;
|
||||||
import de.steamwar.fightsystem.fight.FightTeam;
|
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.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
@ -23,15 +25,20 @@ public class PlayerChatListener extends BasicListener {
|
|||||||
if(message.startsWith(Config.TeamChatDetection)) {
|
if(message.startsWith(Config.TeamChatDetection)) {
|
||||||
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
|
fightTeam.broadcast(teamName + " " + player.getName() + "» " + message.substring(1));
|
||||||
} else {
|
} else {
|
||||||
Bukkit.broadcastMessage(teamName + " " + player.getName() + "§8» §7" + message);
|
broadcastChat(teamName + " " + player.getName() + "§8» §7" + message);
|
||||||
}
|
}
|
||||||
}else if(player == FightSystem.getEventLeiter()){
|
}else if(player == FightSystem.getEventLeiter()){
|
||||||
Bukkit.broadcastMessage("§e" + player.getName() + "§8» §e" + message);
|
broadcastChat("§e" + player.getName() + "§8» §e" + message);
|
||||||
}else{
|
}else{
|
||||||
Bukkit.broadcastMessage("§7" + player.getName() + "§8» §7" + message);
|
broadcastChat("§7" + player.getName() + "§8» §7" + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void broadcastChat(String message){
|
||||||
|
BaseComponent[] msg = TextComponent.fromLegacyText(message);
|
||||||
|
for(Player p : Bukkit.getOnlinePlayers())
|
||||||
|
toChat(p, msg);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren