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