diff --git a/SchematicSystem_10/pom.xml b/SchematicSystem_10/pom.xml deleted file mode 100644 index 47b45e2..0000000 --- a/SchematicSystem_10/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - - - steamwar - SchematicSystem - 1.0 - - - SchematicSystem_10 - 1.0 - - - src - - - src - - **/*.java - **/*.kt - - - - - - - - steamwar - Spigot - 1.10 - provided - - - steamwar - WorldEdit - 1.0 - provided - - - steamwar - FAWE - 1.0 - provided - - - steamwar - SchematicSystem_9 - 1.0 - compile - - - steamwar - SchematicSystem_API - 1.0 - compile - - - \ No newline at end of file diff --git a/SchematicSystem_10/src/de/steamwar/schematicsystem/CheckSchemType_10.java b/SchematicSystem_10/src/de/steamwar/schematicsystem/CheckSchemType_10.java deleted file mode 100644 index c48847e..0000000 --- a/SchematicSystem_10/src/de/steamwar/schematicsystem/CheckSchemType_10.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.steamwar.schematicsystem; - -class CheckSchemType_10 { - private CheckSchemType_10(){} - - static AutoCheckResult autoCheck() { - return new AutoCheckResult(); - } -} diff --git a/SchematicSystem_10/src/de/steamwar/schematicsystem/WorldEdit_10.java b/SchematicSystem_10/src/de/steamwar/schematicsystem/WorldEdit_10.java deleted file mode 100644 index fbf4449..0000000 --- a/SchematicSystem_10/src/de/steamwar/schematicsystem/WorldEdit_10.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_10 { - private WorldEdit_10(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException { - return WorldEdit_8.pasteSchematic(player, schematic); - } -} diff --git a/SchematicSystem_12/pom.xml b/SchematicSystem_12/pom.xml index 5a1966a..7b58775 100644 --- a/SchematicSystem_12/pom.xml +++ b/SchematicSystem_12/pom.xml @@ -39,18 +39,6 @@ 1.0 provided - - steamwar - FAWE - 1.0 - provided - - - steamwar - SchematicSystem_10 - 1.0 - compile - steamwar SchematicSystem_API diff --git a/SchematicSystem_12/src/de/steamwar/schematicsystem/WorldEdit_12.java b/SchematicSystem_12/src/de/steamwar/schematicsystem/WorldEdit_12.java deleted file mode 100644 index 4771bfc..0000000 --- a/SchematicSystem_12/src/de/steamwar/schematicsystem/WorldEdit_12.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_12 { - private WorldEdit_12(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException { - return WorldEdit_8.pasteSchematic(player, schematic); - } -} diff --git a/SchematicSystem_14/pom.xml b/SchematicSystem_14/pom.xml deleted file mode 100644 index 371b1cc..0000000 --- a/SchematicSystem_14/pom.xml +++ /dev/null @@ -1,48 +0,0 @@ - - - 4.0.0 - - - steamwar - SchematicSystem - 1.0 - - - SchematicSystem_14 - 1.0 - - - src - - - src - - **/*.java - **/*.kt - - - - - - - - steamwar - SchematicSystem_API - 1.0 - - - steamwar - Spigot - 1.14 - provided - - - steamwar - WorldEdit - 1.15 - provided - - - \ No newline at end of file diff --git a/SchematicSystem_14/src/de/steamwar/schematicsystem/CheckSchemType_14.java b/SchematicSystem_14/src/de/steamwar/schematicsystem/CheckSchemType_14.java deleted file mode 100644 index 5630d66..0000000 --- a/SchematicSystem_14/src/de/steamwar/schematicsystem/CheckSchemType_14.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.steamwar.schematicsystem; - -class CheckSchemType_14 { - private CheckSchemType_14(){} - - static AutoCheckResult autoCheck() { - return new AutoCheckResult(); - } -} diff --git a/SchematicSystem_14/src/de/steamwar/schematicsystem/WorldEdit_14.java b/SchematicSystem_14/src/de/steamwar/schematicsystem/WorldEdit_14.java deleted file mode 100644 index 2535e85..0000000 --- a/SchematicSystem_14/src/de/steamwar/schematicsystem/WorldEdit_14.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.math.BlockVector3; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_14 { - private WorldEdit_14(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws IOException, NoClipboardException { - World weWorld = new BukkitWorld(player.getWorld()); - Location playerLocation = player.getLocation(); - Clipboard clipboard = schematic.load(); - BlockVector3 vector = BlockVector3.at(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()); - BlockVector3 offset = clipboard.getRegion().getMinimumPoint().subtract(clipboard.getOrigin()); - BlockVector3 dimensions = clipboard.getDimensions(); - BlockVector3 v = vector.subtract(dimensions.getX()/2, 0, dimensions.getZ()).subtract(offset); - EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1); - Operations.completeBlindly(new ClipboardHolder(clipboard).createPaste(e).to(v).build()); - e.flushSession(); - return e; - } -} diff --git a/SchematicSystem_15/pom.xml b/SchematicSystem_15/pom.xml index 0969ed3..5bc6204 100644 --- a/SchematicSystem_15/pom.xml +++ b/SchematicSystem_15/pom.xml @@ -32,11 +32,6 @@ SchematicSystem_API 1.0 - - steamwar - SchematicSystem_14 - 1.0 - steamwar Spigot diff --git a/SchematicSystem_15/src/de/steamwar/schematicsystem/WorldEdit_15.java b/SchematicSystem_15/src/de/steamwar/schematicsystem/WorldEdit_15.java deleted file mode 100644 index 6fcc4a4..0000000 --- a/SchematicSystem_15/src/de/steamwar/schematicsystem/WorldEdit_15.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_15 { - private WorldEdit_15(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException { - return WorldEdit_14.pasteSchematic(player, schematic); - } -} diff --git a/SchematicSystem_8/pom.xml b/SchematicSystem_8/pom.xml deleted file mode 100644 index 1950a72..0000000 --- a/SchematicSystem_8/pom.xml +++ /dev/null @@ -1,49 +0,0 @@ - - - 4.0.0 - - - steamwar - SchematicSystem - 1.0 - - - SchematicSystem_8 - 1.0 - - - src - - - src - - **/*.java - **/*.kt - - - - - - - - steamwar - Spigot - 1.8 - provided - - - steamwar - WorldEdit - 1.0 - provided - - - steamwar - SchematicSystem_API - 1.0 - compile - - - \ No newline at end of file diff --git a/SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType_8.java b/SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType_8.java deleted file mode 100644 index 38244c2..0000000 --- a/SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType_8.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.steamwar.schematicsystem; - -class CheckSchemType_8 { - private CheckSchemType_8(){} - - static AutoCheckResult autoCheck() { - return new AutoCheckResult(); - } -} diff --git a/SchematicSystem_8/src/de/steamwar/schematicsystem/WorldEdit_8.java b/SchematicSystem_8/src/de/steamwar/schematicsystem/WorldEdit_8.java deleted file mode 100644 index a11bdf6..0000000 --- a/SchematicSystem_8/src/de/steamwar/schematicsystem/WorldEdit_8.java +++ /dev/null @@ -1,34 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import com.sk89q.worldedit.Vector; -import com.sk89q.worldedit.WorldEdit; -import com.sk89q.worldedit.bukkit.BukkitWorld; -import com.sk89q.worldedit.extent.clipboard.Clipboard; -import com.sk89q.worldedit.function.operation.Operations; -import com.sk89q.worldedit.session.ClipboardHolder; -import com.sk89q.worldedit.world.World; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.Location; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_8 { - private WorldEdit_8(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException { - World weWorld = new BukkitWorld(player.getWorld()); - Location playerLocation = player.getLocation(); - Vector vector = new Vector(playerLocation.getBlockX(), playerLocation.getBlockY(), playerLocation.getBlockZ()); - Clipboard clipboard = schematic.load(); - Vector offset = new Vector(clipboard.getRegion().getMinimumPoint()).subtract(clipboard.getOrigin()); - Vector dimensions = clipboard.getDimensions(); - Vector v = vector.subtract(dimensions.getX()/2 - dimensions.getX()%2, 0, dimensions.getZ()).subtract(offset); - EditSession e = WorldEdit.getInstance().getEditSessionFactory().getEditSession(weWorld, -1); - Operations.completeBlindly(new ClipboardHolder(clipboard, weWorld.getWorldData()).createPaste(e, weWorld.getWorldData()).to(v).build()); - e.flushQueue(); - return e; - } -} diff --git a/SchematicSystem_9/pom.xml b/SchematicSystem_9/pom.xml deleted file mode 100644 index 53bcf19..0000000 --- a/SchematicSystem_9/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - - - steamwar - SchematicSystem - 1.0 - - - SchematicSystem_9 - 1.0 - - - src - - - src - - **/*.java - **/*.kt - - - - - - - - steamwar - Spigot - 1.9 - provided - - - steamwar - WorldEdit - 1.0 - provided - - - steamwar - FAWE - 1.0 - provided - - - steamwar - SchematicSystem_8 - 1.0 - compile - - - steamwar - SchematicSystem_API - 1.0 - compile - - - \ No newline at end of file diff --git a/SchematicSystem_9/src/de/steamwar/schematicsystem/CheckSchemType_9.java b/SchematicSystem_9/src/de/steamwar/schematicsystem/CheckSchemType_9.java deleted file mode 100644 index 6ac3141..0000000 --- a/SchematicSystem_9/src/de/steamwar/schematicsystem/CheckSchemType_9.java +++ /dev/null @@ -1,9 +0,0 @@ -package de.steamwar.schematicsystem; - -class CheckSchemType_9 { - private CheckSchemType_9(){} - - static AutoCheckResult autoCheck() { - return new AutoCheckResult(); - } -} diff --git a/SchematicSystem_9/src/de/steamwar/schematicsystem/WorldEdit_9.java b/SchematicSystem_9/src/de/steamwar/schematicsystem/WorldEdit_9.java deleted file mode 100644 index 0ef2a9e..0000000 --- a/SchematicSystem_9/src/de/steamwar/schematicsystem/WorldEdit_9.java +++ /dev/null @@ -1,16 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.entity.Player; - -import java.io.IOException; - -class WorldEdit_9 { - private WorldEdit_9(){} - - static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, NoClipboardException, IOException { - return WorldEdit_8.pasteSchematic(player, schematic); - } -} diff --git a/SchematicSystem_Main/pom.xml b/SchematicSystem_Main/pom.xml index 6008670..1427efb 100644 --- a/SchematicSystem_Main/pom.xml +++ b/SchematicSystem_Main/pom.xml @@ -50,48 +50,18 @@ 1.15 provided - - steamwar - WorldEdit - 1.15 - provided - steamwar SchematicSystem_15 1.0 compile - - steamwar - SchematicSystem_14 - 1.0 - compile - steamwar SchematicSystem_12 1.0 compile - - steamwar - SchematicSystem_10 - 1.0 - compile - - - steamwar - SchematicSystem_9 - 1.0 - compile - - - steamwar - SchematicSystem_8 - 1.0 - compile - steamwar SchematicSystem_API diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java index 48c1c85..350f287 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java @@ -24,7 +24,6 @@ public class CheckSchemType implements ICheckSchemType { private final int maxTNTSlime; private final int maxDispenser; private final int maxBlocks; - private final LinkedList checkList; CheckSchemType(ConfigurationSection section) { name = section.getName(); @@ -40,7 +39,6 @@ public class CheckSchemType implements ICheckSchemType { maxBlocks = section.getInt("maxBlocks"); forbiddenMaterials = section.getStringList("forbiddenMaterials"); - checkList = new LinkedList<>(section.getStringList("checkList")); types.put(SchematicType.fromDB(name), this); types.put(SchematicType.fromDB("c" + name), this); } @@ -49,28 +47,14 @@ public class CheckSchemType implements ICheckSchemType { return types.get(type); } - public List getCheckList() { - return checkList; - } - - public SchematicType getAcceptedType(){ - return SchematicType.fromDB(name); - } - public AutoCheckResult autoCheck(Schematic schematic) { switch(Core.getVersion()){ case 15: return CheckSchemType_15.autoCheck(schematic, this); - case 14: - return CheckSchemType_14.autoCheck(); - case 10: - return CheckSchemType_10.autoCheck(); - case 9: - return CheckSchemType_9.autoCheck(); - case 8: - return CheckSchemType_8.autoCheck(); - default: + case 12: return CheckSchemType_12.autoCheck(schematic, this); + default: + return new AutoCheckResult(); } } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java index 0f8a3ea..a6d2e96 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -1,12 +1,8 @@ package de.steamwar.schematicsystem; import de.steamwar.core.CommandRemover; -import de.steamwar.schematicsystem.check.CheckUtils; -import de.steamwar.schematicsystem.commands.CheckCommand; import de.steamwar.schematicsystem.commands.SchematicCommand; -import de.steamwar.schematicsystem.listener.PlayerCommandPreProcessListener; import de.steamwar.schematicsystem.listener.PlayerJoinListener; -import de.steamwar.schematicsystem.listener.PlayerQuitListener; import org.bukkit.Bukkit; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.file.FileConfiguration; @@ -35,16 +31,8 @@ public class SchematicSystem extends JavaPlugin { CommandRemover.removeAll("/schematic", "/schem", "//schematic", "//schem"); getCommand("schem").setExecutor(new SchematicCommand()); - getCommand("check").setExecutor(new CheckCommand()); PluginManager pm = Bukkit.getPluginManager(); pm.registerEvents(new PlayerJoinListener(), this); - pm.registerEvents(new PlayerQuitListener(), this); - pm.registerEvents(new PlayerCommandPreProcessListener(), this); - - Bukkit.getScheduler().runTaskTimerAsynchronously(this, () -> { - if(CheckUtils.getCSchematicsSize() > 0) - CheckUtils.sendTeamMembersCSchematics(CheckUtils.sendTeamMembersCSchematicsInfo()); - }, 0, 6000); } } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/WorldEdit.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/WorldEdit.java deleted file mode 100644 index cc892a2..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/WorldEdit.java +++ /dev/null @@ -1,30 +0,0 @@ -package de.steamwar.schematicsystem; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.core.Core; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import org.bukkit.entity.Player; - -import java.io.IOException; - -public class WorldEdit { - private WorldEdit(){} - - public static EditSession pasteSchematic(Player player, Schematic schematic) throws Schematic.WrongVersionException, IOException, NoClipboardException { - switch(Core.getVersion()){ - case 15: - return WorldEdit_15.pasteSchematic(player, schematic); - case 14: - return WorldEdit_14.pasteSchematic(player, schematic); - case 10: - return WorldEdit_10.pasteSchematic(player, schematic); - case 9: - return WorldEdit_9.pasteSchematic(player, schematic); - case 8: - return WorldEdit_8.pasteSchematic(player, schematic); - default: - return WorldEdit_12.pasteSchematic(player, schematic); - } - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckSession.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckSession.java deleted file mode 100644 index 69bfbd4..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckSession.java +++ /dev/null @@ -1,128 +0,0 @@ -package de.steamwar.schematicsystem.check; - -import com.sk89q.worldedit.EditSession; -import de.steamwar.schematicsystem.CheckSchemType; -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.sql.CheckedSchematic; -import de.steamwar.sql.Schematic; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; -import net.md_5.bungee.api.ChatColor; -import net.md_5.bungee.api.chat.ClickEvent; -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 { - - private static Set checkSessions = new HashSet<>(); - - private UUID uuid; //player - private Schematic schematic; - private ListIterator checkList; - - private Timestamp startTime; - private Timestamp stopTime; - - private EditSession editSession; - - public CheckSession(UUID uuid, Schematic schematic) { - this.uuid = uuid; - this.schematic = schematic; - checkList = CheckSchemType.get(schematic.getSchemType()).getCheckList().listIterator(); - - checkSessions.add(this); - setStartTime(); - } - - public static boolean currentChecking(){ - return !checkSessions.isEmpty(); - } - - public static CheckSession getCheckSession() { - if(checkSessions.isEmpty()) - return null; - return checkSessions.iterator().next(); - } - - public static CheckSession getCheckSession(Player player) { - for(CheckSession session : checkSessions){ - if(session.uuid.equals(player.getUniqueId())) - return session; - } - return null; - } - - public void sendNextCheck() { - if(!checkList.hasNext()){ - Bukkit.getPlayer(uuid).sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §e" + schematic.getSchemName() + " §avon §e" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §aist nun freigegeben!"); - schematic.setSchemType(CheckSchemType.get(schematic.getSchemType()).getAcceptedType()); - new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, "freigegeben"); - - removeSchematic(); - return; - } - - setStopTime(); - setStartTime(); - Bukkit.getPlayer(uuid).sendMessage(checkList.next()); - - if(checkList.hasNext()){ - - TextComponent next = new TextComponent("next "); - next.setColor(ChatColor.GREEN); - next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next")); - - TextComponent decline = new TextComponent("decline"); - decline.setColor(ChatColor.DARK_RED); - decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline ")); - - next.addExtra(decline); - Bukkit.getPlayer(uuid).spigot().sendMessage(next); - }else{ - TextComponent accept = new TextComponent("accept "); - accept.setColor(ChatColor.GREEN); - accept.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow")); - - TextComponent decline = new TextComponent("decline"); - decline.setColor(ChatColor.DARK_RED); - decline.setClickEvent(new ClickEvent(ClickEvent.Action.SUGGEST_COMMAND, "/check decline ")); - - accept.addExtra(decline); - Bukkit.getPlayer(uuid).spigot().sendMessage(accept); - } - } - - public void declineSchematic(String declineReason) { - schematic.setSchemType(SchematicType.Normal); - new CheckedSchematic(this.schematic.getSchemName(), this.schematic.getSchemOwner(), SteamwarUser.get(this.uuid).getId(), this.startTime, this.stopTime, declineReason); - - removeSchematic(); - } - - public void removeSchematic() { - this.editSession.undo(editSession); - checkSessions.remove(this); - } - - public Schematic getSchematic() { - return schematic; - } - - private void setStartTime() { - Date date = new Date(); - this.startTime = new Timestamp(date.getTime()); - } - - private void setStopTime() { - Date date = new Date(); - this.stopTime = new Timestamp(date.getTime()); - } - - public void setEditSession(EditSession editSession) { - this.editSession = editSession; - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckUtils.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckUtils.java deleted file mode 100644 index 90893a9..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/check/CheckUtils.java +++ /dev/null @@ -1,93 +0,0 @@ -package de.steamwar.schematicsystem.check; - -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.sql.Schematic; -import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; -import de.steamwar.sql.UserGroup; -import net.md_5.bungee.api.chat.ClickEvent; -import net.md_5.bungee.api.chat.ComponentBuilder; -import net.md_5.bungee.api.chat.HoverEvent; -import net.md_5.bungee.api.chat.TextComponent; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; - -import java.util.LinkedList; -import java.util.List; - -public class CheckUtils { - private CheckUtils(){} - - public static boolean schemnameForbidden(String schematicName) { - return schematicName.contains("/") || - schematicName.contains("\\") || - schematicName.contains("<") || - schematicName.contains(">") || - schematicName.contains("^") || - schematicName.contains("°") || - schematicName.contains("'") || - schematicName.contains("\""); - } - - public static boolean allowedToCheck(Player player) { - SteamwarUser warkingUser = SteamwarUser.get(player.getUniqueId()); - return warkingUser.getUserGroup() == UserGroup.Supporter || - warkingUser.getUserGroup() == UserGroup.Developer || - warkingUser.getUserGroup() == UserGroup.Moderator || - warkingUser.getUserGroup() == UserGroup.Admin; - } - - public static void sendTeamMembersCSchematics(String message) { - for(Player player : Bukkit.getServer().getOnlinePlayers()) { - if(allowedToCheck(player)) - player.sendMessage(message); - } - } - - public static int getCSchematicsSize() { - int size = 0; - for(SchematicType type : SchematicType.values()){ - if(type.check()) - size += Schematic.getAllSchemsOfType(type).size(); - } - return size; - } - - public static String sendTeamMembersCSchematicsInfo() { - int size = getCSchematicsSize(); - - String message = ""; - if(size == 0) - message = SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!"; - if(size == 1) - message = SchematicSystem.PREFIX + "§aEs gibt noch §6eine §aungeprüfte Schematic!"; - if(size > 1) - message = SchematicSystem.PREFIX + "§aEs gibt noch §6" + size + " §aungeprüfte Schematics!"; - - return message; - } - - public static void sendTeammemberSchematicList(Player player) { - List schematicList = new LinkedList<>(); - - for(SchematicType type : SchematicType.values()) { - if (type.check()) - schematicList.addAll(Schematic.getAllSchemsOfType(type)); - } - - if(schematicList.isEmpty()) { - player.sendMessage(SchematicSystem.PREFIX + "§aMomentan gibt es keine Schematics zu prüfen!"); - return; - } - - player.sendMessage("§e" + schematicList.size() + " ungeprüfte Schematics"); - - for(Schematic schematic : schematicList) { - TextComponent schematics = new TextComponent("§8" + schematic.getSchemType().getKuerzel() + " §7" + SteamwarUser.get(schematic.getSchemOwner()).getUserName() + " §e" + schematic.getSchemName()); - schematics.setBold(true); - schematics.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, new ComponentBuilder("Schematic prüfen").create())); - schematics.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check schematic " + schematic.getSchemName() + " " + SteamwarUser.get(schematic.getSchemOwner()).getUserName())); - player.spigot().sendMessage(schematics); - } - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/CheckCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/CheckCommand.java deleted file mode 100644 index 5b0fa0e..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/CheckCommand.java +++ /dev/null @@ -1,149 +0,0 @@ -package de.steamwar.schematicsystem.commands; - -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.WorldEdit; -import de.steamwar.schematicsystem.check.CheckSession; -import de.steamwar.schematicsystem.check.CheckUtils; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.Schematic; -import de.steamwar.sql.SteamwarUser; -import org.bukkit.Bukkit; -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import java.io.IOException; -import java.util.List; -import java.util.logging.Level; - -public class CheckCommand implements CommandExecutor { - - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if(!(sender instanceof Player)) - return false; - - Player player = (Player) sender; - if(CheckUtils.allowedToCheck(player)) { - if(args.length == 0) { - help(player); - return false; - } - - CheckSession checkSession; - - switch(args[0]){ - case "list": - CheckUtils.sendTeammemberSchematicList(player); - break; - case "next": - case "allow": - checkSession = session(player); - if(checkSession != null) - checkSession.sendNextCheck(); - break; - case "cancel": - checkSession = session(player); - if(checkSession != null){ - checkSession.removeSchematic(); - player.sendMessage(SchematicSystem.PREFIX + "§aDer Prüfvorgang wurde abgebrochen!"); - } - break; - case "schematic": - SteamwarUser checker = SteamwarUser.get(player.getUniqueId()); - String worldName = player.getWorld().getName(); - if(!worldName.equals(player.getUniqueId().toString()) && !worldName.equals(Integer.toString(checker.getId()))) { - player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen musst du dich auf deinem Bauserver befinden!"); - return false; - }else if(args.length < 3){ - help(player); - return false; - }else if(CheckSession.getCheckSession(player) != null) { - player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst schon eine Schematic!"); - return false; - } - - SteamwarUser user = SteamwarUser.get(args[2]); - if(user.getUUID() == null){ - player.sendMessage(SchematicSystem.PREFIX + "§cUnbekannter Benutzer"); - return false; - } - - Schematic schematic = Schematic.getSchemFromDB(args[1], user.getUUID()); - if(schematic == null){ - player.sendMessage(SchematicSystem.PREFIX + "§cSchematic gibts nicht"); - return false; - }else if(!schematic.getSchemType().check()){ - player.sendMessage(SchematicSystem.PREFIX + "§cSchematic ist nicht zu prüfen"); - return false; - }else if(schematic.getSchemOwner() == SteamwarUser.get(player.getUniqueId()).getId()) { - player.sendMessage(SchematicSystem.PREFIX + "§cDu kannst nicht deine eigenen Schematics prüfen"); - return false; - } - - List worldPlayers = player.getWorld().getPlayers(); - for(Player players : worldPlayers) { - if(!players.getUniqueId().toString().equals(player.getWorld().getName())) { - SteamwarUser warkingUsers = SteamwarUser.get(players.getUniqueId()); - if(!CheckUtils.allowedToCheck(players) && - !warkingUsers.getUUID().toString().equals(SteamwarUser.get(schematic.getSchemOwner()).getUUID().toString())) { - player.sendMessage(SchematicSystem.PREFIX + "§cZum Prüfen darf sich kein Unbeteiligter auf deinem Bauserver befinden!"); - return false; - } - } - } - - try { - checkSession = new CheckSession(player.getUniqueId(), schematic); - checkSession.sendNextCheck(); - checkSession.setEditSession(WorldEdit.pasteSchematic(player, schematic)); - } catch (IOException | NoClipboardException ex) { - player.sendMessage(SchematicSystem.PREFIX + "§cSchematic konnte nicht geladen/gepastet werden"); - Bukkit.getLogger().log(Level.SEVERE, "Failed to load schematic", ex); - return false; - } catch (Schematic.WrongVersionException e) { - player.sendMessage(SchematicSystem.PREFIX + "§cDiese Schematic kann nicht in dieser Minecraft-Version geladen werden"); - return false; - } - break; - case "decline": - if(args.length < 2) { - help(player); - return false; - } - checkSession = CheckSession.getCheckSession(player); - if(checkSession == null) - return false; - - StringBuilder message = new StringBuilder(); - for (int i = 1; i < args.length; i++) message.append(args[i]).append(" "); - - player.sendMessage(SchematicSystem.PREFIX + "§aDie Schematic §6" + checkSession.getSchematic().getSchemName() + " §avon §6" + SteamwarUser.get(checkSession.getSchematic().getSchemOwner()).getUserName() + " §awurde aufgrund von §6" + message + " §anicht freigegeben!"); - checkSession.declineSchematic(message.toString()); - break; - default: - help(player); - } - } - - return false; - } - - private void help(Player player) { - if(CheckUtils.allowedToCheck(player)){ - player.sendMessage("§8/§echeck list §8- §7Zeigt die Liste der ungeprüften Schematics"); - player.sendMessage("§8/§echeck schematic [SchematicName] [Besitzer] §8- §7Zum Checken einer Schematic"); - player.sendMessage("§8/§echeck allow §8- §7Schematic freigeben"); - player.sendMessage("§8/§echeck decline [Grund] §8- §7Schematic nicht freigeben"); - player.sendMessage("§8/§echeck cancel §8- §7Bricht das Prüfen ab"); - } - } - - private CheckSession session(Player player){ - CheckSession checkSession = CheckSession.getCheckSession(player); - if(checkSession == null) - player.sendMessage(SchematicSystem.PREFIX + "§cDu prüfst momentan keine Schematic!"); - return checkSession; - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java index d618587..fdc6a90 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java @@ -3,7 +3,6 @@ package de.steamwar.schematicsystem.commands; import de.steamwar.schematicsystem.AutoCheckResult; import de.steamwar.schematicsystem.CheckSchemType; import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.sql.*; import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.chat.ClickEvent; @@ -95,8 +94,19 @@ public class SchematicCommand implements CommandExecutor { } } + private boolean schemnameForbidden(String schematicName) { + return schematicName.contains("/") || + schematicName.contains("\\") || + schematicName.contains("<") || + schematicName.contains(">") || + schematicName.contains("^") || + schematicName.contains("°") || + schematicName.contains("'") || + schematicName.contains("\""); + } + private boolean invalidSchemName(Player player, String name){ - if(CheckUtils.schemnameForbidden(name)){ + if(schemnameForbidden(name)){ player.sendMessage(SchematicSystem.PREFIX + "§cDer angegebene Schematicname enthält verbotene Zeichen"); return true; } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java deleted file mode 100644 index 50d8ac5..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerCommandPreProcessListener.java +++ /dev/null @@ -1,27 +0,0 @@ -package de.steamwar.schematicsystem.listener; - -import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.check.CheckSession; -import org.bukkit.Bukkit; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerCommandPreprocessEvent; - -import java.util.logging.Level; - -public class PlayerCommandPreProcessListener implements Listener { - - @EventHandler - public void handlePlayerCommandPreprocess(PlayerCommandPreprocessEvent event) { - Player player = event.getPlayer(); - if(!event.getMessage().contains("copy") && !event.getMessage().contains("cut")) - return; - - if(CheckSession.getCheckSession() != null) { - event.setCancelled(true); - player.sendMessage(SchematicSystem.PREFIX + "§cDieser Befehl ist beim Prüfen gesperrt! Admin wird benachrichtigt."); - Bukkit.getLogger().log(Level.SEVERE, player.getName() + " tried to use a copy command!"); - } - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java index ba2aec0..07d75f5 100644 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java +++ b/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerJoinListener.java @@ -1,11 +1,8 @@ package de.steamwar.schematicsystem.listener; import de.steamwar.schematicsystem.SchematicSystem; -import de.steamwar.schematicsystem.check.CheckSession; -import de.steamwar.schematicsystem.check.CheckUtils; import de.steamwar.sql.Schematic; import de.steamwar.sql.SchematicType; -import de.steamwar.sql.SteamwarUser; import org.bukkit.entity.Player; import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; @@ -20,21 +17,8 @@ public class PlayerJoinListener implements Listener { public void handlePlayerJoin(PlayerJoinEvent event) { Player player = event.getPlayer(); - if(CheckSession.currentChecking()){ - CheckSession current = CheckSession.getCheckSession(); - assert current != null; - if(!CheckUtils.allowedToCheck(player) && !SteamwarUser.get(current.getSchematic().getSchemOwner()).getUUID().equals(player.getUniqueId())){ - player.sendMessage(SchematicSystem.PREFIX + "§cAuf diesem Server wird momentan eine Schematic geprüft!"); - player.kickPlayer(""); - return; - } - } - - if(CheckUtils.allowedToCheck(player)) - player.sendMessage(CheckUtils.sendTeamMembersCSchematicsInfo()); List uncheckedSchematics = new LinkedList<>(); - for(SchematicType type : SchematicType.values()){ if(type.check()) uncheckedSchematics.addAll(Schematic.getSchemsOfType(player.getUniqueId(), type)); diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java deleted file mode 100644 index 90178bd..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/listener/PlayerQuitListener.java +++ /dev/null @@ -1,20 +0,0 @@ -package de.steamwar.schematicsystem.listener; - -import de.steamwar.schematicsystem.check.CheckSession; -import org.bukkit.entity.Player; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; - -public class PlayerQuitListener implements Listener { - - @EventHandler - public void handlePlayerQuit(PlayerQuitEvent event) { - Player player = event.getPlayer(); - CheckSession checkSession = CheckSession.getCheckSession(player); - if(checkSession == null) - return; - - checkSession.removeSchematic(); - } -} diff --git a/pom.xml b/pom.xml index 964414f..6bef6fd 100644 --- a/pom.xml +++ b/pom.xml @@ -36,11 +36,7 @@ - SchematicSystem_8 - SchematicSystem_9 - SchematicSystem_10 SchematicSystem_12 - SchematicSystem_14 SchematicSystem_15 SchematicSystem_API SchematicSystem_Main