2015-07-26 18:14:34 +02:00
|
|
|
package com.plotsquared.sponge;
|
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.google.inject.Inject;
|
|
|
|
import com.intellectualcrafters.configuration.ConfigurationSection;
|
|
|
|
import com.intellectualcrafters.plot.IPlotMain;
|
|
|
|
import com.intellectualcrafters.plot.PS;
|
|
|
|
import com.intellectualcrafters.plot.config.C;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.intellectualcrafters.plot.config.ConfigurationNode;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.config.Settings;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.GeneratorWrapper;
|
|
|
|
import com.intellectualcrafters.plot.generator.HybridGen;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.generator.HybridUtils;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.intellectualcrafters.plot.generator.IndependentPlotGenerator;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.object.PlotPlayer;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.intellectualcrafters.plot.object.SetupObject;
|
2016-03-16 15:15:38 +01:00
|
|
|
import com.intellectualcrafters.plot.util.AbstractTitle;
|
|
|
|
import com.intellectualcrafters.plot.util.ChatManager;
|
|
|
|
import com.intellectualcrafters.plot.util.ChunkManager;
|
|
|
|
import com.intellectualcrafters.plot.util.EconHandler;
|
|
|
|
import com.intellectualcrafters.plot.util.EventUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.InventoryUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.MainUtil;
|
|
|
|
import com.intellectualcrafters.plot.util.SchematicHandler;
|
|
|
|
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.intellectualcrafters.plot.util.UUIDHandlerImplementation;
|
|
|
|
import com.intellectualcrafters.plot.util.WorldUtil;
|
2016-06-13 06:47:50 +02:00
|
|
|
import com.intellectualcrafters.plot.util.block.QueueProvider;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.intellectualcrafters.plot.uuid.UUIDWrapper;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.plotsquared.sponge.generator.SpongePlotGenerator;
|
|
|
|
import com.plotsquared.sponge.listener.ChunkProcessor;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.plotsquared.sponge.listener.MainListener;
|
2016-02-19 19:52:26 +01:00
|
|
|
import com.plotsquared.sponge.listener.WorldEvents;
|
2016-03-16 15:15:38 +01:00
|
|
|
import com.plotsquared.sponge.util.KillRoadMobs;
|
|
|
|
import com.plotsquared.sponge.util.SpongeChatManager;
|
|
|
|
import com.plotsquared.sponge.util.SpongeChunkManager;
|
|
|
|
import com.plotsquared.sponge.util.SpongeCommand;
|
|
|
|
import com.plotsquared.sponge.util.SpongeEconHandler;
|
|
|
|
import com.plotsquared.sponge.util.SpongeEventUtil;
|
|
|
|
import com.plotsquared.sponge.util.SpongeHybridUtils;
|
|
|
|
import com.plotsquared.sponge.util.SpongeInventoryUtil;
|
|
|
|
import com.plotsquared.sponge.util.SpongeSchematicHandler;
|
2016-02-22 07:20:22 +01:00
|
|
|
import com.plotsquared.sponge.util.SpongeSetupUtils;
|
2016-03-16 15:15:38 +01:00
|
|
|
import com.plotsquared.sponge.util.SpongeTaskManager;
|
|
|
|
import com.plotsquared.sponge.util.SpongeTitleManager;
|
|
|
|
import com.plotsquared.sponge.util.SpongeUtil;
|
2016-06-13 06:47:50 +02:00
|
|
|
import com.plotsquared.sponge.util.block.SpongeLocalQueue;
|
2015-07-30 16:25:16 +02:00
|
|
|
import com.plotsquared.sponge.uuid.SpongeLowerOfflineUUIDWrapper;
|
|
|
|
import com.plotsquared.sponge.uuid.SpongeOnlineUUIDWrapper;
|
|
|
|
import com.plotsquared.sponge.uuid.SpongeUUIDHandler;
|
2016-07-17 04:51:49 +02:00
|
|
|
import net.minecrell.mcstats.SpongeStatsLite;
|
2016-02-25 10:13:07 +01:00
|
|
|
import org.slf4j.Logger;
|
|
|
|
import org.spongepowered.api.Game;
|
|
|
|
import org.spongepowered.api.Server;
|
|
|
|
import org.spongepowered.api.Sponge;
|
2016-05-26 15:19:38 +02:00
|
|
|
import org.spongepowered.api.config.ConfigDir;
|
2016-02-25 10:13:07 +01:00
|
|
|
import org.spongepowered.api.entity.living.player.Player;
|
|
|
|
import org.spongepowered.api.event.Listener;
|
|
|
|
import org.spongepowered.api.event.game.state.GameAboutToStartServerEvent;
|
2016-07-17 04:51:49 +02:00
|
|
|
import org.spongepowered.api.event.game.state.GamePreInitializationEvent;
|
2016-02-25 10:13:07 +01:00
|
|
|
import org.spongepowered.api.plugin.Plugin;
|
|
|
|
import org.spongepowered.api.plugin.PluginContainer;
|
|
|
|
import org.spongepowered.api.profile.GameProfileManager;
|
|
|
|
import org.spongepowered.api.world.World;
|
|
|
|
import org.spongepowered.api.world.gen.GenerationPopulator;
|
|
|
|
import org.spongepowered.api.world.gen.WorldGenerator;
|
|
|
|
import org.spongepowered.api.world.gen.WorldGeneratorModifier;
|
2016-06-10 19:00:34 +02:00
|
|
|
|
2016-05-21 18:55:06 +02:00
|
|
|
@Plugin(id = "plotsquared", name = "PlotSquared", description = "Easy, yet powerful Plot World generation and management.",
|
2016-07-06 05:39:38 +02:00
|
|
|
url = "https://github.com/IntellectualSites/PlotSquared", version = "3.5.0-SNAPSHOT")
|
2016-02-22 07:20:22 +01:00
|
|
|
public class SpongeMain implements IPlotMain {
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
public static SpongeMain THIS;
|
2016-05-21 16:39:06 +02:00
|
|
|
|
|
|
|
@Inject
|
2016-03-26 20:47:34 +01:00
|
|
|
public PluginContainer plugin;
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
@Inject
|
|
|
|
private Logger logger;
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2015-09-11 12:09:22 +02:00
|
|
|
@Inject
|
|
|
|
private Game game;
|
2016-05-26 15:19:38 +02:00
|
|
|
|
2016-07-17 04:51:49 +02:00
|
|
|
@Inject
|
|
|
|
public SpongeStatsLite stats;
|
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
private Server server;
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2016-05-26 15:19:38 +02:00
|
|
|
@Inject
|
|
|
|
@ConfigDir(sharedRoot = false)
|
|
|
|
private Path privateConfigDir;
|
|
|
|
|
2015-12-19 20:30:06 +01:00
|
|
|
private GameProfileManager resolver;
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2016-07-17 04:51:49 +02:00
|
|
|
private Logger getLogger() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.logger;
|
2015-07-28 13:38:49 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-09-13 06:04:31 +02:00
|
|
|
public Game getGame() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.game;
|
2015-07-28 13:38:49 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-09-13 06:04:31 +02:00
|
|
|
public Server getServer() {
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.server;
|
2015-07-28 13:38:49 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-12-19 20:30:06 +01:00
|
|
|
public GameProfileManager getResolver() {
|
2016-03-23 02:41:37 +01:00
|
|
|
if (this.resolver == null) {
|
|
|
|
this.resolver = this.game.getServer().getGameProfileManager();
|
2016-02-22 07:20:22 +01:00
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
return this.resolver;
|
2015-07-28 13:38:49 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-12-19 20:30:06 +01:00
|
|
|
public SpongeMain getPlugin() {
|
|
|
|
return THIS;
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2016-07-17 04:51:49 +02:00
|
|
|
@Listener
|
|
|
|
public void onPreInitialize(GamePreInitializationEvent event) {
|
|
|
|
getLogger().info("The metrics section in PlotSquared is ignored in favor of the actual metrics reporter configurations.");
|
|
|
|
this.stats.start();
|
|
|
|
}
|
|
|
|
|
2015-10-07 08:33:33 +02:00
|
|
|
@Listener
|
2016-03-23 02:41:37 +01:00
|
|
|
public void onServerAboutToStart(GameAboutToStartServerEvent event) {
|
2015-07-26 18:14:34 +02:00
|
|
|
THIS = this;
|
2016-02-22 07:20:22 +01:00
|
|
|
new PS(this, "Sponge");
|
2016-03-23 02:41:37 +01:00
|
|
|
this.server = this.game.getServer();
|
|
|
|
this.game.getRegistry().register(WorldGeneratorModifier.class, (WorldGeneratorModifier) new HybridGen().specify());
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void log(String message) {
|
2015-07-30 16:25:16 +02:00
|
|
|
message = C.format(message, C.replacements);
|
2016-06-10 19:00:34 +02:00
|
|
|
if (!Settings.Chat.CONSOLE_COLOR) {
|
2015-07-30 16:25:16 +02:00
|
|
|
message = message.replaceAll('\u00a7' + "[a-z|0-9]", "");
|
|
|
|
}
|
2016-03-29 06:56:44 +02:00
|
|
|
if (this.server == null) {
|
2016-03-23 02:41:37 +01:00
|
|
|
this.logger.info(message);
|
2015-07-30 16:25:16 +02:00
|
|
|
return;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
this.server.getConsole().sendMessage(SpongeUtil.getText(message));
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public File getDirectory() {
|
2016-05-26 15:19:38 +02:00
|
|
|
return privateConfigDir.toFile();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-10 07:34:41 +02:00
|
|
|
public File getWorldContainer() {
|
2016-05-21 16:39:06 +02:00
|
|
|
return game.getSavesDirectory().toFile();
|
2015-09-10 07:34:41 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
|
|
|
public void disable() {
|
|
|
|
PS.get().disable();
|
|
|
|
THIS = null;
|
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2016-03-17 17:05:36 +01:00
|
|
|
public int[] getPluginVersion() {
|
2016-05-21 16:39:06 +02:00
|
|
|
String version = this.plugin.getVersion().orElse("");
|
2016-03-23 02:41:37 +01:00
|
|
|
String[] split = version.split("\\.");
|
2016-03-21 03:52:16 +01:00
|
|
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2016-06-24 02:12:17 +02:00
|
|
|
@Override public String getPluginVersionString() {
|
|
|
|
return this.plugin.getVersion().orElse("");
|
|
|
|
}
|
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public int[] getServerVersion() {
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log("Checking minecraft version: Sponge: ");
|
2016-03-23 02:41:37 +01:00
|
|
|
String version = this.game.getPlatform().getMinecraftVersion().getName();
|
|
|
|
String[] split = version.split("\\.");
|
2016-03-21 03:52:16 +01:00
|
|
|
return new int[]{Integer.parseInt(split[0]), Integer.parseInt(split[1]), split.length == 3 ? Integer.parseInt(split[2]) : 0};
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public InventoryUtil initInventoryUtil() {
|
2015-07-30 16:25:16 +02:00
|
|
|
return new SpongeInventoryUtil();
|
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public EconHandler getEconomyHandler() {
|
2016-02-19 19:52:26 +01:00
|
|
|
SpongeEconHandler econ = new SpongeEconHandler();
|
2016-02-22 07:20:22 +01:00
|
|
|
Sponge.getEventManager().registerListeners(this, econ);
|
2016-02-19 19:52:26 +01:00
|
|
|
return econ;
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public EventUtil initEventUtil() {
|
2015-07-30 16:25:16 +02:00
|
|
|
return new SpongeEventUtil();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public ChunkManager initChunkManager() {
|
2015-07-30 16:25:16 +02:00
|
|
|
return new SpongeChunkManager();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public SetupUtils initSetupUtils() {
|
2015-08-02 21:25:41 +02:00
|
|
|
return new SpongeSetupUtils();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public HybridUtils initHybridUtils() {
|
2015-08-02 13:56:18 +02:00
|
|
|
return new SpongeHybridUtils();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public SchematicHandler initSchematicHandler() {
|
2015-08-02 13:56:18 +02:00
|
|
|
return new SpongeSchematicHandler();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public TaskManager getTaskManager() {
|
2016-04-05 18:37:11 +02:00
|
|
|
return new SpongeTaskManager(this);
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void runEntityTask() {
|
2015-07-30 16:25:16 +02:00
|
|
|
new KillRoadMobs().run();
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerCommands() {
|
2016-03-16 15:15:38 +01:00
|
|
|
getGame().getCommandManager().register(THIS, new SpongeCommand(), "plots", "p", "plot", "ps", "plotsquared", "p2", "2");
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerPlayerEvents() {
|
2016-02-22 07:20:22 +01:00
|
|
|
Sponge.getEventManager().registerListeners(this, new MainListener());
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerInventoryEvents() {
|
2016-02-19 19:52:26 +01:00
|
|
|
// Part of PlayerEvents - can be moved if necessary
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerPlotPlusEvents() {
|
2016-05-21 16:45:48 +02:00
|
|
|
PS.log("registerPlotPlusEvents is not implemented!");
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerForceFieldEvents() {
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public boolean initWorldEdit() {
|
|
|
|
try {
|
2015-09-07 14:17:48 +02:00
|
|
|
Class.forName("com.sk89q.worldedit.WorldEdit");
|
|
|
|
return true;
|
2016-05-12 23:09:35 +02:00
|
|
|
} catch (ClassNotFoundException ignored) {
|
2015-09-07 14:17:48 +02:00
|
|
|
return false;
|
|
|
|
}
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public UUIDHandlerImplementation initUUIDHandler() {
|
2015-07-28 13:38:49 +02:00
|
|
|
UUIDWrapper wrapper;
|
2016-06-05 09:28:34 +02:00
|
|
|
if (Settings.UUID.OFFLINE) {
|
2015-07-28 13:38:49 +02:00
|
|
|
wrapper = new SpongeLowerOfflineUUIDWrapper();
|
2015-09-13 06:04:31 +02:00
|
|
|
} else {
|
2015-07-28 13:38:49 +02:00
|
|
|
wrapper = new SpongeOnlineUUIDWrapper();
|
|
|
|
}
|
|
|
|
return new SpongeUUIDHandler(wrapper);
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public boolean initPlotMeConverter() {
|
2015-07-26 18:14:34 +02:00
|
|
|
return false;
|
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public void unregister(PlotPlayer player) {
|
2015-07-30 16:25:16 +02:00
|
|
|
SpongeUtil.removePlayer(player.getName());
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerChunkProcessor() {
|
2016-02-22 07:20:22 +01:00
|
|
|
Sponge.getEventManager().registerListeners(this, new ChunkProcessor());
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-26 18:14:34 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void registerWorldEvents() {
|
2016-02-22 07:20:22 +01:00
|
|
|
Sponge.getEventManager().registerListeners(this, new WorldEvents());
|
2015-07-26 18:14:34 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public void startMetrics() {
|
2015-07-28 08:06:19 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
@Override
|
2016-03-29 21:47:59 +02:00
|
|
|
public void setGenerator(String worldName) {
|
|
|
|
World world = SpongeUtil.getWorld(worldName);
|
2016-02-19 19:52:26 +01:00
|
|
|
if (world == null) {
|
|
|
|
// create world
|
2016-06-05 09:28:34 +02:00
|
|
|
ConfigurationSection worldConfig = PS.get().worlds.getConfigurationSection("worlds." + worldName);
|
2016-03-19 19:07:55 +01:00
|
|
|
String manager = worldConfig.getString("generator.plugin", "PlotSquared");
|
|
|
|
String generator = worldConfig.getString("generator.init", manager);
|
|
|
|
|
2016-03-23 02:41:37 +01:00
|
|
|
int type = worldConfig.getInt("generator.type");
|
|
|
|
int terrain = worldConfig.getInt("generator.terrain");
|
|
|
|
SetupObject setup = new SetupObject();
|
2016-02-19 19:52:26 +01:00
|
|
|
setup.plotManager = manager;
|
|
|
|
setup.setupGenerator = generator;
|
|
|
|
setup.type = type;
|
|
|
|
setup.terrain = terrain;
|
|
|
|
setup.step = new ConfigurationNode[0];
|
2016-03-29 21:47:59 +02:00
|
|
|
setup.world = worldName;
|
2016-02-19 19:52:26 +01:00
|
|
|
SetupUtils.manager.setupWorld(setup);
|
2016-05-19 10:09:12 +02:00
|
|
|
world = SpongeUtil.getWorld(worldName);
|
2016-02-19 19:52:26 +01:00
|
|
|
} else {
|
2016-03-29 21:47:59 +02:00
|
|
|
throw new IllegalArgumentException("World already loaded: " + worldName + "???");
|
2016-02-19 19:52:26 +01:00
|
|
|
}
|
|
|
|
WorldGenerator wg = world.getWorldGenerator();
|
|
|
|
GenerationPopulator gen = wg.getBaseGenerationPopulator();
|
|
|
|
if (gen instanceof SpongePlotGenerator) {
|
2016-03-29 21:47:59 +02:00
|
|
|
PS.get().loadWorld(worldName, (SpongePlotGenerator) gen);
|
2016-02-19 19:52:26 +01:00
|
|
|
} else {
|
2016-03-21 03:52:16 +01:00
|
|
|
throw new UnsupportedOperationException("NOT IMPLEMENTED YET!");
|
2016-02-19 19:52:26 +01:00
|
|
|
}
|
2015-07-30 16:25:16 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-30 16:25:16 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public AbstractTitle initTitleManager() {
|
2015-07-30 16:25:16 +02:00
|
|
|
return new SpongeTitleManager();
|
2015-07-28 08:06:19 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-07-30 19:24:01 +02:00
|
|
|
@Override
|
2016-03-23 02:41:37 +01:00
|
|
|
public PlotPlayer wrapPlayer(Object player) {
|
|
|
|
if (player instanceof Player) {
|
|
|
|
return SpongeUtil.getPlayer((Player) player);
|
|
|
|
} else if (player instanceof String) {
|
|
|
|
return UUIDHandler.getPlayer((String) player);
|
|
|
|
} else if (player instanceof UUID) {
|
|
|
|
return UUIDHandler.getPlayer((UUID) player);
|
2015-07-30 19:24:01 +02:00
|
|
|
}
|
2016-02-19 19:52:26 +01:00
|
|
|
// TODO FIXME offline player
|
2015-07-30 19:24:01 +02:00
|
|
|
return null;
|
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-08-03 20:20:04 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public String getNMSPackage() {
|
2016-02-22 07:20:22 +01:00
|
|
|
return "";//TODO FIXME
|
2015-08-03 20:20:04 +02:00
|
|
|
}
|
2015-11-26 04:40:22 +01:00
|
|
|
|
2015-08-24 18:28:32 +02:00
|
|
|
@Override
|
2015-09-13 06:04:31 +02:00
|
|
|
public ChatManager<?> initChatManager() {
|
2015-08-24 18:28:32 +02:00
|
|
|
return new SpongeChatManager();
|
|
|
|
}
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2016-02-19 19:52:26 +01:00
|
|
|
@Override
|
2016-06-13 06:47:50 +02:00
|
|
|
public QueueProvider initBlockQueue() {
|
|
|
|
MainUtil.canSendChunk = true;
|
|
|
|
return QueueProvider.of(SpongeLocalQueue.class, null);
|
2016-02-19 19:52:26 +01:00
|
|
|
}
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2016-02-19 19:52:26 +01:00
|
|
|
@Override
|
|
|
|
public WorldUtil initWorldUtil() {
|
2016-02-19 20:55:49 +01:00
|
|
|
return new SpongeUtil();
|
2016-02-19 19:52:26 +01:00
|
|
|
}
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2016-02-19 19:52:26 +01:00
|
|
|
@Override
|
|
|
|
public GeneratorWrapper<?> getGenerator(String world, String name) {
|
|
|
|
if (name == null) {
|
|
|
|
return null;
|
|
|
|
}
|
2016-03-23 02:41:37 +01:00
|
|
|
Collection<WorldGeneratorModifier> wgms = this.game.getRegistry().getAllOf(WorldGeneratorModifier.class);
|
2016-02-19 19:52:26 +01:00
|
|
|
for (WorldGeneratorModifier wgm : wgms) {
|
|
|
|
if (StringMan.isEqualIgnoreCaseToAny(name, wgm.getName(), wgm.getId())) {
|
|
|
|
if (wgm instanceof GeneratorWrapper<?>) {
|
|
|
|
return (GeneratorWrapper<?>) wgm;
|
|
|
|
}
|
|
|
|
return new SpongePlotGenerator(wgm);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return new SpongePlotGenerator(new HybridGen());
|
|
|
|
}
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2016-02-19 19:52:26 +01:00
|
|
|
@Override
|
|
|
|
public GeneratorWrapper<?> wrapPlotGenerator(IndependentPlotGenerator generator) {
|
|
|
|
return new SpongePlotGenerator(generator);
|
|
|
|
}
|
2016-05-21 16:39:06 +02:00
|
|
|
|
2016-02-19 19:52:26 +01:00
|
|
|
@Override
|
|
|
|
public List<String> getPluginIds() {
|
2016-05-12 23:09:35 +02:00
|
|
|
return this.game.getPluginManager().getPlugins().stream().map(plugin1 -> plugin1.getName() + ';' + plugin1.getVersion() + ':' + true)
|
|
|
|
.collect(Collectors.toCollection(ArrayList::new));
|
2016-02-19 19:52:26 +01:00
|
|
|
}
|
2015-09-11 12:09:22 +02:00
|
|
|
}
|