mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2025-06-26 10:44:42 +02:00
World generation options for sponge
This commit is contained in:
@ -80,7 +80,6 @@ import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||
|
||||
/**
|
||||
* An implementation of the core,
|
||||
@ -99,7 +98,6 @@ public class PS {
|
||||
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||
|
||||
// public:
|
||||
public WorldEditPlugin worldEdit = null;
|
||||
public File configFile;
|
||||
public File translationFile;
|
||||
public YamlConfiguration style;
|
||||
|
@ -24,11 +24,10 @@ import java.util.ArrayList;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.generator.ChunkGenerator;
|
||||
|
||||
import com.intellectualcrafters.plot.PS;
|
||||
import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.database.DBFunc;
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||
import com.intellectualcrafters.plot.object.Location;
|
||||
import com.intellectualcrafters.plot.object.Plot;
|
||||
@ -43,9 +42,10 @@ import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
import com.plotsquared.bukkit.generator.HybridGen;
|
||||
//import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
//import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||
//import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||
//import com.plotsquared.bukkit.generator.HybridGen;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@CommandDeclaration(
|
||||
@ -157,21 +157,32 @@ public class Cluster extends SubCommand {
|
||||
PS.get().loadWorld(world, PS.get().IMP.getGenerator(world, null));
|
||||
}
|
||||
else {
|
||||
final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
||||
BukkitPlotGenerator generator;
|
||||
String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
||||
if (gen_string == null) {
|
||||
generator = new HybridGen(world);
|
||||
} else {
|
||||
ChunkGenerator chunkgen = (ChunkGenerator) PS.get().IMP.getGenerator(world, gen_string).generator;
|
||||
if (chunkgen instanceof BukkitPlotGenerator) {
|
||||
generator = (BukkitPlotGenerator) chunkgen;
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ","));
|
||||
return false;
|
||||
}
|
||||
gen_string = "PlotSquared";
|
||||
}
|
||||
new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||
PlotGenerator<?> wrapper = PS.get().IMP.getGenerator(world, gen_string);
|
||||
if (wrapper.isFull()) {
|
||||
wrapper.augment(cluster, plotworld);
|
||||
}
|
||||
else {
|
||||
MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ","));
|
||||
return false;
|
||||
}
|
||||
// BukkitPlotGenerator generator;
|
||||
// if (gen_string == null) {
|
||||
// generator = new HybridGen(world);
|
||||
// } else {
|
||||
// ChunkGenerator chunkgen = (ChunkGenerator) PS.get().IMP.getGenerator(world, gen_string).generator;
|
||||
// if (chunkgen instanceof BukkitPlotGenerator) {
|
||||
// generator = (BukkitPlotGenerator) chunkgen;
|
||||
// }
|
||||
// else {
|
||||
// MainUtil.sendMessage(plr, C.SETUP_INVALID_GENERATOR, StringMan.join(SetupUtils.generators.keySet(), ","));
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
// new AugmentedPopulator(world, generator, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||
}
|
||||
MainUtil.sendMessage(plr, C.CLUSTER_ADDED);
|
||||
return true;
|
||||
@ -222,7 +233,7 @@ public class Cluster extends SubCommand {
|
||||
}
|
||||
DBFunc.delete(cluster);
|
||||
if (plotworld.TYPE == 2) {
|
||||
AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster);
|
||||
SetupUtils.manager.removePopulator(plr.getLocation().getWorld(), cluster);
|
||||
}
|
||||
ClusterManager.last = null;
|
||||
ClusterManager.clusters.get(cluster.world).remove(cluster);
|
||||
|
@ -125,6 +125,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
||||
createCommand(new Copy());
|
||||
createCommand(new Chat());
|
||||
createCommand(new Trim());
|
||||
if (Settings.ENABLE_CLUSTERS) {
|
||||
MainCommand.getInstance().addCommand(new Cluster());
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
||||
|
@ -25,6 +25,7 @@ import com.intellectualcrafters.plot.config.C;
|
||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||
import com.intellectualcrafters.plot.util.MainUtil;
|
||||
import com.intellectualcrafters.plot.util.Permissions;
|
||||
import com.plotsquared.bukkit.BukkitMain;
|
||||
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
||||
import com.plotsquared.general.commands.CommandDeclaration;
|
||||
|
||||
@ -41,7 +42,7 @@ public class WE_Anywhere extends SubCommand {
|
||||
|
||||
@Override
|
||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
||||
if (PS.get().worldEdit == null) {
|
||||
if (BukkitMain.worldEdit == null) {
|
||||
MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server");
|
||||
return true;
|
||||
}
|
||||
|
@ -12,4 +12,8 @@ public class RegionWrapper {
|
||||
this.maxZ = maxZ;
|
||||
this.minZ = minZ;
|
||||
}
|
||||
|
||||
public boolean isIn(final int x, final int z) {
|
||||
return ((x >= this.minX) && (x <= this.maxX) && (z >= this.minZ) && (z <= this.maxZ));
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,7 @@ package com.intellectualcrafters.plot.util;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Random;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
|
@ -47,7 +47,6 @@ import com.intellectualcrafters.plot.object.PlotId;
|
||||
import com.intellectualcrafters.plot.object.RunnableVal;
|
||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||
import com.plotsquared.bukkit.util.WorldEditSchematic;
|
||||
|
||||
public abstract class SchematicHandler {
|
||||
public static SchematicHandler manager;
|
||||
@ -98,40 +97,38 @@ public abstract class SchematicHandler {
|
||||
if (area > 4096) {
|
||||
PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used");
|
||||
}
|
||||
if (area <= 4096 && PS.get().worldEdit != null) {
|
||||
new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
||||
}
|
||||
else {
|
||||
final Runnable THIS = this;
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value == null) {
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
}
|
||||
else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
||||
final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic");
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
} else {
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
THIS.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
// if (area <= 4096 && PS.get().worldEdit != null) {
|
||||
// new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
||||
// }
|
||||
final Runnable THIS = this;
|
||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (value == null) {
|
||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
TaskManager.runTaskAsync(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
MainUtil.sendMessage(null, "&6ID: " + plot.id);
|
||||
final boolean result = SchematicHandler.manager.save(value, directory + File.separator + name + ".schematic");
|
||||
if (!result) {
|
||||
MainUtil.sendMessage(null, "&7 - Failed to save &c" + plot.id);
|
||||
} else {
|
||||
MainUtil.sendMessage(null, "&7 - &a success: " + plot.id);
|
||||
}
|
||||
TaskManager.runTask(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
THIS.run();
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
return true;
|
||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
|
||||
@ -19,4 +20,6 @@ public abstract class SetupUtils {
|
||||
public abstract String getGenerator(PlotWorld plotworld);
|
||||
|
||||
public abstract String setupWorld(final SetupObject object);
|
||||
|
||||
public abstract void removePopulator(String world, PlotCluster cluster);
|
||||
}
|
||||
|
Reference in New Issue
Block a user