Archiviert
1
0

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.commands.*;
import de.warking.bungeecore.sql.sql;
import net.md_5.bungee.api.config.ServerInfo;
import net.md_5.bungee.api.plugin.Command;
import net.md_5.bungee.api.plugin.Plugin;
@ -22,7 +23,7 @@ public class BungeeCore extends Plugin {
public static BungeeCore instance;
public static String ChatPrefix;
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 final HashMap<String, String> serverPermissions = 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 KickCommand());
addCmd(new JoinmeCommand());
addCmd(new FightCommand());
//addCmd(new FightCommand());
addCmd(new HelpCommand());
addCmd(new BanCommand());
}
@Override

Datei anzeigen

@ -1,9 +1,15 @@
package de.warking.bungeecore;
import de.warking.bungeecore.arenasystem.Arena;
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.ChatColor;
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.config.ServerInfo;
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 java.util.List;
import java.util.Map;
public class PlayerListener implements Listener {
@ -19,6 +26,7 @@ public class PlayerListener implements Listener {
public void onLogin(LoginEvent event) {
WarkingUser user = new WarkingUser(event.getConnection());
if(user.isBanned()) {
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
event.setCancelled(true);
if (user.BanTime.before(WarkingUser.PermaBan)) {
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));
}
}
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
@ -74,7 +110,12 @@ public class PlayerListener implements Listener {
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. */
@ -104,6 +145,15 @@ public class PlayerListener implements Listener {
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
public void onChatEvent(ChatEvent e){
if(e.isCommand()){
@ -129,9 +179,8 @@ public class PlayerListener implements Listener {
e.setCancelled(true);
return;
}
if(ArenaSystem.getPlayer(sender) != null){
if(ArenaSystem.inArena(sender))
return;
}
String name = sender.getDisplayName();
String message = e.getMessage();

Datei anzeigen

@ -11,31 +11,32 @@ import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.net.InetSocketAddress;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
public class Arena implements Runnable{
public final String serverName;
public final int arenenNummer;
public final String spielModus;
public final ArenaMode spielModus;
private Process p;
private PrintWriter writer;
private ServerInfo server;
public ServerInfo server;
private boolean started = false;
private final List<ArenaPlayer> cachedPlayers = new ArrayList<>();
private final List<ArenaPlayer> players = new ArrayList<>();
private final List<ProxiedPlayer> cachedPlayers = new ArrayList<>();
private final List<ProxiedPlayer> players = new ArrayList<>();
public Arena(String modus, int id){
public Arena(ArenaMode modus, int id){
spielModus = modus;
arenenNummer = id;
serverName = modus + id;
serverName = modus.name() + id;
int port = 2500 + arenenNummer;
ProcessBuilder pb = new ProcessBuilder(
"/home/netuser/mc",
"-a", modus, serverName, Integer.toString(port));
"-a", modus.name(), serverName, Integer.toString(port));
try{
p = pb.start();
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){
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);
}else{
if(players.contains(p)){
p.player.connect(server);
players.add(p);
p.connect(server);
players.add(p);
}
}
public void removePlayer(ProxiedPlayer p){
Iterator<ProxiedPlayer> it = cachedPlayers.iterator();
while(it.hasNext()){
if(it.next().equals(p)){
it.remove();
return;
}
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;
it = players.iterator();
while(it.hasNext()){
if(it.next().equals(p)){
it.remove();
return;
}
}
}
@ -118,42 +95,35 @@ public class Arena implements Runnable{
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;
public boolean inArena(ProxiedPlayer p){
for(ProxiedPlayer ap : cachedPlayers)
if(ap.equals(p))
return true;
for(ProxiedPlayer ap : players)
if(ap.equals(p))
return true;
return false;
}
@Override
public void run() {
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
String line;
String line = "";
while (!started && (line = reader.readLine()) != null) {
//started = line.contains(" INFO]: Done ("); Problematisch
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);
}
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;
}
public static Arena startServer(String modus){
public static Arena startServer(ArenaMode modus){
Arena arena = new Arena(modus, freeId());
arenen.add(arena);
return arena;
@ -36,19 +36,17 @@ public class ArenaSystem {
arenen.firstElement().stop();
}
public static ArenaPlayer getPlayer(ProxiedPlayer p){
public static boolean inArena(ProxiedPlayer p){
for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p);
if(aP != null)
return aP;
if(a.inArena(p))
return true;
}
return null;
return false;
}
public static Arena getArena(ProxiedPlayer p){
for(Arena a : arenen){
ArenaPlayer aP = a.getPlayer(p);
if(aP != null)
if(a.inArena(p))
return a;
}
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) {
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.arenasystem.Arena;
import de.warking.bungeecore.arenasystem.ArenaMode;
import de.warking.bungeecore.arenasystem.ArenaSystem;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -23,7 +24,11 @@ public class FightCommand extends Command {
@Override
public void execute(CommandSender sender, String[] args) {
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;
}
if(sender instanceof ProxiedPlayer){
@ -32,7 +37,19 @@ public class FightCommand extends Command {
switch(args[0].toLowerCase()){
case "as":
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;
default:
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]);
@ -40,8 +57,8 @@ public class FightCommand extends Command {
}
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()));
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 §7" + player.getName() + " §ckämpfen").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
ProxyServer.getInstance().broadcast(tc);
}
@ -51,8 +68,14 @@ public class FightCommand extends Command {
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
List<String> gamemodes = new ArrayList<>();
if(args.length == 1){
gamemodes.add("airship");
gamemodes.add("as");
gamemodes.add("AirShip");
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);
return gamemodes;

Datei anzeigen

@ -16,12 +16,30 @@ public class HelpCommand extends Command {
public void execute(CommandSender sender, String[] args) {
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.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cServer beitreten").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help "));
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Komme mit §6/bau §7auf den Bauserver!");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZum Bauserver").create()));
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{
switch(args[0]){

Datei anzeigen

@ -2,7 +2,6 @@ package de.warking.bungeecore.commands;
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.ProxyServer;
@ -25,38 +24,32 @@ public class JoinmeCommand extends Command {
ProxiedPlayer player = (ProxiedPlayer) sender;
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.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
ProxyServer.getInstance().broadcast(tc);
} else if (args.length == 1) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null || !target.isConnected()){
player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist derzeit offline.");
player.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist offline.");
return;
}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;
}
ServerInfo server = ProxyServer.getInstance().getPlayer(args[0]).getServer().getInfo();
ServerInfo server = target.getServer().getInfo();
String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
Arena arena = ArenaSystem.getArena(target);
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)){
if(arena != null){
arena.sendPlayer(player);
}else if(ServerPerm != null && !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]");
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);
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.sendMessage(msg);
}

Datei anzeigen

@ -1,8 +1,8 @@
package de.warking.bungeecore.commands;
import de.warking.bungeecore.BungeeCore;
import de.warking.bungeecore.WarkingUser;
import de.warking.bungeecore.sql;
import de.warking.bungeecore.sql.WarkingUser;
import de.warking.bungeecore.sql.sql;
import net.md_5.bungee.api.CommandSender;
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.ProxiedPlayer;
@ -20,12 +21,16 @@ public class WarkingUser {
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){
init(sql.select("SELECT * FROM UserData WHERE UUID = '" + UUID.toString() + "'"));
}
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){
@ -91,9 +96,24 @@ public class WarkingUser {
return true;
}else{
sql.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE UUID = '" + UUID.toString() + "'");
sql.update("DELETE FROM BannedUserIPs WHERE UserID = '" + id + "'");
BanTime = null;
BanReason = "";
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.DriverManager;