13
0

Schemnodes Schematic System #93

Zusammengeführt
Lixfel hat 30 Commits von nodes nach master 2021-12-27 16:30:26 +01:00 zusammengeführt
4 geänderte Dateien mit 487 neuen und 305 gelöschten Zeilen
Nur Änderungen aus Commit 7c300f366f werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -20,13 +20,17 @@
package de.steamwar.schematicsystem;
import de.steamwar.schematicsystem.commands.SchematicCommand;
import de.steamwar.schematicsystem.commands.SchematicCommandUtils;
import org.bukkit.Bukkit;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.plugin.java.JavaPlugin;
import java.io.File;
import java.util.logging.Level;
public class SchematicSystem extends JavaPlugin {
public class SchematicSystem extends JavaPlugin implements Listener {
public static final String PREFIX = "§eSchematic§8» §7";
public static SchematicSystem INSTANCE;
@ -41,6 +45,12 @@ public class SchematicSystem extends JavaPlugin {
}
CheckSchemType.init(getConfig());
Bukkit.getPluginManager().registerEvents(this, this);
SCHEMATIC_COMMAND = new SchematicCommand();
}
@EventHandler
public void onPlayerQuit(PlayerQuitEvent event) {
SchematicCommandUtils.turnOffPublic(event.getPlayer());
}
}

Datei anzeigen

@ -37,19 +37,30 @@ import org.bukkit.Bukkit;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.logging.Level;
import java.util.stream.Collectors;
public class SchematicCommand extends SWCommand {
import static de.steamwar.schematicsystem.commands.SchematicCommandHelp.*;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.*;
private static final int CHUNK_SIZE = 15;
public class SchematicCommand extends SWCommand {
public SchematicCommand() {
super("schematic", "/schematic", "schem", "/schem");
}
@Register(help = true)
@Register("help")
public void genericHelp(Player player, String... args) {
printHelpMainPage(player);
}
@Register("help")
public void pagedHelp(Player player, HelpPage page) {
printHelpPage(player, page);
}
@Register("gui")
public void gui(Player player) {
GUI.open(player);
@ -58,36 +69,13 @@ public class SchematicCommand extends SWCommand {
@Register("list")
@Register({"list", "/"})
public void schemList(Player player) {
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId(), 0), 0, "", false);
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), 0, "", false);
}
@Register("list")
@Register({"list", "/"})
public void schemList(Player player, int page) {
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId(), 0), page, "", false);
}
@Register(help = true)
public void genericHelp(Player player, String... args) {
player.sendMessage(SchematicSystem.PREFIX + "Befehle§8:");
player.sendMessage("§8/§eschem gui §8- §7Öffnet die Schematic-GUI");
player.sendMessage("§8/§eschem list §8- §7Zeigt dir deine Schematics an");
player.sendMessage("§8/§eschem list public §8- §7Zeigt alle Public-Schematics");
player.sendMessage("§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics");
player.sendMessage("§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic");
player.sendMessage("§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic");
player.sendMessage("§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic");
player.sendMessage("§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic");
player.sendMessage("§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic");
player.sendMessage("§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)");
player.sendMessage("§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu");
player.sendMessage("§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic");
player.sendMessage("§8/§eschem clearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic");
player.sendMessage("§8/§eschem mkdir §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner");
player.sendMessage("§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic");
player.sendMessage("§8/§eschem rename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen");
player.sendMessage("§8/§eschem addteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu");
player.sendMessage("§8/§eschem remteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic");
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), page, "", false);
}
@Register({"list", "public"})
@ -120,7 +108,7 @@ public class SchematicCommand extends SWCommand {
@Register("list")
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (!node.isDir()) {
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
} else {
@ -132,13 +120,13 @@ public class SchematicCommand extends SWCommand {
public void schemInfoSecret(Player player) {
player.sendMessage("§7--==( §eSteam§8War §eSchematic-System §7)==--");
player.sendMessage("§7Anzahl an Schematics: §e" + SchematicNode.countNodes());
player.sendMessage("§7Von dir einsehbar: §e" + SchematicNode.getAllSchematicsAccessibleByUser(SteamwarUser.get(player.getUniqueId()).getId()).size());
player.sendMessage("§7Von dir einsehbar: §e" + SchematicNode.getAllSchematicsAccessibleByUser(getUser(player).getId()).size());
player.sendMessage("§7Autoren: §e" + Arrays.toString(SchematicSystem.INSTANCE.getDescription().getAuthors().toArray()));
}
@Register("list")
public void schemList(Player player, @Mapper("dirMapper") SchematicNode node, int page) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (!node.isDir()) {
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
} else {
@ -154,90 +142,7 @@ public class SchematicCommand extends SWCommand {
@Register("info")
public void schemInfo(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
player.sendMessage("§7--==( §e" + node.getName() + " §7)==--");
player.sendMessage("§7Name: §e" + node.generateBreadcrumbs(user));
player.sendMessage("§7Besitzer: §e" + SteamwarUser.get(node.getOwner()).getUserName());
player.sendMessage("§7Ordner: §e" + (node.getParent() == null || node.getParent() == 0 ? "/" : node.getParentNode().generateBreadcrumbs(user)));
player.sendMessage("§7Letzes Update: §e" + node.getLastUpdate().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm dd.MM.yyyy", Locale.GERMAN)));
player.sendMessage("§7Typ: §e" + (node.isDir() ? "§9DIR" : node.getSchemtype().name()));
if (!node.isDir()) {
if (node.getRank() > 0) {
player.sendMessage("§7Rang: §e" + node.getRank());
}
player.sendMessage("§7Format: §e" + (node.getSchemFormat() ? ".schem" : ".schematic"));
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
for (CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemName().equals(node.getName()) &&
checkedSchematic.getSchemOwner() == node.getOwner()) {
player.sendMessage("§cStatus: §c" + checkedSchematic.getStartTime() + " : " + checkedSchematic.getDeclineReason());
break;
}
}
}
List<String> schematicMembers = new ArrayList<>();
NodeMember.getNodeMembers(node.getId()).forEach(nodeMember -> schematicMembers.add(SteamwarUser.get(nodeMember.getMember()).getUserName()));
if (!schematicMembers.isEmpty()) {
player.sendMessage("§7Mitglieder: §e" + schematicMembers);
}
TextComponent base = new TextComponent();
if (!node.isDir()) {
TextComponent load = new TextComponent("[Laden] ");
load.setColor(ChatColor.GREEN);
load.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic laden")));
load.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + (node.getOwner() == 0 ? "public " : "") + node.generateBreadcrumbs(user)));
base.addExtra(load);
if (node.getOwner() == user.getId()) {
TextComponent download = new TextComponent("[Download] ");
download.setColor(ChatColor.GOLD);
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic downloaden")));
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + node.generateBreadcrumbs(user)));
base.addExtra(download);
TextComponent changeTyp = new TextComponent("[Typ ändern] ");
changeTyp.setColor(ChatColor.BLUE);
changeTyp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic Typ ändern")));
changeTyp.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + node.generateBreadcrumbs(user)));
base.addExtra(changeTyp);
}
}
if (node.getOwner() == user.getId()) {
TextComponent addMember = new TextComponent("[Hinzufügen] ");
addMember.setColor(ChatColor.AQUA);
addMember.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eMember hinzufügen")));
addMember.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem addmember " + node.generateBreadcrumbs(user) + " "));
base.addExtra(addMember);
TextComponent delMember = new TextComponent("[Entfernen] ");
delMember.setColor(ChatColor.RED);
delMember.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eMember entfernen")));
delMember.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem delmember " + node.generateBreadcrumbs(user) + " "));
base.addExtra(delMember);
TextComponent move = new TextComponent("[Verschieben] ");
move.setColor(ChatColor.DARK_PURPLE);
move.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " verschieben")));
move.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem move " + node.generateBreadcrumbs(user) + " " + node.generateBreadcrumbs(user).replace("/" + node.getName(), "")));
base.addExtra(move);
TextComponent rename = new TextComponent("[Umbenennen] ");
rename.setColor(ChatColor.LIGHT_PURPLE);
rename.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " umbenennen")));
rename.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem rename " + node.generateBreadcrumbs(user) + " [Neuer Name]"));
base.addExtra(rename);
TextComponent delete = new TextComponent("[Löschen] ");
delete.setColor(ChatColor.DARK_RED);
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
base.addExtra(delete);
}
player.spigot().sendMessage(base);
printSchemInfo(player, node);
}
@Register("l")
@ -263,7 +168,7 @@ public class SchematicCommand extends SWCommand {
@Register("save")
@Register("s")
public void saveSchem(Player player, @Mapper("dirStringMapper") String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (name.startsWith("/")) name = name.substring(1);
String[] layers = name.split("/");
if (invalidSchemName(player, layers)) return;
@ -305,7 +210,7 @@ public class SchematicCommand extends SWCommand {
@Register("addmember")
public void addMember(Player player, SchematicNode node, SteamwarUser target) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden hinzufügen.");
return;
@ -332,7 +237,7 @@ public class SchematicCommand extends SWCommand {
@Register("delmember")
@Register("remmember")
public void delMember(Player player, SchematicNode node, @Mapper("memberMapper") NodeMember member) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur auf deine eigenen Sachen jemanden entfernen.");
@ -353,7 +258,7 @@ public class SchematicCommand extends SWCommand {
@Register("search")
public void schemSearch(Player player, String quarry) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
List<SchematicNode> nodes = SchematicNode.filterSchems(user.getId(), node -> node.getName().contains(quarry));
player.sendMessage("§7--==( §eSchematics §8(§e" + nodes.size() + "§8) §7)==--");
nodes.forEach(node -> {
@ -368,7 +273,7 @@ public class SchematicCommand extends SWCommand {
@Register("download")
public void download(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage("§cDu darfst nur deine eigenen Schematics herunterladen!");
return;
@ -382,7 +287,7 @@ public class SchematicCommand extends SWCommand {
@Register("ordner")
@Register("mkdir")
public void mkdir(Player player, @Mapper("dirStringMapper") String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (name.startsWith("/")) name = name.substring(1);
if (name.endsWith("/")) name = name.substring(0, name.length() - 1);
String[] layers = name.split("/");
@ -393,7 +298,11 @@ public class SchematicCommand extends SWCommand {
@Register("changetype")
public void changeType(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden.");
return;
}
TextComponent base = new TextComponent();
SchematicType.values().forEach(type -> {
@ -417,6 +326,12 @@ public class SchematicCommand extends SWCommand {
@Register("changetype")
public void changeType(Player player, SchematicNode node, SchematicType type, Extend extend) {
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nur deine eigenen Schematics einsenden.");
return;
}
if (node.isDir()) {
player.sendMessage(SchematicSystem.PREFIX + "§cOrdner haben keinen Typen.");
return;
@ -472,7 +387,7 @@ public class SchematicCommand extends SWCommand {
@Register("move")
public void move(Player player, SchematicNode node, @Mapper("dirStringMapper") String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return;
@ -492,7 +407,7 @@ public class SchematicCommand extends SWCommand {
@Register("rename")
public void rename(Player player, SchematicNode node, String name) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return;
@ -506,7 +421,7 @@ public class SchematicCommand extends SWCommand {
@Register("addteam")
public void addTeam(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return;
@ -536,7 +451,7 @@ public class SchematicCommand extends SWCommand {
@Register("remteam")
public void remTeam(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return;
@ -568,7 +483,7 @@ public class SchematicCommand extends SWCommand {
@Register("remallmember")
@Register("clearmember")
public void clearMember(Player player, SchematicNode node) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
SteamwarUser user = getUser(player);
if (node.getOwner() != user.getId()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return;
@ -578,129 +493,24 @@ public class SchematicCommand extends SWCommand {
player.sendMessage(SchematicSystem.PREFIX + "§7Alle Spieler wurden von der Schematic entfernt");
}
private boolean invalidSchemName(Player player, String[] layers) {
for (String layer : layers) {
if (layer.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDeine Ordner brauchen schon einen Namen!");
return true;
}
if (layer.contains("/") ||
layer.contains("\\") ||
layer.contains("<") ||
layer.contains(">") ||
layer.contains("^") ||
layer.contains("°") ||
layer.contains("'") ||
layer.contains("\"")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true;
}
@Register("togglepublic")
public void togglePublicMode(Player player) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
if (!user.getUserGroup().isAdminGroup()) {
genericHelp(player);
return;
}
return false;
}
private SchematicNode mkdirs(String[] layers, SteamwarUser user, int minus) {
SchematicNode currentNode = null;
for (int i = 0; i < layers.length - minus; i++) {
int finalI = i;
List<SchematicNode> nodes;
if (currentNode == null) {
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
} else {
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
}
if (nodes.isEmpty()) {
currentNode = SchematicNode.createSchematicDirectory(user.getId(), layers[i], currentNode == null ? 0 : currentNode.getId());
} else {
if (!nodes.get(0).isDir()) {
nodes.set(0, SchematicNode.createSchematicDirectory(user.getId(), layers[i] + "-dir-" + System.currentTimeMillis() % 100, currentNode == null ? 0 : currentNode.getId()));
}
currentNode = nodes.get(0);
}
if (togglePublic(player)) {
player.sendMessage(SchematicSystem.PREFIX + "§aDu bist nun der Public User");
} else {
player.sendMessage(SchematicSystem.PREFIX + "§cDu bist nun nicht mehr der Public User");
}
return currentNode;
}
private final TypeMapper<SchematicNode> schematicCommandTypeMapper = nodeTypeMapper();
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
private void renderSchemlist(Player player, List<SchematicNode> nodes, int chunk, String breadcrumbs, boolean isPublic) {
nodes.sort(Comparator.comparing(SchematicNode::getName));
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
int pageCount = (int) Math.ceil(nodes.size() / (double) CHUNK_SIZE);
player.sendMessage("§7--==( §eSchematics §8(§e" + nodes.size() + "§8) §7)==--");
player.sendMessage("§7Aktueller Pfad: §e" + (breadcrumbs.isEmpty() ? "/" : breadcrumbs));
if (!breadcrumbs.isEmpty()) {
TextComponent back = new TextComponent("§e../");
String str = breadcrumbs.substring(0, Math.max(0, breadcrumbs.substring(0, breadcrumbs.length() - 1).lastIndexOf("/")));
back.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZurück gehen" + str).create()));
back.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + str));
player.spigot().sendMessage(back);
}
for (int i = chunk * CHUNK_SIZE; i < nodes.size() && i < (chunk + 1) * CHUNK_SIZE; i++) {
SchematicNode node = nodes.get(i);
StringBuilder nodeString = new StringBuilder();
if (node.isDir()) {
nodeString.append("§9DIR §e");
} else {
SchematicType type = node.getSchemtype();
if (type != SchematicType.Normal) {
nodeString.append("§8§l")
.append(type.getKuerzel().toUpperCase())
.append(" ");
}
nodeString.append("§e");
}
nodeString.append(node.getName());
if (node.isDir()) {
nodeString.append("/");
}
if (node.getOwner() != user.getId()) {
nodeString.append(" §8von §7")
.append(SteamwarUser.get(node.getOwner()).getUserName());
}
TextComponent schematics = new TextComponent(nodeString.toString());
if (node.isDir()) {
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eOrdner anzeigen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + node.getName() + "/"));
} else {
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + (isPublic ? "public" : "") + " " + breadcrumbs + node.getName()));
}
player.spigot().sendMessage(schematics);
}
TextComponent beforePage = new TextComponent("««");
if (chunk > 0) {
beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk - 1)));
} else {
beforePage.setColor(ChatColor.RED);
}
TextComponent nextPage = new TextComponent(" Seite (" + (chunk + 1) + "/" + Math.max(pageCount, 1) + ") »»");
if (chunk < pageCount - 1) {
nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk + 1)));
} else {
nextPage.setColor(ChatColor.RED);
}
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
@Mapper("publicMapper")
public TypeMapper<SchematicNode> publicNodeTypeMapper() {
return new TypeMapper<SchematicNode>() {
@ -788,7 +598,7 @@ public class SchematicCommand extends SWCommand {
return new TypeMapper<String>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
List<String> list = getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), strings, s);
List<String> list = getNodeTabcomplete(getUser((Player) commandSender), strings, s);
list.removeIf(s1 -> !s1.endsWith("/"));
return list;
}
@ -805,12 +615,12 @@ public class SchematicCommand extends SWCommand {
return new TypeMapper<SchematicNode>() {
@Override
public List<String> tabCompletes(CommandSender commandSender, String[] strings, String s) {
return getNodeTabcomplete(SteamwarUser.get(((Player) commandSender).getUniqueId()), strings, s);
return getNodeTabcomplete(getUser((Player) commandSender), strings, s);
}
@Override
public SchematicNode map(CommandSender commandSender, String[] previousArguments, String s) {
return mapNode(SteamwarUser.get(((Player) commandSender).getUniqueId()), previousArguments, s);
return mapNode(getUser((Player) commandSender), previousArguments, s);
}
};
}
@ -834,63 +644,4 @@ public class SchematicCommand extends SWCommand {
AUSFAHREN,
NORMAL
}
private static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
List<String> list = new ArrayList<>();
boolean sws = s.startsWith("/");
if (sws) {
s = s.substring(1);
}
if (s.contains("/")) {
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
SchematicNode pa = mapNode(user, strings, preTab);
if (pa == null) return Collections.emptyList();
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
nodes.forEach(node -> list.add(node.generateBreadcrumbs(user)));
} else {
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
}
list.remove("//copy");
return list;
}
private static SchematicNode mapNode(SteamwarUser user, String[] previousArguments, String s) {
if (s.startsWith("/")) {
s = s.substring(1);
}
if (s.isEmpty()) {
return null;
}
if (s.contains("/")) {
String[] layers = s.split("/");
SchematicNode currentNode = null;
for (int i = 0; i < layers.length; i++) {
int finalI = i;
List<SchematicNode> nodes;
if (currentNode == null) {
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
} else {
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
}
if (nodes.isEmpty()) {
return null;
} else {
currentNode = nodes.get(0);
if (!currentNode.isDir() && i != layers.length - 1) {
return null;
}
}
}
return currentNode;
} else {
String finalS = s;
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(finalS)).collect(Collectors.toList());
if (nodes.isEmpty()) {
return null;
} else {
return nodes.get(0);
}
}
}
}

Datei anzeigen

@ -0,0 +1,89 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.schematicsystem.commands;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
public class SchematicCommandHelp {
private SchematicCommandHelp() {
}
public static void printHelpMainPage(Player player) {
player.sendMessage("§7---===( §eSchematicSystem Hilfe §7)===---");
player.sendMessage("§eKategorien: ");
for (HelpPage page : HelpPage.values()) {
TextComponent pageComp = new TextComponent(page.mainText);
pageComp.setColor(ChatColor.GRAY);
pageComp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + page.hover)));
pageComp.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem help " + page.name()));
player.spigot().sendMessage(pageComp);
}
}
public static void printHelpPage(Player player, HelpPage page) {
player.sendMessage("§7---===( §eSchematicSystem Hilfe §7)===---");
for (String s : page.content) {
player.sendMessage(s);
}
}
public enum HelpPage {
ANSICHT("Ansichtbefehle", "Schaue dir deine oder dir Freigegebene Schematics an", new String[]{
"§8/§eschem info §8[§7Schematic§8] - §7Zeigt dir Informationen zur Schematic",
"§8/§eschem list §8- §7Zeigt dir deine Schematics an",
"§8/§eschem list public §8- §7Zeigt alle Public-Schematics",
"§8/§eschem search §8[§7Stichwort§8] - §7Sucht nach passenden Schematics",
"§8/§eschem load §8[§7Schematic§8] - §7Lädt eine Schematic",
"§8/§eschem download §8[§7Schematic§8] - §7Gibt dir einen Downloadlink (1 min gültig)"
}),
BEARBEITUNG("Bearbeitungsbefehle", "Modifizierung von Schematics und Ordnern", new String[]{
"§8/§eschem save §8[§7Schematic§8] - §7Speichert dein Clipboard als Schematic",
"§8/§eschem mkdir §8[§7Ordner§8] - §7Erstelle einen Leeren Ordner",
"§8/§eschem move §8[§7Schematic§8] [§7Neuer Pfad§8] - §7Verschiebe eine Schematic",
"§8/§eschem rename §8[§7Schematic§8] [§7Neuer Name§8] - §7Gib der Schematic einen neuen Namen",
"§8/§eschem changetype §8[§7Schematic§8] - §7Ändert die Art deiner Schematic",
"§8/§eschem delete §8[§7Schematic§8] - §7Löscht eine Schematic"
}),
MEMBER("Memberbefehle", "Schematics mit anderen teilen", new String[]{
"§8/§eschem addmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Fügt einen Spieler zu einer Schematic hinzu",
"§8/§eschem delmember §8[§7Schematic§8] §8[§7Spieler§8] - §7Entfernt einen Spieler von einer Schematic",
"§8/§eschem clearmember §8[§7Schematic§8] - §7Entfernt alle Spieler von der Schematic",
"§8/§eschem addteam §8[§7Schematic§8] - §7Füge jeden aus deinem Team auf die Schematic hinzu",
"§8/§eschem remteam §8[§7Schematic§8] - §7Entferne jeden aus deinem Team von der Schematic"
});
private final String mainText;
private final String[] content;
private final String hover;
HelpPage(String mainText, String hover, String[] content) {
this.mainText = mainText;
this.hover = hover;
this.content = content;
}
}
}

Datei anzeigen

@ -0,0 +1,332 @@
/*
This file is a part of the SteamWar software.
Copyright (C) 2020 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.schematicsystem.commands;
import de.steamwar.schematicsystem.SchematicSystem;
import de.steamwar.sql.*;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.ComponentBuilder;
import net.md_5.bungee.api.chat.HoverEvent;
import net.md_5.bungee.api.chat.TextComponent;
import org.bukkit.entity.Player;
import java.time.format.DateTimeFormatter;
import java.util.*;
import java.util.stream.Collectors;
public class SchematicCommandUtils {
private static final int CHUNK_SIZE = 15;
private static final List<Player> PUBLIC_TOGGLED = new ArrayList<>();
private SchematicCommandUtils() {
}
public static SchematicNode mapNode(SteamwarUser user, String[] previousArguments, String s) {
if (s.startsWith("/")) {
s = s.substring(1);
}
if (s.isEmpty()) {
return null;
}
if (s.contains("/")) {
String[] layers = s.split("/");
SchematicNode currentNode = null;
for (int i = 0; i < layers.length; i++) {
int finalI = i;
List<SchematicNode> nodes;
if (currentNode == null) {
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
} else {
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
}
if (nodes.isEmpty()) {
return null;
} else {
currentNode = nodes.get(0);
if (!currentNode.isDir() && i != layers.length - 1) {
return null;
}
}
}
return currentNode;
} else {
String finalS = s;
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(finalS)).collect(Collectors.toList());
if (nodes.isEmpty()) {
return null;
} else {
return nodes.get(0);
}
}
}
public static List<String> getNodeTabcomplete(SteamwarUser user, String[] strings, String s) {
List<String> list = new ArrayList<>();
boolean sws = s.startsWith("/");
if (sws) {
s = s.substring(1);
}
if (s.contains("/")) {
String preTab = s.substring(0, s.lastIndexOf("/") + 1);
SchematicNode pa = mapNode(user, strings, preTab);
if (pa == null) return Collections.emptyList();
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
nodes.forEach(node -> list.add(node.generateBreadcrumbs(user)));
} else {
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));
}
list.remove("//copy");
return list;
}
public static boolean invalidSchemName(Player player, String[] layers) {
for (String layer : layers) {
if (layer.isEmpty()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDeine Ordner brauchen schon einen Namen!");
return true;
}
if (layer.contains("/") ||
layer.contains("\\") ||
layer.contains("<") ||
layer.contains(">") ||
layer.contains("^") ||
layer.contains("°") ||
layer.contains("'") ||
layer.contains("\"")) {
player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen");
return true;
}
}
return false;
}
public static void renderSchemlist(Player player, List<SchematicNode> nodes, int chunk, String breadcrumbs, boolean isPublic) {
nodes.sort(Comparator.comparing(SchematicNode::getName));
SteamwarUser user = getUser(player);
int pageCount = (int) Math.ceil(nodes.size() / (double) CHUNK_SIZE);
player.sendMessage("§7--==( §eSchematics §8(§e" + nodes.size() + "§8) §7)==--");
player.sendMessage("§7Aktueller Pfad: §e" + (breadcrumbs.isEmpty() ? "/" : breadcrumbs));
if (!breadcrumbs.isEmpty()) {
TextComponent back = new TextComponent("§e../");
String str = breadcrumbs.substring(0, Math.max(0, breadcrumbs.substring(0, breadcrumbs.length() - 1).lastIndexOf("/")));
back.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eZurück gehen" + str).create()));
back.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + str));
player.spigot().sendMessage(back);
}
for (int i = chunk * CHUNK_SIZE; i < nodes.size() && i < (chunk + 1) * CHUNK_SIZE; i++) {
SchematicNode node = nodes.get(i);
StringBuilder nodeString = new StringBuilder();
if (node.isDir()) {
nodeString.append("§9DIR §e");
} else {
SchematicType type = node.getSchemtype();
if (type != SchematicType.Normal) {
nodeString.append("§8§l")
.append(type.getKuerzel().toUpperCase())
.append(" ");
}
nodeString.append("§e");
}
nodeString.append(node.getName());
if (node.isDir()) {
nodeString.append("/");
}
if (node.getOwner() != user.getId()) {
nodeString.append(" §8von §7")
.append(SteamwarUser.get(node.getOwner()).getUserName());
}
TextComponent schematics = new TextComponent(nodeString.toString());
if (node.isDir()) {
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eOrdner anzeigen").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + node.getName() + "/"));
} else {
schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eSchematic verwalten").create()));
schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + (isPublic ? "public" : "") + " " + breadcrumbs + node.getName()));
}
player.spigot().sendMessage(schematics);
}
TextComponent beforePage = new TextComponent("««");
if (chunk > 0) {
beforePage.setColor(ChatColor.YELLOW);
beforePage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eVorherige Seite").create()));
beforePage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk - 1)));
} else {
beforePage.setColor(ChatColor.RED);
}
TextComponent nextPage = new TextComponent(" Seite (" + (chunk + 1) + "/" + Math.max(pageCount, 1) + ") »»");
if (chunk < pageCount - 1) {
nextPage.setColor(ChatColor.YELLOW);
nextPage.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§eNächste Seite").create()));
nextPage.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem list " + (isPublic ? "public" : "") + " " + breadcrumbs + " " + (chunk + 1)));
} else {
nextPage.setColor(ChatColor.RED);
}
beforePage.addExtra(nextPage);
player.spigot().sendMessage(beforePage);
}
public static void printSchemInfo(Player player, SchematicNode node) {
SteamwarUser user = getUser(player);
player.sendMessage("§7--==( §e" + node.getName() + " §7)==--");
player.sendMessage("§7Name: §e" + node.generateBreadcrumbs(user));
player.sendMessage("§7Besitzer: §e" + SteamwarUser.get(node.getOwner()).getUserName());
player.sendMessage("§7Ordner: §e" + (node.getParent() == null || node.getParent() == 0 ? "/" : node.getParentNode().generateBreadcrumbs(user)));
player.sendMessage("§7Letzes Update: §e" + node.getLastUpdate().toLocalDateTime().format(DateTimeFormatter.ofPattern("HH:mm dd.MM.yyyy", Locale.GERMAN)));
player.sendMessage("§7Typ: §e" + (node.isDir() ? "§9DIR" : node.getSchemtype().name()));
if (!node.isDir()) {
if (node.getRank() > 0) {
player.sendMessage("§7Rang: §e" + node.getRank());
}
player.sendMessage("§7Format: §e" + (node.getSchemFormat() ? ".schem" : ".schematic"));
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
for (CheckedSchematic checkedSchematic : checkedSchematics) {
if (checkedSchematic.getSchemName().equals(node.getName()) &&
checkedSchematic.getSchemOwner() == node.getOwner()) {
player.sendMessage("§cStatus: §c" + checkedSchematic.getStartTime() + " : " + checkedSchematic.getDeclineReason());
break;
}
}
}
List<String> schematicMembers = new ArrayList<>();
NodeMember.getNodeMembers(node.getId()).forEach(nodeMember -> schematicMembers.add(SteamwarUser.get(nodeMember.getMember()).getUserName()));
if (!schematicMembers.isEmpty()) {
player.sendMessage("§7Mitglieder: §e" + schematicMembers);
}
TextComponent base = new TextComponent();
if (!node.isDir()) {
TextComponent load = new TextComponent("[Laden] ");
load.setColor(ChatColor.GREEN);
load.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic laden")));
load.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + (node.getOwner() == 0 ? "public " : "") + node.generateBreadcrumbs(user)));
base.addExtra(load);
if (node.getOwner() == user.getId()) {
TextComponent download = new TextComponent("[Download] ");
download.setColor(ChatColor.GOLD);
download.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic downloaden")));
download.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem download " + node.generateBreadcrumbs(user)));
base.addExtra(download);
TextComponent changeTyp = new TextComponent("[Typ ändern] ");
changeTyp.setColor(ChatColor.BLUE);
changeTyp.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eSchematic Typ ändern")));
changeTyp.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + node.generateBreadcrumbs(user)));
base.addExtra(changeTyp);
}
}
if (node.getOwner() == user.getId()) {
TextComponent addMember = new TextComponent("[Hinzufügen] ");
addMember.setColor(ChatColor.AQUA);
addMember.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eMember hinzufügen")));
addMember.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem addmember " + node.generateBreadcrumbs(user) + " "));
base.addExtra(addMember);
TextComponent delMember = new TextComponent("[Entfernen] ");
delMember.setColor(ChatColor.RED);
delMember.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§eMember entfernen")));
delMember.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem delmember " + node.generateBreadcrumbs(user) + " "));
base.addExtra(delMember);
TextComponent move = new TextComponent("[Verschieben] ");
move.setColor(ChatColor.DARK_PURPLE);
move.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " verschieben")));
move.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem move " + node.generateBreadcrumbs(user) + " " + node.generateBreadcrumbs(user).replace("/" + node.getName(), "")));
base.addExtra(move);
TextComponent rename = new TextComponent("[Umbenennen] ");
rename.setColor(ChatColor.LIGHT_PURPLE);
rename.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " umbenennen")));
rename.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/schem rename " + node.generateBreadcrumbs(user) + " [Neuer Name]"));
base.addExtra(rename);
TextComponent delete = new TextComponent("[Löschen] ");
delete.setColor(ChatColor.DARK_RED);
delete.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§e" + (node.isDir() ? "Ordner" : "Schematic") + " Löschen")));
delete.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + node.generateBreadcrumbs(user)));
base.addExtra(delete);
}
if (!base.getExtra().isEmpty()) {
player.spigot().sendMessage(base);
}
}
public static SchematicNode mkdirs(String[] layers, SteamwarUser user, int minus) {
SchematicNode currentNode = null;
for (int i = 0; i < layers.length - minus; i++) {
int finalI = i;
List<SchematicNode> nodes;
if (currentNode == null) {
nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
} else {
nodes = SchematicNode.getSchematicNodeInNode(currentNode).stream().filter(node -> node.getName().equals(layers[finalI])).collect(Collectors.toList());
}
if (nodes.isEmpty()) {
currentNode = SchematicNode.createSchematicDirectory(user.getId(), layers[i], currentNode == null ? 0 : currentNode.getId());
} else {
if (!nodes.get(0).isDir()) {
nodes.set(0, SchematicNode.createSchematicDirectory(user.getId(), layers[i] + "-dir-" + System.currentTimeMillis() % 100, currentNode == null ? 0 : currentNode.getId()));
}
currentNode = nodes.get(0);
}
}
return currentNode;
}
public static SteamwarUser getUser(Player player) {
if (PUBLIC_TOGGLED.contains(player)) {
return SteamwarUser.get(0);
} else {
return SteamwarUser.get(player.getUniqueId());
}
}
public static boolean togglePublic(Player player) {
if (PUBLIC_TOGGLED.contains(player)) {
PUBLIC_TOGGLED.remove(player);
return false;
} else {
PUBLIC_TOGGLED.add(player);
return true;
}
}
public static void turnOffPublic(Player player) {
PUBLIC_TOGGLED.remove(player);
}
}