geforkt von SteamWar/BungeeCore
Adding support to multiple arenas
Dieser Commit ist enthalten in:
Ursprung
c4390df7fa
Commit
ffa69b1929
@ -1,8 +1,8 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaMode;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.commands.*;
|
||||
import de.warking.bungeecore.commands.*;
|
||||
import de.steamwar.bungeecore.sql.sql;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
@ -16,12 +16,12 @@ import java.io.IOException;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class BungeeCore extends Plugin {
|
||||
|
||||
private Configuration config;
|
||||
public static BungeeCore instance;
|
||||
public static String ChatPrefix;
|
||||
public static final String TeamchatPrefix = "§4T§7c§r §e";
|
||||
@ -29,12 +29,14 @@ public class BungeeCore extends Plugin {
|
||||
public static String LobbyServer;
|
||||
public static String [] BroadCastMsgs;
|
||||
public static int LastBroadCast = 0;
|
||||
public static final HashMap<String, String> serverPermissions = new HashMap<>();
|
||||
public static final HashMap<String, String> commands = new HashMap<>();
|
||||
public static final Map<String, String> serverPermissions = new HashMap<>();
|
||||
public static final Map<String, String> commands = new HashMap<>();
|
||||
public static final Map<ArenaMode, List<String>> arenaMaps = new HashMap<>();
|
||||
|
||||
@Override
|
||||
public void onEnable(){
|
||||
instance = this;
|
||||
Configuration config;
|
||||
try{
|
||||
if(!getDataFolder().exists()){
|
||||
getDataFolder().mkdir();
|
||||
@ -89,11 +91,15 @@ public class BungeeCore extends Plugin {
|
||||
commands.put("/bau", "");
|
||||
commands.remove("/bauserver");
|
||||
|
||||
final Configuration maps = config.getSection("maps");
|
||||
for(final String modeName : maps.getKeys()){
|
||||
arenaMaps.put(ArenaMode.valueOf(modeName), maps.getStringList(modeName));
|
||||
}
|
||||
|
||||
addCmd(new TeamchatCommand());
|
||||
addCmd(new MsgCommand());
|
||||
addCmd(new RCommand());
|
||||
addCmd(new PingCommand());
|
||||
//addCmd(new DenyCommand("list", "pl", "plugins", "ver", "version", "about"));
|
||||
addCmd(new WebpwCommand());
|
||||
addCmd(new AlertCommand());
|
||||
addCmd(new KickCommand());
|
||||
@ -109,7 +115,7 @@ public class BungeeCore extends Plugin {
|
||||
if(LastBroadCast == BroadCastMsgs.length){
|
||||
LastBroadCast = 0;
|
||||
}
|
||||
}, 5, 5, TimeUnit.MINUTES);
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -16,29 +16,27 @@ import java.util.List;
|
||||
|
||||
public class Arena implements Runnable{
|
||||
|
||||
public final String serverName;
|
||||
public final int arenenNummer;
|
||||
final String serverName;
|
||||
final int arenenNummer;
|
||||
public final ArenaMode spielModus;
|
||||
|
||||
private Process p;
|
||||
private PrintWriter writer;
|
||||
public ServerInfo server;
|
||||
private String map;
|
||||
private boolean started = false;
|
||||
|
||||
private final List<ProxiedPlayer> cachedPlayers = new ArrayList<>();
|
||||
private final List<ProxiedPlayer> players = new ArrayList<>();
|
||||
|
||||
|
||||
public Arena(ArenaMode modus, int id, String map){
|
||||
Arena(ArenaMode modus, int id, String map){
|
||||
spielModus = modus;
|
||||
arenenNummer = id;
|
||||
serverName = modus.name() + id;
|
||||
this.map = map;
|
||||
int port = 2500 + arenenNummer;
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
"/home/minecraft/mc",
|
||||
"-a", modus.name(), serverName, Integer.toString(port), "Arena");
|
||||
"-a", modus.name(), serverName, Integer.toString(port), map);
|
||||
try{
|
||||
p = pb.start();
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
|
||||
@ -108,7 +106,7 @@ public class Arena implements Runnable{
|
||||
stop();
|
||||
}
|
||||
|
||||
public boolean inArena(ProxiedPlayer p){
|
||||
boolean inArena(ProxiedPlayer p){
|
||||
for(ProxiedPlayer ap : cachedPlayers)
|
||||
if(ap.equals(p))
|
||||
return true;
|
||||
|
@ -25,8 +25,8 @@ public class ArenaSystem {
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Arena startServer(ArenaMode modus){
|
||||
Arena arena = new Arena(modus, freeId());
|
||||
public static Arena startServer(ArenaMode modus, String map){
|
||||
Arena arena = new Arena(modus, freeId(), map);
|
||||
arenen.add(arena);
|
||||
return arena;
|
||||
}
|
||||
|
@ -1,21 +0,0 @@
|
||||
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."));
|
||||
}
|
||||
}
|
||||
}
|
@ -14,6 +14,7 @@ import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
|
||||
public class FightCommand extends Command {
|
||||
|
||||
@ -21,9 +22,25 @@ public class FightCommand extends Command {
|
||||
super("fight", "");
|
||||
}
|
||||
|
||||
private String getMap(CommandSender sender, ArenaMode mode, String[] args){
|
||||
if(args.length == 2){
|
||||
String map = args[1].toLowerCase();
|
||||
for(String realMap : BungeeCore.arenaMaps.get(mode)){
|
||||
if(map.equalsIgnoreCase(realMap))
|
||||
return realMap;
|
||||
}
|
||||
sender.sendMessage(BungeeCore.ChatPrefix + "§cDie gewünschte Arena gibt es nicht.");
|
||||
return null;
|
||||
}else{
|
||||
List<String> l = BungeeCore.arenaMaps.get(mode);
|
||||
Random rand = new Random();
|
||||
return l.get(rand.nextInt(l.size()));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(CommandSender sender, String[] args) {
|
||||
if(args.length != 1){
|
||||
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!");
|
||||
@ -40,23 +57,36 @@ public class FightCommand extends Command {
|
||||
return;
|
||||
}
|
||||
|
||||
String map;
|
||||
Arena arena;
|
||||
switch(args[0].toLowerCase()){
|
||||
case "as":
|
||||
case "airship":
|
||||
arena = ArenaSystem.startServer(ArenaMode.AirShip);
|
||||
map = getMap(sender, ArenaMode.AirShip, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.AirShip, map);
|
||||
break;
|
||||
case "ws":
|
||||
case "warship":
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarShip);
|
||||
map = getMap(sender, ArenaMode.WarShip, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarShip, map);
|
||||
break;
|
||||
case "wg":
|
||||
case "wargear":
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarGear);
|
||||
map = getMap(sender, ArenaMode.WarGear, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarGear, map);
|
||||
break;
|
||||
case "mwg":
|
||||
case "miniwargear":
|
||||
arena = ArenaSystem.startServer(ArenaMode.MiniWarGear);
|
||||
map = getMap(sender, ArenaMode.MiniWarGear, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.MiniWarGear, map);
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren