Fix Region
Add BackupCommand /bu gui Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
Ursprung
8d23831687
Commit
efead4b8ef
@ -108,10 +108,13 @@ BACKUP_NO_PERMS=§cDu darfst hier nicht das Backup System verwenden
|
|||||||
BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt
|
BACKUP_CREATE_SUCCESS=§7Das Backup wurde erstellt
|
||||||
BACKUP_CREATE_FAILURE=§cDas Backup erstellen ist schiefgegangen
|
BACKUP_CREATE_FAILURE=§cDas Backup erstellen ist schiefgegangen
|
||||||
BACKUP_CREATE_NO_CHANGE=§7Die Region hat keine Veränderung
|
BACKUP_CREATE_NO_CHANGE=§7Die Region hat keine Veränderung
|
||||||
BACKUP_LIST_HEAD=§7---=== (§eBackup§7) ===---
|
BACKUP_LIST_HEAD=§7---=== (§eBackup §7{0}§7) ===---
|
||||||
BACKUP_LIST_ENTRY=§7{0} §e[Laden]
|
BACKUP_LIST_ENTRY=§7{0} §e[Laden]
|
||||||
BACKUP_LOAD_FAILURE=§cDas Backup laden ist schiefgegangen
|
BACKUP_LOAD_FAILURE=§cDas Backup laden ist schiefgegangen
|
||||||
BACKUP_LOAD=§7Backup geladen
|
BACKUP_LOAD=§7Backup geladen
|
||||||
|
BACKUP_INV_NAME=§eBackup
|
||||||
|
BACKUP_ITEM_NAME=§eBackup §7von §e{0}
|
||||||
|
BACKUP_LORE=§eKlicken zum Laden
|
||||||
|
|
||||||
# Bau
|
# Bau
|
||||||
BAU_COMMAND_HELP1 = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers
|
BAU_COMMAND_HELP1 = §8/§ebau togglewe §8[§7Player§8] §8- §7Editiere die WorldEdit Rechte eines Spielers
|
||||||
|
@ -28,10 +28,15 @@ import de.steamwar.bausystem.region.tags.Tag;
|
|||||||
import de.steamwar.command.SWCommand;
|
import de.steamwar.command.SWCommand;
|
||||||
import de.steamwar.command.SWCommandUtils;
|
import de.steamwar.command.SWCommandUtils;
|
||||||
import de.steamwar.command.TypeMapper;
|
import de.steamwar.command.TypeMapper;
|
||||||
|
import de.steamwar.inventory.SWItem;
|
||||||
|
import de.steamwar.inventory.SWListInv;
|
||||||
import net.md_5.bungee.api.chat.ClickEvent;
|
import net.md_5.bungee.api.chat.ClickEvent;
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -108,12 +113,35 @@ public class BackupCommand extends SWCommand {
|
|||||||
if (checkGlobalRegion(region, p)) {
|
if (checkGlobalRegion(region, p)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p);
|
List<String> backups = listBackup(p);
|
||||||
listBackup(p).forEach(s -> {
|
BauSystem.MESSAGE.send("BACKUP_LIST_HEAD", p, backups.size());
|
||||||
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s.replace('_', ' ')), s);
|
backups.forEach(s -> {
|
||||||
|
BauSystem.MESSAGE.send("BACKUP_LIST_ENTRY", p, "/backup load " + s, new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/backup load " + s), s);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Register("gui")
|
||||||
|
public void backupGui(Player p) {
|
||||||
|
Region region = Region.getRegion(p.getLocation());
|
||||||
|
if (checkGlobalRegion(region, p)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
List<String> backups = listBackup(p);
|
||||||
|
List<SWListInv.SWListEntry<String>> swListEntries = new ArrayList<>();
|
||||||
|
List<String> lore = Arrays.asList(BauSystem.MESSAGE.parse("BACKUP_LORE", p));
|
||||||
|
for (int i = 0; i < backups.size(); i++) {
|
||||||
|
String s = backups.get(i);
|
||||||
|
SWItem swItem = new SWItem(Material.BRICK, BauSystem.MESSAGE.parse("BACKUP_ITEM_NAME", p, s), lore, false, clickType -> {});
|
||||||
|
swItem.getItemStack().setAmount(i + 1);
|
||||||
|
swListEntries.add(new SWListInv.SWListEntry<>(swItem, s));
|
||||||
|
}
|
||||||
|
SWListInv<String> swListInv = new SWListInv<>(p, BauSystem.MESSAGE.parse("BACKUP_INV_NAME", p), swListEntries, (clickType, s) -> {
|
||||||
|
p.getOpenInventory().close();
|
||||||
|
backupLoad(p, s);
|
||||||
|
});
|
||||||
|
swListInv.open();
|
||||||
|
}
|
||||||
|
|
||||||
@Mapper(value = "backupName", local = true)
|
@Mapper(value = "backupName", local = true)
|
||||||
public TypeMapper<String> backupMapper() {
|
public TypeMapper<String> backupMapper() {
|
||||||
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
return SWCommandUtils.createMapper(s -> s, (commandSender, s) -> listBackup((Player) commandSender));
|
||||||
@ -130,5 +158,4 @@ public class BackupCommand extends SWCommand {
|
|||||||
return Collections.emptyList();
|
return Collections.emptyList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -478,7 +478,7 @@ public class Region {
|
|||||||
definedBackupFolder.mkdirs();
|
definedBackupFolder.mkdirs();
|
||||||
|
|
||||||
File[] currentBackups = definedBackupFolder.listFiles();
|
File[] currentBackups = definedBackupFolder.listFiles();
|
||||||
if (currentBackups.length >= 20) {
|
if (currentBackups != null && currentBackups.length >= 20) {
|
||||||
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
|
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
|
||||||
files.sort(Comparator.comparingLong(File::lastModified));
|
files.sort(Comparator.comparingLong(File::lastModified));
|
||||||
while (files.size() >= 20) files.remove(0).delete();
|
while (files.size() >= 20) files.remove(0).delete();
|
||||||
@ -493,7 +493,11 @@ public class Region {
|
|||||||
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
|
final File definedBackupFolder = new File(new File(backupFolder, prototype.getName()), name);
|
||||||
//noinspection ResultOfMethodCallIgnored
|
//noinspection ResultOfMethodCallIgnored
|
||||||
definedBackupFolder.mkdirs();
|
definedBackupFolder.mkdirs();
|
||||||
return Arrays.asList(Objects.requireNonNull(definedBackupFolder.list((dir, name) -> name.endsWith(".schem"))));
|
|
||||||
|
File[] currentBackups = definedBackupFolder.listFiles();
|
||||||
|
List<File> files = new ArrayList<>(Arrays.asList(currentBackups));
|
||||||
|
files.sort(Comparator.comparingLong(File::lastModified));
|
||||||
|
return files.stream().map(File::getName).collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
|
|
||||||
public File getBackupFile(String backupName) {
|
public File getBackupFile(String backupName) {
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren