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;
import java.util.ArrayList;
import org.bukkit.Material;
import java.util.ArrayList;
import java.util.List;
/**
* This is the PlotWorld class (obviously)
* <br> - 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<String> SCHEMATICS = new ArrayList<>();
/**
* 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.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<String, Object> 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];

View File

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