SteamWar/BungeeCore
Archiviert
13
2

Update TutorialCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2022-06-16 12:15:50 +02:00
Ursprung 8a21d5c93d
Commit 9e867a7457

Datei anzeigen

@ -26,7 +26,9 @@ import de.steamwar.bungeecore.inventory.SWListInv;
import de.steamwar.bungeecore.inventory.SWStreamInv; import de.steamwar.bungeecore.inventory.SWStreamInv;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.bungeecore.sql.Tutorial; import de.steamwar.bungeecore.sql.Tutorial;
import net.md_5.bungee.api.CommandSender; import de.steamwar.command.GuardChecker;
import de.steamwar.command.GuardResult;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.connection.ProxiedPlayer; import net.md_5.bungee.api.connection.ProxiedPlayer;
@ -38,66 +40,63 @@ import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class TutorialCommand extends BasicCommand { public class TutorialCommand extends SWCommand {
public TutorialCommand() { public TutorialCommand() {
super("tutorial", null); super("tutorial", null);
addDefaultHelpMessage("TUTORIAL_CREATE_HELP");
addDefaultHelpMessage("TUTORIAL_OWN_HELP");
} }
@Override @Register
public void execute(CommandSender sender, String[] args) { public void genericCommand(ProxiedPlayer player) {
if(!(sender instanceof ProxiedPlayer)) openInventory(player, true, false);
return; }
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0) { @Register("rate")
openInventory(player, true, false); public void rate(ProxiedPlayer player) {
player.chat("/tutorial rate");
}
@Register("rate")
public void rate(ProxiedPlayer player, int id) {
Tutorial tutorial = Tutorial.get(id);
if(tutorial == null) {
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id);
return; return;
} }
switch(args[0].toLowerCase()) { rate(player, tutorial);
case "rate": }
if(args.length < 2) {
player.chat("/tutorial rate");
return;
}
int id; @Register(value = "create", description = "TUTORIAL_CREATE_HELP")
try { public void create(ProxiedPlayer player, String material, String... name) {
id = Integer.parseInt(args[1]); create(player, String.join(" ", name), material.toUpperCase());
} catch (NumberFormatException e) { }
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with non number: " + args[1]);
return;
}
Tutorial tutorial = Tutorial.get(id); @Register("own")
if(tutorial == null) { public void own(ProxiedPlayer player) {
BungeeCore.get().getLogger().log(Level.SEVERE, "rate executed with nonexistent id: " + id); openInventory(player, false, true);
return; }
}
rate(player, tutorial); @Register("unreleased")
break; public void unreleased(@Guard("unreleased") ProxiedPlayer player) {
case "create": openInventory(player, false, false);
if(args.length < 3) { }
Message.send("TUTORIAL_CREATE_HELP", player);
return;
}
create(player, Arrays.stream(args).skip(2).collect(Collectors.joining(" ")), args[1].toUpperCase()); @Guard("unreleased")
break; public GuardChecker unreleasedChecker() {
case "own": return (commandSender, guardCheckType, previousArguments, s) -> {
openInventory(player, false, true); if (commandSender instanceof ProxiedPlayer) {
break; if (SteamwarUser.get(((ProxiedPlayer) commandSender).getUniqueId()).getUserGroup().isTeamGroup()) {
case "unreleased": return GuardResult.ALLOWED;
if (SteamwarUser.get(player.getUniqueId()).getUserGroup().isTeamGroup()) { } else {
openInventory(player, false, false); return GuardResult.DENIED_WITH_HELP;
break;
} }
default: } else {
Message.send("TUTORIAL_CREATE_HELP", player); return GuardResult.ALLOWED;
Message.send("TUTORIAL_OWN_HELP", player); }
} };
} }
private void openInventory(ProxiedPlayer player, boolean released, boolean own) { private void openInventory(ProxiedPlayer player, boolean released, boolean own) {