SteamWar/BauSystem2.0
Archiviert
12
0

Add SkinCommand
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2021-12-23 15:52:29 +01:00
Ursprung be0a69f546
Commit d990fc81d5
4 geänderte Dateien mit 198 neuen und 2 gelöschten Zeilen

Datei anzeigen

@ -1011,6 +1011,12 @@ LOCK_SCHEM_HELP=§8/§eschemlock §8[§7Owner§8] [§7Schematic§8] [§7Grund§8
AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert. AFK_KICK_MESSAGE=§cAuf diesem Server ist seit 5 Minuten nichts passiert.
AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt AFK_WARNING_MESSAGE=§cDieser Server wird bei weiterer Inaktivität in einer Minute gestoppt
SKIN_HELP = §8/§eskin §8[§7Kuerzel§8] §8[§7Creator§8|§epublic§8] §8[§7Name...§8] §8- §7Erstellt die Skin Schematics. 'public' als Creator nutzen für keinen Creator, danach die nachricht an YoyoNow kopieren (mit Click kopieren)
SKIN_NO_REGION=§7Du steht in keiner Region, welche mit einem Skin versehen werden kann
SKIN_ALREADY_EXISTS=§cDieser Skin existiert in der Form bereits
SKIN_MESSAGE=§7Skin erstellt
SKIN_MESSAGE_HOVER=§eKlicken zum kopieren für YoyoNow und an diesen senden
# Panzern # Panzern
PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl PANZERN_HELP = §8/§epanzern §8[§7Block§8] §8[§7Slab§8] §8- §7Panzer deine WorldEdit Auswahl
PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen. PANZERN_PREPARE1 = §71. Gucke nochmal nach, ob Läufe auch bis zur Panzergrenze führen.

Datei anzeigen

@ -0,0 +1,184 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2021 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.bausystem.features.team;
import de.steamwar.bausystem.BauSystem;
import de.steamwar.bausystem.linkage.LinkageType;
import de.steamwar.bausystem.linkage.Linked;
import de.steamwar.bausystem.region.Region;
import de.steamwar.bausystem.region.utils.RegionType;
import de.steamwar.command.SWCommand;
import de.steamwar.command.TypeMapper;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.UserGroup;
import net.md_5.bungee.api.chat.ClickEvent;
import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import yapion.hierarchy.output.StringOutput;
import yapion.hierarchy.types.YAPIONObject;
import java.io.File;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
@Linked(LinkageType.COMMAND)
public class SkinCommand extends SWCommand {
public SkinCommand() {
super("skin");
}
@Register(help = true)
public void genericHelp(Player p, String... args) {
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (!userGroup.isAdminGroup() && steamwarUser.getId() != 571) {
return;
}
BauSystem.MESSAGE.send("SKIN_HELP", p);
}
@Register
public void createCommand(Player p, @OptionalValue("") @Mapper("force") String force, @Mapper("kuerzel") String typeKuerzel, @Mapper("creator") String creator, String... names) {
SteamwarUser steamwarUser = SteamwarUser.get(p.getUniqueId());
UserGroup userGroup = steamwarUser.getUserGroup();
if (!userGroup.isAdminGroup() && steamwarUser.getId() != 571) {
return;
}
Region region = Region.getRegion(p.getLocation());
if (region.isGlobal()) {
BauSystem.MESSAGE.send("SKIN_NO_REGION", p);
return;
}
String name = String.join(" ", names);
File arenaFile = new File("sections4/custom/" + name + "/" + typeKuerzel + "Arena.schem");
File testblockFile = region.hasType(RegionType.TESTBLOCK) ? new File("sections4/custom/" + name + "/" + typeKuerzel + "Testblock.schem") : null;
arenaFile.getParentFile().mkdirs();
if (testblockFile != null) {
testblockFile.getParentFile().mkdirs();
}
if (arenaFile.exists() && force.equals("")) {
BauSystem.MESSAGE.send("SKIN_ALREADY_EXISTS", p);
return;
}
if (testblockFile != null && testblockFile.exists() && force.equals("")) {
BauSystem.MESSAGE.send("SKIN_ALREADY_EXISTS", p);
return;
}
Region.copy(region.getMinPoint(), region.getMaxPoint(), arenaFile);
if (testblockFile != null) {
Region.copy(region.getMinPointTestblock(), region.getMaxPointTestblock(), testblockFile);
}
YAPIONObject yapionObject = new YAPIONObject();
yapionObject.add("name", name);
if (!creator.equals("public")) {
yapionObject.add("creator", creator);
}
yapionObject.add("type", typeKuerzel);
yapionObject.add("schematic", arenaFile.getPath());
if (testblockFile != null) {
yapionObject.add("testblockSchematic", testblockFile.getPath());
}
BauSystem.MESSAGE.send("SKIN_MESSAGE", p, BauSystem.MESSAGE.parse("SKIN_MESSAGE_HOVER", p), new ClickEvent(ClickEvent.Action.COPY_TO_CLIPBOARD, yapionObject.toYAPION(new StringOutput(true)).getResult()));
}
@Mapper(value = "kuerzel", local = true)
public static TypeMapper<String> kurzelMapper() {
return new TypeMapper<String>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
List<String> current = new ArrayList<>();
current.add("WG");
current.add("MWG");
current.add("AS");
current.add("WS");
current.add("WSInner");
current.add("WG35");
return current;
}
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
return s;
}
};
}
@Mapper(value = "force", local = true)
public static TypeMapper<String> forceMapper() {
return new TypeMapper<String>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
List<String> current = new ArrayList<>();
current.add("-f");
return current;
}
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
if (s.equals("-f")) {
return s;
}
if (s.equals("")) {
return "";
}
return null;
}
};
}
@Mapper(value = "creator", local = true)
public static TypeMapper<String> creatorMapper() {
return new TypeMapper<String>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
List<String> current = new ArrayList<>();
current.add("public");
Bukkit.getOnlinePlayers().forEach(player -> {
current.add(player.getName());
});
return current;
}
@Override
public String map(CommandSender commandSender, String[] previousArguments, String s) {
Set<String> current = new HashSet<>();
current.add("public");
Bukkit.getOnlinePlayers().forEach(player -> {
current.add(player.getName());
});
if (current.contains(s)) {
return s;
}
return null;
}
};
}
}

Datei anzeigen

@ -45,6 +45,7 @@ public class Prototype {
@Getter @Getter
public static class Skin { public static class Skin {
private final String name; private final String name;
private final String creator; // Nullable
private final File schematicFile; private final File schematicFile;
private final File testblockSchematicFile; // Nullable private final File testblockSchematicFile; // Nullable
private final File buildSchematicFile; // Nullable private final File buildSchematicFile; // Nullable
@ -100,17 +101,18 @@ public class Prototype {
yapionObject.getArray("skins").forEach(yapionAnyType -> { yapionObject.getArray("skins").forEach(yapionAnyType -> {
YAPIONObject skinObject = (YAPIONObject) yapionAnyType; YAPIONObject skinObject = (YAPIONObject) yapionAnyType;
String skinName = skinObject.getPlainValue("name"); String skinName = skinObject.getPlainValue("name");
String skinCreator = skinObject.getPlainValueOrDefault("creator", null);
String schematicFileName = skinObject.getPlainValue("schematic"); String schematicFileName = skinObject.getPlainValue("schematic");
String testblockSchematicFileName = skinObject.getPlainValueOrDefault("testblockSchematic", null); String testblockSchematicFileName = skinObject.getPlainValueOrDefault("testblockSchematic", null);
String buildSchematicFileName = skinObject.getPlainValueOrDefault("buildSchematic", null); String buildSchematicFileName = skinObject.getPlainValueOrDefault("buildSchematic", null);
skinMap.put(skinName, new Skin(skinName, new File(schematicFileName), testblockSchematicFileName == null ? null : new File(testblockSchematicFileName), buildSchematicFileName == null ? null : new File(buildSchematicFileName))); skinMap.put(skinName, new Skin(skinName, skinCreator, new File(schematicFileName), testblockSchematicFileName == null ? null : new File(testblockSchematicFileName), buildSchematicFileName == null ? null : new File(buildSchematicFileName)));
}); });
} else { } else {
String s = yapionObject.getPlainValueOrDefault("schematic", null); String s = yapionObject.getPlainValueOrDefault("schematic", null);
File schematicFile = s == null ? null : new File(s); File schematicFile = s == null ? null : new File(s);
File testblockSchematicFile = testblock != null ? testblock.getSchematicFile() : null; File testblockSchematicFile = testblock != null ? testblock.getSchematicFile() : null;
File buildSchematicFile = build != null ? build.getSchematicFile() : null; File buildSchematicFile = build != null ? build.getSchematicFile() : null;
skinMap.put(displayName, new Skin(defaultSkin, schematicFile, testblockSchematicFile, buildSchematicFile)); skinMap.put(displayName, new Skin(defaultSkin, null, schematicFile, testblockSchematicFile, buildSchematicFile));
} }
if (PROTOTYPE_MAP.containsKey(name)) { if (PROTOTYPE_MAP.containsKey(name)) {

Datei anzeigen

@ -547,6 +547,10 @@ public class Region {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15)); return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, backupFile), 15));
} }
public static boolean copy(Point minPoint, Point maxPoint, File file) {
return VersionedCallable.call(new VersionedCallable<>(() -> Region_15.backup(minPoint, maxPoint, file), 15));
}
public List<String> listBackup() { public List<String> listBackup() {
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