Soem New Things
Signed-off-by: Chaoscaot <chaoscaot444@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
1ff74f7ab8
Commit
4f8e527201
@ -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,46 +60,57 @@ 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()) {
|
SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user));
|
||||||
list(player, SchematicNode.getSchematicNodeInNode(node), node.getOwner() == 0, node.generateBreadcrumbs(user));
|
if(!node.isDir()) {
|
||||||
} else {
|
|
||||||
SWInventory inv = new SWInventory(player, 9, node.generateBreadcrumbs(user));
|
|
||||||
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()) {
|
||||||
CheckedSchematic checkedSchematic = i.previous();
|
CheckedSchematic checkedSchematic = i.previous();
|
||||||
if(checkedSchematic.getNode() == node.getId()) {
|
if(checkedSchematic.getNode() == node.getId()) {
|
||||||
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + node.getSchemtype().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
|
inv.setItem(1, SWItem.getDye(10), (byte) 10, "§eStatus " + node.getSchemtype().name(), Collections.singletonList("§7" + checkedSchematic.getDeclineReason()), false, click -> {});
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Material mat = SWItem.getMaterial("CAULDRON_ITEM");
|
}
|
||||||
if(node.getItem() != null && !node.getItem().equals(""))
|
Material mat = node.isDir()?SWItem.getMaterial("CHEST"):SWItem.getMaterial("CAULDRON_ITEM");
|
||||||
mat = SWItem.getMaterial(node.getItem());
|
if(node.getItem() != null && !node.getItem().equals(""))
|
||||||
|
mat = SWItem.getMaterial(node.getItem());
|
||||||
|
|
||||||
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
inv.setItem(2, mat, "§e" + mat.name(), Arrays.asList("§7Zum Ändern", "§7anklicken"), false, click -> {
|
||||||
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,34 +119,48 @@ 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");
|
}
|
||||||
skull.setCallback(click -> {
|
SWItem skull = SWItem.getPlayerSkull("MHF_STEVE");
|
||||||
player.closeInventory();
|
skull.setCallback(click -> {
|
||||||
delmembers(player, node);
|
player.closeInventory();
|
||||||
|
delmembers(player, node);
|
||||||
|
});
|
||||||
|
skull.setName("§eMitglieder");
|
||||||
|
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);
|
||||||
});
|
});
|
||||||
skull.setName("§eMitglieder");
|
anvilInv.open();
|
||||||
inv.setItem(6, skull);
|
});
|
||||||
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());
|
|
||||||
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
|
|
||||||
skull.setName("§7von §e" + owneruser.getUserName());
|
|
||||||
inv.setItem(6, skull);
|
|
||||||
|
|
||||||
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
|
|
||||||
player.closeInventory();
|
|
||||||
delete(player, node);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
inv.setCallback(-999, click -> player.closeInventory());
|
SteamwarUser owneruser = SteamwarUser.get(node.getOwner());
|
||||||
inv.open();
|
SWItem skull = SWItem.getPlayerSkull(owneruser.getUserName());
|
||||||
|
skull.setName("§7von §e" + owneruser.getUserName());
|
||||||
|
inv.setItem(6, skull);
|
||||||
|
|
||||||
|
inv.setItem(8, SWItem.getDye(1), (byte) 1, "§cZugriff entfernen", click -> {
|
||||||
|
player.closeInventory();
|
||||||
|
delete(player, node);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inv.setCallback(-999, click -> player.closeInventory());
|
||||||
|
inv.open();
|
||||||
}
|
}
|
||||||
|
|
||||||
static void changeType(Player p, SchematicNode schem){
|
static void changeType(Player p, SchematicNode schem){
|
||||||
@ -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();
|
||||||
});
|
});
|
||||||
|
@ -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 {
|
||||||
|
@ -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() ? "/" : "")));
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren