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,38 +40,26 @@ 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;
|
||||
|
||||
if(args.length == 0) {
|
||||
@Register
|
||||
public void genericCommand(ProxiedPlayer player) {
|
||||
openInventory(player, true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
switch(args[0].toLowerCase()) {
|
||||
case "rate":
|
||||
if(args.length < 2) {
|
||||
@Register("rate")
|
||||
public void rate(ProxiedPlayer player) {
|
||||
player.chat("/tutorial rate");
|
||||
return;
|
||||
}
|
||||
|
||||
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("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);
|
||||
@ -77,27 +67,36 @@ public class TutorialCommand extends BasicCommand {
|
||||
}
|
||||
|
||||
rate(player, tutorial);
|
||||
break;
|
||||
case "create":
|
||||
if(args.length < 3) {
|
||||
Message.send("TUTORIAL_CREATE_HELP", player);
|
||||
return;
|
||||
}
|
||||
|
||||
create(player, Arrays.stream(args).skip(2).collect(Collectors.joining(" ")), args[1].toUpperCase());
|
||||
break;
|
||||
case "own":
|
||||
@Register(value = "create", description = "TUTORIAL_CREATE_HELP")
|
||||
public void create(ProxiedPlayer player, String material, String... name) {
|
||||
create(player, String.join(" ", name), material.toUpperCase());
|
||||
}
|
||||
|
||||
@Register("own")
|
||||
public void own(ProxiedPlayer player) {
|
||||
openInventory(player, false, true);
|
||||
break;
|
||||
case "unreleased":
|
||||
if (SteamwarUser.get(player.getUniqueId()).getUserGroup().isTeamGroup()) {
|
||||
}
|
||||
|
||||
@Register("unreleased")
|
||||
public void unreleased(@Guard("unreleased") ProxiedPlayer player) {
|
||||
openInventory(player, false, false);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
Message.send("TUTORIAL_CREATE_HELP", player);
|
||||
Message.send("TUTORIAL_OWN_HELP", player);
|
||||
|
||||
@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;
|
||||
}
|
||||
} else {
|
||||
return GuardResult.ALLOWED;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
private void openInventory(ProxiedPlayer player, boolean released, boolean own) {
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren