mirror of
https://github.com/GeorgH93/Minepacks.git
synced 2025-01-07 19:28:11 +01:00
Add command to create a backup of all online players
This commit is contained in:
parent
04bf7da6ff
commit
1ad83c7173
@ -71,6 +71,7 @@ Language:
|
||||
Reload: "Lädt die Konfigurationsdatei neu."
|
||||
Update: "Prüft auf neue Plugin-Updates."
|
||||
Backup: "Erstellt eine Sicherungskopie eines Rucksacks."
|
||||
BackupEveryone: "Erstellt eine Sicherungskopie der Rucksäcke aller verbundenen Spieler."
|
||||
Restore: "Stellt eine Sicherungskopie eines Rucksacks wieder her."
|
||||
RestoreList: "Listet alle verfügbaren Sicherungskopien von Rucksäcken auf."
|
||||
Version: "Gibt die Versionsdetails über das Plugin und seine Abhängigkeiten aus."
|
||||
@ -120,4 +121,4 @@ LanguageName: "german"
|
||||
Author: "GeorgH93"
|
||||
|
||||
# Language file version. Don't touch it!
|
||||
Version: 18
|
||||
Version: 19
|
||||
|
@ -73,6 +73,7 @@ Language:
|
||||
Update: "Checks for new plugin updates."
|
||||
Version: "Prints the version details about the plugin and it's dependencies."
|
||||
Backup: "Creates a backup of a players backpack."
|
||||
BackupEveryone: "Creates a backup of everyone currently online."
|
||||
Restore: "Restores a backup."
|
||||
RestoreList: "Lists all available backups."
|
||||
Help: "Shows all available commands and their description."
|
||||
@ -115,4 +116,4 @@ LanguageName: "english"
|
||||
Author: "GeorgH93"
|
||||
|
||||
# Language file version. Don't touch it!
|
||||
Version: 18
|
||||
Version: 19
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
* Copyright (C) 2021 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -26,7 +26,9 @@
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Minepacks;
|
||||
import at.pcgamingfreaks.Minepacks.Bukkit.Permissions;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@ -35,12 +37,14 @@
|
||||
public class BackupCommand extends MinepacksCommand
|
||||
{
|
||||
private final Message messageCreated, messageNoBackpack;
|
||||
private final String helpParam;
|
||||
private final String helpParam, helpParamEveryone, descriptionEveryone;
|
||||
|
||||
public BackupCommand(Minepacks plugin)
|
||||
{
|
||||
super(plugin, "backup", plugin.getLanguage().getTranslated("Commands.Description.Backup"), Permissions.BACKUP, plugin.getLanguage().getCommandAliases("Backup"));
|
||||
helpParam = "<" + plugin.getLanguage().get("Commands.PlayerNameVariable") + ">";
|
||||
helpParamEveryone = "!everyone!";
|
||||
descriptionEveryone = plugin.getLanguage().getTranslated("Commands.Description.BackupEveryone");
|
||||
messageCreated = plugin.getLanguage().getMessage("Ingame.Backup.Created");
|
||||
messageNoBackpack = plugin.getLanguage().getMessage("Ingame.Backup.NoBackpack");
|
||||
}
|
||||
@ -50,21 +54,18 @@ public void execute(final @NotNull CommandSender sender, final @NotNull String m
|
||||
{
|
||||
if(args.length == 1)
|
||||
{
|
||||
//noinspection deprecation
|
||||
getMinepacksPlugin().getBackpack(plugin.getServer().getOfflinePlayer(args[0]), new Callback<Backpack>() {
|
||||
@Override
|
||||
public void onResult(Backpack backpack)
|
||||
if(args[0].equalsIgnoreCase("!everyone!"))
|
||||
{
|
||||
for(Player player : plugin.getServer().getOnlinePlayers())
|
||||
{
|
||||
((at.pcgamingfreaks.Minepacks.Bukkit.Backpack) backpack).backup();
|
||||
messageCreated.send(sender);
|
||||
backup(sender, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
messageNoBackpack.send(sender);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
else
|
||||
{
|
||||
//noinspection deprecation
|
||||
backup(sender, plugin.getServer().getOfflinePlayer(args[0]));
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -72,6 +73,24 @@ public void onFail()
|
||||
}
|
||||
}
|
||||
|
||||
private void backup(final @NotNull CommandSender sender, final @NotNull OfflinePlayer offlinePlayer)
|
||||
{
|
||||
getMinepacksPlugin().getBackpack(offlinePlayer, new Callback<Backpack>() {
|
||||
@Override
|
||||
public void onResult(Backpack backpack)
|
||||
{
|
||||
((at.pcgamingfreaks.Minepacks.Bukkit.Backpack) backpack).backup();
|
||||
messageCreated.send(sender);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onFail()
|
||||
{
|
||||
messageNoBackpack.send(sender);
|
||||
}
|
||||
}, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> tabComplete(final @NotNull CommandSender sender, final @NotNull String mainCommandAlias, final @NotNull String alias, final @NotNull String[] args)
|
||||
{
|
||||
@ -83,6 +102,7 @@ public List<HelpData> getHelp(final @NotNull CommandSender requester)
|
||||
{
|
||||
List<HelpData> help = new ArrayList<>(1);
|
||||
help.add(new HelpData(getTranslatedName(), helpParam, getDescription()));
|
||||
help.add(new HelpData(getTranslatedName(), helpParamEveryone, descriptionEveryone));
|
||||
return help;
|
||||
}
|
||||
}
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (C) 2020 GeorgH93
|
||||
* Copyright (C) 2021 GeorgH93
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
public class Language extends at.pcgamingfreaks.Bukkit.Language
|
||||
{
|
||||
private static final int LANG_VERSION = 18, UPGRADE_THRESHOLD = LANG_VERSION;
|
||||
private static final int LANG_VERSION = 19, UPGRADE_THRESHOLD = LANG_VERSION;
|
||||
|
||||
public Language(JavaPlugin plugin)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user