13
0

Schemnodes Schematic System #93

Zusammengeführt
Lixfel hat 30 Commits von nodes nach master 2021-12-27 16:30:26 +01:00 zusammengeführt
15 geänderte Dateien mit 218 neuen und 399 gelöschten Zeilen
Nur Änderungen aus Commit e55b0481c4 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -33,7 +33,7 @@
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<artifactId>SchematicSystem_Core</artifactId>
<version>1.0</version>
</dependency>
<dependency>

Datei anzeigen

@ -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<Material> 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());

Datei anzeigen

@ -4,7 +4,7 @@
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<artifactId>SchematicSystem_12</artifactId>
<artifactId>SchematicSystem_8</artifactId>
<version>1.0</version>
<parent>
@ -34,9 +34,9 @@
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<version>1.8</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/Spigot-1.12.jar</systemPath>
<systemPath>${main.basedir}/lib/Spigot-1.8.jar</systemPath>
</dependency>
<dependency>
<groupId>steamwar</groupId>
@ -47,7 +47,7 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<artifactId>SchematicSystem_Core</artifactId>
<version>1.0</version>
</dependency>
</dependencies>

Datei anzeigen

@ -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<Integer> INVENTORY;
private static final Set<Integer> INVENTORY = new HashSet<>();
private static final Set<Material> FLOWERS;
static{
Set<Integer> 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<Material> 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());

Datei anzeigen

@ -14,8 +14,9 @@
<main.basedir>${project.basedir}/..</main.basedir>
</properties>
<artifactId>SchematicSystem_API</artifactId>
<artifactId>SchematicSystem_Core</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<sourceDirectory>src</sourceDirectory>
@ -34,9 +35,16 @@
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.12</version>
<version>1.15</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/Spigot-1.12.jar</systemPath>
<systemPath>${main.basedir}/lib/Spigot-1.15.jar</systemPath>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>WorldEdit</artifactId>
<version>1.15</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/WorldEdit-1.15.jar</systemPath>
</dependency>
</dependencies>
</project>

Datei anzeigen

@ -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<String, Integer> forbiddenMaterials = new HashMap<>(); // Anzahl verbotener Blöcke nach Material
private final Map<Set<String>, Integer> limitedMaterials;
private Map<String, Integer> defunctNbt = new HashMap<>(); // Anzahl an defekten NBT-Blöcken nach Materialname
private int records = 0; // Gefundene Schallplatten
private Map<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Anzahl verbotener Items nach Inventartyp
private Map<String, Map<String, Integer>> itemsWithTag = new HashMap<>(); // Anzahl an Items mit Tag nach Inventartyp
private int tooManyDispenserItems = 0; // Gefundene Überschreitungen von DispenserItems
private final Map<String, Integer> 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<String, Map<String, Integer>> forbiddenItems = new HashMap<>(); // Amount forbidden items per inventory block
private final Map<String, Map<String, Integer>> 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<String> errors(){
public Collection<String> errors() {
List<String> 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<Set<String>, 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<String, Integer> 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<String, Map<String, Integer>> 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<Set<String>, Integer> entry : limitedMaterials.entrySet()) {
if(entry.getKey().contains(name))
entry.setValue(entry.getValue() - 1);
}
}
void defunctNbt(String name){

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<SchematicType, CheckSchemType> types = new HashMap<>();
private final int width;
private final int height;
private final int depth;
private final int maxDispenserItems;
private final Map<Set<String>, 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<String> materials = new HashSet<>((List<String>) 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<Set<String>, Integer> getLimits() {
return new HashMap<>(limits);
}
public static final ICheckSchemType impl = VersionDependent.getVersionImpl(SchematicSystem.getInstance());
public interface ICheckSchemType {
void autoCheck(AutoCheckResult result, Clipboard clipboard);
}
}

Datei anzeigen

@ -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<String> getForbidden();
@Override
public void onEnable() {
instance = this;
SCHEMATIC_COMMAND = new SchematicCommand();
Chaoscaot markierte diese Unterhaltung als gelöst Veraltet
Veraltet
Review

Fände es schön, wenn man die Funktionen, welche Funktionalität auch für die GUI bereitstellen, einfach static deklarieren würde.

Fände es schön, wenn man die Funktionen, welche Funktionalität auch für die GUI bereitstellen, einfach static deklarieren würde.
}
public static SchematicSystem getInstance() {
return instance;
}
}

Datei anzeigen

@ -6,5 +6,4 @@ main: de.steamwar.schematicsystem.SchematicSystem
website: steamwar.de
api-version: "1.13"
commands:
check:
commands:

Datei anzeigen

@ -16,20 +16,9 @@
<artifactId>SchematicSystem_Main</artifactId>
<version>1.0</version>
<packaging>jar</packaging>
<build>
<defaultGoal>clean verify -U</defaultGoal>
<sourceDirectory>src</sourceDirectory>
<resources>
<resource>
<directory>src</directory>
<excludes>
<exclude>**/*.java</exclude>
<exclude>**/*.kt</exclude>
</excludes>
</resource>
</resources>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
@ -49,13 +38,6 @@
</build>
<dependencies>
<dependency>
<groupId>steamwar</groupId>
<artifactId>Spigot</artifactId>
<version>1.15</version>
<scope>system</scope>
<systemPath>${main.basedir}/lib/Spigot-1.15.jar</systemPath>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_15</artifactId>
@ -64,13 +46,13 @@
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_12</artifactId>
<artifactId>SchematicSystem_8</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>steamwar</groupId>
<artifactId>SchematicSystem_API</artifactId>
<artifactId>SchematicSystem_Core</artifactId>
<version>1.0</version>
<scope>compile</scope>
</dependency>

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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<SchematicType, CheckSchemType> 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<String> 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<String> getForbidden() {
return forbiddenMaterials;
}
}

Datei anzeigen

@ -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 <https://www.gnu.org/licenses/>.
*/
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());
}
}

Datei anzeigen

@ -30,10 +30,10 @@
</build>
<modules>
<module>SchematicSystem_12</module>
<module>SchematicSystem_8</module>
<module>SchematicSystem_15</module>
<module>SchematicSystem_API</module>
<module>SchematicSystem_Main</module>
<module>SchematicSystem_Core</module>
</modules>
<dependencies>