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
3 geänderte Dateien mit 83 neuen und 55 gelöschten Zeilen
Nur Änderungen aus Commit 4f8e527201 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -33,6 +33,7 @@ import org.bukkit.event.inventory.ClickType;
import java.util.*; import java.util.*;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.getUser; import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.getUser;
import static de.steamwar.schematicsystem.commands.SchematicCommandUtils.invalidSchemName;
public class GUI { public class GUI {
@ -46,7 +47,7 @@ public class GUI {
for(SchematicNode schem : schems) { for(SchematicNode schem : schems) {
Material m; Material m;
if (schem.getItem().isEmpty()) if (schem.getItem().isEmpty())
m = SWItem.getMaterial("CAULDRON_ITEM"); m = schem.isDir()?SWItem.getMaterial("CHEST"):SWItem.getMaterial("CAULDRON_ITEM");
else else
m = SWItem.getMaterial(schem.getItem()); m = SWItem.getMaterial(schem.getItem());
@ -59,28 +60,38 @@ public class GUI {
schemList.add(new SWListInv.SWListEntry<>(item, schem)); schemList.add(new SWListInv.SWListEntry<>(item, schem));
} }
SWListInv<SchematicNode> inv = new SWListInv<>(player, "§eSchematicliste §8- §r" + path, false, schemList, (clickType, schem) -> info(player, schem)); SWListInv<SchematicNode> inv = new SWListInv<>(player, "§eSchematicliste §8- §r" + path, false, schemList, (clickType, schem) -> {
if(publics) if(schem.isDir()) {
SteamwarUser user = SteamwarUser.get(player.getUniqueId());
list(player, SchematicNode.getSchematicNodeInNode(schem), schem.getOwner() == 0, schem.generateBreadcrumbs(user));
} else {
info(player, schem);
}
});
if(publics) {
inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> open(player)); inv.setItem(48, Material.BUCKET, "§7Eigene Schematics", clickType -> open(player));
else } else {
inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(player, SchematicNode.getSchematicsAccessibleByUser(0, null), true, "/")); inv.setItem(48, Material.GLASS, "§7Public Schematics", clickType -> list(player, SchematicNode.getSchematicsAccessibleByUser(0, null), true, "/"));
}
if(!publics && !path.equals("/")) {
inv.setItem(49, Material.ANVIL, "§7Ordner-Info", clickType -> info(player, SchematicSystem.SCHEMATIC_COMMAND.nodeTypeMapper().map(player, new String[0], path)));
}
inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(player, publics)); inv.setItem(50, Material.NAME_TAG, "§7Suche", clickType -> search(player, publics));
inv.open(); inv.open();
} }
private static void info(Player player, SchematicNode node) { private static void info(Player player, SchematicNode node) {
SteamwarUser user = getUser(player); SteamwarUser user = getUser(player);
if(node.isDir()) {
list(player, SchematicNode.getSchematicNodeInNode(node), node.getOwner() == 0, node.generateBreadcrumbs(user));
} else {
SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user)); SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user));
if(!node.isDir()) {
inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> { inv.setItem(0, SWItem.getMaterial("WOOD_AXE"), "§eLaden", click -> {
player.closeInventory(); player.closeInventory();
SchematicSystem.SCHEMATIC_COMMAND.loadSchem(player, node); SchematicSystem.SCHEMATIC_COMMAND.loadSchem(player, node);
}); });
}
if(node.getOwner() == user.getId()){ if(node.getOwner() == user.getId()){
if(node.getSchemtype().writeable()){ if(!node.isDir() && node.getSchemtype().writeable()){
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId());
ListIterator<CheckedSchematic> i = checkedSchematics.listIterator(checkedSchematics.size()); ListIterator<CheckedSchematic> i = checkedSchematics.listIterator(checkedSchematics.size());
while(i.hasPrevious()) { while(i.hasPrevious()) {
@ -91,7 +102,7 @@ public class GUI {
} }
} }
} }
Material mat = SWItem.getMaterial("CAULDRON_ITEM"); Material mat = node.isDir()?SWItem.getMaterial("CHEST"):SWItem.getMaterial("CAULDRON_ITEM");
if(node.getItem() != null && !node.getItem().equals("")) if(node.getItem() != null && !node.getItem().equals(""))
mat = SWItem.getMaterial(node.getItem()); mat = SWItem.getMaterial(node.getItem());
@ -99,6 +110,7 @@ public class GUI {
player.closeInventory(); player.closeInventory();
changeItem(player, node); changeItem(player, node);
}); });
if(!node.isDir()) {
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> { inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
player.closeInventory(); player.closeInventory();
changeType(player, node); changeType(player, node);
@ -107,6 +119,7 @@ public class GUI {
player.closeInventory(); player.closeInventory();
SchematicSystem.SCHEMATIC_COMMAND.download(player, node); SchematicSystem.SCHEMATIC_COMMAND.download(player, node);
}); });
}
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE"); SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
skull.setCallback(click -> { skull.setCallback(click -> {
player.closeInventory(); player.closeInventory();
@ -114,12 +127,26 @@ public class GUI {
}); });
skull.setName("§eMitglieder"); skull.setName("§eMitglieder");
inv.setItem(6, skull); inv.setItem(6, skull);
Material finalMat = mat;
inv.setItem(7, Material.NAME_TAG, "§eUmbenennen", clickType -> {
SWAnvilInv anvilInv = new SWAnvilInv(player, node.getName() + " umbenennen");
anvilInv.setItem(finalMat);
anvilInv.setCallback(s -> {
if (!invalidSchemName(player, new String[]{s})) {
node.setName(s);
}
info(player, node);
});
anvilInv.open();
});
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> { inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cLöschen", click -> {
player.closeInventory(); player.closeInventory();
delete(player, node); delete(player, node);
}); });
}else{ }else{
if(!node.isDir()) {
inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), click -> {}); inv.setItem(4, SWItem.getMaterial("CAULDRON_ITEM"), "§e" + node.getSchemtype().name(), click -> {});
}
SteamwarUser owneruser = SteamwarUser.get(node.getOwner()); SteamwarUser owneruser = SteamwarUser.get(node.getOwner());
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName()); SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
@ -135,7 +162,6 @@ public class GUI {
inv.setCallback(-999, click -> player.closeInventory()); inv.setCallback(-999, click -> player.closeInventory());
inv.open(); inv.open();
} }
}
static void changeType(Player p, SchematicNode schem){ static void changeType(Player p, SchematicNode schem){
List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>(); List<SWListInv.SWListEntry<SchematicType>> types = new LinkedList<>();
@ -164,10 +190,6 @@ public class GUI {
inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> { inv.setItem(0, SWItem.getDye(1), (byte) 1, "§eLöschen", click -> {
schem.delete(); schem.delete();
List<CheckedSchematic> checkedSchematics = CheckedSchematic.getLastDeclined(schem);
for(CheckedSchematic checkedSchematic : checkedSchematics) {
checkedSchematic.remove();
}
p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht"); p.sendMessage(SchematicSystem.PREFIX + "Schematic §e" + schem.generateBreadcrumbs(user) + " §7gelöscht");
p.closeInventory(); p.closeInventory();
}); });

Datei anzeigen

@ -174,7 +174,7 @@ public class SchematicCommand extends SWCommand {
if (invalidSchemName(player, layers)) return; if (invalidSchemName(player, layers)) return;
SchematicNode currentNode = mkdirs(layers, user, 1); SchematicNode currentNode = mkdirs(layers, user, 1);
SchematicNode node = SchematicNode.getSchematicInParent(layers[layers.length - 1], currentNode == null ? 0 : currentNode.getId()); SchematicNode node = SchematicNode.getSchematicNode(layers[layers.length - 1], currentNode == null ? 0 : currentNode.getId());
if (node != null && !node.getSchemtype().writeable()) { if (node != null && !node.getSchemtype().writeable()) {
player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diese Schematic nicht überschreiben"); player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diese Schematic nicht überschreiben");
return; return;
@ -285,7 +285,7 @@ public class SchematicCommand extends SWCommand {
} }
player.sendMessage(SchematicSystem.PREFIX + "Dein Download Link:"); player.sendMessage(SchematicSystem.PREFIX + "Dein Download Link:");
player.sendMessage(DownloadSchematic.getLink(node)); player.sendMessage(NodeDownload.getLink(node));
} }
@Register("dir") @Register("dir")
@ -397,6 +397,12 @@ public class SchematicCommand extends SWCommand {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen"); player.sendMessage(SchematicSystem.PREFIX + "§cDas kannst du nur bei deinen eigenen Schems machen");
return; return;
} }
if(SchematicNode.getAllParentsOfNode(node).contains(node)) {
player.sendMessage(SchematicSystem.PREFIX + "§cDas kann nur Fehler machen, vertrau mir!");
return;
}
if (name.equals("/")) { if (name.equals("/")) {
node.setParent(0); node.setParent(0);
} else { } else {

Datei anzeigen

@ -90,7 +90,7 @@ public class SchematicCommandUtils {
SchematicNode pa = mapNode(user, strings, preTab); SchematicNode pa = mapNode(user, strings, preTab);
if (pa == null) return Collections.emptyList(); if (pa == null) return Collections.emptyList();
List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa); List<SchematicNode> nodes = SchematicNode.getSchematicNodeInNode(pa);
nodes.forEach(node -> list.add(node.generateBreadcrumbs(user))); nodes.forEach(node -> list.add((sws ? "/" : "") + node.generateBreadcrumbs(user)));
} else { } else {
List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0); List<SchematicNode> nodes = SchematicNode.getSchematicsAccessibleByUser(user.getId(), 0);
nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : ""))); nodes.forEach(node -> list.add((sws ? "/" : "") + node.getName() + (node.isDir() ? "/" : "")));