geforkt von SteamWar/BungeeCore
Adding challenge system (completly untested)
Dieser Commit ist enthalten in:
Ursprung
cbae6bdef1
Commit
90a456f200
@ -111,6 +111,7 @@ public class BungeeCore extends Plugin {
|
|||||||
addCmd(new HelpCommand());
|
addCmd(new HelpCommand());
|
||||||
addCmd(new BanCommand());
|
addCmd(new BanCommand());
|
||||||
addCmd(new DenyCommand("watchcat", "wc"));
|
addCmd(new DenyCommand("watchcat", "wc"));
|
||||||
|
addCmd(new ChallengeCommand());
|
||||||
|
|
||||||
BroadCastMsgs = config.getStringList("broadcasts").toArray(new String[1]);
|
BroadCastMsgs = config.getStringList("broadcasts").toArray(new String[1]);
|
||||||
getProxy().getScheduler().schedule(this, () -> {
|
getProxy().getScheduler().schedule(this, () -> {
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package de.steamwar.bungeecore;
|
package de.steamwar.bungeecore;
|
||||||
|
|
||||||
import de.steamwar.bungeecore.commands.BauCommand;
|
import de.steamwar.bungeecore.commands.BauCommand;
|
||||||
|
import de.steamwar.bungeecore.commands.ChallengeCommand;
|
||||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||||
import de.steamwar.bungeecore.sql.WarkingUser;
|
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||||
import net.md_5.bungee.api.AbstractReconnectHandler;
|
import net.md_5.bungee.api.AbstractReconnectHandler;
|
||||||
@ -167,6 +168,11 @@ public class PlayerListener implements Listener {
|
|||||||
ev.setCancelServer(kickTo);
|
ev.setCancelServer(kickTo);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onDisconnect(PlayerDisconnectEvent e){
|
||||||
|
ChallengeCommand.challenges.remove(e.getPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onChatEvent(ChatEvent e){
|
public void onChatEvent(ChatEvent e){
|
||||||
if(e.getMessage().startsWith("/")){
|
if(e.getMessage().startsWith("/")){
|
||||||
@ -177,7 +183,7 @@ 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].equalsIgnoreCase("/bau") && e.getSender() instanceof ProxiedPlayer){
|
}else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b")) && e.getSender() instanceof ProxiedPlayer){
|
||||||
BauCommand.onBau(e, command);
|
BauCommand.onBau(e, command);
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
|
126
src/de/steamwar/bungeecore/commands/ChallengeCommand.java
Normale Datei
126
src/de/steamwar/bungeecore/commands/ChallengeCommand.java
Normale Datei
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -20,10 +20,10 @@ import java.util.Random;
|
|||||||
public class FightCommand extends Command {
|
public class FightCommand extends Command {
|
||||||
|
|
||||||
public FightCommand() {
|
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){
|
if(args.length == 2){
|
||||||
String map = args[1].toLowerCase();
|
String map = args[1].toLowerCase();
|
||||||
for(String realMap : BungeeCore.arenaMaps.get(mode)){
|
for(String realMap : BungeeCore.arenaMaps.get(mode)){
|
||||||
@ -43,10 +43,11 @@ public class FightCommand extends Command {
|
|||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
if(args.length != 1 && args.length != 2){
|
if(args.length != 1 && args.length != 2){
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "§7Mit §e/fight §7kannst du einen neuen Kampf starten!");
|
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 + "§8/§efight §8[§7Spielmodus§8] <§7Arena§8>");
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarShip §8- §7Starte einen §eWarShip§8-§7Kampf§8!");
|
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight AirShip §8- §7Starte einen §eAirShip§8-§7Kampf§8!");
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "/fight WarGear §8- §7Starte einen §eWarGear§8-§7Kampf§8!");
|
sender.sendMessage(BungeeCore.ChatPrefix + "§8/§efight WarShip §8- §7Starte einen §eWarShip§8-§7Kampf§8!");
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "/fight MiniWarGear §8- §7Starte einen §eMiniWarGear§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;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -120,6 +121,27 @@ public class FightCommand extends Command {
|
|||||||
gamemodes.add("WG");
|
gamemodes.add("WG");
|
||||||
gamemodes.add("MiniWarGear");
|
gamemodes.add("MiniWarGear");
|
||||||
gamemodes.add("MWG");
|
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;
|
return gamemodes;
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren