forked from SteamWar/SteamWar
Add Unified GameModeConfig
This commit is contained in:
+4
-3
@@ -24,7 +24,8 @@ import com.sk89q.worldedit.entity.Entity;
|
||||
import com.sk89q.worldedit.extent.clipboard.Clipboard;
|
||||
import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
@@ -118,7 +119,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult check(Clipboard clipboard, CheckSchemType type) {
|
||||
public AutoCheckerResult check(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
@@ -130,7 +131,7 @@ public class AutoChecker15 implements AutoChecker.IAutoChecker {
|
||||
}
|
||||
|
||||
@Override
|
||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, CheckSchemType type) {
|
||||
public AutoCheckerResult sizeCheck(Clipboard clipboard, GameModeConfig<Material, SchematicType, String> type) {
|
||||
return AutoCheckerResult.builder()
|
||||
.type(type)
|
||||
.height(clipboard.getDimensions().getBlockY())
|
||||
|
||||
+7
-8
@@ -31,10 +31,10 @@ import com.sk89q.worldedit.math.BlockVector3;
|
||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||
import com.sk89q.worldedit.world.block.BlockState;
|
||||
import com.sk89q.worldedit.world.block.BlockTypes;
|
||||
import de.steamwar.schematicsystem.CheckSchemType;
|
||||
import de.steamwar.data.GameModeConfig;
|
||||
import de.steamwar.schematicsystem.autocheck.AutoCheckerResult;
|
||||
import de.steamwar.schematicsystem.autocheck.BlockPos;
|
||||
import de.steamwar.schematicsystem.commands.schematiccommand.SchematicCommand;
|
||||
import de.steamwar.sql.SchematicType;
|
||||
import org.bukkit.Material;
|
||||
|
||||
import java.util.*;
|
||||
@@ -42,7 +42,7 @@ import java.util.stream.Collectors;
|
||||
|
||||
public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||
@Override
|
||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, CheckSchemType type) throws Exception {
|
||||
public Clipboard fixClipboard(Clipboard clipboard, AutoCheckerResult result, GameModeConfig<Material, SchematicType, String> type) throws Exception {
|
||||
for (BlockPos blockPos : result.getBlockScanResult().getRecords()) {
|
||||
BlockVector3 vector = BlockVector3.at(blockPos.getX(), blockPos.getY(), blockPos.getZ());
|
||||
clipboard.setBlock(vector, clipboard.getFullBlock(vector).toBaseBlock(new CompoundTag(Collections.emptyMap())));
|
||||
@@ -76,9 +76,9 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||
clipboard.setBlock(vector, block.toBaseBlock(builder.build()));
|
||||
}
|
||||
|
||||
if(type.getMaxDispenserItems() > 0 ) {
|
||||
if(type.Schematic.MaxDispenserItems > 0 ) {
|
||||
for (Map.Entry<BlockPos, Integer> entry : result.getBlockScanResult().getDispenserItems().entrySet()) {
|
||||
if(entry.getValue() <= type.getMaxDispenserItems()) {
|
||||
if(entry.getValue() <= type.Schematic.MaxDispenserItems) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||
List<CompoundTag> items = tag.getList("Items", CompoundTag.class);
|
||||
Collections.reverse(items); // To let the first item be in the Dispenser
|
||||
List<CompoundTag> list = new ArrayList<>();
|
||||
int diff = entry.getValue() - type.getMaxDispenserItems();
|
||||
int diff = entry.getValue() - type.Schematic.MaxDispenserItems;
|
||||
for (CompoundTag item : items) {
|
||||
if(item == null) {
|
||||
continue;
|
||||
@@ -117,10 +117,9 @@ public class SchematicCommand15 implements SchematicCommand.ISchematicCommand {
|
||||
}
|
||||
|
||||
if(!result.isLimitedBlocksOK()) {
|
||||
Set<Material> toReplace = type.getLimits().entrySet().stream()
|
||||
Set<Material> toReplace = type.Schematic.Limited.entrySet().stream()
|
||||
.filter(setIntegerEntry -> setIntegerEntry.getValue() == 0)
|
||||
.flatMap(setIntegerEntry -> setIntegerEntry.getKey().stream())
|
||||
.map(Material::matchMaterial)
|
||||
.collect(Collectors.toSet());
|
||||
BlockState replaceType = Objects.requireNonNull(toReplace.contains(Material.END_STONE) ? BlockTypes.IRON_BLOCK : BlockTypes.END_STONE).getDefaultState();
|
||||
BlockVector3 min = clipboard.getMinimumPoint();
|
||||
|
||||
Reference in New Issue
Block a user