SteamWar/BungeeCore
Archiviert
13
2

Commenting Fight out + various small changes

Dieser Commit ist enthalten in:
Lixfel 2019-03-29 22:25:03 +01:00
Ursprung 78e6cd5696
Commit 510114e53c
17 geänderte Dateien mit 327 neuen und 141 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 de.warking.bungeecore.sql.sql;
import net.md_5.bungee.api.config.ServerInfo; 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;
@ -22,7 +23,7 @@ public class BungeeCore extends Plugin {
public static BungeeCore instance; public static BungeeCore instance;
public static String ChatPrefix; public static String ChatPrefix;
public static final String TeamchatPrefix = "§4T§7c§r §e"; public static final String TeamchatPrefix = "§4T§7c§r §e";
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy HH:mm"); public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy");
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<>(); public static final HashMap<String, String> commands = new HashMap<>();
@ -91,8 +92,9 @@ public class BungeeCore extends Plugin {
addCmd(new AlertCommand()); addCmd(new AlertCommand());
addCmd(new KickCommand()); addCmd(new KickCommand());
addCmd(new JoinmeCommand()); addCmd(new JoinmeCommand());
addCmd(new FightCommand()); //addCmd(new FightCommand());
addCmd(new HelpCommand()); addCmd(new HelpCommand());
addCmd(new BanCommand());
} }
@Override @Override

Datei anzeigen

@ -1,9 +1,15 @@
package de.warking.bungeecore; package de.warking.bungeecore;
import de.warking.bungeecore.arenasystem.Arena;
import de.warking.bungeecore.arenasystem.ArenaSystem; import de.warking.bungeecore.arenasystem.ArenaSystem;
import de.warking.bungeecore.sql.BannedUserIPs;
import de.warking.bungeecore.sql.WarkingUser;
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.ChatColor;
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.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.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;
@ -12,6 +18,7 @@ import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler; import net.md_5.bungee.event.EventHandler;
import java.util.List; import java.util.List;
import java.util.Map;
public class PlayerListener implements Listener { public class PlayerListener implements Listener {
@ -19,6 +26,7 @@ public class PlayerListener implements Listener {
public void onLogin(LoginEvent event) { public void onLogin(LoginEvent event) {
WarkingUser user = new WarkingUser(event.getConnection()); WarkingUser user = new WarkingUser(event.getConnection());
if(user.isBanned()) { if(user.isBanned()) {
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
event.setCancelled(true); event.setCancelled(true);
if (user.BanTime.before(WarkingUser.PermaBan)) { if (user.BanTime.before(WarkingUser.PermaBan)) {
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + "§cDu bist permanent gebannt. §r§lGrund§r: §c" + user.BanReason)); event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + "§cDu bist permanent gebannt. §r§lGrund§r: §c" + user.BanReason));
@ -27,6 +35,34 @@ public class PlayerListener implements Listener {
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));
} }
} }
List<BannedUserIPs> ips = BannedUserIPs.get(event.getConnection().getAddress().getAddress().getHostAddress());
if(ips.size() > 0){
StringBuilder potentialBan = new StringBuilder();
potentialBan.append(BungeeCore.ChatPrefix);
potentialBan.append("§cMögliche Bannumgehung durch §r");
potentialBan.append(user.UserName);
potentialBan.append("§c:");
for(BannedUserIPs banned : ips){
WarkingUser bannedUser = new WarkingUser(banned.getUserID());
potentialBan.append(" §6");
potentialBan.append(banned.getTimestamp().toLocalDateTime().format(BungeeCore.DateFormat));
potentialBan.append(" §c");
potentialBan.append(bannedUser.UserName);
}
TextComponent msg = new TextComponent(potentialBan.toString());
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cBanne Spieler wegen Bannumgehung").create()));
msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.UserName + " perma Bannumgehung"));
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
if ((target.hasPermission("bungeecore.teamchat"))
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|| target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN)){
target.sendMessage(msg);
}
}
}
} }
@EventHandler @EventHandler
@ -74,7 +110,12 @@ public class PlayerListener implements Listener {
break; break;
} }
//player.getModList(); For the Future! Map<String, String> modlist = player.getModList();
for(String key : modlist.keySet()){
System.out.println(key + " > " + modlist.get(key));
}
if(player.isForgeUser())
System.out.println("Forge user!");
} }
/** To redirect players to the lobby in case of server closure. */ /** To redirect players to the lobby in case of server closure. */
@ -104,6 +145,15 @@ public class PlayerListener implements Listener {
ev.setCancelServer(kickTo); ev.setCancelServer(kickTo);
} }
@EventHandler
public void onServerSwitchEvent(ServerSwitchEvent e){
ProxiedPlayer p = e.getPlayer();
Arena a = ArenaSystem.getArena(p);
if(a != null && !p.getServer().getInfo().equals(a.server)){
a.removePlayer(p);
}
}
@EventHandler @EventHandler
public void onChatEvent(ChatEvent e){ public void onChatEvent(ChatEvent e){
if(e.isCommand()){ if(e.isCommand()){
@ -129,9 +179,8 @@ public class PlayerListener implements Listener {
e.setCancelled(true); e.setCancelled(true);
return; return;
} }
if(ArenaSystem.getPlayer(sender) != null){ if(ArenaSystem.inArena(sender))
return; return;
}
String name = sender.getDisplayName(); String name = sender.getDisplayName();
String message = e.getMessage(); String message = e.getMessage();

Datei anzeigen

@ -11,31 +11,32 @@ import java.io.InputStreamReader;
import java.io.PrintWriter; import java.io.PrintWriter;
import java.net.InetSocketAddress; import java.net.InetSocketAddress;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator;
import java.util.List; 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; public final ArenaMode spielModus;
private Process p; private Process p;
private PrintWriter writer; private PrintWriter writer;
private ServerInfo server; public ServerInfo server;
private boolean started = false; private boolean started = false;
private final List<ArenaPlayer> cachedPlayers = new ArrayList<>(); private final List<ProxiedPlayer> cachedPlayers = new ArrayList<>();
private final List<ArenaPlayer> players = new ArrayList<>(); private final List<ProxiedPlayer> players = new ArrayList<>();
public Arena(String modus, int id){ public Arena(ArenaMode modus, int id){
spielModus = modus; spielModus = modus;
arenenNummer = id; arenenNummer = id;
serverName = modus + id; serverName = modus.name() + id;
int port = 2500 + arenenNummer; int port = 2500 + arenenNummer;
ProcessBuilder pb = new ProcessBuilder( ProcessBuilder pb = new ProcessBuilder(
"/home/netuser/mc", "/home/netuser/mc",
"-a", modus, serverName, Integer.toString(port)); "-a", modus.name(), serverName, Integer.toString(port));
try{ try{
p = pb.start(); p = pb.start();
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this); ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
@ -50,54 +51,30 @@ public class Arena implements Runnable{
} }
} }
private void sendPlayer(ArenaPlayer p){ public void sendPlayer(ProxiedPlayer p){
if(!started){ if(!started){
p.player.sendMessage(BungeeCore.ChatPrefix + "Die Arena wird gestartet, einen Moment bitte..."); p.sendMessage(BungeeCore.ChatPrefix + "Die Arena wird gestartet, einen Moment bitte...");
cachedPlayers.add(p); cachedPlayers.add(p);
}else{ }else{
if(players.contains(p)){ p.connect(server);
p.player.connect(server);
players.add(p); players.add(p);
} }
p.player.getServer().sendData("FightSystem:NewPlayer", p.role.name().getBytes());
}
} }
public void sendPlayer(ProxiedPlayer p){ public void removePlayer(ProxiedPlayer p){
ArenaRole role; Iterator<ProxiedPlayer> it = cachedPlayers.iterator();
switch(cachedPlayers.size() + players.size()){ while(it.hasNext()){
case 0: if(it.next().equals(p)){
role = ArenaRole.RED_LEADER; it.remove();
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; return;
}
switch(parent.role){ }
case RED_LEADER: it = players.iterator();
case RED_MEMBER: while(it.hasNext()){
sendPlayer(new ArenaPlayer(p, ArenaRole.RED_MEMBER)); if(it.next().equals(p)){
break; it.remove();
case BLUE_MEMBER: return;
case BLUE_LEADER: }
sendPlayer(new ArenaPlayer(p, ArenaRole.BLUE_MEMBER));
break;
case SPECTATOR:
default:
sendPlayer(new ArenaPlayer(p, ArenaRole.SPECTATOR));
break;
} }
} }
@ -118,42 +95,35 @@ public class Arena implements Runnable{
ArenaSystem.arenen.remove(this); ArenaSystem.arenen.remove(this);
} }
public ArenaPlayer getPlayer(ProxiedPlayer p){ public boolean inArena(ProxiedPlayer p){
for(int i = 0; i < cachedPlayers.size(); i++) for(ProxiedPlayer ap : cachedPlayers)
if(cachedPlayers.get(i).player.equals(p)){ if(ap.equals(p))
if(server.equals(p.getServer().getInfo())) { return true;
return cachedPlayers.get(i); for(ProxiedPlayer ap : players)
}else{ if(ap.equals(p))
cachedPlayers.remove(i); return true;
return null; return false;
}
}
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 {
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream())); BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line; String line = "";
while (!started && (line = reader.readLine()) != null) { while (!started && (line = reader.readLine()) != null) {
//started = line.contains(" INFO]: Done ("); Problematisch //started = line.contains(" INFO]: Done ("); Problematisch
started = line.contains("INFO]: [AAC] AAC has been enabled."); started = line.contains("INFO]: [AAC] AAC has been enabled.");
} }
//Thread.sleep(1000); if(line == null){
System.out.println("Fatal error starting arena!");
return;
}
for(ArenaPlayer aP : cachedPlayers){ Thread.sleep(200);
for(ProxiedPlayer aP : cachedPlayers){
sendPlayer(aP); sendPlayer(aP);
} }
cachedPlayers.clear(); cachedPlayers.clear();

Datei anzeigen

@ -0,0 +1,8 @@
package de.warking.bungeecore.arenasystem;
public enum ArenaMode {
AirShip,
WarShip,
WarGear,
MiniWarGear
}

Datei anzeigen

@ -1,13 +0,0 @@
package de.warking.bungeecore.arenasystem;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class ArenaPlayer {
public ProxiedPlayer player;
public ArenaRole role;
public ArenaPlayer(ProxiedPlayer p, ArenaRole r){
player = p;
role = r;
}
}

Datei anzeigen

@ -1,9 +0,0 @@
package de.warking.bungeecore.arenasystem;
public enum ArenaRole {
RED_LEADER,
RED_MEMBER,
BLUE_LEADER,
BLUE_MEMBER,
SPECTATOR
}

Datei anzeigen

@ -25,7 +25,7 @@ public class ArenaSystem {
return id; return id;
} }
public static Arena startServer(String modus){ public static Arena startServer(ArenaMode modus){
Arena arena = new Arena(modus, freeId()); Arena arena = new Arena(modus, freeId());
arenen.add(arena); arenen.add(arena);
return arena; return arena;
@ -36,19 +36,17 @@ public class ArenaSystem {
arenen.firstElement().stop(); arenen.firstElement().stop();
} }
public static ArenaPlayer getPlayer(ProxiedPlayer p){ public static boolean inArena(ProxiedPlayer p){
for(Arena a : arenen){ for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p); if(a.inArena(p))
if(aP != null) return true;
return aP;
} }
return null; return false;
} }
public static Arena getArena(ProxiedPlayer p){ public static Arena getArena(ProxiedPlayer p){
for(Arena a : arenen){ for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p); if(a.inArena(p))
if(aP != null)
return a; return a;
} }
return null; return null;

Datei anzeigen

@ -0,0 +1,63 @@
package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.sql.WarkingUser;
import net.md_5.bungee.api.*;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.sql.Timestamp;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.time.Instant;
import java.util.*;
public class BanCommand extends Command {
public BanCommand() {
super("ban", "bungeecore.ban");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length < 3){
sender.sendMessage(BungeeCore.ChatPrefix + "/ban [Spieler] [dd.mm.yyyy oder perma] [Grund]");
return;
}
WarkingUser target = new WarkingUser(args[0]);
if(target.UserName == null){
sender.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler existiert nicht.");
return;
}
StringBuilder msgBuilder = new StringBuilder();
msgBuilder.append(BungeeCore.ChatPrefix);
Timestamp banTime;
if(args[1].equalsIgnoreCase("perma")) {
msgBuilder.append("§cDu bist permanent gebannt. §r§lGrund§r: §c");
banTime = Timestamp.from(Instant.ofEpochSecond(946674800));
}else{
SimpleDateFormat dateFormat = new SimpleDateFormat("dd.MM.yyyy");
try{
Date parsedDate = dateFormat.parse(args[1]);
banTime = new java.sql.Timestamp(parsedDate.getTime());
msgBuilder.append(" Du bist bis zum ");
msgBuilder.append(banTime.toLocalDateTime().format(BungeeCore.DateFormat));
msgBuilder.append(" gebannt. §r§lGrund§r: §c");
}catch(ParseException e){
sender.sendMessage(BungeeCore.ChatPrefix + "§cUngültige Zeitangabe.");
return;
}
}
StringBuilder banReason = new StringBuilder();
for (int i = 2; i < args.length; i++){
banReason.append(args[i]).append(" ");
}
String msg = banReason.toString();
msgBuilder.append(msg);
sender.sendMessage(BungeeCore.ChatPrefix + "Du hast " + target.UserName + " gebannt. Grund: §c" + msg);
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(target.UUID);
target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg);
targetPlayer.disconnect(msgBuilder.toString());
}
}

Datei anzeigen

@ -27,6 +27,6 @@ public abstract class Command extends net.md_5.bungee.api.plugin.Command impleme
} }
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
return null; return new ArrayList<>();
} }
} }

Datei anzeigen

@ -2,6 +2,7 @@ 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.ArenaMode;
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.ProxyServer;
@ -23,7 +24,11 @@ public class FightCommand extends Command {
@Override @Override
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length != 1){ if(args.length != 1){
sender.sendMessage(BungeeCore.ChatPrefix + "/fight airship"); sender.sendMessage(BungeeCore.ChatPrefix + "§7Mit §6/fight §7kannst du einen neuen Kampf starten!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight AirShip §8- §7Starte einen §6AirShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarShip §8- §7Starte einen §6WarShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarGear §8- §7Starte einen §6WarGear§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight MiniWarGear §8- §7Starte einen §6Mini§8-§6WarGear§8-§7Kampf§8!");
return; return;
} }
if(sender instanceof ProxiedPlayer){ if(sender instanceof ProxiedPlayer){
@ -32,7 +37,19 @@ public class FightCommand extends Command {
switch(args[0].toLowerCase()){ switch(args[0].toLowerCase()){
case "as": case "as":
case "airship": case "airship":
arena = ArenaSystem.startServer("Airship"); arena = ArenaSystem.startServer(ArenaMode.AirShip);
break;
case "ws":
case "warship":
arena = ArenaSystem.startServer(ArenaMode.WarShip);
break;
case "wg":
case "wargear":
arena = ArenaSystem.startServer(ArenaMode.WarGear);
break;
case "mwg":
case "miniwargear":
arena = ArenaSystem.startServer(ArenaMode.MiniWarGear);
break; break;
default: default:
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]); sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]);
@ -40,8 +57,8 @@ public class FightCommand extends Command {
} }
arena.sendPlayer(player); arena.sendPlayer(player);
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "Kämpfe jetzt " + arena.spielModus + " gegen " + player.getName() + "[Hier Klicken]!"); TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §6hier§7, um jetzt §6" + arena.spielModus + " §7gegen §6" + player.getName() + " §7zu kämpfen!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen Spieler kämpfen").create())); tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen §7" + player.getName() + " §ckämpfen").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);
} }
@ -51,8 +68,14 @@ public class FightCommand extends Command {
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) { public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
List<String> gamemodes = new ArrayList<>(); List<String> gamemodes = new ArrayList<>();
if(args.length == 1){ if(args.length == 1){
gamemodes.add("airship"); gamemodes.add("AirShip");
gamemodes.add("as"); gamemodes.add("AS");
gamemodes.add("WarShip");
gamemodes.add("WS");
gamemodes.add("WarGear");
gamemodes.add("WG");
gamemodes.add("MiniWarGear");
gamemodes.add("MWG");
} }
System.out.println(args); System.out.println(args);
return gamemodes; return gamemodes;

Datei anzeigen

@ -16,12 +16,30 @@ public class HelpCommand extends Command {
public void execute(CommandSender sender, String[] args) { public void execute(CommandSender sender, String[] args) {
if(args.length != 1){ if(args.length != 1){
sender.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§l§7Hilfe")); TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Kehre von überall mit §6/l §7zur Lobby zurück!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZurück zur Lobby").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/l"));
sender.sendMessage(tc);
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "Klicke hier, um dem Server beizutreten!"); tc = new TextComponent(BungeeCore.ChatPrefix + "§7Komme mit §6/bau §7auf den Bauserver!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cServer beitreten").create())); tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZum Bauserver").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help ")); tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bauserver"));
sender.sendMessage(tc);
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Erhalte mit §6/bau §7Hilfe auf dem Bauserver!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cHilfe zum Bausystem").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau"));
sender.sendMessage(tc);
/*tc = new TextComponent(BungeeCore.ChatPrefix + "§7Starte mit §6/fight §7einen neuen Kampf!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZum Kampfsystem").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/fight"));
sender.sendMessage(tc);
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Trete mit §6/join [Spieler] §7einem Kampf bei!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cSpieler nachjoinen").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/join"));
sender.sendMessage(tc);*/
}else{ }else{
switch(args[0]){ switch(args[0]){

Datei anzeigen

@ -2,7 +2,6 @@ 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.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.ProxyServer;
@ -25,38 +24,32 @@ public class JoinmeCommand extends Command {
ProxiedPlayer player = (ProxiedPlayer) sender; ProxiedPlayer player = (ProxiedPlayer) sender;
if (args.length == 0 && player.hasPermission("bungeecore.joinme")) { if (args.length == 0 && 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 + "§7Klicke §6hier§8, §7um zu §6" + player.getName() + " §7auf §6" + player.getServer().getInfo().getName() + " §7zu kommen§8!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aSpieler folgen").create())); tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aSpieler folgen").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 if (args.length == 1) { } else if (args.length == 1) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]); ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null || !target.isConnected()){ if(target == null || !target.isConnected()){
player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit offline."); player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist offline.");
return; return;
}else if(target.equals(player)){ }else if(target.equals(player)){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu bist bereits in deiner Sphäre."); player.sendMessage(BungeeCore.ChatPrefix + "§cSei eins mit dir selbst!");
return; return;
} }
ServerInfo server = ProxyServer.getInstance().getPlayer(args[0]).getServer().getInfo(); ServerInfo server = target.getServer().getInfo();
String ServerPerm = BungeeCore.serverPermissions.get(server.getName()); String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
Arena arena = ArenaSystem.getArena(target);
if(ServerPerm == null){ if(arena != null){
Arena arena = ArenaSystem.getArena(player); arena.sendPlayer(player);
}else if(ServerPerm != null && !player.hasPermission(ServerPerm)){
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."); player.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst diesem Spieler derzeit nicht folgen.");
}else{ }else{
player.connect(server); player.connect(server);
} }
} else { } else {
player.sendMessage(BungeeCore.ChatPrefix + "/join [Spieler]"); player.sendMessage(BungeeCore.ChatPrefix + "§7Mit §r/join §8[§rSpieler§8] §7kannst du einem Spieler folgen §8(z.B. in eine Arena)§7.");
} }
} }
} }

Datei anzeigen

@ -31,7 +31,7 @@ public class TeamchatCommand extends Command {
msg = ChatColor.translateAlternateColorCodes('&', msg); msg = ChatColor.translateAlternateColorCodes('&', 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.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){ && target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
target.sendMessage(msg); target.sendMessage(msg);
} }

Datei anzeigen

@ -1,8 +1,8 @@
package de.warking.bungeecore.commands; package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore; import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.WarkingUser; import de.warking.bungeecore.sql.WarkingUser;
import de.warking.bungeecore.sql; import de.warking.bungeecore.sql.sql;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;

Datei anzeigen

@ -0,0 +1,64 @@
package de.warking.bungeecore.sql;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Timestamp;
import java.util.ArrayList;
import java.util.List;
public class BannedUserIPs {
private int UserID;
private Timestamp Timestamp;
private String IP;
private BannedUserIPs(int userID, Timestamp timestamp, String ip){
UserID = userID;
Timestamp = timestamp;
IP = ip;
}
public static List<BannedUserIPs> get(int userID){
List<BannedUserIPs> userIPs = new ArrayList<>();
ResultSet dbentry = sql.select("SELECT * FROM BannedUserIPs WHERE UserID = '" + userID + "' ORDER BY Timestamp ASC");
try {
while(dbentry.next()){
userIPs.add(new BannedUserIPs(
userID,
dbentry.getTimestamp("Timestamp"),
dbentry.getString("IP")));
}
} catch (SQLException e) {
e.printStackTrace();
}
return userIPs;
}
public static List<BannedUserIPs> get(String ip){
List<BannedUserIPs> userIDs = new ArrayList<>();
ResultSet dbentry = sql.select("SELECT * FROM BannedUserIPs WHERE IP = '" + ip + "' ORDER BY Timestamp DESC");
try {
while(dbentry.next()){
userIDs.add(new BannedUserIPs(
dbentry.getInt("UserID"),
dbentry.getTimestamp("Timestamp"),
ip));
}
} catch (SQLException e) {
e.printStackTrace();
}
return userIDs;
}
public int getUserID() {
return UserID;
}
public java.sql.Timestamp getTimestamp() {
return Timestamp;
}
public String getIP() {
return IP;
}
}

Datei anzeigen

@ -1,5 +1,6 @@
package de.warking.bungeecore; package de.warking.bungeecore.sql;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.PendingConnection; import net.md_5.bungee.api.connection.PendingConnection;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -20,12 +21,16 @@ public class WarkingUser {
public static Timestamp PermaBan = Timestamp.from(Instant.ofEpochSecond(946684800)); public static Timestamp PermaBan = Timestamp.from(Instant.ofEpochSecond(946684800));
public WarkingUser(int id){
init(sql.select("SELECT * FROM UserData WHERE id = '" + id + "'"));
}
public WarkingUser(UUID UUID){ public WarkingUser(UUID UUID){
init(sql.select("SELECT * FROM UserData WHERE UUID = '" + UUID.toString() + "'")); init(sql.select("SELECT * FROM UserData WHERE UUID = '" + UUID.toString() + "'"));
} }
public WarkingUser(String UserName){ public WarkingUser(String UserName){
init(sql.select("SELECT * FROM UserData WHERE UserName = '" + UserName + "'")); init(sql.select("SELECT * FROM UserData WHERE lower(UserName) = '" + UserName.toLowerCase() + "'"));
} }
public WarkingUser(PendingConnection connection){ public WarkingUser(PendingConnection connection){
@ -91,9 +96,24 @@ public class WarkingUser {
return true; return true;
}else{ }else{
sql.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE UUID = '" + UUID.toString() + "'"); sql.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE UUID = '" + UUID.toString() + "'");
sql.update("DELETE FROM BannedUserIPs WHERE UserID = '" + id + "'");
BanTime = null; BanTime = null;
BanReason = ""; BanReason = "";
return false; return false;
} }
} }
public void updateBanIP(String ip){
sql.update("INSERT INTO BannedUserIPs\n" +
" (UserID, Timestamp, IP)\n" +
"VALUES\n" +
" (" + id + ", NOW(), '" + ip + "')\n" +
"ON DUPLICATE KEY UPDATE\n" +
" Timestamp=NOW()");
}
public void banPlayer(String ip, Timestamp time, String banReason){
sql.update("UPDATE UserData SET BanTime = '" + time.toString() + "', BanReason = '" + banReason + "' WHERE UUID = '" + UUID.toString() + "'");
updateBanIP(ip);
}
} }

Datei anzeigen

@ -1,4 +1,4 @@
package de.warking.bungeecore; package de.warking.bungeecore.sql;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;