Add Schem Delete
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
b59ff373b1
Commit
1ff74f7ab8
@ -69,13 +69,13 @@ public class SchematicCommand extends SWCommand {
|
||||
@Register("list")
|
||||
@Register({"list", "/"})
|
||||
public void schemList(Player player) {
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), 0, "", false);
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), 0, "", false, null);
|
||||
}
|
||||
|
||||
@Register("list")
|
||||
@Register({"list", "/"})
|
||||
public void schemList(Player player, int page) {
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), page, "", false);
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(getUser(player).getId(), 0), page, "", false, null);
|
||||
}
|
||||
|
||||
@Register({"list", "public"})
|
||||
@ -91,13 +91,13 @@ public class SchematicCommand extends SWCommand {
|
||||
@Register({"list", "public"})
|
||||
@Register({"list", "public", "/"})
|
||||
public void schemListPublic(Player player) {
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), 0, "", true);
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), 0, "", true, null);
|
||||
}
|
||||
|
||||
@Register({"list", "public"})
|
||||
@Register({"list", "public", "/"})
|
||||
public void schemListPublic(Player player, int page) {
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), page, "", true);
|
||||
renderSchemlist(player, SchematicNode.getSchematicsAccessibleByUser(0, 0), page, "", true, null);
|
||||
}
|
||||
|
||||
|
||||
@ -112,7 +112,7 @@ public class SchematicCommand extends SWCommand {
|
||||
if (!node.isDir()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
|
||||
} else {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), 0, node.generateBreadcrumbs(user), node.getOwner() == 0);
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), 0, node.generateBreadcrumbs(user), node.getOwner() == 0, node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +130,7 @@ public class SchematicCommand extends SWCommand {
|
||||
if (!node.isDir()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "Das ist eine Schematic und kein Ordner");
|
||||
} else {
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), page, node.generateBreadcrumbs(user), node.getOwner() == 0);
|
||||
renderSchemlist(player, SchematicNode.getSchematicNodeInNode(node), page, node.generateBreadcrumbs(user), node.getOwner() == 0, node);
|
||||
}
|
||||
}
|
||||
|
||||
@ -221,6 +221,11 @@ public class SchematicCommand extends SWCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (target.getId() == 0) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cFür Public-Anträge bitte bei der Moderation melden");
|
||||
return;
|
||||
}
|
||||
|
||||
if (NodeMember.getNodeMember(node.getId(), target.getId()) != null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler ist bereits auf diese Schematic geaddet");
|
||||
return;
|
||||
@ -508,6 +513,33 @@ public class SchematicCommand extends SWCommand {
|
||||
}
|
||||
}
|
||||
|
||||
@Register("delete")
|
||||
public void deleteSchem(Player player, SchematicNode node) {
|
||||
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
|
||||
if (node.getOwner() != user.getId()) {
|
||||
NodeMember member = NodeMember.getNodeMember(node.getId(), user.getId());
|
||||
if (member == null) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDie Schematic gehört dir nicht");
|
||||
return;
|
||||
}
|
||||
member.delete();
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aDu hast dich von der Schematic entfernt");
|
||||
return;
|
||||
}
|
||||
|
||||
if (node.isDir()) {
|
||||
if (SchematicNode.getSchematicNodeInNode(node).isEmpty()) {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aDer Ordner §e" + node.generateBreadcrumbs(user) + "§a wird gelöcht...");
|
||||
node.delete();
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§cDer Ordner muss leer sein, um ihn zu löchen!");
|
||||
}
|
||||
} else {
|
||||
player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + node.generateBreadcrumbs(user) + "§a wird gelöcht...");
|
||||
node.delete();
|
||||
}
|
||||
}
|
||||
|
||||
private final TypeMapper<SchematicNode> schematicCommandTypeMapper = nodeTypeMapper();
|
||||
private final TypeMapper<SchematicNode> publicCommandTypeMapper = publicNodeTypeMapper();
|
||||
|
||||
|
@ -120,7 +120,7 @@ public class SchematicCommandUtils {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static void renderSchemlist(Player player, List<SchematicNode> nodes, int chunk, String breadcrumbs, boolean isPublic) {
|
||||
public static void renderSchemlist(Player player, List<SchematicNode> nodes, int chunk, String breadcrumbs, boolean isPublic, SchematicNode parent) {
|
||||
nodes.sort(Comparator.comparing(SchematicNode::getName));
|
||||
SteamwarUser user = getUser(player);
|
||||
int pageCount = (int) Math.ceil(nodes.size() / (double) CHUNK_SIZE);
|
||||
@ -175,6 +175,14 @@ public class SchematicCommandUtils {
|
||||
player.spigot().sendMessage(schematics);
|
||||
}
|
||||
|
||||
if (parent != null && parent.getOwner() != user.getId() && NodeMember.getNodeMember(parent.getId(), user.getId()) != null) {
|
||||
TextComponent deadd = new TextComponent("[Entfernen]");
|
||||
deadd.setColor(ChatColor.RED);
|
||||
deadd.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText("§7Entferne dich von dem Ordner")));
|
||||
deadd.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + parent.generateBreadcrumbs(user)));
|
||||
player.spigot().sendMessage(deadd);
|
||||
}
|
||||
|
||||
TextComponent beforePage = new TextComponent("««");
|
||||
if (chunk > 0) {
|
||||
beforePage.setColor(ChatColor.YELLOW);
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren