Archiviert
1
0

Merge branch 'forgeanalyzer'

# Conflicts:
#	src/de/steamwar/bungeecore/PlayerListener.java
Dieser Commit ist enthalten in:
Lixfel 2019-07-12 16:55:52 +02:00
Commit 14c2a7d362
6 geänderte Dateien mit 302 neuen und 13 gelöschten Zeilen

Datei anzeigen

@ -110,6 +110,8 @@ public class BungeeCore extends Plugin {
addCmd(new FightCommand());
addCmd(new HelpCommand());
addCmd(new BanCommand());
addCmd(new DenyCommand("watchcat", "wc"));
addCmd(new ChallengeCommand());
BroadCastMsgs = config.getStringList("broadcasts").toArray(new String[1]);
getProxy().getScheduler().schedule(this, () -> {

Datei anzeigen

@ -1,6 +1,7 @@
package de.steamwar.bungeecore;
import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.commands.ChallengeCommand;
import de.steamwar.bungeecore.sql.BannedUserIPs;
import de.steamwar.bungeecore.sql.WarkingUser;
import net.md_5.bungee.api.AbstractReconnectHandler;
@ -16,8 +17,8 @@ import net.md_5.bungee.api.event.*;
import net.md_5.bungee.api.plugin.Listener;
import net.md_5.bungee.event.EventHandler;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
public class PlayerListener implements Listener {
@ -110,12 +111,34 @@ public class PlayerListener implements Listener {
break;
}
Map<String, String> modlist = player.getModList();
for(String key : modlist.keySet()){
System.out.println(key + " > " + modlist.get(key));
for(Subserver subserver : Subserver.getServerList()){
if(subserver.getType() == Servertype.ARENA){
Iterator<ProxiedPlayer> it = subserver.getServer().getPlayers().iterator();
if(it.hasNext()){
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §ehier§7, um §e" + subserver.getServer().getName() + " §7beizutreten");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eArena beitreten").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + it.next().getName()));
player.sendMessage(tc);
}
if(player.isForgeUser())
System.out.println("Forge user!");
}
}
if(player.getPendingConnection().getVersion() < 335){
player.sendMessage(BungeeCore.ChatPrefix + "§cWir empfehlen die Minecraft-Version 1.12.2");
}
/*
ByteArrayDataOutput output = ByteStreams.newDataOutput();
output.writeUTF("FML|HS");
if(player.getPendingConnection().getVersion() > 340){
//1.13+
player.sendData("minecraft:register", output.toByteArray());
}else{
//1.12-
player.sendData("REGISTER", output.toByteArray());
}
player.sendData("FML|HS", new byte[]{0, 2, 0, 0, 0, 0});*/
}
/** To redirect players to the lobby in case of server closure. */
@ -145,6 +168,11 @@ public class PlayerListener implements Listener {
ev.setCancelServer(kickTo);
}
@EventHandler
public void onDisconnect(PlayerDisconnectEvent e){
ChallengeCommand.challenges.remove(e.getPlayer());
}
@EventHandler
public void onChatEvent(ChatEvent e){
if(e.getMessage().startsWith("/")){
@ -155,7 +183,7 @@ public class PlayerListener implements Listener {
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Befehl.");
}
}else if(command[0].equalsIgnoreCase("/bau") && e.getSender() instanceof ProxiedPlayer){
}else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b")) && e.getSender() instanceof ProxiedPlayer){
BauCommand.onBau(e, command);
}
}else{
@ -235,4 +263,93 @@ public class PlayerListener implements Listener {
}
}
}
/*@EventHandler
public void onPluginMessageEvent(PluginMessageEvent e){
System.out.println(e.getSender().getAddress().getHostString() + " " + e.getTag() + " " + Arrays.toString(e.getData()));
if(!e.getTag().equals("FML|HS")){
return;
}
e.setCancelled(true);
byte[] data = e.getData();
ProxiedPlayer p = getPlayer(e.getSender());
switch(data[0]){
case 2:
int numMods = readVarInt(data, 1);
System.out.println("Number of mods: " + numMods);
int bytePos = 1 + readVarIntLength(data, 1);
for(int i = 0; i < numMods; i++){
byte[] name = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
bytePos += 1 + data[bytePos];
byte[] version = Arrays.copyOfRange(data, bytePos + 1, bytePos + data[bytePos] + 1);
bytePos += 1 + data[bytePos];
System.out.println(new String(name) + " " + new String(version));
}
p.sendData("FML|HS", new byte[]{2, 0});
//p.sendData("FML|HS", new byte[]{2, 1, 9, 109, 105, 110, 101, 99, 114, 97, 102, 116, 6, 49, 46, 49, 50, 46, 50});
break;
case -1:
switch(data[1]){
case 2:
p.sendData("FML|HS", new byte[]{3, 0, 1, 97, 0, 0, 0});
break;
case 3:
p.sendData("FML|HS", new byte[]{-1, 2});
break;
case 4:
p.sendData("FML|HS", new byte[]{-1, 3});
break;
default:
break;
}
break;
case 1:
default:
break;
}
}
private static ProxiedPlayer getPlayer(Connection c){
for(ProxiedPlayer p : ProxyServer.getInstance().getPlayers()){
if(p.getPendingConnection().getAddress().equals(c.getAddress())){
return p;
}
}
return null;
}
private static int readVarInt(byte[] array, int startPos) {
int numRead = 0;
int result = 0;
byte read;
do {
read = array[startPos + numRead];
int value = (read & 0b01111111);
result |= (value << (7 * numRead));
numRead++;
if (numRead > 5) {
break;
}
} while ((read & 0b10000000) != 0);
return result;
}
private static int readVarIntLength(byte[] array, int startPos) {
int numRead = 0;
byte read;
do {
read = array[startPos + numRead];
numRead++;
if (numRead > 5) {
break;
}
} while ((read & 0b10000000) != 0);
return numRead;
}*/
}

Datei anzeigen

@ -0,0 +1,126 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.*;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import java.util.*;
public class ChallengeCommand extends Command {
public static final Map<ProxiedPlayer, List<ProxiedPlayer>> challenges = new HashMap<>();
public ChallengeCommand() {
super("challenge", "");
}
@Override
public void execute(CommandSender sender, String[] args) {
if(args.length != 2){
sender.sendMessage(BungeeCore.ChatPrefix + "§7Mit §e/challenge §7kannst du jemanden herausfordern!");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§echallenge §8[§7Spieler§8] §8[§7Spielmodus§8]");
return;
}
if(!(sender instanceof ProxiedPlayer)){
return;
}
ProxiedPlayer player = (ProxiedPlayer) sender;
Subserver subserver = Subserver.getSubserver(player);
if(subserver != null && subserver.getType() == Servertype.ARENA){
player.sendMessage(BungeeCore.ChatPrefix + "§cDu befindest dich bereits in einer Arena.");
return;
}
ProxiedPlayer target = (ProxiedPlayer) ProxyServer.getInstance().getPlayer(args[0]);
if(target == null){
player.sendMessage(BungeeCore.ChatPrefix + "§cDer gewünschte Spieler ist nicht online.");
return;
}
subserver = Subserver.getSubserver(target);
if(subserver != null && subserver.getType() == Servertype.ARENA){
player.sendMessage(BungeeCore.ChatPrefix + "§cDer Herausgeforderte ist bereits in einer Arena.");
return;
}
String map;
ArenaMode mode;
switch(args[1].toLowerCase()){
case "as":
case "airship":
map = FightCommand.getMap(sender, ArenaMode.AirShip, new String[0]);
mode = ArenaMode.AirShip;
break;
case "ws":
case "warship":
map = FightCommand.getMap(sender, ArenaMode.WarShip, new String[0]);
mode = ArenaMode.WarShip;
break;
case "wg":
case "wargear":
map = FightCommand.getMap(sender, ArenaMode.WarGear, new String[0]);
mode = ArenaMode.WarGear;
break;
case "mwg":
case "miniwargear":
map = FightCommand.getMap(sender, ArenaMode.MiniWarGear, new String[0]);
mode = ArenaMode.MiniWarGear;
break;
default:
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[1]);
return;
}
if(challenges.containsKey(target) && challenges.get(target).contains(player)){
challenges.remove(target);
challenges.remove(player);
Subserver arena = SubserverSystem.startArena(mode, map);
arena.sendPlayer(player);
arena.sendPlayer(target);
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§e" + mode.name() + "§7-§eDuell§7: " + player.getName() + " vs " + target.getName());
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aZuschauen").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
ProxyServer.getInstance().broadcast(tc);
}else{
if(!challenges.containsKey(player)){
challenges.put(player, new LinkedList<>());
}
challenges.get(player).add(target);
player.sendMessage(BungeeCore.ChatPrefix + "§7Du hast §e" + target.getName() + " §7zu einem §e" + mode.name() + "-Kampf §7herausgefordert!");
target.sendMessage(BungeeCore.ChatPrefix + "§e" + player.getName() + " §7 hat dich zu einem §e" + mode.name() + "-Kampf §7herausgefordert!");
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §ehier§7, um die Herausforderung anzunehmen");
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aHerausforderung annehmen").create()));
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/challenge " + player.getName() + " " + mode.name()));
target.sendMessage(tc);
}
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
List<String> gamemodes = new ArrayList<>();
if(args.length == 2){
gamemodes.add("AirShip");
gamemodes.add("AS");
gamemodes.add("WarShip");
gamemodes.add("WS");
gamemodes.add("WarGear");
gamemodes.add("WG");
gamemodes.add("MiniWarGear");
gamemodes.add("MWG");
}
return gamemodes;
}
}

Datei anzeigen

@ -0,0 +1,21 @@
package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.TextComponent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class DenyCommand extends Command {
public DenyCommand(String cmd, String ...aliases) {
super(cmd, "", aliases);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(sender instanceof ProxiedPlayer){
ProxiedPlayer player = (ProxiedPlayer) sender;
player.sendMessage(new TextComponent(BungeeCore.ChatPrefix + "§cUnbekannter Befehl."));
}
}
}

Datei anzeigen

@ -20,10 +20,10 @@ import java.util.Random;
public class FightCommand extends Command {
public FightCommand() {
super("fight", "");
super("fight", "", "f");
}
private String getMap(CommandSender sender, ArenaMode mode, String[] args){
static String getMap(CommandSender sender, ArenaMode mode, String[] args){
if(args.length == 2){
String map = args[1].toLowerCase();
for(String realMap : BungeeCore.arenaMaps.get(mode)){
@ -43,10 +43,11 @@ public class FightCommand extends Command {
public void execute(CommandSender sender, String[] args) {
if(args.length != 1 && args.length != 2){
sender.sendMessage(BungeeCore.ChatPrefix + "§7Mit §e/fight §7kannst du einen neuen Kampf starten!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight AirShip §8- §7Starte einen §eAirShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarShip §8- §7Starte einen §eWarShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarGear §8- §7Starte einen §eWarGear§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "/fight MiniWarGear §8- §7Starte einen §eMiniWarGear§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight §8[§7Spielmodus§8] <§7Arena§8>");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight AirShip §8- §7Starte einen §eAirShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight WarShip §8- §7Starte einen §eWarShip§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight WarGear §8- §7Starte einen §eWarGear§8-§7Kampf§8!");
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight MiniWarGear §8- §7Starte einen §eMiniWarGear§8-§7Kampf§8!");
return;
}
@ -120,6 +121,27 @@ public class FightCommand extends Command {
gamemodes.add("WG");
gamemodes.add("MiniWarGear");
gamemodes.add("MWG");
}else if(args.length == 2){
switch(args[1].toLowerCase()){
case "as":
case "airship":
gamemodes.addAll(BungeeCore.arenaMaps.get(ArenaMode.AirShip));
break;
case "ws":
case "warship":
gamemodes.addAll(BungeeCore.arenaMaps.get(ArenaMode.WarShip));
break;
case "wg":
case "wargear":
gamemodes.addAll(BungeeCore.arenaMaps.get(ArenaMode.WarGear));
break;
case "mwg":
case "miniwargear":
gamemodes.addAll(BungeeCore.arenaMaps.get(ArenaMode.MiniWarGear));
break;
default:
break;
}
}
return gamemodes;
}

Datei anzeigen

@ -50,6 +50,7 @@ public class HelpCommand extends Command {
sender.sendMessage("§8/§espeed §8- §7Ändert deine Fluggeschwindigkeit");
sender.sendMessage("§8/§env §8- §7(de)aktiviert Nachtsicht");
sender.sendMessage("§8/§etrace §8- §7Gibt einen Überblick über den TNT-Tracer");
sender.sendMessage("§8/§eprotect §8- §7Schützt den Boden der (M)WG-Region");
sender.sendMessage("§8/§ebauinfo §8- §7Gibt dir Informationen über den Bauserver");
sender.sendMessage("§8/§ehelp bauserver §8- §7Hilfe zum Bauserver");
}