diff --git a/src/de/warking/schematicsystem/commands/SchematicCommand.java b/src/de/warking/schematicsystem/commands/SchematicCommand.java index e36cb30..2a74ea2 100644 --- a/src/de/warking/schematicsystem/commands/SchematicCommand.java +++ b/src/de/warking/schematicsystem/commands/SchematicCommand.java @@ -80,6 +80,10 @@ public class SchematicCommand implements CommandExecutor { if(args[0].equalsIgnoreCase("load")) { if(CheckUtils.isSchematicNameAllowed(args[1])) { Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); + + if(schematic == null) + schematic = Schematic.getSchemFromDB(args[1], 0); //public schematic + if (schematic != null) { try { @@ -236,71 +240,6 @@ public class SchematicCommand implements CommandExecutor { } } - if(args[0].equalsIgnoreCase("info")) { - if(CheckUtils.isSchematicNameAllowed(args[1])) { - Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); - if(schematic != null) { - - player.sendMessage("§6Name: §7" + schematic.getSchemName()); - - if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) { - TextComponent typ = new TextComponent("§6Typ: §7" + schematic.getSchemType().name()); - typ.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Typ ändern").create())); - typ.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getschemchangetype " + schematic.getSchemName())); - player.spigot().sendMessage(typ); - } else - player.sendMessage("§6Typ: §7" + schematic.getSchemType().name()); - - if(schematic.getSchemType() == SchematicType.normal) { - List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); - for(int i = checkedSchematics.size() -1; i > 0; i--) { - if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) && - checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) { - player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason()); - TextComponent mehr = new TextComponent("§9mehr..."); - mehr.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getmoreinfo " + schematic.getSchemName())); - player.spigot().sendMessage(mehr); - break; - } - } - } - - if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { - player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName()); - } else { - - List schematicMembers = new ArrayList<>(); - for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) { - schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName()); - } - if(schematicMembers.size() <= 3) { - player.sendMessage("§6Member: §7" + schematicMembers.toString()); - } else - player.sendMessage("§6Member: §7..."); - } - - TextComponent loadSchematic = new TextComponent("LADEN"); - loadSchematic.setColor(ChatColor.DARK_GREEN); - loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName())); - player.spigot().sendMessage(loadSchematic); - - if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { - TextComponent deleteSchematic = new TextComponent("LÖSCHEN"); - deleteSchematic.setColor(ChatColor.RED); - deleteSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + schematic.getSchemName())); - player.spigot().sendMessage(deleteSchematic); - } - return false; - } else { - player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); - return false; - } - } else { - player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!"); - return false; - } - } - if(args[0].equalsIgnoreCase("getschemchangetype")) { if(CheckUtils.isSchematicNameAllowed(args[1])) { Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); @@ -361,6 +300,76 @@ public class SchematicCommand implements CommandExecutor { return false; case 3: + if(args[0].equalsIgnoreCase("info")) { + if(CheckUtils.isSchematicNameAllowed(args[1])) { + WarkingUser warkingUser = WarkingUser.get(Integer.valueOf(args[2])); + if(warkingUser.getUUID() == null) { + player.sendMessage(SchematicSystem.PREFIX + "§cDieser Benutzer hat keine Schematic mit diesem Namen!"); + return false; + } + Schematic schematic = Schematic.getSchemFromDB(args[1], warkingUser.getId()); + if(schematic != null) { + + player.sendMessage("§6Name: §7" + schematic.getSchemName()); + + if(schematic.getSchemOwner() == WarkingUser.get(player.getUniqueId()).getId()) { + TextComponent typ = new TextComponent("§6Typ: §7" + schematic.getSchemType().name()); + typ.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("§7Typ ändern").create())); + typ.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getschemchangetype " + schematic.getSchemName())); + player.spigot().sendMessage(typ); + } else + player.sendMessage("§6Typ: §7" + schematic.getSchemType().name()); + + if(schematic.getSchemType() == SchematicType.normal) { + List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); + for(int i = checkedSchematics.size() -1; i > 0; i--) { + if(checkedSchematics.get(i).getSchemName().equals(schematic.getSchemName()) && + checkedSchematics.get(i).getSchemOwner() == schematic.getSchemOwner()) { + player.sendMessage("§cStatus: §c" + checkedSchematics.get(i).getStartTime() + " : " + checkedSchematics.get(i).getDeclineReason()); + TextComponent mehr = new TextComponent("§9mehr..."); + mehr.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem getmoreinfo " + schematic.getSchemName())); + player.spigot().sendMessage(mehr); + break; + } + } + } + + if(!WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { + player.sendMessage("§6Owner: §7" + WarkingUser.get(schematic.getSchemOwner()).getUserName()); + } else { + + List schematicMembers = new ArrayList<>(); + for(SchematicMember schematicMember : SchematicMember.getSchemMembers(schematic.getSchemName(), schematic.getSchemOwner())) { + schematicMembers.add(WarkingUser.get(schematicMember.getMember()).getUserName()); + } + if(schematicMembers.size() <= 3) { + player.sendMessage("§6Member: §7" + schematicMembers.toString()); + } else + player.sendMessage("§6Member: §7..."); + } + + TextComponent loadSchematic = new TextComponent("LADEN"); + loadSchematic.setColor(ChatColor.DARK_GREEN); + loadSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem load " + schematic.getSchemName())); + player.spigot().sendMessage(loadSchematic); + + if(WarkingUser.get(schematic.getSchemOwner()).getUUID().equals(player.getUniqueId())) { + TextComponent deleteSchematic = new TextComponent("LÖSCHEN"); + deleteSchematic.setColor(ChatColor.RED); + deleteSchematic.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem delete " + schematic.getSchemName())); + player.spigot().sendMessage(deleteSchematic); + } + return false; + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); + return false; + } + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!"); + return false; + } + } + if(args[0].equalsIgnoreCase("list")) { if(args[1].equalsIgnoreCase("public")) { try { @@ -374,35 +383,6 @@ public class SchematicCommand implements CommandExecutor { return false; } - if(args[0].equalsIgnoreCase("load")) { - if(!player.hasPermission("bau.team")) return false; - WarkingUser warkingUser = WarkingUser.get(args[2]); - if(warkingUser != null) { - if(CheckUtils.isSchematicNameAllowed(args[1])) { - Schematic schematic = Schematic.getSchemFromDB(args[1], warkingUser.getUUID()); - if(schematic != null) { - try { - Actor actor = SchematicSystem.getWorldEditPlugin().wrapCommandSender(player); - SchematicSystem.getWorldEditPlugin().getWorldEdit().getSessionManager().get(actor).setClipboard((ClipboardHolder) FaweAPI.load(new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/", args[1] + ".schematic")).getClipboard()); - player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7von §6" + warkingUser.getUserName() + "§7geladen."); - } catch (IOException ex) { - ex.printStackTrace(); - } - } else { - player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); - return false; - } - } else { - player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen!"); - return false; - } - } else { - player.sendMessage(SchematicSystem.PREFIX + "§cDieser Spieler existiert nicht!"); - return false; - } - return false; - } - if(args[0].equalsIgnoreCase("changetype")) { Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); if(schematic != null) { @@ -604,11 +584,11 @@ public class SchematicCommand implements CommandExecutor { player.sendMessage("§8/schem - §6Zeigt Informationen zum Plugin"); player.sendMessage("§8/schem help - §6Zeigt eine Liste mit Befehlen"); player.sendMessage("§8/schem list (public) - §6Listet deine (oder Public) Schematics auf"); - player.sendMessage("§8/schem load [Besitzer] - §6Du lädst eine Schematic"); + player.sendMessage("§8/schem load - §6Du lädst eine Schematic"); player.sendMessage("§8/schem save - §6Du speicherst dein Clipboard als Datei"); player.sendMessage("§8/schem changetype - §6Ändert den Typ deiner Schematic"); - player.sendMessage("§8/schem info - §6Zeigt dir Informationen zu der Schematic"); player.sendMessage("§8/schem delete - §6Löscht eine Schematic"); + player.sendMessage("§8/schem info - §6Zeigt dir Informationen zu der Schematic"); player.sendMessage("§8/schem addmember - §6Fügt einen Spieler zu einer Schematic hinzu"); player.sendMessage("§8/schem delmember - §6Entfernt einen Spieler von einer Schematic"); @@ -675,7 +655,7 @@ public class SchematicCommand implements CommandExecutor { schematics.setBold(true); schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic verwalten...").create())); - schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName())); + schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem info " + schematic.getSchemName() + " " + schematic.getSchemOwner())); player.spigot().sendMessage(schematics); }