From c5195fc198368fcfab4f24b7ef0e0295da5b4bd5 Mon Sep 17 00:00:00 2001 From: Sauilitired Date: Sun, 28 Sep 2014 10:43:44 +0200 Subject: [PATCH] Schematic Support++ --- .../intellectualcrafters/plot/PlotWorld.java | 8 ++++++-- .../plot/WorldGenerator.java | 5 ++++- .../plot/commands/Claim.java | 17 ++++++++++------- 3 files changed, 20 insertions(+), 10 deletions(-) diff --git a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java index 86aec60cb..4be44e08a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/PlotWorld.java @@ -1,9 +1,10 @@ package com.intellectualcrafters.plot; -import java.util.ArrayList; - import org.bukkit.Material; +import java.util.ArrayList; +import java.util.List; + /** * This is the PlotWorld class (obviously) *
- All existing PlotWorld instances should be kept in PlotMain (worlds variable) @@ -190,6 +191,9 @@ public class PlotWorld { * Default schematic on claim: false */ public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; + public boolean SCHEMATIC_CLAIM_SPECIFY = false; + public List SCHEMATICS = new ArrayList<>(); + /** * schematic file */ diff --git a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java index 4dcaf7242..5b13b7d6e 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/WorldGenerator.java @@ -89,7 +89,8 @@ public class WorldGenerator extends ChunkGenerator { options.put("worlds." + world + ".schematic.on_claim", SCHEMATIC_ON_CLAIM_DEFAULT); options.put("worlds." + world + ".schematic.file", SCHEMATIC_FILE_DEFAULT); options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_DEFAULT); - + options.put("worlds." + world + ".schematic.schematics", plotworld.SCHEMATICS); + options.put("worlds." + world + ".schematic.specify_on_claim", plotworld.SCHEMATIC_CLAIM_SPECIFY); for (Entry node : options.entrySet()) { if (!config.contains(node.getKey())) { config.set(node.getKey(), node.getValue()); @@ -116,6 +117,8 @@ public class WorldGenerator extends ChunkGenerator { this.plotworld.PLOT_CHAT = config.getBoolean("worlds." + world + ".plot_chat"); this.plotworld.SCHEMATIC_ON_CLAIM = config.getBoolean("worlds." + world + ".schematic.on_claim"); this.plotworld.SCHEMATIC_FILE = config.getString("worlds." + world + ".schematic.file"); + this.plotworld.SCHEMATIC_CLAIM_SPECIFY = config.getBoolean("worlds." + world + ".schematic.specify_on_claim"); + this.plotworld.SCHEMATICS = config.getStringList("worlds." + world + ".schematic.schematics"); String[] default_flags_string = config.getStringList("worlds." + world + ".flags.default").toArray(new String[0]); Flag[] default_flags = new Flag[default_flags_string.length]; diff --git a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java index 259f0cf14..54d209f7a 100644 --- a/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java +++ b/PlotSquared/src/com/intellectualcrafters/plot/commands/Claim.java @@ -52,13 +52,16 @@ public class Claim extends SubCommand { return false; } if(!schematic.equals("")) { - if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { - PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); - return true; - } - if(new SchematicHandler().getSchematic(schematic) == null) { - sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); - return true; + PlotWorld world = PlotMain.getWorldSettings(plot.getWorld()); + if(world.SCHEMATIC_CLAIM_SPECIFY) { + if(!world.SCHEMATICS.contains(schematic.toLowerCase())) { + sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent"); + return true; + } + if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { + PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); + return true; + } } } boolean result = claimPlot(plr, plot, false, schematic);