mirror of
https://github.com/IntellectualSites/PlotSquared.git
synced 2024-11-22 05:06:44 +01:00
Guice progress
This commit is contained in:
parent
55bf41d2da
commit
c0f69f321d
@ -99,12 +99,15 @@ shadowJar {
|
|||||||
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
include(dependency("org.bstats:bstats-bukkit:1.7"))
|
||||||
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
include(dependency("org.khelekore:prtree:1.7.0-SNAPSHOT"))
|
||||||
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
|
include(dependency("com.sk89q:squirrelid:1.0.0-SNAPSHOT"))
|
||||||
|
include(dependency("com.google.inject:guice:4.2.3"))
|
||||||
|
include(dependency("com.google.inject.extensions:guice-assistedinject:4.2.3"))
|
||||||
}
|
}
|
||||||
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
|
relocate('net.kyori.text', 'com.plotsquared.formatting.text')
|
||||||
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
relocate("io.papermc.lib", "com.plotsquared.bukkit.paperlib")
|
||||||
relocate("org.bstats", "com.plotsquared.metrics")
|
relocate("org.bstats", "com.plotsquared.metrics")
|
||||||
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
relocate('com.sk89q.squirrelid', 'com.plotsquared.squirrelid')
|
||||||
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
|
relocate('org.khelekore.prtree', 'com.plotsquared.prtree')
|
||||||
|
relocate('com.google', 'com.plotsquared.google')
|
||||||
archiveFileName = "${project.name}-${parent.version}.jar"
|
archiveFileName = "${project.name}-${parent.version}.jar"
|
||||||
destinationDirectory = file "../target"
|
destinationDirectory = file "../target"
|
||||||
}
|
}
|
||||||
|
@ -25,29 +25,24 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit;
|
package com.plotsquared.bukkit;
|
||||||
|
|
||||||
import com.plotsquared.bukkit.generator.BukkitHybridUtils;
|
import com.google.inject.Guice;
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Key;
|
||||||
|
import com.google.inject.Stage;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
|
import com.plotsquared.bukkit.inject.BackupModule;
|
||||||
|
import com.plotsquared.bukkit.inject.BukkitModule;
|
||||||
|
import com.plotsquared.bukkit.inject.WorldManagerModule;
|
||||||
import com.plotsquared.bukkit.listener.ChunkListener;
|
import com.plotsquared.bukkit.listener.ChunkListener;
|
||||||
import com.plotsquared.bukkit.listener.EntitySpawnListener;
|
import com.plotsquared.bukkit.listener.EntitySpawnListener;
|
||||||
import com.plotsquared.bukkit.listener.PaperListener;
|
import com.plotsquared.bukkit.listener.PaperListener;
|
||||||
import com.plotsquared.bukkit.listener.PlayerEvents;
|
import com.plotsquared.bukkit.listener.PlayerEvents;
|
||||||
import com.plotsquared.bukkit.listener.SingleWorldListener;
|
import com.plotsquared.bukkit.listener.SingleWorldListener;
|
||||||
import com.plotsquared.bukkit.listener.WorldEvents;
|
import com.plotsquared.bukkit.listener.WorldEvents;
|
||||||
import com.plotsquared.bukkit.managers.BukkitWorldManager;
|
|
||||||
import com.plotsquared.bukkit.managers.HyperverseWorldManager;
|
|
||||||
import com.plotsquared.bukkit.managers.MultiverseWorldManager;
|
|
||||||
import com.plotsquared.bukkit.placeholder.PlaceholderFormatter;
|
import com.plotsquared.bukkit.placeholder.PlaceholderFormatter;
|
||||||
import com.plotsquared.bukkit.placeholder.Placeholders;
|
import com.plotsquared.bukkit.placeholder.Placeholders;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
|
|
||||||
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitChatManager;
|
import com.plotsquared.bukkit.util.BukkitChatManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitPermHandler;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitRegionManager;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
|
||||||
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
import com.plotsquared.bukkit.util.BukkitTaskManager;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.BukkitWorld;
|
import com.plotsquared.bukkit.util.BukkitWorld;
|
||||||
@ -63,8 +58,8 @@ import com.plotsquared.bukkit.uuid.SquirrelIdUUIDService;
|
|||||||
import com.plotsquared.core.PlotPlatform;
|
import com.plotsquared.core.PlotPlatform;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.backup.NullBackupManager;
|
import com.plotsquared.core.command.WE_Anywhere;
|
||||||
import com.plotsquared.core.backup.SimpleBackupManager;
|
import com.plotsquared.core.components.ComponentPresetManager;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ChatFormatter;
|
import com.plotsquared.core.configuration.ChatFormatter;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
@ -73,11 +68,16 @@ import com.plotsquared.core.configuration.Settings;
|
|||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||||
import com.plotsquared.core.generator.HybridGen;
|
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
|
import com.plotsquared.core.inject.annotations.BackgroundPipeline;
|
||||||
|
import com.plotsquared.core.inject.annotations.DefaultGenerator;
|
||||||
|
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
|
||||||
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
|
import com.plotsquared.core.inject.modules.PlotSquaredModule;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
|
import com.plotsquared.core.listener.WESubscriber;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
@ -88,23 +88,18 @@ import com.plotsquared.core.plot.message.PlainChatManager;
|
|||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.QueueProvider;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.setup.PlotAreaBuilder;
|
import com.plotsquared.core.setup.PlotAreaBuilder;
|
||||||
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
import com.plotsquared.core.setup.SettingsNodesWrapper;
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
|
||||||
import com.plotsquared.core.util.ConsoleColors;
|
import com.plotsquared.core.util.ConsoleColors;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.PermHandler;
|
import com.plotsquared.core.util.PermHandler;
|
||||||
import com.plotsquared.core.util.PlatformWorldManager;
|
import com.plotsquared.core.util.PlatformWorldManager;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
|
||||||
import com.plotsquared.core.util.PremiumVerification;
|
import com.plotsquared.core.util.PremiumVerification;
|
||||||
import com.plotsquared.core.util.ReflectionUtils;
|
import com.plotsquared.core.util.ReflectionUtils;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
@ -113,8 +108,6 @@ import com.plotsquared.core.uuid.CacheUUIDService;
|
|||||||
import com.plotsquared.core.uuid.UUIDPipeline;
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
|
import com.plotsquared.core.uuid.offline.OfflineModeUUIDService;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import io.papermc.lib.PaperLib;
|
import io.papermc.lib.PaperLib;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
@ -125,7 +118,6 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
import org.bukkit.OfflinePlayer;
|
import org.bukkit.OfflinePlayer;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.command.ConsoleCommandSender;
|
|
||||||
import org.bukkit.command.PluginCommand;
|
import org.bukkit.command.PluginCommand;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
@ -162,10 +154,9 @@ import static com.plotsquared.core.util.PremiumVerification.getResourceID;
|
|||||||
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
import static com.plotsquared.core.util.PremiumVerification.getUserID;
|
||||||
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
import static com.plotsquared.core.util.ReflectionUtils.getRefClass;
|
||||||
|
|
||||||
public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
|
@SuppressWarnings("unused") public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPlatform<Player> {
|
||||||
|
|
||||||
private static final int BSTATS_ID = 1404;
|
private static final int BSTATS_ID = 1404;
|
||||||
@Getter private static WorldEdit worldEdit;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
try {
|
try {
|
||||||
@ -180,17 +171,21 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
private Method methodUnloadChunk0;
|
private Method methodUnloadChunk0;
|
||||||
private boolean methodUnloadSetup = false;
|
private boolean methodUnloadSetup = false;
|
||||||
private boolean metricsStarted;
|
private boolean metricsStarted;
|
||||||
@Getter private BackupManager backupManager;
|
|
||||||
@Getter private PlatformWorldManager<World> worldManager;
|
|
||||||
private BukkitPlayerManager playerManager;
|
|
||||||
private EconHandler econ;
|
private EconHandler econ;
|
||||||
private PermHandler perm;
|
private PermHandler perm;
|
||||||
|
|
||||||
|
@Getter private Injector injector;
|
||||||
|
|
||||||
private PlotAreaManager plotAreaManager;
|
private PlotAreaManager plotAreaManager;
|
||||||
private EventDispatcher eventDispatcher;
|
private EventDispatcher eventDispatcher;
|
||||||
private PlotListener plotListener;
|
private PlotListener plotListener;
|
||||||
private YamlConfiguration worldConfiguration;
|
@WorldConfig private YamlConfiguration worldConfiguration;
|
||||||
private File worldfile;
|
@WorldFile private File worldfile;
|
||||||
|
private BukkitPlayerManager playerManager;
|
||||||
|
private BackupManager backupManager;
|
||||||
|
@ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
||||||
|
@BackgroundPipeline private UUIDPipeline backgroundPipeline;
|
||||||
|
private PlatformWorldManager<World> worldManager;
|
||||||
|
|
||||||
@Override public int[] getServerVersion() {
|
@Override public int[] getServerVersion() {
|
||||||
if (this.version == null) {
|
if (this.version == null) {
|
||||||
@ -219,17 +214,13 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
@Override public void onEnable() {
|
@Override public void onEnable() {
|
||||||
this.pluginName = getDescription().getName();
|
this.pluginName = getDescription().getName();
|
||||||
|
|
||||||
|
// Stuff that needs to be created before the PlotSquared instance
|
||||||
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
PlotPlayer.registerConverter(Player.class, BukkitUtil::getPlayer);
|
||||||
|
TaskManager.setImplementation(new BukkitTaskManager(this));
|
||||||
|
|
||||||
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
final PlotSquared plotSquared = new PlotSquared(this, "Bukkit");
|
||||||
|
|
||||||
this.plotAreaManager = plotSquared.getPlotAreaManager();
|
|
||||||
this.eventDispatcher = plotSquared.getEventDispatcher();
|
|
||||||
this.plotListener = plotSquared.getPlotListener();
|
|
||||||
this.playerManager = new BukkitPlayerManager(this.plotAreaManager, this.eventDispatcher);
|
|
||||||
this.worldConfiguration = plotSquared.getWorldConfiguration();
|
|
||||||
this.worldfile = plotSquared.getWorldsFile();
|
|
||||||
|
|
||||||
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
if (PlotSquared.platform().getServerVersion()[1] < 13) {
|
||||||
System.out.println(
|
System.out.println(
|
||||||
"You can't use this version of PlotSquared on a server less than Minecraft 1.13.2.");
|
"You can't use this version of PlotSquared on a server less than Minecraft 1.13.2.");
|
||||||
@ -240,8 +231,14 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// We create the injector after PlotSquared has been initialized, so that we have access
|
||||||
|
// to generated instances and settings
|
||||||
|
this.injector = Guice.createInjector(Stage.PRODUCTION, new PlotSquaredModule(),
|
||||||
|
new BukkitModule(this), new BackupModule(), new WorldManagerModule());
|
||||||
|
this.injector.injectMembers(this);
|
||||||
|
|
||||||
if (PremiumVerification.isPremium() && Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
|
if (PremiumVerification.isPremium() && Settings.Enabled_Components.UPDATE_NOTIFICATIONS) {
|
||||||
new UpdateUtility(this).updateChecker();
|
injector.getInstance(UpdateUtility.class).updateChecker();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (PremiumVerification.isPremium()) {
|
if (PremiumVerification.isPremium()) {
|
||||||
@ -255,29 +252,121 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
|
PlotSquared.log(Captions.PREFIX + "&6Couldn't verify purchase :(");
|
||||||
}
|
}
|
||||||
|
|
||||||
final UUIDPipeline impromptuPipeline = PlotSquared.get().getImpromptuUUIDPipeline();
|
// Do stuff that was previously done in PlotSquared
|
||||||
final UUIDPipeline backgroundPipeline = PlotSquared.get().getBackgroundUUIDPipeline();
|
// Kill entities
|
||||||
|
if (Settings.Enabled_Components.KILL_ROAD_MOBS
|
||||||
|
|| Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
||||||
|
this.runEntityTask();
|
||||||
|
}
|
||||||
|
|
||||||
|
// WorldEdit
|
||||||
|
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
||||||
|
try {
|
||||||
|
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.getPluginName()
|
||||||
|
+ " hooked into WorldEdit.");
|
||||||
|
WorldEdit.getInstance().getEventBus().register(this.getInjector().getInstance(WESubscriber.class));
|
||||||
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
|
new WE_Anywhere();
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
PlotSquared.debug(
|
||||||
|
"Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.Enabled_Components.EVENTS) {
|
||||||
|
getServer().getPluginManager().registerEvents(getInjector().getInstance(PlayerEvents.class), this);
|
||||||
|
getServer().getPluginManager().registerEvents(getInjector().getInstance(EntitySpawnListener.class), this);
|
||||||
|
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
||||||
|
getServer().getPluginManager().registerEvents(getInjector().getInstance(PaperListener.class), this);
|
||||||
|
}
|
||||||
|
this.plotListener.startRunnable();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Required
|
||||||
|
getServer().getPluginManager().registerEvents(getInjector().getInstance(WorldEvents.class), this);
|
||||||
|
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
||||||
|
getServer().getPluginManager().registerEvents(getInjector().getInstance(ChunkListener.class), this);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Start the global block queue
|
||||||
|
final GlobalBlockQueue globalBlockQueue = this.injector.getInstance(GlobalBlockQueue.class);
|
||||||
|
globalBlockQueue.runTask();
|
||||||
|
|
||||||
|
// Commands
|
||||||
|
if (Settings.Enabled_Components.COMMANDS) {
|
||||||
|
this.registerCommands();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Economy
|
||||||
|
if (Settings.Enabled_Components.ECONOMY) {
|
||||||
|
TaskManager.runTask(() -> {
|
||||||
|
getInjector().getInstance(PermHandler.class).init();
|
||||||
|
getInjector().getInstance(EconHandler.class).init();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Settings.Enabled_Components.COMPONENT_PRESETS) {
|
||||||
|
try {
|
||||||
|
new ComponentPresetManager();
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log(Captions.PREFIX + "Failed to initialize the preset system");
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// World generators:
|
||||||
|
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
||||||
|
final WorldUtil worldUtil = getInjector().getInstance(WorldUtil.class);
|
||||||
|
|
||||||
|
if (section != null) {
|
||||||
|
for (String world : section.getKeys(false)) {
|
||||||
|
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (worldUtil.isWorld(world)) {
|
||||||
|
this.setGenerator(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
TaskManager.runTaskLater(() -> {
|
||||||
|
for (String world : section.getKeys(false)) {
|
||||||
|
if (world.equals("CheckingPlotSquaredGenerator")) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
if (!worldUtil.isWorld(world) && !world.equals("*")) {
|
||||||
|
PlotSquared.debug("`" + world + "` was not properly loaded - " + this.getPluginName()
|
||||||
|
+ " will now try to load it properly: ");
|
||||||
|
PlotSquared.debug(
|
||||||
|
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
||||||
|
PlotSquared.debug(
|
||||||
|
" - Your world management plugin may be faulty (or non existent)");
|
||||||
|
PlotSquared.debug(
|
||||||
|
" This message may also be a false positive and could be ignored.");
|
||||||
|
this.setGenerator(world);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}, 1);
|
||||||
|
}
|
||||||
|
|
||||||
// Services are accessed in order
|
// Services are accessed in order
|
||||||
final CacheUUIDService cacheUUIDService =
|
final CacheUUIDService cacheUUIDService = new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE);
|
||||||
new CacheUUIDService(Settings.UUID.UUID_CACHE_SIZE);
|
this.impromptuPipeline.registerService(cacheUUIDService);
|
||||||
impromptuPipeline.registerService(cacheUUIDService);
|
this.backgroundPipeline.registerService(cacheUUIDService);
|
||||||
backgroundPipeline.registerService(cacheUUIDService);
|
this.impromptuPipeline.registerConsumer(cacheUUIDService);
|
||||||
impromptuPipeline.registerConsumer(cacheUUIDService);
|
this.backgroundPipeline.registerConsumer(cacheUUIDService);
|
||||||
backgroundPipeline.registerConsumer(cacheUUIDService);
|
|
||||||
|
|
||||||
// Now, if the server is in offline mode we can only use profiles and direct UUID
|
// Now, if the server is in offline mode we can only use profiles and direct UUID
|
||||||
// access, and so we skip the player profile stuff as well as SquirrelID (Mojang lookups)
|
// access, and so we skip the player profile stuff as well as SquirrelID (Mojang lookups)
|
||||||
if (Settings.UUID.OFFLINE) {
|
if (Settings.UUID.OFFLINE) {
|
||||||
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
|
final OfflineModeUUIDService offlineModeUUIDService = new OfflineModeUUIDService();
|
||||||
impromptuPipeline.registerService(offlineModeUUIDService);
|
this.impromptuPipeline.registerService(offlineModeUUIDService);
|
||||||
backgroundPipeline.registerService(offlineModeUUIDService);
|
this.backgroundPipeline.registerService(offlineModeUUIDService);
|
||||||
PlotSquared.log(Captions.PREFIX + "(UUID) Using the offline mode UUID service");
|
PlotSquared.log(Captions.PREFIX + "(UUID) Using the offline mode UUID service");
|
||||||
}
|
}
|
||||||
|
|
||||||
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
final OfflinePlayerUUIDService offlinePlayerUUIDService = new OfflinePlayerUUIDService();
|
||||||
impromptuPipeline.registerService(offlinePlayerUUIDService);
|
this.impromptuPipeline.registerService(offlinePlayerUUIDService);
|
||||||
backgroundPipeline.registerService(offlinePlayerUUIDService);
|
this.backgroundPipeline.registerService(offlinePlayerUUIDService);
|
||||||
|
|
||||||
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService("user_cache.db");
|
final SQLiteUUIDService sqLiteUUIDService = new SQLiteUUIDService("user_cache.db");
|
||||||
|
|
||||||
@ -320,64 +409,64 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
// If running Paper we'll also try to use their profiles
|
// If running Paper we'll also try to use their profiles
|
||||||
if (PaperLib.isPaper()) {
|
if (PaperLib.isPaper()) {
|
||||||
final PaperUUIDService paperUUIDService = new PaperUUIDService();
|
final PaperUUIDService paperUUIDService = new PaperUUIDService();
|
||||||
impromptuPipeline.registerService(paperUUIDService);
|
this.impromptuPipeline.registerService(paperUUIDService);
|
||||||
backgroundPipeline.registerService(paperUUIDService);
|
this.backgroundPipeline.registerService(paperUUIDService);
|
||||||
PlotSquared
|
PlotSquared
|
||||||
.log(Captions.PREFIX + "(UUID) Using Paper as a complementary UUID service");
|
.log(Captions.PREFIX + "(UUID) Using Paper as a complementary UUID service");
|
||||||
}
|
}
|
||||||
|
|
||||||
impromptuPipeline.registerService(sqLiteUUIDService);
|
this.impromptuPipeline.registerService(sqLiteUUIDService);
|
||||||
backgroundPipeline.registerService(sqLiteUUIDService);
|
this.backgroundPipeline.registerService(sqLiteUUIDService);
|
||||||
impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
this.impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
this.backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
|
|
||||||
if (legacyUUIDService != null) {
|
if (legacyUUIDService != null) {
|
||||||
impromptuPipeline.registerService(legacyUUIDService);
|
this.impromptuPipeline.registerService(legacyUUIDService);
|
||||||
backgroundPipeline.registerService(legacyUUIDService);
|
this.backgroundPipeline.registerService(legacyUUIDService);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Plugin providers
|
// Plugin providers
|
||||||
if (luckPermsUUIDService != null) {
|
if (luckPermsUUIDService != null) {
|
||||||
impromptuPipeline.registerService(luckPermsUUIDService);
|
this.impromptuPipeline.registerService(luckPermsUUIDService);
|
||||||
backgroundPipeline.registerService(luckPermsUUIDService);
|
this.backgroundPipeline.registerService(luckPermsUUIDService);
|
||||||
}
|
}
|
||||||
if (bungeePermsUUIDService != null) {
|
if (bungeePermsUUIDService != null) {
|
||||||
impromptuPipeline.registerService(bungeePermsUUIDService);
|
this.impromptuPipeline.registerService(bungeePermsUUIDService);
|
||||||
backgroundPipeline.registerService(bungeePermsUUIDService);
|
this.backgroundPipeline.registerService(bungeePermsUUIDService);
|
||||||
}
|
}
|
||||||
if (essentialsUUIDService != null) {
|
if (essentialsUUIDService != null) {
|
||||||
impromptuPipeline.registerService(essentialsUUIDService);
|
this.impromptuPipeline.registerService(essentialsUUIDService);
|
||||||
backgroundPipeline.registerService(essentialsUUIDService);
|
this.backgroundPipeline.registerService(essentialsUUIDService);
|
||||||
}
|
}
|
||||||
|
|
||||||
final SquirrelIdUUIDService impromptuMojangService =
|
final SquirrelIdUUIDService impromptuMojangService =
|
||||||
new SquirrelIdUUIDService(Settings.UUID.IMPROMPTU_LIMIT);
|
new SquirrelIdUUIDService(Settings.UUID.IMPROMPTU_LIMIT);
|
||||||
impromptuPipeline.registerService(impromptuMojangService);
|
this.impromptuPipeline.registerService(impromptuMojangService);
|
||||||
final SquirrelIdUUIDService backgroundMojangService =
|
final SquirrelIdUUIDService backgroundMojangService =
|
||||||
new SquirrelIdUUIDService(Settings.UUID.BACKGROUND_LIMIT);
|
new SquirrelIdUUIDService(Settings.UUID.BACKGROUND_LIMIT);
|
||||||
backgroundPipeline.registerService(backgroundMojangService);
|
this.backgroundPipeline.registerService(backgroundMojangService);
|
||||||
} else {
|
} else {
|
||||||
impromptuPipeline.registerService(sqLiteUUIDService);
|
this.impromptuPipeline.registerService(sqLiteUUIDService);
|
||||||
backgroundPipeline.registerService(sqLiteUUIDService);
|
this.backgroundPipeline.registerService(sqLiteUUIDService);
|
||||||
impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
this.impromptuPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
this.backgroundPipeline.registerConsumer(sqLiteUUIDService);
|
||||||
|
|
||||||
if (legacyUUIDService != null) {
|
if (legacyUUIDService != null) {
|
||||||
impromptuPipeline.registerService(legacyUUIDService);
|
this.impromptuPipeline.registerService(legacyUUIDService);
|
||||||
backgroundPipeline.registerService(legacyUUIDService);
|
this.backgroundPipeline.registerService(legacyUUIDService);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);
|
this.impromptuPipeline.storeImmediately("*", DBFunc.EVERYONE);
|
||||||
|
|
||||||
if (Settings.UUID.BACKGROUND_CACHING_ENABLED) {
|
if (Settings.UUID.BACKGROUND_CACHING_ENABLED) {
|
||||||
this.startUuidCaching(sqLiteUUIDService, cacheUUIDService);
|
this.startUuidCaching(sqLiteUUIDService, cacheUUIDService);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
if (Bukkit.getPluginManager().getPlugin("PlaceholderAPI") != null) {
|
||||||
new Placeholders().register();
|
injector.getInstance(Placeholders.class).register();
|
||||||
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
if (Settings.Enabled_Components.EXTERNAL_PLACEHOLDERS) {
|
||||||
ChatFormatter.formatters.add(new PlaceholderFormatter());
|
ChatFormatter.formatters.add(getInjector().getInstance(PlaceholderFormatter.class));
|
||||||
}
|
}
|
||||||
PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI");
|
PlotSquared.log(Captions.PREFIX + "&6PlotSquared hooked into PlaceholderAPI");
|
||||||
} else {
|
} else {
|
||||||
@ -387,31 +476,14 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
|
|
||||||
this.startMetrics();
|
this.startMetrics();
|
||||||
if (Settings.Enabled_Components.WORLDS) {
|
if (Settings.Enabled_Components.WORLDS) {
|
||||||
TaskManager.IMP.taskRepeat(this::unload, 20);
|
TaskManager.getImplementation().taskRepeat(this::unload, 20);
|
||||||
try {
|
try {
|
||||||
singleWorldListener = new SingleWorldListener(this);
|
singleWorldListener = getInjector().getInstance(SingleWorldListener.class);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
|
||||||
this.backupManager = new SimpleBackupManager();
|
|
||||||
} catch (final Exception e) {
|
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Failed to initialize backup manager");
|
|
||||||
e.printStackTrace();
|
|
||||||
PlotSquared.log(Captions.PREFIX + "&6Backup features will be disabled");
|
|
||||||
this.backupManager = new NullBackupManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Bukkit.getPluginManager().getPlugin("Hyperverse") != null) {
|
|
||||||
this.worldManager = new HyperverseWorldManager();
|
|
||||||
} else if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
|
|
||||||
this.worldManager = new MultiverseWorldManager();
|
|
||||||
} else {
|
|
||||||
this.worldManager = new BukkitWorldManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
PlotSquared.log(
|
PlotSquared.log(
|
||||||
Captions.PREFIX.getTranslated() + "Using platform world manager: " + this.worldManager
|
Captions.PREFIX.getTranslated() + "Using platform world manager: " + this.worldManager
|
||||||
.getName());
|
.getName());
|
||||||
@ -601,21 +673,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
this.getServer().getPluginManager().disablePlugin(this);
|
this.getServer().getPluginManager().disablePlugin(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public int[] getPluginVersion() {
|
private void registerCommands() {
|
||||||
String ver = getDescription().getVersion();
|
|
||||||
if (ver.contains("-")) {
|
|
||||||
ver = ver.split("-")[0];
|
|
||||||
}
|
|
||||||
String[] split = ver.split("\\.");
|
|
||||||
return new int[] {Integer.parseInt(split[0]), Integer.parseInt(split[1]),
|
|
||||||
Integer.parseInt(split[2])};
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public String getPluginVersionString() {
|
|
||||||
return getDescription().getVersion();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void registerCommands() {
|
|
||||||
final BukkitCommand bukkitCommand = new BukkitCommand();
|
final BukkitCommand bukkitCommand = new BukkitCommand();
|
||||||
final PluginCommand plotCommand = getCommand("plots");
|
final PluginCommand plotCommand = getCommand("plots");
|
||||||
if (plotCommand != null) {
|
if (plotCommand != null) {
|
||||||
@ -633,11 +691,7 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
return Bukkit.getWorldContainer();
|
return Bukkit.getWorldContainer();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public TaskManager getTaskManager() {
|
@SuppressWarnings("deprecation") private void runEntityTask() {
|
||||||
return new BukkitTaskManager(this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @SuppressWarnings("deprecation") public void runEntityTask() {
|
|
||||||
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
|
PlotSquared.log(Captions.PREFIX + "KillAllEntities started.");
|
||||||
TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> {
|
TaskManager.runTaskRepeat(() -> this.plotAreaManager.forEachPlotArea(plotArea -> {
|
||||||
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
final World world = Bukkit.getWorld(plotArea.getWorldName());
|
||||||
@ -897,9 +951,9 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
final String id) {
|
final String id) {
|
||||||
final IndependentPlotGenerator result;
|
final IndependentPlotGenerator result;
|
||||||
if (id != null && id.equalsIgnoreCase("single")) {
|
if (id != null && id.equalsIgnoreCase("single")) {
|
||||||
result = new SingleWorldGenerator(this.plotAreaManager);
|
result = getInjector().getInstance(SingleWorldGenerator.class);
|
||||||
} else {
|
} else {
|
||||||
result = PlotSquared.platform().getDefaultGenerator();
|
result = getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
||||||
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
if (!PlotSquared.get().setupPlotWorld(worldName, id, result)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -907,84 +961,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
return (ChunkGenerator) result.specify(worldName);
|
return (ChunkGenerator) result.specify(worldName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerPlayerEvents() {
|
|
||||||
final PlayerEvents main = new PlayerEvents(this.plotAreaManager, this.eventDispatcher, worldEdit);
|
|
||||||
getServer().getPluginManager().registerEvents(main, this);
|
|
||||||
getServer().getPluginManager().registerEvents(new EntitySpawnListener(), this);
|
|
||||||
if (PaperLib.isPaper() && Settings.Paper_Components.PAPER_LISTENERS) {
|
|
||||||
getServer().getPluginManager().registerEvents(new PaperListener(this.plotAreaManager), this);
|
|
||||||
}
|
|
||||||
this.plotListener.startRunnable();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void registerForceFieldEvents() {
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public boolean initWorldEdit() {
|
|
||||||
if (getServer().getPluginManager().getPlugin("WorldEdit") != null) {
|
|
||||||
worldEdit = WorldEdit.getInstance();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public EconHandler getEconomyHandler() {
|
|
||||||
if (econ != null) {
|
|
||||||
if (econ.init() /* is inited */) {
|
|
||||||
return econ;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
econ = new BukkitEconHandler();
|
|
||||||
if (econ.init()) {
|
|
||||||
return econ;
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
PlotSquared.debug("No economy detected!");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public PermHandler getPermissionHandler() {
|
|
||||||
if (perm != null) {
|
|
||||||
if (perm.init() /* is inited */) {
|
|
||||||
return perm;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
perm = new BukkitPermHandler();
|
|
||||||
if (perm.init()) {
|
|
||||||
return perm;
|
|
||||||
}
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
PlotSquared.debug("No permissions detected!");
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public QueueProvider initBlockQueue() {
|
|
||||||
//TODO Figure out why this code is still here yet isn't being called anywhere.
|
|
||||||
// try {
|
|
||||||
// new SendChunk();
|
|
||||||
// MainUtil.canSendChunk = true;
|
|
||||||
// } catch (ClassNotFoundException | NoSuchFieldException | NoSuchMethodException e) {
|
|
||||||
// PlotSquared.debug(
|
|
||||||
// SendChunk.class + " does not support " + StringMan.getString(getServerVersion()));
|
|
||||||
// MainUtil.canSendChunk = false;
|
|
||||||
// }
|
|
||||||
return QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public WorldUtil initWorldUtil() {
|
|
||||||
return new BukkitUtil();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @Nullable public GeneratorWrapper<?> getGenerator(@NonNull final String world,
|
@Override @Nullable public GeneratorWrapper<?> getGenerator(@NonNull final String world,
|
||||||
@Nullable final String name) {
|
@Nullable final String name) {
|
||||||
if (name == null) {
|
if (name == null) {
|
||||||
@ -998,18 +974,11 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
|
return new BukkitPlotGenerator(world, gen, this.plotAreaManager);
|
||||||
} else {
|
} else {
|
||||||
return new BukkitPlotGenerator(world, PlotSquared.platform().getDefaultGenerator(), this.plotAreaManager);
|
return new BukkitPlotGenerator(world, getInjector()
|
||||||
|
.getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class)), this.plotAreaManager);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public HybridUtils initHybridUtils() {
|
|
||||||
return new BukkitHybridUtils(this.plotAreaManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public SetupUtils initSetupUtils() {
|
|
||||||
return new BukkitSetupUtils(this.plotAreaManager, this.worldConfiguration, this.worldfile);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void startMetrics() {
|
@Override public void startMetrics() {
|
||||||
if (this.metricsStarted) {
|
if (this.metricsStarted) {
|
||||||
return;
|
return;
|
||||||
@ -1041,47 +1010,23 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
"WorldEdit"));
|
"WorldEdit"));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public ChunkManager initChunkManager() {
|
|
||||||
return new BukkitChunkManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public RegionManager initRegionManager() {
|
|
||||||
return new BukkitRegionManager();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void unregister(@NonNull final PlotPlayer player) {
|
@Override public void unregister(@NonNull final PlotPlayer player) {
|
||||||
BukkitUtil.removePlayer(player.getUUID());
|
BukkitUtil.removePlayer(player.getUUID());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void registerChunkProcessor() {
|
|
||||||
getServer().getPluginManager().registerEvents(new ChunkListener(this.plotAreaManager), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void registerWorldEvents() {
|
|
||||||
getServer().getPluginManager().registerEvents(new WorldEvents(this.plotAreaManager), this);
|
|
||||||
}
|
|
||||||
|
|
||||||
@NotNull @Override public IndependentPlotGenerator getDefaultGenerator() {
|
|
||||||
return new HybridGen(this.eventDispatcher, this.plotListener, this.worldConfiguration);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public InventoryUtil initInventoryUtil() {
|
|
||||||
return new BukkitInventoryUtil();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override public void setGenerator(@NonNull final String worldName) {
|
@Override public void setGenerator(@NonNull final String worldName) {
|
||||||
World world = BukkitUtil.getWorld(worldName);
|
World world = BukkitUtil.getWorld(worldName);
|
||||||
if (world == null) {
|
if (world == null) {
|
||||||
// create world
|
// create world
|
||||||
ConfigurationSection worldConfig = this.worldConfiguration.getConfigurationSection("worlds." + worldName);
|
ConfigurationSection worldConfig = this.worldConfiguration.getConfigurationSection("worlds." + worldName);
|
||||||
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
String manager = worldConfig.getString("generator.plugin", getPluginName());
|
||||||
PlotAreaBuilder builder = new PlotAreaBuilder().plotManager(manager)
|
PlotAreaBuilder builder = PlotAreaBuilder.newBuilder().plotManager(manager)
|
||||||
.generatorName(worldConfig.getString("generator.init", manager))
|
.generatorName(worldConfig.getString("generator.init", manager))
|
||||||
.plotAreaType(MainUtil.getType(worldConfig))
|
.plotAreaType(MainUtil.getType(worldConfig))
|
||||||
.terrainType(MainUtil.getTerrain(worldConfig))
|
.terrainType(MainUtil.getTerrain(worldConfig))
|
||||||
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
.settingsNodesWrapper(new SettingsNodesWrapper(new ConfigurationNode[0], null))
|
||||||
.worldName(worldName);
|
.worldName(worldName);
|
||||||
SetupUtils.manager.setupWorld(builder);
|
getInjector().getInstance(SetupUtils.class).setupWorld(builder);
|
||||||
world = Bukkit.getWorld(worldName);
|
world = Bukkit.getWorld(worldName);
|
||||||
} else {
|
} else {
|
||||||
try {
|
try {
|
||||||
@ -1105,10 +1050,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public SchematicHandler initSchematicHandler() {
|
|
||||||
return new BukkitSchematicHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Attempt to retrieve a {@link PlotPlayer} from a player identifier.
|
* Attempt to retrieve a {@link PlotPlayer} from a player identifier.
|
||||||
* This method accepts:
|
* This method accepts:
|
||||||
@ -1170,18 +1111,6 @@ public final class BukkitPlatform extends JavaPlugin implements Listener, PlotPl
|
|||||||
return names;
|
return names;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Actor getConsole() {
|
|
||||||
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
|
||||||
WorldEditPlugin wePlugin =
|
|
||||||
((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
|
||||||
return wePlugin.wrapCommandSender(console);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @NotNull
|
|
||||||
public PlayerManager<? extends PlotPlayer<Player>, ? extends Player> getPlayerManager() {
|
|
||||||
return this.playerManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override @NotNull public com.plotsquared.core.location.World<?> getPlatformWorld(@NotNull final String worldName) {
|
@Override @NotNull public com.plotsquared.core.location.World<?> getPlatformWorld(@NotNull final String worldName) {
|
||||||
return BukkitWorld.of(worldName);
|
return BukkitWorld.of(worldName);
|
||||||
}
|
}
|
||||||
|
@ -65,7 +65,8 @@ public class BukkitPlotGenerator extends ChunkGenerator
|
|||||||
@Getter private final String levelName;
|
@Getter private final String levelName;
|
||||||
|
|
||||||
public BukkitPlotGenerator(@NotNull final String name,
|
public BukkitPlotGenerator(@NotNull final String name,
|
||||||
@NotNull final IndependentPlotGenerator generator, @NotNull final PlotAreaManager plotAreaManager) {
|
@NotNull final IndependentPlotGenerator generator,
|
||||||
|
@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
this.levelName = name;
|
this.levelName = name;
|
||||||
this.plotGenerator = generator;
|
this.plotGenerator = generator;
|
||||||
|
@ -0,0 +1,54 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.inject;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.google.inject.assistedinject.FactoryModuleBuilder;
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
|
import com.plotsquared.core.backup.BackupProfile;
|
||||||
|
import com.plotsquared.core.backup.NullBackupManager;
|
||||||
|
import com.plotsquared.core.backup.PlayerBackupProfile;
|
||||||
|
import com.plotsquared.core.backup.SimpleBackupManager;
|
||||||
|
import com.plotsquared.core.configuration.Captions;
|
||||||
|
import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory;
|
||||||
|
|
||||||
|
public class BackupModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override protected void configure() {
|
||||||
|
try {
|
||||||
|
install(new FactoryModuleBuilder()
|
||||||
|
.implement(BackupProfile.class, PlayerBackupProfile.class).build(PlayerBackupProfileFactory.class));
|
||||||
|
bind(BackupManager.class).to(SimpleBackupManager.class);
|
||||||
|
} catch (final Exception e) {
|
||||||
|
PlotSquared.log(Captions.PREFIX + "&6Failed to initialize backup manager");
|
||||||
|
e.printStackTrace();
|
||||||
|
PlotSquared.log(Captions.PREFIX + "&6Backup features will be disabled");
|
||||||
|
bind(BackupManager.class).to(NullBackupManager.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,92 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.inject;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.plotsquared.bukkit.BukkitPlatform;
|
||||||
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
|
import com.plotsquared.bukkit.queue.BukkitLocalQueue;
|
||||||
|
import com.plotsquared.bukkit.schematic.BukkitSchematicHandler;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitChunkManager;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitEconHandler;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitInventoryUtil;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitPermHandler;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitRegionManager;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitSetupUtils;
|
||||||
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
|
import com.plotsquared.core.PlotPlatform;
|
||||||
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.generator.HybridGen;
|
||||||
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
|
import com.plotsquared.core.inject.annotations.ConsoleActor;
|
||||||
|
import com.plotsquared.core.inject.annotations.DefaultGenerator;
|
||||||
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
|
import com.plotsquared.core.queue.QueueProvider;
|
||||||
|
import com.plotsquared.core.util.ChunkManager;
|
||||||
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.InventoryUtil;
|
||||||
|
import com.plotsquared.core.util.PermHandler;
|
||||||
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
|
import com.plotsquared.core.util.RegionManager;
|
||||||
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
|
import com.sk89q.worldedit.bukkit.WorldEditPlugin;
|
||||||
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.command.ConsoleCommandSender;
|
||||||
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor public class BukkitModule extends AbstractModule {
|
||||||
|
|
||||||
|
private final BukkitPlatform bukkitPlatform;
|
||||||
|
|
||||||
|
@Override protected void configure() {
|
||||||
|
bind(PlayerManager.class).to(BukkitPlayerManager.class);
|
||||||
|
bind(JavaPlugin.class).toInstance(bukkitPlatform);
|
||||||
|
bind(PlotPlatform.class).toInstance(bukkitPlatform);
|
||||||
|
bind(IndependentPlotGenerator.class).annotatedWith(DefaultGenerator.class).to(HybridGen.class);
|
||||||
|
// Console actor
|
||||||
|
@NotNull ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
|
||||||
|
WorldEditPlugin wePlugin = ((WorldEditPlugin) Bukkit.getPluginManager().getPlugin("WorldEdit"));
|
||||||
|
bind(Actor.class).annotatedWith(ConsoleActor.class).toInstance(wePlugin.wrapCommandSender(console));
|
||||||
|
bind(HybridUtils.class).to(BukkitHybridUtils.class);
|
||||||
|
bind(InventoryUtil.class).to(BukkitInventoryUtil.class);
|
||||||
|
bind(SetupUtils.class).to(BukkitSetupUtils.class);
|
||||||
|
bind(WorldUtil.class).to(BukkitUtil.class);
|
||||||
|
bind(GlobalBlockQueue.class).toInstance(new GlobalBlockQueue(
|
||||||
|
QueueProvider.of(BukkitLocalQueue.class, BukkitLocalQueue.class), 1, Settings.QUEUE.TARGET_TIME));
|
||||||
|
bind(ChunkManager.class).to(BukkitChunkManager.class);
|
||||||
|
bind(RegionManager.class).to(BukkitRegionManager.class);
|
||||||
|
bind(SchematicHandler.class).to(BukkitSchematicHandler.class);
|
||||||
|
bind(PermHandler.class).to(BukkitPermHandler.class);
|
||||||
|
bind(EconHandler.class).to(BukkitEconHandler.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.bukkit.inject;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.plotsquared.bukkit.managers.BukkitWorldManager;
|
||||||
|
import com.plotsquared.bukkit.managers.HyperverseWorldManager;
|
||||||
|
import com.plotsquared.bukkit.managers.MultiverseWorldManager;
|
||||||
|
import com.plotsquared.core.util.PlatformWorldManager;
|
||||||
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
|
public class WorldManagerModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override protected void configure() {
|
||||||
|
if (Bukkit.getPluginManager().getPlugin("Hyperverse") != null) {
|
||||||
|
bind(PlatformWorldManager.class).to(HyperverseWorldManager.class);
|
||||||
|
} else if (Bukkit.getPluginManager().getPlugin("Multiverse-Core") != null) {
|
||||||
|
bind(PlatformWorldManager.class).to(MultiverseWorldManager.class);
|
||||||
|
} else {
|
||||||
|
bind(PlatformWorldManager.class).to(BukkitWorldManager.class);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.listener;
|
package com.plotsquared.bukkit.listener;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
@ -69,7 +70,7 @@ public class ChunkListener implements Listener {
|
|||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
private boolean ignoreUnload = false;
|
private boolean ignoreUnload = false;
|
||||||
|
|
||||||
public ChunkListener(@NotNull final PlotAreaManager plotAreaManager) {
|
@Inject public ChunkListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
if (Settings.Chunk_Processor.AUTO_TRIM) {
|
||||||
try {
|
try {
|
||||||
|
@ -32,6 +32,7 @@ import com.destroystokyo.paper.event.entity.PreSpawnerSpawnEvent;
|
|||||||
import com.destroystokyo.paper.event.entity.SlimePathfindEvent;
|
import com.destroystokyo.paper.event.entity.SlimePathfindEvent;
|
||||||
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
import com.destroystokyo.paper.event.player.PlayerLaunchProjectileEvent;
|
||||||
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
|
import com.destroystokyo.paper.event.server.AsyncTabCompleteEvent;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.core.command.Command;
|
import com.plotsquared.core.command.Command;
|
||||||
import com.plotsquared.core.command.MainCommand;
|
import com.plotsquared.core.command.MainCommand;
|
||||||
@ -75,7 +76,7 @@ public class PaperListener implements Listener {
|
|||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private Chunk lastChunk;
|
private Chunk lastChunk;
|
||||||
|
|
||||||
public PaperListener(@NotNull final PlotAreaManager plotAreaManager) {
|
@Inject public PaperListener(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,7 @@ package com.plotsquared.bukkit.listener;
|
|||||||
|
|
||||||
import com.destroystokyo.paper.MaterialTags;
|
import com.destroystokyo.paper.MaterialTags;
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.util.BukkitUtil;
|
import com.plotsquared.bukkit.util.BukkitUtil;
|
||||||
import com.plotsquared.bukkit.util.UpdateUtility;
|
import com.plotsquared.bukkit.util.UpdateUtility;
|
||||||
@ -107,6 +108,7 @@ import com.plotsquared.core.util.MathMan;
|
|||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.PremiumVerification;
|
import com.plotsquared.core.util.PremiumVerification;
|
||||||
import com.plotsquared.core.util.RegExUtil;
|
import com.plotsquared.core.util.RegExUtil;
|
||||||
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.entity.EntityCategories;
|
import com.plotsquared.core.util.entity.EntityCategories;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
@ -245,10 +247,11 @@ import java.util.regex.Pattern;
|
|||||||
private PlayerMoveEvent moveTmp;
|
private PlayerMoveEvent moveTmp;
|
||||||
private String internalVersion;
|
private String internalVersion;
|
||||||
|
|
||||||
public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager,
|
@Inject public PlayerEvents(@NotNull final PlotAreaManager plotAreaManager,
|
||||||
@NotNull final EventDispatcher eventDispatcher,
|
@NotNull final EventDispatcher eventDispatcher,
|
||||||
@NotNull final WorldEdit worldEdit) {
|
@NotNull final WorldEdit worldEdit,
|
||||||
super(eventDispatcher);
|
@NotNull final WorldUtil worldUtil) {
|
||||||
|
super(eventDispatcher, worldUtil);
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
this.worldEdit = worldEdit;
|
this.worldEdit = worldEdit;
|
||||||
|
@ -37,7 +37,7 @@ import org.bukkit.event.EventPriority;
|
|||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.world.ChunkEvent;
|
import org.bukkit.event.world.ChunkEvent;
|
||||||
import org.bukkit.event.world.ChunkLoadEvent;
|
import org.bukkit.event.world.ChunkLoadEvent;
|
||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.lang.reflect.Method;
|
import java.lang.reflect.Method;
|
||||||
@ -50,7 +50,7 @@ public class SingleWorldListener implements Listener {
|
|||||||
private Method methodGetHandleChunk;
|
private Method methodGetHandleChunk;
|
||||||
private Field mustSave;
|
private Field mustSave;
|
||||||
|
|
||||||
public SingleWorldListener(Plugin plugin) throws Exception {
|
public SingleWorldListener(JavaPlugin plugin) throws Exception {
|
||||||
ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
|
ReflectionUtils.RefClass classChunk = getRefClass("{nms}.Chunk");
|
||||||
ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
ReflectionUtils.RefClass classCraftChunk = getRefClass("{cb}.CraftChunk");
|
||||||
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod();
|
this.methodGetHandleChunk = classCraftChunk.getMethod("getHandle").getRealMethod();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.listener;
|
package com.plotsquared.bukkit.listener;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||||
@ -43,7 +44,7 @@ public class WorldEvents implements Listener {
|
|||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
public WorldEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
@Inject public WorldEvents(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.managers;
|
package com.plotsquared.bukkit.managers;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.util.PlatformWorldManager;
|
import com.plotsquared.core.util.PlatformWorldManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -44,7 +45,7 @@ import java.util.List;
|
|||||||
* Default Bukkit world manager. It will handle world creation by
|
* Default Bukkit world manager. It will handle world creation by
|
||||||
* registering the generator in bukkit.yml
|
* registering the generator in bukkit.yml
|
||||||
*/
|
*/
|
||||||
public class BukkitWorldManager implements PlatformWorldManager<World> {
|
@Singleton public class BukkitWorldManager implements PlatformWorldManager<World> {
|
||||||
|
|
||||||
@Override public void initialize() {
|
@Override public void initialize() {
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.managers;
|
package com.plotsquared.bukkit.managers;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -38,7 +39,7 @@ import se.hyperver.hyperverse.world.WorldType;
|
|||||||
* Hyperverse specific manager that creates worlds
|
* Hyperverse specific manager that creates worlds
|
||||||
* using Hyperverse's API
|
* using Hyperverse's API
|
||||||
*/
|
*/
|
||||||
public class HyperverseWorldManager extends BukkitWorldManager {
|
@Singleton public class HyperverseWorldManager extends BukkitWorldManager {
|
||||||
|
|
||||||
@Override @Nullable
|
@Override @Nullable
|
||||||
public World handleWorldCreation(@NotNull String worldName, @Nullable String generator) {
|
public World handleWorldCreation(@NotNull String worldName, @Nullable String generator) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.managers;
|
package com.plotsquared.bukkit.managers;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -34,7 +35,7 @@ import org.jetbrains.annotations.Nullable;
|
|||||||
* Multiverse specific manager that informs Multiverse of
|
* Multiverse specific manager that informs Multiverse of
|
||||||
* world creation by executing a console command
|
* world creation by executing a console command
|
||||||
*/
|
*/
|
||||||
public class MultiverseWorldManager extends BukkitWorldManager {
|
@Singleton public class MultiverseWorldManager extends BukkitWorldManager {
|
||||||
|
|
||||||
@Override @Nullable
|
@Override @Nullable
|
||||||
public World handleWorldCreation(@NotNull final String worldName, @Nullable final String generator) {
|
public World handleWorldCreation(@NotNull final String worldName, @Nullable final String generator) {
|
||||||
|
@ -54,6 +54,7 @@ import org.bukkit.event.player.PlayerTeleportEvent;
|
|||||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||||
import org.bukkit.plugin.RegisteredListener;
|
import org.bukkit.plugin.RegisteredListener;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@ -68,10 +69,13 @@ import static com.sk89q.worldedit.world.gamemode.GameModes.SURVIVAL;
|
|||||||
public class BukkitPlayer extends PlotPlayer<Player> {
|
public class BukkitPlayer extends PlotPlayer<Player> {
|
||||||
|
|
||||||
private static boolean CHECK_EFFECTIVE = true;
|
private static boolean CHECK_EFFECTIVE = true;
|
||||||
|
|
||||||
|
private final EconHandler econHandler;
|
||||||
public final Player player;
|
public final Player player;
|
||||||
private boolean offline;
|
private boolean offline;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>Please do not use this method. Instead use
|
* <p>Please do not use this method. Instead use
|
||||||
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
|
* BukkitUtil.getPlayer(Player), as it caches player objects.</p>
|
||||||
@ -79,20 +83,22 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
* @param player Bukkit player instance
|
* @param player Bukkit player instance
|
||||||
*/
|
*/
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||||
@NotNull final Player player) {
|
@NotNull final Player player, @Nullable final EconHandler econHandler) {
|
||||||
this(plotAreaManager, eventDispatcher, player, false);
|
this(plotAreaManager, eventDispatcher, player, false, econHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher,
|
||||||
@NotNull final Player player, final boolean offline) {
|
@NotNull final Player player, final boolean offline, @Nullable final EconHandler econHandler) {
|
||||||
this(plotAreaManager, eventDispatcher, player, offline, true);
|
this(plotAreaManager, eventDispatcher, player, offline, true, econHandler);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final
|
public BukkitPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final
|
||||||
EventDispatcher eventDispatcher, @NotNull final Player player, final boolean offline, final boolean realPlayer) {
|
EventDispatcher eventDispatcher, @NotNull final Player player, final boolean offline,
|
||||||
super(plotAreaManager, eventDispatcher);
|
final boolean realPlayer, @Nullable final EconHandler econHandler) {
|
||||||
|
super(plotAreaManager, eventDispatcher, econHandler);
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.offline = offline;
|
this.offline = offline;
|
||||||
|
this.econHandler = econHandler;
|
||||||
if (realPlayer) {
|
if (realPlayer) {
|
||||||
super.populatePersistentMetaMap();
|
super.populatePersistentMetaMap();
|
||||||
}
|
}
|
||||||
@ -161,8 +167,8 @@ public class BukkitPlayer extends PlotPlayer<Player> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean hasPermission(final String permission) {
|
@Override public boolean hasPermission(final String permission) {
|
||||||
if (this.offline && EconHandler.getEconHandler() != null) {
|
if (this.offline && this.econHandler != null) {
|
||||||
return EconHandler.getEconHandler().hasPermission(getName(), permission);
|
return this.econHandler.hasPermission(getName(), permission);
|
||||||
}
|
}
|
||||||
return this.player.hasPermission(permission);
|
return this.player.hasPermission(permission);
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,11 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.player;
|
package com.plotsquared.bukkit.player;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
@ -39,11 +40,17 @@ import java.util.UUID;
|
|||||||
/**
|
/**
|
||||||
* Player manager providing {@link BukkitPlayer Bukkit players}
|
* Player manager providing {@link BukkitPlayer Bukkit players}
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
@Singleton public class BukkitPlayerManager extends PlayerManager<BukkitPlayer, Player> {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
@Inject public BukkitPlayerManager(@NotNull final PlotAreaManager plotAreaManager,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher) {
|
||||||
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
@NotNull @Override public BukkitPlayer getPlayer(@NotNull final Player object) {
|
||||||
try {
|
try {
|
||||||
return getPlayer(object.getUniqueId());
|
return getPlayer(object.getUniqueId());
|
||||||
|
@ -25,14 +25,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.schematic;
|
package com.plotsquared.bukkit.schematic;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Schematic Handler.
|
* Schematic Handler.
|
||||||
*/
|
*/
|
||||||
public class BukkitSchematicHandler extends SchematicHandler {
|
@Singleton public class BukkitSchematicHandler extends SchematicHandler {
|
||||||
|
|
||||||
|
@Inject public BukkitSchematicHandler(@NotNull final WorldUtil worldUtil) {
|
||||||
|
super(worldUtil);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean restoreTile(LocalBlockQueue queue, CompoundTag ct, int x, int y, int z) {
|
public boolean restoreTile(LocalBlockQueue queue, CompoundTag ct, int x, int y, int z) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.listener.WEExtent;
|
import com.plotsquared.core.listener.WEExtent;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
@ -54,7 +55,7 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB;
|
|||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||||
|
|
||||||
public class BukkitChunkManager extends ChunkManager {
|
@Singleton public class BukkitChunkManager extends ChunkManager {
|
||||||
|
|
||||||
public static boolean isIn(CuboidRegion region, int x, int z) {
|
public static boolean isIn(CuboidRegion region, int x, int z) {
|
||||||
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
||||||
|
@ -25,9 +25,10 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.player.BukkitOfflinePlayer;
|
import com.plotsquared.bukkit.player.BukkitOfflinePlayer;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
@ -35,11 +36,18 @@ import com.plotsquared.core.util.PermHandler;
|
|||||||
import net.milkbowl.vault.economy.Economy;
|
import net.milkbowl.vault.economy.Economy;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public class BukkitEconHandler extends EconHandler {
|
@Singleton public class BukkitEconHandler extends EconHandler {
|
||||||
|
|
||||||
private Economy econ;
|
private Economy econ;
|
||||||
|
|
||||||
|
private final PermHandler permHandler;
|
||||||
|
|
||||||
|
@Inject public BukkitEconHandler(@Nullable final PermHandler permHandler) {
|
||||||
|
this.permHandler = permHandler;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean init() {
|
public boolean init() {
|
||||||
if (this.econ == null) {
|
if (this.econ == null) {
|
||||||
@ -83,8 +91,8 @@ public class BukkitEconHandler extends EconHandler {
|
|||||||
* @deprecated Use {@link PermHandler#hasPermission(String, String, String)} instead
|
* @deprecated Use {@link PermHandler#hasPermission(String, String, String)} instead
|
||||||
*/
|
*/
|
||||||
@Deprecated @Override public boolean hasPermission(String world, String player, String perm) {
|
@Deprecated @Override public boolean hasPermission(String world, String player, String perm) {
|
||||||
if (PlotSquared.platform().getPermissionHandler() != null) {
|
if (this.permHandler != null) {
|
||||||
return PlotSquared.platform().getPermissionHandler().hasPermission(world, player, perm);
|
return this.permHandler.hasPermission(world, player, perm);
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.PlotInventory;
|
import com.plotsquared.core.plot.PlotInventory;
|
||||||
@ -45,7 +46,7 @@ import java.util.ArrayList;
|
|||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.IntStream;
|
import java.util.stream.IntStream;
|
||||||
|
|
||||||
public class BukkitInventoryUtil extends InventoryUtil {
|
@Singleton public class BukkitInventoryUtil extends InventoryUtil {
|
||||||
|
|
||||||
@Override public void open(PlotInventory inv) {
|
@Override public void open(PlotInventory inv) {
|
||||||
BukkitPlayer bp = (BukkitPlayer) inv.player;
|
BukkitPlayer bp = (BukkitPlayer) inv.player;
|
||||||
|
@ -25,12 +25,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.util.PermHandler;
|
import com.plotsquared.core.util.PermHandler;
|
||||||
import net.milkbowl.vault.permission.Permission;
|
import net.milkbowl.vault.permission.Permission;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.plugin.RegisteredServiceProvider;
|
import org.bukkit.plugin.RegisteredServiceProvider;
|
||||||
|
|
||||||
public class BukkitPermHandler extends PermHandler {
|
@Singleton public class BukkitPermHandler extends PermHandler {
|
||||||
|
|
||||||
private Permission perms;
|
private Permission perms;
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.BukkitPlatform;
|
import com.plotsquared.bukkit.BukkitPlatform;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.generator.AugmentedUtils;
|
import com.plotsquared.core.generator.AugmentedUtils;
|
||||||
@ -56,6 +58,7 @@ import org.bukkit.Chunk;
|
|||||||
import org.bukkit.World;
|
import org.bukkit.World;
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.ArrayDeque;
|
import java.util.ArrayDeque;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@ -74,7 +77,11 @@ import static com.plotsquared.core.util.entity.EntityCategories.CAP_MOB;
|
|||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_MONSTER;
|
||||||
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
import static com.plotsquared.core.util.entity.EntityCategories.CAP_VEHICLE;
|
||||||
|
|
||||||
public class BukkitRegionManager extends RegionManager {
|
@Singleton public class BukkitRegionManager extends RegionManager {
|
||||||
|
|
||||||
|
@Inject public BukkitRegionManager(@NotNull ChunkManager chunkManager) {
|
||||||
|
super(chunkManager);
|
||||||
|
}
|
||||||
|
|
||||||
public static boolean isIn(CuboidRegion region, int x, int z) {
|
public static boolean isIn(CuboidRegion region, int x, int z) {
|
||||||
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
return x >= region.getMinimumPoint().getX() && x <= region.getMaximumPoint().getX()
|
||||||
|
@ -25,10 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
import com.plotsquared.bukkit.generator.BukkitPlotGenerator;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.annoations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
@ -54,13 +56,13 @@ import java.util.HashMap;
|
|||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
public class BukkitSetupUtils extends SetupUtils {
|
@Singleton public class BukkitSetupUtils extends SetupUtils {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final YamlConfiguration worldConfiguration;
|
private final YamlConfiguration worldConfiguration;
|
||||||
private final File worldFile;
|
private final File worldFile;
|
||||||
|
|
||||||
public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager,
|
@Inject public BukkitSetupUtils(@NotNull final PlotAreaManager plotAreaManager,
|
||||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
@WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||||
@WorldFile @NotNull final File worldFile) {
|
@WorldFile @NotNull final File worldFile) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
@ -117,7 +119,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated @Override public String setupWorld(SetupObject object) {
|
@Deprecated @Override public String setupWorld(SetupObject object) {
|
||||||
SetupUtils.manager.updateGenerators();
|
this.updateGenerators();
|
||||||
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
ConfigurationNode[] steps = object.step == null ? new ConfigurationNode[0] : object.step;
|
||||||
String world = object.world;
|
String world = object.world;
|
||||||
PlotAreaType type = object.type;
|
PlotAreaType type = object.type;
|
||||||
@ -222,7 +224,7 @@ public class BukkitSetupUtils extends SetupUtils {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public String setupWorld(PlotAreaBuilder builder) {
|
@Override public String setupWorld(PlotAreaBuilder builder) {
|
||||||
SetupUtils.manager.updateGenerators();
|
this.updateGenerators();
|
||||||
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?
|
ConfigurationNode[] steps = builder.settingsNodesWrapper() == null ?
|
||||||
new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes();
|
new ConfigurationNode[0] : builder.settingsNodesWrapper().getSettingsNodes();
|
||||||
String world = builder.worldName();
|
String world = builder.worldName();
|
||||||
|
@ -25,15 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.BukkitPlatform;
|
import com.plotsquared.bukkit.BukkitPlatform;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
|
||||||
public class BukkitTaskManager extends TaskManager {
|
@Singleton public class BukkitTaskManager extends TaskManager {
|
||||||
|
|
||||||
private final BukkitPlatform bukkitMain;
|
private final BukkitPlatform bukkitMain;
|
||||||
|
|
||||||
public BukkitTaskManager(BukkitPlatform bukkitMain) {
|
@Inject public BukkitTaskManager(BukkitPlatform bukkitMain) {
|
||||||
this.bukkitMain = bukkitMain;
|
this.bukkitMain = bukkitMain;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.util;
|
package com.plotsquared.bukkit.util;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.bukkit.BukkitPlatform;
|
import com.plotsquared.bukkit.BukkitPlatform;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayer;
|
import com.plotsquared.bukkit.player.BukkitPlayer;
|
||||||
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
import com.plotsquared.bukkit.player.BukkitPlayerManager;
|
||||||
@ -37,6 +39,7 @@ import com.plotsquared.core.util.BlockUtil;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
|
import com.plotsquared.core.util.RegionManager;
|
||||||
import com.plotsquared.core.util.StringComparison;
|
import com.plotsquared.core.util.StringComparison;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
@ -108,7 +111,7 @@ import java.util.function.IntConsumer;
|
|||||||
import java.util.stream.Stream;
|
import java.util.stream.Stream;
|
||||||
|
|
||||||
@SuppressWarnings({"unused", "WeakerAccess"})
|
@SuppressWarnings({"unused", "WeakerAccess"})
|
||||||
public class BukkitUtil extends WorldUtil {
|
@Singleton public class BukkitUtil extends WorldUtil {
|
||||||
|
|
||||||
private static String lastString = null;
|
private static String lastString = null;
|
||||||
private static World lastWorld = null;
|
private static World lastWorld = null;
|
||||||
@ -116,6 +119,10 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
private static Player lastPlayer = null;
|
private static Player lastPlayer = null;
|
||||||
private static BukkitPlayer lastPlotPlayer = null;
|
private static BukkitPlayer lastPlotPlayer = null;
|
||||||
|
|
||||||
|
@Inject public BukkitUtil(@NotNull final RegionManager regionManager) {
|
||||||
|
super(regionManager);
|
||||||
|
}
|
||||||
|
|
||||||
public static void removePlayer(UUID uuid) {
|
public static void removePlayer(UUID uuid) {
|
||||||
lastPlayer = null;
|
lastPlayer = null;
|
||||||
lastPlotPlayer = null;
|
lastPlotPlayer = null;
|
||||||
@ -412,7 +419,7 @@ public class BukkitUtil extends WorldUtil {
|
|||||||
@Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) {
|
@Override @Nullable public String[] getSignSynchronous(@NonNull final Location location) {
|
||||||
Block block = getWorld(location.getWorldName())
|
Block block = getWorld(location.getWorldName())
|
||||||
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
.getBlockAt(location.getX(), location.getY(), location.getZ());
|
||||||
return TaskManager.IMP.sync(new RunnableVal<String[]>() {
|
return TaskManager.getImplementation().sync(new RunnableVal<String[]>() {
|
||||||
@Override public void run(String[] value) {
|
@Override public void run(String[] value) {
|
||||||
if (block.getState() instanceof Sign) {
|
if (block.getState() instanceof Sign) {
|
||||||
Sign sign = (Sign) block.getState();
|
Sign sign = (Sign) block.getState();
|
||||||
|
@ -28,6 +28,7 @@ package com.plotsquared.bukkit.util;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.google.gson.stream.JsonReader;
|
import com.google.gson.stream.JsonReader;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.PlotVersion;
|
import com.plotsquared.core.PlotVersion;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -51,7 +52,7 @@ public class UpdateUtility implements Listener {
|
|||||||
public final JavaPlugin javaPlugin;
|
public final JavaPlugin javaPlugin;
|
||||||
private boolean notify = true;
|
private boolean notify = true;
|
||||||
|
|
||||||
public UpdateUtility(final JavaPlugin javaPlugin) {
|
@Inject public UpdateUtility(final JavaPlugin javaPlugin) {
|
||||||
this.javaPlugin = javaPlugin;
|
this.javaPlugin = javaPlugin;
|
||||||
internalVersion = PlotSquared.get().getVersion();
|
internalVersion = PlotSquared.get().getVersion();
|
||||||
}
|
}
|
||||||
|
@ -18,6 +18,8 @@ dependencies {
|
|||||||
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
implementation("org.jetbrains.kotlin:kotlin-stdlib:1.3.72")
|
||||||
implementation("org.jetbrains:annotations:19.0.0")
|
implementation("org.jetbrains:annotations:19.0.0")
|
||||||
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
implementation("org.khelekore:prtree:1.7.0-SNAPSHOT")
|
||||||
|
compile("com.google.inject:guice:4.2.3")
|
||||||
|
compile("com.google.inject.extensions:guice-assistedinject:4.2.3")
|
||||||
}
|
}
|
||||||
|
|
||||||
sourceCompatibility = 1.8
|
sourceCompatibility = 1.8
|
||||||
|
12
Core/pom.xml
12
Core/pom.xml
@ -98,6 +98,18 @@
|
|||||||
<version>1.7.0-SNAPSHOT</version>
|
<version>1.7.0-SNAPSHOT</version>
|
||||||
<scope>runtime</scope>
|
<scope>runtime</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.inject</groupId>
|
||||||
|
<artifactId>guice</artifactId>
|
||||||
|
<version>4.2.3</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>com.google.inject.extensions</groupId>
|
||||||
|
<artifactId>guice-assistedinject</artifactId>
|
||||||
|
<version>4.2.3</version>
|
||||||
|
<scope>runtime</scope>
|
||||||
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>junit</groupId>
|
<groupId>junit</groupId>
|
||||||
<artifactId>junit</artifactId>
|
<artifactId>junit</artifactId>
|
||||||
|
@ -102,7 +102,7 @@ import java.util.UUID;
|
|||||||
* @see ChunkManager
|
* @see ChunkManager
|
||||||
*/
|
*/
|
||||||
public ChunkManager getChunkManager() {
|
public ChunkManager getChunkManager() {
|
||||||
return ChunkManager.manager;
|
return PlotSquared.platform().getInjector().getInstance(ChunkManager.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -111,7 +111,7 @@ import java.util.UUID;
|
|||||||
* @return GlobalBlockQueue.IMP
|
* @return GlobalBlockQueue.IMP
|
||||||
*/
|
*/
|
||||||
public GlobalBlockQueue getBlockQueue() {
|
public GlobalBlockQueue getBlockQueue() {
|
||||||
return GlobalBlockQueue.IMP;
|
return PlotSquared.platform().getGlobalBlockQueue();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -122,7 +122,7 @@ import java.util.UUID;
|
|||||||
* @see SchematicHandler
|
* @see SchematicHandler
|
||||||
*/
|
*/
|
||||||
public SchematicHandler getSchematicHandler() {
|
public SchematicHandler getSchematicHandler() {
|
||||||
return SchematicHandler.manager;
|
return PlotSquared.platform().getInjector().getInstance(SchematicHandler.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,27 +25,21 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core;
|
package com.plotsquared.core;
|
||||||
|
|
||||||
|
import com.google.inject.Injector;
|
||||||
|
import com.google.inject.Key;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.generator.GeneratorWrapper;
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
|
import com.plotsquared.core.inject.annotations.DefaultGenerator;
|
||||||
import com.plotsquared.core.location.World;
|
import com.plotsquared.core.location.World;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.queue.QueueProvider;
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
|
||||||
import com.plotsquared.core.util.EconHandler;
|
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
|
||||||
import com.plotsquared.core.util.PermHandler;
|
|
||||||
import com.plotsquared.core.util.PlatformWorldManager;
|
import com.plotsquared.core.util.PlatformWorldManager;
|
||||||
import com.plotsquared.core.util.PlayerManager;
|
import com.plotsquared.core.util.PlayerManager;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.logger.ILogger;
|
import com.plotsquared.core.util.logger.ILogger;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
@ -94,20 +88,6 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*/
|
*/
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version of the PlotSquared being used.
|
|
||||||
*
|
|
||||||
* @return the plugin version
|
|
||||||
*/
|
|
||||||
int[] getPluginVersion();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the version of the PlotSquared being used as a string.
|
|
||||||
*
|
|
||||||
* @return the plugin version as a string
|
|
||||||
*/
|
|
||||||
String getPluginVersionString();
|
|
||||||
|
|
||||||
default String getPluginName() {
|
default String getPluginName() {
|
||||||
return "PlotSquared";
|
return "PlotSquared";
|
||||||
}
|
}
|
||||||
@ -129,13 +109,6 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*/
|
*/
|
||||||
String getNMSPackage();
|
String getNMSPackage();
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the schematic handler.
|
|
||||||
*
|
|
||||||
* @return The {@link SchematicHandler}
|
|
||||||
*/
|
|
||||||
SchematicHandler initSchematicHandler();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the {@link ChatManager}.
|
* Starts the {@link ChatManager}.
|
||||||
*
|
*
|
||||||
@ -143,86 +116,6 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*/
|
*/
|
||||||
ChatManager initChatManager();
|
ChatManager initChatManager();
|
||||||
|
|
||||||
/**
|
|
||||||
* The task manager will run and manage Minecraft tasks.
|
|
||||||
*
|
|
||||||
* @return the PlotSquared task manager
|
|
||||||
*/
|
|
||||||
TaskManager getTaskManager();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Run the task that will kill road mobs.
|
|
||||||
*/
|
|
||||||
void runEntityTask();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registerss the implementation specific commands.
|
|
||||||
*/
|
|
||||||
void registerCommands();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the protection system.
|
|
||||||
*/
|
|
||||||
void registerPlayerEvents();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register force field events.
|
|
||||||
*/
|
|
||||||
void registerForceFieldEvents();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Registers the WorldEdit hook.
|
|
||||||
*/
|
|
||||||
boolean initWorldEdit();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the economy provider, if there is one
|
|
||||||
*
|
|
||||||
* @return the PlotSquared economy manager
|
|
||||||
*/
|
|
||||||
@Nullable EconHandler getEconomyHandler();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the permission provider, if there is one
|
|
||||||
*
|
|
||||||
* @return the PlotSquared permission manager
|
|
||||||
*/
|
|
||||||
@Nullable PermHandler getPermissionHandler();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link QueueProvider} class.
|
|
||||||
*/
|
|
||||||
QueueProvider initBlockQueue();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link WorldUtil} class.
|
|
||||||
*/
|
|
||||||
WorldUtil initWorldUtil();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the chunk manager.
|
|
||||||
*
|
|
||||||
* @return the PlotSquared chunk manager
|
|
||||||
*/
|
|
||||||
ChunkManager initChunkManager();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the region manager.
|
|
||||||
*
|
|
||||||
* @return the PlotSquared region manager
|
|
||||||
*/
|
|
||||||
RegionManager initRegionManager();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link SetupUtils} class.
|
|
||||||
*/
|
|
||||||
SetupUtils initSetupUtils();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets {@link HybridUtils} class.
|
|
||||||
*/
|
|
||||||
HybridUtils initHybridUtils();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Start Metrics.
|
* Start Metrics.
|
||||||
*/
|
*/
|
||||||
@ -235,12 +128,6 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*/
|
*/
|
||||||
void setGenerator(String world);
|
void setGenerator(String world);
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the {@link InventoryUtil} class (used for implementation specific
|
|
||||||
* inventory guis).
|
|
||||||
*/
|
|
||||||
InventoryUtil initInventoryUtil();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
|
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
|
||||||
*
|
*
|
||||||
@ -259,49 +146,43 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
|
|
||||||
GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
|
GeneratorWrapper<?> wrapPlotGenerator(String world, IndependentPlotGenerator generator);
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the chunk processor which will clean out chunks that have too
|
|
||||||
* many block states or entities.
|
|
||||||
*/
|
|
||||||
void registerChunkProcessor();
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Register the world initialization events (used to keep track of worlds
|
|
||||||
* being generated).
|
|
||||||
*/
|
|
||||||
void registerWorldEvents();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Usually HybridGen
|
* Usually HybridGen
|
||||||
*
|
*
|
||||||
* @return Default implementation generator
|
* @return Default implementation generator
|
||||||
*/
|
*/
|
||||||
@NotNull IndependentPlotGenerator getDefaultGenerator();
|
@NotNull default IndependentPlotGenerator getDefaultGenerator() {
|
||||||
|
return getInjector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
||||||
|
}
|
||||||
|
|
||||||
List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds();
|
List<Map.Entry<Map.Entry<String, String>, Boolean>> getPluginIds();
|
||||||
|
|
||||||
Actor getConsole();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the backup manager instance
|
* Get the backup manager instance
|
||||||
*
|
*
|
||||||
* @return Backup manager
|
* @return Backup manager
|
||||||
*/
|
*/
|
||||||
@NotNull BackupManager getBackupManager();
|
@NotNull default BackupManager getBackupManager() {
|
||||||
|
return getInjector().getInstance(BackupManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the platform specific world manager
|
* Get the platform specific world manager
|
||||||
*
|
*
|
||||||
* @return World manager
|
* @return World manager
|
||||||
*/
|
*/
|
||||||
@NotNull PlatformWorldManager<?> getWorldManager();
|
@NotNull default PlatformWorldManager<?> getWorldManager() {
|
||||||
|
return getInjector().getInstance(PlatformWorldManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the player manager implementation for the platform
|
* Get the player manager implementation for the platform
|
||||||
*
|
*
|
||||||
* @return Player manager
|
* @return Player manager
|
||||||
*/
|
*/
|
||||||
@NotNull PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager();
|
@NotNull default PlayerManager<? extends PlotPlayer<P>, ? extends P> getPlayerManager() {
|
||||||
|
return getInjector().getInstance(PlayerManager.class);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a platform world wrapper from a world name
|
* Get a platform world wrapper from a world name
|
||||||
@ -311,4 +192,38 @@ public interface PlotPlatform<P> extends ILogger {
|
|||||||
*/
|
*/
|
||||||
@NotNull World<?> getPlatformWorld(@NotNull final String worldName);
|
@NotNull World<?> getPlatformWorld(@NotNull final String worldName);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the {@link com.google.inject.Injector} instance used by PlotSquared
|
||||||
|
*
|
||||||
|
* @return Injector instance
|
||||||
|
*/
|
||||||
|
@NotNull Injector getInjector();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the world utility implementation
|
||||||
|
*
|
||||||
|
* @return World utility
|
||||||
|
*/
|
||||||
|
@NotNull default WorldUtil getWorldUtil() {
|
||||||
|
return getInjector().getInstance(WorldUtil.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the global block queue implementation
|
||||||
|
*
|
||||||
|
* @return Global block queue implementation
|
||||||
|
*/
|
||||||
|
@NotNull default GlobalBlockQueue getGlobalBlockQueue() {
|
||||||
|
return getInjector().getInstance(GlobalBlockQueue.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the hybrid utility class
|
||||||
|
*
|
||||||
|
* @return Hybrid utility class
|
||||||
|
*/
|
||||||
|
@NotNull default HybridUtils getHybridUtils() {
|
||||||
|
return getInjector().getInstance(HybridUtils.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -25,8 +25,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core;
|
package com.plotsquared.core;
|
||||||
|
|
||||||
import com.plotsquared.core.command.WE_Anywhere;
|
|
||||||
import com.plotsquared.core.components.ComponentPresetManager;
|
|
||||||
import com.plotsquared.core.configuration.Caption;
|
import com.plotsquared.core.configuration.Caption;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -47,7 +45,6 @@ import com.plotsquared.core.generator.HybridPlotWorld;
|
|||||||
import com.plotsquared.core.generator.HybridUtils;
|
import com.plotsquared.core.generator.HybridUtils;
|
||||||
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.listener.WESubscriber;
|
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.plot.BlockBucket;
|
import com.plotsquared.core.plot.BlockBucket;
|
||||||
@ -65,21 +62,13 @@ import com.plotsquared.core.plot.world.DefaultPlotAreaManager;
|
|||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotArea;
|
import com.plotsquared.core.plot.world.SinglePlotArea;
|
||||||
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
import com.plotsquared.core.plot.world.SinglePlotAreaManager;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
|
||||||
import com.plotsquared.core.util.ChatManager;
|
import com.plotsquared.core.util.ChatManager;
|
||||||
import com.plotsquared.core.util.ChunkManager;
|
|
||||||
import com.plotsquared.core.util.EconHandler;
|
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
|
||||||
import com.plotsquared.core.util.LegacyConverter;
|
import com.plotsquared.core.util.LegacyConverter;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.MathMan;
|
import com.plotsquared.core.util.MathMan;
|
||||||
import com.plotsquared.core.util.ReflectionUtils;
|
import com.plotsquared.core.util.ReflectionUtils;
|
||||||
import com.plotsquared.core.util.RegionManager;
|
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
|
||||||
import com.plotsquared.core.util.logger.ILogger;
|
import com.plotsquared.core.util.logger.ILogger;
|
||||||
import com.plotsquared.core.util.query.PlotQuery;
|
import com.plotsquared.core.util.query.PlotQuery;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -202,10 +191,6 @@ public class PlotSquared {
|
|||||||
"PlotSquared-" + platform + ".jar");
|
"PlotSquared-" + platform + ".jar");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TaskManager.IMP = this.platform.getTaskManager();
|
|
||||||
|
|
||||||
// World Util. Has to be done before config files are loaded
|
|
||||||
WorldUtil.IMP = this.platform.initWorldUtil();
|
|
||||||
|
|
||||||
if (!setupConfigs()) {
|
if (!setupConfigs()) {
|
||||||
return;
|
return;
|
||||||
@ -215,24 +200,7 @@ public class PlotSquared {
|
|||||||
+ ".use_THIS.yml");
|
+ ".use_THIS.yml");
|
||||||
Captions.load(this.translationFile);
|
Captions.load(this.translationFile);
|
||||||
|
|
||||||
// WorldEdit
|
this.worldedit = WorldEdit.getInstance();
|
||||||
if (Settings.Enabled_Components.WORLDEDIT_RESTRICTIONS) {
|
|
||||||
try {
|
|
||||||
if (this.platform.initWorldEdit()) {
|
|
||||||
PlotSquared.log(Captions.PREFIX.getTranslated() + "&6" + this.platform.getPluginName()
|
|
||||||
+ " hooked into WorldEdit.");
|
|
||||||
this.worldedit = WorldEdit.getInstance();
|
|
||||||
WorldEdit.getInstance().getEventBus().register(new WESubscriber(this.plotAreaManager));
|
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
|
||||||
new WE_Anywhere();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
PlotSquared.debug(
|
|
||||||
"Incompatible version of WorldEdit, please upgrade: http://builds.enginehub.org/job/worldedit?branch=master");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Create Event utility class
|
// Create Event utility class
|
||||||
this.eventDispatcher = new EventDispatcher(this.worldedit);
|
this.eventDispatcher = new EventDispatcher(this.worldedit);
|
||||||
@ -263,85 +231,11 @@ public class PlotSquared {
|
|||||||
|
|
||||||
// Comments
|
// Comments
|
||||||
CommentManager.registerDefaultInboxes();
|
CommentManager.registerDefaultInboxes();
|
||||||
// Kill entities
|
|
||||||
if (Settings.Enabled_Components.KILL_ROAD_MOBS
|
|
||||||
|| Settings.Enabled_Components.KILL_ROAD_VEHICLES) {
|
|
||||||
this.platform.runEntityTask();
|
|
||||||
}
|
|
||||||
if (Settings.Enabled_Components.EVENTS) {
|
|
||||||
this.platform.registerPlayerEvents();
|
|
||||||
}
|
|
||||||
// Required
|
|
||||||
this.platform.registerWorldEvents();
|
|
||||||
if (Settings.Enabled_Components.CHUNK_PROCESSOR) {
|
|
||||||
this.platform.registerChunkProcessor();
|
|
||||||
}
|
|
||||||
startExpiryTasks();
|
startExpiryTasks();
|
||||||
// create Hybrid utility class
|
|
||||||
HybridUtils.manager = this.platform.initHybridUtils();
|
// This is getting removed so I won't even bother migrating it
|
||||||
// Inventory utility class
|
|
||||||
InventoryUtil.manager = this.platform.initInventoryUtil();
|
|
||||||
// create setup util class
|
|
||||||
SetupUtils.manager = this.platform.initSetupUtils();
|
|
||||||
// Set block
|
|
||||||
GlobalBlockQueue.IMP =
|
|
||||||
new GlobalBlockQueue(this.platform.initBlockQueue(), 1, Settings.QUEUE.TARGET_TIME);
|
|
||||||
GlobalBlockQueue.IMP.runTask();
|
|
||||||
// Set chunk
|
|
||||||
ChunkManager.manager = this.platform.initChunkManager();
|
|
||||||
RegionManager.manager = this.platform.initRegionManager();
|
|
||||||
// Schematic handler
|
|
||||||
SchematicHandler.manager = this.platform.initSchematicHandler();
|
|
||||||
// Chat
|
|
||||||
ChatManager.manager = this.platform.initChatManager();
|
ChatManager.manager = this.platform.initChatManager();
|
||||||
// Commands
|
|
||||||
if (Settings.Enabled_Components.COMMANDS) {
|
|
||||||
this.platform.registerCommands();
|
|
||||||
}
|
|
||||||
// Economy
|
|
||||||
if (Settings.Enabled_Components.ECONOMY) {
|
|
||||||
TaskManager.runTask(() -> EconHandler.initializeEconHandler());
|
|
||||||
}
|
|
||||||
|
|
||||||
if (Settings.Enabled_Components.COMPONENT_PRESETS) {
|
|
||||||
try {
|
|
||||||
new ComponentPresetManager();
|
|
||||||
} catch (final Exception e) {
|
|
||||||
PlotSquared.log(Captions.PREFIX + "Failed to initialize the preset system");
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// World generators:
|
|
||||||
final ConfigurationSection section = this.worldConfiguration.getConfigurationSection("worlds");
|
|
||||||
if (section != null) {
|
|
||||||
for (String world : section.getKeys(false)) {
|
|
||||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (WorldUtil.IMP.isWorld(world)) {
|
|
||||||
this.platform.setGenerator(world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
TaskManager.runTaskLater(() -> {
|
|
||||||
for (String world : section.getKeys(false)) {
|
|
||||||
if (world.equals("CheckingPlotSquaredGenerator")) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (!WorldUtil.IMP.isWorld(world) && !world.equals("*")) {
|
|
||||||
debug("`" + world + "` was not properly loaded - " + this.platform.getPluginName()
|
|
||||||
+ " will now try to load it properly: ");
|
|
||||||
debug(
|
|
||||||
" - Are you trying to delete this world? Remember to remove it from the worlds.yml, bukkit.yml and multiverse worlds.yml");
|
|
||||||
debug(
|
|
||||||
" - Your world management plugin may be faulty (or non existent)");
|
|
||||||
debug(
|
|
||||||
" This message may also be a false positive and could be ignored.");
|
|
||||||
PlotSquared.this.platform.setGenerator(world);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Copy files
|
// Copy files
|
||||||
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
copyFile("addplots.js", Settings.Paths.SCRIPTS);
|
||||||
@ -552,7 +446,7 @@ public class PlotSquared {
|
|||||||
PlotSquared.debug(" Regions: " + regions.size());
|
PlotSquared.debug(" Regions: " + regions.size());
|
||||||
PlotSquared.debug(" Chunks: " + chunks.size());
|
PlotSquared.debug(" Chunks: " + chunks.size());
|
||||||
HybridUtils.UPDATE = true;
|
HybridUtils.UPDATE = true;
|
||||||
HybridUtils.manager.scheduleRoadUpdate(plotArea, regions, height, chunks);
|
PlotSquared.platform().getHybridUtils().scheduleRoadUpdate(plotArea, regions, height, chunks);
|
||||||
} catch (IOException | ClassNotFoundException e) {
|
} catch (IOException | ClassNotFoundException e) {
|
||||||
PlotSquared.log(Captions.PREFIX + "Error restarting road regeneration.");
|
PlotSquared.log(Captions.PREFIX + "Error restarting road regeneration.");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.backup;
|
package com.plotsquared.core.backup;
|
||||||
|
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
@ -37,7 +38,7 @@ import java.util.Objects;
|
|||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
public class NullBackupManager implements BackupManager {
|
@Singleton public class NullBackupManager implements BackupManager {
|
||||||
|
|
||||||
@Override @NotNull public BackupProfile getProfile(@NotNull Plot plot) {
|
@Override @NotNull public BackupProfile getProfile(@NotNull Plot plot) {
|
||||||
return new NullBackupProfile();
|
return new NullBackupProfile();
|
||||||
|
@ -25,13 +25,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.backup;
|
package com.plotsquared.core.backup;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.assistedinject.Assisted;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.schematic.Schematic;
|
import com.plotsquared.core.plot.schematic.Schematic;
|
||||||
import com.plotsquared.core.util.SchematicHandler;
|
import com.plotsquared.core.util.SchematicHandler;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -51,12 +52,20 @@ import java.util.concurrent.CompletableFuture;
|
|||||||
* plot, which is used to store and retrieve plot backups
|
* plot, which is used to store and retrieve plot backups
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class PlayerBackupProfile implements BackupProfile {
|
public class PlayerBackupProfile implements BackupProfile {
|
||||||
|
|
||||||
private final UUID owner;
|
private final UUID owner;
|
||||||
private final Plot plot;
|
private final Plot plot;
|
||||||
private final BackupManager backupManager;
|
private final BackupManager backupManager;
|
||||||
|
private final SchematicHandler schematicHandler;
|
||||||
|
|
||||||
|
@Inject public PlayerBackupProfile(@Assisted @NotNull final UUID owner, @Assisted @NotNull final Plot plot,
|
||||||
|
@NotNull final BackupManager backupManager, @NotNull final SchematicHandler schematicHandler) {
|
||||||
|
this.owner = owner;
|
||||||
|
this.plot = plot;
|
||||||
|
this.backupManager = backupManager;
|
||||||
|
this.schematicHandler = schematicHandler;
|
||||||
|
}
|
||||||
|
|
||||||
private volatile List<Backup> backupCache;
|
private volatile List<Backup> backupCache;
|
||||||
private final Object backupLock = new Object();
|
private final Object backupLock = new Object();
|
||||||
@ -141,7 +150,7 @@ public class PlayerBackupProfile implements BackupProfile {
|
|||||||
backups.get(backups.size() - 1).delete();
|
backups.get(backups.size() - 1).delete();
|
||||||
}
|
}
|
||||||
final List<Plot> plots = Collections.singletonList(plot);
|
final List<Plot> plots = Collections.singletonList(plot);
|
||||||
final boolean result = SchematicHandler.manager.exportAll(plots, getBackupDirectory().toFile(),
|
final boolean result = this.schematicHandler.exportAll(plots, getBackupDirectory().toFile(),
|
||||||
"%world%-%id%-" + System.currentTimeMillis(), () ->
|
"%world%-%id%-" + System.currentTimeMillis(), () ->
|
||||||
future.complete(new Backup(this, System.currentTimeMillis(), null)));
|
future.complete(new Backup(this, System.currentTimeMillis(), null)));
|
||||||
if (!result) {
|
if (!result) {
|
||||||
@ -161,14 +170,14 @@ public class PlayerBackupProfile implements BackupProfile {
|
|||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
Schematic schematic = null;
|
Schematic schematic = null;
|
||||||
try {
|
try {
|
||||||
schematic = SchematicHandler.manager.getSchematic(backup.getFile().toFile());
|
schematic = this.schematicHandler.getSchematic(backup.getFile().toFile());
|
||||||
} catch (SchematicHandler.UnsupportedFormatException e) {
|
} catch (SchematicHandler.UnsupportedFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
if (schematic == null) {
|
if (schematic == null) {
|
||||||
future.completeExceptionally(new IllegalArgumentException("The backup is non-existent or not in the correct format"));
|
future.completeExceptionally(new IllegalArgumentException("The backup is non-existent or not in the correct format"));
|
||||||
} else {
|
} else {
|
||||||
SchematicHandler.manager.paste(schematic, plot, 0, 1, 0, false, new RunnableVal<Boolean>() {
|
this.schematicHandler.paste(schematic, plot, 0, 1, 0, false, new RunnableVal<Boolean>() {
|
||||||
@Override public void run(Boolean value) {
|
@Override public void run(Boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
future.complete(null);
|
future.complete(null);
|
||||||
|
@ -27,9 +27,12 @@ package com.plotsquared.core.backup;
|
|||||||
|
|
||||||
import com.google.common.cache.Cache;
|
import com.google.common.cache.Cache;
|
||||||
import com.google.common.cache.CacheBuilder;
|
import com.google.common.cache.CacheBuilder;
|
||||||
|
import com.google.inject.Inject;
|
||||||
|
import com.google.inject.Singleton;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
import com.plotsquared.core.inject.factory.PlayerBackupProfileFactory;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
@ -48,15 +51,17 @@ import java.util.concurrent.TimeUnit;
|
|||||||
/**
|
/**
|
||||||
* {@inheritDoc}
|
* {@inheritDoc}
|
||||||
*/
|
*/
|
||||||
@RequiredArgsConstructor public class SimpleBackupManager implements BackupManager {
|
@RequiredArgsConstructor @Singleton public class SimpleBackupManager implements BackupManager {
|
||||||
|
|
||||||
@Getter private final Path backupPath;
|
@Getter private final Path backupPath;
|
||||||
private final boolean automaticBackup;
|
private final boolean automaticBackup;
|
||||||
@Getter private final int backupLimit;
|
@Getter private final int backupLimit;
|
||||||
private final Cache<PlotCacheKey, BackupProfile> backupProfileCache = CacheBuilder.newBuilder()
|
private final Cache<PlotCacheKey, BackupProfile> backupProfileCache = CacheBuilder.newBuilder()
|
||||||
.expireAfterAccess(3, TimeUnit.MINUTES).build();
|
.expireAfterAccess(3, TimeUnit.MINUTES).build();
|
||||||
|
private final PlayerBackupProfileFactory playerBackupProfileFactory;
|
||||||
|
|
||||||
public SimpleBackupManager() throws Exception {
|
@Inject public SimpleBackupManager(@NotNull final PlayerBackupProfileFactory playerBackupProfileFactory) throws Exception {
|
||||||
|
this.playerBackupProfileFactory = playerBackupProfileFactory;
|
||||||
this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
|
this.backupPath = Objects.requireNonNull(PlotSquared.platform()).getDirectory().toPath().resolve("backups");
|
||||||
if (!Files.exists(backupPath)) {
|
if (!Files.exists(backupPath)) {
|
||||||
Files.createDirectory(backupPath);
|
Files.createDirectory(backupPath);
|
||||||
@ -68,9 +73,9 @@ import java.util.concurrent.TimeUnit;
|
|||||||
@Override @NotNull public BackupProfile getProfile(@NotNull final Plot plot) {
|
@Override @NotNull public BackupProfile getProfile(@NotNull final Plot plot) {
|
||||||
if (plot.hasOwner() && !plot.isMerged()) {
|
if (plot.hasOwner() && !plot.isMerged()) {
|
||||||
try {
|
try {
|
||||||
return backupProfileCache.get(new PlotCacheKey(plot), () -> new PlayerBackupProfile(plot.getOwnerAbs(), plot, this));
|
return backupProfileCache.get(new PlotCacheKey(plot), () -> this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot));
|
||||||
} catch (ExecutionException e) {
|
} catch (ExecutionException e) {
|
||||||
final BackupProfile profile = new PlayerBackupProfile(plot.getOwnerAbs(), plot, this);
|
final BackupProfile profile = this.playerBackupProfileFactory.create(plot.getOwnerAbs(), plot);
|
||||||
this.backupProfileCache.put(new PlotCacheKey(plot), profile);
|
this.backupProfileCache.put(new PlotCacheKey(plot), profile);
|
||||||
return profile;
|
return profile;
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.annoations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
|
@ -25,7 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.google.inject.Inject;
|
||||||
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.backup.BackupProfile;
|
import com.plotsquared.core.backup.BackupProfile;
|
||||||
import com.plotsquared.core.backup.NullBackupProfile;
|
import com.plotsquared.core.backup.NullBackupProfile;
|
||||||
import com.plotsquared.core.backup.PlayerBackupProfile;
|
import com.plotsquared.core.backup.PlayerBackupProfile;
|
||||||
@ -35,6 +36,7 @@ import com.plotsquared.core.plot.Plot;
|
|||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.task.RunnableVal2;
|
import com.plotsquared.core.util.task.RunnableVal2;
|
||||||
import com.plotsquared.core.util.task.RunnableVal3;
|
import com.plotsquared.core.util.task.RunnableVal3;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.time.Instant;
|
import java.time.Instant;
|
||||||
@ -60,8 +62,11 @@ import java.util.stream.Stream;
|
|||||||
permission = "plots.backup")
|
permission = "plots.backup")
|
||||||
public final class Backup extends Command {
|
public final class Backup extends Command {
|
||||||
|
|
||||||
public Backup() {
|
private final BackupManager backupManager;
|
||||||
|
|
||||||
|
@Inject public Backup(@NotNull final BackupManager backupManager) {
|
||||||
super(MainCommand.getInstance(), true);
|
super(MainCommand.getInstance(), true);
|
||||||
|
this.backupManager = backupManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
|
private static boolean sendMessage(PlotPlayer player, Captions message, Object... args) {
|
||||||
@ -90,8 +95,7 @@ public final class Backup extends Command {
|
|||||||
|
|
||||||
final Plot plot = player.getCurrentPlot();
|
final Plot plot = player.getCurrentPlot();
|
||||||
if (plot != null) {
|
if (plot != null) {
|
||||||
final BackupProfile backupProfile =
|
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
|
||||||
if (backupProfile instanceof PlayerBackupProfile) {
|
if (backupProfile instanceof PlayerBackupProfile) {
|
||||||
final CompletableFuture<List<com.plotsquared.core.backup.Backup>> backupList =
|
final CompletableFuture<List<com.plotsquared.core.backup.Backup>> backupList =
|
||||||
backupProfile.listBackups();
|
backupProfile.listBackups();
|
||||||
@ -135,8 +139,7 @@ public final class Backup extends Command {
|
|||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
|
||||||
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
||||||
} else {
|
} else {
|
||||||
final BackupProfile backupProfile =
|
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
|
||||||
if (backupProfile instanceof NullBackupProfile) {
|
if (backupProfile instanceof NullBackupProfile) {
|
||||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||||
Captions.GENERIC_OTHER.getTranslated());
|
Captions.GENERIC_OTHER.getTranslated());
|
||||||
@ -175,8 +178,7 @@ public final class Backup extends Command {
|
|||||||
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
|
.hasPermission(player, Captions.PERMISSION_ADMIN_BACKUP_OTHER)) {
|
||||||
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
sendMessage(player, Captions.NO_PERMISSION, Captions.PERMISSION_ADMIN_BACKUP_OTHER);
|
||||||
} else {
|
} else {
|
||||||
final BackupProfile backupProfile =
|
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
|
||||||
if (backupProfile instanceof NullBackupProfile) {
|
if (backupProfile instanceof NullBackupProfile) {
|
||||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||||
Captions.GENERIC_OTHER.getTranslated());
|
Captions.GENERIC_OTHER.getTranslated());
|
||||||
@ -237,8 +239,7 @@ public final class Backup extends Command {
|
|||||||
sendMessage(player, Captions.NOT_A_NUMBER, args[0]);
|
sendMessage(player, Captions.NOT_A_NUMBER, args[0]);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
final BackupProfile backupProfile =
|
final BackupProfile backupProfile = Objects.requireNonNull(this.backupManager.getProfile(plot));
|
||||||
Objects.requireNonNull(PlotSquared.platform()).getBackupManager().getProfile(plot);
|
|
||||||
if (backupProfile instanceof NullBackupProfile) {
|
if (backupProfile instanceof NullBackupProfile) {
|
||||||
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
sendMessage(player, Captions.BACKUP_IMPOSSIBLE,
|
||||||
Captions.GENERIC_OTHER.getTranslated());
|
Captions.GENERIC_OTHER.getTranslated());
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.database.Database;
|
import com.plotsquared.core.database.Database;
|
||||||
|
@ -28,8 +28,8 @@ package com.plotsquared.core.command;
|
|||||||
import com.google.gson.JsonObject;
|
import com.google.gson.JsonObject;
|
||||||
import com.google.gson.JsonParser;
|
import com.google.gson.JsonParser;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.ConfigFile;
|
import com.plotsquared.core.inject.annotations.ConfigFile;
|
||||||
import com.plotsquared.core.annoations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.annoations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.MemorySection;
|
import com.plotsquared.core.configuration.MemorySection;
|
||||||
|
@ -26,8 +26,8 @@
|
|||||||
package com.plotsquared.core.command;
|
package com.plotsquared.core.command;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.annoations.WorldFile;
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.components;
|
package com.plotsquared.core.components;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.backup.BackupManager;
|
import com.plotsquared.core.backup.BackupManager;
|
||||||
import com.plotsquared.core.command.MainCommand;
|
import com.plotsquared.core.command.MainCommand;
|
||||||
@ -36,13 +37,14 @@ import com.plotsquared.core.player.PlotPlayer;
|
|||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.plot.PlotInventory;
|
import com.plotsquared.core.plot.PlotInventory;
|
||||||
import com.plotsquared.core.plot.PlotItemStack;
|
import com.plotsquared.core.plot.PlotItemStack;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
|
||||||
import com.plotsquared.core.util.EconHandler;
|
import com.plotsquared.core.util.EconHandler;
|
||||||
|
import com.plotsquared.core.util.InventoryUtil;
|
||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.PatternUtil;
|
import com.plotsquared.core.util.PatternUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -59,8 +61,13 @@ public class ComponentPresetManager {
|
|||||||
|
|
||||||
private final List<ComponentPreset> presets;
|
private final List<ComponentPreset> presets;
|
||||||
private final String guiName;
|
private final String guiName;
|
||||||
|
private final EconHandler econHandler;
|
||||||
|
private final InventoryUtil inventoryUtil;
|
||||||
|
|
||||||
public ComponentPresetManager() {
|
@Inject public ComponentPresetManager(@Nullable final EconHandler econHandler, @NotNull final
|
||||||
|
InventoryUtil inventoryUtil) {
|
||||||
|
this.econHandler = econHandler;
|
||||||
|
this.inventoryUtil = inventoryUtil;
|
||||||
final File file = new File(Objects.requireNonNull(PlotSquared.platform()).getDirectory(), "components.yml");
|
final File file = new File(Objects.requireNonNull(PlotSquared.platform()).getDirectory(), "components.yml");
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
boolean created = false;
|
boolean created = false;
|
||||||
@ -144,7 +151,7 @@ public class ComponentPresetManager {
|
|||||||
allowedPresets.add(componentPreset);
|
allowedPresets.add(componentPreset);
|
||||||
}
|
}
|
||||||
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
|
final int size = (int) Math.ceil((double) allowedPresets.size() / 9.0D);
|
||||||
final PlotInventory plotInventory = new PlotInventory(player, size, this.guiName) {
|
final PlotInventory plotInventory = new PlotInventory(this.inventoryUtil, player, size, this.guiName) {
|
||||||
@Override public boolean onClick(final int index) {
|
@Override public boolean onClick(final int index) {
|
||||||
if (!player.getCurrentPlot().equals(plot)) {
|
if (!player.getCurrentPlot().equals(plot)) {
|
||||||
return false;
|
return false;
|
||||||
@ -170,12 +177,12 @@ public class ComponentPresetManager {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (componentPreset.getCost() > 0.0D && EconHandler.getEconHandler() != null && plot.getArea().useEconomy()) {
|
if (componentPreset.getCost() > 0.0D && econHandler != null && plot.getArea().useEconomy()) {
|
||||||
if (EconHandler.getEconHandler().getMoney(player) < componentPreset.getCost()) {
|
if (econHandler.getMoney(player) < componentPreset.getCost()) {
|
||||||
Captions.PRESET_CANNOT_AFFORD.send(player);
|
Captions.PRESET_CANNOT_AFFORD.send(player);
|
||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
EconHandler.getEconHandler().withdrawMoney(player, componentPreset.getCost());
|
econHandler.withdrawMoney(player, componentPreset.getCost());
|
||||||
Captions.REMOVED_BALANCE.send(player, componentPreset.getCost() + "");
|
Captions.REMOVED_BALANCE.send(player, componentPreset.getCost() + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -186,7 +193,7 @@ public class ComponentPresetManager {
|
|||||||
current.setComponent(componentPreset.getComponent().name(), pattern);
|
current.setComponent(componentPreset.getComponent().name(), pattern);
|
||||||
}
|
}
|
||||||
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
MainUtil.sendMessage(player, Captions.GENERATING_COMPONENT);
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(plot::removeRunning);
|
PlotSquared.platform().getGlobalBlockQueue().addEmptyTask(plot::removeRunning);
|
||||||
});
|
});
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
@ -196,7 +203,7 @@ public class ComponentPresetManager {
|
|||||||
for (int i = 0; i < allowedPresets.size(); i++) {
|
for (int i = 0; i < allowedPresets.size(); i++) {
|
||||||
final ComponentPreset preset = allowedPresets.get(i);
|
final ComponentPreset preset = allowedPresets.get(i);
|
||||||
final List<String> lore = new ArrayList<>();
|
final List<String> lore = new ArrayList<>();
|
||||||
if (preset.getCost() > 0 && EconHandler.getEconHandler() != null && plot.getArea().useEconomy()){
|
if (preset.getCost() > 0 && this.econHandler != null && plot.getArea().useEconomy()){
|
||||||
lore.add(Captions.PRESET_LORE_COST.getTranslated().replace("%cost%",
|
lore.add(Captions.PRESET_LORE_COST.getTranslated().replace("%cost%",
|
||||||
String.format("%.2f", preset.getCost())));
|
String.format("%.2f", preset.getCost())));
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ package com.plotsquared.core.database;
|
|||||||
|
|
||||||
import com.google.common.base.Charsets;
|
import com.google.common.base.Charsets;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
@ -1842,7 +1842,7 @@ public class SQLManager implements AbstractDB {
|
|||||||
}
|
}
|
||||||
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
Plot p = new Plot(plot_id, user, new HashSet<>(), new HashSet<>(),
|
||||||
new HashSet<>(), "", null, null, null,
|
new HashSet<>(), "", null, null, null,
|
||||||
new boolean[] {false, false, false, false}, time, id, this.eventDispatcher, this.plotListener);
|
new boolean[] {false, false, false, false}, time, id);
|
||||||
HashMap<PlotId, Plot> map = newPlots.get(areaID);
|
HashMap<PlotId, Plot> map = newPlots.get(areaID);
|
||||||
if (map != null) {
|
if (map != null) {
|
||||||
Plot last = map.put(p.getId(), p);
|
Plot last = map.put(p.getId(), p);
|
||||||
|
@ -32,7 +32,6 @@ import com.plotsquared.core.plot.PlotAreaTerrainType;
|
|||||||
import com.plotsquared.core.plot.PlotAreaType;
|
import com.plotsquared.core.plot.PlotAreaType;
|
||||||
import com.plotsquared.core.plot.PlotManager;
|
import com.plotsquared.core.plot.PlotManager;
|
||||||
import com.plotsquared.core.queue.AreaBoundDelegateLocalBlockQueue;
|
import com.plotsquared.core.queue.AreaBoundDelegateLocalBlockQueue;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.queue.LocationOffsetDelegateLocalBlockQueue;
|
import com.plotsquared.core.queue.LocationOffsetDelegateLocalBlockQueue;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
@ -87,7 +86,7 @@ public class AugmentedUtils {
|
|||||||
IndependentPlotGenerator generator = area.getGenerator();
|
IndependentPlotGenerator generator = area.getGenerator();
|
||||||
// Mask
|
// Mask
|
||||||
if (queue == null) {
|
if (queue == null) {
|
||||||
queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
queue.setChunkObject(chunkObject);
|
queue.setChunkObject(chunkObject);
|
||||||
}
|
}
|
||||||
LocalBlockQueue primaryMask;
|
LocalBlockQueue primaryMask;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
|
@ -25,13 +25,16 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
||||||
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
public abstract class GridPlotWorld extends PlotArea {
|
public abstract class GridPlotWorld extends PlotArea {
|
||||||
|
|
||||||
@ -39,7 +42,9 @@ public abstract class GridPlotWorld extends PlotArea {
|
|||||||
|
|
||||||
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
public GridPlotWorld(String worldName, String id, @NotNull IndependentPlotGenerator generator,
|
||||||
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
PlotId min, PlotId max, @NotNull final EventDispatcher eventDispatcher, @NotNull final
|
||||||
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
PlotListener plotListener, @WorldConfig @NotNull final YamlConfiguration worldConfiguration,
|
||||||
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration);
|
@NotNull final GlobalBlockQueue blockQueue,
|
||||||
|
@Nullable final EconHandler econHandler) {
|
||||||
|
super(worldName, id, generator, min, max, eventDispatcher, plotListener, worldConfiguration, blockQueue, econHandler);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -26,8 +26,9 @@
|
|||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.google.common.base.Preconditions;
|
import com.google.common.base.Preconditions;
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
@ -48,7 +49,7 @@ public class HybridGen extends IndependentPlotGenerator {
|
|||||||
private final PlotListener plotListener;
|
private final PlotListener plotListener;
|
||||||
private final YamlConfiguration worldConfiguration;
|
private final YamlConfiguration worldConfiguration;
|
||||||
|
|
||||||
public HybridGen(@NotNull final EventDispatcher eventDispatcher,
|
@Inject public HybridGen(@NotNull final EventDispatcher eventDispatcher,
|
||||||
@NotNull final PlotListener plotListener,
|
@NotNull final PlotListener plotListener,
|
||||||
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
@WorldConfig @NotNull final YamlConfiguration worldConfiguration) {
|
||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.events.PlotFlagAddEvent;
|
import com.plotsquared.core.events.PlotFlagAddEvent;
|
||||||
@ -76,9 +77,8 @@ import java.util.Set;
|
|||||||
import java.util.concurrent.atomic.AtomicBoolean;
|
import java.util.concurrent.atomic.AtomicBoolean;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
|
|
||||||
public abstract class HybridUtils {
|
public class HybridUtils {
|
||||||
|
|
||||||
public static HybridUtils manager;
|
|
||||||
public static Set<BlockVector2> regions;
|
public static Set<BlockVector2> regions;
|
||||||
public static int height;
|
public static int height;
|
||||||
public static Set<BlockVector2> chunks = new HashSet<>();
|
public static Set<BlockVector2> chunks = new HashSet<>();
|
||||||
@ -86,14 +86,26 @@ public abstract class HybridUtils {
|
|||||||
public static boolean UPDATE = false;
|
public static boolean UPDATE = false;
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final ChunkManager chunkManager;
|
||||||
|
private final GlobalBlockQueue blockQueue;
|
||||||
|
private final WorldUtil worldUtil;
|
||||||
|
private final RegionManager regionManager;
|
||||||
|
private final SchematicHandler schematicHandler;
|
||||||
|
|
||||||
public HybridUtils(@NotNull final PlotAreaManager plotAreaManager) {
|
@Inject public HybridUtils(@NotNull final PlotAreaManager plotAreaManager,
|
||||||
|
@NotNull final ChunkManager chunkManager, @NotNull final GlobalBlockQueue blockQueue,
|
||||||
|
@NotNull final WorldUtil worldUtil, @NotNull final RegionManager regionManager, @NotNull final SchematicHandler schematicHandler) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.chunkManager = chunkManager;
|
||||||
|
this.blockQueue = blockQueue;
|
||||||
|
this.worldUtil = worldUtil;
|
||||||
|
this.regionManager = regionManager;
|
||||||
|
this.schematicHandler = schematicHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean regeneratePlotWalls(final PlotArea area) {
|
public void regeneratePlotWalls(final PlotArea area) {
|
||||||
PlotManager plotManager = area.getPlotManager();
|
PlotManager plotManager = area.getPlotManager();
|
||||||
return plotManager.regenerateAllPlotWalls();
|
plotManager.regenerateAllPlotWalls();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void analyzeRegion(final String world, final CuboidRegion region,
|
public void analyzeRegion(final String world, final CuboidRegion region,
|
||||||
@ -111,7 +123,7 @@ public abstract class HybridUtils {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
||||||
|
|
||||||
final BlockVector3 bot = region.getMinimumPoint();
|
final BlockVector3 bot = region.getMinimumPoint();
|
||||||
final BlockVector3 top = region.getMaximumPoint();
|
final BlockVector3 top = region.getMaximumPoint();
|
||||||
@ -365,7 +377,7 @@ public abstract class HybridUtils {
|
|||||||
for (int z = z1; z <= z2; z++) {
|
for (int z = z1; z <= z2; z++) {
|
||||||
BlockState block = queue.getBlock(x, y, z);
|
BlockState block = queue.getBlock(x, y, z);
|
||||||
boolean same =
|
boolean same =
|
||||||
Arrays.stream(blocks).anyMatch(p -> WorldUtil.IMP.isBlockSame(block, p));
|
Arrays.stream(blocks).anyMatch(p -> this.worldUtil.isBlockSame(block, p));
|
||||||
if (!same) {
|
if (!same) {
|
||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
@ -392,7 +404,7 @@ public abstract class HybridUtils {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
HybridUtils.UPDATE = true;
|
HybridUtils.UPDATE = true;
|
||||||
Set<BlockVector2> regions = RegionManager.manager.getChunkChunks(area.getWorldName());
|
Set<BlockVector2> regions = this.regionManager.getChunkChunks(area.getWorldName());
|
||||||
return scheduleRoadUpdate(area, regions, extend, new HashSet<>());
|
return scheduleRoadUpdate(area, regions, extend, new HashSet<>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -424,7 +436,7 @@ public abstract class HybridUtils {
|
|||||||
if (!regenedRoad) {
|
if (!regenedRoad) {
|
||||||
PlotSquared.debug("Failed to regenerate roads.");
|
PlotSquared.debug("Failed to regenerate roads.");
|
||||||
}
|
}
|
||||||
ChunkManager.manager.unloadChunk(area.getWorldName(), chunk, true);
|
chunkManager.unloadChunk(area.getWorldName(), chunk, true);
|
||||||
}
|
}
|
||||||
PlotSquared.debug("Cancelled road task");
|
PlotSquared.debug("Cancelled road task");
|
||||||
return;
|
return;
|
||||||
@ -460,7 +472,7 @@ public abstract class HybridUtils {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!chunks.isEmpty()) {
|
if (!chunks.isEmpty()) {
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.getImplementation().sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
long start = System.currentTimeMillis();
|
long start = System.currentTimeMillis();
|
||||||
Iterator<BlockVector2> iterator = chunks.iterator();
|
Iterator<BlockVector2> iterator = chunks.iterator();
|
||||||
@ -489,15 +501,14 @@ public abstract class HybridUtils {
|
|||||||
int sz = loc.getZ() << 5;
|
int sz = loc.getZ() << 5;
|
||||||
for (int x = sx; x < sx + 32; x++) {
|
for (int x = sx; x < sx + 32; x++) {
|
||||||
for (int z = sz; z < sz + 32; z++) {
|
for (int z = sz; z < sz + 32; z++) {
|
||||||
ChunkManager.manager
|
chunkManager.unloadChunk(area.getWorldName(), BlockVector2.at(x, z),
|
||||||
.unloadChunk(area.getWorldName(), BlockVector2.at(x, z),
|
|
||||||
true);
|
true);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
PlotSquared.debug(" - Potentially skipping 1024 chunks");
|
PlotSquared.debug(" - Potentially skipping 1024 chunks");
|
||||||
PlotSquared.debug(" - TODO: recommend chunkster if corrupt");
|
PlotSquared.debug(" - TODO: recommend chunkster if corrupt");
|
||||||
}
|
}
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
|
blockQueue.addEmptyTask(() -> TaskManager.runTaskLater(task, 20));
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -507,7 +518,7 @@ public abstract class HybridUtils {
|
|||||||
|
|
||||||
public boolean setupRoadSchematic(Plot plot) {
|
public boolean setupRoadSchematic(Plot plot) {
|
||||||
final String world = plot.getWorldName();
|
final String world = plot.getWorldName();
|
||||||
final LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
final LocalBlockQueue queue = blockQueue.getNewQueue(world, false);
|
||||||
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
Location bot = plot.getBottomAbs().subtract(1, 0, 1);
|
||||||
Location top = plot.getTopAbs();
|
Location top = plot.getTopAbs();
|
||||||
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
final HybridPlotWorld plotworld = (HybridPlotWorld) plot.getArea();
|
||||||
@ -531,13 +542,12 @@ public abstract class HybridUtils {
|
|||||||
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea()
|
"schematics" + File.separator + "GEN_ROAD_SCHEMATIC" + File.separator + plot.getArea()
|
||||||
.toString() + File.separator;
|
.toString() + File.separator;
|
||||||
|
|
||||||
SchematicHandler.manager.getCompoundTag(world, sideRoad, new RunnableVal<CompoundTag>() {
|
this.schematicHandler.getCompoundTag(world, sideRoad, new RunnableVal<CompoundTag>() {
|
||||||
@Override public void run(CompoundTag value) {
|
@Override public void run(CompoundTag value) {
|
||||||
SchematicHandler.manager.save(value, dir + "sideroad.schem");
|
schematicHandler.save(value, dir + "sideroad.schem");
|
||||||
SchematicHandler.manager
|
schematicHandler.getCompoundTag(world, intersection, new RunnableVal<CompoundTag>() {
|
||||||
.getCompoundTag(world, intersection, new RunnableVal<CompoundTag>() {
|
|
||||||
@Override public void run(CompoundTag value) {
|
@Override public void run(CompoundTag value) {
|
||||||
SchematicHandler.manager.save(value, dir + "intersection.schem");
|
schematicHandler.save(value, dir + "intersection.schem");
|
||||||
plotworld.ROAD_SCHEMATIC_ENABLED = true;
|
plotworld.ROAD_SCHEMATIC_ENABLED = true;
|
||||||
try {
|
try {
|
||||||
plotworld.setupSchematics();
|
plotworld.setupSchematics();
|
||||||
@ -595,9 +605,9 @@ public abstract class HybridUtils {
|
|||||||
z -= plotWorld.ROAD_OFFSET_Z;
|
z -= plotWorld.ROAD_OFFSET_Z;
|
||||||
final int finalX = x;
|
final int finalX = x;
|
||||||
final int finalZ = z;
|
final int finalZ = z;
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(plotWorld.getWorldName(), false);
|
LocalBlockQueue queue = this.blockQueue.getNewQueue(plotWorld.getWorldName(), false);
|
||||||
if (id1 == null || id2 == null || id1 != id2) {
|
if (id1 == null || id2 == null || id1 != id2) {
|
||||||
ChunkManager.manager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
this.chunkManager.loadChunk(area.getWorldName(), chunk, false).thenRun(() -> {
|
||||||
if (id1 != null) {
|
if (id1 != null) {
|
||||||
Plot p1 = area.getPlotAbs(id1);
|
Plot p1 = area.getPlotAbs(id1);
|
||||||
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
|
if (p1 != null && p1.hasOwner() && p1.isMerged()) {
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotId;
|
import com.plotsquared.core.plot.PlotId;
|
||||||
@ -47,7 +48,7 @@ public class SingleWorldGenerator extends IndependentPlotGenerator {
|
|||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
|
||||||
public SingleWorldGenerator(@NotNull final PlotAreaManager plotAreaManager) {
|
@Inject public SingleWorldGenerator(@NotNull final PlotAreaManager plotAreaManager) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.generator;
|
package com.plotsquared.core.generator;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
|
@ -23,16 +23,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.bukkit.generator;
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
import com.plotsquared.core.generator.HybridUtils;
|
import java.lang.annotation.ElementType;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import java.lang.annotation.Retention;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
public class BukkitHybridUtils extends HybridUtils {
|
|
||||||
|
|
||||||
public BukkitHybridUtils(@NotNull PlotAreaManager plotAreaManager) {
|
|
||||||
super(plotAreaManager);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface BackgroundPipeline {
|
||||||
}
|
}
|
@ -23,7 +23,7 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.annoations;
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target(ElementType.PARAMETER)
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface ConsoleActor {
|
||||||
|
}
|
@ -0,0 +1,11 @@
|
|||||||
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface DefaultGenerator {
|
||||||
|
}
|
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
|
import java.lang.annotation.ElementType;
|
||||||
|
import java.lang.annotation.Retention;
|
||||||
|
import java.lang.annotation.RetentionPolicy;
|
||||||
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||||
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
|
public @interface ImpromptuPipeline {
|
||||||
|
}
|
@ -23,14 +23,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.annoations;
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@Target(ElementType.PARAMETER)
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface WorldConfig {
|
public @interface WorldConfig {
|
||||||
}
|
}
|
@ -23,14 +23,14 @@
|
|||||||
* You should have received a copy of the GNU General Public License
|
* You should have received a copy of the GNU General Public License
|
||||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
*/
|
*/
|
||||||
package com.plotsquared.core.annoations;
|
package com.plotsquared.core.inject.annotations;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
import java.lang.annotation.ElementType;
|
||||||
import java.lang.annotation.Retention;
|
import java.lang.annotation.Retention;
|
||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@Target(ElementType.PARAMETER)
|
@Target({ElementType.PARAMETER, ElementType.FIELD})
|
||||||
@Retention(RetentionPolicy.RUNTIME)
|
@Retention(RetentionPolicy.RUNTIME)
|
||||||
public @interface WorldFile {
|
public @interface WorldFile {
|
||||||
}
|
}
|
@ -0,0 +1,13 @@
|
|||||||
|
package com.plotsquared.core.inject.factory;
|
||||||
|
|
||||||
|
import com.plotsquared.core.backup.PlayerBackupProfile;
|
||||||
|
import com.plotsquared.core.plot.Plot;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
|
public interface PlayerBackupProfileFactory {
|
||||||
|
|
||||||
|
PlayerBackupProfile create(@NotNull UUID uuid, @NotNull Plot plot);
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,59 @@
|
|||||||
|
/*
|
||||||
|
* _____ _ _ _____ _
|
||||||
|
* | __ \| | | | / ____| | |
|
||||||
|
* | |__) | | ___ | |_| (___ __ _ _ _ __ _ _ __ ___ __| |
|
||||||
|
* | ___/| |/ _ \| __|\___ \ / _` | | | |/ _` | '__/ _ \/ _` |
|
||||||
|
* | | | | (_) | |_ ____) | (_| | |_| | (_| | | | __/ (_| |
|
||||||
|
* |_| |_|\___/ \__|_____/ \__, |\__,_|\__,_|_| \___|\__,_|
|
||||||
|
* | |
|
||||||
|
* |_|
|
||||||
|
* PlotSquared plot management system for Minecraft
|
||||||
|
* Copyright (C) 2020 IntellectualSites
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU General Public License
|
||||||
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
package com.plotsquared.core.inject.modules;
|
||||||
|
|
||||||
|
import com.google.inject.AbstractModule;
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
|
import com.plotsquared.core.inject.annotations.BackgroundPipeline;
|
||||||
|
import com.plotsquared.core.inject.annotations.ConfigFile;
|
||||||
|
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
|
||||||
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
|
import com.plotsquared.core.inject.annotations.WorldFile;
|
||||||
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
|
||||||
|
public class PlotSquaredModule extends AbstractModule {
|
||||||
|
|
||||||
|
@Override protected void configure() {
|
||||||
|
final PlotSquared plotSquared = PlotSquared.get();
|
||||||
|
bind(YamlConfiguration.class).annotatedWith(WorldConfig.class).toInstance(plotSquared.getWorldConfiguration());
|
||||||
|
bind(File.class).annotatedWith(WorldFile.class).toInstance(plotSquared.getWorldsFile());
|
||||||
|
bind(File.class).annotatedWith(ConfigFile.class).toInstance(plotSquared.getConfigFile());
|
||||||
|
bind(PlotAreaManager.class).toInstance(plotSquared.getPlotAreaManager());
|
||||||
|
bind(PlotListener.class).toInstance(plotSquared.getPlotListener());
|
||||||
|
bind(UUIDPipeline.class).annotatedWith(ImpromptuPipeline.class).toInstance(plotSquared.getImpromptuUUIDPipeline());
|
||||||
|
bind(UUIDPipeline.class).annotatedWith(BackgroundPipeline.class).toInstance(plotSquared.getBackgroundUUIDPipeline());
|
||||||
|
bind(WorldEdit.class).toInstance(WorldEdit.getInstance());
|
||||||
|
bind(EventDispatcher.class).toInstance(plotSquared.getEventDispatcher());
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -59,27 +59,30 @@ import com.plotsquared.core.util.EventDispatcher;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameMode;
|
import com.sk89q.worldedit.world.gamemode.GameMode;
|
||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import com.sk89q.worldedit.world.item.ItemTypes;
|
import com.sk89q.worldedit.world.item.ItemTypes;
|
||||||
import lombok.RequiredArgsConstructor;
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@RequiredArgsConstructor public class PlotListener {
|
public class PlotListener {
|
||||||
|
|
||||||
private final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
private final HashMap<UUID, Interval> feedRunnable = new HashMap<>();
|
||||||
private final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
private final HashMap<UUID, Interval> healRunnable = new HashMap<>();
|
||||||
|
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
|
|
||||||
|
public PlotListener(@Nullable final EventDispatcher eventDispatcher) {
|
||||||
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
}
|
||||||
|
|
||||||
public void startRunnable() {
|
public void startRunnable() {
|
||||||
TaskManager.runTaskRepeat(() -> {
|
TaskManager.runTaskRepeat(() -> {
|
||||||
if (!healRunnable.isEmpty()) {
|
if (!healRunnable.isEmpty()) {
|
||||||
@ -90,15 +93,14 @@ import java.util.UUID;
|
|||||||
++value.count;
|
++value.count;
|
||||||
if (value.count == value.interval) {
|
if (value.count == value.interval) {
|
||||||
value.count = 0;
|
value.count = 0;
|
||||||
PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
|
PlotPlayer<?> player = PlotPlayer.wrap(entry.getKey());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
double level = WorldUtil.IMP.getHealth(player);
|
double level = PlotSquared.platform().getWorldUtil().getHealth(player);
|
||||||
if (level != value.max) {
|
if (level != value.max) {
|
||||||
WorldUtil.IMP
|
PlotSquared.platform().getWorldUtil().setHealth(player, Math.min(level + value.amount, value.max));
|
||||||
.setHealth(player, Math.min(level + value.amount, value.max));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -111,15 +113,14 @@ import java.util.UUID;
|
|||||||
++value.count;
|
++value.count;
|
||||||
if (value.count == value.interval) {
|
if (value.count == value.interval) {
|
||||||
value.count = 0;
|
value.count = 0;
|
||||||
PlotPlayer player = WorldUtil.IMP.wrapPlayer(entry.getKey());
|
PlotPlayer<?> player = PlotSquared.platform().getWorldUtil().wrapPlayer(entry.getKey());
|
||||||
if (player == null) {
|
if (player == null) {
|
||||||
iterator.remove();
|
iterator.remove();
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
int level = WorldUtil.IMP.getFoodLevel(player);
|
int level = PlotSquared.platform().getWorldUtil().getFoodLevel(player);
|
||||||
if (level != value.max) {
|
if (level != value.max) {
|
||||||
WorldUtil.IMP
|
PlotSquared.platform().getWorldUtil().setFoodLevel(player, Math.min(level + value.amount, value.max));
|
||||||
.setFoodLevel(player, Math.min(level + value.amount, value.max));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,7 @@ import com.sk89q.worldedit.world.biome.BiomeType;
|
|||||||
import com.sk89q.worldedit.world.block.BaseBlock;
|
import com.sk89q.worldedit.world.block.BaseBlock;
|
||||||
import com.sk89q.worldedit.world.block.BlockState;
|
import com.sk89q.worldedit.world.block.BlockState;
|
||||||
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
import com.sk89q.worldedit.world.block.BlockStateHolder;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -55,17 +56,19 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
private final Set<CuboidRegion> mask;
|
private final Set<CuboidRegion> mask;
|
||||||
private final String world;
|
private final String world;
|
||||||
private final int max;
|
private final int max;
|
||||||
|
private final WorldUtil worldUtil;
|
||||||
|
|
||||||
int Ecount = 0;
|
int Ecount = 0;
|
||||||
boolean Eblocked = false;
|
boolean Eblocked = false;
|
||||||
private int count;
|
private int count;
|
||||||
private Extent parent;
|
private Extent parent;
|
||||||
private Map<Long, Integer[]> tileEntityCount = new HashMap<>();
|
private Map<Long, Integer[]> tileEntityCount = new HashMap<>();
|
||||||
|
|
||||||
public ProcessedWEExtent(String world, Set<CuboidRegion> mask, int max, Extent child,
|
public ProcessedWEExtent(String world, Set<CuboidRegion> mask, int max, Extent child, Extent parent, @NotNull final WorldUtil worldUtil) {
|
||||||
Extent parent) {
|
|
||||||
super(child);
|
super(child);
|
||||||
this.mask = mask;
|
this.mask = mask;
|
||||||
this.world = world;
|
this.world = world;
|
||||||
|
this.worldUtil = worldUtil;
|
||||||
if (max == -1) {
|
if (max == -1) {
|
||||||
max = Integer.MAX_VALUE;
|
max = Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
@ -92,10 +95,10 @@ public class ProcessedWEExtent extends AbstractDelegateExtent {
|
|||||||
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
public <T extends BlockStateHolder<T>> boolean setBlock(BlockVector3 location, T block)
|
||||||
throws WorldEditException {
|
throws WorldEditException {
|
||||||
|
|
||||||
final boolean isTile = WorldUtil.IMP.getTileEntityTypes().contains(block.getBlockType());
|
final boolean isTile = this.worldUtil.getTileEntityTypes().contains(block.getBlockType());
|
||||||
if (isTile) {
|
if (isTile) {
|
||||||
final Integer[] tileEntityCount = this.tileEntityCount.computeIfAbsent(getChunkKey(location),
|
final Integer[] tileEntityCount = this.tileEntityCount.computeIfAbsent(getChunkKey(location),
|
||||||
key -> new Integer[] {WorldUtil.IMP.getTileEntityCount(world,
|
key -> new Integer[] {this.worldUtil.getTileEntityCount(world,
|
||||||
BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4))});
|
BlockVector2.at(location.getBlockX() >> 4, location.getBlockZ() >> 4))});
|
||||||
if (tileEntityCount[0] >= Settings.Chunk_Processor.MAX_TILES) {
|
if (tileEntityCount[0] >= Settings.Chunk_Processor.MAX_TILES) {
|
||||||
return false;
|
return false;
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.listener;
|
package com.plotsquared.core.listener;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
import com.plotsquared.core.configuration.Settings;
|
import com.plotsquared.core.configuration.Settings;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
@ -33,6 +34,7 @@ import com.plotsquared.core.plot.world.PlotAreaManager;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.Permissions;
|
import com.plotsquared.core.util.Permissions;
|
||||||
import com.plotsquared.core.util.WEManager;
|
import com.plotsquared.core.util.WEManager;
|
||||||
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.sk89q.worldedit.WorldEdit;
|
import com.sk89q.worldedit.WorldEdit;
|
||||||
import com.sk89q.worldedit.entity.Player;
|
import com.sk89q.worldedit.entity.Player;
|
||||||
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
import com.sk89q.worldedit.event.extent.EditSessionEvent;
|
||||||
@ -50,9 +52,11 @@ import java.util.Set;
|
|||||||
public class WESubscriber {
|
public class WESubscriber {
|
||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
|
private final WorldUtil worldUtil;
|
||||||
public WESubscriber(@NotNull final PlotAreaManager plotAreaManager) {
|
|
||||||
|
@Inject public WESubscriber(@NotNull final PlotAreaManager plotAreaManager, @NotNull final WorldUtil worldUtil) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
|
this.worldUtil = worldUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe(priority = Priority.VERY_EARLY) public void onEditSession(EditSessionEvent event) {
|
@Subscribe(priority = Priority.VERY_EARLY) public void onEditSession(EditSessionEvent event) {
|
||||||
@ -99,7 +103,7 @@ public class WESubscriber {
|
|||||||
if (this.plotAreaManager.hasPlotArea(world)) {
|
if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
event.setExtent(
|
event.setExtent(
|
||||||
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
|
new ProcessedWEExtent(world, mask, event.getMaxBlocks(), event.getExtent(),
|
||||||
event.getExtent()));
|
event.getExtent(), this.worldUtil));
|
||||||
}
|
}
|
||||||
} else if (this.plotAreaManager.hasPlotArea(world)) {
|
} else if (this.plotAreaManager.hasPlotArea(world)) {
|
||||||
event.setExtent(new WEExtent(mask, event.getExtent()));
|
event.setExtent(new WEExtent(mask, event.getExtent()));
|
||||||
|
@ -267,7 +267,7 @@ public final class Location implements Comparable<Location> {
|
|||||||
/**
|
/**
|
||||||
* Check whether or not the location belongs to a plot area
|
* Check whether or not the location belongs to a plot area
|
||||||
*
|
*
|
||||||
* @return {@code true} if the location belongs to a plot area, else {@link false}
|
* @return {@code true} if the location belongs to a plot area, else {@code false}
|
||||||
*/
|
*/
|
||||||
public boolean isPlotArea() {
|
public boolean isPlotArea() {
|
||||||
return this.getPlotArea() != null;
|
return this.getPlotArea() != null;
|
||||||
@ -276,7 +276,7 @@ public final class Location implements Comparable<Location> {
|
|||||||
/**
|
/**
|
||||||
* Check whether or not the location belongs to a plot road
|
* Check whether or not the location belongs to a plot road
|
||||||
*
|
*
|
||||||
* @return {@code true} if the location belongs to a plot road, else {@link false}
|
* @return {@code true} if the location belongs to a plot road, else {@code false}
|
||||||
*/
|
*/
|
||||||
public boolean isPlotRoad() {
|
public boolean isPlotRoad() {
|
||||||
final PlotArea area = this.getPlotArea();
|
final PlotArea area = this.getPlotArea();
|
||||||
@ -286,7 +286,7 @@ public final class Location implements Comparable<Location> {
|
|||||||
/**
|
/**
|
||||||
* Checks if anyone owns a plot at the current location.
|
* Checks if anyone owns a plot at the current location.
|
||||||
*
|
*
|
||||||
* @return {@link true} if the location is a road, not a plot area, or if the plot is unclaimed.
|
* @return {@code true} if the location is a road, not a plot area, or if the plot is unclaimed.
|
||||||
*/
|
*/
|
||||||
public boolean isUnownedPlotArea() {
|
public boolean isUnownedPlotArea() {
|
||||||
final PlotArea area = this.getPlotArea();
|
final PlotArea area = this.getPlotArea();
|
||||||
|
@ -25,14 +25,17 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.player;
|
package com.plotsquared.core.player;
|
||||||
|
|
||||||
|
import com.google.inject.Inject;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.command.RequiredType;
|
import com.plotsquared.core.command.RequiredType;
|
||||||
import com.plotsquared.core.database.DBFunc;
|
import com.plotsquared.core.database.DBFunc;
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
|
import com.plotsquared.core.inject.annotations.ConsoleActor;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.PlotArea;
|
import com.plotsquared.core.plot.PlotArea;
|
||||||
import com.plotsquared.core.plot.PlotWeather;
|
import com.plotsquared.core.plot.PlotWeather;
|
||||||
import com.plotsquared.core.plot.world.PlotAreaManager;
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
||||||
|
import com.plotsquared.core.util.EconHandler;
|
||||||
import com.plotsquared.core.util.EventDispatcher;
|
import com.plotsquared.core.util.EventDispatcher;
|
||||||
import com.sk89q.worldedit.extension.platform.Actor;
|
import com.sk89q.worldedit.extension.platform.Actor;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
@ -40,6 +43,7 @@ import com.sk89q.worldedit.world.gamemode.GameMode;
|
|||||||
import com.sk89q.worldedit.world.gamemode.GameModes;
|
import com.sk89q.worldedit.world.gamemode.GameModes;
|
||||||
import com.sk89q.worldedit.world.item.ItemType;
|
import com.sk89q.worldedit.world.item.ItemType;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
@ -47,8 +51,14 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
private static ConsolePlayer instance;
|
private static ConsolePlayer instance;
|
||||||
|
|
||||||
private ConsolePlayer(final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
private final Actor actor;
|
||||||
super(plotAreaManager, eventDispatcher);
|
|
||||||
|
@Inject private ConsolePlayer(@NotNull final PlotAreaManager plotAreaManager,
|
||||||
|
@NotNull final EventDispatcher eventDispatcher,
|
||||||
|
@ConsoleActor @NotNull final Actor actor,
|
||||||
|
@Nullable final EconHandler econHandler) {
|
||||||
|
super(plotAreaManager, eventDispatcher, econHandler);
|
||||||
|
this.actor = actor;
|
||||||
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
final PlotArea[] areas = plotAreaManager.getAllPlotAreas();
|
||||||
final PlotArea area;
|
final PlotArea area;
|
||||||
if (areas.length > 0) {
|
if (areas.length > 0) {
|
||||||
@ -70,14 +80,14 @@ public class ConsolePlayer extends PlotPlayer<Actor> {
|
|||||||
|
|
||||||
public static ConsolePlayer getConsole() {
|
public static ConsolePlayer getConsole() {
|
||||||
if (instance == null) {
|
if (instance == null) {
|
||||||
instance = new ConsolePlayer(PlotSquared.get().getPlotAreaManager(), PlotSquared.get().getEventDispatcher());
|
instance = PlotSquared.platform().getInjector().getInstance(ConsolePlayer.class);
|
||||||
instance.teleport(instance.getLocation());
|
instance.teleport(instance.getLocation());
|
||||||
}
|
}
|
||||||
return instance;
|
return instance;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Actor toActor() {
|
@Override public Actor toActor() {
|
||||||
return PlotSquared.platform().getConsole();
|
return this.actor;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public Actor getPlatformPlayer() {
|
@Override public Actor getPlatformPlayer() {
|
||||||
|
@ -91,10 +91,12 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
|
|
||||||
private final PlotAreaManager plotAreaManager;
|
private final PlotAreaManager plotAreaManager;
|
||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
|
private final EconHandler econHandler;
|
||||||
|
|
||||||
public PlotPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher) {
|
public PlotPlayer(@NotNull final PlotAreaManager plotAreaManager, @NotNull final EventDispatcher eventDispatcher, @Nullable final EconHandler econHandler) {
|
||||||
this.plotAreaManager = plotAreaManager;
|
this.plotAreaManager = plotAreaManager;
|
||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
|
this.econHandler = econHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
public static <T> PlotPlayer<T> from(@NonNull final T object) {
|
||||||
@ -764,23 +766,24 @@ public abstract class PlotPlayer<P> implements CommandCaller, OfflinePlotPlayer
|
|||||||
* The amount of money this Player has.
|
* The amount of money this Player has.
|
||||||
*/
|
*/
|
||||||
public double getMoney() {
|
public double getMoney() {
|
||||||
return EconHandler.getEconHandler() == null ? 0 : EconHandler.getEconHandler().getMoney(this);
|
return this.econHandler == null ? 0 : this.econHandler.getMoney(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void withdraw(double amount) {
|
public void withdraw(double amount) {
|
||||||
if (EconHandler.getEconHandler() != null) {
|
if (this.econHandler != null) {
|
||||||
EconHandler.getEconHandler().withdrawMoney(this, amount);
|
this.econHandler.withdrawMoney(this, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void deposit(double amount) {
|
public void deposit(double amount) {
|
||||||
if (EconHandler.getEconHandler() != null) {
|
if (this.econHandler != null) {
|
||||||
EconHandler.getEconHandler().depositMoney(this, amount);
|
this.econHandler.depositMoney(this, amount);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@FunctionalInterface
|
@FunctionalInterface
|
||||||
public interface PlotPlayerConverter<BaseObject> {
|
public interface PlotPlayerConverter<BaseObject> {
|
||||||
PlotPlayer convert(BaseObject object);
|
PlotPlayer<?> convert(BaseObject object);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -38,6 +38,7 @@ import com.plotsquared.core.events.PlotUnlinkEvent;
|
|||||||
import com.plotsquared.core.events.Result;
|
import com.plotsquared.core.events.Result;
|
||||||
import com.plotsquared.core.events.TeleportCause;
|
import com.plotsquared.core.events.TeleportCause;
|
||||||
import com.plotsquared.core.generator.SquarePlotWorld;
|
import com.plotsquared.core.generator.SquarePlotWorld;
|
||||||
|
import com.plotsquared.core.inject.annotations.ImpromptuPipeline;
|
||||||
import com.plotsquared.core.listener.PlotListener;
|
import com.plotsquared.core.listener.PlotListener;
|
||||||
import com.plotsquared.core.location.BlockLoc;
|
import com.plotsquared.core.location.BlockLoc;
|
||||||
import com.plotsquared.core.location.Direction;
|
import com.plotsquared.core.location.Direction;
|
||||||
@ -64,6 +65,7 @@ import com.plotsquared.core.util.SchematicHandler;
|
|||||||
import com.plotsquared.core.util.WorldUtil;
|
import com.plotsquared.core.util.WorldUtil;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
import com.plotsquared.core.util.task.TaskManager;
|
import com.plotsquared.core.util.task.TaskManager;
|
||||||
|
import com.plotsquared.core.uuid.UUIDPipeline;
|
||||||
import com.sk89q.jnbt.CompoundTag;
|
import com.sk89q.jnbt.CompoundTag;
|
||||||
import com.sk89q.worldedit.function.pattern.Pattern;
|
import com.sk89q.worldedit.function.pattern.Pattern;
|
||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
@ -124,9 +126,16 @@ public class Plot {
|
|||||||
private static Set<CuboidRegion> regions_cache;
|
private static Set<CuboidRegion> regions_cache;
|
||||||
|
|
||||||
@NotNull private final PlotId id;
|
@NotNull private final PlotId id;
|
||||||
@NotNull private final EventDispatcher eventDispatcher;
|
|
||||||
@NotNull private final PlotListener plotListener;
|
// These will be injected
|
||||||
|
private EventDispatcher eventDispatcher;
|
||||||
|
private PlotListener plotListener;
|
||||||
|
private RegionManager regionManager;
|
||||||
|
private GlobalBlockQueue blockQueue;
|
||||||
|
private WorldUtil worldUtil;
|
||||||
|
private SchematicHandler schematicHandler;
|
||||||
|
@ImpromptuPipeline private UUIDPipeline impromptuPipeline;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Plot flag container
|
* Plot flag container
|
||||||
*/
|
*/
|
||||||
@ -197,9 +206,8 @@ public class Plot {
|
|||||||
* @param owner the plot owner
|
* @param owner the plot owner
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner,
|
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner) {
|
||||||
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
this(area, id, owner, 0);
|
||||||
this(area, id, owner, 0, eventDispatcher, plotListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -210,9 +218,8 @@ public class Plot {
|
|||||||
* @param id the plot id
|
* @param id the plot id
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(@NotNull final PlotArea area, @NotNull final PlotId id,
|
public Plot(@NotNull final PlotArea area, @NotNull final PlotId id) {
|
||||||
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
this(area, id, null, 0);
|
||||||
this(area, id, null, 0, eventDispatcher, plotListener);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -226,15 +233,13 @@ public class Plot {
|
|||||||
* @param temp Represents whatever the database manager needs it to
|
* @param temp Represents whatever the database manager needs it to
|
||||||
* @see Plot#getPlot(Location) for existing plots
|
* @see Plot#getPlot(Location) for existing plots
|
||||||
*/
|
*/
|
||||||
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner, final int temp,
|
public Plot(final PlotArea area, @NotNull final PlotId id, final UUID owner, final int temp) {
|
||||||
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
this.temp = temp;
|
this.temp = temp;
|
||||||
this.flagContainer.setParentContainer(area.getFlagContainer());
|
this.flagContainer.setParentContainer(area.getFlagContainer());
|
||||||
this.eventDispatcher = eventDispatcher;
|
PlotSquared.platform().getInjector().injectMembers(this);
|
||||||
this.plotListener = plotListener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -249,8 +254,7 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
public Plot(@NotNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
public Plot(@NotNull PlotId id, UUID owner, HashSet<UUID> trusted, HashSet<UUID> members,
|
||||||
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
HashSet<UUID> denied, String alias, BlockLoc position, Collection<PlotFlag<?, ?>> flags,
|
||||||
PlotArea area, boolean[] merged, long timestamp, int temp,
|
PlotArea area, boolean[] merged, long timestamp, int temp) {
|
||||||
@NotNull final EventDispatcher eventDispatcher, @NotNull final PlotListener plotListener) {
|
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.area = area;
|
this.area = area;
|
||||||
this.owner = owner;
|
this.owner = owner;
|
||||||
@ -271,8 +275,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.eventDispatcher = eventDispatcher;
|
PlotSquared.platform().getInjector().injectMembers(this);
|
||||||
this.plotListener = plotListener;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -950,7 +953,7 @@ public class Plot {
|
|||||||
Runnable run = () -> {
|
Runnable run = () -> {
|
||||||
for (CuboidRegion region : regions) {
|
for (CuboidRegion region : regions) {
|
||||||
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
Location[] corners = MainUtil.getCorners(getWorldName(), region);
|
||||||
RegionManager.manager.clearAllEntities(corners[0], corners[1]);
|
regionManager.clearAllEntities(corners[0], corners[1]);
|
||||||
}
|
}
|
||||||
TaskManager.runTask(whenDone);
|
TaskManager.runTask(whenDone);
|
||||||
};
|
};
|
||||||
@ -961,14 +964,13 @@ public class Plot {
|
|||||||
manager.claimPlot(current);
|
manager.claimPlot(current);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(run);
|
blockQueue.addEmptyTask(run);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Plot current = queue.poll();
|
Plot current = queue.poll();
|
||||||
if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
|
if (Plot.this.area.getTerrain() != PlotAreaTerrainType.NONE) {
|
||||||
try {
|
try {
|
||||||
RegionManager.manager
|
regionManager.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
|
||||||
.regenerateRegion(current.getBottomAbs(), current.getTopAbs(), false,
|
|
||||||
this);
|
this);
|
||||||
} catch (UnsupportedOperationException exception) {
|
} catch (UnsupportedOperationException exception) {
|
||||||
MainUtil.sendMessage(null,
|
MainUtil.sendMessage(null,
|
||||||
@ -1005,7 +1007,7 @@ public class Plot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
CuboidRegion region = regions.poll();
|
CuboidRegion region = regions.poll();
|
||||||
RegionManager.manager.setBiome(region, extendBiome, biome, getWorldName(), this);
|
regionManager.setBiome(region, extendBiome, biome, getWorldName(), this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
run.run();
|
run.run();
|
||||||
@ -1057,7 +1059,7 @@ public class Plot {
|
|||||||
current.setMerged(merged);
|
current.setMerged(merged);
|
||||||
}
|
}
|
||||||
if (createSign) {
|
if (createSign) {
|
||||||
GlobalBlockQueue.IMP.addEmptyTask(() -> {
|
blockQueue.addEmptyTask(() -> {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
for (Plot current : plots) {
|
for (Plot current : plots) {
|
||||||
current.setSign(MainUtil.getName(current.getOwnerAbs()));
|
current.setSign(MainUtil.getName(current.getOwnerAbs()));
|
||||||
@ -1092,14 +1094,13 @@ public class Plot {
|
|||||||
"%plr%", name),
|
"%plr%", name),
|
||||||
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
Captions.OWNER_SIGN_LINE_4.formatted().replaceAll("%id%", id).replaceAll(
|
||||||
"%plr%", name)};
|
"%plr%", name)};
|
||||||
WorldUtil.IMP
|
this.worldUtil.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
|
||||||
.setSign(this.getWorldName(), location.getX(), location.getY(), location.getZ(),
|
|
||||||
lines);
|
lines);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isLoaded() {
|
public boolean isLoaded() {
|
||||||
return WorldUtil.IMP.isWorld(getWorldName());
|
return this.worldUtil.isWorld(getWorldName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1270,7 +1271,7 @@ public class Plot {
|
|||||||
public int[] countEntities() {
|
public int[] countEntities() {
|
||||||
int[] count = new int[6];
|
int[] count = new int[6];
|
||||||
for (Plot current : this.getConnectedPlots()) {
|
for (Plot current : this.getConnectedPlots()) {
|
||||||
int[] result = RegionManager.manager.countEntities(current);
|
int[] result = this.regionManager.countEntities(current);
|
||||||
count[CAP_ENTITY] += result[CAP_ENTITY];
|
count[CAP_ENTITY] += result[CAP_ENTITY];
|
||||||
count[CAP_ANIMAL] += result[CAP_ANIMAL];
|
count[CAP_ANIMAL] += result[CAP_ANIMAL];
|
||||||
count[CAP_MONSTER] += result[CAP_MONSTER];
|
count[CAP_MONSTER] += result[CAP_MONSTER];
|
||||||
@ -1377,7 +1378,7 @@ public class Plot {
|
|||||||
result.accept(location);
|
result.accept(location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldUtil.IMP.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
|
this.worldUtil.getHighestBlock(getWorldName(), location.getX(), location.getZ(), y -> {
|
||||||
int height = y;
|
int height = y;
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
height = Math.max(y, getManager().getSignLoc(this).getY());
|
height = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
@ -1398,8 +1399,7 @@ public class Plot {
|
|||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
int y = WorldUtil.IMP
|
int y = this.worldUtil.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
||||||
.getHighestBlockSynchronous(getWorldName(), location.getX(), location.getZ());
|
|
||||||
if (area.allowSigns()) {
|
if (area.allowSigns()) {
|
||||||
y = Math.max(y, getManager().getSignLoc(this).getY());
|
y = Math.max(y, getManager().getSignLoc(this).getY());
|
||||||
}
|
}
|
||||||
@ -1415,7 +1415,7 @@ public class Plot {
|
|||||||
+ largest.getMinimumPoint().getX();
|
+ largest.getMinimumPoint().getX();
|
||||||
int z = largest.getMinimumPoint().getZ() - 1;
|
int z = largest.getMinimumPoint().getZ() - 1;
|
||||||
PlotManager manager = getManager();
|
PlotManager manager = getManager();
|
||||||
int y = isLoaded() ? WorldUtil.IMP.getHighestBlockSynchronous(getWorldName(), x, z) : 62;
|
int y = isLoaded() ? this.worldUtil.getHighestBlockSynchronous(getWorldName(), x, z) : 62;
|
||||||
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
||||||
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
y = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
||||||
}
|
}
|
||||||
@ -1429,7 +1429,7 @@ public class Plot {
|
|||||||
int z = largest.getMinimumPoint().getZ() - 1;
|
int z = largest.getMinimumPoint().getZ() - 1;
|
||||||
PlotManager manager = getManager();
|
PlotManager manager = getManager();
|
||||||
if (isLoaded()) {
|
if (isLoaded()) {
|
||||||
WorldUtil.IMP.getHighestBlock(getWorldName(), x, z, y -> {
|
this.worldUtil.getHighestBlock(getWorldName(), x, z, y -> {
|
||||||
int height = y;
|
int height = y;
|
||||||
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
if (area.allowSigns() && (y <= 0 || y >= 255)) {
|
||||||
height = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
height = Math.max(y, manager.getSignLoc(this).getY() - 1);
|
||||||
@ -1460,9 +1460,8 @@ public class Plot {
|
|||||||
if (!isLoaded()) {
|
if (!isLoaded()) {
|
||||||
return location;
|
return location;
|
||||||
}
|
}
|
||||||
if (!WorldUtil.IMP.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
if (!this.worldUtil.getBlockSynchronous(location).getBlockType().getMaterial().isAir()) {
|
||||||
location = location.withY(Math.max(1 + WorldUtil.IMP
|
location = location.withY(Math.max(1 + this.worldUtil.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
|
||||||
.getHighestBlockSynchronous(this.getWorldName(), location.getX(),
|
|
||||||
location.getZ()), bottom.getY()));
|
location.getZ()), bottom.getY()));
|
||||||
}
|
}
|
||||||
return location;
|
return location;
|
||||||
@ -1485,10 +1484,9 @@ public class Plot {
|
|||||||
result.accept(location);
|
result.accept(location);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
WorldUtil.IMP.getBlock(location, block -> {
|
this.worldUtil.getBlock(location, block -> {
|
||||||
if (!block.getBlockType().getMaterial().isAir()) {
|
if (!block.getBlockType().getMaterial().isAir()) {
|
||||||
WorldUtil.IMP
|
this.worldUtil.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
||||||
.getHighestBlock(this.getWorldName(), location.getX(), location.getZ(),
|
|
||||||
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY()))));
|
y -> result.accept(location.withY(Math.max(1 + y, bottom.getY()))));
|
||||||
} else {
|
} else {
|
||||||
result.accept(location);
|
result.accept(location);
|
||||||
@ -1547,7 +1545,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
int y = loc.getY() < 1 ?
|
int y = loc.getY() < 1 ?
|
||||||
(isLoaded() ?
|
(isLoaded() ?
|
||||||
WorldUtil.IMP.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 :
|
this.worldUtil.getHighestBlockSynchronous(plot.getWorldName(), x, z) + 1 :
|
||||||
63) :
|
63) :
|
||||||
loc.getY();
|
loc.getY();
|
||||||
return Location.at(plot.getWorldName(), x, y, z);
|
return Location.at(plot.getWorldName(), x, y, z);
|
||||||
@ -1577,7 +1575,7 @@ public class Plot {
|
|||||||
}
|
}
|
||||||
if (loc.getY() < 1) {
|
if (loc.getY() < 1) {
|
||||||
if (isLoaded()) {
|
if (isLoaded()) {
|
||||||
WorldUtil.IMP.getHighestBlock(plot.getWorldName(), x, z,
|
this.worldUtil.getHighestBlock(plot.getWorldName(), x, z,
|
||||||
y -> result.accept(Location.at(plot.getWorldName(), x, y + 1, z)));
|
y -> result.accept(Location.at(plot.getWorldName(), x, y + 1, z)));
|
||||||
} else {
|
} else {
|
||||||
result.accept(Location.at(plot.getWorldName(), x, 63, z));
|
result.accept(Location.at(plot.getWorldName(), x, 63, z));
|
||||||
@ -1680,7 +1678,7 @@ public class Plot {
|
|||||||
* This should not need to be called
|
* This should not need to be called
|
||||||
*/
|
*/
|
||||||
public void refreshChunks() {
|
public void refreshChunks() {
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
||||||
HashSet<BlockVector2> chunks = new HashSet<>();
|
HashSet<BlockVector2> chunks = new HashSet<>();
|
||||||
for (CuboidRegion region : Plot.this.getRegions()) {
|
for (CuboidRegion region : Plot.this.getRegions()) {
|
||||||
for (int x = region.getMinimumPoint().getX() >> 4;
|
for (int x = region.getMinimumPoint().getX() >> 4;
|
||||||
@ -1704,7 +1702,7 @@ public class Plot {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
Location location = manager.getSignLoc(this);
|
Location location = manager.getSignLoc(this);
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(getWorldName(), false);
|
LocalBlockQueue queue = this.blockQueue.getNewQueue(getWorldName(), false);
|
||||||
queue.setBlock(location.getX(), location.getY(), location.getZ(),
|
queue.setBlock(location.getX(), location.getY(), location.getZ(),
|
||||||
BlockTypes.AIR.getDefaultState());
|
BlockTypes.AIR.getDefaultState());
|
||||||
queue.flush();
|
queue.flush();
|
||||||
@ -1718,7 +1716,7 @@ public class Plot {
|
|||||||
this.setSign("unknown");
|
this.setSign("unknown");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
PlotSquared.get().getImpromptuUUIDPipeline().getSingle(this.getOwnerAbs(), (username, sign) ->
|
this.impromptuPipeline.getSingle(this.getOwnerAbs(), (username, sign) ->
|
||||||
this.setSign(username));
|
this.setSign(username));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1769,18 +1767,18 @@ public class Plot {
|
|||||||
Schematic sch;
|
Schematic sch;
|
||||||
try {
|
try {
|
||||||
if (schematic == null || schematic.isEmpty()) {
|
if (schematic == null || schematic.isEmpty()) {
|
||||||
sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
|
sch = schematicHandler.getSchematic(plotworld.getSchematicFile());
|
||||||
} else {
|
} else {
|
||||||
sch = SchematicHandler.manager.getSchematic(schematic);
|
sch = schematicHandler.getSchematic(schematic);
|
||||||
if (sch == null) {
|
if (sch == null) {
|
||||||
sch = SchematicHandler.manager.getSchematic(plotworld.getSchematicFile());
|
sch = schematicHandler.getSchematic(plotworld.getSchematicFile());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (SchematicHandler.UnsupportedFormatException e) {
|
} catch (SchematicHandler.UnsupportedFormatException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
SchematicHandler.manager.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP,
|
schematicHandler.paste(sch, this, 0, 1, 0, Settings.Schematics.PASTE_ON_TOP,
|
||||||
new RunnableVal<Boolean>() {
|
new RunnableVal<Boolean>() {
|
||||||
@Override public void run(Boolean value) {
|
@Override public void run(Boolean value) {
|
||||||
if (value) {
|
if (value) {
|
||||||
@ -1827,7 +1825,7 @@ public class Plot {
|
|||||||
DBFunc.createPlotAndSettings(this, () -> {
|
DBFunc.createPlotAndSettings(this, () -> {
|
||||||
PlotArea plotworld = Plot.this.area;
|
PlotArea plotworld = Plot.this.area;
|
||||||
if (notify && plotworld.isAutoMerge()) {
|
if (notify && plotworld.isAutoMerge()) {
|
||||||
PlotPlayer player = WorldUtil.IMP.wrapPlayer(uuid);
|
PlotPlayer player = this.worldUtil.wrapPlayer(uuid);
|
||||||
PlotMergeEvent event = this.eventDispatcher
|
PlotMergeEvent event = this.eventDispatcher
|
||||||
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
.callMerge(this, Direction.ALL, Integer.MAX_VALUE, player);
|
||||||
if (event.getEventResult() == Result.DENY) {
|
if (event.getEventResult() == Result.DENY) {
|
||||||
@ -1861,7 +1859,7 @@ public class Plot {
|
|||||||
* Retrieve the biome of the plot.
|
* Retrieve the biome of the plot.
|
||||||
*/
|
*/
|
||||||
public void getBiome(Consumer<BiomeType> result) {
|
public void getBiome(Consumer<BiomeType> result) {
|
||||||
this.getCenter(location -> WorldUtil.IMP
|
this.getCenter(location -> this.worldUtil
|
||||||
.getBiome(location.getWorldName(), location.getX(), location.getZ(), result));
|
.getBiome(location.getWorldName(), location.getX(), location.getZ(), result));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1870,7 +1868,7 @@ public class Plot {
|
|||||||
*/
|
*/
|
||||||
@Deprecated public BiomeType getBiomeSynchronous() {
|
@Deprecated public BiomeType getBiomeSynchronous() {
|
||||||
final Location location = this.getCenterSynchronous();
|
final Location location = this.getCenterSynchronous();
|
||||||
return WorldUtil.IMP
|
return this.worldUtil
|
||||||
.getBiomeSynchronous(location.getWorldName(), location.getX(), location.getZ());
|
.getBiomeSynchronous(location.getWorldName(), location.getX(), location.getZ());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2022,7 +2020,7 @@ public class Plot {
|
|||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = Location.at(this.getWorldName(), top.getX(), 0, bot.getZ());
|
Location pos1 = Location.at(this.getWorldName(), top.getX(), 0, bot.getZ());
|
||||||
Location pos2 = Location.at(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
|
Location pos2 = Location.at(this.getWorldName(), bot.getX(), MAX_HEIGHT, top.getZ());
|
||||||
RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
|
this.regionManager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain()
|
} else if (this.area.getTerrain()
|
||||||
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.area.getPlotManager().removeRoadEast(this);
|
this.area.getPlotManager().removeRoadEast(this);
|
||||||
@ -2176,7 +2174,7 @@ public class Plot {
|
|||||||
* Export the plot as a schematic to the configured output directory.
|
* Export the plot as a schematic to the configured output directory.
|
||||||
*/
|
*/
|
||||||
public void export(final RunnableVal<Boolean> whenDone) {
|
public void export(final RunnableVal<Boolean> whenDone) {
|
||||||
SchematicHandler.manager.getCompoundTag(this, new RunnableVal<CompoundTag>() {
|
this.schematicHandler.getCompoundTag(this, new RunnableVal<CompoundTag>() {
|
||||||
@Override public void run(final CompoundTag value) {
|
@Override public void run(final CompoundTag value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
@ -2187,7 +2185,7 @@ public class Plot {
|
|||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
|
String name = Plot.this.id + "," + Plot.this.area + ',' + MainUtil
|
||||||
.getName(Plot.this.getOwnerAbs());
|
.getName(Plot.this.getOwnerAbs());
|
||||||
boolean result = SchematicHandler.manager.save(value,
|
boolean result = schematicHandler.save(value,
|
||||||
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
|
Settings.Paths.SCHEMATICS + File.separator + name + ".schem");
|
||||||
if (whenDone != null) {
|
if (whenDone != null) {
|
||||||
whenDone.value = result;
|
whenDone.value = result;
|
||||||
@ -2205,9 +2203,9 @@ public class Plot {
|
|||||||
* @param whenDone value will be null if uploading fails
|
* @param whenDone value will be null if uploading fails
|
||||||
*/
|
*/
|
||||||
public void upload(final RunnableVal<URL> whenDone) {
|
public void upload(final RunnableVal<URL> whenDone) {
|
||||||
SchematicHandler.manager.getCompoundTag(this, new RunnableVal<CompoundTag>() {
|
this.schematicHandler.getCompoundTag(this, new RunnableVal<CompoundTag>() {
|
||||||
@Override public void run(CompoundTag value) {
|
@Override public void run(CompoundTag value) {
|
||||||
SchematicHandler.manager.upload(value, null, null, whenDone);
|
schematicHandler.upload(value, null, null, whenDone);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -2221,7 +2219,7 @@ public class Plot {
|
|||||||
* @see WorldUtil
|
* @see WorldUtil
|
||||||
*/
|
*/
|
||||||
public void uploadWorld(RunnableVal<URL> whenDone) {
|
public void uploadWorld(RunnableVal<URL> whenDone) {
|
||||||
WorldUtil.IMP.upload(this, null, null, whenDone);
|
this.worldUtil.upload(this, null, null, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean equals(Object obj) {
|
@Override public boolean equals(Object obj) {
|
||||||
@ -2394,7 +2392,7 @@ public class Plot {
|
|||||||
Location top = this.getTopAbs();
|
Location top = this.getTopAbs();
|
||||||
Location pos1 = Location.at(this.getWorldName(), bot.getX(), 0, top.getZ());
|
Location pos1 = Location.at(this.getWorldName(), bot.getX(), 0, top.getZ());
|
||||||
Location pos2 = Location.at(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
|
Location pos2 = Location.at(this.getWorldName(), top.getX(), MAX_HEIGHT, bot.getZ());
|
||||||
RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
|
this.regionManager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain()
|
} else if (this.area.getTerrain()
|
||||||
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.getManager().removeRoadSouth(this);
|
this.getManager().removeRoadSouth(this);
|
||||||
@ -2570,7 +2568,7 @@ public class Plot {
|
|||||||
Plot other = this.getRelative(1, 1);
|
Plot other = this.getRelative(1, 1);
|
||||||
Location pos1 = this.getTopAbs().add(1, 0, 1).withY(0);
|
Location pos1 = this.getTopAbs().add(1, 0, 1).withY(0);
|
||||||
Location pos2 = other.getBottomAbs().subtract(1, 0, 1).withY(MAX_HEIGHT);
|
Location pos2 = other.getBottomAbs().subtract(1, 0, 1).withY(MAX_HEIGHT);
|
||||||
RegionManager.manager.regenerateRegion(pos1, pos2, true, null);
|
this.regionManager.regenerateRegion(pos1, pos2, true, null);
|
||||||
} else if (this.area.getTerrain()
|
} else if (this.area.getTerrain()
|
||||||
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
!= PlotAreaTerrainType.ALL) { // no road generated => no road to remove
|
||||||
this.area.getPlotManager().removeRoadSouthEast(this);
|
this.area.getPlotManager().removeRoadSouthEast(this);
|
||||||
@ -3228,7 +3226,7 @@ public class Plot {
|
|||||||
Location pos2 = corners[1];
|
Location pos2 = corners[1];
|
||||||
Location pos3 = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location pos3 = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
Location pos4 = pos2.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location pos4 = pos2.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
RegionManager.manager.swap(pos1, pos2, pos3, pos4, this);
|
regionManager.swap(pos1, pos2, pos3, pos4, this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
@ -3259,7 +3257,7 @@ public class Plot {
|
|||||||
final Location pos1 = corners[0];
|
final Location pos1 = corners[0];
|
||||||
final Location pos2 = corners[1];
|
final Location pos2 = corners[1];
|
||||||
Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location newPos = pos1.add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
RegionManager.manager.copyRegion(pos1, pos2, newPos, task);
|
regionManager.copyRegion(pos1, pos2, newPos, task);
|
||||||
}
|
}
|
||||||
}.run();
|
}.run();
|
||||||
}
|
}
|
||||||
@ -3353,7 +3351,7 @@ public class Plot {
|
|||||||
Location pos1 = corners[0];
|
Location pos1 = corners[0];
|
||||||
Location pos2 = corners[1];
|
Location pos2 = corners[1];
|
||||||
Location newPos = pos1 .add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
Location newPos = pos1 .add(offsetX, 0, offsetZ).withWorld(destination.getWorldName());
|
||||||
RegionManager.manager.copyRegion(pos1, pos2, newPos, this);
|
regionManager.copyRegion(pos1, pos2, newPos, this);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
run.run();
|
run.run();
|
||||||
|
@ -28,7 +28,7 @@ package com.plotsquared.core.plot;
|
|||||||
import com.google.common.collect.ImmutableMap;
|
import com.google.common.collect.ImmutableMap;
|
||||||
import com.google.common.collect.ImmutableSet;
|
import com.google.common.collect.ImmutableSet;
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.collection.QuadMap;
|
import com.plotsquared.core.collection.QuadMap;
|
||||||
import com.plotsquared.core.configuration.CaptionUtility;
|
import com.plotsquared.core.configuration.CaptionUtility;
|
||||||
import com.plotsquared.core.configuration.Captions;
|
import com.plotsquared.core.configuration.Captions;
|
||||||
@ -140,15 +140,21 @@ public abstract class PlotArea {
|
|||||||
private final EventDispatcher eventDispatcher;
|
private final EventDispatcher eventDispatcher;
|
||||||
private final PlotListener plotListener;
|
private final PlotListener plotListener;
|
||||||
private final YamlConfiguration worldConfiguration;
|
private final YamlConfiguration worldConfiguration;
|
||||||
|
private final GlobalBlockQueue globalBlockQueue;
|
||||||
|
private final EconHandler econHandler;
|
||||||
|
|
||||||
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
public PlotArea(@NotNull final String worldName, @Nullable final String id,
|
||||||
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
|
@NotNull IndependentPlotGenerator generator, @Nullable final PlotId min,
|
||||||
@Nullable final PlotId max, @NotNull final EventDispatcher eventDispatcher,
|
@Nullable final PlotId max, @NotNull final EventDispatcher eventDispatcher,
|
||||||
@NotNull final PlotListener plotListener, @WorldConfig @Nullable final YamlConfiguration worldConfiguration) {
|
@NotNull final PlotListener plotListener,
|
||||||
|
@WorldConfig @Nullable final YamlConfiguration worldConfiguration,
|
||||||
|
@NotNull final GlobalBlockQueue blockQueue,
|
||||||
|
@Nullable final EconHandler econHandler) {
|
||||||
this.worldName = worldName;
|
this.worldName = worldName;
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.plotManager = createManager();
|
this.plotManager = createManager();
|
||||||
this.generator = generator;
|
this.generator = generator;
|
||||||
|
this.globalBlockQueue = blockQueue;
|
||||||
if (min == null || max == null) {
|
if (min == null || max == null) {
|
||||||
if (min != max) {
|
if (min != max) {
|
||||||
throw new IllegalArgumentException(
|
throw new IllegalArgumentException(
|
||||||
@ -164,12 +170,13 @@ public abstract class PlotArea {
|
|||||||
this.eventDispatcher = eventDispatcher;
|
this.eventDispatcher = eventDispatcher;
|
||||||
this.plotListener = plotListener;
|
this.plotListener = plotListener;
|
||||||
this.worldConfiguration = worldConfiguration;
|
this.worldConfiguration = worldConfiguration;
|
||||||
|
this.econHandler = econHandler;
|
||||||
}
|
}
|
||||||
|
|
||||||
@NotNull protected abstract PlotManager createManager();
|
@NotNull protected abstract PlotManager createManager();
|
||||||
|
|
||||||
public LocalBlockQueue getQueue(final boolean autoQueue) {
|
public LocalBlockQueue getQueue(final boolean autoQueue) {
|
||||||
return GlobalBlockQueue.IMP.getNewQueue(worldName, autoQueue);
|
return this.globalBlockQueue.getNewQueue(worldName, autoQueue);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -288,7 +295,7 @@ public abstract class PlotArea {
|
|||||||
this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
|
this.schematicClaimSpecify = config.getBoolean("schematic.specify_on_claim");
|
||||||
this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
|
this.schematics = new ArrayList<>(config.getStringList("schematic.schematics"));
|
||||||
this.schematics.replaceAll(String::toLowerCase);
|
this.schematics.replaceAll(String::toLowerCase);
|
||||||
this.useEconomy = config.getBoolean("economy.use") && EconHandler.getEconHandler() != null;
|
this.useEconomy = config.getBoolean("economy.use") && this.econHandler != null;
|
||||||
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
|
ConfigurationSection priceSection = config.getConfigurationSection("economy.prices");
|
||||||
if (this.useEconomy) {
|
if (this.useEconomy) {
|
||||||
this.prices = new HashMap<>();
|
this.prices = new HashMap<>();
|
||||||
@ -650,7 +657,7 @@ public abstract class PlotArea {
|
|||||||
|
|
||||||
//todo check if this method is needed in this class
|
//todo check if this method is needed in this class
|
||||||
|
|
||||||
public int getPlotCount(@Nullable final PlotPlayer player) {
|
public int getPlotCount(@Nullable final PlotPlayer<?> player) {
|
||||||
return player != null ? getPlotCount(player.getUUID()) : 0;
|
return player != null ? getPlotCount(player.getUUID()) : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -661,7 +668,7 @@ public abstract class PlotArea {
|
|||||||
|| id.y > this.max.y)) {
|
|| id.y > this.max.y)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id, this.eventDispatcher, this.plotListener);
|
return new Plot(this, id);
|
||||||
}
|
}
|
||||||
return plot;
|
return plot;
|
||||||
}
|
}
|
||||||
@ -673,7 +680,7 @@ public abstract class PlotArea {
|
|||||||
|| id.y > this.max.y)) {
|
|| id.y > this.max.y)) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
return new Plot(this, id, this.eventDispatcher, this.plotListener);
|
return new Plot(this, id);
|
||||||
}
|
}
|
||||||
return plot.getBasePlot(false);
|
return plot.getBasePlot(false);
|
||||||
}
|
}
|
||||||
|
@ -29,6 +29,7 @@ import com.plotsquared.core.PlotSquared;
|
|||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import com.plotsquared.core.util.InventoryUtil;
|
import com.plotsquared.core.util.InventoryUtil;
|
||||||
import lombok.NonNull;
|
import lombok.NonNull;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
public class PlotInventory {
|
public class PlotInventory {
|
||||||
|
|
||||||
@ -38,19 +39,14 @@ public class PlotInventory {
|
|||||||
private final PlotItemStack[] items;
|
private final PlotItemStack[] items;
|
||||||
private String title;
|
private String title;
|
||||||
private boolean open = false;
|
private boolean open = false;
|
||||||
|
private final InventoryUtil inventoryUtil;
|
||||||
public PlotInventory(PlotPlayer<?> player) {
|
|
||||||
this.size = 4;
|
public PlotInventory(@NotNull final InventoryUtil inventoryUtil, PlotPlayer<?> player, int size, String name) {
|
||||||
this.title = null;
|
|
||||||
this.player = player;
|
|
||||||
this.items = InventoryUtil.manager.getItems(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public PlotInventory(PlotPlayer<?> player, int size, String name) {
|
|
||||||
this.size = size;
|
this.size = size;
|
||||||
this.title = name == null ? "" : name;
|
this.title = name == null ? "" : name;
|
||||||
this.player = player;
|
this.player = player;
|
||||||
this.items = new PlotItemStack[size * 9];
|
this.items = new PlotItemStack[size * 9];
|
||||||
|
this.inventoryUtil = inventoryUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer<?> plotPlayer) {
|
public static boolean hasPlotInventoryOpen(@NonNull final PlotPlayer<?> plotPlayer) {
|
||||||
@ -84,7 +80,7 @@ public class PlotInventory {
|
|||||||
} else {
|
} else {
|
||||||
this.open = true;
|
this.open = true;
|
||||||
setPlotInventoryOpen(player, this);
|
setPlotInventoryOpen(player, this);
|
||||||
InventoryUtil.manager.open(this);
|
this.inventoryUtil.open(this);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -93,13 +89,13 @@ public class PlotInventory {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
removePlotInventoryOpen(player);
|
removePlotInventoryOpen(player);
|
||||||
InventoryUtil.manager.close(this);
|
this.inventoryUtil.close(this);
|
||||||
this.open = false;
|
this.open = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(int index, PlotItemStack item) {
|
public void setItem(int index, PlotItemStack item) {
|
||||||
this.items[index] = item;
|
this.items[index] = item;
|
||||||
InventoryUtil.manager.setItem(this, index, item);
|
this.inventoryUtil.setItem(this, index, item);
|
||||||
}
|
}
|
||||||
|
|
||||||
public PlotItemStack getItem(int index) {
|
public PlotItemStack getItem(int index) {
|
||||||
|
@ -80,7 +80,7 @@ public class PlotAnalysis {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void analyzePlot(Plot plot, RunnableVal<PlotAnalysis> whenDone) {
|
public static void analyzePlot(Plot plot, RunnableVal<PlotAnalysis> whenDone) {
|
||||||
HybridUtils.manager.analyzePlot(plot, whenDone);
|
PlotSquared.platform().getInjector().getInstance(HybridUtils.class).analyzePlot(plot, whenDone);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
package com.plotsquared.core.plot.world;
|
package com.plotsquared.core.plot.world;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.configuration.ConfigurationNode;
|
import com.plotsquared.core.configuration.ConfigurationNode;
|
||||||
import com.plotsquared.core.configuration.ConfigurationSection;
|
import com.plotsquared.core.configuration.ConfigurationSection;
|
||||||
import com.plotsquared.core.configuration.ConfigurationUtil;
|
import com.plotsquared.core.configuration.ConfigurationUtil;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.plot.world;
|
package com.plotsquared.core.plot.world;
|
||||||
|
|
||||||
import com.plotsquared.core.annoations.WorldConfig;
|
import com.plotsquared.core.inject.annotations.WorldConfig;
|
||||||
import com.plotsquared.core.collection.ArrayUtil;
|
import com.plotsquared.core.collection.ArrayUtil;
|
||||||
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
import com.plotsquared.core.configuration.file.YamlConfiguration;
|
||||||
import com.plotsquared.core.generator.SingleWorldGenerator;
|
import com.plotsquared.core.generator.SingleWorldGenerator;
|
||||||
|
@ -51,6 +51,8 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
private int lastZ = Integer.MIN_VALUE;
|
private int lastZ = Integer.MIN_VALUE;
|
||||||
private boolean setbiome = false;
|
private boolean setbiome = false;
|
||||||
|
|
||||||
|
private GlobalBlockQueue globalBlockQueue;
|
||||||
|
|
||||||
public BasicLocalBlockQueue(String world) {
|
public BasicLocalBlockQueue(String world) {
|
||||||
super(world);
|
super(world);
|
||||||
this.world = world;
|
this.world = world;
|
||||||
@ -182,8 +184,8 @@ public abstract class BasicLocalBlockQueue extends LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void flush() {
|
@Override public void flush() {
|
||||||
GlobalBlockQueue.IMP.dequeue(this);
|
this.globalBlockQueue.dequeue(this);
|
||||||
TaskManager.IMP.sync(new RunnableVal<Object>() {
|
TaskManager.getImplementation().sync(new RunnableVal<Object>() {
|
||||||
@Override public void run(Object value) {
|
@Override public void run(Object value) {
|
||||||
while (next()) {
|
while (next()) {
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ import java.util.concurrent.atomic.AtomicBoolean;
|
|||||||
|
|
||||||
public class GlobalBlockQueue {
|
public class GlobalBlockQueue {
|
||||||
|
|
||||||
public static GlobalBlockQueue IMP;
|
|
||||||
private final int PARALLEL_THREADS;
|
private final int PARALLEL_THREADS;
|
||||||
private final ConcurrentLinkedDeque<LocalBlockQueue> activeQueues;
|
private final ConcurrentLinkedDeque<LocalBlockQueue> activeQueues;
|
||||||
private final ConcurrentLinkedDeque<LocalBlockQueue> inactiveQueues;
|
private final ConcurrentLinkedDeque<LocalBlockQueue> inactiveQueues;
|
||||||
@ -92,6 +91,8 @@ public class GlobalBlockQueue {
|
|||||||
|
|
||||||
public LocalBlockQueue getNewQueue(String world, boolean autoQueue) {
|
public LocalBlockQueue getNewQueue(String world, boolean autoQueue) {
|
||||||
LocalBlockQueue queue = provider.getNewQueue(world);
|
LocalBlockQueue queue = provider.getNewQueue(world);
|
||||||
|
// Auto-inject into the queue
|
||||||
|
PlotSquared.platform().getInjector().injectMembers(queue);
|
||||||
if (autoQueue) {
|
if (autoQueue) {
|
||||||
inactiveQueues.add(queue);
|
inactiveQueues.add(queue);
|
||||||
}
|
}
|
||||||
|
@ -48,12 +48,17 @@ public abstract class LocalBlockQueue {
|
|||||||
@Getter @Setter private boolean forceSync = false;
|
@Getter @Setter private boolean forceSync = false;
|
||||||
@Getter @Setter @Nullable private Object chunkObject;
|
@Getter @Setter @Nullable private Object chunkObject;
|
||||||
|
|
||||||
|
private SchematicHandler schematicHandler;
|
||||||
|
private WorldUtil worldUtil;
|
||||||
|
private GlobalBlockQueue blockQueue;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Needed for compatibility with FAWE.
|
* Needed for compatibility with FAWE.
|
||||||
*
|
*
|
||||||
* @param world unused
|
* @param world unused
|
||||||
*/
|
*/
|
||||||
@Deprecated public LocalBlockQueue(String world) {
|
@Deprecated public LocalBlockQueue(String world) {
|
||||||
|
PlotSquared.platform().getInjector().injectMembers(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ScopedLocalBlockQueue getForChunk(int x, int z) {
|
public ScopedLocalBlockQueue getForChunk(int x, int z) {
|
||||||
@ -94,7 +99,7 @@ public abstract class LocalBlockQueue {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
public boolean setTile(int x, int y, int z, CompoundTag tag) {
|
||||||
SchematicHandler.manager.restoreTile(this, tag, x, y, z);
|
this.schematicHandler.restoreTile(this, tag, x, y, z);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,18 +128,18 @@ public abstract class LocalBlockQueue {
|
|||||||
fixChunkLighting(x, z);
|
fixChunkLighting(x, z);
|
||||||
BlockVector2 loc = BlockVector2.at(x, z);
|
BlockVector2 loc = BlockVector2.at(x, z);
|
||||||
|
|
||||||
for (final PlotPlayer pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
for (final PlotPlayer<?> pp : PlotSquared.platform().getPlayerManager().getPlayers()) {
|
||||||
Location pLoc = pp.getLocation();
|
Location pLoc = pp.getLocation();
|
||||||
if (!StringMan.isEqual(getWorld(), pLoc.getWorldName()) || !pLoc.getChunkLocation()
|
if (!StringMan.isEqual(getWorld(), pLoc.getWorldName()) || !pLoc.getChunkLocation()
|
||||||
.equals(loc)) {
|
.equals(loc)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
pp.teleport(pLoc.withY(WorldUtil.IMP.getHighestBlockSynchronous(getWorld(), pLoc.getX(), pLoc.getZ())));
|
pp.teleport(pLoc.withY(this.worldUtil.getHighestBlockSynchronous(getWorld(), pLoc.getX(), pLoc.getZ())));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean enqueue() {
|
public boolean enqueue() {
|
||||||
return GlobalBlockQueue.IMP.enqueue(this);
|
return blockQueue.enqueue(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCuboid(Location pos1, Location pos2, BlockState block) {
|
public void setCuboid(Location pos1, Location pos2, BlockState block) {
|
||||||
|
@ -38,7 +38,6 @@ import com.plotsquared.core.plot.PlotId;
|
|||||||
import com.plotsquared.core.util.MainUtil;
|
import com.plotsquared.core.util.MainUtil;
|
||||||
import com.plotsquared.core.util.SetupUtils;
|
import com.plotsquared.core.util.SetupUtils;
|
||||||
import com.plotsquared.core.util.StringMan;
|
import com.plotsquared.core.util.StringMan;
|
||||||
import com.plotsquared.core.util.WorldUtil;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
import org.jetbrains.annotations.Nullable;
|
import org.jetbrains.annotations.Nullable;
|
||||||
@ -214,7 +213,7 @@ public enum CommonSetupSteps implements SetupStep {
|
|||||||
MainUtil.sendMessage(plotPlayer, Captions.SETUP_WORLD_NAME_FORMAT + argument);
|
MainUtil.sendMessage(plotPlayer, Captions.SETUP_WORLD_NAME_FORMAT + argument);
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
if (WorldUtil.IMP.isWorld(argument)) {
|
if (PlotSquared.platform().getWorldUtil().isWorld(argument)) {
|
||||||
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(argument)) {
|
if (PlotSquared.get().getPlotAreaManager().hasPlotArea(argument)) {
|
||||||
MainUtil.sendMessage(plotPlayer, Captions.SETUP_WORLD_NAME_TAKEN);
|
MainUtil.sendMessage(plotPlayer, Captions.SETUP_WORLD_NAME_TAKEN);
|
||||||
return this;
|
return this;
|
||||||
@ -225,12 +224,12 @@ public enum CommonSetupSteps implements SetupStep {
|
|||||||
plotPlayer.deleteMeta("setup");
|
plotPlayer.deleteMeta("setup");
|
||||||
String world;
|
String world;
|
||||||
if (builder.setupManager() == null) {
|
if (builder.setupManager() == null) {
|
||||||
world = SetupUtils.manager.setupWorld(builder);
|
world = PlotSquared.platform().getInjector().getInstance(SetupUtils.class).setupWorld(builder);
|
||||||
} else {
|
} else {
|
||||||
world = builder.setupManager().setupWorld(builder);
|
world = builder.setupManager().setupWorld(builder);
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
plotPlayer.teleport(WorldUtil.IMP.getSpawn(world), TeleportCause.COMMAND);
|
plotPlayer.teleport(PlotSquared.platform().getWorldUtil().getSpawn(world), TeleportCause.COMMAND);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
plotPlayer.sendMessage("&cAn error occurred. See console for more information");
|
plotPlayer.sendMessage("&cAn error occurred. See console for more information");
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -49,6 +49,13 @@ public class PlotAreaBuilder {
|
|||||||
@Getter @Setter private SettingsNodesWrapper settingsNodesWrapper;
|
@Getter @Setter private SettingsNodesWrapper settingsNodesWrapper;
|
||||||
@Getter @Setter private SetupUtils setupManager;
|
@Getter @Setter private SetupUtils setupManager;
|
||||||
|
|
||||||
|
private PlotAreaBuilder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static PlotAreaBuilder newBuilder() {
|
||||||
|
return new PlotAreaBuilder();
|
||||||
|
}
|
||||||
|
|
||||||
public static PlotAreaBuilder ofPlotArea(PlotArea area) {
|
public static PlotAreaBuilder ofPlotArea(PlotArea area) {
|
||||||
return new PlotAreaBuilder()
|
return new PlotAreaBuilder()
|
||||||
.worldName(area.getWorldName())
|
.worldName(area.getWorldName())
|
||||||
|
@ -39,7 +39,7 @@ public class SetupProcess {
|
|||||||
private SetupStep current;
|
private SetupStep current;
|
||||||
|
|
||||||
public SetupProcess() {
|
public SetupProcess() {
|
||||||
this.builder = new PlotAreaBuilder();
|
this.builder = PlotAreaBuilder.newBuilder();
|
||||||
this.history = new Stack<>();
|
this.history = new Stack<>();
|
||||||
this.current = CommonSetupSteps.CHOOSE_GENERATOR;
|
this.current = CommonSetupSteps.CHOOSE_GENERATOR;
|
||||||
}
|
}
|
||||||
|
@ -28,7 +28,6 @@ package com.plotsquared.core.util;
|
|||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.location.Location;
|
import com.plotsquared.core.location.Location;
|
||||||
import com.plotsquared.core.plot.Plot;
|
import com.plotsquared.core.plot.Plot;
|
||||||
import com.plotsquared.core.queue.GlobalBlockQueue;
|
|
||||||
import com.plotsquared.core.queue.LocalBlockQueue;
|
import com.plotsquared.core.queue.LocalBlockQueue;
|
||||||
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
import com.plotsquared.core.queue.ScopedLocalBlockQueue;
|
||||||
import com.plotsquared.core.util.task.RunnableVal;
|
import com.plotsquared.core.util.task.RunnableVal;
|
||||||
@ -47,11 +46,10 @@ public abstract class ChunkManager {
|
|||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
private static final Map<BlockVector2, RunnableVal<ScopedLocalBlockQueue>> addChunks =
|
private static final Map<BlockVector2, RunnableVal<ScopedLocalBlockQueue>> addChunks =
|
||||||
new ConcurrentHashMap<>();
|
new ConcurrentHashMap<>();
|
||||||
public static ChunkManager manager = null;
|
|
||||||
|
|
||||||
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force,
|
public static void setChunkInPlotArea(RunnableVal<ScopedLocalBlockQueue> force,
|
||||||
RunnableVal<ScopedLocalBlockQueue> add, String world, BlockVector2 loc) {
|
RunnableVal<ScopedLocalBlockQueue> add, String world, BlockVector2 loc) {
|
||||||
LocalBlockQueue queue = GlobalBlockQueue.IMP.getNewQueue(world, false);
|
LocalBlockQueue queue = PlotSquared.platform().getGlobalBlockQueue().getNewQueue(world, false);
|
||||||
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
if (PlotSquared.get().getPlotAreaManager().isAugmented(world) && PlotSquared.get().isNonStandardGeneration(world, loc)) {
|
||||||
int blockX = loc.getX() << 4;
|
int blockX = loc.getX() << 4;
|
||||||
int blockZ = loc.getZ() << 4;
|
int blockZ = loc.getZ() << 4;
|
||||||
|
@ -25,41 +25,12 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
import com.plotsquared.core.PlotPlatform;
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
|
||||||
import com.plotsquared.core.player.ConsolePlayer;
|
import com.plotsquared.core.player.ConsolePlayer;
|
||||||
import com.plotsquared.core.player.OfflinePlotPlayer;
|
import com.plotsquared.core.player.OfflinePlotPlayer;
|
||||||
import com.plotsquared.core.player.PlotPlayer;
|
import com.plotsquared.core.player.PlotPlayer;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
public abstract class EconHandler {
|
public abstract class EconHandler {
|
||||||
|
|
||||||
/**
|
|
||||||
* @deprecated This will be removed in the future,
|
|
||||||
* call {@link PlotPlatform#getEconomyHandler()} instead.
|
|
||||||
*/
|
|
||||||
@Deprecated @Nullable public static EconHandler manager;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Initialize the economy handler using {@link PlotPlatform#getEconomyHandler()}
|
|
||||||
* @deprecated Call {@link #init} instead or use {@link PlotPlatform#getEconomyHandler()}
|
|
||||||
* which does this already.
|
|
||||||
*/
|
|
||||||
@Deprecated public static void initializeEconHandler() {
|
|
||||||
manager = PlotSquared.platform().getEconomyHandler();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Return the econ handler instance, if one exists
|
|
||||||
*
|
|
||||||
* @return Economy handler instance
|
|
||||||
* @deprecated Call {@link PlotPlatform#getEconomyHandler()} instead
|
|
||||||
*/
|
|
||||||
@Deprecated @Nullable public static EconHandler getEconHandler() {
|
|
||||||
manager = PlotSquared.platform().getEconomyHandler();
|
|
||||||
return manager;
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract boolean init();
|
public abstract boolean init();
|
||||||
|
|
||||||
public double getMoney(PlotPlayer<?> player) {
|
public double getMoney(PlotPlayer<?> player) {
|
||||||
@ -88,4 +59,5 @@ public abstract class EconHandler {
|
|||||||
@Deprecated public boolean hasPermission(String player, String perm) {
|
@Deprecated public boolean hasPermission(String player, String perm) {
|
||||||
return hasPermission(null, player, perm);
|
return hasPermission(null, player, perm);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -34,11 +34,6 @@ import com.plotsquared.core.plot.PlotItemStack;
|
|||||||
*/
|
*/
|
||||||
public abstract class InventoryUtil {
|
public abstract class InventoryUtil {
|
||||||
|
|
||||||
/**
|
|
||||||
* This class is only used by internal functions, for most cases use the PlotInventory class
|
|
||||||
*/
|
|
||||||
public static InventoryUtil manager = null;
|
|
||||||
|
|
||||||
public abstract void open(final PlotInventory inv);
|
public abstract void open(final PlotInventory inv);
|
||||||
|
|
||||||
public abstract void close(final PlotInventory inv);
|
public abstract void close(final PlotInventory inv);
|
||||||
|
@ -64,7 +64,7 @@ public final class LegacyConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlockBucket blockToBucket(@NonNull final String block) {
|
private BlockBucket blockToBucket(@NonNull final String block) {
|
||||||
final BlockState plotBlock = WorldUtil.IMP.getClosestBlock(block).best;
|
final BlockState plotBlock = PlotSquared.platform().getWorldUtil().getClosestBlock(block).best;
|
||||||
return BlockBucket.withSingle(plotBlock);
|
return BlockBucket.withSingle(plotBlock);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,7 +101,7 @@ public final class LegacyConverter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private BlockState[] splitBlockList(@NonNull final List<String> list) {
|
private BlockState[] splitBlockList(@NonNull final List<String> list) {
|
||||||
return list.stream().map(s -> WorldUtil.IMP.getClosestBlock(s).best)
|
return list.stream().map(s -> PlotSquared.platform().getWorldUtil().getClosestBlock(s).best)
|
||||||
.toArray(BlockState[]::new);
|
.toArray(BlockState[]::new);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -240,8 +240,7 @@ public class MainUtil {
|
|||||||
*/
|
*/
|
||||||
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
public static boolean resetBiome(PlotArea area, Location pos1, Location pos2) {
|
||||||
BiomeType biome = area.getPlotBiome();
|
BiomeType biome = area.getPlotBiome();
|
||||||
if (!Objects.equals(WorldUtil.IMP
|
if (!Objects.equals(PlotSquared.platform().getWorldUtil().getBiomeSynchronous(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
|
||||||
.getBiomeSynchronous(area.getWorldName(), (pos1.getX() + pos2.getX()) / 2,
|
|
||||||
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
(pos1.getZ() + pos2.getZ()) / 2), biome)) {
|
||||||
MainUtil
|
MainUtil
|
||||||
.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
.setBiome(area.getWorldName(), pos1.getX(), pos1.getZ(), pos2.getX(), pos2.getZ(),
|
||||||
@ -613,14 +612,14 @@ public class MainUtil {
|
|||||||
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
|
BlockVector3 pos1 = BlockVector2.at(p1x, p1z).toBlockVector3();
|
||||||
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
|
BlockVector3 pos2 = BlockVector2.at(p2x, p2z).toBlockVector3(Plot.MAX_HEIGHT - 1);
|
||||||
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
CuboidRegion region = new CuboidRegion(pos1, pos2);
|
||||||
WorldUtil.IMP.setBiomes(world, region, biome);
|
PlotSquared.platform().getWorldUtil().setBiomes(world, region, biome);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the highest block at a location.
|
* Get the highest block at a location.
|
||||||
*/
|
*/
|
||||||
public static void getHighestBlock(String world, int x, int z, IntConsumer result) {
|
public static void getHighestBlock(String world, int x, int z, IntConsumer result) {
|
||||||
WorldUtil.IMP.getHighestBlock(world, x, z, highest -> {
|
PlotSquared.platform().getWorldUtil().getHighestBlock(world, x, z, highest -> {
|
||||||
if (highest == 0) {
|
if (highest == 0) {
|
||||||
result.accept(63);
|
result.accept(63);
|
||||||
} else {
|
} else {
|
||||||
@ -802,7 +801,7 @@ public class MainUtil {
|
|||||||
int num = plot.getConnectedPlots().size();
|
int num = plot.getConnectedPlots().size();
|
||||||
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
String alias = !plot.getAlias().isEmpty() ? plot.getAlias() : Captions.NONE.getTranslated();
|
||||||
Location bot = plot.getCorners()[0];
|
Location bot = plot.getCorners()[0];
|
||||||
WorldUtil.IMP.getBiome(plot.getWorldName(), bot.getX(), bot.getZ(), biome -> {
|
PlotSquared.platform().getWorldUtil().getBiome(plot.getWorldName(), bot.getX(), bot.getZ(), biome -> {
|
||||||
String info = iInfo;
|
String info = iInfo;
|
||||||
String trusted = getPlayerList(plot.getTrusted());
|
String trusted = getPlayerList(plot.getTrusted());
|
||||||
String members = getPlayerList(plot.getMembers());
|
String members = getPlayerList(plot.getMembers());
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
package com.plotsquared.core.util;
|
package com.plotsquared.core.util;
|
||||||
|
|
||||||
public class PremiumVerification {
|
public class PremiumVerification {
|
||||||
|
|
||||||
private static Boolean usingPremium;
|
private static Boolean usingPremium;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -37,6 +37,7 @@ import com.sk89q.worldedit.function.pattern.Pattern;
|
|||||||
import com.sk89q.worldedit.math.BlockVector2;
|
import com.sk89q.worldedit.math.BlockVector2;
|
||||||
import com.sk89q.worldedit.regions.CuboidRegion;
|
import com.sk89q.worldedit.regions.CuboidRegion;
|
||||||
import com.sk89q.worldedit.world.biome.BiomeType;
|
import com.sk89q.worldedit.world.biome.BiomeType;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@ -45,19 +46,23 @@ import java.util.Set;
|
|||||||
|
|
||||||
public abstract class RegionManager {
|
public abstract class RegionManager {
|
||||||
|
|
||||||
public static RegionManager manager = null;
|
|
||||||
|
|
||||||
public static BlockVector2 getRegion(Location location) {
|
public static BlockVector2 getRegion(Location location) {
|
||||||
int x = location.getX() >> 9;
|
int x = location.getX() >> 9;
|
||||||
int z = location.getZ() >> 9;
|
int z = location.getZ() >> 9;
|
||||||
return BlockVector2.at(x, z);
|
return BlockVector2.at(x, z);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void largeRegionTask(final String world, final CuboidRegion region,
|
private final ChunkManager chunkManager;
|
||||||
|
|
||||||
|
public RegionManager(@NotNull final ChunkManager chunkManager) {
|
||||||
|
this.chunkManager = chunkManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void largeRegionTask(final String world, final CuboidRegion region,
|
||||||
final RunnableVal<BlockVector2> task, final Runnable whenDone) {
|
final RunnableVal<BlockVector2> task, final Runnable whenDone) {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
HashSet<BlockVector2> chunks = new HashSet<>();
|
HashSet<BlockVector2> chunks = new HashSet<>();
|
||||||
Set<BlockVector2> mcrs = manager.getChunkChunks(world);
|
Set<BlockVector2> mcrs = this.getChunkChunks(world);
|
||||||
for (BlockVector2 mcr : mcrs) {
|
for (BlockVector2 mcr : mcrs) {
|
||||||
int bx = mcr.getX() << 9;
|
int bx = mcr.getX() << 9;
|
||||||
int bz = mcr.getZ() << 9;
|
int bz = mcr.getZ() << 9;
|
||||||
@ -85,7 +90,7 @@ public abstract class RegionManager {
|
|||||||
}
|
}
|
||||||
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
TaskManager.objectTask(chunks, new RunnableVal<BlockVector2>() {
|
||||||
@Override public void run(BlockVector2 value) {
|
@Override public void run(BlockVector2 value) {
|
||||||
ChunkManager.manager.loadChunk(world, value, false)
|
chunkManager.loadChunk(world, value, false)
|
||||||
.thenRun(() -> task.run(value));
|
.thenRun(() -> task.run(value));
|
||||||
}
|
}
|
||||||
}, whenDone);
|
}, whenDone);
|
||||||
|
@ -93,10 +93,15 @@ import java.util.zip.GZIPInputStream;
|
|||||||
import java.util.zip.GZIPOutputStream;
|
import java.util.zip.GZIPOutputStream;
|
||||||
|
|
||||||
public abstract class SchematicHandler {
|
public abstract class SchematicHandler {
|
||||||
public static SchematicHandler manager;
|
|
||||||
|
|
||||||
private boolean exportAll = false;
|
private boolean exportAll = false;
|
||||||
|
|
||||||
|
private final WorldUtil worldUtil;
|
||||||
|
|
||||||
|
public SchematicHandler(@NotNull final WorldUtil worldUtil) {
|
||||||
|
this.worldUtil = worldUtil;
|
||||||
|
}
|
||||||
|
|
||||||
public boolean exportAll(Collection<Plot> collection, final File outputDir,
|
public boolean exportAll(Collection<Plot> collection, final File outputDir,
|
||||||
final String namingScheme, final Runnable ifSuccess) {
|
final String namingScheme, final Runnable ifSuccess) {
|
||||||
if (this.exportAll) {
|
if (this.exportAll) {
|
||||||
@ -144,15 +149,14 @@ public abstract class SchematicHandler {
|
|||||||
}
|
}
|
||||||
|
|
||||||
final Runnable THIS = this;
|
final Runnable THIS = this;
|
||||||
SchematicHandler.manager.getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
getCompoundTag(plot, new RunnableVal<CompoundTag>() {
|
||||||
@Override public void run(final CompoundTag value) {
|
@Override public void run(final CompoundTag value) {
|
||||||
if (value == null) {
|
if (value == null) {
|
||||||
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.getId());
|
MainUtil.sendMessage(null, "&7 - Skipped plot &c" + plot.getId());
|
||||||
} else {
|
} else {
|
||||||
TaskManager.runTaskAsync(() -> {
|
TaskManager.runTaskAsync(() -> {
|
||||||
MainUtil.sendMessage(null, "&6ID: " + plot.getId());
|
MainUtil.sendMessage(null, "&6ID: " + plot.getId());
|
||||||
boolean result = SchematicHandler.manager
|
boolean result = save(value, directory + File.separator + name + ".schem");
|
||||||
.save(value, directory + File.separator + name + ".schem");
|
|
||||||
if (!result) {
|
if (!result) {
|
||||||
MainUtil
|
MainUtil
|
||||||
.sendMessage(null, "&7 - Failed to save &c" + plot.getId());
|
.sendMessage(null, "&7 - Failed to save &c" + plot.getId());
|
||||||
@ -223,7 +227,7 @@ public abstract class SchematicHandler {
|
|||||||
if (pw instanceof ClassicPlotWorld) {
|
if (pw instanceof ClassicPlotWorld) {
|
||||||
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
y_offset_actual = yOffset + ((ClassicPlotWorld) pw).PLOT_HEIGHT;
|
||||||
} else {
|
} else {
|
||||||
y_offset_actual = yOffset + 1 + WorldUtil.IMP
|
y_offset_actual = yOffset + 1 + this.worldUtil
|
||||||
.getHighestBlockSynchronous(plot.getWorldName(),
|
.getHighestBlockSynchronous(plot.getWorldName(),
|
||||||
region.getMinimumPoint().getX() + 1,
|
region.getMinimumPoint().getX() + 1,
|
||||||
region.getMinimumPoint().getZ() + 1);
|
region.getMinimumPoint().getZ() + 1);
|
||||||
@ -493,7 +497,7 @@ public abstract class SchematicHandler {
|
|||||||
final Location top = corners[1];
|
final Location top = corners[1];
|
||||||
|
|
||||||
CuboidRegion cuboidRegion =
|
CuboidRegion cuboidRegion =
|
||||||
new CuboidRegion(WorldUtil.IMP.getWeWorld(world), bot.getBlockVector3(),
|
new CuboidRegion(this.worldUtil.getWeWorld(world), bot.getBlockVector3(),
|
||||||
top.getBlockVector3());
|
top.getBlockVector3());
|
||||||
|
|
||||||
final int width = cuboidRegion.getWidth();
|
final int width = cuboidRegion.getWidth();
|
||||||
|
@ -34,8 +34,6 @@ import java.util.HashMap;
|
|||||||
|
|
||||||
public abstract class SetupUtils {
|
public abstract class SetupUtils {
|
||||||
|
|
||||||
public static SetupUtils manager;
|
|
||||||
|
|
||||||
public static HashMap<String, GeneratorWrapper<?>> generators = new HashMap<>();
|
public static HashMap<String, GeneratorWrapper<?>> generators = new HashMap<>();
|
||||||
|
|
||||||
public abstract void updateGenerators();
|
public abstract void updateGenerators();
|
||||||
@ -48,4 +46,5 @@ public abstract class SetupUtils {
|
|||||||
public abstract String setupWorld(final PlotAreaBuilder builder);
|
public abstract String setupWorld(final PlotAreaBuilder builder);
|
||||||
|
|
||||||
public abstract void unload(String world, boolean save);
|
public abstract void unload(String world, boolean save);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -61,7 +61,12 @@ import java.util.zip.ZipEntry;
|
|||||||
import java.util.zip.ZipOutputStream;
|
import java.util.zip.ZipOutputStream;
|
||||||
|
|
||||||
public abstract class WorldUtil {
|
public abstract class WorldUtil {
|
||||||
public static WorldUtil IMP;
|
|
||||||
|
private final RegionManager regionManager;
|
||||||
|
|
||||||
|
public WorldUtil(@NotNull final RegionManager regionManager) {
|
||||||
|
this.regionManager = regionManager;
|
||||||
|
}
|
||||||
|
|
||||||
public abstract String getMainWorld();
|
public abstract String getMainWorld();
|
||||||
|
|
||||||
@ -150,8 +155,7 @@ public abstract class WorldUtil {
|
|||||||
int brz = bot.getZ() >> 9;
|
int brz = bot.getZ() >> 9;
|
||||||
int trx = top.getX() >> 9;
|
int trx = top.getX() >> 9;
|
||||||
int trz = top.getZ() >> 9;
|
int trz = top.getZ() >> 9;
|
||||||
Set<BlockVector2> files =
|
Set<BlockVector2> files = regionManager.getChunkChunks(bot.getWorldName());
|
||||||
RegionManager.manager.getChunkChunks(bot.getWorldName());
|
|
||||||
for (BlockVector2 mca : files) {
|
for (BlockVector2 mca : files) {
|
||||||
if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz
|
if (mca.getX() >= brx && mca.getX() <= trx && mca.getZ() >= brz
|
||||||
&& mca.getZ() <= trz) {
|
&& mca.getZ() <= trz) {
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
*/
|
*/
|
||||||
package com.plotsquared.core.util.entity;
|
package com.plotsquared.core.util.entity;
|
||||||
|
|
||||||
|
import com.plotsquared.core.PlotSquared;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A collection of {@link EntityCategory entity categories}
|
* A collection of {@link EntityCategory entity categories}
|
||||||
*/
|
*/
|
||||||
@ -48,7 +50,7 @@ public class EntityCategories {
|
|||||||
public static final EntityCategory PLAYER = register("player");
|
public static final EntityCategory PLAYER = register("player");
|
||||||
|
|
||||||
public static EntityCategory register(final String id) {
|
public static EntityCategory register(final String id) {
|
||||||
final EntityCategory entityCategory = new EntityCategory(id);
|
final EntityCategory entityCategory = new EntityCategory(PlotSquared.platform().getWorldUtil(), id);
|
||||||
EntityCategory.REGISTRY.register(entityCategory.getId(), entityCategory);
|
EntityCategory.REGISTRY.register(entityCategory.getId(), entityCategory);
|
||||||
return entityCategory;
|
return entityCategory;
|
||||||
}
|
}
|
||||||
|
@ -41,15 +41,17 @@ public class EntityCategory extends Category<EntityType> implements Keyed {
|
|||||||
public static final NamespacedRegistry<EntityCategory> REGISTRY =
|
public static final NamespacedRegistry<EntityCategory> REGISTRY =
|
||||||
new NamespacedRegistry<>("entity type");
|
new NamespacedRegistry<>("entity type");
|
||||||
|
|
||||||
|
private final WorldUtil worldUtil;
|
||||||
private final String key;
|
private final String key;
|
||||||
|
|
||||||
protected EntityCategory(final String id) {
|
protected EntityCategory(final WorldUtil worldUtil, final String id) {
|
||||||
super("plotsquared:" + id);
|
super("plotsquared:" + id);
|
||||||
this.key = id;
|
this.key = id;
|
||||||
|
this.worldUtil = worldUtil;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected Set<EntityType> load() {
|
@Override protected Set<EntityType> load() {
|
||||||
return WorldUtil.IMP.getTypesInCategory(this.key);
|
return this.worldUtil.getTypesInCategory(this.key);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,8 @@ package com.plotsquared.core.util.task;
|
|||||||
|
|
||||||
import com.plotsquared.core.PlotSquared;
|
import com.plotsquared.core.PlotSquared;
|
||||||
import com.plotsquared.core.util.RuntimeExceptionRunnableVal;
|
import com.plotsquared.core.util.RuntimeExceptionRunnableVal;
|
||||||
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -39,46 +41,47 @@ public abstract class TaskManager {
|
|||||||
|
|
||||||
public static final HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
public static final HashSet<String> TELEPORT_QUEUE = new HashSet<>();
|
||||||
public static final HashMap<Integer, Integer> tasks = new HashMap<>();
|
public static final HashMap<Integer, Integer> tasks = new HashMap<>();
|
||||||
public static TaskManager IMP;
|
|
||||||
public static AtomicInteger index = new AtomicInteger(0);
|
public static AtomicInteger index = new AtomicInteger(0);
|
||||||
|
|
||||||
|
@Getter @Setter private static TaskManager implementation;
|
||||||
|
|
||||||
public static int runTaskRepeat(Runnable runnable, int interval) {
|
public static int runTaskRepeat(Runnable runnable, int interval) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
throw new IllegalArgumentException("disabled");
|
throw new IllegalArgumentException("disabled");
|
||||||
}
|
}
|
||||||
return IMP.taskRepeat(runnable, interval);
|
return getImplementation().taskRepeat(runnable, interval);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int runTaskRepeatAsync(Runnable runnable, int interval) {
|
public static int runTaskRepeatAsync(Runnable runnable, int interval) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
throw new IllegalArgumentException("disabled");
|
throw new IllegalArgumentException("disabled");
|
||||||
}
|
}
|
||||||
return IMP.taskRepeatAsync(runnable, interval);
|
return getImplementation().taskRepeatAsync(runnable, interval);
|
||||||
}
|
}
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runTaskAsync(Runnable runnable) {
|
public static void runTaskAsync(Runnable runnable) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMP.taskAsync(runnable);
|
getImplementation().taskAsync(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runTask(Runnable runnable) {
|
public static void runTask(Runnable runnable) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMP.task(runnable);
|
getImplementation().task(runnable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -90,21 +93,21 @@ public abstract class TaskManager {
|
|||||||
*/
|
*/
|
||||||
public static void runTaskLater(Runnable runnable, int delay) {
|
public static void runTaskLater(Runnable runnable, int delay) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMP.taskLater(runnable, delay);
|
getImplementation().taskLater(runnable, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void runTaskLaterAsync(Runnable runnable, int delay) {
|
public static void runTaskLaterAsync(Runnable runnable, int delay) {
|
||||||
if (runnable != null) {
|
if (runnable != null) {
|
||||||
if (IMP == null) {
|
if (getImplementation() == null) {
|
||||||
runnable.run();
|
runnable.run();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
IMP.taskLaterAsync(runnable, delay);
|
getImplementation().taskLaterAsync(runnable, delay);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -133,7 +136,7 @@ public abstract class TaskManager {
|
|||||||
final AtomicBoolean running = new AtomicBoolean(true);
|
final AtomicBoolean running = new AtomicBoolean(true);
|
||||||
final RuntimeExceptionRunnableVal<T> run =
|
final RuntimeExceptionRunnableVal<T> run =
|
||||||
new RuntimeExceptionRunnableVal<>(function, running);
|
new RuntimeExceptionRunnableVal<>(function, running);
|
||||||
TaskManager.IMP.task(run);
|
TaskManager.getImplementation().task(run);
|
||||||
try {
|
try {
|
||||||
synchronized (function) {
|
synchronized (function) {
|
||||||
while (running.get()) {
|
while (running.get()) {
|
||||||
|
Loading…
Reference in New Issue
Block a user