mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-09-07 01:08:40 +02:00
World generation options for sponge
This commit is contained in:
parent
b77c2d1049
commit
4d8b9f9674
@ -80,7 +80,6 @@ import com.intellectualcrafters.plot.util.SetupUtils;
|
|||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An implementation of the core,
|
* An implementation of the core,
|
||||||
@ -99,7 +98,6 @@ public class PS {
|
|||||||
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
private final HashMap<String, PlotManager> plotmanagers = new HashMap<>();
|
||||||
|
|
||||||
// public:
|
// public:
|
||||||
public WorldEditPlugin worldEdit = null;
|
|
||||||
public File configFile;
|
public File configFile;
|
||||||
public File translationFile;
|
public File translationFile;
|
||||||
public YamlConfiguration style;
|
public YamlConfiguration style;
|
||||||
|
@ -24,11 +24,10 @@ import java.util.ArrayList;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.generator.ChunkGenerator;
|
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.C;
|
import com.intellectualcrafters.plot.config.C;
|
||||||
import com.intellectualcrafters.plot.database.DBFunc;
|
import com.intellectualcrafters.plot.database.DBFunc;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
import com.intellectualcrafters.plot.object.BlockLoc;
|
import com.intellectualcrafters.plot.object.BlockLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.Plot;
|
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.SetupUtils;
|
||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
//import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
//import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.generator.HybridGen;
|
//import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
|
//import com.plotsquared.bukkit.generator.HybridGen;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
@CommandDeclaration(
|
@CommandDeclaration(
|
||||||
@ -157,21 +157,32 @@ public class Cluster extends SubCommand {
|
|||||||
PS.get().loadWorld(world, PS.get().IMP.getGenerator(world, null));
|
PS.get().loadWorld(world, PS.get().IMP.getGenerator(world, null));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
final String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
String gen_string = PS.get().config.getString("worlds." + world + "." + "generator.plugin");
|
||||||
BukkitPlotGenerator generator;
|
|
||||||
if (gen_string == null) {
|
if (gen_string == null) {
|
||||||
generator = new HybridGen(world);
|
gen_string = "PlotSquared";
|
||||||
} 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);
|
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);
|
MainUtil.sendMessage(plr, C.CLUSTER_ADDED);
|
||||||
return true;
|
return true;
|
||||||
@ -222,7 +233,7 @@ public class Cluster extends SubCommand {
|
|||||||
}
|
}
|
||||||
DBFunc.delete(cluster);
|
DBFunc.delete(cluster);
|
||||||
if (plotworld.TYPE == 2) {
|
if (plotworld.TYPE == 2) {
|
||||||
AugmentedPopulator.removePopulator(plr.getLocation().getWorld(), cluster);
|
SetupUtils.manager.removePopulator(plr.getLocation().getWorld(), cluster);
|
||||||
}
|
}
|
||||||
ClusterManager.last = null;
|
ClusterManager.last = null;
|
||||||
ClusterManager.clusters.get(cluster.world).remove(cluster);
|
ClusterManager.clusters.get(cluster.world).remove(cluster);
|
||||||
|
@ -125,6 +125,9 @@ public class MainCommand extends CommandManager<PlotPlayer> {
|
|||||||
createCommand(new Copy());
|
createCommand(new Copy());
|
||||||
createCommand(new Chat());
|
createCommand(new Chat());
|
||||||
createCommand(new Trim());
|
createCommand(new Trim());
|
||||||
|
if (Settings.ENABLE_CLUSTERS) {
|
||||||
|
MainCommand.getInstance().addCommand(new Cluster());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean no_permission(final PlotPlayer player, final String permission) {
|
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.object.PlotPlayer;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
||||||
import com.plotsquared.general.commands.CommandDeclaration;
|
import com.plotsquared.general.commands.CommandDeclaration;
|
||||||
|
|
||||||
@ -41,7 +42,7 @@ public class WE_Anywhere extends SubCommand {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(PlotPlayer player, String[] arguments) {
|
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");
|
MainUtil.sendMessage(player, "&cWorldEdit is not enabled on this server");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -12,4 +12,8 @@ public class RegionWrapper {
|
|||||||
this.maxZ = maxZ;
|
this.maxZ = maxZ;
|
||||||
this.minZ = minZ;
|
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.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
|
import java.util.Map.Entry;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
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.RunnableVal;
|
||||||
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
import com.intellectualcrafters.plot.object.schematic.PlotItem;
|
||||||
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
import com.plotsquared.bukkit.object.schematic.StateWrapper;
|
||||||
import com.plotsquared.bukkit.util.WorldEditSchematic;
|
|
||||||
|
|
||||||
public abstract class SchematicHandler {
|
public abstract class SchematicHandler {
|
||||||
public static SchematicHandler manager;
|
public static SchematicHandler manager;
|
||||||
@ -98,40 +97,38 @@ public abstract class SchematicHandler {
|
|||||||
if (area > 4096) {
|
if (area > 4096) {
|
||||||
PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used");
|
PS.debug("The plot is > 64 x 64 - Fast lossy schematic saving will be used");
|
||||||
}
|
}
|
||||||
if (area <= 4096 && PS.get().worldEdit != null) {
|
// if (area <= 4096 && PS.get().worldEdit != null) {
|
||||||
new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
// new WorldEditSchematic().saveSchematic(directory + File.separator + name + ".schematic", plot.world, plot.id);
|
||||||
}
|
// }
|
||||||
else {
|
final Runnable THIS = this;
|
||||||
final Runnable THIS = this;
|
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
||||||
SchematicHandler.manager.getCompoundTag(plot.world, plot.id, new RunnableVal<CompoundTag>() {
|
@Override
|
||||||
@Override
|
public void run() {
|
||||||
public void run() {
|
if (value == null) {
|
||||||
if (value == null) {
|
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.id);
|
||||||
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();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
});
|
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;
|
return true;
|
||||||
|
@ -4,6 +4,7 @@ import java.util.HashMap;
|
|||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
|
||||||
@ -19,4 +20,6 @@ public abstract class SetupUtils {
|
|||||||
public abstract String getGenerator(PlotWorld plotworld);
|
public abstract String getGenerator(PlotWorld plotworld);
|
||||||
|
|
||||||
public abstract String setupWorld(final SetupObject object);
|
public abstract String setupWorld(final SetupObject object);
|
||||||
|
|
||||||
|
public abstract void removePopulator(String world, PlotCluster cluster);
|
||||||
}
|
}
|
||||||
|
@ -88,9 +88,11 @@ import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|||||||
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
||||||
|
|
||||||
public static BukkitMain THIS;
|
public static BukkitMain THIS;
|
||||||
|
public static WorldEditPlugin worldEdit;
|
||||||
|
|
||||||
private int[] version;
|
private int[] version;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public int[] getServerVersion() {
|
public int[] getServerVersion() {
|
||||||
if (version == null) {
|
if (version == null) {
|
||||||
@ -345,8 +347,8 @@ public class BukkitMain extends JavaPlugin implements Listener, IPlotMain {
|
|||||||
@Override
|
@Override
|
||||||
public void registerWorldEditEvents() {
|
public void registerWorldEditEvents() {
|
||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
||||||
PS.get().worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
BukkitMain.worldEdit = (WorldEditPlugin) getServer().getPluginManager().getPlugin("WorldEdit");
|
||||||
final String version = PS.get().worldEdit.getDescription().getVersion();
|
final String version = BukkitMain.worldEdit.getDescription().getVersion();
|
||||||
if ((version != null) && version.startsWith("5.")) {
|
if ((version != null) && version.startsWith("5.")) {
|
||||||
log("&cThis version of WorldEdit does not support PlotSquared.");
|
log("&cThis version of WorldEdit does not support PlotSquared.");
|
||||||
log("&cPlease use WorldEdit 6+ for masking support");
|
log("&cPlease use WorldEdit 6+ for masking support");
|
||||||
|
@ -42,6 +42,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
|
|
||||||
public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
public AugmentedPopulator(final String world, final BukkitPlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
||||||
MainUtil.initCache();
|
MainUtil.initCache();
|
||||||
|
PS.log("== NEW AUGMENTED POPULATOR FOR: " + world);
|
||||||
this.cluster = cluster;
|
this.cluster = cluster;
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
this.plotworld = PS.get().getPlotWorld(world);
|
this.plotworld = PS.get().getPlotWorld(world);
|
||||||
@ -99,6 +100,7 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
public void populate(final World world, final Random rand, final Chunk chunk) {
|
public void populate(final World world, final Random rand, final Chunk chunk) {
|
||||||
final int cx = chunk.getX();
|
final int cx = chunk.getX();
|
||||||
final int cz = chunk.getZ();
|
final int cz = chunk.getZ();
|
||||||
|
PS.log("== POPULATING FOR: " + world + " | " + cx + "," + cz);
|
||||||
final int bx = cx << 4;
|
final int bx = cx << 4;
|
||||||
final int bz = cz << 4;
|
final int bz = cz << 4;
|
||||||
final int tx = bx + 15;
|
final int tx = bx + 15;
|
||||||
@ -257,8 +259,4 @@ public class AugmentedPopulator extends BlockPopulator {
|
|||||||
populator.populate(world, this.r, chunk);
|
populator.populate(world, this.r, chunk);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIn(final RegionWrapper plot, final int x, final int z) {
|
|
||||||
return ((x >= plot.minX) && (x <= plot.maxX) && (z >= plot.minZ) && (z <= plot.maxZ));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -139,6 +139,7 @@ import com.intellectualcrafters.plot.util.RegExUtil;
|
|||||||
import com.intellectualcrafters.plot.util.StringMan;
|
import com.intellectualcrafters.plot.util.StringMan;
|
||||||
import com.intellectualcrafters.plot.util.TaskManager;
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||||
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
import com.plotsquared.bukkit.listeners.worldedit.WEManager;
|
||||||
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
import com.plotsquared.bukkit.object.BukkitLazyBlock;
|
||||||
import com.plotsquared.bukkit.object.BukkitPlayer;
|
import com.plotsquared.bukkit.object.BukkitPlayer;
|
||||||
@ -454,7 +455,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
final UUID uuid = pp.getUUID();
|
final UUID uuid = pp.getUUID();
|
||||||
UUIDHandler.add(name, uuid);
|
UUIDHandler.add(name, uuid);
|
||||||
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
ExpireManager.dates.put(uuid, System.currentTimeMillis());
|
||||||
if (PS.get().worldEdit != null) {
|
if (BukkitMain.worldEdit != null) {
|
||||||
if (Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) {
|
if (Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) {
|
||||||
WEManager.bypass.add(pp.getName());
|
WEManager.bypass.add(pp.getName());
|
||||||
}
|
}
|
||||||
@ -741,7 +742,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("location");
|
||||||
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
BukkitUtil.getPlayer(event.getPlayer()).deleteMeta("lastplot");
|
||||||
|
|
||||||
if (PS.get().worldEdit != null) {
|
if (BukkitMain.worldEdit != null) {
|
||||||
if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) {
|
if (!Permissions.hasPermission(pp, PERMISSION_WORLDEDIT_BYPASS)) {
|
||||||
WEManager.bypass.remove(pp.getName());
|
WEManager.bypass.remove(pp.getName());
|
||||||
}
|
}
|
||||||
@ -1613,7 +1614,7 @@ public class PlayerEvents extends com.plotsquared.listener.PlotListener implemen
|
|||||||
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
PlotPlayer pp = BukkitUtil.getPlayer(event.getPlayer());
|
||||||
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
|
ExpireManager.dates.put(pp.getUUID(), System.currentTimeMillis());
|
||||||
EventUtil.unregisterPlayer(pp);
|
EventUtil.unregisterPlayer(pp);
|
||||||
if (PS.get().worldEdit != null) {
|
if (BukkitMain.worldEdit != null) {
|
||||||
WEManager.bypass.remove(pp.getName());
|
WEManager.bypass.remove(pp.getName());
|
||||||
}
|
}
|
||||||
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
if (Settings.DELETE_PLOTS_ON_BAN && event.getPlayer().isBanned()) {
|
||||||
|
@ -19,6 +19,7 @@ import com.intellectualcrafters.plot.object.PlotPlayer;
|
|||||||
import com.intellectualcrafters.plot.object.RegionWrapper;
|
import com.intellectualcrafters.plot.object.RegionWrapper;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
import com.intellectualcrafters.plot.util.Permissions;
|
import com.intellectualcrafters.plot.util.Permissions;
|
||||||
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.sk89q.worldedit.BlockVector;
|
import com.sk89q.worldedit.BlockVector;
|
||||||
import com.sk89q.worldedit.bukkit.selections.Selection;
|
import com.sk89q.worldedit.bukkit.selections.Selection;
|
||||||
@ -93,7 +94,7 @@ public class WEListener implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) {
|
public boolean checkSelection(Player p, PlotPlayer pp, int modifier, long max, Cancellable e) {
|
||||||
final Selection selection = PS.get().worldEdit.getSelection(p);
|
final Selection selection = BukkitMain.worldEdit.getSelection(p);
|
||||||
if (selection == null) {
|
if (selection == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -29,9 +29,6 @@ public class BukkitCommand implements CommandExecutor, TabCompleter {
|
|||||||
|
|
||||||
public BukkitCommand() {
|
public BukkitCommand() {
|
||||||
MainCommand.getInstance().addCommand(new DebugUUID());
|
MainCommand.getInstance().addCommand(new DebugUUID());
|
||||||
if (Settings.ENABLE_CLUSTERS) {
|
|
||||||
MainCommand.getInstance().addCommand(new Cluster());
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -13,9 +13,11 @@ import org.bukkit.plugin.Plugin;
|
|||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
import com.plotsquared.bukkit.generator.AugmentedPopulator;
|
||||||
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
import com.plotsquared.bukkit.generator.BukkitGeneratorWrapper;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
|
|
||||||
@ -33,11 +35,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
if (generator != null) {
|
if (generator != null) {
|
||||||
PS.get().removePlotWorld(testWorld);
|
PS.get().removePlotWorld(testWorld);
|
||||||
final String name = plugin.getDescription().getName();
|
final String name = plugin.getDescription().getName();
|
||||||
// final PlotGenerator pgen = (PlotGenerator) generator;
|
|
||||||
// if (pgen.getPlotManager() instanceof SquarePlotManager) {
|
|
||||||
SetupUtils.generators.put(name, new BukkitGeneratorWrapper("CheckingPlotSquaredGenerator", generator));
|
SetupUtils.generators.put(name, new BukkitGeneratorWrapper("CheckingPlotSquaredGenerator", generator));
|
||||||
// }
|
|
||||||
// }
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -115,4 +113,9 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePopulator(String world, PlotCluster cluster) {
|
||||||
|
AugmentedPopulator.removePopulator(world, cluster);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -8,6 +8,7 @@ import com.intellectualcrafters.plot.PS;
|
|||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotId;
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
import com.intellectualcrafters.plot.util.MainUtil;
|
import com.intellectualcrafters.plot.util.MainUtil;
|
||||||
|
import com.plotsquared.bukkit.BukkitMain;
|
||||||
import com.sk89q.worldedit.CuboidClipboard;
|
import com.sk89q.worldedit.CuboidClipboard;
|
||||||
import com.sk89q.worldedit.EditSession;
|
import com.sk89q.worldedit.EditSession;
|
||||||
import com.sk89q.worldedit.Vector;
|
import com.sk89q.worldedit.Vector;
|
||||||
@ -22,7 +23,7 @@ public class WorldEditSchematic {
|
|||||||
CuboidClipboard clipboard = new CuboidClipboard(size, origin);
|
CuboidClipboard clipboard = new CuboidClipboard(size, origin);
|
||||||
Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ());
|
Vector pos1 = new Vector(bot.getX(), bot.getY(), bot.getZ());
|
||||||
Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ());
|
Vector pos2 = new Vector(top.getX(), top.getY(), top.getZ());
|
||||||
EditSession session = PS.get().worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
|
EditSession session = BukkitMain.worldEdit.getWorldEdit().getEditSessionFactory().getEditSession(new BukkitWorld(Bukkit.getWorld(world)), 999999999);
|
||||||
clipboard.copy(session);
|
clipboard.copy(session);
|
||||||
try {
|
try {
|
||||||
clipboard.saveSchematic(new File(file));
|
clipboard.saveSchematic(new File(file));
|
||||||
|
@ -50,6 +50,7 @@ import com.intellectualcrafters.plot.config.Settings;
|
|||||||
import com.intellectualcrafters.plot.generator.HybridUtils;
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
import com.intellectualcrafters.plot.object.PlotPlayer;
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||||
import com.intellectualcrafters.plot.util.BlockManager;
|
import com.intellectualcrafters.plot.util.BlockManager;
|
||||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
@ -240,14 +241,27 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
ConfigurationSection worldSection = PS.get().config.getConfigurationSection("worlds");
|
||||||
if (worldSection != null) {
|
if (worldSection != null) {
|
||||||
for (String world : worldSection.getKeys(false)) {
|
for (String world : worldSection.getKeys(false)) {
|
||||||
|
createWorldFromConfig(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
SpongeBasicGen generator = new SpongeBasicGen(world);
|
public World createWorldFromConfig(String world) {
|
||||||
PS.get().loadWorld(world, new SpongeGeneratorWrapper(world, generator));
|
SpongeBasicGen generator = new SpongeBasicGen(world);
|
||||||
|
PlotWorld plotworld = generator.getNewPlotWorld(world);
|
||||||
this.modify = new WorldModify(generator);
|
SpongeGeneratorWrapper wrapper;
|
||||||
Game game = event.getGame();
|
if (plotworld.TYPE == 0) {
|
||||||
|
wrapper = new SpongeGeneratorWrapper(world, generator);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
wrapper = new SpongeGeneratorWrapper(world, null);
|
||||||
|
}
|
||||||
|
PS.get().loadWorld(world, wrapper);
|
||||||
|
switch (plotworld.TYPE) {
|
||||||
|
// Normal
|
||||||
|
case 0: {
|
||||||
|
this.modify = new WorldModify(generator, false);
|
||||||
game.getRegistry().registerWorldGeneratorModifier(modify);
|
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||||
|
|
||||||
Optional<World> builder = game.getRegistry().getWorldBuilder()
|
Optional<World> builder = game.getRegistry().getWorldBuilder()
|
||||||
.name(world)
|
.name(world)
|
||||||
.enabled(true)
|
.enabled(true)
|
||||||
@ -255,11 +269,26 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
.keepsSpawnLoaded(true)
|
.keepsSpawnLoaded(true)
|
||||||
.dimensionType(DimensionTypes.OVERWORLD)
|
.dimensionType(DimensionTypes.OVERWORLD)
|
||||||
.generator(GeneratorTypes.FLAT)
|
.generator(GeneratorTypes.FLAT)
|
||||||
.gameMode(GameModes.CREATIVE)
|
|
||||||
.usesMapFeatures(false)
|
.usesMapFeatures(false)
|
||||||
.generatorModifiers(modify)
|
.generatorModifiers(modify)
|
||||||
.build();
|
.build();
|
||||||
World worldObj = builder.get();
|
return builder.get();
|
||||||
|
}
|
||||||
|
// Augmented
|
||||||
|
default: {
|
||||||
|
this.modify = new WorldModify(generator, true);
|
||||||
|
game.getRegistry().registerWorldGeneratorModifier(modify);
|
||||||
|
Optional<World> builder = game.getRegistry().getWorldBuilder()
|
||||||
|
.name(world)
|
||||||
|
.enabled(true)
|
||||||
|
.loadsOnStartup(true)
|
||||||
|
.keepsSpawnLoaded(true)
|
||||||
|
.dimensionType(DimensionTypes.OVERWORLD)
|
||||||
|
.generator(GeneratorTypes.OVERWORLD)
|
||||||
|
.usesMapFeatures(false)
|
||||||
|
.generatorModifiers(modify)
|
||||||
|
.build();
|
||||||
|
return builder.get();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -433,7 +462,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
return new SpongeGeneratorWrapper(world, null);
|
return new SpongeGeneratorWrapper(world, null);
|
||||||
}
|
}
|
||||||
if (name.equals("PlotSquared")) {
|
if (name.equals("PlotSquared")) {
|
||||||
return new SpongeGeneratorWrapper(world, null);
|
return new SpongeGeneratorWrapper(world, new SpongeBasicGen(world));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
||||||
@ -465,8 +494,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SetupUtils initSetupUtils() {
|
public SetupUtils initSetupUtils() {
|
||||||
// TODO Auto-generated method stub
|
return new SpongeSetupUtils();
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -585,7 +613,7 @@ public class SpongeMain implements IPlotMain, PluginContainer {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setGenerator(String world) {
|
public void setGenerator(String world) {
|
||||||
// THIS IS DONE DURING STARTUP ALREADY
|
// TODO THIS IS DONE DURING STARTUP ALREADY
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -14,6 +14,7 @@ import com.intellectualcrafters.jnbt.ListTag;
|
|||||||
import com.intellectualcrafters.jnbt.ShortTag;
|
import com.intellectualcrafters.jnbt.ShortTag;
|
||||||
import com.intellectualcrafters.jnbt.StringTag;
|
import com.intellectualcrafters.jnbt.StringTag;
|
||||||
import com.intellectualcrafters.jnbt.Tag;
|
import com.intellectualcrafters.jnbt.Tag;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.object.ChunkLoc;
|
import com.intellectualcrafters.plot.object.ChunkLoc;
|
||||||
import com.intellectualcrafters.plot.object.Location;
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
import com.intellectualcrafters.plot.object.PlotBlock;
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
@ -85,8 +86,10 @@ public class SpongeSchematicHandler extends SchematicHandler {
|
|||||||
// save schematics
|
// save schematics
|
||||||
ChunkLoc chunk = chunks.remove(0);
|
ChunkLoc chunk = chunks.remove(0);
|
||||||
|
|
||||||
if (!worldObj.loadChunk(chunk.x << 4, 0, chunk.z << 4, false).isPresent()) {
|
if (!worldObj.loadChunk(chunk.x << 4, 1, chunk.z << 4, false).isPresent()) {
|
||||||
continue;
|
System.out.println("COULD NOT LOAD CHUNK AT: " + chunk.x + "," + chunk.z);
|
||||||
|
// TODO continue - right now sponge chunk api seems to be broken :(
|
||||||
|
// continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
int X = chunk.x;
|
int X = chunk.x;
|
||||||
|
88
src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java
Normal file
88
src/main/java/com/plotsquared/sponge/SpongeSetupUtils.java
Normal file
@ -0,0 +1,88 @@
|
|||||||
|
package com.plotsquared.sponge;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||||
|
import com.intellectualcrafters.plot.generator.PlotGenerator;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||||
|
import com.plotsquared.sponge.generator.AugmentedPopulator;
|
||||||
|
import com.plotsquared.sponge.generator.SpongeBasicGen;
|
||||||
|
import com.plotsquared.sponge.generator.SpongeGeneratorWrapper;
|
||||||
|
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||||
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
|
|
||||||
|
public class SpongeSetupUtils extends SetupUtils {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateGenerators() {
|
||||||
|
if (SetupUtils.generators.size() > 0) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// TODO get external world generators
|
||||||
|
final String testWorld = "CheckingPlotSquaredGenerator";
|
||||||
|
SetupUtils.generators.put("PlotSquared", new SpongeGeneratorWrapper(testWorld, new SpongeBasicGen(testWorld)));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getGenerator(PlotWorld plotworld) {
|
||||||
|
if (SetupUtils.generators.size() == 0) {
|
||||||
|
updateGenerators();
|
||||||
|
}
|
||||||
|
World world = SpongeUtil.getWorld(plotworld.worldname);
|
||||||
|
if (world == null) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
WorldGenerator generator = world.getWorldGenerator();
|
||||||
|
if (!(generator instanceof SpongePlotGenerator)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (Entry<String, PlotGenerator<?>> entry : generators.entrySet()) {
|
||||||
|
if (entry.getValue().generator.getClass().getName().equals(generator.getClass().getName())) {
|
||||||
|
return entry.getKey();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String setupWorld(SetupObject object) {
|
||||||
|
SetupUtils.manager.updateGenerators();
|
||||||
|
final ConfigurationNode[] steps = object.step;
|
||||||
|
final String world = object.world;
|
||||||
|
for (final ConfigurationNode step : steps) {
|
||||||
|
PS.get().config.set("worlds." + world + "." + step.getConstant(), step.getValue());
|
||||||
|
}
|
||||||
|
if (object.type != 0) {
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.type", object.type);
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.terrain", object.terrain);
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.plugin", object.plotManager);
|
||||||
|
if (object.setupGenerator != null && !object.setupGenerator.equals(object.plotManager)) {
|
||||||
|
PS.get().config.set("worlds." + world + "." + "generator.init", object.setupGenerator);
|
||||||
|
}
|
||||||
|
PlotGenerator<WorldGenerator> gen = (PlotGenerator<WorldGenerator>) generators.get(object.setupGenerator);
|
||||||
|
if (gen != null && gen.generator instanceof SpongePlotGenerator) {
|
||||||
|
object.setupGenerator = null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
PS.get().config.save(PS.get().configFile);
|
||||||
|
} catch (final IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
SpongeMain.THIS.createWorldFromConfig(world);
|
||||||
|
return object.world;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void removePopulator(String world, PlotCluster cluster) {
|
||||||
|
AugmentedPopulator.removePopulator(world, cluster);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,291 @@
|
|||||||
|
package com.plotsquared.sponge.generator;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
|
import org.spongepowered.api.block.BlockState;
|
||||||
|
import org.spongepowered.api.block.BlockType;
|
||||||
|
import org.spongepowered.api.world.Chunk;
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
|
import org.spongepowered.api.world.extent.MutableBlockVolume;
|
||||||
|
import org.spongepowered.api.world.gen.GeneratorPopulator;
|
||||||
|
import org.spongepowered.api.world.gen.Populator;
|
||||||
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
|
||||||
|
import com.flowpowered.math.vector.Vector3i;
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
|
import com.intellectualcrafters.plot.object.Location;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotBlock;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotId;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotLoc;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||||
|
import com.intellectualcrafters.plot.util.SetBlockQueue;
|
||||||
|
import com.intellectualcrafters.plot.util.TaskManager;
|
||||||
|
import com.plotsquared.sponge.SpongeMain;
|
||||||
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
|
|
||||||
|
public class AugmentedPopulator implements Populator {
|
||||||
|
|
||||||
|
public final PlotWorld plotworld;
|
||||||
|
public final PlotManager manager;
|
||||||
|
public final SpongePlotGenerator generator;
|
||||||
|
public final GeneratorPopulator populator;
|
||||||
|
public final PlotCluster cluster;
|
||||||
|
public final Random r = new Random();
|
||||||
|
public final boolean p;
|
||||||
|
public final boolean b;
|
||||||
|
public final boolean o;
|
||||||
|
private final int bx;
|
||||||
|
private final int bz;
|
||||||
|
private final int tx;
|
||||||
|
private final int tz;
|
||||||
|
|
||||||
|
public AugmentedPopulator(String worldname, WorldGenerator gen, final SpongePlotGenerator generator, final PlotCluster cluster, final boolean p, final boolean b) {
|
||||||
|
// MainUtil.initCache();
|
||||||
|
// Initialize any chach that's needed
|
||||||
|
this.cluster = cluster;
|
||||||
|
this.generator = generator;
|
||||||
|
this.populator = generator.getBaseGeneratorPopulator();
|
||||||
|
this.plotworld = generator.getNewPlotWorld(worldname);
|
||||||
|
this.manager = generator.getPlotManager();
|
||||||
|
this.p = p;
|
||||||
|
this.b = b;
|
||||||
|
this.o = (this.plotworld.TERRAIN == 1) || (this.plotworld.TERRAIN == 2);
|
||||||
|
if (cluster != null) {
|
||||||
|
final Location bl = this.manager.getPlotBottomLocAbs(this.plotworld, cluster.getP1());
|
||||||
|
final Location tl = this.manager.getPlotTopLocAbs(this.plotworld, cluster.getP2()).add(1, 0, 1);
|
||||||
|
this.bx = bl.getX();
|
||||||
|
this.bz = bl.getZ();
|
||||||
|
this.tx = tl.getX();
|
||||||
|
this.tz = tl.getZ();
|
||||||
|
} else {
|
||||||
|
this.bx = Integer.MIN_VALUE;
|
||||||
|
this.bz = Integer.MIN_VALUE;
|
||||||
|
this.tx = Integer.MAX_VALUE;
|
||||||
|
this.tz = Integer.MAX_VALUE;
|
||||||
|
}
|
||||||
|
// Add the populator
|
||||||
|
List<Populator> populators = gen.getPopulators();
|
||||||
|
if (this.o) {
|
||||||
|
populators.add(0, this);
|
||||||
|
} else {
|
||||||
|
populators.add(this);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static void removePopulator(final String worldname, final PlotCluster cluster) {
|
||||||
|
final World world = SpongeUtil.getWorld(worldname);
|
||||||
|
List<Populator> populators = world.getWorldGenerator().getPopulators();
|
||||||
|
for (final Iterator<Populator> iterator = populators.iterator(); iterator.hasNext();) {
|
||||||
|
final Populator populator = iterator.next();
|
||||||
|
if (populator instanceof AugmentedPopulator) {
|
||||||
|
if (((AugmentedPopulator) populator).cluster.equals(cluster)) {
|
||||||
|
iterator.remove();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void populate(final Chunk chunk, Random r_unused) {
|
||||||
|
Vector3i min = chunk.getBlockMin();
|
||||||
|
final World worldObj = chunk.getWorld();
|
||||||
|
final String world = worldObj.getName();
|
||||||
|
final int cx = min.getX() >> 4;
|
||||||
|
final int cz = min.getZ() >> 4;
|
||||||
|
final int bx = cx << 4;
|
||||||
|
final int bz = cz << 4;
|
||||||
|
final int tx = bx + 15;
|
||||||
|
final int tz = bz + 15;
|
||||||
|
final boolean inX1 = ((bx >= this.bx) && (bx <= this.tx));
|
||||||
|
final boolean inX2 = ((tx >= this.bx) && (tx <= this.tx));
|
||||||
|
final boolean inZ1 = ((bz >= this.bz) && (bz <= this.tz));
|
||||||
|
final boolean inZ2 = ((tz >= this.bz) && (tz <= this.tz));
|
||||||
|
final boolean inX = inX1 || inX2;
|
||||||
|
final boolean inZ = inZ1 || inZ2;
|
||||||
|
if (!inX || !inZ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (this.plotworld.TERRAIN == 3) {
|
||||||
|
int X = min.getX();
|
||||||
|
int Z = min.getZ();
|
||||||
|
if (ChunkManager.FORCE_PASTE) {
|
||||||
|
for (short x = 0; x < 16; x++) {
|
||||||
|
for (short z = 0; z < 16; z++) {
|
||||||
|
final PlotLoc loc = new PlotLoc((short) (X + x), (short) (Z + z));
|
||||||
|
final HashMap<Short, Short> blocks = ChunkManager.GENERATE_BLOCKS.get(loc);
|
||||||
|
HashMap<Short, Byte> datas = ChunkManager.GENERATE_DATA.get(loc);
|
||||||
|
for (final Entry<Short, Short> entry : blocks.entrySet()) {
|
||||||
|
int y = entry.getKey();
|
||||||
|
if (datas != null) {
|
||||||
|
SetBlockQueue.setBlock(world, x, y, z, new PlotBlock(blocks.get(y), datas.get(y)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
SetBlockQueue.setBlock(world, x, y, z, blocks.get(y));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
PlotLoc loc;
|
||||||
|
for (Entry<PlotLoc, HashMap<Short, Byte>> entry : ChunkManager.GENERATE_DATA.entrySet()) {
|
||||||
|
HashMap<Short, Byte> datas = ChunkManager.GENERATE_DATA.get(entry.getKey());
|
||||||
|
for (Entry<Short, Byte> entry2 : entry.getValue().entrySet()) {
|
||||||
|
Short y = entry2.getKey();
|
||||||
|
byte data;
|
||||||
|
if (datas != null) {
|
||||||
|
data = datas.get(y);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
data = 0;
|
||||||
|
}
|
||||||
|
loc = entry.getKey();
|
||||||
|
int xx = loc.x - X;
|
||||||
|
int zz = loc.z - Z;
|
||||||
|
if (xx >= 0 && xx < 16) {
|
||||||
|
if (zz >= 0 && zz < 16) {
|
||||||
|
SetBlockQueue.setBlock(world, xx, y, zz, new PlotBlock(entry2.getValue(), data));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
final boolean check;
|
||||||
|
check = !inX1 || !inX2 || !inZ1 || !inZ2;
|
||||||
|
if (this.plotworld.TERRAIN > 1) {
|
||||||
|
final PlotId plot1 = this.manager.getPlotIdAbs(this.plotworld, bx, 0, bz);
|
||||||
|
final PlotId plot2 = this.manager.getPlotIdAbs(this.plotworld, tx, 0, tz);
|
||||||
|
if ((plot1 != null) && (plot2 != null) && plot1.equals(plot2)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (this.o) {
|
||||||
|
populateBlocks(worldObj, chunk, cx, cz, bx, bz, check);
|
||||||
|
} else {
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
// TODO populate biome
|
||||||
|
}
|
||||||
|
}, 20 + r.nextInt(10));
|
||||||
|
TaskManager.runTaskLater(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
populateBlocks(worldObj, chunk, cx, cz, bx, bz, check);
|
||||||
|
}
|
||||||
|
}, 40 + r.nextInt(40));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void populateBlocks(final World world, final Chunk chunk, final int X, final int Z, final int x, final int z, final boolean check) {
|
||||||
|
final String worldname = world.getName();
|
||||||
|
MutableBlockVolume blocks = new MutableBlockVolume() {
|
||||||
|
@Override
|
||||||
|
public void setBlock(int x, int y, int z, BlockState t) {
|
||||||
|
if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotBlock block = SpongeMain.THIS.getPlotBlock(t);
|
||||||
|
if (block != null) {
|
||||||
|
SetBlockQueue.setBlock(worldname, x, y, z, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlock(Vector3i v, BlockState t) {
|
||||||
|
setBlock(v.getX(), v.getY(), v.getZ(), t);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockType getBlockType(int x, int y, int z) {
|
||||||
|
return world.getBlockType(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockType getBlockType(Vector3i v) {
|
||||||
|
return getBlockType(v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector3i getBlockSize() {
|
||||||
|
return chunk.getBlockSize();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector3i getBlockMin() {
|
||||||
|
return chunk.getBlockMin();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Vector3i getBlockMax() {
|
||||||
|
return chunk.getBlockMax();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(int x, int y, int z) {
|
||||||
|
return world.getBlock(x, y, z);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public BlockState getBlock(Vector3i v) {
|
||||||
|
return getBlock(v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsBlock(int x, int y, int z) {
|
||||||
|
return ((x) >= bz) && ((z) <= tz) && ((x) >= bx) && ((z) <= tx);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public boolean containsBlock(Vector3i v) {
|
||||||
|
return containsBlock(v.getX(), v.getY(), v.getZ());
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockType(int x, int y, int z, BlockType t) {
|
||||||
|
if (check && (((z) < bz) || ((z) > tz) || ((x) < bx) || ((x) > tx))) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (p) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR != null) {
|
||||||
|
if (ChunkManager.CURRENT_PLOT_CLEAR.isIn(x, z)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else if (manager.getPlotIdAbs(plotworld, x, 0, z) != null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PlotBlock block = SpongeMain.THIS.getPlotBlock(t.getDefaultState());
|
||||||
|
if (block != null) {
|
||||||
|
SetBlockQueue.setBlock(worldname, x, y, z, block);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setBlockType(Vector3i v, BlockType t) {
|
||||||
|
setBlockType(v.getX(), v.getY(), v.getZ(), t);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
this.populator.populate(world, blocks , null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -7,6 +7,7 @@ import org.spongepowered.api.block.BlockState;
|
|||||||
import org.spongepowered.api.block.BlockTypes;
|
import org.spongepowered.api.block.BlockTypes;
|
||||||
import org.spongepowered.api.world.gen.BiomeGenerator;
|
import org.spongepowered.api.world.gen.BiomeGenerator;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.PS;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
import com.intellectualcrafters.plot.generator.HybridPlotManager;
|
||||||
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
import com.intellectualcrafters.plot.generator.HybridPlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
@ -15,11 +16,7 @@ import com.plotsquared.sponge.SpongeMain;
|
|||||||
|
|
||||||
public class SpongeBasicGen extends SpongePlotGenerator {
|
public class SpongeBasicGen extends SpongePlotGenerator {
|
||||||
|
|
||||||
public final BlockState ROAD_BLOCK = BlockTypes.QUARTZ_BLOCK.getDefaultState(); // Quartz
|
public final BlockState AIR = BlockTypes.AIR.getDefaultState();
|
||||||
public final BlockState MAIN_BLOCK = BlockTypes.STONE.getDefaultState(); // Stone
|
|
||||||
public final BlockState WALL_BLOCK = BlockTypes.BEDROCK.getDefaultState(); // Bedrock
|
|
||||||
public final BlockState BORDER_BLOCK = BlockTypes.STONE_SLAB.getDefaultState(); // Stone slab
|
|
||||||
public final BlockState[] FLOOR_BLOCK = new BlockState[] {BlockTypes.GRASS.getDefaultState(), BlockTypes.SPONGE.getDefaultState(), BlockTypes.PLANKS.getDefaultState() }; // Grass and sponge
|
|
||||||
|
|
||||||
private static HybridPlotManager manager;
|
private static HybridPlotManager manager;
|
||||||
public HybridPlotWorld plotworld;
|
public HybridPlotWorld plotworld;
|
||||||
@ -93,7 +90,10 @@ public class SpongeBasicGen extends SpongePlotGenerator {
|
|||||||
@Override
|
@Override
|
||||||
public PlotWorld getNewPlotWorld(String world) {
|
public PlotWorld getNewPlotWorld(String world) {
|
||||||
if (this.plotworld == null) {
|
if (this.plotworld == null) {
|
||||||
this.plotworld = new HybridPlotWorld(world);
|
this.plotworld = (HybridPlotWorld) PS.get().getPlotWorld(world);
|
||||||
|
if (this.plotworld == null) {
|
||||||
|
this.plotworld = new HybridPlotWorld(world);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return this.plotworld;
|
return this.plotworld;
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
package com.plotsquared.sponge.generator;
|
package com.plotsquared.sponge.generator;
|
||||||
|
|
||||||
|
import org.spongepowered.api.world.World;
|
||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
|
|
||||||
import com.intellectualcrafters.plot.PS;
|
import com.intellectualcrafters.plot.PS;
|
||||||
@ -8,6 +9,7 @@ import com.intellectualcrafters.plot.object.PlotCluster;
|
|||||||
import com.intellectualcrafters.plot.object.PlotManager;
|
import com.intellectualcrafters.plot.object.PlotManager;
|
||||||
import com.intellectualcrafters.plot.object.PlotWorld;
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
import com.intellectualcrafters.plot.object.SetupObject;
|
import com.intellectualcrafters.plot.object.SetupObject;
|
||||||
|
import com.plotsquared.sponge.util.SpongeUtil;
|
||||||
|
|
||||||
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
||||||
|
|
||||||
@ -29,13 +31,14 @@ public class SpongeGeneratorWrapper extends PlotGenerator<WorldGenerator>{
|
|||||||
public void augment(PlotCluster cluster, PlotWorld plotworld) {
|
public void augment(PlotCluster cluster, PlotWorld plotworld) {
|
||||||
if (generator instanceof SpongePlotGenerator) {
|
if (generator instanceof SpongePlotGenerator) {
|
||||||
SpongePlotGenerator plotgen = (SpongePlotGenerator) generator;
|
SpongePlotGenerator plotgen = (SpongePlotGenerator) generator;
|
||||||
if (cluster != null) {
|
World worldObj = SpongeUtil.getWorld(world);
|
||||||
// TODO Augment partial
|
if (worldObj != null) {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
if (cluster != null) {
|
||||||
}
|
new AugmentedPopulator(world, worldObj.getWorldGenerator(), plotgen, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||||
else {
|
}
|
||||||
// TODO augment full
|
else {
|
||||||
throw new UnsupportedOperationException("NOT IMPLEMENTED YET");
|
new AugmentedPopulator(world, worldObj.getWorldGenerator(), plotgen, null, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -55,7 +55,6 @@ public abstract class SpongePlotPopulator<T extends SpongePlotGenerator> impleme
|
|||||||
populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz);
|
populate(world, ChunkManager.CURRENT_PLOT_CLEAR, random, cx, cz);
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
PS.debug("ERROR GENERATING CHUNK!");
|
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -5,23 +5,38 @@ import org.spongepowered.api.world.WorldCreationSettings;
|
|||||||
import org.spongepowered.api.world.gen.WorldGenerator;
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
||||||
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
||||||
|
|
||||||
|
import com.intellectualcrafters.plot.object.PlotCluster;
|
||||||
|
import com.intellectualcrafters.plot.object.PlotWorld;
|
||||||
|
import com.intellectualcrafters.plot.util.ClusterManager;
|
||||||
|
|
||||||
public class WorldModify implements WorldGeneratorModifier {
|
public class WorldModify implements WorldGeneratorModifier {
|
||||||
|
|
||||||
private SpongePlotGenerator plotgen;
|
private SpongePlotGenerator plotgen;
|
||||||
|
private boolean augment;
|
||||||
|
|
||||||
public WorldModify(SpongePlotGenerator plotgen) {
|
public WorldModify(SpongePlotGenerator plotgen, boolean augment) {
|
||||||
this.plotgen = plotgen;
|
this.plotgen = plotgen;
|
||||||
|
this.augment = augment;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void modifyWorldGenerator(WorldCreationSettings world, DataContainer settings, WorldGenerator gen) {
|
public void modifyWorldGenerator(WorldCreationSettings world, DataContainer settings, WorldGenerator gen) {
|
||||||
gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator());
|
if (augment) {
|
||||||
gen.setBiomeGenerator(plotgen.getBiomeGenerator());
|
String worldname = plotgen.world;
|
||||||
// if (gen instanceof SpongeWorldGenerator) {
|
PlotWorld plotworld = plotgen.getNewPlotWorld(worldname);
|
||||||
// SpongePlotGenerator plotgen = (SpongePlotGenerator) gen;
|
if (plotworld.TYPE == 2) {
|
||||||
// plotgen.setBaseGeneratorPopulator(plotgen.getGenerator());
|
for (PlotCluster cluster : ClusterManager.getClusters(worldname)) {
|
||||||
// plotgen.setBiomeGenerator(plotgen.getPlotBiomeProvider());
|
new AugmentedPopulator(worldname, gen, plotgen, cluster, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||||
// }
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
new AugmentedPopulator(worldname, gen, plotgen, null, plotworld.TERRAIN == 2, plotworld.TERRAIN != 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
gen.setBaseGeneratorPopulator(plotgen.getBaseGeneratorPopulator());
|
||||||
|
gen.setBiomeGenerator(plotgen.getBiomeGenerator());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
Loading…
Reference in New Issue
Block a user