diff --git a/SchematicSystem_15/pom.xml b/SchematicSystem_15/pom.xml index 0074fa1..e23f79a 100644 --- a/SchematicSystem_15/pom.xml +++ b/SchematicSystem_15/pom.xml @@ -33,7 +33,7 @@ steamwar - SchematicSystem_API + SchematicSystem_Core 1.0 diff --git a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType15.java similarity index 81% rename from SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java rename to SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType15.java index c3b32f3..e0640c9 100644 --- a/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType_15.java +++ b/SchematicSystem_15/src/de/steamwar/schematicsystem/CheckSchemType15.java @@ -24,18 +24,13 @@ import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.math.BlockVector3; import com.sk89q.worldedit.regions.Region; import com.sk89q.worldedit.world.block.BaseBlock; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.SchematicNode; -import org.bukkit.Bukkit; import org.bukkit.Material; -import java.io.IOException; import java.util.EnumSet; import java.util.List; import java.util.Set; -import java.util.logging.Level; -class CheckSchemType_15 { +public class CheckSchemType15 implements CheckSchemType.ICheckSchemType { private static final Set INVENTORY = EnumSet.of( Material.BARREL, Material.BLAST_FURNACE, @@ -89,19 +84,8 @@ class CheckSchemType_15 { Material.GOLDEN_HORSE_ARMOR, Material.HONEY_BOTTLE); - private CheckSchemType_15(){} - - static AutoCheckResult autoCheck(SchematicNode schematic, ICheckSchemType type) { - AutoCheckResult result = new AutoCheckResult(type); - Clipboard clipboard; - try { - clipboard = schematic.load(); - } catch (IOException | NoClipboardException e) { - result.setErrorLoadingSchematic(); - Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e); - return result; - } - + @Override + public void autoCheck(AutoCheckResult result, Clipboard clipboard) { BlockVector3 dimensions = clipboard.getDimensions(); result.setLength(dimensions.getBlockX()); result.setHeight(dimensions.getBlockY()); @@ -111,11 +95,7 @@ class CheckSchemType_15 { BlockVector3 min = region.getMinimumPoint(); BlockVector3 max = region.getMaximumPoint(); - int tnt = 0; - int slime = 0; - int dispenser = 0; int blocks = 0; - for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ for(int y = min.getBlockY(); y <= max.getBlockY(); y++){ for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){ @@ -126,15 +106,6 @@ class CheckSchemType_15 { result.checkMaterial(blockMaterial.name()); - if(blockMaterial == Material.TNT || blockMaterial == Material.OBSIDIAN) - tnt++; - - if(blockMaterial == Material.SLIME_BLOCK || blockMaterial == Material.HONEY_BLOCK || blockMaterial == Material.BEDROCK) - slime++; - - if(blockMaterial == Material.DISPENSER) - dispenser++; - if(blockMaterial != Material.AIR) blocks++; @@ -144,15 +115,10 @@ class CheckSchemType_15 { } } - result.setTNT(tnt); - result.setSlime(slime); - result.setDispenser(dispenser); result.setBlocks(blocks); - - return result; } - private static void checkInventory(AutoCheckResult result, BaseBlock block, Material blockMaterial){ + private static void checkInventory(AutoCheckResult result, BaseBlock block, Material blockMaterial) { CompoundTag nbt = block.getNbtData(); if(nbt == null){ result.defunctNbt(blockMaterial.name()); diff --git a/SchematicSystem_12/pom.xml b/SchematicSystem_8/pom.xml similarity index 87% rename from SchematicSystem_12/pom.xml rename to SchematicSystem_8/pom.xml index 5143fee..109833f 100644 --- a/SchematicSystem_12/pom.xml +++ b/SchematicSystem_8/pom.xml @@ -4,7 +4,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 - SchematicSystem_12 + SchematicSystem_8 1.0 @@ -34,9 +34,9 @@ steamwar Spigot - 1.12 + 1.8 system - ${main.basedir}/lib/Spigot-1.12.jar + ${main.basedir}/lib/Spigot-1.8.jar steamwar @@ -47,7 +47,7 @@ steamwar - SchematicSystem_API + SchematicSystem_Core 1.0 diff --git a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java b/SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType8.java similarity index 64% rename from SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java rename to SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType8.java index 9839d29..c5fa415 100644 --- a/SchematicSystem_12/src/de/steamwar/schematicsystem/CheckSchemType_12.java +++ b/SchematicSystem_8/src/de/steamwar/schematicsystem/CheckSchemType8.java @@ -24,19 +24,14 @@ import com.sk89q.worldedit.Vector; import com.sk89q.worldedit.blocks.BaseBlock; import com.sk89q.worldedit.extent.clipboard.Clipboard; import com.sk89q.worldedit.regions.Region; -import de.steamwar.sql.NoClipboardException; -import de.steamwar.sql.SchematicNode; -import org.bukkit.Bukkit; import org.bukkit.Material; -import java.io.IOException; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.logging.Level; @SuppressWarnings("deprecation") -class CheckSchemType_12 { +public class CheckSchemType8 implements CheckSchemType.ICheckSchemType { private static final int TNT = Material.TNT.getId(); private static final int SLIME = Material.SLIME_BLOCK.getId(); private static final int OBSIDIAN = Material.OBSIDIAN.getId(); @@ -45,38 +40,23 @@ class CheckSchemType_12 { private static final int AIR = Material.AIR.getId(); private static final int JUKEBOX = Material.JUKEBOX.getId(); private static final int CHEST = Material.CHEST.getId(); - private static final Set INVENTORY; + private static final Set INVENTORY = new HashSet<>(); private static final Set FLOWERS; static{ - Set inventory = new HashSet<>(); - inventory.add(CHEST); - inventory.add(Material.TRAPPED_CHEST.getId()); - inventory.add(Material.HOPPER.getId()); - inventory.add(Material.FURNACE.getId()); - inventory.add(Material.BURNING_FURNACE.getId()); - inventory.add(JUKEBOX); //RecordItem - inventory.add(DISPENSER); - inventory.add(Material.DROPPER.getId()); - inventory.add(Material.ANVIL.getId()); - inventory.add(Material.BREWING_STAND.getId()); - inventory.add(Material.BLACK_SHULKER_BOX.getId()); - inventory.add(Material.RED_SHULKER_BOX.getId()); - inventory.add(Material.WHITE_SHULKER_BOX.getId()); - inventory.add(Material.ORANGE_SHULKER_BOX.getId()); - inventory.add(Material.BLUE_SHULKER_BOX.getId()); - inventory.add(Material.LIGHT_BLUE_SHULKER_BOX.getId()); - inventory.add(Material.YELLOW_SHULKER_BOX.getId()); - inventory.add(Material.GREEN_SHULKER_BOX.getId()); - inventory.add(Material.BROWN_SHULKER_BOX.getId()); - inventory.add(Material.CYAN_SHULKER_BOX.getId()); - inventory.add(Material.GRAY_SHULKER_BOX.getId()); - inventory.add(Material.SILVER_SHULKER_BOX.getId()); - inventory.add(Material.LIME_SHULKER_BOX.getId()); - inventory.add(Material.MAGENTA_SHULKER_BOX.getId()); - inventory.add(Material.PINK_SHULKER_BOX.getId()); - inventory.add(Material.PURPLE_SHULKER_BOX.getId()); - INVENTORY = inventory; + INVENTORY.add(CHEST); + INVENTORY.add(Material.TRAPPED_CHEST.getId()); + INVENTORY.add(Material.HOPPER.getId()); + INVENTORY.add(Material.FURNACE.getId()); + INVENTORY.add(Material.BURNING_FURNACE.getId()); + INVENTORY.add(JUKEBOX); //RecordItem + INVENTORY.add(DISPENSER); + INVENTORY.add(Material.DROPPER.getId()); + INVENTORY.add(Material.ANVIL.getId()); + INVENTORY.add(Material.BREWING_STAND.getId()); + for(int i = 219; i <= 234; i++) { + INVENTORY.add(i); // ShulkerBoxes + } Set flowers = new HashSet<>(); flowers.add(Material.YELLOW_FLOWER); @@ -88,19 +68,8 @@ class CheckSchemType_12 { FLOWERS = flowers; } - private CheckSchemType_12(){} - - static AutoCheckResult autoCheck(SchematicNode schematic, ICheckSchemType type) { - AutoCheckResult result = new AutoCheckResult(type); - Clipboard clipboard; - try { - clipboard = schematic.load(); - } catch (IOException | NoClipboardException e) { - Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e); - result.setErrorLoadingSchematic(); - return result; - } - + @Override + public void autoCheck(AutoCheckResult result, Clipboard clipboard) { Vector dimensions = clipboard.getDimensions(); result.setLength(dimensions.getBlockX()); result.setHeight(dimensions.getBlockY()); @@ -110,47 +79,29 @@ class CheckSchemType_12 { Vector min = region.getMinimumPoint(); Vector max = region.getMaximumPoint(); - int tnt = 0; - int slime = 0; int blocks = 0; - int dispenser = 0; - for(int x = min.getBlockX(); x <= max.getBlockX(); x++){ for(int y = min.getBlockY(); y <= max.getBlockY(); y++){ for(int z = min.getBlockZ(); z <= max.getBlockZ(); z++){ final BaseBlock block = clipboard.getBlock(new Vector(x, y, z)); final int blockId = block.getId(); - if(blockId == TNT || blockId == OBSIDIAN) - tnt++; - - if(blockId == SLIME || blockId == BEDROCK) - slime++; - - if(blockId == DISPENSER) - dispenser++; + result.checkMaterial(Material.getMaterial(blockId).name()); if (blockId != AIR) blocks++; if(INVENTORY.contains(blockId)){ - checkInventory(result, block, blockId, type); + checkInventory(result, block, blockId); } - - result.checkMaterial(Material.getMaterial(blockId).name()); } } } - result.setTNT(tnt); - result.setSlime(slime); - result.setDispenser(dispenser); result.setBlocks(blocks); - - return result; } - private static void checkInventory(AutoCheckResult result, BaseBlock block, int blockId, ICheckSchemType type){ + private static void checkInventory(AutoCheckResult result, BaseBlock block, int blockId) { CompoundTag nbt = block.getNbtData(); if(nbt == null){ result.defunctNbt(Material.getMaterial(blockId).name()); diff --git a/SchematicSystem_API/pom.xml b/SchematicSystem_Core/pom.xml similarity index 70% rename from SchematicSystem_API/pom.xml rename to SchematicSystem_Core/pom.xml index e6ef4f8..60d1745 100644 --- a/SchematicSystem_API/pom.xml +++ b/SchematicSystem_Core/pom.xml @@ -14,8 +14,9 @@ ${project.basedir}/.. - SchematicSystem_API + SchematicSystem_Core 1.0 + jar src @@ -34,9 +35,16 @@ steamwar Spigot - 1.12 + 1.15 system - ${main.basedir}/lib/Spigot-1.12.jar + ${main.basedir}/lib/Spigot-1.15.jar + + + steamwar + WorldEdit + 1.15 + system + ${main.basedir}/lib/WorldEdit-1.15.jar \ No newline at end of file diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java similarity index 62% rename from SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java rename to SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java index 317df27..d3760a9 100644 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/AutoCheckResult.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/AutoCheckResult.java @@ -19,54 +19,37 @@ package de.steamwar.schematicsystem; -import de.steamwar.core.Core; - import java.util.*; public class AutoCheckResult { - private final ICheckSchemType type; + private final CheckSchemType type; - private final boolean noChecksInThisVersion; - private boolean wrongVersionException = false; // Schematic nicht in der Version ladbar - private boolean errorLoadingSchematic = false; // Schematic irgendwie invalide + private boolean errorLoadingSchematic = false; private int width = 0; private int height = 0; private int length = 0; - private int tnt = 0; - private int slime = 0; - private int dispenser = 0; private int blocks = 0; - private Map forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material + private final Map, Integer> limitedMaterials; - private Map defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname - private int records = 0; // Gefundene Schallplatten - private Map> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp - private Map> itemsWithTag = new HashMap<>(); // Anzahl an Items mit Tag nach Inventartyp - private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems + private final Map defunctNbt = new HashMap<>(); // Amount of defect NBT-Blocks with material name - AutoCheckResult(ICheckSchemType type){ + private int records = 0; // Amount of found records + private final Map> forbiddenItems = new HashMap<>(); // Amount forbidden items per inventory block + private final Map> itemsWithTag = new HashMap<>(); // Amount of items with forbidden nbt tags + private int tooManyDispenserItems = 0; // Amount of dispensers with too many items + + public AutoCheckResult(CheckSchemType type) { this.type = type; - noChecksInThisVersion = false; + this.limitedMaterials = type.getLimits(); } - AutoCheckResult(){ - type = null; - noChecksInThisVersion = true; - } - - public Collection errors(){ + public Collection errors() { List errors = new LinkedList<>(); - if(noChecksInThisVersion){ - errors.add("In der 1." + Core.getVersion() + " können keine Schematics eingesendet werden"); - return errors; - } - if(wrongVersionException) - errors.add("Diese Schematic kann nicht in dieser Version geändert werden"); if(errorLoadingSchematic) errors.add("Die Schematic konnte nicht geladen werden"); @@ -78,22 +61,15 @@ public class AutoCheckResult { if(height > type.getHeight()) errors.add("Die Schematic ist zu hoch (" + height + " > " + type.getHeight() + ")"); - int errorTNTSlime = slime + tnt; - if(type.getMaxTNT() != 0 && tnt > type.getMaxTNT()) - errors.add("Zu viele TNT-Blöcke (" + tnt + " > " + type.getMaxTNT() + ")"); - if(type.getMaxSlime() != 0 && slime > type.getMaxSlime()) - errors.add("Zu viele Schleim/Honig-Blöcke (" + slime + " > " + type.getMaxSlime() + ")"); - if(type.getMaxDispenser() != 0 && dispenser > type.getMaxDispenser()) - errors.add("Zu viele Werfer (" + dispenser + " > " + type.getMaxDispenser() + ")"); - if(type.getMaxTNTSlime() != 0 && errorTNTSlime > type.getMaxTNTSlime()) - errors.add("Zu viel Schleim+TNT" + errorTNTSlime + " > " + type.getMaxTNTSlime() + ")"); + for(Map.Entry, Integer> entry : limitedMaterials.entrySet()) { + if(entry.getValue() < 0) + errors.add((entry.getKey().size() == 1 ? "Der Block " : "Die Blockkombination") + String.join(" ", entry.getKey()) + " wurde " + (-entry.getValue()) + " mal zu häufig verbaut"); + } + if(type.getMaxBlocks() != 0 && blocks > type.getMaxBlocks()) { errors.add("Zu viele Blöcke (" + blocks + " > " + type.getMaxBlocks() + ")"); } - for(Map.Entry block : forbiddenMaterials.entrySet()) - errors.add("Der Block " + block.getKey() + " ist verboten (" + block.getValue() + " verbaut)"); - if(records > 0) errors.add("Keine Schallplatten erlaubt (" + records + " gefunden)"); for(Map.Entry> block : forbiddenItems.entrySet()) @@ -137,23 +113,15 @@ public class AutoCheckResult { this.height = height; } - void setTNT(int tnt){ - this.tnt = tnt; - } - void setSlime(int slime){ - this.slime = slime; - } - void setDispenser(int dispenser){ - this.dispenser = dispenser; - } void setBlocks(int blocks) { this.blocks = blocks; } void checkMaterial(String name){ - assert type != null; - if(type.getForbidden().contains(name)) - forbiddenMaterials.compute(name, (k, v) -> v == null ? 1 : v+1); + for(Map.Entry, Integer> entry : limitedMaterials.entrySet()) { + if(entry.getKey().contains(name)) + entry.setValue(entry.getValue() - 1); + } } void defunctNbt(String name){ diff --git a/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemType.java new file mode 100644 index 0000000..f3c3a01 --- /dev/null +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/CheckSchemType.java @@ -0,0 +1,136 @@ +/* + This file is a part of the SteamWar software. + + Copyright (C) 2020 SteamWar.de-Serverteam + + This program is free software: you can redistribute it and/or modify + it under the terms of the GNU Affero General Public License as published by + the Free Software Foundation, either version 3 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU Affero General Public License for more details. + + You should have received a copy of the GNU Affero General Public License + along with this program. If not, see . +*/ + +package de.steamwar.schematicsystem; + +import com.sk89q.worldedit.extent.clipboard.Clipboard; +import de.steamwar.core.Core; +import de.steamwar.core.VersionDependent; +import de.steamwar.sql.NoClipboardException; +import de.steamwar.sql.Schematic; +import de.steamwar.sql.SchematicType; +import org.bukkit.Bukkit; +import org.bukkit.configuration.ConfigurationSection; +import org.bukkit.configuration.file.YamlConfiguration; + +import java.io.File; +import java.io.IOException; +import java.util.*; +import java.util.logging.Level; + +public class CheckSchemType { + + private static final Map types = new HashMap<>(); + + private final int width; + private final int height; + private final int depth; + private final int maxDispenserItems; + + private final Map, Integer> limits; + private final int maxBlocks; + + private CheckSchemType(ConfigurationSection section) { + String name = section.getString("Schematic.Type"); + width = section.getInt("Schematic.Size.x"); + height = section.getInt("Schematic.Size.y"); + depth = section.getInt("Schematic.Size.z"); + + maxDispenserItems = section.getInt("Schematic.MaxDispenserItems", 128); + maxBlocks = section.getInt("Schematic.MaxBlocks", 0); + + limits = new HashMap<>(); + for(Map entry : section.getMapList("Schematic.Limited")) { + int amount = (Integer) entry.get("Amount"); + Set materials = new HashSet<>((List) entry.get("Materials")); + if(amount == 0) { + materials.forEach(material -> limits.put(Collections.singleton(material), 0)); + } else { + limits.put(materials, amount); + } + } + + types.put(SchematicType.fromDB(name.toLowerCase()), this); + types.put(SchematicType.fromDB("c" + name.toLowerCase()), this); + } + + static { + File folder = new File(Core.getInstance().getDataFolder().getParentFile(), "FightSystem"); + + if(folder.exists()) { + for(File configFile : folder.listFiles((file, name) -> name.endsWith(".yml") && !name.endsWith(".kits.yml"))) { + YamlConfiguration config = YamlConfiguration.loadConfiguration(configFile); + if (!config.isList("CheckQuestions")) + continue; + + new CheckSchemType(config); + } + } + } + + public static CheckSchemType get(SchematicType type){ + return types.get(type); + } + + public AutoCheckResult autoCheck(Schematic schematic) { + AutoCheckResult result = new AutoCheckResult(this); + Clipboard clipboard; + try { + clipboard = schematic.load(); + } catch (IOException | NoClipboardException e) { + Bukkit.getLogger().log(Level.SEVERE, "Schematic could not be loaded", e); + result.setErrorLoadingSchematic(); + return result; + } + + impl.autoCheck(result, clipboard); + return result; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } + + public int getDepth() { + return depth; + } + + public int getMaxDispenserItems() { + return maxDispenserItems; + } + + public int getMaxBlocks(){ + return maxBlocks; + } + + public Map, Integer> getLimits() { + return new HashMap<>(limits); + } + + + public static final ICheckSchemType impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance()); + + public interface ICheckSchemType { + void autoCheck(AutoCheckResult result, Clipboard clipboard); + } +} diff --git a/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java similarity index 61% rename from SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java rename to SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java index bc58010..ff6702f 100644 --- a/SchematicSystem_API/src/de/steamwar/schematicsystem/ICheckSchemType.java +++ b/SchematicSystem_Core/src/de/steamwar/schematicsystem/SchematicSystem.java @@ -19,20 +19,23 @@ package de.steamwar.schematicsystem; -import java.util.List; +import de.steamwar.schematicsystem.commands.SchematicCommand; +import org.bukkit.plugin.java.JavaPlugin; -interface ICheckSchemType { - String getName(); +public class SchematicSystem extends JavaPlugin { + public static final String PREFIX = "§eSchematic§8» §7"; - int getWidth(); - int getHeight(); - int getDepth(); - int getMaxDispenserItems(); - int getMaxDispenser(); - int getMaxTNT(); - int getMaxTNTSlime(); - int getMaxSlime(); - int getMaxBlocks(); + private static SchematicSystem instance; + public SchematicCommand SCHEMATIC_COMMAND; - List getForbidden(); + @Override + public void onEnable() { + instance = this; + + SCHEMATIC_COMMAND = new SchematicCommand(); + } + + public static SchematicSystem getInstance() { + return instance; + } } diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java similarity index 100% rename from SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/GUI.java rename to SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/GUI.java diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java b/SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java similarity index 100% rename from SchematicSystem_Main/src/de/steamwar/schematicsystem/commands/SchematicCommand.java rename to SchematicSystem_Core/src/de/steamwar/schematicsystem/commands/SchematicCommand.java diff --git a/SchematicSystem_Main/src/plugin.yml b/SchematicSystem_Core/src/plugin.yml similarity index 91% rename from SchematicSystem_Main/src/plugin.yml rename to SchematicSystem_Core/src/plugin.yml index 9670206..457fdd9 100644 --- a/SchematicSystem_Main/src/plugin.yml +++ b/SchematicSystem_Core/src/plugin.yml @@ -6,5 +6,4 @@ main: de.steamwar.schematicsystem.SchematicSystem website: steamwar.de api-version: "1.13" -commands: - check: \ No newline at end of file +commands: \ No newline at end of file diff --git a/SchematicSystem_Main/pom.xml b/SchematicSystem_Main/pom.xml index 4b5ab42..fef4162 100644 --- a/SchematicSystem_Main/pom.xml +++ b/SchematicSystem_Main/pom.xml @@ -16,20 +16,9 @@ SchematicSystem_Main 1.0 - jar clean verify -U - src - - - src - - **/*.java - **/*.kt - - - org.apache.maven.plugins @@ -49,13 +38,6 @@ - - steamwar - Spigot - 1.15 - system - ${main.basedir}/lib/Spigot-1.15.jar - steamwar SchematicSystem_15 @@ -64,13 +46,13 @@ steamwar - SchematicSystem_12 + SchematicSystem_8 1.0 compile steamwar - SchematicSystem_API + SchematicSystem_Core 1.0 compile diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java deleted file mode 100644 index 1cfb616..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/CheckSchemType.java +++ /dev/null @@ -1,138 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.schematicsystem; - -import de.steamwar.core.VersionedCallable; -import de.steamwar.sql.SchematicNode; -import de.steamwar.sql.SchematicType; -import org.bukkit.configuration.ConfigurationSection; - -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -public class CheckSchemType implements ICheckSchemType { - - private static final Map types = new HashMap<>(); - - private final String name; - - private final int width; - private final int height; - private final int depth; - private final int maxDispenserItems; - private final List forbiddenMaterials; - - private final int maxTNT; - private final int maxSlime; - private final int maxTNTSlime; - private final int maxDispenser; - private final int maxBlocks; - - private CheckSchemType(ConfigurationSection section) { - name = section.getName(); - width = section.getInt("width"); - height = section.getInt("height"); - depth = section.getInt("depth"); - - maxTNT = section.getInt("maxTNT"); - maxSlime = section.getInt("maxSlime"); - maxTNTSlime = section.getInt("maxTNTSlime"); - maxDispenser = section.getInt("maxDispenser"); - maxDispenserItems = section.getInt("maxDispenserItems"); - maxBlocks = section.getInt("maxBlocks"); - - forbiddenMaterials = section.getStringList("forbiddenMaterials"); - types.put(SchematicType.fromDB(name), this); - types.put(SchematicType.fromDB("c" + name), this); - } - - static void init(ConfigurationSection config){ - ConfigurationSection types = config.getConfigurationSection("Schematics"); - for(String sectionName : types.getKeys(false)) - new CheckSchemType(types.getConfigurationSection(sectionName)); - } - - public static CheckSchemType get(SchematicType type){ - return types.get(type); - } - - public AutoCheckResult autoCheck(SchematicNode schematic) { - return VersionedCallable.call(new VersionedCallable<>(AutoCheckResult::new, 8), - new VersionedCallable<>(() -> CheckSchemType_12.autoCheck(schematic, this), 12), - new VersionedCallable<>(AutoCheckResult::new, 13), - new VersionedCallable<>(() -> CheckSchemType_15.autoCheck(schematic, this), 15)); - } - - @Override - public String getName() { - return name; - } - - @Override - public int getWidth() { - return width; - } - - @Override - public int getHeight() { - return height; - } - - @Override - public int getDepth() { - return depth; - } - - @Override - public int getMaxDispenserItems() { - return maxDispenserItems; - } - - @Override - public int getMaxDispenser() { - return maxDispenser; - } - - @Override - public int getMaxTNT() { - return maxTNT; - } - - @Override - public int getMaxTNTSlime() { - return maxTNTSlime; - } - - @Override - public int getMaxSlime() { - return maxSlime; - } - - @Override - public int getMaxBlocks(){ - return maxBlocks; - } - - @Override - public List getForbidden() { - return forbiddenMaterials; - } -} diff --git a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java b/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java deleted file mode 100644 index 9c77aaa..0000000 --- a/SchematicSystem_Main/src/de/steamwar/schematicsystem/SchematicSystem.java +++ /dev/null @@ -1,56 +0,0 @@ -/* - This file is a part of the SteamWar software. - - Copyright (C) 2020 SteamWar.de-Serverteam - - This program is free software: you can redistribute it and/or modify - it under the terms of the GNU Affero General Public License as published by - the Free Software Foundation, either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU Affero General Public License for more details. - - You should have received a copy of the GNU Affero General Public License - along with this program. If not, see . -*/ - -package de.steamwar.schematicsystem; - -import de.steamwar.schematicsystem.commands.SchematicCommand; -import de.steamwar.schematicsystem.commands.SchematicCommandUtils; -import org.bukkit.Bukkit; -import org.bukkit.event.EventHandler; -import org.bukkit.event.Listener; -import org.bukkit.event.player.PlayerQuitEvent; -import org.bukkit.plugin.java.JavaPlugin; - -import java.io.File; -import java.util.logging.Level; - -public class SchematicSystem extends JavaPlugin implements Listener { - public static final String PREFIX = "§eSchematic§8» §7"; - - public static SchematicSystem INSTANCE; - public static SchematicCommand SCHEMATIC_COMMAND; - - @Override - public void onEnable() { - INSTANCE = this; - if (!new File(getDataFolder(), "config.yml").exists()) { - saveDefaultConfig(); - Bukkit.getLogger().log(Level.SEVERE, "config.yml erstellt und geladen!"); - } - - CheckSchemType.init(getConfig()); - Bukkit.getPluginManager().registerEvents(this, this); - SCHEMATIC_COMMAND = new SchematicCommand(); - } - - @EventHandler - public void onPlayerQuit(PlayerQuitEvent event) { - SchematicCommandUtils.turnOffPublic(event.getPlayer()); - } -} diff --git a/pom.xml b/pom.xml index 1d72398..8973ac5 100644 --- a/pom.xml +++ b/pom.xml @@ -30,10 +30,10 @@ - SchematicSystem_12 + SchematicSystem_8 SchematicSystem_15 - SchematicSystem_API SchematicSystem_Main + SchematicSystem_Core