geforkt von SteamWar/BungeeCore
Merge pull request 'Improve @Ping a lot' (#195) from new_@ping into master
Reviewed-on: SteamWar/BungeeCore#195 Reviewed-by: Lixfel <lixfel@steamwar.de>
Dieser Commit ist enthalten in:
Commit
fc20d9c671
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
@ -56,7 +57,7 @@ public class ServerTeamchatCommand extends BasicCommand {
|
|||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||||
Message.sendPrefixless("STC_FORMAT", target, sender.getName(), message);
|
Message.sendPrefixless("STC_FORMAT", target, sender.getName(), ChatListener.parseAtMessage(message, "§r", target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
package de.steamwar.bungeecore.commands;
|
package de.steamwar.bungeecore.commands;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.Message;
|
import de.steamwar.bungeecore.Message;
|
||||||
|
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||||
import net.md_5.bungee.api.ChatColor;
|
import net.md_5.bungee.api.ChatColor;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
@ -59,7 +60,7 @@ public class TeamchatCommand extends BasicCommand {
|
|||||||
SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId());
|
SteamwarUser targetuser = SteamwarUser.get(target.getUniqueId());
|
||||||
if (targetuser.getTeam() == user.getTeam()
|
if (targetuser.getTeam() == user.getTeam()
|
||||||
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
||||||
Message.sendPrefixless("TC_FORMAT", target, player.getName(), msg);
|
Message.sendPrefixless("TC_FORMAT", target, player.getName(), ChatListener.parseAtMessage(msg, "§f", target));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -166,22 +166,11 @@ public class ChatListener extends BasicListener {
|
|||||||
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
||||||
}
|
}
|
||||||
|
|
||||||
String[] msgSplits = msg.split(" ");
|
|
||||||
StringBuilder builder = new StringBuilder();
|
|
||||||
|
|
||||||
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
Subserver targetServer = Subserver.getSubserver(target);
|
Subserver targetServer = Subserver.getSubserver(target);
|
||||||
if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;
|
if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;
|
||||||
for (String curr : msgSplits) {
|
|
||||||
if(curr.equalsIgnoreCase("@" + target.getName())) {
|
BungeeCore.send(target, ChatMessageType.CHAT, parseAtMessage(msg, chatcolor, target));
|
||||||
builder.append("§e@").append(target.getName()).append(chatcolor).append(" ");
|
|
||||||
new PingPacket(SteamwarUser.get(target).getId()).send(target);
|
|
||||||
}else {
|
|
||||||
builder.append(curr).append(" ");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
BungeeCore.send(target, ChatMessageType.CHAT, builder.toString());
|
|
||||||
builder = new StringBuilder();
|
|
||||||
}
|
}
|
||||||
BungeeCore.log(sender.getServer().getInfo(), msg);
|
BungeeCore.log(sender.getServer().getInfo(), msg);
|
||||||
}
|
}
|
||||||
@ -211,6 +200,28 @@ public class ChatListener extends BasicListener {
|
|||||||
e.setMessage(e.getMessage().substring(command[0].length() + 1));
|
e.setMessage(e.getMessage().substring(command[0].length() + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static String parseAtMessage(String message, String returnColor, ProxiedPlayer player) {
|
||||||
|
if(!message.contains("@")) {
|
||||||
|
return message;
|
||||||
|
}
|
||||||
|
|
||||||
|
StringBuilder builder = new StringBuilder();
|
||||||
|
for (String curr : message.split(" ")) {
|
||||||
|
if(curr.toLowerCase().startsWith("@" + player.getName().toLowerCase())) {
|
||||||
|
new PingPacket(SteamwarUser.get(player).getId()).send(player);
|
||||||
|
builder.append("§e@")
|
||||||
|
.append(player.getName())
|
||||||
|
.append(returnColor)
|
||||||
|
.append(curr.substring(player.getName().length() + 1))
|
||||||
|
.append(" ");
|
||||||
|
}else {
|
||||||
|
builder.append(curr)
|
||||||
|
.append(" ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return builder.toString();
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTabCompleteEvent(TabCompleteEvent e){
|
public void onTabCompleteEvent(TabCompleteEvent e){
|
||||||
List<String> suggestions = e.getSuggestions();
|
List<String> suggestions = e.getSuggestions();
|
||||||
@ -226,6 +237,17 @@ public class ChatListener extends BasicListener {
|
|||||||
suggestions.add(name);
|
suggestions.add(name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if(last.startsWith("@")) {
|
||||||
|
String plrName = last.replace("@", "");
|
||||||
|
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
|
||||||
|
String name = player.getName();
|
||||||
|
if ((plrName.isEmpty() || name.startsWith(plrName)) && !plrName.equalsIgnoreCase(name)) {
|
||||||
|
suggestions.add("@" + name);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if(e.getSender() instanceof ProxiedPlayer && cursor.length == 1 && cursor[0].startsWith("/")){
|
if(e.getSender() instanceof ProxiedPlayer && cursor.length == 1 && cursor[0].startsWith("/")){
|
||||||
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
|
||||||
for(String cmd : BungeeCore.commands.keySet()){
|
for(String cmd : BungeeCore.commands.keySet()){
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren