mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-25 14:46:45 +01:00
Some sponge fixes
This commit is contained in:
parent
c1a6c75ebe
commit
6e0ade4f63
@ -2033,7 +2033,7 @@ public class Plot {
|
||||
for (int i = 4; i > 0; i--) {
|
||||
String caption = C.valueOf("OWNER_SIGN_LINE_" + i).s();
|
||||
int index = caption.indexOf("%plr%");
|
||||
if (index == -1) {
|
||||
if (index < 0) {
|
||||
continue;
|
||||
}
|
||||
String line = lines[i - 1];
|
||||
|
@ -36,11 +36,7 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
||||
result.setCuboid(dirt1, dirt2, PlotBlock.get(3, 0));
|
||||
result.setCuboid(grass1, grass2, PlotBlock.get(2, 0));
|
||||
}
|
||||
for (int x = 0; x < 16; x++) {
|
||||
for (int z = 0; z < 16; z++) {
|
||||
result.setBiome(x, z, "PLAINS");
|
||||
}
|
||||
}
|
||||
result.fillBiome("PLAINS");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.worlds.PlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotArea;
|
||||
import com.intellectualcrafters.plot.object.worlds.SinglePlotAreaManager;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.AbstractTitle;
|
||||
import com.intellectualcrafters.plot.util.ChatManager;
|
||||
import com.intellectualcrafters.plot.util.ChunkManager;
|
||||
@ -143,6 +144,7 @@ public class SpongeMain implements IPlotMain {
|
||||
new PS(this, "Sponge");
|
||||
this.server = this.game.getServer();
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) PS.get().IMP.getDefaultGenerator().specify(null));
|
||||
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new SingleWorldGenerator().specify(null));
|
||||
if (Settings.Enabled_Components.WORLDS) {
|
||||
TaskManager.IMP.taskRepeat(new Runnable() {
|
||||
@Override
|
||||
@ -172,6 +174,7 @@ public class SpongeMain implements IPlotMain {
|
||||
return;
|
||||
}
|
||||
}
|
||||
System.out.println("Unload " + world);
|
||||
Sponge.getServer().unloadWorld(world);
|
||||
}
|
||||
}
|
||||
@ -200,7 +203,7 @@ public class SpongeMain implements IPlotMain {
|
||||
|
||||
@Override
|
||||
public File getWorldContainer() {
|
||||
return game.getSavesDirectory().toFile();
|
||||
return new File(game.getSavesDirectory().toFile(), "world");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -18,6 +18,7 @@ import com.intellectualcrafters.plot.util.StringMan;
|
||||
import com.intellectualcrafters.plot.util.TaskManager;
|
||||
import com.intellectualcrafters.plot.util.UUIDHandler;
|
||||
import com.plotsquared.listener.PlotListener;
|
||||
import com.plotsquared.sponge.SpongeMain;
|
||||
import com.plotsquared.sponge.object.SpongePlayer;
|
||||
import com.plotsquared.sponge.util.SpongeUtil;
|
||||
import java.util.ArrayList;
|
||||
@ -161,7 +162,6 @@ public class MainListener {
|
||||
|
||||
@Listener
|
||||
public void onSpawnEntity(SpawnEntityEvent event) {
|
||||
World world = event.getTargetWorld();
|
||||
event.filterEntities(entity -> {
|
||||
if (entity instanceof Player) {
|
||||
return true;
|
||||
@ -389,14 +389,12 @@ public class MainListener {
|
||||
}
|
||||
|
||||
public void onChangeBlock(ChangeBlockEvent event) {
|
||||
World world = event.getTargetWorld();
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
Location loc = SpongeUtil.getLocation(worldName, first.getOriginal().getPosition());
|
||||
BlockSnapshot original = first.getOriginal();
|
||||
Optional<World> world = SpongeMain.THIS.getServer().getWorld(original.getWorldUniqueId());
|
||||
String worldName = world.get().getName();
|
||||
Location loc = SpongeUtil.getLocation(worldName, original.getPosition());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -435,15 +433,12 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
World world = event.getTargetWorld();
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
BlockSnapshot pos = first.getOriginal();
|
||||
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
|
||||
BlockSnapshot original = first.getOriginal();
|
||||
Optional<World> world = SpongeMain.THIS.getServer().getWorld(original.getWorldUniqueId());
|
||||
String worldName = world.get().getName();
|
||||
Location loc = SpongeUtil.getLocation(worldName, original.getPosition());
|
||||
Plot plot = loc.getPlot();
|
||||
if (plot == null) {
|
||||
if (!loc.isPlotArea()) {
|
||||
@ -468,7 +463,7 @@ public class MainListener {
|
||||
} else {
|
||||
MainUtil.sendMessage(pp, C.NO_PERMISSION_EVENT, C.PERMISSION_ADMIN_DESTROY_OTHER);
|
||||
com.google.common.base.Optional<HashSet<PlotBlock>> destroy = plot.getFlag(Flags.BREAK);
|
||||
BlockState state = pos.getState();
|
||||
BlockState state = original.getState();
|
||||
if (!destroy.isPresent() || !destroy.get().contains(SpongeUtil.getPlotBlock(state))) {
|
||||
event.setCancelled(true);
|
||||
return;
|
||||
@ -511,14 +506,10 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
World world = event.getTargetWorld();
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
List<org.spongepowered.api.world.Location<World>> locs = event.getLocations();
|
||||
org.spongepowered.api.world.Location<World> first = locs.get(0);
|
||||
Location loc = SpongeUtil.getLocation(worldName, first);
|
||||
String worldName = first.getExtent().getName();
|
||||
Location loc = SpongeUtil.getLocation(worldName, first.getPosition());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
return;
|
||||
@ -559,14 +550,11 @@ public class MainListener {
|
||||
return;
|
||||
}
|
||||
PlotPlayer pp = SpongeUtil.getPlayer(player);
|
||||
World world = event.getTargetWorld();
|
||||
String worldName = world.getName();
|
||||
if (!PS.get().hasPlotArea(worldName)) {
|
||||
return;
|
||||
}
|
||||
List<Transaction<BlockSnapshot>> transactions = event.getTransactions();
|
||||
Transaction<BlockSnapshot> first = transactions.get(0);
|
||||
BlockSnapshot pos = first.getOriginal();
|
||||
Optional<World> world = SpongeMain.THIS.getServer().getWorld(pos.getWorldUniqueId());
|
||||
String worldName = world.get().getName();
|
||||
Location loc = SpongeUtil.getLocation(worldName, pos.getPosition());
|
||||
PlotArea area = loc.getPlotArea();
|
||||
if (area == null) {
|
||||
|
@ -6,6 +6,7 @@ import com.intellectualcrafters.plot.config.ConfigurationNode;
|
||||
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
||||
import com.intellectualcrafters.plot.object.PlotArea;
|
||||
import com.intellectualcrafters.plot.object.SetupObject;
|
||||
import com.intellectualcrafters.plot.object.worlds.SingleWorldGenerator;
|
||||
import com.intellectualcrafters.plot.util.SetupUtils;
|
||||
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
||||
import java.io.IOException;
|
||||
@ -14,6 +15,7 @@ import java.util.HashMap;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import org.spongepowered.api.Sponge;
|
||||
import org.spongepowered.api.world.DimensionTypes;
|
||||
import org.spongepowered.api.world.GeneratorTypes;
|
||||
@ -31,6 +33,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
return;
|
||||
}
|
||||
SetupUtils.generators.put(PS.imp().getPluginName(), new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator()));
|
||||
SetupUtils.generators.put(PS.imp().getPluginName() + ":single", new SpongePlotGenerator(new SingleWorldGenerator()));
|
||||
// TODO get external world generators
|
||||
Collection<WorldGeneratorModifier> wgms = Sponge.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
||||
for (WorldGeneratorModifier wgm : wgms) {
|
||||
@ -75,12 +78,12 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
String world = object.world;
|
||||
int type = object.type;
|
||||
String worldPath = "worlds." + object.world;
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
switch (type) {
|
||||
case 2: {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
if (object.id != null) {
|
||||
String areaName = object.id + "-" + object.min + "-" + object.max;
|
||||
String areaPath = "areas." + areaName;
|
||||
@ -117,7 +120,11 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
}
|
||||
break;
|
||||
}
|
||||
case 1:
|
||||
case 1: {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
@ -132,11 +139,19 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
object.setupGenerator = null;
|
||||
}
|
||||
break;
|
||||
case 0:
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
case 0: {
|
||||
if (steps.length != 0) {
|
||||
if (!PS.get().worlds.contains(worldPath)) {
|
||||
PS.get().worlds.createSection(worldPath);
|
||||
}
|
||||
ConfigurationSection worldSection = PS.get().worlds.getConfigurationSection(worldPath);
|
||||
for (ConfigurationNode step : steps) {
|
||||
worldSection.set(step.getConstant(), step.getValue());
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
try {
|
||||
PS.get().worlds.save(PS.get().worldsFile);
|
||||
@ -147,6 +162,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
// create world with generator
|
||||
GeneratorWrapper<?> gw = SetupUtils.generators.get(object.setupGenerator);
|
||||
WorldGeneratorModifier wgm = (WorldGeneratorModifier) gw.getPlatformGenerator();
|
||||
System.out.println("GW " + gw + " | " + wgm);
|
||||
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
@ -156,7 +172,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
.usesMapFeatures(false)
|
||||
.enabled(true)
|
||||
.generatorModifiers(wgm)
|
||||
.build("PS",object.world);
|
||||
.build("PS-" + UUID.randomUUID(),object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
@ -168,7 +184,9 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
if (world1.isPresent()) {
|
||||
worldObj = world1.get();
|
||||
}
|
||||
System.out.println("Create normal world");
|
||||
} else {
|
||||
System.out.println("Create vanilla world");
|
||||
// create vanilla world
|
||||
WorldArchetype settings = WorldArchetype.builder()
|
||||
.loadsOnStartup(true)
|
||||
@ -177,7 +195,7 @@ public class SpongeSetupUtils extends SetupUtils {
|
||||
.generator(GeneratorTypes.OVERWORLD)
|
||||
.usesMapFeatures(true)
|
||||
.enabled(true)
|
||||
.build("PS",object.world);
|
||||
.build("PS-" + UUID.randomUUID(),object.world);
|
||||
WorldProperties properties = null;
|
||||
try {
|
||||
properties = Sponge.getServer().createWorldProperties(object.world, settings);
|
||||
|
@ -1,3 +1,3 @@
|
||||
rootProject.name = 'PlotSquared'
|
||||
|
||||
include 'Core', 'Bukkit', 'Nukkit' //,'Sponge'
|
||||
include 'Core', 'Bukkit', 'Nukkit' ,'Sponge'
|
Loading…
Reference in New Issue
Block a user