SteamWar/BungeeCore
Archiviert
13
2

Rework two commands
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
zOnlyKroks 2023-01-21 16:18:47 +01:00
Ursprung b4ad223831
Commit 24456458de
4 geänderte Dateien mit 65 neuen und 71 gelöschten Zeilen

Datei anzeigen

@ -136,7 +136,7 @@ public class BungeeCore extends Plugin {
new KickCommand(); new KickCommand();
new JoinmeCommand(); new JoinmeCommand();
new TpCommand(); new TpCommand();
new HelpCommand(); HelpCommand helpCommand = new HelpCommand();
new TeamCommand(); new TeamCommand();
new ServerTeamchatCommand(); new ServerTeamchatCommand();
new DevCommand(); new DevCommand();
@ -176,7 +176,7 @@ public class BungeeCore extends Plugin {
new PunishmentCommand("note", Punishment.PunishmentType.Note); new PunishmentCommand("note", Punishment.PunishmentType.Note);
if(!EVENT_MODE){ if(!EVENT_MODE){
new BauCommand(); new BauCommand(helpCommand);
new WebpasswordCommand(); new WebpasswordCommand();
new FightCommand(); new FightCommand();
new ChallengeCommand(); new ChallengeCommand();

Datei anzeigen

@ -41,13 +41,16 @@ import java.util.Map;
public class BauCommand extends SWCommand { public class BauCommand extends SWCommand {
public BauCommand(){ private final HelpCommand command;
public BauCommand(HelpCommand command){
super("bau", null, "b", "build", "gs"); super("bau", null, "b", "build", "gs");
this.command = command;
} }
@Register(help = true) @Register(help = true)
public void genericHelp(ProxiedPlayer p, String... args) { public void genericHelp(ProxiedPlayer p, String... args) {
HelpCommand.sendBauHelp(ChatSender.of(p)); this.command.sendBauHelp(p);
} }
@Register @Register

Datei anzeigen

@ -20,20 +20,23 @@
package de.steamwar.bungeecore.commands; package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.Message; import de.steamwar.bungeecore.Message;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.protocol.packet.Chat;
public class HelpCommand extends BasicCommand { public class HelpCommand extends SWCommand {
public HelpCommand() { public HelpCommand() {
super("help", "", "?"); super("help", "", "?");
} }
@Override @Register
public void execute(CommandSender s, String[] args) { public void genericCommand(ProxiedPlayer player) {
ChatSender sender = ChatSender.of(s); ChatSender sender = ChatSender.of(player);
if (args.length < 1) {
printPage(sender, ClickEvent.Action.RUN_COMMAND, printPage(sender, ClickEvent.Action.RUN_COMMAND,
"HELP_LOBBY", "/l", "HELP_LOBBY", "/l",
"HELP_BAU", "/build", "HELP_BAU", "/build",
@ -44,48 +47,34 @@ public class HelpCommand extends BasicCommand {
"HELP_TEAM", "/team", "HELP_TEAM", "/team",
"HELP_JOIN", "/join", "HELP_JOIN", "/join",
"HELP_LOCAL", "/local"); "HELP_LOCAL", "/local");
}else if (args[0].equalsIgnoreCase("buildserver")) {
sendBauHelp(sender);
}else if (args[0].equalsIgnoreCase("build")) {
bauHelpGroup(sender, args);
}
} }
private static void bauHelpGroup(ChatSender sender, String[] args) { @Register({"build","world"})
if (args.length < 2) { public void buildWorld(ProxiedPlayer player) {
sendBauHelpGroup(sender); printPage(ChatSender.of(player), "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
return;
} }
switch (args[1].toLowerCase()) { @Register({"build","player"})
case "admin": public void buildPlayer(ProxiedPlayer player) {
case "owner": printPage(ChatSender.of(player), "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
case "bauwelt":
sender.system("HELP_BAU_GROUP_ADMIN_TITLE");
sendBauHelp(sender);
return;
case "world":
printPage(sender, "HELP_BAU_GROUP_WORLD_TITLE", "HELP_TNT", "HELP_FIRE", "HELP_FREEZE", "HELP_TPSLIMIT", "HELP_PROTECT", "HELP_RESET");
return;
case "player":
printPage(sender, "HELP_BAU_GROUP_PLAYER_TITLE", "HELP_SPEED", "HELP_NV", "HELP_WV", "HELP_DEBUGSTICK", "HELP_TRACE", "HELP_LOADER");
return;
case "worldedit":
case "we":
case "world-edit":
case "edit":
printPage(sender, "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
return;
case "other":
printPage(sender, "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
return;
default:
sendBauHelpGroup(sender);
}
} }
private static void sendBauHelpGroup(ChatSender sender) { @Register({"build","worldedit"})
printPage(sender, ClickEvent.Action.RUN_COMMAND, @Register({"build","we"})
@Register({"build","world-edit"})
@Register({"build","edit"})
public void buildWorldedit(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_WE_TITLE", "HELP_WE_POS1", "HELP_WE_POS2", "HELP_WE_COPY", "HELP_WE_PASTE", "HELP_WE_FLOPY", "HELP_WE_FLOPYP", "HELP_WE_ROTATE_90", "HELP_WE_ROTATE_180", "HELP_WE_ROTATE_N90");
}
@Register({"build","other"})
public void buildOther(ProxiedPlayer player) {
printPage(ChatSender.of(player), "HELP_BAU_GROUP_OTHER_TITLE", "HELP_TESTBLOCK", "HELP_SKULL", "HELP_BAUINFO");
}
@Register("build")
public void sendBauHelpGroup(ProxiedPlayer player) {
printPage(ChatSender.of(player), ClickEvent.Action.RUN_COMMAND,
"HELP_BAU_GROUP_ADMIN", "/help build admin", "HELP_BAU_GROUP_ADMIN", "/help build admin",
"HELP_BAU_GROUP_WORLD", "/help build world", "HELP_BAU_GROUP_WORLD", "/help build world",
"HELP_BAU_GROUP_PLAYER", "/help build player", "HELP_BAU_GROUP_PLAYER", "/help build player",
@ -93,8 +82,12 @@ public class HelpCommand extends BasicCommand {
"HELP_BAU_GROUP_OTHER", "/help build other"); "HELP_BAU_GROUP_OTHER", "/help build other");
} }
static void sendBauHelp(ChatSender sender) { @Register("buildserver")
printPage(sender, ClickEvent.Action.SUGGEST_COMMAND, @Register({"build","admin"})
@Register({"build","owner"})
@Register({"build","bauwelt"})
public void sendBauHelp(ProxiedPlayer player) {
printPage(ChatSender.of(player), ClickEvent.Action.SUGGEST_COMMAND,
"HELP_BAU_TP", "/build tp ", "HELP_BAU_TP", "/build tp ",
"HELP_BAU_ADDMEMBER", "/build addmember ", "HELP_BAU_ADDMEMBER", "/build addmember ",
"HELP_BAU_DELMEMBER", "/build delmember ", "HELP_BAU_DELMEMBER", "/build delmember ",

Datei anzeigen

@ -21,29 +21,27 @@ package de.steamwar.bungeecore.commands;
import de.steamwar.bungeecore.listeners.ChatListener; import de.steamwar.bungeecore.listeners.ChatListener;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import de.steamwar.messages.ChatSender; import de.steamwar.messages.ChatSender;
import net.md_5.bungee.api.CommandSender; import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.connection.ProxiedPlayer;
public class TeamchatCommand extends BasicCommand { public class TeamchatCommand extends SWCommand {
public TeamchatCommand() { public TeamchatCommand() {
super("tc", "","teamchat"); super("tc", "","teamchat");
} }
@Override @Register
public void execute(CommandSender s, String[] args) { public void genericCommand(ProxiedPlayer player, @ErrorMessage(value = "TC_USAGE", allowEAs = false) String... args) {
ChatSender sender = ChatSender.of(s); ChatSender sender = ChatSender.of(player);
if(args.length == 0){
sender.system("TC_USAGE");
return;
}
SteamwarUser user = sender.user(); SteamwarUser user = sender.user();
if(user.getTeam() == 0){ if(user.getTeam() == 0){
sender.system("TC_NO_TEAM"); sender.system("TC_NO_TEAM");
return; return;
} }
ChatListener.sendChat(sender, ChatSender.allReceivers().filter(player -> player.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args)); ChatListener.sendChat(sender, ChatSender.allReceivers().filter(p -> p.user().getTeam() == user.getTeam()), "CHAT_TEAM", null, String.join(" ", args));
} }
} }