SteamWar/BungeeCore
Archiviert
13
2

Various updates

Dieser Commit ist enthalten in:
Lixfel 2019-03-17 14:55:36 +01:00
Ursprung df834fab5f
Commit 78e6cd5696
17 geänderte Dateien mit 363 neuen und 92 gelöschten Zeilen

Datei anzeigen

@ -2,6 +2,7 @@ package de.warking.bungeecore;
import de.warking.bungeecore.arenasystem.ArenaSystem; import de.warking.bungeecore.arenasystem.ArenaSystem;
import de.warking.bungeecore.commands.*; import de.warking.bungeecore.commands.*;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Command; import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin; import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration; import net.md_5.bungee.config.Configuration;
@ -13,6 +14,7 @@ import java.io.IOException;
import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatter;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.logging.Level;
public class BungeeCore extends Plugin { public class BungeeCore extends Plugin {
@ -23,6 +25,7 @@ public class BungeeCore extends Plugin {
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"); public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm");
public static String LobbyServer; public static String LobbyServer;
public static final HashMap<String, String> serverPermissions = new HashMap<>(); public static final HashMap<String, String> serverPermissions = new HashMap<>();
public static final HashMap<String, String> commands = new HashMap<>();
@Override @Override
public void onEnable(){ public void onEnable(){
@ -76,6 +79,8 @@ public class BungeeCore extends Plugin {
commands.toArray(new String[0]) commands.toArray(new String[0])
)); ));
} }
commands.put("/bau", "");
commands.remove("/bauserver");
addCmd(new TeamchatCommand()); addCmd(new TeamchatCommand());
addCmd(new MsgCommand()); addCmd(new MsgCommand());
@ -94,6 +99,16 @@ public class BungeeCore extends Plugin {
public void onDisable(){ public void onDisable(){
ArenaSystem.shutdown(); ArenaSystem.shutdown();
sql.close(); sql.close();
getProxy().getPluginManager().unregisterCommands(this);
getProxy().getPluginManager().unregisterListeners(this);
}
public static void log(final String message, final ServerInfo server){
log("[" + server.getName() + "] " + message);
}
public static void log(final String message){
instance.getLogger().log(Level.INFO, message);
} }
private void addCmd(Command cmd){ private void addCmd(Command cmd){

Datei anzeigen

@ -1,6 +1,8 @@
package de.warking.bungeecore; package de.warking.bungeecore;
import de.warking.bungeecore.arenasystem.ArenaSystem;
import net.md_5.bungee.api.AbstractReconnectHandler; import net.md_5.bungee.api.AbstractReconnectHandler;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
@ -24,7 +26,6 @@ public class PlayerListener implements Listener {
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + " Du bist bis zum " + event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + " Du bist bis zum " +
user.BanTime.toLocalDateTime().format(BungeeCore.DateFormat) + " gebannt. §r§lGrund§r: §c" + user.BanReason)); user.BanTime.toLocalDateTime().format(BungeeCore.DateFormat) + " gebannt. §r§lGrund§r: §c" + user.BanReason));
} }
return;
} }
} }
@ -35,17 +36,41 @@ public class PlayerListener implements Listener {
player.removeGroups("Admin", "team"); player.removeGroups("Admin", "team");
switch(user.UserGroup){ switch(user.UserGroup){
case "Admin": case "Admin":
player.addGroups("admin", "team");
player.setPermission("bungeecore.group.admin", true);
player.setDisplayName("§4Admin " + player.getName() + "§r");
break;
case "Developer": case "Developer":
player.addGroups("admin", "team", "default"); player.addGroups("admin", "team");
player.setPermission("bungeecore.group.developer", true);
player.setDisplayName("§3Developer " + player.getName() + "§r");
break; break;
case "Moderator": case "Moderator":
player.addGroups("team");
player.setPermission("bungeecore.group.moderator", true);
player.setDisplayName("§bModerator " + player.getName() + "§r");
break;
case "Supporter": case "Supporter":
player.addGroups("team");
player.setPermission("bungeecore.group.supporter", true);
player.setDisplayName("§1Supporter " + player.getName() + "§r");
break;
case "Builder": case "Builder":
player.addGroups("team", "default"); player.addGroups("team");
player.setPermission("bungeecore.group.builder", true);
player.setDisplayName("§2Architekt " + player.getName() + "§r");
break;
case "Youtuber":
player.setPermission("bungeecore.group.youtuber", true);
player.setDisplayName("§5Youtuber " + player.getName() + "§r");
break;
case "Premium":
player.setPermission("bungeecore.group.premium", true);
player.setDisplayName("§6Premium " + player.getName() + "§r");
break; break;
case "Member": case "Member":
default: default:
player.addGroups("default"); player.setDisplayName("§7" + player.getName() + "§r");
break; break;
} }
@ -89,6 +114,57 @@ public class PlayerListener implements Listener {
ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Befehl."); sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Befehl.");
} }
}else if(command[0].equals("/bau") && e.getSender() instanceof ProxiedPlayer){
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
if(!sender.getServer().getInfo().getName().equals("Bauserver")){
e.setCancelled(true);
sender.connect(ProxyServer.getInstance().getServerInfo("Bauserver"));
}
}
}else{
if(e.getSender() instanceof ProxiedPlayer){
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
if(sender.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
sender.sendMessage(BungeeCore.ChatPrefix + "§cUm Chatnachrichten versenden zu können, musst du erst einmal welche empfangen!");
e.setCancelled(true);
return;
}
if(ArenaSystem.getPlayer(sender) != null){
return;
}
String name = sender.getDisplayName();
String message = e.getMessage();
String chatsuffix = "§7» ";
e.setCancelled(true);
if(sender.hasPermission("bungeecore.group.admin")){
chatsuffix = "§7» §6";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.developer")){
chatsuffix = "§7» §r";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.moderator")){
chatsuffix = "§7» §r";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.supporter")){
chatsuffix = "§7» §r";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.builder")){
chatsuffix = "§7» §r";
message = ChatColor.translateAlternateColorCodes('&', message);
}else if(sender.hasPermission("bungeecore.group.youtuber") ||
sender.hasPermission("bungeecore.group.premium")){
message = ChatColor.translateAlternateColorCodes('&', message);
}
String msg = name + chatsuffix + message;
for(ProxiedPlayer target : sender.getServer().getInfo().getPlayers()){
if(target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
target.sendMessage(msg);
}
}
BungeeCore.log(msg, sender.getServer().getInfo());
} }
} }
} }
@ -104,6 +180,14 @@ public class PlayerListener implements Listener {
suggestions.add(name); suggestions.add(name);
} }
} }
if(e.getSender() instanceof ProxiedPlayer && cursor.length == 1 && cursor[0].startsWith("/")){
ProxiedPlayer player = (ProxiedPlayer) e.getSender();
for(String cmd : BungeeCore.commands.keySet()){
if(cmd.startsWith(cursor[0]) && player.hasPermission(BungeeCore.commands.get(cmd))){
suggestions.add(cmd);
}
}
}
} }
@EventHandler @EventHandler

Datei anzeigen

@ -2,7 +2,6 @@ package de.warking.bungeecore.arenasystem;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -11,19 +10,26 @@ import java.io.IOException;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.Vector; import java.util.ArrayList;
import java.util.List;
public class Arena implements Runnable{ public class Arena implements Runnable{
public final String serverName; public final String serverName;
public final int arenenNummer; public final int arenenNummer;
public final String spielModus;
private Process p; private Process p;
private PrintWriter writer;
private ServerInfo server; private ServerInfo server;
private boolean started = false; private boolean started = false;
private Vector<ArenaPlayer> cachedPlayers = new Vector<>();
private PrintWriter writer; private final List<ArenaPlayer> cachedPlayers = new ArrayList<>();
private final List<ArenaPlayer> players = new ArrayList<>();
public Arena(String modus, int id){ public Arena(String modus, int id){
spielModus = modus;
arenenNummer = id; arenenNummer = id;
serverName = modus + id; serverName = modus + id;
int port = 2500 + arenenNummer; int port = 2500 + arenenNummer;
@ -44,12 +50,55 @@ public class Arena implements Runnable{
} }
} }
public void sendPlayer(ArenaPlayer p){ private void sendPlayer(ArenaPlayer p){
if(!started) { if(!started){
p.player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "Die Arena wird gestartet, einen Moment bitte...")); p.player.sendMessage(BungeeCore.ChatPrefix + "Die Arena wird gestartet, einen Moment bitte...");
cachedPlayers.add(p); cachedPlayers.add(p);
}else }else{
p.player.connect(server); if(players.contains(p)){
p.player.connect(server);
players.add(p);
}
p.player.getServer().sendData("FightSystem:NewPlayer", p.role.name().getBytes());
}
}
public void sendPlayer(ProxiedPlayer p){
ArenaRole role;
switch(cachedPlayers.size() + players.size()){
case 0:
role = ArenaRole.RED_LEADER;
break;
case 1:
role = ArenaRole.BLUE_LEADER;
break;
default:
role = ArenaRole.SPECTATOR;
}
ArenaPlayer aP = new ArenaPlayer(p, role);
sendPlayer(aP);
}
public void sendPlayer(ProxiedPlayer p, ProxiedPlayer initiator){
ArenaPlayer parent = getPlayer(initiator);
if(parent == null)
return;
switch(parent.role){
case RED_LEADER:
case RED_MEMBER:
sendPlayer(new ArenaPlayer(p, ArenaRole.RED_MEMBER));
break;
case BLUE_MEMBER:
case BLUE_LEADER:
sendPlayer(new ArenaPlayer(p, ArenaRole.BLUE_MEMBER));
break;
case SPECTATOR:
default:
sendPlayer(new ArenaPlayer(p, ArenaRole.SPECTATOR));
break;
}
} }
protected void stop(){ protected void stop(){
@ -69,6 +118,28 @@ public class Arena implements Runnable{
ArenaSystem.arenen.remove(this); ArenaSystem.arenen.remove(this);
} }
public ArenaPlayer getPlayer(ProxiedPlayer p){
for(int i = 0; i < cachedPlayers.size(); i++)
if(cachedPlayers.get(i).player.equals(p)){
if(server.equals(p.getServer().getInfo())) {
return cachedPlayers.get(i);
}else{
cachedPlayers.remove(i);
return null;
}
}
for(int i = 0; i < players.size(); i++)
if(players.get(i).player.equals(p)){
if(server.equals(p.getServer().getInfo())) {
return players.get(i);
}else{
players.remove(i);
return null;
}
}
return null;
}
@Override @Override
public void run() { public void run() {
try { try {
@ -76,10 +147,11 @@ public class Arena implements Runnable{
String line; String line;
while (!started && (line = reader.readLine()) != null) { while (!started && (line = reader.readLine()) != null) {
started = line.contains(" INFO]: Done ("); //started = line.contains(" INFO]: Done ("); Problematisch
started = line.contains("INFO]: [AAC] AAC has been enabled.");
} }
Thread.sleep(1000); //Thread.sleep(1000);
for(ArenaPlayer aP : cachedPlayers){ for(ArenaPlayer aP : cachedPlayers){
sendPlayer(aP); sendPlayer(aP);
@ -90,7 +162,7 @@ public class Arena implements Runnable{
}catch(IOException e){ }catch(IOException e){
e.printStackTrace(); e.printStackTrace();
}catch(InterruptedException e){ }catch(InterruptedException e){
System.out.println("Arena "+serverName+" was interrupted!"); BungeeCore.log("Arena "+serverName+" was interrupted!");
} }
stop(); stop();
} }

Datei anzeigen

@ -1,6 +1,8 @@
package de.warking.bungeecore.arenasystem; package de.warking.bungeecore.arenasystem;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.Vector; import java.util.Vector;
public class ArenaSystem { public class ArenaSystem {
@ -33,4 +35,29 @@ public class ArenaSystem {
while(!arenen.isEmpty()) while(!arenen.isEmpty())
arenen.firstElement().stop(); arenen.firstElement().stop();
} }
public static ArenaPlayer getPlayer(ProxiedPlayer p){
for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p);
if(aP != null)
return aP;
}
return null;
}
public static Arena getArena(ProxiedPlayer p){
for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p);
if(aP != null)
return a;
}
return null;
}
public static Arena getArena(String serverName){
for(Arena a : arenen)
if(a.serverName.equals(serverName))
return a;
return null;
}
} }

Datei anzeigen

@ -4,19 +4,18 @@ import de.warking.bungeecore.BungeeCore;
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;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
public class AlertCommand extends Command { public class AlertCommand extends Command {
public AlertCommand() { public AlertCommand() {
super("bc", "bungeecore.alert"); super("bc", "bungeecore.alert", "alert");
} }
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length == 0){ if(args.length == 0){
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "/alert [Nachricht]")); sender.sendMessage(BungeeCore.ChatPrefix + "/alert [Nachricht]");
return;
} }
StringBuilder msgBuilder = new StringBuilder(); StringBuilder msgBuilder = new StringBuilder();

Datei anzeigen

@ -0,0 +1,32 @@
package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.TabExecutor;
import java.util.ArrayList;
import java.util.List;
public abstract class Command extends net.md_5.bungee.api.plugin.Command implements TabExecutor {
public Command(String name, String permission, String... aliases) {
super(name, permission, aliases);
BungeeCore.commands.put("/" + name, permission);
}
public Iterable<String> allPlayers(String begin) {
List<String> suggestions = new ArrayList<>();
for(ProxiedPlayer player : ProxyServer.getInstance().getPlayers()){
String playerName = player.getName();
if(playerName.startsWith(begin))
suggestions.add(playerName);
}
return suggestions;
}
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
return null;
}
}

Datei anzeigen

@ -4,7 +4,6 @@ import de.warking.bungeecore.BungeeCore;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class DenyCommand extends Command { public class DenyCommand extends Command {

Datei anzeigen

@ -2,13 +2,17 @@ package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.arenasystem.Arena; import de.warking.bungeecore.arenasystem.Arena;
import de.warking.bungeecore.arenasystem.ArenaPlayer;
import de.warking.bungeecore.arenasystem.ArenaRole;
import de.warking.bungeecore.arenasystem.ArenaSystem; import de.warking.bungeecore.arenasystem.ArenaSystem;
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.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.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import java.util.ArrayList;
import java.util.List;
public class FightCommand extends Command { public class FightCommand extends Command {
@ -24,16 +28,33 @@ public class FightCommand extends Command {
} }
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
Arena arena;
switch(args[0].toLowerCase()){ switch(args[0].toLowerCase()){
case "as": case "as":
case "airship": case "airship":
Arena arena = ArenaSystem.startServer("Airship"); arena = ArenaSystem.startServer("Airship");
arena.sendPlayer(new ArenaPlayer(player, ArenaRole.RED_LEADER));
break; break;
default: default:
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0])); sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]);
break; return;
} }
arena.sendPlayer(player);
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "Kämpfe jetzt " + arena.spielModus + " gegen " + player.getName() + "[Hier Klicken]!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen Spieler kämpfen").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
ProxyServer.getInstance().broadcast(tc);
} }
} }
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
List<String> gamemodes = new ArrayList<>();
if(args.length == 1){
gamemodes.add("airship");
gamemodes.add("as");
}
System.out.println(args);
return gamemodes;
}
} }

Datei anzeigen

@ -6,7 +6,6 @@ import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder; import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent; import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.plugin.Command;
public class HelpCommand extends Command { public class HelpCommand extends Command {
public HelpCommand() { public HelpCommand() {

Datei anzeigen

@ -1,6 +1,9 @@
package de.warking.bungeecore.commands; package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.arenasystem.Arena;
import de.warking.bungeecore.arenasystem.ArenaPlayer;
import de.warking.bungeecore.arenasystem.ArenaSystem;
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;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
@ -9,12 +12,11 @@ import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class JoinmeCommand extends Command { public class JoinmeCommand extends Command {
public JoinmeCommand() { public JoinmeCommand() {
super("join", ""); super("join", "", "joinme");
} }
@Override @Override
@ -22,25 +24,48 @@ public class JoinmeCommand extends Command {
if(sender instanceof ProxiedPlayer) { if(sender instanceof ProxiedPlayer) {
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if (args.length == 0) { if (args.length == 0 && player.hasPermission("bungeecore.joinme")) {
if(player.hasPermission("bungeecore.joinme")){ TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "Klicke hier, um dem Spieler " + player.getName() + " auf " + player.getServer().getInfo().getName() + " zu folgen!");
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "Klicke hier, um dem Server " + player.getServer().getInfo().getName() + " beizutreten!"); tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aSpieler folgen").create()));
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cServer beitreten").create())); tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName())); ProxyServer.getInstance().broadcast(tc);
ProxyServer.getInstance().broadcast(tc);
}else {
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDu hast dazu keine Berechtigung."));
}
} else if (args.length == 1) { } else if (args.length == 1) {
//TODO: Joinme to player ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
ServerInfo server = ProxyServer.getInstance().getPlayer(args[0]).getServer().getInfo(); if(target == null || !target.isConnected()){
String ServerPerm = BungeeCore.serverPermissions.get(server.getName()); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit offline.");
if(ServerPerm == null || !player.hasPermission(ServerPerm)){ return;
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDiesen Server gibt es nicht.")); }else if(target.equals(player)){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu bist bereits in deiner Sphäre.");
return; return;
} }
player.connect(server); ServerInfo server = ProxyServer.getInstance().getPlayer(args[0]).getServer().getInfo();
String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
if(ServerPerm == null){
Arena arena = ArenaSystem.getArena(player);
if(arena == null){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst diesem Spieler derzeit nicht folgen.");
return;
}
arena.sendPlayer(player, target);
}else if(!player.hasPermission(ServerPerm)){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst diesem Spieler derzeit nicht folgen.");
}else{
player.connect(server);
}
} else {
player.sendMessage(BungeeCore.ChatPrefix + "/join [Spieler]");
} }
} }
} }
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return null;
}
} }

Datei anzeigen

@ -3,9 +3,7 @@ package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
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;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class KickCommand extends Command { public class KickCommand extends Command {
@ -16,25 +14,34 @@ public class KickCommand extends Command {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length == 0){ if(args.length == 0){
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "/kick [Spieler] [Nachricht]")); sender.sendMessage(BungeeCore.ChatPrefix + "/kick [Spieler] [Nachricht]");
return;
} }
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]); ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null){ if(target == null){
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!")); sender.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!");
return; return;
} }
if(args.length == 1){ if(args.length == 1){
target.disconnect(new TextComponent(BungeeCore.ChatPrefix + "§cDu wurdest gekickt.")); target.disconnect(BungeeCore.ChatPrefix + "§cDu wurdest gekickt.");
}else{ }else{
StringBuilder msgBuilder = new StringBuilder(); StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append(BungeeCore.ChatPrefix).append("§c"); msgBuilder.append(BungeeCore.ChatPrefix).append("§c");
for (int i = 1; i < args.length; i++){ for (int i = 1; i < args.length; i++){
msgBuilder.append(args[i]).append(" "); msgBuilder.append(args[i]).append(" ");
} }
target.disconnect(new TextComponent(msgBuilder.toString())); target.disconnect(msgBuilder.toString());
} }
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "Der Spieler " + target.getName() + " wurde gekickt.")); sender.sendMessage(BungeeCore.ChatPrefix + "Der Spieler " + target.getName() + " wurde gekickt.");
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return null;
} }
} }

Datei anzeigen

@ -3,14 +3,13 @@ package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
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;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
import java.util.HashMap; import java.util.HashMap;
public class MsgCommand extends Command { public class MsgCommand extends Command {
public static HashMap<String, ProxiedPlayer> lastChats = new HashMap<>(); protected static final HashMap<String, ProxiedPlayer> lastChats = new HashMap<>();
public MsgCommand() { public MsgCommand() {
super("msg", "", "w", "tell"); super("msg", "", "w", "tell");
@ -22,19 +21,19 @@ public class MsgCommand extends Command {
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if (args.length < 2) { if (args.length < 2) {
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "/msg [Benutzer] [Nachricht]")); player.sendMessage(BungeeCore.ChatPrefix + "/msg [Benutzer] [Nachricht]");
return; return;
} }
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]); ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null){ if(target == null){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!");
return; return;
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){ }else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!");
return; return;
}else if(target.equals(player)){ }else if(target.equals(player)){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cNachrichten an dich selbst hast du wirklich nicht nötig!")); player.sendMessage(BungeeCore.ChatPrefix + "§cNachrichten an dich selbst hast du wirklich nicht nötig!");
return; return;
} }
@ -43,14 +42,21 @@ public class MsgCommand extends Command {
for (int i = 1; i < args.length; i++){ for (int i = 1; i < args.length; i++){
msgBuilder.append(args[i]).append(" "); msgBuilder.append(args[i]).append(" ");
} }
TextComponent msg = new TextComponent(msgBuilder.toString()); String msg = msgBuilder.toString();
player.sendMessage(msg); player.sendMessage(msg);
target.sendMessage(msg); target.sendMessage(msg);
BungeeCore.log(msg);
lastChats.put(player.getName().toLowerCase(), target); lastChats.put(player.getName().toLowerCase(), target);
lastChats.put(target.getName().toLowerCase(), player); lastChats.put(target.getName().toLowerCase(), player);
} }
} }
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return null;
}
} }

Datei anzeigen

@ -2,9 +2,7 @@ package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class PingCommand extends Command { public class PingCommand extends Command {
@ -16,7 +14,7 @@ public class PingCommand extends Command {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§7Dein Ping beträgt §c" + player.getPing() + "§r§7 ms!")); player.sendMessage(BungeeCore.ChatPrefix + "§7Dein Ping beträgt §c" + player.getPing() + "§r§7 ms!");
} }
} }
} }

Datei anzeigen

@ -2,9 +2,7 @@ package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class RCommand extends Command { public class RCommand extends Command {
@ -17,21 +15,21 @@ public class RCommand extends Command {
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){ if(args.length == 0){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "/r [Antwort]")); player.sendMessage(BungeeCore.ChatPrefix + "/r [Antwort]");
return; return;
} }
ProxiedPlayer target = MsgCommand.lastChats.get(player.getName().toLowerCase()); ProxiedPlayer target = MsgCommand.lastChats.get(player.getName().toLowerCase());
if(target == null){ if(target == null){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDu hast bisher mit niemandem geschrieben!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDu hast bisher mit niemandem geschrieben!");
return; return;
} }
if(!target.isConnected()){ if(!target.isConnected()){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit nicht online!");
return; return;
}else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){ }else if(target.getChatMode() != ProxiedPlayer.ChatMode.SHOWN){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler empfängt derzeit keine Chatnachrichten!");
return; return;
} }
@ -40,9 +38,10 @@ public class RCommand extends Command {
for (String arg : args){ for (String arg : args){
msgBuilder.append(arg).append(" "); msgBuilder.append(arg).append(" ");
} }
TextComponent msg = new TextComponent(msgBuilder.toString()); String msg = msgBuilder.toString();
player.sendMessage(msg); player.sendMessage(msg);
target.sendMessage(msg); target.sendMessage(msg);
BungeeCore.log(msg);
MsgCommand.lastChats.put(target.getName().toLowerCase(), player); MsgCommand.lastChats.put(target.getName().toLowerCase(), player);
} }

Datei anzeigen

@ -1,12 +1,9 @@
package de.warking.bungeecore.commands; package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore;
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;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.config.ServerInfo; import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class ServerSwitchCommand extends Command { public class ServerSwitchCommand extends Command {
@ -21,12 +18,8 @@ public class ServerSwitchCommand extends Command {
public void execute(CommandSender sender, String[] strings) { public void execute(CommandSender sender, String[] strings) {
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if(!player.getServer().getInfo().getName().equalsIgnoreCase(serverName)){ ServerInfo target = ProxyServer.getInstance().getServerInfo(serverName);
ServerInfo target = ProxyServer.getInstance().getServerInfo(serverName); player.connect(target);
player.connect(target);
}else{
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDu bist bereits auf diesem Server!"));
}
} }
} }
} }

Datei anzeigen

@ -4,9 +4,7 @@ import de.warking.bungeecore.BungeeCore;
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;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class TeamchatCommand extends Command { public class TeamchatCommand extends Command {
@ -20,7 +18,7 @@ public class TeamchatCommand extends Command {
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){ if(args.length == 0){
player.sendMessage(new TextComponent(BungeeCore.TeamchatPrefix + "/teamchat [Nachricht an das Team]")); player.sendMessage(BungeeCore.TeamchatPrefix + "/teamchat [Nachricht an das Team]");
return; return;
} }
@ -31,12 +29,11 @@ public class TeamchatCommand extends Command {
} }
String msg = msgBuilder.toString(); String msg = msgBuilder.toString();
msg = ChatColor.translateAlternateColorCodes('&', msg); msg = ChatColor.translateAlternateColorCodes('&', msg);
TextComponent message = new TextComponent(msg);
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){ for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat") || target.hasPermission("bungeecore.*")) if ((target.hasPermission("bungeecore.teamchat") || target.hasPermission("bungeecore.*"))
&& target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
target.sendMessage(message); target.sendMessage(msg);
} }
} }
} }

Datei anzeigen

@ -4,9 +4,7 @@ import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.WarkingUser; import de.warking.bungeecore.WarkingUser;
import de.warking.bungeecore.sql; import de.warking.bungeecore.sql;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Command;
public class WebpwCommand extends Command { public class WebpwCommand extends Command {
@ -19,18 +17,18 @@ public class WebpwCommand extends Command {
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length != 2){ if(args.length != 2){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "/webpw [Passwort] [Passwort wiederholen]")); player.sendMessage(BungeeCore.ChatPrefix + "/webpw [Passwort] [Passwort wiederholen]");
return; return;
}else if(!args[0].equals(args[1])){ }else if(!args[0].equals(args[1])){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDie Passwörter stimmen nicht überein!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDie Passwörter stimmen nicht überein!");
return; return;
}else if(args[0].length() < 6){ }else if(args[0].length() < 6){
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cDas Passwort muss mindestens 6 Zeichen lang sein!")); player.sendMessage(BungeeCore.ChatPrefix + "§cDas Passwort muss mindestens 6 Zeichen lang sein!");
return; return;
} }
sql.setWebpw(new WarkingUser(player), args[0]); sql.setWebpw(new WarkingUser(player), args[0]);
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "Webpasswort gesetzt!")); player.sendMessage(BungeeCore.ChatPrefix + "Webpasswort gesetzt!");
} }
} }
} }