Schematic Support++

This commit is contained in:
Sauilitired 2014-09-28 10:43:44 +02:00
parent aa0d97eb2d
commit c5195fc198
3 changed files with 20 additions and 10 deletions

View File

@ -1,9 +1,10 @@
package com.intellectualcrafters.plot; package com.intellectualcrafters.plot;
import java.util.ArrayList;
import org.bukkit.Material; import org.bukkit.Material;
import java.util.ArrayList;
import java.util.List;
/** /**
* This is the PlotWorld class (obviously) * This is the PlotWorld class (obviously)
* <br> - All existing PlotWorld instances should be kept in PlotMain (worlds variable) * <br> - All existing PlotWorld instances should be kept in PlotMain (worlds variable)
@ -190,6 +191,9 @@ public class PlotWorld {
* Default schematic on claim: false * Default schematic on claim: false
*/ */
public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false; public static boolean SCHEMATIC_ON_CLAIM_DEFAULT = false;
public boolean SCHEMATIC_CLAIM_SPECIFY = false;
public List<String> SCHEMATICS = new ArrayList<>();
/** /**
* schematic file * schematic file
*/ */

View File

@ -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.on_claim", SCHEMATIC_ON_CLAIM_DEFAULT);
options.put("worlds." + world + ".schematic.file", SCHEMATIC_FILE_DEFAULT); options.put("worlds." + world + ".schematic.file", SCHEMATIC_FILE_DEFAULT);
options.put("worlds." + world + ".flags.default", DEFAULT_FLAGS_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<String, Object> node : options.entrySet()) { for (Entry<String, Object> node : options.entrySet()) {
if (!config.contains(node.getKey())) { if (!config.contains(node.getKey())) {
config.set(node.getKey(), node.getValue()); 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.PLOT_CHAT = config.getBoolean("worlds." + world + ".plot_chat");
this.plotworld.SCHEMATIC_ON_CLAIM = config.getBoolean("worlds." + world + ".schematic.on_claim"); 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_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]); String[] default_flags_string = config.getStringList("worlds." + world + ".flags.default").toArray(new String[0]);
Flag[] default_flags = new Flag[default_flags_string.length]; Flag[] default_flags = new Flag[default_flags_string.length];

View File

@ -52,13 +52,16 @@ public class Claim extends SubCommand {
return false; return false;
} }
if(!schematic.equals("")) { if(!schematic.equals("")) {
if(!plr.hasPermission("plots.claim." + schematic) && !plr.hasPermission("plots.admin")) { PlotWorld world = PlotMain.getWorldSettings(plot.getWorld());
PlayerFunctions.sendMessage(plr, C.NO_SCHEMATIC_PERMISSION, schematic); if(world.SCHEMATIC_CLAIM_SPECIFY) {
return true; if(!world.SCHEMATICS.contains(schematic.toLowerCase())) {
} sendMessage(plr, C.SCHEMATIC_INVALID, "non-existent");
if(new SchematicHandler().getSchematic(schematic) == null) { return true;
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); boolean result = claimPlot(plr, plot, false, schematic);