SteamWar/BungeeCore
Archiviert
13
2

Merge branch 'tpCommand' of SteamWar/BungeeCore into master

Dieser Commit ist enthalten in:
Lixfel 2019-12-21 17:41:26 +01:00 committet von Gitea
Commit d9fc6cfc76
5 geänderte Dateien mit 141 neuen und 43 gelöschten Zeilen

Datei anzeigen

@ -60,7 +60,6 @@
<groupId>steamwar</groupId> <groupId>steamwar</groupId>
<artifactId>PersistentBungeeCore</artifactId> <artifactId>PersistentBungeeCore</artifactId>
<version>1.0</version> <version>1.0</version>
<type>jar</type>
<scope>provided</scope> <scope>provided</scope>
</dependency> </dependency>
</dependencies> </dependencies>

Datei anzeigen

@ -56,7 +56,13 @@ public class BungeeCore extends Plugin {
new ChatListener(); new ChatListener();
new BanListener(); new BanListener();
commands.put("/bau", ""); commands.put("/b", null);
commands.put("/gs", null);
commands.put("/bau", null);
commands.put("/tp", null);
commands.put("/bc", null);
commands.put("/bauchat", null);
commands.put("/local", null);
new TeamchatCommand(); new TeamchatCommand();
new MsgCommand(); new MsgCommand();
@ -66,6 +72,7 @@ public class BungeeCore extends Plugin {
new AlertCommand(); new AlertCommand();
new KickCommand(); new KickCommand();
new JoinmeCommand(); new JoinmeCommand();
new TpCommand();
new FightCommand(); new FightCommand();
new HelpCommand(); new HelpCommand();
new BanCommand(); new BanCommand();

Datei anzeigen

@ -18,7 +18,7 @@ public class JoinmeCommand extends BasicCommand {
private static final String DENY_MESSAGE = "§cDu kannst diesem Spieler derzeit nicht folgen."; private static final String DENY_MESSAGE = "§cDu kannst diesem Spieler derzeit nicht folgen.";
public JoinmeCommand() { public JoinmeCommand() {
super("join", "", "joinme"); super("joinme", "");
} }
@Override @Override
@ -34,14 +34,14 @@ public class JoinmeCommand extends BasicCommand {
} else if (args.length == 1) { } else if (args.length == 1) {
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]); ProxiedPlayer target = ProxyServer.getInstance().getPlayer(args[0]);
if(target == null || !target.isConnected()){ if(target == null || !target.isConnected()){
player.sendMessage(BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist offline."); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist offline.");
return; return;
}else if(target.equals(player)){ }else if(target.equals(player)){
player.sendMessage(BungeeCore.CHAT_PREFIX + "§cSei eins mit dir selbst!"); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cSei eins mit dir selbst!");
return; return;
} }
ServerInfo server = target.getServer().getInfo(); ServerInfo server = target.getServer().getInfo();
String ServerPerm = BungeeCore.serverPermissions.get(server.getName()); String serverPerm = BungeeCore.serverPermissions.get(server.getName());
Subserver subserver = Subserver.getSubserver(target); Subserver subserver = Subserver.getSubserver(target);
if(subserver != null) { if(subserver != null) {
@ -55,18 +55,18 @@ public class JoinmeCommand extends BasicCommand {
subserver.sendPlayer(player); subserver.sendPlayer(player);
} else { } else {
SubserverSystem.sendDeniedMessage(player, bauserver.getOwner()); SubserverSystem.sendDeniedMessage(player, bauserver.getOwner());
player.sendMessage(BungeeCore.CHAT_PREFIX + DENY_MESSAGE); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
} }
} }
}else if(ServerPerm != null && !player.hasPermission(ServerPerm)){ }else if(serverPerm != null && !player.hasPermission(serverPerm)){
player.sendMessage(BungeeCore.CHAT_PREFIX + DENY_MESSAGE); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
}else if(ServerPerm == null && !player.getGroups().contains("team")) { }else if(serverPerm == null && !player.getGroups().contains("team")) {
player.sendMessage(BungeeCore.CHAT_PREFIX + DENY_MESSAGE); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
}else{ }else{
player.connect(server); player.connect(server);
} }
} else { } else {
player.sendMessage(BungeeCore.CHAT_PREFIX + "§7Mit §8/§ejoin §8[§eSpieler§8] §7kannst du einem Spieler folgen §8(z.B. in eine Arena)§7."); BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§7Mit §8/§ejoin §8[§eSpieler§8] §7kannst du einem Spieler folgen §8(z.B. in eine Arena)§7.");
} }
} }
} }

Datei anzeigen

@ -1,44 +1,116 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.BungeeCore; import de.steamwar.bungeecore.*;
import de.steamwar.bungeecore.sql.BauweltMember;
import de.steamwar.bungeecore.sql.Event;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team;
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.config.ServerInfo;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.event.ChatEvent; import net.md_5.bungee.api.event.ChatEvent;
public class TpCommand { import java.util.ArrayList;
import java.util.Arrays;
private TpCommand(){} public class TpCommand extends BasicCommand {
private static final String DENY_MESSAGE = "§cDu kannst diesem Spieler derzeit nicht folgen.";
public static void onTp(ChatEvent e, String[] command){ public static void onTp(ChatEvent e, String[] command){
if(!(e.getSender() instanceof ProxiedPlayer)) if(!(e.getSender() instanceof ProxiedPlayer))
return; return;
ProxiedPlayer player = (ProxiedPlayer) e.getSender(); if(onTp((ProxiedPlayer) e.getSender(), Arrays.copyOfRange(command, 1, command.length)))
if(command.length == 1){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§c/tp [Spieler]");
e.setCancelled(true); e.setCancelled(true);
}
public TpCommand(){
super("join", null);
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return; return;
if(!onTp((ProxiedPlayer) sender, args))
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cKonnte das angegebene Ziel nicht finden.");
}
@Override
public Iterable<String> onTabComplete(CommandSender commandSender, String[] args) {
if(args.length == 1){
return allPlayers(args[0]);
}
return new ArrayList<>();
}
private static boolean onTp(ProxiedPlayer player, String[] args){
if(args.length == 0){
if(Event.get() == null)
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§etp §8[§7Spieler§8]");
else
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§8/§etp §8[§7Spieler §8oder §7Team§8]");
return true;
} }
SteamwarUser user = SteamwarUser.get(player); //Get target player server
if(user == null){ ServerInfo server = getTargetPlayer(args[0]);
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cUnbekannter Spieler");
e.setCancelled(true); //Get target team event arena
return; if(server == null){
Team team = Team.get(args[0]);
if(team != null){
Subserver eventArena = EventStarter.getEventServer().get(team);
if(eventArena != null && Subserver.getServerList().contains(eventArena))
server = eventArena.getServer();
}
} }
//Give control of teleport command to server
if(server == null || server == player.getServer().getInfo())
return false;
teleport(player, server);
return true;
}
private static ServerInfo getTargetPlayer(String playerName){
SteamwarUser user = SteamwarUser.get(playerName);
if(user == null)
return null;
ProxiedPlayer target = ProxyServer.getInstance().getPlayer(user.getUuid()); ProxiedPlayer target = ProxyServer.getInstance().getPlayer(user.getUuid());
if(target == null){ if(target == null)
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + "§cDieser Spieler ist derzeit offline"); return null;
e.setCancelled(true);
return; return target.getServer().getInfo();
}
private static void teleport(ProxiedPlayer player, ServerInfo server){
String serverPerm = BungeeCore.serverPermissions.get(server.getName());
Subserver subserver = Subserver.getSubserver(server);
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());
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
}
}
}else if(serverPerm != null && !player.hasPermission(serverPerm)){
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
}else if(serverPerm == null && !player.getGroups().contains("team")) {
BungeeCore.send(player, BungeeCore.CHAT_PREFIX + DENY_MESSAGE);
}else{
player.connect(server);
} }
if(target.getServer() == player.getServer())
return;
e.setCancelled(true);
//TODO: Implement Joinme-Command Option
} }
} }

Datei anzeigen

@ -4,6 +4,7 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Servertype; import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver; import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.commands.BauCommand; import de.steamwar.bungeecore.commands.BauCommand;
import de.steamwar.bungeecore.commands.TpCommand;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Team; import de.steamwar.bungeecore.sql.Team;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
@ -23,7 +24,7 @@ import java.util.concurrent.TimeUnit;
public class ChatListener extends BasicListener { public class ChatListener extends BasicListener {
private static Title LIXFEL = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lLIXFEL")); private static final Title LIXFEL = ProxyServer.getInstance().createTitle().fadeIn(5).fadeOut(20).stay(30).title(TextComponent.fromLegacyText("§4§lLIXFEL"));
@EventHandler @EventHandler
public void onChatEvent(ChatEvent e){ public void onChatEvent(ChatEvent e){
@ -36,15 +37,28 @@ public class ChatListener extends BasicListener {
private void onCommand(ChatEvent e){ private void onCommand(ChatEvent e){
String [] command = e.getMessage().split(" "); String [] command = e.getMessage().split(" ");
if(command[0].contains(":")){ if(command[0].contains(":")){
if(e.getSender() instanceof ProxiedPlayer)
BungeeCore.send((ProxiedPlayer) e.getSender(), BungeeCore.CHAT_PREFIX + "§cUnbekannter Befehl.");
e.setCancelled(true); e.setCancelled(true);
if(e.getSender() instanceof ProxiedPlayer){ return;
ProxiedPlayer sender = (ProxiedPlayer) e.getSender(); }
BungeeCore.send(sender, BungeeCore.CHAT_PREFIX + "§cUnbekannter Befehl.");
} switch(command[0].toLowerCase()){
}else if((command[0].equalsIgnoreCase("/bau") || command[0].equalsIgnoreCase("/b") || command[0].equalsIgnoreCase("/gs")) && e.getSender() instanceof ProxiedPlayer){ case "/bau":
BauCommand.onBau(e, command); case "/b":
}else if(command[0].equalsIgnoreCase("/bc") || command[0].equalsIgnoreCase("/bauchat") || command[0].equalsIgnoreCase("/local")){ case "/gs":
localChat(e, command); BauCommand.onBau(e, command);
break;
case "/bc":
case "/bauchat":
case "/local":
localChat(e, command);
break;
case "/tp":
TpCommand.onTp(e, command);
break;
default:
//do nothing, let the normal command handlers proceed
} }
} }
@ -136,6 +150,12 @@ public class ChatListener extends BasicListener {
return; return;
} }
if(command[1].startsWith("/")){
BungeeCore.send(sender, "§Keine Befehle mit /local möglich.");
e.setCancelled(true);
return;
}
e.setMessage(e.getMessage().substring(command[0].length() + 1)); e.setMessage(e.getMessage().substring(command[0].length() + 1));
} }