Refactor PS (and rename to PlotSquared)

This commit is contained in:
sauilitired
2018-11-14 14:19:56 +01:00
parent 16dbbe5244
commit 8df7f63931
133 changed files with 1122 additions and 1137 deletions

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.sponge;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.IPlotMain;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.config.Settings;
@ -105,10 +105,10 @@ public class SpongeMain implements IPlotMain {
@Listener public void onServerAboutToStart(GameAboutToStartServerEvent event) {
THIS = this;
new PS(this, "Sponge");
new PlotSquared(this, "Sponge");
this.server = this.game.getServer();
this.game.getRegistry().register(WorldGeneratorModifier.class,
(WorldGeneratorModifier) PS.get().IMP.getDefaultGenerator().specify(null));
(WorldGeneratorModifier) PlotSquared.get().IMP.getDefaultGenerator().specify(null));
this.game.getRegistry().register(WorldGeneratorModifier.class,
(WorldGeneratorModifier) new SingleWorldGenerator().specify(null));
if (Settings.Enabled_Components.WORLDS) {
@ -121,7 +121,7 @@ public class SpongeMain implements IPlotMain {
}
public void unload() {
PlotAreaManager manager = PS.get().getPlotAreaManager();
PlotAreaManager manager = PlotSquared.get().getPlotAreaManager();
if (manager instanceof SinglePlotAreaManager) {
SinglePlotArea area = ((SinglePlotAreaManager) manager).getArea();
for (World world : Sponge.getServer().getWorlds()) {
@ -175,7 +175,7 @@ public class SpongeMain implements IPlotMain {
}
@Override public void disable() {
PS.get().disable();
PlotSquared.get().disable();
THIS = null;
}
@ -195,7 +195,7 @@ public class SpongeMain implements IPlotMain {
}
@Override public int[] getServerVersion() {
PS.log("Checking minecraft version: Sponge: ");
PlotSquared.log("Checking minecraft version: Sponge: ");
String version = this.game.getPlatform().getMinecraftVersion().getName();
String[] split = version.split("\\.");
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
@ -255,7 +255,7 @@ public class SpongeMain implements IPlotMain {
}
@Override public void registerPlotPlusEvents() {
PS.log("registerPlotPlusEvents is not implemented!");
PlotSquared.log("registerPlotPlusEvents is not implemented!");
}
@Override public void registerForceFieldEvents() {
@ -304,7 +304,7 @@ public class SpongeMain implements IPlotMain {
if (world == null) {
// create world
ConfigurationSection worldConfig =
PS.get().worlds.getConfigurationSection("worlds." + worldName);
PlotSquared.get().worlds.getConfigurationSection("worlds." + worldName);
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
String generator = worldConfig.getString("generator.init", manager);
@ -325,7 +325,7 @@ public class SpongeMain implements IPlotMain {
WorldGenerator wg = world.getWorldGenerator();
GenerationPopulator gen = wg.getBaseGenerationPopulator();
if (gen instanceof GeneratorWrapper) {
PS.get().loadWorld(worldName, (GeneratorWrapper) gen);
PlotSquared.get().loadWorld(worldName, (GeneratorWrapper) gen);
} else {
throw new UnsupportedOperationException(
"NOT IMPLEMENTED YET2! " + worldName + " | " + gen);
@ -381,7 +381,7 @@ public class SpongeMain implements IPlotMain {
return new SpongePlotGenerator(wgm);
}
}
return new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator());
return new SpongePlotGenerator(PlotSquared.get().IMP.getDefaultGenerator());
}
@Override

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.sponge.generator;
import com.flowpowered.math.vector.Vector3i;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -73,7 +73,7 @@ public class SpongePlotGenerator
worldGenerator.setBaseGenerationPopulator(new SpongeTerrainGen(this.plotGenerator));
worldGenerator.setBiomeGenerator(new BiomeGenerator() {
@Override public void generateBiomes(MutableBiomeVolume buffer) {
PlotArea area = PS.get().getPlotArea(worldName, null);
PlotArea area = PlotSquared.get().getPlotArea(worldName, null);
if (area != null) {
BiomeType biome = SpongeUtil.getBiome(area.PLOT_BIOME);
Vector3i min = buffer.getBiomeMin();
@ -94,7 +94,7 @@ public class SpongePlotGenerator
}
worldGenerator.getGenerationPopulators().clear();
worldGenerator.getPopulators().clear();
PS.get().loadWorld(worldName, this);
PlotSquared.get().loadWorld(worldName, this);
}
@Override public IndependentPlotGenerator getPlotGenerator() {

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.sponge.generator;
import com.flowpowered.math.vector.Vector3i;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.generator.IndependentPlotGenerator;
import com.github.intellectualsites.plotsquared.plot.object.ChunkWrapper;
@ -66,7 +66,7 @@ public class SpongeTerrainGen
return;
}
// Fill the result data
PlotArea area = PS.get().getPlotArea(world.getName(), null);
PlotArea area = PlotSquared.get().getPlotArea(world.getName(), null);
child.generateChunk(result, area, random);
child.populateChunk(result, area, random);
ChunkManager.postProcessChunk(result);

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.sponge.listener;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.flag.Flags;
import com.github.intellectualsites.plotsquared.plot.listener.PlotListener;
@ -74,10 +74,10 @@ import java.util.function.Predicate;
return;
}
String world = player.getWorld().getName();
if (!PS.get().hasPlotArea(world)) {
if (!PlotSquared.get().hasPlotArea(world)) {
return;
}
PlotArea plotworld = PS.get().getPlotAreaByString(world);
PlotArea plotworld = PlotSquared.get().getPlotAreaByString(world);
PlotPlayer plr = SpongeUtil.getPlayer(player);
if (!plotworld.PLOT_CHAT && (plr.getMeta("chat") == null || !(Boolean) plr
.getMeta("chat"))) {
@ -128,7 +128,7 @@ import java.util.function.Predicate;
@Listener public void onBreedEntity(BreedEntityEvent.Breed event) {
Location loc = SpongeUtil.getLocation(event.getTargetEntity());
String world = loc.getWorld();
PlotArea plotworld = PS.get().getPlotAreaByString(world);
PlotArea plotworld = PlotSquared.get().getPlotAreaByString(world);
if (plotworld == null) {
return;
}
@ -339,7 +339,7 @@ import java.util.function.Predicate;
ExplosionEvent.Detonate event = (Detonate) e;
World world = event.getTargetWorld();
String worldName = world.getName();
if (!PS.get().hasPlotArea(worldName)) {
if (!PlotSquared.get().hasPlotArea(worldName)) {
return;
}
Optional<Explosive> source = event.getExplosion().getSourceExplosive();

View File

@ -1,6 +1,6 @@
package com.github.intellectualsites.plotsquared.sponge.listener;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import org.spongepowered.api.event.Listener;
import org.spongepowered.api.event.world.LoadWorldEvent;
@ -17,9 +17,9 @@ public class WorldEvents {
GenerationPopulator terrain = generator.getBaseGenerationPopulator();
if (terrain instanceof GeneratorWrapper) {
GeneratorWrapper stg = (GeneratorWrapper) terrain;
PS.get().loadWorld(name, stg);
PlotSquared.get().loadWorld(name, stg);
} else {
PS.get().loadWorld(name, null);
PlotSquared.get().loadWorld(name, null);
}
}
}

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.sponge.object;
import com.flowpowered.math.vector.Vector3d;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.commands.RequiredType;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotPlayer;
@ -118,7 +118,7 @@ public class SpongePlayer extends PlotPlayer {
target.get()
.set(Keys.TARGETED_LOCATION, SpongeUtil.getLocation(location).getPosition());
} else {
PS.debug("Failed to set compass target.");
PlotSquared.debug("Failed to set compass target.");
}
}

View File

@ -28,7 +28,7 @@ package com.github.intellectualsites.plotsquared.sponge.util;
* either expressed or implied, of anybody else.
*/
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.google.inject.Inject;
import ninja.leaping.configurate.commented.CommentedConfigurationNode;
import ninja.leaping.configurate.hocon.HoconConfigurationLoader;
@ -310,7 +310,7 @@ public class SpongeMetrics {
firstPost = false;
} catch (final IOException e) {
if (debug) {
PS.debug("[Metrics] " + e.getMessage());
PlotSquared.debug("[Metrics] " + e.getMessage());
}
}
}
@ -467,7 +467,7 @@ public class SpongeMetrics {
connection.setDoOutput(true);
if (debug) {
PS.debug("[Metrics] Prepared request for " + pluginName + " uncompressed="
PlotSquared.debug("[Metrics] Prepared request for " + pluginName + " uncompressed="
+ uncompressed.length + " compressed=" + compressed.length);
}

View File

@ -1,7 +1,7 @@
package com.github.intellectualsites.plotsquared.sponge.util;
import com.github.intellectualsites.plotsquared.configuration.ConfigurationSection;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.ConfigurationNode;
import com.github.intellectualsites.plotsquared.plot.generator.GeneratorWrapper;
import com.github.intellectualsites.plotsquared.plot.object.PlotArea;
@ -28,9 +28,9 @@ public class SpongeSetupUtils extends SetupUtils {
if (!SetupUtils.generators.isEmpty()) {
return;
}
SetupUtils.generators.put(PS.imp().getPluginName(),
new SpongePlotGenerator(PS.get().IMP.getDefaultGenerator()));
SetupUtils.generators.put(PS.imp().getPluginName() + ":single",
SetupUtils.generators.put(PlotSquared.imp().getPluginName(),
new SpongePlotGenerator(PlotSquared.get().IMP.getDefaultGenerator()));
SetupUtils.generators.put(PlotSquared.imp().getPluginName() + ":single",
new SpongePlotGenerator(new SingleWorldGenerator()));
// TODO get external world generators
Collection<WorldGeneratorModifier> wgms =
@ -76,11 +76,11 @@ public class SpongeSetupUtils extends SetupUtils {
String worldPath = "worlds." + object.world;
switch (type) {
case 2: {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PS.get().worlds.getConfigurationSection(worldPath);
PlotSquared.get().worlds.getConfigurationSection(worldPath);
if (object.id != null) {
String areaName = object.id + "-" + object.min + "-" + object.max;
String areaPath = "areas." + areaName;
@ -120,20 +120,20 @@ public class SpongeSetupUtils extends SetupUtils {
break;
}
case 1: {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PS.get().worlds.getConfigurationSection(worldPath);
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
PS.get().worlds.set("worlds." + world + ".generator.type", object.type);
PS.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
PS.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
PlotSquared.get().worlds.set("worlds." + world + ".generator.type", object.type);
PlotSquared.get().worlds.set("worlds." + world + ".generator.terrain", object.terrain);
PlotSquared.get().worlds.set("worlds." + world + ".generator.plugin", object.plotManager);
if (object.setupGenerator != null && !object.setupGenerator
.equals(object.plotManager)) {
PS.get().worlds
PlotSquared.get().worlds
.set("worlds." + world + ".generator.init", object.setupGenerator);
}
GeneratorWrapper<?> gen = SetupUtils.generators.get(object.setupGenerator);
@ -144,11 +144,11 @@ public class SpongeSetupUtils extends SetupUtils {
}
case 0: {
if (steps.length != 0) {
if (!PS.get().worlds.contains(worldPath)) {
PS.get().worlds.createSection(worldPath);
if (!PlotSquared.get().worlds.contains(worldPath)) {
PlotSquared.get().worlds.createSection(worldPath);
}
ConfigurationSection worldSection =
PS.get().worlds.getConfigurationSection(worldPath);
PlotSquared.get().worlds.getConfigurationSection(worldPath);
for (ConfigurationNode step : steps) {
worldSection.set(step.getConstant(), step.getValue());
}
@ -157,7 +157,7 @@ public class SpongeSetupUtils extends SetupUtils {
}
}
try {
PS.get().worlds.save(PS.get().worldsFile);
PlotSquared.get().worlds.save(PlotSquared.get().worldsFile);
} catch (IOException e) {
e.printStackTrace();
}

View File

@ -2,7 +2,7 @@ package com.github.intellectualsites.plotsquared.sponge.util;
import com.flowpowered.math.vector.Vector3d;
import com.flowpowered.math.vector.Vector3i;
import com.github.intellectualsites.plotsquared.plot.PS;
import com.github.intellectualsites.plotsquared.plot.PlotSquared;
import com.github.intellectualsites.plotsquared.plot.config.C;
import com.github.intellectualsites.plotsquared.plot.object.Location;
import com.github.intellectualsites.plotsquared.plot.object.PlotBlock;
@ -335,7 +335,7 @@ public class SpongeUtil extends WorldUtil {
SpongeUtil.getWorld(worldName).save();
} catch (IOException e) {
e.printStackTrace();
PS.debug("Failed to save world.");
PlotSquared.debug("Failed to save world.");
}
}