diff --git a/src/de/warking/schematicsystem/SchematicSystem.java b/src/de/warking/schematicsystem/SchematicSystem.java index 715d960..ae8ebf2 100644 --- a/src/de/warking/schematicsystem/SchematicSystem.java +++ b/src/de/warking/schematicsystem/SchematicSystem.java @@ -15,7 +15,7 @@ import org.bukkit.plugin.java.JavaPlugin; public class SchematicSystem extends JavaPlugin { - public static final String SCHEM_DIR = "/home/netuser/schematics/"; + public static final String SCHEM_DIR = "/home/minecraft/schematics/"; public static final String PREFIX = "§6Schematic§8» §7"; private static SchematicSystem instance; diff --git a/src/de/warking/schematicsystem/check/CheckSession.java b/src/de/warking/schematicsystem/check/CheckSession.java index aa1023f..e4005e2 100644 --- a/src/de/warking/schematicsystem/check/CheckSession.java +++ b/src/de/warking/schematicsystem/check/CheckSession.java @@ -3,6 +3,8 @@ package de.warking.schematicsystem.check; import com.sk89q.worldedit.EditSession; import de.warking.hunjy.MySQL.Schematic; import de.warking.hunjy.MySQL.SchematicType; +import de.warking.hunjy.MySQL.WarkingUser; +import de.warking.schematicsystem.utils.CheckedSchematic; import de.warking.schematicsystem.utils.Config; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; @@ -10,6 +12,7 @@ import net.md_5.bungee.api.chat.TextComponent; import org.bukkit.Bukkit; import org.bukkit.entity.Player; +import java.sql.Timestamp; import java.util.*; public class CheckSession { @@ -19,10 +22,9 @@ public class CheckSession { private UUID uuid; //player private Schematic schematic; private int position; //position in checklist - private HashMap checkTimes = new HashMap<>(); //position, time - private long startTime; - private long stopTime; + private Timestamp startTime; + private Timestamp stopTime; EditSession editSession; @@ -53,18 +55,6 @@ public class CheckSession { return null; } - public int calculatePositionTime() { - return Math.round((stopTime - startTime) / 1000); - } - - public int calculateTotalTime() { - int totalTime = 0; - for(Map.Entry entry : this.checkTimes.entrySet()) { - totalTime += entry.getValue(); - } - return totalTime; - } - public void sendNextCheck() { setStopTime(); this.position++; @@ -130,17 +120,15 @@ public class CheckSession { if(schematic.getSchemType() == SchematicType.Cairship) { schematic.setSchemType(SchematicType.airship); } - //TODO: save position times and total time to file - //calculateTotalTime(); + CheckedSchematic checkedSchematic = new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben"); removeSchematic(); remove(); } - public void declineSchematic() { + public void declineSchematic(String declineReason) { this.schematic.setSchemType(SchematicType.normal); - //TODO: save position times and total time to file - //calculateTotalTime(); + CheckedSchematic checkedSchematic = new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), WarkingUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason); removeSchematic(); remove(); } @@ -177,25 +165,24 @@ public class CheckSession { this.position = position; } - public HashMap getCheckTimes() { - return checkTimes; - } - - public long getStartTime() { + public Timestamp getStartTime() { return startTime; } public void setStartTime() { - this.startTime = System.currentTimeMillis(); + Date date = new Date(); + Timestamp timestamp = new Timestamp(date.getTime()); + this.startTime = timestamp; } - public long getStopTime() { + public Timestamp getStopTime() { return stopTime; } public void setStopTime() { - this.stopTime = System.currentTimeMillis(); - checkTimes.put(this.position, calculatePositionTime()); + Date date = new Date(); + Timestamp timestamp = new Timestamp(date.getTime()); + this.stopTime = timestamp; } public EditSession getEditSession() { diff --git a/src/de/warking/schematicsystem/check/CheckUtils.java b/src/de/warking/schematicsystem/check/CheckUtils.java index 133dd93..690998d 100644 --- a/src/de/warking/schematicsystem/check/CheckUtils.java +++ b/src/de/warking/schematicsystem/check/CheckUtils.java @@ -1,9 +1,6 @@ package de.warking.schematicsystem.check; import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEditException; -import com.sk89q.worldedit.blocks.BaseBlock; -import com.sk89q.worldedit.entity.Entity; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.regions.Region; import de.warking.hunjy.MySQL.Schematic; @@ -39,7 +36,7 @@ public class CheckUtils { return true; } - public static boolean checkSchematic(Clipboard clipboard, List forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) { + public static Checkresult checkSchematic(Clipboard clipboard, List forbiddenBlocks, boolean obsidianToTnt, boolean slimeToBedrock, String modus) { Region region = clipboard.getRegion(); Vector min = region.getMinimumPoint(); @@ -54,71 +51,119 @@ public class CheckUtils { for (int z = min.getBlockZ(); z <= max.getBlockZ(); z++) { Vector vector = new Vector(x, y, z); - try { - if(obsidianToTnt && clipboard.getBlock(vector).getId() == 46) { - clipboard.setBlock(vector, new BaseBlock(49)); + //obsidian check + if(obsidianToTnt) { + if(clipboard.getBlock(vector).getId() == 46) { + Checkresult checkresult = new Checkresult(false, "TNT verbaut"); + return checkresult; + } + if(clipboard.getBlock(vector).getId() == 49) obsidian++; + } + //bedrock check + if(clipboard.getBlock(vector).getId() == 165) { + if(slimeToBedrock) { + Checkresult checkresult = new Checkresult(false, "SCHLEIM verbaut"); + return checkresult; } - if(slimeToBedrock && clipboard.getBlock(vector).getId() == 165) { - if(modus.equals("WarShip") || - modus.equals("AirShip")) - clipboard.setBlock(vector, new BaseBlock(7)); - bedrock++; - } - if(clipboard.getBlock(vector).getId() == 23) - dispenser++; - } catch (WorldEditException ex) { - return false; } - if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId())) - return false; + if(clipboard.getBlock(vector).getId() == 7) { + if(!modus.equals("WarGear") && !modus.equals("MiniWarGear")) + bedrock++; + else { + Checkresult checkresult = new Checkresult(false, "BEDROCK verbaut"); + return checkresult; + } + } + //dispenser check + if(clipboard.getBlock(vector).getId() == 23) + dispenser++; + + //forbidden check + if (forbiddenBlocks.contains(clipboard.getBlock(vector).getId())) { + Checkresult checkresult = new Checkresult(false, "VERBOTENE ID", clipboard.getBlock(vector).getId()); + return checkresult; + } } } } int obsidianBedrock = obsidian + bedrock; if(modus.equalsIgnoreCase("WarGear")) { - if(Config.WarGearMaxObsidian < obsidian) - return false; - if(Config.WarGearMaxBedrock < bedrock) - return false; - if(Config.WarGearMaxDispenser < dispenser) - return false; - if(Config.WarGearObsidianBedrock < obsidianBedrock) - return false; + if(Config.WarGearMaxObsidian < obsidian) { + Checkresult checkresult = new Checkresult(false, "zu viel OBSIDIAN"); + return checkresult; + } + if(Config.WarGearMaxBedrock < bedrock) { + Checkresult checkresult = new Checkresult(false, "zu viel BEDROCK"); + return checkresult; + } + if(Config.WarGearMaxDispenser < dispenser) { + Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER"); + return checkresult; + } + if(Config.WarGearObsidianBedrock < obsidianBedrock) { + Checkresult checkresult = new Checkresult(false, "OBSIDIAN und TNT Summe überschritten"); + return checkresult; + } } if(modus.equalsIgnoreCase("MiniWarGear")) { - if(Config.MiniWarGearMaxObsidian < obsidian) - return false; - if(Config.MiniWarGearMaxBedrock < bedrock) - return false; - if(Config.MiniWarGearMaxDispenser < dispenser) - return false; - if(Config.MiniWarGearObsidianBedrock < obsidianBedrock) - return false; + if(Config.MiniWarGearMaxObsidian < obsidian) { + Checkresult checkresult = new Checkresult(false, "zu viel OBSIDIAN"); + return checkresult; + } + if(Config.MiniWarGearMaxBedrock < bedrock) { + Checkresult checkresult = new Checkresult(false, "zu viel BEDROCK"); + return checkresult; + } + if(Config.MiniWarGearMaxDispenser < dispenser) { + Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER"); + return checkresult; + } + if(Config.MiniWarGearObsidianBedrock < obsidianBedrock) { + Checkresult checkresult = new Checkresult(false, "OBSIDIAN und TNT Summe überschritten"); + return checkresult; + } } if(modus.equalsIgnoreCase("WarShip")) { - if(Config.WarShipMaxObsidian < obsidian) - return false; - if(Config.WarShipMaxBedrock < bedrock) - return false; - if(Config.WarShipMaxDispenser < dispenser) - return false; - if(Config.WarShipObsidianBedrock < obsidianBedrock) - return false; + if(Config.WarShipMaxObsidian < obsidian) { + Checkresult checkresult = new Checkresult(false, "zu viel OBSIDIAN"); + return checkresult; + } + if(Config.WarShipMaxBedrock < bedrock) { + Checkresult checkresult = new Checkresult(false, "zu viel BEDROCK"); + return checkresult; + } + if(Config.WarShipMaxDispenser < dispenser) { + Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER"); + return checkresult; + } + if(Config.WarShipObsidianBedrock < obsidianBedrock) { + Checkresult checkresult = new Checkresult(false, "OBSIDIAN und TNT Summe überschritten"); + return checkresult; + } } if(modus.equalsIgnoreCase("AirShip")) { - if(Config.AirShipMaxObsidian < obsidian) - return false; - if(Config.AirShipMaxBedrock < bedrock) - return false; - if(Config.AirShipMaxDispenser < dispenser) - return false; - if(Config.AirShipObsidianBedrock < obsidianBedrock) - return false; + if(Config.AirShipMaxObsidian < obsidian) { + Checkresult checkresult = new Checkresult(false, "zu viel OBSIDIAN"); + return checkresult; + } + if(Config.AirShipMaxBedrock < bedrock) { + Checkresult checkresult = new Checkresult(false, "zu viel BEDROCK"); + return checkresult; + } + if(Config.AirShipMaxDispenser < dispenser) { + Checkresult checkresult = new Checkresult(false, "zu viele DISPENSER"); + return checkresult; + } + if(Config.AirShipObsidianBedrock < obsidianBedrock) { + Checkresult checkresult = new Checkresult(false, "OBSIDIAN und TNT Summe überschritten"); + return checkresult; + } } - return true; + Checkresult checkresult = new Checkresult(true); + return checkresult; } public static boolean allowedToCheck(Player player) { diff --git a/src/de/warking/schematicsystem/check/Checkresult.java b/src/de/warking/schematicsystem/check/Checkresult.java new file mode 100644 index 0000000..f27acae --- /dev/null +++ b/src/de/warking/schematicsystem/check/Checkresult.java @@ -0,0 +1,58 @@ +package de.warking.schematicsystem.check; + +import java.util.ArrayList; + +public class Checkresult { + + public static ArrayList checkresults = new ArrayList<>(); + + private boolean check; //schematic allowed / declined + private String reason; //general reason + private int blockID = -1; //not allowed block id / must be initialized -1 + + public Checkresult(boolean check) { + this.check = check; + checkresults.add(this); + } + + public Checkresult(boolean check, String reason) { + this.check = check; + this.reason = reason; + checkresults.add(this); + } + + public Checkresult(boolean check, String reason, int blockID) { + this.check = check; + this.reason = reason; + this.blockID = blockID; + checkresults.add(this); + } + + public void remove() { + checkresults.remove(this); + } + + public boolean isCheck() { + return check; + } + + public void setCheck(boolean check) { + this.check = check; + } + + public String getReason() { + return reason; + } + + public void setReason(String reason) { + this.reason = reason; + } + + public int getBlockID() { + return blockID; + } + + public void setBlockID(int blockID) { + this.blockID = blockID; + } +} diff --git a/src/de/warking/schematicsystem/commands/CheckCommand.java b/src/de/warking/schematicsystem/commands/CheckCommand.java index 089e22d..1bdd727 100644 --- a/src/de/warking/schematicsystem/commands/CheckCommand.java +++ b/src/de/warking/schematicsystem/commands/CheckCommand.java @@ -1,7 +1,6 @@ package de.warking.schematicsystem.commands; import com.boydti.fawe.FaweAPI; -import com.sk89q.worldedit.EditSession; import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.bukkit.BukkitWorld; import com.sk89q.worldedit.world.World; @@ -11,7 +10,6 @@ import de.warking.hunjy.MySQL.WarkingUser; import de.warking.schematicsystem.SchematicSystem; import de.warking.schematicsystem.check.CheckSession; import de.warking.schematicsystem.check.CheckUtils; -import org.bukkit.Bukkit; import org.bukkit.Location; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; @@ -116,64 +114,73 @@ public class CheckCommand implements CommandExecutor { } WarkingUser warkingUser = WarkingUser.get(owner); - if(warkingUser != null) { + if(warkingUser.getUUID() != null) { Schematic schematic = Schematic.getSchemFromDB(schemName, warkingUser.getUUID()); if(schematic != null) { - for(CheckSession checkSession : CheckSession.checkSessions) { - if(checkSession.getSchematic().getSchemName().equals(schematic.getSchemName()) - && checkSession.getSchematic().getSchemOwner() == schematic.getSchemOwner()) { - player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!"); + if(schematic.getSchemType() != SchematicType.normal && + schematic.getSchemType() != SchematicType.airship && + schematic.getSchemType() != SchematicType.warship && + schematic.getSchemType() != SchematicType.wargear && + schematic.getSchemType() != SchematicType.miniwargear) { + for(CheckSession checkSession : CheckSession.checkSessions) { + if(checkSession.getSchematic().getSchemName().equals(schematic.getSchemName()) + && checkSession.getSchematic().getSchemOwner() == schematic.getSchemOwner()) { + player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic wird bereits geprüft!"); + return false; + } + } + + HashMap schematicList = new HashMap<>(); + for(Schematic schematics : CheckUtils.getAllCSchems()) { + schematicList.put(schematics.getSchemName(), WarkingUser.get(schematics.getSchemOwner()).getUUID()); + } + + for(Map.Entry entry : schematicList.entrySet()) { + if(!(entry.getKey().equals(schematic.getSchemName()) || entry.getValue().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID()))) { + player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! CONTAINS"); + return false; + } + } + + File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + schemName + ".schematic"); + if(!file.exists()) { + player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NO SUCH FILE"); return false; } - } - HashMap schematicList = new HashMap<>(); - for(Schematic schematics : CheckUtils.getAllCSchems()) { - schematicList.put(schematics.getSchemName(), WarkingUser.get(schematics.getSchemOwner()).getUUID()); - } + try { + com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file); + Location playerLocation = player.getLocation(); - for(Map.Entry entry : schematicList.entrySet()) { - if(!(entry.getKey().equals(schematic.getSchemName()) || entry.getValue().equals(WarkingUser.get(schematic.getSchemOwner()).getUUID()))) { - player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! CONTAINS"); + World weWorld = new BukkitWorld(player.getWorld()); + Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()); + Vector offset = new Vector(schematicFAWE.getClipboard().getRegion().getMinimumPoint()).subtract(schematicFAWE.getClipboard().getOrigin()); + Vector v; + Vector dimensions = schematicFAWE.getClipboard().getDimensions(); + v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset); + + + CheckSession checkSession = new CheckSession(player.getUniqueId(), schematic, -1); + checkSession.sendNextCheck(); + + checkSession.setEditSession(schematicFAWE.paste(weWorld, v)); + } catch (IOException ex) { + player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! ERROR: PASTE / CHECK_SESSION"); + ex.printStackTrace(); return false; } - } - - File file = new File(SchematicSystem.SCHEM_DIR + warkingUser.getUUID().toString() + "/" + schemName + ".schematic"); - if(!file.exists()) { - player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NO SUCH FILE"); - return false; - } - - try { - com.boydti.fawe.object.schematic.Schematic schematicFAWE = FaweAPI.load(file); - Location playerLocation = player.getLocation(); - - World weWorld = new BukkitWorld(player.getWorld()); - Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()); - Vector offset = new Vector(schematicFAWE.getClipboard().getRegion().getMinimumPoint()).subtract(schematicFAWE.getClipboard().getOrigin()); - Vector v; - Vector dimensions = schematicFAWE.getClipboard().getDimensions(); - v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset); - - - CheckSession checkSession = new CheckSession(player.getUniqueId(), schematic, -1); - checkSession.sendNextCheck(); - - checkSession.setEditSession(schematicFAWE.paste(weWorld, v)); - } catch (IOException ex) { - player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! PASTE"); - ex.printStackTrace(); + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic ist nicht zum Prüfen eingesendet!"); return false; } } else { - player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! NULL"); + player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! SCHEMATIC DOES NOT EXIST"); return false; } } else { - player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! USER"); + player.sendMessage(SchematicSystem.PREFIX + "§cBeim Laden der Schematic ist ein Fehler aufgetreten! USER DOES NOT EXIST"); return false; } return false; @@ -191,7 +198,7 @@ public class CheckCommand implements CommandExecutor { message = message + args[i] + " "; } player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + WarkingUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!"); - checkSession.declineSchematic(); + checkSession.declineSchematic(message); } else { player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!"); return false; diff --git a/src/de/warking/schematicsystem/commands/SchematicCommand.java b/src/de/warking/schematicsystem/commands/SchematicCommand.java index cd05f6b..275a594 100644 --- a/src/de/warking/schematicsystem/commands/SchematicCommand.java +++ b/src/de/warking/schematicsystem/commands/SchematicCommand.java @@ -10,6 +10,8 @@ import com.sk89q.worldedit.session.ClipboardHolder; import de.warking.hunjy.MySQL.*; import de.warking.schematicsystem.SchematicSystem; import de.warking.schematicsystem.check.CheckUtils; +import de.warking.schematicsystem.check.Checkresult; +import de.warking.schematicsystem.utils.CheckedSchematic; import de.warking.schematicsystem.utils.Config; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; @@ -168,14 +170,15 @@ public class SchematicCommand implements CommandExecutor { if(CheckUtils.isSchematicNameAllowed(args[1])) { try { if(FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard() != null) { - if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) { - if(Schematic.getSchemFromDB(args[1], player.getUniqueId()).getSchemType() != SchematicType.normal) { + Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); + if(schematic != null) { + if(schematic.getSchemType() != SchematicType.normal) { player.sendMessage(SchematicSystem.PREFIX + "§cDu darfst diesen Schematic Typ nicht überschreiben!"); return false; } } - if(Schematic.getSchemFromDB(args[1], player.getUniqueId()) != null) { - Schematic.getSchemFromDB(args[1], player.getUniqueId()).remove(); + if(schematic != null) { + schematic.remove(); player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7überschrieben!"); } else player.sendMessage(SchematicSystem.PREFIX + "Schematic §6" + args[1] + " §7gespeichert!"); @@ -207,7 +210,7 @@ public class SchematicCommand implements CommandExecutor { FaweAPI.wrapPlayer(player).getSession().getClipboard().getClipboard(), FaweAPI.wrapPlayer(player).getSession().getClipboard().getWorldData()); - Schematic schematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal); + Schematic newSchematic = new Schematic(args[1], player.getUniqueId(), "", SchematicType.normal); } else { player.sendMessage(SchematicSystem.PREFIX + "§cDein Clipboard ist leer!"); @@ -226,7 +229,28 @@ public class SchematicCommand implements CommandExecutor { if(schematic != null) { player.sendMessage("§6Name: §7" + schematic.getSchemName()); - player.sendMessage("§6Typ: §7" + schematic.getSchemType().name()); + + 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()); @@ -263,6 +287,64 @@ public class SchematicCommand implements CommandExecutor { return false; } } + + if(args[0].equalsIgnoreCase("getschemchangetype")) { + if(CheckUtils.isSchematicNameAllowed(args[1])) { + Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); + if(schematic != null) { + TextComponent normal = new TextComponent("§7[§anormal§7]"); + normal.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " normal")); + + TextComponent wargear = new TextComponent("§7[§awargear§7]"); + wargear.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " wargear")); + + TextComponent miniwargear = new TextComponent("§7[§aminiwargear§7]"); + miniwargear.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " miniwargear")); + + TextComponent airship = new TextComponent("§7[§aairship§7]"); + airship.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " airship")); + + TextComponent warship = new TextComponent("§7[§awarship§7]"); + warship.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/schem changetype " + schematic.getSchemName() + " warship")); + + player.spigot().sendMessage(normal); + player.spigot().sendMessage(wargear); + player.spigot().sendMessage(miniwargear); + player.spigot().sendMessage(airship); + player.spigot().sendMessage(warship); + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); + return false; + } + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!"); + return false; + } + } + + if(args[0].equalsIgnoreCase("getmoreinfo")) { + if(CheckUtils.isSchematicNameAllowed(args[1])) { + Schematic schematic = Schematic.getSchemFromDB(args[1], player.getUniqueId()); + if(schematic != null) { + List checkedSchematics = CheckedSchematic.getLastDeclined(player.getUniqueId()); + for(CheckedSchematic checkedSchematic : checkedSchematics) { + if(checkedSchematic.getSchemName().equals(schematic.getSchemName()) && + checkedSchematic.getSchemOwner() == schematic.getSchemOwner()) { + player.sendMessage("§bStart: " + checkedSchematic.getStartTime()); + player.sendMessage("§bEnde: " + checkedSchematic.getEndTime()); + player.sendMessage("§bPrüfer: " + WarkingUser.get(checkedSchematic.getValidator()).getUserName()); + player.sendMessage("§bGrund: " + checkedSchematic.getDeclineReason()); + } + } + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic existiert nicht!"); + return false; + } + } else { + player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematic Name enthält verbotene Zeichen!"); + return false; + } + } return false; case 3: @@ -325,53 +407,69 @@ public class SchematicCommand implements CommandExecutor { if(args[2].equalsIgnoreCase("airship")) { if(dimensions.getBlockX() <= Config.AirShipBreite && dimensions.getBlockY() <= Config.AirShipHöhe && dimensions.getBlockZ() <= Config.AirShipTiefe) { - if(!CheckUtils.checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip")) { - player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform!"); + Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.AirShipForbiddenIds, true, true, "AirShip"); + if(!checkresult.isCheck()) { + player.sendMessage(SchematicSystem.PREFIX + "§cDein AirShip ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]"); + checkresult.remove(); return false; } schematic.setSchemType(SchematicType.Cairship); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6airship §7angefordert!"); CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6AirShip§8]"); - } + checkresult.remove(); + } else + player.sendMessage(SchematicSystem.PREFIX + "§cDein Airship überschreitet die Maximalmaße!"); return false; } if(args[2].equalsIgnoreCase("miniwargear")) { if(dimensions.getBlockX() <= Config.MiniWarGearBreite && dimensions.getBlockY() <= Config.MiniWarGearHöhe && dimensions.getBlockZ() <= Config.MiniWarGearTiefe) { - if(!CheckUtils.checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, false, "MiniWarGear")) { - player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform!"); + Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.MiniWarGearForbiddenIds, true, false, "MiniWarGear"); + if(!checkresult.isCheck()) { + player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]"); + checkresult.remove(); return false; } schematic.setSchemType(SchematicType.Cminiwargear); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6miniwargear §7angefordert!"); CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6MiniWarGear§8]"); - } + checkresult.remove(); + } else + player.sendMessage(SchematicSystem.PREFIX + "§cDein MiniWarGear überschreitet die Maximalmaße!"); return false; } if(args[2].equalsIgnoreCase("wargear")) { if(dimensions.getBlockX() <= Config.WarGearBreite && dimensions.getBlockY() <= Config.WarGearHöhe && dimensions.getBlockZ() <= Config.WarGearTiefe) { - if(!CheckUtils.checkSchematic(clipboard, Config.WarGearForbiddenIds, true, false, "WarGear")) { - player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform!"); + Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.WarGearForbiddenIds, true, false, "WarGear"); + if(!checkresult.isCheck()) { + player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]"); + checkresult.remove(); return false; } schematic.setSchemType(SchematicType.Cwargear); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6wargear §7angefordert!"); CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarGear§8]"); - } + checkresult.remove(); + } else + player.sendMessage(SchematicSystem.PREFIX + "§cDein WarGear überschreitet die Maximalmaße!"); return false; } if(args[2].equalsIgnoreCase("warship")) { if(dimensions.getBlockX() <= Config.WarShipBreite && dimensions.getBlockY() <= Config.WarShipHöhe && dimensions.getBlockZ() <= Config.WarShipTiefe) { - if(!CheckUtils.checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip")) { - player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform!"); + Checkresult checkresult = CheckUtils.checkSchematic(clipboard, Config.WarShipForbiddenIds, true, true, "WarShip"); + if(!checkresult.isCheck()) { + player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip ist nicht regelkonform! §0[§c" + checkresult.getReason() + ((checkresult.getBlockID() != -1) ? ": " + checkresult.getBlockID() : "") + "§0]"); + checkresult.remove(); return false; } schematic.setSchemType(SchematicType.Cwarship); player.sendMessage(SchematicSystem.PREFIX + "Schematic Type §6warship §7angefordert!"); CheckUtils.sendTeamMembersCSchematics(SchematicSystem.PREFIX + "§aDer Benutzer §6" + player.getName() + " §ahat eine Schematic eingesendet §8[§6WarShip§8]"); - } + checkresult.remove(); + } else + player.sendMessage(SchematicSystem.PREFIX + "§cDein WarShip überschreitet die Maximalmaße!"); return false; } }