geforkt von SteamWar/BungeeCore
Reintegrating with PersistentBungeeCore
Dieser Commit ist enthalten in:
Ursprung
0f1240faf1
Commit
31ff23f1c1
1
.gitignore
vendored
1
.gitignore
vendored
@ -1,3 +1,2 @@
|
||||
.idea
|
||||
target
|
||||
dependency-reduced-pom.xml
|
11
pom.xml
11
pom.xml
@ -19,6 +19,10 @@
|
||||
<id>bungeecord-repo</id>
|
||||
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>steamwar</id>
|
||||
<url>https://steamwar.de:81/maven</url>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<build>
|
||||
@ -51,5 +55,12 @@
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>steamwar</groupId>
|
||||
<artifactId>PersistentBungeeCore</artifactId>
|
||||
<version>1.0</version>
|
||||
<type>jar</type>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</project>
|
@ -1,4 +1,4 @@
|
||||
package de.steamwar.bungeecore.arenasystem;
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
public enum ArenaMode {
|
||||
AirShip,
|
@ -1,8 +1,5 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaMode;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||
import de.steamwar.bungeecore.commands.*;
|
||||
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||
import de.steamwar.bungeecore.sql.sql;
|
||||
@ -31,8 +28,8 @@ public class BungeeCore extends Plugin {
|
||||
public static final String TeamchatPrefix = "§4T§7c§r §e";
|
||||
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||
public static String LobbyServer;
|
||||
public static String [] BroadCastMsgs;
|
||||
public static int LastBroadCast = 0;
|
||||
private static String [] BroadCastMsgs;
|
||||
private static int LastBroadCast = 0;
|
||||
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<>();
|
||||
@ -123,16 +120,14 @@ public class BungeeCore extends Plugin {
|
||||
}
|
||||
}, 10, 10, TimeUnit.MINUTES);
|
||||
|
||||
Persistent.setChatPrefix(ChatPrefix);
|
||||
Persistent.setLobbyServer(LobbyServer);
|
||||
getProxy().getScheduler().schedule(this, WarkingUser::clearCache, 1, 1, TimeUnit.HOURS);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onDisable(){
|
||||
ArenaSystem.shutdown();
|
||||
BauSystem.shutdown();
|
||||
sql.close();
|
||||
getProxy().getPluginManager().unregisterCommands(this);
|
||||
getProxy().getPluginManager().unregisterListeners(this);
|
||||
}
|
||||
|
||||
static void log(final String message, final ServerInfo server){
|
||||
|
@ -1,9 +1,5 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.bausystem.BauServer;
|
||||
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||
import de.steamwar.bungeecore.commands.BauCommand;
|
||||
import de.steamwar.bungeecore.sql.BannedUserIPs;
|
||||
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||
@ -149,21 +145,6 @@ 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);
|
||||
return;
|
||||
}
|
||||
|
||||
BauServer bau = BauSystem.getBau(p);
|
||||
if(bau != null && !p.getServer().getInfo().equals(bau.getServer())){
|
||||
bau.removePlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onChatEvent(ChatEvent e){
|
||||
if(e.getMessage().startsWith("/")){
|
||||
@ -185,7 +166,9 @@ public class PlayerListener implements Listener {
|
||||
e.setCancelled(true);
|
||||
return;
|
||||
}
|
||||
if(ArenaSystem.inArena(sender))
|
||||
|
||||
Subserver subserver = Subserver.getSubserver(sender);
|
||||
if(subserver != null && subserver.getType() == Servertype.ARENA)
|
||||
return;
|
||||
|
||||
String name = sender.getDisplayName();
|
||||
@ -210,7 +193,8 @@ public class PlayerListener implements Listener {
|
||||
|
||||
String msg = name + chatsuffix + message;
|
||||
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||
if(target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN && !ArenaSystem.inArena(target)){
|
||||
Subserver targetServer = Subserver.getSubserver(target);
|
||||
if(target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN && (targetServer == null || targetServer.getType() != Servertype.ARENA)){
|
||||
target.sendMessage(msg);
|
||||
}
|
||||
}
|
||||
|
85
src/de/steamwar/bungeecore/SubserverSystem.java
Normale Datei
85
src/de/steamwar/bungeecore/SubserverSystem.java
Normale Datei
@ -0,0 +1,85 @@
|
||||
package de.steamwar.bungeecore;
|
||||
|
||||
import de.steamwar.bungeecore.sql.Bauwelt;
|
||||
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||
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.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.UUID;
|
||||
|
||||
public class SubserverSystem {
|
||||
private SubserverSystem(){}
|
||||
|
||||
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
|
||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||
if(o == null)
|
||||
return;
|
||||
|
||||
o.sendMessage(BungeeCore.ChatPrefix + "§e" + p.getName() + " §7möchte auf deine Bauwelt.");
|
||||
TextComponent tc = new TextComponent("§7Klicke §ehier§7, wenn du das erlauben möchtest.");
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§e/bau addmember " + p.getName()).create()));
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
|
||||
o.sendMessage(tc);
|
||||
}
|
||||
|
||||
public static Subserver startArena(ArenaMode modus, String map){
|
||||
int port = freePort(2500);
|
||||
String serverName = modus.name() + (port - 2500);
|
||||
return new Subserver(Servertype.ARENA, serverName, port,
|
||||
"/home/minecraft/mc", "-a", modus.name(), serverName, Integer.toString(port), map);
|
||||
}
|
||||
|
||||
public static void sendToBauServer(ProxiedPlayer p, UUID owner){
|
||||
for(Subserver subserver : Subserver.getServerList()){
|
||||
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(owner)){
|
||||
subserver.sendPlayer(p);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
File w = new File(BungeeCore.WorldFolder + owner);
|
||||
if (!w.exists() || !w.isDirectory()){
|
||||
try {
|
||||
Process pr;
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
"cp", "-r", BungeeCore.BauweltPrototyp, BungeeCore.WorldFolder + owner);
|
||||
pr = pb.start();
|
||||
pr.waitFor();
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§cDas Erstellen der Welt ist fehlgeschlagen.");
|
||||
return;
|
||||
}
|
||||
if(Bauwelt.getBauwelt(owner) == null)
|
||||
new Bauwelt(owner, false, false);
|
||||
}
|
||||
|
||||
WarkingUser user = WarkingUser.get(owner);
|
||||
int port = freePort(4000);
|
||||
|
||||
new Bauserver(user.getUserName() + "s Bau", owner, port,
|
||||
"/home/minecraft/mc", "-b", owner.toString(), Integer.toString(port)).sendPlayer(p);
|
||||
}
|
||||
|
||||
private static int freePort(int start){
|
||||
int port = start;
|
||||
boolean isFree = false;
|
||||
while(!isFree){
|
||||
port++;
|
||||
isFree = true;
|
||||
for(Subserver server : Subserver.getServerList()){
|
||||
if(server.getServer().getAddress().getPort() == port){
|
||||
isFree = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return port;
|
||||
}
|
||||
}
|
@ -1,158 +0,0 @@
|
||||
package de.steamwar.bungeecore.arenasystem;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.config.ServerInfo;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
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{
|
||||
|
||||
final String serverName;
|
||||
final int arenenNummer;
|
||||
public final ArenaMode spielModus;
|
||||
|
||||
private Process p;
|
||||
private PrintWriter writer;
|
||||
public ServerInfo server;
|
||||
private boolean started = false;
|
||||
|
||||
private final List<ProxiedPlayer> cachedPlayers = new ArrayList<>();
|
||||
private final List<ProxiedPlayer> players = new ArrayList<>();
|
||||
|
||||
|
||||
Arena(ArenaMode modus, int id, String map){
|
||||
spielModus = modus;
|
||||
arenenNummer = id;
|
||||
serverName = modus.name() + id;
|
||||
int port = 2500 + arenenNummer;
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
"/home/minecraft/mc",
|
||||
"-a", modus.name(), serverName, Integer.toString(port), map);
|
||||
try{
|
||||
p = pb.start();
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
||||
server = ProxyServer.getInstance().constructServerInfo(
|
||||
serverName, address, "SteamWar.de - Arena", false);
|
||||
ProxyServer.getInstance().getServers().put(serverName, server);
|
||||
writer = new PrintWriter( p.getOutputStream(), true);
|
||||
}catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void sendPlayer(ProxiedPlayer p){
|
||||
if(!started){
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§7Die Arena wird gestartet, einen Moment bitte...");
|
||||
cachedPlayers.add(p);
|
||||
}else{
|
||||
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;
|
||||
}
|
||||
}
|
||||
it = players.iterator();
|
||||
while(it.hasNext()){
|
||||
if(it.next().equals(p)){
|
||||
it.remove();
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void stop(){
|
||||
ProxyServer.getInstance().getServers().remove(serverName);
|
||||
if(p != null && p.isAlive()){
|
||||
for(ProxiedPlayer player : server.getPlayers()){
|
||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||
}
|
||||
writer.println("stop");
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, ()->{
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
ArenaSystem.arenen.remove(this);
|
||||
});
|
||||
}else
|
||||
ArenaSystem.arenen.remove(this);
|
||||
}
|
||||
|
||||
private void fatalError(){
|
||||
for(ProxiedPlayer cached : cachedPlayers){
|
||||
cached.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler beim Arenenstart.");
|
||||
}
|
||||
for(ProxiedPlayer player : server.getPlayers()){
|
||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||
player.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler in der Arena.");
|
||||
}
|
||||
stop();
|
||||
}
|
||||
|
||||
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 = "";
|
||||
|
||||
while (!started && (line = reader.readLine()) != null) {
|
||||
started = line.contains(" INFO]: Done ("); //Problematisch
|
||||
}
|
||||
|
||||
if(line == null){
|
||||
BungeeCore.log("Arena "+serverName+" stopped to early!");
|
||||
fatalError();
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
sendPlayer(cachedPlayers.get(0));
|
||||
|
||||
Thread.sleep(200);
|
||||
|
||||
for(int i = 1; i < cachedPlayers.size(); i++){
|
||||
sendPlayer(cachedPlayers.get(i));
|
||||
}
|
||||
cachedPlayers.clear();
|
||||
|
||||
p.waitFor();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
fatalError();
|
||||
}catch(InterruptedException e){
|
||||
BungeeCore.log("Arena "+serverName+" was interrupted!");
|
||||
fatalError();
|
||||
}
|
||||
stop();
|
||||
}
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
package de.steamwar.bungeecore.arenasystem;
|
||||
|
||||
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
public class ArenaSystem {
|
||||
|
||||
private ArenaSystem(){}
|
||||
|
||||
static ArrayList<Arena> arenen = new ArrayList<>();
|
||||
|
||||
private static int freeId(){
|
||||
int id = 0;
|
||||
boolean isFree = false;
|
||||
while(!isFree){
|
||||
id++;
|
||||
isFree = true;
|
||||
for(Arena arena : arenen){
|
||||
if(arena.arenenNummer == id){
|
||||
isFree = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static Arena startServer(ArenaMode modus, String map){
|
||||
Arena arena = new Arena(modus, freeId(), map);
|
||||
arenen.add(arena);
|
||||
return arena;
|
||||
}
|
||||
|
||||
public static void shutdown(){
|
||||
while(!arenen.isEmpty())
|
||||
arenen.get(0).stop();
|
||||
}
|
||||
|
||||
public static boolean inArena(ProxiedPlayer p){
|
||||
for(Arena a : arenen){
|
||||
if(a.inArena(p))
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public static Arena getArena(ProxiedPlayer p){
|
||||
for(Arena a : arenen){
|
||||
if(a.inArena(p))
|
||||
return a;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Arena getArena(String serverName){
|
||||
for(Arena a : arenen)
|
||||
if(a.serverName.equals(serverName))
|
||||
return a;
|
||||
return null;
|
||||
}
|
||||
}
|
@ -1,174 +0,0 @@
|
||||
package de.steamwar.bungeecore.bausystem;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||
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;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BauServer implements Runnable{
|
||||
|
||||
private final UUID owner;
|
||||
private final int id;
|
||||
private final String name;
|
||||
|
||||
private Process p;
|
||||
private PrintWriter writer;
|
||||
private ServerInfo server;
|
||||
private boolean started = false;
|
||||
private boolean stopped = false;
|
||||
|
||||
private final List<ProxiedPlayer> cachedPlayers = new ArrayList<>();
|
||||
private final List<ProxiedPlayer> players = new ArrayList<>();
|
||||
|
||||
BauServer(int id, UUID owner){
|
||||
this.id = id;
|
||||
this.owner = owner;
|
||||
this.name = new WarkingUser(owner).getUserName() + "s Bau";
|
||||
int port = 4000 + id;
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
"/home/minecraft/mc",
|
||||
"-b", owner.toString(), Integer.toString(port));
|
||||
try{
|
||||
p = pb.start();
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
|
||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
||||
server = ProxyServer.getInstance().constructServerInfo(
|
||||
name, address, "SteamWar.de - BauServer", false);
|
||||
ProxyServer.getInstance().getServers().put(name, server);
|
||||
writer = new PrintWriter( p.getOutputStream(), true);
|
||||
}catch(IOException e) {
|
||||
e.printStackTrace();
|
||||
stop();
|
||||
}
|
||||
}
|
||||
|
||||
public void stop(){
|
||||
ProxyServer.getInstance().getServers().remove(name);
|
||||
if(p != null && p.isAlive()) {
|
||||
for (ProxiedPlayer player : server.getPlayers()) {
|
||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||
}
|
||||
stopped = true;
|
||||
writer.println("stop");
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, ()->{
|
||||
try {
|
||||
p.waitFor();
|
||||
} catch (InterruptedException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
BauSystem.server.remove(owner);
|
||||
});
|
||||
}else
|
||||
BauSystem.server.remove(owner);
|
||||
}
|
||||
|
||||
void sendPlayer(ProxiedPlayer p){
|
||||
if(stopped) {
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§7Die Bauwelt derzeit entladen, bitte versuche es später erneut.");
|
||||
}else if(!started){
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§7Die Bauwelt wird geladen, einen Moment bitte...");
|
||||
cachedPlayers.add(p);
|
||||
}else{
|
||||
p.connect(server);
|
||||
players.add(p);
|
||||
}
|
||||
}
|
||||
|
||||
boolean onBau(ProxiedPlayer p){
|
||||
for(ProxiedPlayer ap : cachedPlayers)
|
||||
if(ap.equals(p))
|
||||
return true;
|
||||
for(ProxiedPlayer ap : players)
|
||||
if(ap.equals(p))
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
public void removePlayer(ProxiedPlayer p){
|
||||
cachedPlayers.remove(p);
|
||||
players.remove(p);
|
||||
}
|
||||
|
||||
private void fatalError(){
|
||||
for(ProxiedPlayer cached : cachedPlayers){
|
||||
cached.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler beim Laden der Bauwelt.");
|
||||
}
|
||||
for(ProxiedPlayer player : server.getPlayers()){
|
||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||
player.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler in der Bauwelt.");
|
||||
}
|
||||
stop();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
BufferedReader reader = new BufferedReader(new InputStreamReader(p.getInputStream()));
|
||||
String line = "";
|
||||
|
||||
while (!started && (line = reader.readLine()) != null) {
|
||||
started = line.contains(" INFO]: Done (");
|
||||
}
|
||||
|
||||
if(line == null){
|
||||
BungeeCore.log("Bau "+name+" stopped to early!");
|
||||
fatalError();
|
||||
return;
|
||||
}
|
||||
|
||||
Thread.sleep(1000);
|
||||
|
||||
for(ProxiedPlayer player : cachedPlayers){
|
||||
sendPlayer(player);
|
||||
}
|
||||
cachedPlayers.clear();
|
||||
|
||||
p.waitFor();
|
||||
}catch(IOException e){
|
||||
e.printStackTrace();
|
||||
fatalError();
|
||||
}catch(InterruptedException e){
|
||||
BungeeCore.log("Bau "+name+" was interrupted!");
|
||||
fatalError();
|
||||
}
|
||||
stop();
|
||||
}
|
||||
|
||||
public UUID getOwner() {
|
||||
return owner;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public ServerInfo getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public static void sendDeniedMessage(ProxiedPlayer p, UUID owner){
|
||||
ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
|
||||
if(o == null)
|
||||
return;
|
||||
|
||||
o.sendMessage(BungeeCore.ChatPrefix + "§e" + p.getName() + " §7möchte auf deine Bauwelt.");
|
||||
TextComponent tc = new TextComponent("§7Klicke §ehier§7, wenn du das erlauben möchtest.");
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§e/bau addmember " + p.getName()).create()));
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.getName()));
|
||||
o.sendMessage(tc);
|
||||
}
|
||||
}
|
@ -1,75 +0,0 @@
|
||||
package de.steamwar.bungeecore.bausystem;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.sql.Bauwelt;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Iterator;
|
||||
import java.util.UUID;
|
||||
|
||||
public class BauSystem {
|
||||
|
||||
private BauSystem(){}
|
||||
|
||||
static HashMap<UUID, BauServer> server = new HashMap<>();
|
||||
|
||||
private static int freeId(){
|
||||
int id = 0;
|
||||
boolean isFree = false;
|
||||
while(!isFree){
|
||||
id++;
|
||||
isFree = true;
|
||||
for(BauServer bau : server.values()){
|
||||
if(bau.getId() == id){
|
||||
isFree = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
public static void sendToServer(ProxiedPlayer p, UUID owner){
|
||||
if(server.containsKey(owner)){
|
||||
server.get(owner).sendPlayer(p);
|
||||
}else{
|
||||
File w = new File(BungeeCore.WorldFolder + owner);
|
||||
if (!w.exists() || !w.isDirectory()){
|
||||
try {
|
||||
Process pr;
|
||||
ProcessBuilder pb = new ProcessBuilder(
|
||||
"cp", "-r", BungeeCore.BauweltPrototyp, BungeeCore.WorldFolder + owner);
|
||||
pr = pb.start();
|
||||
pr.waitFor();
|
||||
} catch (InterruptedException | IOException e) {
|
||||
e.printStackTrace();
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§cDas Erstellen der Welt ist fehlgeschlagen.");
|
||||
return;
|
||||
}
|
||||
if(Bauwelt.getBauwelt(owner) == null)
|
||||
new Bauwelt(owner, false, false);
|
||||
}
|
||||
BauServer bau = new BauServer(freeId(), owner);
|
||||
server.put(owner, bau);
|
||||
bau.sendPlayer(p);
|
||||
}
|
||||
}
|
||||
|
||||
public static BauServer getBau(ProxiedPlayer p){
|
||||
for(BauServer bau : server.values()){
|
||||
if(bau.onBau(p))
|
||||
return bau;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void shutdown(){
|
||||
Iterator<BauServer> it = server.values().iterator();
|
||||
while(it.hasNext()){
|
||||
it.next().stop();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,8 +1,6 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.bausystem.BauServer;
|
||||
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.Bauwelt;
|
||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||
import de.steamwar.bungeecore.sql.Permission;
|
||||
@ -20,12 +18,13 @@ public class BauCommand {
|
||||
|
||||
public static void onBau(ChatEvent e, String[] command){
|
||||
ProxiedPlayer p = (ProxiedPlayer) e.getSender();
|
||||
BauServer bau = BauSystem.getBau(p);
|
||||
Subserver server = Subserver.getSubserver(p);
|
||||
Bauserver bau = server != null && server.getType() == Servertype.BAUSERVER ? (Bauserver)server : null;
|
||||
boolean ownBau = bau != null && bau.getOwner().equals(p.getUniqueId());
|
||||
e.setCancelled(true);
|
||||
|
||||
if(command.length == 1){
|
||||
BauSystem.sendToServer(p, p.getUniqueId());
|
||||
SubserverSystem.sendToBauServer(p, p.getUniqueId());
|
||||
}else if(ownBau && command.length != 2 && (
|
||||
command[1].equalsIgnoreCase("togglebuild") ||
|
||||
command[1].equalsIgnoreCase("togglewe") ||
|
||||
@ -65,11 +64,11 @@ public class BauCommand {
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spieler");
|
||||
return;
|
||||
}else if (!hasPermission(worldOwner, p, Permission.member)){
|
||||
BauServer.sendDeniedMessage(p, worldOwner);
|
||||
SubserverSystem.sendDeniedMessage(p, worldOwner);
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§cDu darfst dich nicht auf diese Welt teleportieren");
|
||||
return;
|
||||
}
|
||||
BauSystem.sendToServer(p, worldOwner);
|
||||
SubserverSystem.sendToBauServer(p, worldOwner);
|
||||
}else if(command[1].equalsIgnoreCase("togglebuild")){
|
||||
if (command.length == 2) {
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "/bau togglebuild <Spieler>");
|
||||
@ -125,12 +124,16 @@ public class BauCommand {
|
||||
}else if(command[1].equalsIgnoreCase("resetall") ||
|
||||
command[1].equalsIgnoreCase("delete")){
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§aDeine Welt wird zurückgesetzt. Einen Moment bitte...");
|
||||
BauServer bauserver = BauSystem.getBau(p);
|
||||
if(bauserver != null){
|
||||
bauserver.stop();
|
||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, () -> {
|
||||
for(Subserver subserver : Subserver.getServerList()){
|
||||
if(subserver.getType() == Servertype.BAUSERVER && ((Bauserver)subserver).getOwner().equals(p.getUniqueId())){
|
||||
subserver.stop();
|
||||
break;
|
||||
}
|
||||
}
|
||||
File directory = new File(BungeeCore.WorldFolder + p.getUniqueId().toString());
|
||||
del(directory);
|
||||
});
|
||||
}else{
|
||||
HelpCommand.sendBauHelp(p);
|
||||
}
|
||||
@ -192,8 +195,8 @@ public class BauCommand {
|
||||
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||
if(z != null){
|
||||
z.sendMessage(BungeeCore.ChatPrefix + "§cDu wurdest von der Welt von §6" + p.getName() + " §centfernt.");
|
||||
BauServer server = BauSystem.getBau(z);
|
||||
if(server != null && server.getOwner().equals(p.getUniqueId()))
|
||||
Subserver server = Subserver.getSubserver(z);
|
||||
if(server != null && server.getType() == Servertype.BAUSERVER && ((Bauserver)server).getOwner().equals(p.getUniqueId()))
|
||||
z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||
}
|
||||
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler wurde entfernt.");
|
||||
|
@ -1,9 +1,10 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaMode;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.Servertype;
|
||||
import de.steamwar.bungeecore.Subserver;
|
||||
import de.steamwar.bungeecore.SubserverSystem;
|
||||
import de.steamwar.bungeecore.ArenaMode;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.chat.ClickEvent;
|
||||
@ -52,41 +53,47 @@ public class FightCommand extends Command {
|
||||
if(sender instanceof ProxiedPlayer){
|
||||
ProxiedPlayer player = (ProxiedPlayer) sender;
|
||||
|
||||
if(ArenaSystem.inArena(player)){
|
||||
Subserver subserver = Subserver.getSubserver(player);
|
||||
if(subserver != null && subserver.getType() == Servertype.ARENA){
|
||||
sender.sendMessage(BungeeCore.ChatPrefix + "§cDu befindest dich bereits in einer Arena.");
|
||||
return;
|
||||
}
|
||||
|
||||
String map;
|
||||
Arena arena;
|
||||
Subserver arena;
|
||||
String spielModus;
|
||||
switch(args[0].toLowerCase()){
|
||||
case "as":
|
||||
case "airship":
|
||||
map = getMap(sender, ArenaMode.AirShip, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.AirShip, map);
|
||||
arena = SubserverSystem.startArena(ArenaMode.AirShip, map);
|
||||
spielModus = "AirShip";
|
||||
break;
|
||||
case "ws":
|
||||
case "warship":
|
||||
map = getMap(sender, ArenaMode.WarShip, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarShip, map);
|
||||
arena = SubserverSystem.startArena(ArenaMode.WarShip, map);
|
||||
spielModus = "WarShip";
|
||||
break;
|
||||
case "wg":
|
||||
case "wargear":
|
||||
map = getMap(sender, ArenaMode.WarGear, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.WarGear, map);
|
||||
arena = SubserverSystem.startArena(ArenaMode.WarGear, map);
|
||||
spielModus = "WarGear";
|
||||
break;
|
||||
case "mwg":
|
||||
case "miniwargear":
|
||||
map = getMap(sender, ArenaMode.MiniWarGear, args);
|
||||
if(map == null)
|
||||
return;
|
||||
arena = ArenaSystem.startServer(ArenaMode.MiniWarGear, map);
|
||||
arena = SubserverSystem.startArena(ArenaMode.MiniWarGear, map);
|
||||
spielModus = "MiniWarGear";
|
||||
break;
|
||||
default:
|
||||
sender.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spielmodus: " + args[0]);
|
||||
@ -94,7 +101,7 @@ public class FightCommand extends Command {
|
||||
}
|
||||
|
||||
arena.sendPlayer(player);
|
||||
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §ehier§7, um §e" + arena.spielModus + " §7gegen §e" + player.getName() + " §7zu §7kämpfen!");
|
||||
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Klicke §ehier§7, um §e" + spielModus + " §7gegen §e" + player.getName() + " §7zu §7kämpfen!");
|
||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§aGegen §7" + player.getName() + " §ekämpfen").create()));
|
||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/join " + player.getName()));
|
||||
ProxyServer.getInstance().broadcast(tc);
|
||||
|
@ -1,10 +1,6 @@
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||
import de.steamwar.bungeecore.bausystem.BauServer;
|
||||
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||
import de.steamwar.bungeecore.*;
|
||||
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
@ -46,19 +42,22 @@ public class JoinmeCommand extends Command {
|
||||
}
|
||||
ServerInfo server = target.getServer().getInfo();
|
||||
String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||
Arena arena = ArenaSystem.getArena(target);
|
||||
BauServer bauserver = BauSystem.getBau(target);
|
||||
Subserver subserver = Subserver.getSubserver(target);
|
||||
|
||||
if(arena != null) {
|
||||
arena.sendPlayer(player);
|
||||
}else if(bauserver != null){
|
||||
if(bauserver.getOwner().equals(player.getUniqueId()) ||
|
||||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null){
|
||||
BauSystem.sendToServer(player, bauserver.getOwner());
|
||||
}else{
|
||||
BauServer.sendDeniedMessage(player, bauserver.getOwner());
|
||||
if(subserver != null) {
|
||||
Servertype type = subserver.getType();
|
||||
if (type == Servertype.ARENA) {
|
||||
subserver.sendPlayer(player);
|
||||
} else if (type == Servertype.BAUSERVER) {
|
||||
Bauserver bauserver = (Bauserver) subserver;
|
||||
if (bauserver.getOwner().equals(player.getUniqueId()) ||
|
||||
BauweltMember.getBauMember(bauserver.getOwner(), player.getUniqueId()) != null) {
|
||||
subserver.sendPlayer(player);
|
||||
} else {
|
||||
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
|
||||
player.sendMessage(BungeeCore.ChatPrefix + DENY_MESSAGE);
|
||||
}
|
||||
}
|
||||
}else if(ServerPerm != null && !player.hasPermission(ServerPerm)){
|
||||
player.sendMessage(BungeeCore.ChatPrefix + DENY_MESSAGE);
|
||||
}else if(ServerPerm == null && !player.getGroups().contains("team")) {
|
||||
|
@ -2,3 +2,4 @@ name: BungeeCore
|
||||
main: de.steamwar.bungeecore.BungeeCore
|
||||
version: 1.0
|
||||
author: Lixfel
|
||||
depend: [PersistentBungeeCore]
|
In neuem Issue referenzieren
Einen Benutzer sperren