Finishing BauServer-System
Dieser Commit ist enthalten in:
Ursprung
ffa69b1929
Commit
378371289b
5
pom.xml
5
pom.xml
@ -61,5 +61,10 @@
|
|||||||
<type>javadoc</type>
|
<type>javadoc</type>
|
||||||
<scope>provided</scope>
|
<scope>provided</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>commons-io</groupId>
|
||||||
|
<artifactId>commons-io</artifactId>
|
||||||
|
<version>2.6</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -2,7 +2,11 @@ package de.steamwar.bungeecore;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.arenasystem.ArenaMode;
|
import de.steamwar.bungeecore.arenasystem.ArenaMode;
|
||||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||||
|
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||||
import de.steamwar.bungeecore.commands.*;
|
import de.steamwar.bungeecore.commands.*;
|
||||||
|
import de.steamwar.bungeecore.sql.Bauwelt;
|
||||||
|
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||||
|
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||||
import de.steamwar.bungeecore.sql.sql;
|
import de.steamwar.bungeecore.sql.sql;
|
||||||
import net.md_5.bungee.api.config.ServerInfo;
|
import net.md_5.bungee.api.config.ServerInfo;
|
||||||
import net.md_5.bungee.api.plugin.Command;
|
import net.md_5.bungee.api.plugin.Command;
|
||||||
@ -24,6 +28,8 @@ public class BungeeCore extends Plugin {
|
|||||||
|
|
||||||
public static BungeeCore instance;
|
public static BungeeCore instance;
|
||||||
public static String ChatPrefix;
|
public static String ChatPrefix;
|
||||||
|
public static String WorldFolder;
|
||||||
|
public static String BauweltPrototyp;
|
||||||
public static final String TeamchatPrefix = "§4T§7c§r §e";
|
public static final String TeamchatPrefix = "§4T§7c§r §e";
|
||||||
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
public static final DateTimeFormatter DateFormat = DateTimeFormatter.ofPattern("dd.MM.yyyy");
|
||||||
public static String LobbyServer;
|
public static String LobbyServer;
|
||||||
@ -65,6 +71,8 @@ public class BungeeCore extends Plugin {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ChatPrefix = config.getString("prefix");
|
ChatPrefix = config.getString("prefix");
|
||||||
|
WorldFolder = config.getString("worldfolder");
|
||||||
|
BauweltPrototyp = config.getString("bauweltprototyp");
|
||||||
LobbyServer = config.getString("lobbyserver");
|
LobbyServer = config.getString("lobbyserver");
|
||||||
sql.connect(
|
sql.connect(
|
||||||
config.getString("db.url"),
|
config.getString("db.url"),
|
||||||
@ -116,17 +124,24 @@ public class BungeeCore extends Plugin {
|
|||||||
LastBroadCast = 0;
|
LastBroadCast = 0;
|
||||||
}
|
}
|
||||||
}, 10, 10, TimeUnit.MINUTES);
|
}, 10, 10, TimeUnit.MINUTES);
|
||||||
|
|
||||||
|
getProxy().getScheduler().schedule(this, () -> {
|
||||||
|
WarkingUser.clearCache();
|
||||||
|
Bauwelt.clearCache();
|
||||||
|
BauweltMember.clearCache();
|
||||||
|
}, 1, 1, TimeUnit.HOURS);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDisable(){
|
public void onDisable(){
|
||||||
ArenaSystem.shutdown();
|
ArenaSystem.shutdown();
|
||||||
|
BauSystem.shutdown();
|
||||||
sql.close();
|
sql.close();
|
||||||
getProxy().getPluginManager().unregisterCommands(this);
|
getProxy().getPluginManager().unregisterCommands(this);
|
||||||
getProxy().getPluginManager().unregisterListeners(this);
|
getProxy().getPluginManager().unregisterListeners(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void log(final String message, final ServerInfo server){
|
static void log(final String message, final ServerInfo server){
|
||||||
log("[" + server.getName() + "] " + message);
|
log("[" + server.getName() + "] " + message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,6 +2,9 @@ package de.steamwar.bungeecore;
|
|||||||
|
|
||||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
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.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;
|
||||||
@ -28,11 +31,11 @@ public class PlayerListener implements Listener {
|
|||||||
if(user.isBanned()) {
|
if(user.isBanned()) {
|
||||||
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
user.updateBanIP(event.getConnection().getAddress().getAddress().getHostAddress());
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
if (user.BanTime.before(WarkingUser.PermaBan)) {
|
if (user.getBanTime().before(WarkingUser.PermaBan)) {
|
||||||
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + "§cDu bist permanent gebannt. §r§lGrund§r: §c" + user.BanReason));
|
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + "§cDu bist permanent gebannt. §r§lGrund§r: §c" + user.getBanReason()));
|
||||||
} else {
|
} else {
|
||||||
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + " Du bist bis zum " +
|
event.setCancelReason(new TextComponent(BungeeCore.ChatPrefix + " Du bist bis zum " +
|
||||||
user.BanTime.toLocalDateTime().format(BungeeCore.DateFormat) + " gebannt. §r§lGrund§r: §c" + user.BanReason));
|
user.getBanTime().toLocalDateTime().format(BungeeCore.DateFormat) + " gebannt. §r§lGrund§r: §c" + user.getBanReason()));
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -42,7 +45,7 @@ public class PlayerListener implements Listener {
|
|||||||
StringBuilder potentialBan = new StringBuilder();
|
StringBuilder potentialBan = new StringBuilder();
|
||||||
potentialBan.append(BungeeCore.ChatPrefix);
|
potentialBan.append(BungeeCore.ChatPrefix);
|
||||||
potentialBan.append("§cMögliche Bannumgehung durch §r");
|
potentialBan.append("§cMögliche Bannumgehung durch §r");
|
||||||
potentialBan.append(user.UserName);
|
potentialBan.append(user.getUserName());
|
||||||
potentialBan.append("§c:");
|
potentialBan.append("§c:");
|
||||||
|
|
||||||
for(BannedUserIPs banned : ips){
|
for(BannedUserIPs banned : ips){
|
||||||
@ -50,12 +53,12 @@ public class PlayerListener implements Listener {
|
|||||||
potentialBan.append(" §e");
|
potentialBan.append(" §e");
|
||||||
potentialBan.append(banned.getTimestamp().toLocalDateTime().format(BungeeCore.DateFormat));
|
potentialBan.append(banned.getTimestamp().toLocalDateTime().format(BungeeCore.DateFormat));
|
||||||
potentialBan.append(" §c");
|
potentialBan.append(" §c");
|
||||||
potentialBan.append(bannedUser.UserName);
|
potentialBan.append(bannedUser.getUserName());
|
||||||
}
|
}
|
||||||
|
|
||||||
TextComponent msg = new TextComponent(potentialBan.toString());
|
TextComponent msg = new TextComponent(potentialBan.toString());
|
||||||
msg.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cBanne Spieler wegen Bannumgehung").create()));
|
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"));
|
msg.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/ban " + user.getUserName() + " perma Bannumgehung"));
|
||||||
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
for (ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if ((target.hasPermission("bungeecore.teamchat"))
|
if ((target.hasPermission("bungeecore.teamchat"))
|
||||||
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|
&& (target.getChatMode() == ProxiedPlayer.ChatMode.COMMANDS_ONLY
|
||||||
@ -71,7 +74,7 @@ public class PlayerListener implements Listener {
|
|||||||
ProxiedPlayer player = event.getPlayer();
|
ProxiedPlayer player = event.getPlayer();
|
||||||
WarkingUser user = new WarkingUser(player);
|
WarkingUser user = new WarkingUser(player);
|
||||||
player.removeGroups("Admin", "team");
|
player.removeGroups("Admin", "team");
|
||||||
switch(user.UserGroup){
|
switch(user.getUserGroup()){
|
||||||
case "Admin":
|
case "Admin":
|
||||||
player.addGroups("admin", "team");
|
player.addGroups("admin", "team");
|
||||||
player.setPermission("bungeecore.group.admin", true);
|
player.setPermission("bungeecore.group.admin", true);
|
||||||
@ -152,6 +155,12 @@ public class PlayerListener implements Listener {
|
|||||||
Arena a = ArenaSystem.getArena(p);
|
Arena a = ArenaSystem.getArena(p);
|
||||||
if(a != null && !p.getServer().getInfo().equals(a.server)){
|
if(a != null && !p.getServer().getInfo().equals(a.server)){
|
||||||
a.removePlayer(p);
|
a.removePlayer(p);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauServer bau = BauSystem.getBau(p);
|
||||||
|
if(bau != null && !p.getServer().getInfo().equals(bau.getServer())){
|
||||||
|
bau.removePlayer(p);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -166,11 +175,7 @@ public class PlayerListener implements Listener {
|
|||||||
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") && e.getSender() instanceof ProxiedPlayer){
|
||||||
ProxiedPlayer sender = (ProxiedPlayer) e.getSender();
|
BauCommand.onBau(e, command);
|
||||||
if(!sender.getServer().getInfo().getName().equals("Bau")){
|
|
||||||
e.setCancelled(true);
|
|
||||||
sender.connect(ProxyServer.getInstance().getServerInfo("Bau"));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}else{
|
}else{
|
||||||
if(e.getSender() instanceof ProxiedPlayer){
|
if(e.getSender() instanceof ProxiedPlayer){
|
||||||
@ -191,16 +196,11 @@ public class PlayerListener implements Listener {
|
|||||||
if(sender.hasPermission("bungeecore.group.admin")){
|
if(sender.hasPermission("bungeecore.group.admin")){
|
||||||
chatsuffix = "§7» §6";
|
chatsuffix = "§7» §6";
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
}else if(sender.hasPermission("bungeecore.group.developer")){
|
}else if(
|
||||||
chatsuffix = "§7» §r";
|
sender.hasPermission("bungeecore.group.developer") ||
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
sender.hasPermission("bungeecore.group.moderator") ||
|
||||||
}else if(sender.hasPermission("bungeecore.group.moderator")){
|
sender.hasPermission("bungeecore.group.supporter") ||
|
||||||
chatsuffix = "§7» §r";
|
sender.hasPermission("bungeecore.group.builder")){
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
||||||
}else if(sender.hasPermission("bungeecore.group.supporter")){
|
|
||||||
chatsuffix = "§7» §r";
|
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
|
||||||
}else if(sender.hasPermission("bungeecore.group.builder")){
|
|
||||||
chatsuffix = "§7» §r";
|
chatsuffix = "§7» §r";
|
||||||
message = ChatColor.translateAlternateColorCodes('&', message);
|
message = ChatColor.translateAlternateColorCodes('&', message);
|
||||||
}else if(sender.hasPermission("bungeecore.group.youtuber") ||
|
}else if(sender.hasPermission("bungeecore.group.youtuber") ||
|
||||||
@ -209,8 +209,8 @@ public class PlayerListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
String msg = name + chatsuffix + message;
|
String msg = name + chatsuffix + message;
|
||||||
for(ProxiedPlayer target : sender.getServer().getInfo().getPlayers()){
|
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||||
if(target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN){
|
if(target.getChatMode() == ProxiedPlayer.ChatMode.SHOWN && !ArenaSystem.inArena(target)){
|
||||||
target.sendMessage(msg);
|
target.sendMessage(msg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ public class Arena implements Runnable{
|
|||||||
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, this);
|
||||||
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
InetSocketAddress address = new InetSocketAddress("127.0.0.1", port);
|
||||||
server = ProxyServer.getInstance().constructServerInfo(
|
server = ProxyServer.getInstance().constructServerInfo(
|
||||||
serverName, address, "WarKing.de - Arena", false);
|
serverName, address, "SteamWar.de - Arena", false);
|
||||||
ProxyServer.getInstance().getServers().put(serverName, server);
|
ProxyServer.getInstance().getServers().put(serverName, server);
|
||||||
writer = new PrintWriter( p.getOutputStream(), true);
|
writer = new PrintWriter( p.getOutputStream(), true);
|
||||||
}catch(IOException e) {
|
}catch(IOException e) {
|
||||||
@ -84,24 +84,26 @@ public class Arena implements Runnable{
|
|||||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||||
}
|
}
|
||||||
writer.println("stop");
|
writer.println("stop");
|
||||||
try{
|
ProxyServer.getInstance().getServers().remove(serverName);
|
||||||
|
ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.instance, ()->{
|
||||||
|
try {
|
||||||
p.waitFor();
|
p.waitFor();
|
||||||
}catch(InterruptedException e){
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
ArenaSystem.arenen.remove(this);
|
||||||
|
});
|
||||||
ProxyServer.getInstance().getServers().remove(serverName);
|
}else
|
||||||
ArenaSystem.arenen.remove(this);
|
ArenaSystem.arenen.remove(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fatalError(){
|
private void fatalError(){
|
||||||
for(ProxiedPlayer cached : cachedPlayers){
|
for(ProxiedPlayer cached : cachedPlayers){
|
||||||
cached.sendMessage(BungeeCore.ChatPrefix + "§7Unerwarteter Fehler beim Arenenstart");
|
cached.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler beim Arenenstart.");
|
||||||
}
|
}
|
||||||
for(ProxiedPlayer player : server.getPlayers()){
|
for(ProxiedPlayer player : server.getPlayers()){
|
||||||
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||||
player.sendMessage(BungeeCore.ChatPrefix + "§7Unerwarteter Fehler in der Arena");
|
player.sendMessage(BungeeCore.ChatPrefix + "§cUnerwarteter Fehler in der Arena.");
|
||||||
}
|
}
|
||||||
stop();
|
stop();
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,13 @@ package de.steamwar.bungeecore.arenasystem;
|
|||||||
|
|
||||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
import java.util.Vector;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
public class ArenaSystem {
|
public class ArenaSystem {
|
||||||
|
|
||||||
protected static Vector<Arena> arenen = new Vector<>();
|
private ArenaSystem(){}
|
||||||
|
|
||||||
|
static ArrayList<Arena> arenen = new ArrayList<>();
|
||||||
|
|
||||||
private static int freeId(){
|
private static int freeId(){
|
||||||
int id = 0;
|
int id = 0;
|
||||||
@ -33,7 +35,7 @@ public class ArenaSystem {
|
|||||||
|
|
||||||
public static void shutdown(){
|
public static void shutdown(){
|
||||||
while(!arenen.isEmpty())
|
while(!arenen.isEmpty())
|
||||||
arenen.firstElement().stop();
|
arenen.get(0).stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean inArena(ProxiedPlayer p){
|
public static boolean inArena(ProxiedPlayer p){
|
||||||
|
174
src/de/steamwar/bungeecore/bausystem/BauServer.java
Normale Datei
174
src/de/steamwar/bungeecore/bausystem/BauServer.java
Normale Datei
@ -0,0 +1,174 @@
|
|||||||
|
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(){
|
||||||
|
if(p != null && p.isAlive()) {
|
||||||
|
for (ProxiedPlayer player : server.getPlayers()) {
|
||||||
|
player.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||||
|
}
|
||||||
|
stopped = true;
|
||||||
|
writer.println("stop");
|
||||||
|
ProxyServer.getInstance().getServers().remove(name);
|
||||||
|
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);
|
||||||
|
}
|
||||||
|
}
|
72
src/de/steamwar/bungeecore/bausystem/BauSystem.java
Normale Datei
72
src/de/steamwar/bungeecore/bausystem/BauSystem.java
Normale Datei
@ -0,0 +1,72 @@
|
|||||||
|
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 org.apache.commons.io.FileUtils;
|
||||||
|
|
||||||
|
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 {
|
||||||
|
FileUtils.copyDirectory(new File(BungeeCore.BauweltPrototyp), w);
|
||||||
|
} catch (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();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -24,7 +24,7 @@ public class BanCommand extends Command {
|
|||||||
}
|
}
|
||||||
|
|
||||||
WarkingUser target = new WarkingUser(args[0]);
|
WarkingUser target = new WarkingUser(args[0]);
|
||||||
if(target.UserName == null){
|
if(target.getUserName() == null){
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler existiert nicht.");
|
sender.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler existiert nicht.");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -55,8 +55,8 @@ public class BanCommand extends Command {
|
|||||||
}
|
}
|
||||||
String msg = banReason.toString();
|
String msg = banReason.toString();
|
||||||
msgBuilder.append(msg);
|
msgBuilder.append(msg);
|
||||||
sender.sendMessage(BungeeCore.ChatPrefix + "Du hast " + target.UserName + " gebannt. Grund: §c" + msg);
|
sender.sendMessage(BungeeCore.ChatPrefix + "Du hast " + target.getUserName() + " gebannt. Grund: §c" + msg);
|
||||||
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(target.UUID);
|
ProxiedPlayer targetPlayer = ProxyServer.getInstance().getPlayer(target.getUUID());
|
||||||
if(targetPlayer != null){
|
if(targetPlayer != null){
|
||||||
target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg);
|
target.banPlayer(targetPlayer.getAddress().getAddress().getHostAddress(), banTime, msg);
|
||||||
targetPlayer.disconnect(msgBuilder.toString());
|
targetPlayer.disconnect(msgBuilder.toString());
|
||||||
|
259
src/de/steamwar/bungeecore/commands/BauCommand.java
Normale Datei
259
src/de/steamwar/bungeecore/commands/BauCommand.java
Normale Datei
@ -0,0 +1,259 @@
|
|||||||
|
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.sql.Bauwelt;
|
||||||
|
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||||
|
import de.steamwar.bungeecore.sql.Permission;
|
||||||
|
import de.steamwar.bungeecore.sql.WarkingUser;
|
||||||
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
import net.md_5.bungee.api.event.ChatEvent;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BauCommand {
|
||||||
|
|
||||||
|
private BauCommand(){}
|
||||||
|
|
||||||
|
public static void onBau(ChatEvent e, String[] command){
|
||||||
|
ProxiedPlayer p = (ProxiedPlayer) e.getSender();
|
||||||
|
BauServer bau = BauSystem.getBau(p);
|
||||||
|
boolean ownBau = bau != null && bau.getOwner().equals(p.getUniqueId());
|
||||||
|
e.setCancelled(true);
|
||||||
|
|
||||||
|
if(command.length == 1){
|
||||||
|
BauSystem.sendToServer(p, p.getUniqueId());
|
||||||
|
}else if(ownBau && command.length != 2 && (
|
||||||
|
command[1].equalsIgnoreCase("togglebuild") ||
|
||||||
|
command[1].equalsIgnoreCase("togglewe") ||
|
||||||
|
command[1].equalsIgnoreCase("toggleworld"))) {
|
||||||
|
e.setCancelled(false);
|
||||||
|
}else if(command[1].equalsIgnoreCase("addmember")){
|
||||||
|
if (!hasWorld(p)){
|
||||||
|
return;
|
||||||
|
}else if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau addmember <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}else if (BauweltMember.getBauMember(p.getUniqueId(), id) != null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDieser Spieler ist bereits Mitglied auf deiner Welt");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
new BauweltMember(p.getUniqueId(), id, true, false, false);
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§aDer Spieler wurde zu deiner Welt hinzugefügt");
|
||||||
|
|
||||||
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(id);
|
||||||
|
if(z != null)
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§aDu wurdest zu der Welt von §6" + p.getName() + " §ahinzugefügt");
|
||||||
|
}else if(command[1].equalsIgnoreCase("tp")){
|
||||||
|
if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau tp <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID worldOwner = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if (worldOwner == null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spieler");
|
||||||
|
return;
|
||||||
|
}else if (!hasPermission(worldOwner, p, Permission.member)){
|
||||||
|
BauServer.sendDeniedMessage(p, worldOwner);
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDu darfst dich nicht auf diese Welt teleportieren");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
BauSystem.sendToServer(p, worldOwner);
|
||||||
|
}else if(command[1].equalsIgnoreCase("togglebuild")){
|
||||||
|
if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau togglebuild <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if(!toggleCheck(p, id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
toggleBuild(p, target);
|
||||||
|
}else if(command[1].equalsIgnoreCase("togglewe")){
|
||||||
|
if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau togglewe <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if(!toggleCheck(p, id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
toggleWE(p, target);
|
||||||
|
}else if(command[1].equalsIgnoreCase("toggleworld")) {
|
||||||
|
if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau toggleworld <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if (!toggleCheck(p, id)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
toggleTestblock(p, target);
|
||||||
|
}else if(command[1].equalsIgnoreCase("delmember")){
|
||||||
|
if (command.length == 2) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "/bau delmember <Spieler>");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
UUID id = WarkingUser.get(command[2]).getUUID();
|
||||||
|
if(!toggleCheck(p, id)){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
removePlayer(p, target);
|
||||||
|
}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();
|
||||||
|
}
|
||||||
|
File directory = new File(BungeeCore.WorldFolder + p.getUniqueId().toString());
|
||||||
|
del(directory);
|
||||||
|
}else{
|
||||||
|
HelpCommand.sendBauHelp(p);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleBuild(ProxiedPlayer p, BauweltMember target){
|
||||||
|
target.setBuild(!target.isBuild());
|
||||||
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isBuild()) {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a bauen");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c bauen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isBuild()) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§aDer Spieler darf nun bauen");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler darf nun nicht mehr bauen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleWE(ProxiedPlayer p, BauweltMember target){
|
||||||
|
target.setWorldEdit(!target.isWorldEdit());
|
||||||
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isWorldEdit()) {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a WorldEdit verwenden");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c WorldEdit verwenden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isWorldEdit()) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§aDer Spieler darf nun WorldEdit verwenden");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler darf nun kein WorldEdit mehr verwenden");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void toggleTestblock(ProxiedPlayer p, BauweltMember target){
|
||||||
|
target.setWorld(!target.isWorld());
|
||||||
|
ProxiedPlayer z = ProxyServer.getInstance().getPlayer(WarkingUser.get(target.getMemberID()).getUUID());
|
||||||
|
if (z != null) {
|
||||||
|
if (target.isWorld()) {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§aDu kannst nun auf der Welt von §6" + p.getName() + "§a Einstellungen vornehmen");
|
||||||
|
}else {
|
||||||
|
z.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst nun nicht mehr auf der Welt von §6" + p.getName() + "§c Einstellungen vornehmen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (target.isWorld()) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§aDer Spieler darf nun Einstellungen vornehmen");
|
||||||
|
} else {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler darf nun nicht mehr Einstellungen vornehmen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removePlayer(ProxiedPlayer p, BauweltMember target){
|
||||||
|
target.remove();
|
||||||
|
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()))
|
||||||
|
z.connect(ProxyServer.getInstance().getServerInfo(BungeeCore.LobbyServer));
|
||||||
|
}
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler wurde entfernt.");
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean toggleCheck(ProxiedPlayer p, UUID id){
|
||||||
|
if (id == null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cUnbekannter Spieler");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
BauweltMember target = BauweltMember.getBauMember(p.getUniqueId(), id);
|
||||||
|
if (target == null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDer Spieler ist kein Mitglied deiner Welt!");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static boolean hasPermission(UUID welt, ProxiedPlayer member, Permission perm){
|
||||||
|
if(member.getUniqueId().equals(welt))
|
||||||
|
return true;
|
||||||
|
|
||||||
|
BauweltMember member1 = BauweltMember.getBauMember(welt, member.getUniqueId());
|
||||||
|
if(member1 == null)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
switch(perm){
|
||||||
|
case build:
|
||||||
|
return member1.isBuild();
|
||||||
|
case worldedit:
|
||||||
|
return member1.isWorldEdit();
|
||||||
|
case world:
|
||||||
|
return member1.isWorld();
|
||||||
|
case member:
|
||||||
|
return true;
|
||||||
|
default:
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static void del(File dir){
|
||||||
|
if (dir.isDirectory()){
|
||||||
|
String[] entries = dir.list();
|
||||||
|
for (String entry : entries) {
|
||||||
|
File aktFile = new File(dir.getPath(), entry);
|
||||||
|
del(aktFile);
|
||||||
|
}
|
||||||
|
dir.delete();
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
dir.delete();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private static boolean hasWorld(ProxiedPlayer p){
|
||||||
|
if (Bauwelt.getBauwelt(p.getUniqueId()).getUUID() == null) {
|
||||||
|
p.sendMessage(BungeeCore.ChatPrefix + "§cDu hast keine Bauwelt");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
@ -6,6 +6,7 @@ import net.md_5.bungee.api.chat.ClickEvent;
|
|||||||
import net.md_5.bungee.api.chat.ComponentBuilder;
|
import net.md_5.bungee.api.chat.ComponentBuilder;
|
||||||
import net.md_5.bungee.api.chat.HoverEvent;
|
import net.md_5.bungee.api.chat.HoverEvent;
|
||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||||
|
|
||||||
public class HelpCommand extends Command {
|
public class HelpCommand extends Command {
|
||||||
public HelpCommand() {
|
public HelpCommand() {
|
||||||
@ -14,36 +15,84 @@ public class HelpCommand extends Command {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(CommandSender sender, String[] args) {
|
public void execute(CommandSender sender, String[] args) {
|
||||||
|
|
||||||
if(args.length != 1){
|
if(args.length != 1){
|
||||||
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Kehre von überall mit §e/l §7zur Lobby zurück!");
|
TextComponent tc = new TextComponent(BungeeCore.ChatPrefix + "§7Kehre von überall mit §8/§el §7zur Lobby zurück!");
|
||||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZurück zur Lobby").create()));
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZurück zur Lobby").create()));
|
||||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/l"));
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/l"));
|
||||||
sender.sendMessage(tc);
|
sender.sendMessage(tc);
|
||||||
|
|
||||||
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Komme mit §e/bau §7auf den Bauserver!");
|
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Komme mit §8/§ebau §7auf den Bauserver!");
|
||||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZum Bauserver").create()));
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZum Bauserver").create()));
|
||||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bauserver"));
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bauserver"));
|
||||||
sender.sendMessage(tc);
|
sender.sendMessage(tc);
|
||||||
|
|
||||||
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Erhalte mit §e/bau §7Hilfe auf dem Bauserver!");
|
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Erhalte mit §8/§ehelp bauserver §7Hilfe zum Bauserver!");
|
||||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cHilfe zum Bausystem").create()));
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eHilfe zum Bauserver").create()));
|
||||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau"));
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bauserver"));
|
||||||
sender.sendMessage(tc);
|
sender.sendMessage(tc);
|
||||||
|
|
||||||
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Starte mit §e/fight §7einen neuen Kampf!");
|
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Starte mit §8/§efight §7einen neuen Kampf!");
|
||||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cZum Kampfsystem").create()));
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZum Kampfsystem").create()));
|
||||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/fight"));
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/fight"));
|
||||||
sender.sendMessage(tc);
|
sender.sendMessage(tc);
|
||||||
|
|
||||||
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Trete mit §e/join [Spieler] §7einem Kampf bei!");
|
tc = new TextComponent(BungeeCore.ChatPrefix + "§7Trete mit §8/§ejoin §8[§eSpieler§8] §7einem Kampf bei!");
|
||||||
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§cSpieler nachjoinen").create()));
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSpieler beitreten").create()));
|
||||||
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/join"));
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/join"));
|
||||||
sender.sendMessage(tc);
|
sender.sendMessage(tc);
|
||||||
}else{
|
}else if(args[0].equalsIgnoreCase("bauserver")){
|
||||||
switch(args[0]){
|
sendBauHelp((ProxiedPlayer) sender);
|
||||||
|
}else if(args[0].equalsIgnoreCase("bau")){
|
||||||
|
sender.sendMessage("§8/§etnt §8- §7(de)aktiviert Explosionsschaden");
|
||||||
|
sender.sendMessage("§8/§efire §8- §7(de)aktiviert Feuerschaden");
|
||||||
|
sender.sendMessage("§8/§etestblock §8- §7Erneuert den nächsten Testblock");
|
||||||
|
sender.sendMessage("§8/§ereset §8- §7Setzt die derzeitige Region zurück");
|
||||||
|
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/§ehelp bauserver §8- §7Hilfe zum Bauserver");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
static void sendBauHelp(ProxiedPlayer p){
|
||||||
}
|
TextComponent tc = new TextComponent("§8/§ebau tp §8- §7Gehe auf Bauserver von Freunden!");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZu einem anderen Bauserver").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau tp "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau addmember §8- §7Fügt einen Freund hinzu");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eFüge einen Freund hinzu").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau addmember "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau delmember §8- §7Entfernt einen Spieler");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eEntfernt einen Spieler").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delmember "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau togglebuild §8- §7Berechtigung zum Bauen, /tp, /gm");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eStellt Spielerberechtigungen ein").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau togglebuild "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau togglewe §8- §7Berechtigung für WorldEdit, /testblock");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eStellt Spielerberechtigungen ein").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau togglewe "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau toggleworld §8- §7/reset, /trace, /fire, /tnt");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eStellt Spielerberechtigungen ein").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau toggleworld "));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ebau delete §8- §7Setzt deine Bauwelt zurück");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eBauwelt zurücksetzen").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/bau delete"));
|
||||||
|
p.sendMessage(tc);
|
||||||
|
|
||||||
|
tc = new TextComponent("§8/§ehelp bau §8- §7Hilfe zu nützlichen Werkzeugen");
|
||||||
|
tc.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNützliche Zusatzfunktionen").create()));
|
||||||
|
tc.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/help bau"));
|
||||||
|
p.sendMessage(tc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,6 +3,9 @@ package de.steamwar.bungeecore.commands;
|
|||||||
import de.steamwar.bungeecore.BungeeCore;
|
import de.steamwar.bungeecore.BungeeCore;
|
||||||
import de.steamwar.bungeecore.arenasystem.Arena;
|
import de.steamwar.bungeecore.arenasystem.Arena;
|
||||||
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
import de.steamwar.bungeecore.arenasystem.ArenaSystem;
|
||||||
|
import de.steamwar.bungeecore.bausystem.BauServer;
|
||||||
|
import de.steamwar.bungeecore.bausystem.BauSystem;
|
||||||
|
import de.steamwar.bungeecore.sql.BauweltMember;
|
||||||
import net.md_5.bungee.api.CommandSender;
|
import net.md_5.bungee.api.CommandSender;
|
||||||
import net.md_5.bungee.api.ProxyServer;
|
import net.md_5.bungee.api.ProxyServer;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
@ -16,6 +19,8 @@ import java.util.ArrayList;
|
|||||||
|
|
||||||
public class JoinmeCommand extends Command {
|
public class JoinmeCommand extends Command {
|
||||||
|
|
||||||
|
private static final String DENY_MESSAGE = "§cDu kannst diesem Spieler derzeit nicht folgen.";
|
||||||
|
|
||||||
public JoinmeCommand() {
|
public JoinmeCommand() {
|
||||||
super("join", "", "joinme");
|
super("join", "", "joinme");
|
||||||
}
|
}
|
||||||
@ -42,18 +47,27 @@ public class JoinmeCommand extends Command {
|
|||||||
ServerInfo server = target.getServer().getInfo();
|
ServerInfo server = target.getServer().getInfo();
|
||||||
String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
|
String ServerPerm = BungeeCore.serverPermissions.get(server.getName());
|
||||||
Arena arena = ArenaSystem.getArena(target);
|
Arena arena = ArenaSystem.getArena(target);
|
||||||
|
BauServer bauserver = BauSystem.getBau(target);
|
||||||
|
|
||||||
if(arena != null){
|
if(arena != null) {
|
||||||
arena.sendPlayer(player);
|
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());
|
||||||
|
player.sendMessage(BungeeCore.ChatPrefix + DENY_MESSAGE);
|
||||||
|
}
|
||||||
}else if(ServerPerm != null && !player.hasPermission(ServerPerm)){
|
}else if(ServerPerm != null && !player.hasPermission(ServerPerm)){
|
||||||
player.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst diesem Spieler derzeit nicht folgen.");
|
player.sendMessage(BungeeCore.ChatPrefix + DENY_MESSAGE);
|
||||||
}else if(ServerPerm == null && !player.getGroups().contains("team")) {
|
}else if(ServerPerm == null && !player.getGroups().contains("team")) {
|
||||||
player.sendMessage(BungeeCore.ChatPrefix + "§cDu kannst diesem Spieler derzeit nicht folgen.");
|
player.sendMessage(BungeeCore.ChatPrefix + DENY_MESSAGE);
|
||||||
}else{
|
}else{
|
||||||
player.connect(server);
|
player.connect(server);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
player.sendMessage(BungeeCore.ChatPrefix + "§7Mit §r/join §8[§rSpieler§8] §7kannst du einem Spieler folgen §8(z.B. in eine Arena)§7.");
|
player.sendMessage(BungeeCore.ChatPrefix + "§7Mit §8/§ejoin §8[§eSpieler§8] §7kannst du einem Spieler folgen §8(z.B. in eine Arena)§7.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
77
src/de/steamwar/bungeecore/sql/Bauwelt.java
Normale Datei
77
src/de/steamwar/bungeecore/sql/Bauwelt.java
Normale Datei
@ -0,0 +1,77 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class Bauwelt {
|
||||||
|
|
||||||
|
private final int UserID;
|
||||||
|
private boolean TNTDmg;
|
||||||
|
private boolean FireDmg;
|
||||||
|
|
||||||
|
private static List<Bauwelt> welten = new ArrayList<>();
|
||||||
|
|
||||||
|
private Bauwelt(int userID, boolean tntDmg, boolean fireDmg, boolean updateDB){
|
||||||
|
UserID = userID;
|
||||||
|
TNTDmg = tntDmg;
|
||||||
|
FireDmg = fireDmg;
|
||||||
|
if(updateDB)
|
||||||
|
updateDB();
|
||||||
|
welten.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bauwelt(int userID, boolean tntDmg, boolean fireDmg){
|
||||||
|
this(userID, tntDmg, fireDmg, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Bauwelt(UUID userID, boolean tntDmg, boolean fireDmg){
|
||||||
|
this(WarkingUser.get(userID).getId(), tntDmg, fireDmg, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDB(){
|
||||||
|
sql.update("INSERT INTO Bauwelt" +
|
||||||
|
" (UserID, TNTDmg, FireDmg)" +
|
||||||
|
" VALUES" +
|
||||||
|
" ('" + UserID + "', '" + sql.booleanToInt(TNTDmg) + "', '" + sql.booleanToInt(FireDmg) + "')" +
|
||||||
|
" ON DUPLICATE KEY UPDATE" +
|
||||||
|
" TNTDmg = VALUES(TNTDmg), FireDmg = VALUES(FireDmg)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bauwelt getBauwelt(UUID user){
|
||||||
|
return getBauwelt(WarkingUser.get(user).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Bauwelt getBauwelt(int userId){
|
||||||
|
for(Bauwelt welt : welten)
|
||||||
|
if(welt.UserID == userId)
|
||||||
|
return welt;
|
||||||
|
ResultSet bauwelt = sql.select("SELECT * FROM Bauwelt WHERE UserID = '" + userId + "'");
|
||||||
|
try {
|
||||||
|
if(bauwelt == null || !bauwelt.next()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean tntDmg = bauwelt.getBoolean("TNTDmg");
|
||||||
|
boolean fireDmg = bauwelt.getBoolean("FireDmg");
|
||||||
|
return new Bauwelt(userId, tntDmg, fireDmg, false);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache(){
|
||||||
|
welten.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getUserID() {
|
||||||
|
return UserID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUUID(){
|
||||||
|
return WarkingUser.get(UserID).getUUID();
|
||||||
|
}
|
||||||
|
}
|
134
src/de/steamwar/bungeecore/sql/BauweltMember.java
Normale Datei
134
src/de/steamwar/bungeecore/sql/BauweltMember.java
Normale Datei
@ -0,0 +1,134 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
import java.sql.ResultSet;
|
||||||
|
import java.sql.SQLException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public class BauweltMember{
|
||||||
|
private final int BauweltID;
|
||||||
|
private final int MemberID;
|
||||||
|
private boolean Build;
|
||||||
|
private boolean WorldEdit;
|
||||||
|
private boolean World;
|
||||||
|
|
||||||
|
private static final List<BauweltMember> members = new ArrayList<>();
|
||||||
|
|
||||||
|
private BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world, boolean updateDB){
|
||||||
|
BauweltID = ownerID;
|
||||||
|
MemberID = memberID;
|
||||||
|
Build = build;
|
||||||
|
WorldEdit = worldEdit;
|
||||||
|
World = world;
|
||||||
|
if(updateDB)
|
||||||
|
updateDB();
|
||||||
|
members.add(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BauweltMember(int ownerID, int memberID, boolean build, boolean worldEdit, boolean world){
|
||||||
|
this(ownerID, memberID, build, worldEdit, world, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BauweltMember(UUID ownerID, UUID memberID, boolean build, boolean worldEdit, boolean world){
|
||||||
|
this(WarkingUser.get(ownerID).getId(), WarkingUser.get(memberID).getId(), build, worldEdit, world, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void remove(){
|
||||||
|
sql.update("DELETE FROM BauweltMember WHERE BauweltID = " + BauweltID + " AND MemberID = " + MemberID);
|
||||||
|
members.remove(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void updateDB(){
|
||||||
|
sql.update("INSERT INTO BauweltMember" +
|
||||||
|
" (BauweltID, MemberID, Build, ChangeGM, Teleport, WorldEdit, Testblock)" +
|
||||||
|
" VALUES" +
|
||||||
|
" ('" + BauweltID + "', '" + MemberID + "', '" + sql.booleanToInt(Build) + "', '" + sql.booleanToInt(WorldEdit) + "', '" + sql.booleanToInt(World) + "')" +
|
||||||
|
" ON DUPLICATE KEY UPDATE" +
|
||||||
|
" Build = VALUES(Build), WorldEdit = VALUES(WorldEdit), World = VALUES(World)");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BauweltMember getBauMember(UUID ownerID, UUID memberID){
|
||||||
|
return getBauMember(WarkingUser.get(ownerID).getId(), WarkingUser.get(memberID).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static BauweltMember getBauMember(int ownerID, int memberID){
|
||||||
|
for(BauweltMember member : members)
|
||||||
|
if(member.BauweltID == ownerID && member.MemberID == memberID)
|
||||||
|
return member;
|
||||||
|
ResultSet member = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + ownerID + "' AND MemberID = '" + memberID + "'");
|
||||||
|
try {
|
||||||
|
if(member == null || !member.next()){
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
boolean build = member.getBoolean("Build");
|
||||||
|
boolean worldEdit = member.getBoolean("WorldEdit");
|
||||||
|
boolean world = member.getBoolean("World");
|
||||||
|
return new BauweltMember(ownerID, memberID, build, worldEdit, world, false);
|
||||||
|
} catch (SQLException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache(){
|
||||||
|
members.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<BauweltMember> getMembers(UUID bauweltID){
|
||||||
|
return getMembers(WarkingUser.get(bauweltID).getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
public static List<BauweltMember> getMembers(int bauweltID){
|
||||||
|
try{
|
||||||
|
ResultSet memberlist = sql.select("SELECT * FROM BauweltMember WHERE BauweltID = '" + bauweltID + "'");
|
||||||
|
List<BauweltMember> members = new ArrayList<>();
|
||||||
|
while(memberlist.next()){
|
||||||
|
int memberID = memberlist.getInt("MemberID");
|
||||||
|
boolean build = memberlist.getBoolean("Build");
|
||||||
|
boolean worldEdit = memberlist.getBoolean("WorldEdit");
|
||||||
|
boolean world = memberlist.getBoolean("World");
|
||||||
|
members.add(new BauweltMember(bauweltID, memberID, build, worldEdit, world, false));
|
||||||
|
}
|
||||||
|
return members;
|
||||||
|
}catch(SQLException e){
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return new ArrayList<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getBauweltID() {
|
||||||
|
return BauweltID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getMemberID() {
|
||||||
|
return MemberID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBuild() {
|
||||||
|
return Build;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBuild(boolean build) {
|
||||||
|
Build = build;
|
||||||
|
updateDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWorldEdit() {
|
||||||
|
return WorldEdit;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorldEdit(boolean worldEdit) {
|
||||||
|
WorldEdit = worldEdit;
|
||||||
|
updateDB();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isWorld() {
|
||||||
|
return World;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWorld(boolean world) {
|
||||||
|
World = world;
|
||||||
|
updateDB();
|
||||||
|
}
|
||||||
|
}
|
9
src/de/steamwar/bungeecore/sql/Permission.java
Normale Datei
9
src/de/steamwar/bungeecore/sql/Permission.java
Normale Datei
@ -0,0 +1,9 @@
|
|||||||
|
package de.steamwar.bungeecore.sql;
|
||||||
|
|
||||||
|
public enum Permission {
|
||||||
|
world,
|
||||||
|
worldedit,
|
||||||
|
build,
|
||||||
|
member,
|
||||||
|
owner
|
||||||
|
}
|
@ -7,17 +7,20 @@ import java.sql.ResultSet;
|
|||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.sql.Timestamp;
|
import java.sql.Timestamp;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class WarkingUser {
|
public class WarkingUser {
|
||||||
public int id;
|
private int id;
|
||||||
public UUID UUID;
|
private UUID UUID;
|
||||||
public String UserName;
|
private String UserName;
|
||||||
public String UserGroup;
|
private String UserGroup;
|
||||||
public Timestamp BanTime;
|
private Timestamp BanTime;
|
||||||
public String BanReason;
|
private String BanReason;
|
||||||
|
|
||||||
|
private static final List<WarkingUser> allUsers = new ArrayList<>();
|
||||||
public static Timestamp PermaBan = Timestamp.from(Instant.ofEpochSecond(946684800));
|
public static Timestamp PermaBan = Timestamp.from(Instant.ofEpochSecond(946684800));
|
||||||
|
|
||||||
public WarkingUser(int id){
|
public WarkingUser(int id){
|
||||||
@ -42,9 +45,9 @@ public class WarkingUser {
|
|||||||
UUID = connection.getUniqueId();
|
UUID = connection.getUniqueId();
|
||||||
UserName = connection.getName();
|
UserName = connection.getName();
|
||||||
UserGroup = "Member";
|
UserGroup = "Member";
|
||||||
sql.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES ('" + UUID.toString() + "', '" + UserName + "', '" + UserGroup + "')");
|
sql.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES ('" + getUUID().toString() + "', '" + getUserName() + "', '" + getUserGroup() + "')");
|
||||||
|
|
||||||
dbplayer = sql.select("SELECT * FROM UserData WHERE UUID = '" + UUID.toString() + "'");
|
dbplayer = sql.select("SELECT * FROM UserData WHERE UUID = '" + getUUID().toString() + "'");
|
||||||
init(dbplayer);
|
init(dbplayer);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -62,9 +65,9 @@ public class WarkingUser {
|
|||||||
UUID = player.getUniqueId();
|
UUID = player.getUniqueId();
|
||||||
UserName = player.getName();
|
UserName = player.getName();
|
||||||
UserGroup = "Member";
|
UserGroup = "Member";
|
||||||
sql.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES ('" + UUID.toString() + "', '" + UserName + "', '" + UserGroup + "')");
|
sql.update("INSERT INTO UserData (UUID, UserName, UserGroup) VALUES ('" + getUUID().toString() + "', '" + getUserName() + "', '" + getUserGroup() + "')");
|
||||||
|
|
||||||
dbplayer = sql.select("SELECT * FROM UserData WHERE UUID = '" + UUID.toString() + "'");
|
dbplayer = sql.select("SELECT * FROM UserData WHERE UUID = '" + getUUID().toString() + "'");
|
||||||
init(dbplayer);
|
init(dbplayer);
|
||||||
}
|
}
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -72,6 +75,32 @@ public class WarkingUser {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static WarkingUser get(String userName){
|
||||||
|
userName = sql.disarmString(userName);
|
||||||
|
for(WarkingUser user : allUsers)
|
||||||
|
if(user.getUserName().equalsIgnoreCase(userName))
|
||||||
|
return user;
|
||||||
|
return new WarkingUser(userName);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WarkingUser get(UUID uuid){
|
||||||
|
for(WarkingUser user : allUsers)
|
||||||
|
if(user.getUUID().equals(uuid))
|
||||||
|
return user;
|
||||||
|
return new WarkingUser(uuid);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static WarkingUser get(int id){
|
||||||
|
for(WarkingUser user : allUsers)
|
||||||
|
if(user.getId() == id)
|
||||||
|
return user;
|
||||||
|
return new WarkingUser(id);
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void clearCache(){
|
||||||
|
allUsers.clear();
|
||||||
|
}
|
||||||
|
|
||||||
private void init(ResultSet dbplayer){
|
private void init(ResultSet dbplayer){
|
||||||
try {
|
try {
|
||||||
if(!dbplayer.next()){
|
if(!dbplayer.next()){
|
||||||
@ -83,19 +112,20 @@ public class WarkingUser {
|
|||||||
UserGroup = dbplayer.getString("UserGroup");
|
UserGroup = dbplayer.getString("UserGroup");
|
||||||
BanTime = dbplayer.getTimestamp("BanTime");
|
BanTime = dbplayer.getTimestamp("BanTime");
|
||||||
BanReason = dbplayer.getString("BanReason");
|
BanReason = dbplayer.getString("BanReason");
|
||||||
|
allUsers.add(this);
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBanned(){
|
public boolean isBanned(){
|
||||||
if(BanTime == null){
|
if(getBanTime() == null){
|
||||||
return false;
|
return false;
|
||||||
}else if(BanTime.after(new Date()) || BanTime.before(PermaBan)){
|
}else if(getBanTime().after(new Date()) || getBanTime().before(PermaBan)){
|
||||||
return true;
|
return true;
|
||||||
}else{
|
}else{
|
||||||
sql.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE UUID = '" + UUID.toString() + "'");
|
sql.update("UPDATE UserData SET BanTime = NULL, BanReason = '' WHERE UUID = '" + getUUID().toString() + "'");
|
||||||
sql.update("DELETE FROM BannedUserIPs WHERE UserID = '" + id + "'");
|
sql.update("DELETE FROM BannedUserIPs WHERE UserID = '" + getId() + "'");
|
||||||
BanTime = null;
|
BanTime = null;
|
||||||
BanReason = "";
|
BanReason = "";
|
||||||
return false;
|
return false;
|
||||||
@ -106,14 +136,38 @@ public class WarkingUser {
|
|||||||
sql.update("INSERT INTO BannedUserIPs\n" +
|
sql.update("INSERT INTO BannedUserIPs\n" +
|
||||||
" (UserID, Timestamp, IP)\n" +
|
" (UserID, Timestamp, IP)\n" +
|
||||||
"VALUES\n" +
|
"VALUES\n" +
|
||||||
" (" + id + ", NOW(), '" + ip + "')\n" +
|
" (" + getId() + ", NOW(), '" + ip + "')\n" +
|
||||||
"ON DUPLICATE KEY UPDATE\n" +
|
"ON DUPLICATE KEY UPDATE\n" +
|
||||||
" Timestamp=NOW()");
|
" Timestamp=NOW()");
|
||||||
}
|
}
|
||||||
|
|
||||||
public void banPlayer(String ip, Timestamp time, String banReason){
|
public void banPlayer(String ip, Timestamp time, String banReason){
|
||||||
sql.update("UPDATE UserData SET BanTime = '" + time.toString() + "', BanReason = '" + banReason + "' WHERE UUID = '" + UUID.toString() + "'");
|
sql.update("UPDATE UserData SET BanTime = '" + time.toString() + "', BanReason = '" + banReason + "' WHERE UUID = '" + getUUID().toString() + "'");
|
||||||
if(ip != null)
|
if(ip != null)
|
||||||
updateBanIP(ip);
|
updateBanIP(ip);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getId() {
|
||||||
|
return id;
|
||||||
|
}
|
||||||
|
|
||||||
|
public UUID getUUID() {
|
||||||
|
return UUID;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserName() {
|
||||||
|
return UserName;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getUserGroup() {
|
||||||
|
return UserGroup;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Timestamp getBanTime() {
|
||||||
|
return BanTime;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getBanReason() {
|
||||||
|
return BanReason;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -73,8 +73,16 @@ public class sql {
|
|||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
public static Connection getCon(){
|
|
||||||
return con;
|
public static String disarmString(String s){
|
||||||
|
return s.replace("'", "");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static Integer booleanToInt(boolean b){
|
||||||
|
if(b)
|
||||||
|
return 1;
|
||||||
|
else
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setWebpw(WarkingUser user, String password){
|
public static void setWebpw(WarkingUser user, String password){
|
||||||
@ -85,7 +93,7 @@ public class sql {
|
|||||||
" (?, password(?))\n" +
|
" (?, password(?))\n" +
|
||||||
"ON DUPLICATE KEY UPDATE\n" +
|
"ON DUPLICATE KEY UPDATE\n" +
|
||||||
" WebPassword = VALUES(WebPassword)");
|
" WebPassword = VALUES(WebPassword)");
|
||||||
st.setInt(1, user.id);
|
st.setInt(1, user.getId());
|
||||||
st.setString(2, password);
|
st.setString(2, password);
|
||||||
st.executeUpdate();
|
st.executeUpdate();
|
||||||
} catch (SQLException e) {
|
} catch (SQLException e) {
|
||||||
@ -98,7 +106,7 @@ public class sql {
|
|||||||
" (?, password(?))\n" +
|
" (?, password(?))\n" +
|
||||||
"ON DUPLICATE KEY UPDATE\n" +
|
"ON DUPLICATE KEY UPDATE\n" +
|
||||||
" WebPassword = VALUES(WebPassword)");
|
" WebPassword = VALUES(WebPassword)");
|
||||||
st.setInt(1, user.id);
|
st.setInt(1, user.getId());
|
||||||
st.setString(2, password);
|
st.setString(2, password);
|
||||||
st.executeUpdate();
|
st.executeUpdate();
|
||||||
} catch (SQLException ex) {
|
} catch (SQLException ex) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren