Archiviert
1
0

Team list, Teamchat, Serverteamchat

Dieser Commit ist enthalten in:
Lixfel 2019-08-02 16:07:10 +02:00
Ursprung 33273be4fd
Commit e0d4314d9e
6 geänderte Dateien mit 95 neuen und 9 gelöschten Zeilen

Datei anzeigen

@ -25,7 +25,8 @@ public class BungeeCore extends Plugin {
public static String ChatPrefix;
public static String WorldFolder;
public static String BauweltPrototyp;
public static final String TeamchatPrefix = "§4T§7c§r §e";
public static final String ServerTeamchatPrefix = "§8STC §e";
public static final String TeamchatPrefix = "§8TC §e";
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy");
public static String LobbyServer;
private static String [] BroadCastMsgs;
@ -113,6 +114,7 @@ public class BungeeCore extends Plugin {
addCmd(new DenyCommand("watchcat", "wc"));
addCmd(new ChallengeCommand());
addCmd(new TeamCommand());
addCmd(new ServerTeamchatCommand());
BroadCastMsgs = config.getStringList("broadcasts").toArray(new String[1]);
getProxy().getScheduler().schedule(this, () -> {

Datei anzeigen

@ -61,7 +61,7 @@ public class BanCommand extends Command {
target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg);
targetPlayer.disconnect(msgBuilder.toString());
}else{
target.banPlayer(null, banTime, msg);
target.banPlayer("", banTime, msg);
}
}
}

Datei anzeigen

@ -0,0 +1,41 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class ServerTeamchatCommand extends Command{
public ServerTeamchatCommand() {
super("stc", "bungeecore.teamchat","serverteamchat");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){
player.sendMessage(BungeeCore.ChatPrefix + "/stc [Nachricht an das Team]");
return;
}
StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append(BungeeCore.ServerTeamchatPrefix).append(sender.getName()).append("» §r");
for (String arg : args){
msgBuilder.append(arg).append(" ");
}
String msg = msgBuilder.toString();
msg = ChatColor.translateAlternateColorCodes('&', msg);
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat"))
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
target.sendMessage(msg);
}
}
}
}
}

Datei anzeigen

@ -5,6 +5,10 @@ import de.steamwar.bungeecore.sql.Team;
import de.steamwar.bungeecore.sql.WarkingUser;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.*;
@ -22,6 +26,7 @@ public class TeamCommand extends Command {
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam create §8- §7Erstelle dein eigenes Team");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam join §8- §7Trete einem Team bei");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam leave §8- §7Verlasse dein Team");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam list §8- §7Liste alle Teams auf");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam info §8- §7Informiere dich über ein Team");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam invite §8- §7Lade jemanden in dein Team ein");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§eteam remove §8- §7Entferne jemanden aus deinem Team");
@ -275,6 +280,16 @@ public class TeamCommand extends Command {
player.sendMessage(sb.toString());
break;
case "list":
player.sendMessage(BungeeCore.ChatPrefix + "§7§lTeamliste");
List<Team> all = Team.getAll();
for(Team tm : all){
TextComponent tc = new TextComponent("§8" + tm.getTeamKuerzel() + " §e" + tm.getTeamName() + " §8[§7" + WarkingUser.get(tm.getTeamLeader()).getUserName() + "§8]");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Teaminfo").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/team info " + tm.getTeamKuerzel()));
player.sendMessage(tc);
}
break;
default:
help(player);
}

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.sql.WarkingUser;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -9,13 +10,19 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
public class TeamchatCommand extends Command {
public TeamchatCommand() {
super("tc", "bungeecore.teamchat","teamchat");
super("tc", "","teamchat");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
WarkingUser user = WarkingUser.get(player.getUniqueId());
if(user.getTeam() == 0){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu bist in keinem Team");
return;
}
if(args.length == 0){
player.sendMessage(BungeeCore.TeamchatPrefix + "/teamchat [Nachricht an das Team]");
@ -23,7 +30,7 @@ public class TeamchatCommand extends Command {
}
StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append(BungeeCore.TeamchatPrefix).append(sender.getName()).append(" §r");
msgBuilder.append(BungeeCore.TeamchatPrefix).append(sender.getName()).append("§8» §r");
for (String arg : args){
msgBuilder.append(arg).append(" ");
}
@ -31,7 +38,8 @@ public class TeamchatCommand extends Command {
msg = ChatColor.translateAlternateColorCodes('&', msg);
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat"))
WarkingUser targetuser = WarkingUser.get(target.getUniqueId());
if (targetuser.getTeam() == user.getTeam()
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
target.sendMessage(msg);
}

Datei anzeigen

@ -3,8 +3,11 @@ package de.steamwar.bungeecore.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import static de.steamwar.bungeecore.sql.sql.select;
public class Team {
private final int teamId;
private String teamKuerzel;
@ -31,7 +34,7 @@ public class Team {
for(Team team : teamCache)
if(team.teamId == id)
return team;
return load(sql.select("SELECT * FROM Team WHERE TeamID = " + id));
return load(select("SELECT * FROM Team WHERE TeamID = " + id));
}
public static Team get(String name){
@ -41,7 +44,24 @@ public class Team {
for(Team team : teamCache)
if(team.teamKuerzel.equalsIgnoreCase(name))
return team;
return load(sql.select("SELECT * FROM Team WHERE lower(TeamName) = '" + sql.disarmString(name).toLowerCase() + "' OR lower(TeamKuerzel) = '" + sql.disarmString(name).toLowerCase() + "'"));
return load(select("SELECT * FROM Team WHERE lower(TeamName) = '" + sql.disarmString(name).toLowerCase() + "' OR lower(TeamKuerzel) = '" + sql.disarmString(name).toLowerCase() + "'"));
}
public static List<Team> getAll(){
teamCache.clear();
List<Team> allTeams = new LinkedList<>();
try{
ResultSet rs = select("SELECT * FROM Team");
if(rs == null)
return allTeams;
while(!rs.isLast()){
allTeams.add(load(rs));
}
} catch (SQLException e) {
e.printStackTrace();
}
return allTeams;
}
public static void clearCache(){
@ -107,7 +127,7 @@ public class Team {
}
public int size(){
ResultSet rs = sql.select("SELECT COUNT(id) FROM UserData WHERE Team = " + teamId);
ResultSet rs = select("SELECT COUNT(id) FROM UserData WHERE Team = " + teamId);
try {
rs.next();
return rs.getInt("COUNT(id)");
@ -124,7 +144,7 @@ public class Team {
public List<Integer> getMembers(){
try{
ResultSet memberlist = sql.select("SELECT id FROM UserData WHERE Team = '" + teamId + "'");
ResultSet memberlist = select("SELECT id FROM UserData WHERE Team = '" + teamId + "'");
List<Integer> members = new ArrayList<>();
while(memberlist.next()){
members.add(memberlist.getInt("id"));