2020-04-16 04:52:39 +02:00
|
|
|
/*
|
2022-06-15 20:17:17 +02:00
|
|
|
* PlotSquared, a land and world management plugin for Minecraft.
|
|
|
|
* Copyright (C) IntellectualSites <https://intellectualsites.com>
|
|
|
|
* Copyright (C) IntellectualSites team and contributors
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* 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.
|
2020-04-16 04:52:39 +02:00
|
|
|
*
|
2022-06-15 20:17:17 +02:00
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
2020-04-16 04:52:39 +02:00
|
|
|
*/
|
2020-04-15 21:26:54 +02:00
|
|
|
package com.plotsquared.core;
|
|
|
|
|
2021-12-31 15:49:11 +01:00
|
|
|
import cloud.commandframework.services.ServicePipeline;
|
2020-07-10 22:12:37 +02:00
|
|
|
import com.google.inject.Injector;
|
|
|
|
import com.google.inject.Key;
|
2020-07-23 12:47:00 +02:00
|
|
|
import com.google.inject.TypeLiteral;
|
2020-05-10 14:02:25 +02:00
|
|
|
import com.plotsquared.core.backup.BackupManager;
|
2020-07-22 21:06:23 +02:00
|
|
|
import com.plotsquared.core.configuration.caption.LocaleHolder;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.generator.GeneratorWrapper;
|
|
|
|
import com.plotsquared.core.generator.HybridUtils;
|
|
|
|
import com.plotsquared.core.generator.IndependentPlotGenerator;
|
2020-07-10 22:12:37 +02:00
|
|
|
import com.plotsquared.core.inject.annotations.DefaultGenerator;
|
2020-07-10 12:21:29 +02:00
|
|
|
import com.plotsquared.core.location.World;
|
2020-07-21 14:28:54 +02:00
|
|
|
import com.plotsquared.core.permissions.PermissionHandler;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.player.PlotPlayer;
|
2021-11-02 14:38:48 +01:00
|
|
|
import com.plotsquared.core.plot.world.PlotAreaManager;
|
2020-07-10 22:12:37 +02:00
|
|
|
import com.plotsquared.core.queue.GlobalBlockQueue;
|
2022-01-12 22:21:51 +01:00
|
|
|
import com.plotsquared.core.util.AnnotationHelper;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.util.ChunkManager;
|
|
|
|
import com.plotsquared.core.util.EconHandler;
|
2020-05-15 18:41:57 +02:00
|
|
|
import com.plotsquared.core.util.PlatformWorldManager;
|
2020-05-19 00:28:52 +02:00
|
|
|
import com.plotsquared.core.util.PlayerManager;
|
2020-05-13 14:13:14 +02:00
|
|
|
import com.plotsquared.core.util.RegionManager;
|
2020-04-15 21:26:54 +02:00
|
|
|
import com.plotsquared.core.util.SetupUtils;
|
2020-04-30 12:53:07 +02:00
|
|
|
import com.plotsquared.core.util.WorldUtil;
|
2020-12-05 18:41:25 +01:00
|
|
|
import com.plotsquared.core.util.placeholders.PlaceholderRegistry;
|
2020-07-05 18:14:29 +02:00
|
|
|
import net.kyori.adventure.audience.Audience;
|
2020-12-28 11:21:35 +01:00
|
|
|
import net.kyori.adventure.text.Component;
|
2021-01-09 22:28:41 +01:00
|
|
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
|
|
import org.checkerframework.checker.nullness.qual.Nullable;
|
2020-07-14 19:34:44 +02:00
|
|
|
|
2016-03-16 15:15:38 +01:00
|
|
|
import java.io.File;
|
|
|
|
|
2020-05-27 14:08:48 +02:00
|
|
|
/**
|
|
|
|
* PlotSquared main utility class
|
|
|
|
*
|
|
|
|
* @param <P> Player type
|
|
|
|
*/
|
2020-07-22 21:06:23 +02:00
|
|
|
public interface PlotPlatform<P> extends LocaleHolder {
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Gets the directory which contains PlotSquared files. The directory may not exist.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2019-02-08 20:49:37 +01:00
|
|
|
* @return the PlotSquared directory
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull File getDirectory();
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-09-10 07:34:41 +02:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Gets the folder where all world data is stored.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2019-02-08 20:49:37 +01:00
|
|
|
* @return the world folder
|
2015-09-10 07:34:41 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull File worldContainer();
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Completely shuts down the plugin.
|
2018-12-23 19:43:36 +01:00
|
|
|
*/
|
|
|
|
void shutdown();
|
|
|
|
|
2020-12-05 18:41:25 +01:00
|
|
|
/**
|
|
|
|
* Get the name of the plugin
|
|
|
|
*
|
|
|
|
* @return Plugin name
|
|
|
|
*/
|
2021-01-10 00:01:48 +01:00
|
|
|
default @NonNull String pluginName() {
|
2019-09-08 20:02:45 +02:00
|
|
|
return "PlotSquared";
|
|
|
|
}
|
2016-09-26 10:31:08 +02:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2020-12-05 18:41:25 +01:00
|
|
|
* Gets the version of Minecraft that is running
|
|
|
|
*
|
2020-08-16 14:22:49 +02:00
|
|
|
* @return server version as array of numbers
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
int[] serverVersion();
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2022-03-05 19:03:39 +01:00
|
|
|
/**
|
|
|
|
* Gets the default minimum world height for the version of Minecraft that the server is running.
|
|
|
|
*
|
|
|
|
* @return minimum world height
|
2022-03-07 15:35:00 +01:00
|
|
|
* @since 6.6.0
|
2022-03-05 19:03:39 +01:00
|
|
|
*/
|
|
|
|
int versionMinHeight();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Gets the default maximum world height for the version of Minecraft that the server is running.
|
|
|
|
*
|
|
|
|
* @return maximum world height (inclusive)
|
2022-03-07 15:35:00 +01:00
|
|
|
* @since 6.6.0
|
2022-03-05 19:03:39 +01:00
|
|
|
*/
|
|
|
|
int versionMaxHeight();
|
|
|
|
|
2019-01-09 23:12:36 +01:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Gets the server implementation name and version
|
2020-12-05 18:41:25 +01:00
|
|
|
*
|
|
|
|
* @return server implementation and version as string
|
2019-01-09 23:12:36 +01:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull String serverImplementation();
|
2019-01-09 23:12:36 +01:00
|
|
|
|
2015-08-03 20:20:04 +02:00
|
|
|
/**
|
2020-12-05 18:41:25 +01:00
|
|
|
* Gets the native server code package prefix.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2020-12-05 18:41:25 +01:00
|
|
|
* @return The package prefix
|
2015-08-03 20:20:04 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull String serverNativePackage();
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2016-03-23 02:41:37 +01:00
|
|
|
* Start Metrics.
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
|
|
|
void startMetrics();
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2016-03-23 02:41:37 +01:00
|
|
|
* If a world is already loaded, set the generator (use NMS if required).
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-03-29 21:47:59 +02:00
|
|
|
* @param world The world to set the generator
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
void setGenerator(@NonNull String world);
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Unregisters a {@link PlotPlayer} from cache e.g. if they have logged off.
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2019-09-08 20:02:45 +02:00
|
|
|
* @param player the player to remove
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
void unregister(@NonNull PlotPlayer<?> player);
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2015-07-28 08:06:19 +02:00
|
|
|
/**
|
2019-02-08 20:49:37 +01:00
|
|
|
* Gets the generator wrapper for a world (world) and generator (name).
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2020-12-05 18:41:25 +01:00
|
|
|
* @param world The world to get the generator from
|
|
|
|
* @param name The name of the generator
|
|
|
|
* @return The generator being used for the provided world
|
2015-07-28 08:06:19 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@Nullable GeneratorWrapper<?> getGenerator(
|
|
|
|
@NonNull String world,
|
|
|
|
@Nullable String name
|
|
|
|
);
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2020-12-05 18:41:25 +01:00
|
|
|
/**
|
|
|
|
* Create a platform generator from a plot generator
|
|
|
|
*
|
|
|
|
* @param world World name
|
|
|
|
* @param generator Plot generator
|
|
|
|
* @return Platform generator wrapper
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull GeneratorWrapper<?> wrapPlotGenerator(
|
|
|
|
@NonNull String world,
|
|
|
|
@NonNull IndependentPlotGenerator generator
|
|
|
|
);
|
2016-03-23 02:41:37 +01:00
|
|
|
|
2016-09-17 08:02:05 +02:00
|
|
|
/**
|
|
|
|
* Usually HybridGen
|
2018-08-10 17:01:10 +02:00
|
|
|
*
|
2016-09-17 08:02:05 +02:00
|
|
|
* @return Default implementation generator
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull IndependentPlotGenerator defaultGenerator() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
2016-09-17 08:02:05 +02:00
|
|
|
|
2020-05-10 14:02:25 +02:00
|
|
|
/**
|
|
|
|
* Get the backup manager instance
|
|
|
|
*
|
|
|
|
* @return Backup manager
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull BackupManager backupManager() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(BackupManager.class);
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
2020-05-15 18:41:57 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the platform specific world manager
|
|
|
|
*
|
|
|
|
* @return World manager
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull PlatformWorldManager<?> worldManager() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(PlatformWorldManager.class);
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
2020-05-19 00:28:52 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the player manager implementation for the platform
|
|
|
|
*
|
|
|
|
* @return Player manager
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull PlayerManager<? extends PlotPlayer<P>, ? extends P> playerManager() {
|
|
|
|
return injector().getInstance(Key.get(new TypeLiteral<PlayerManager<? extends PlotPlayer<P>, ? extends P>>() {
|
|
|
|
}));
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
2020-05-10 14:02:25 +02:00
|
|
|
|
2020-07-10 12:21:29 +02:00
|
|
|
/**
|
|
|
|
* Get a platform world wrapper from a world name
|
|
|
|
*
|
|
|
|
* @param worldName World name
|
|
|
|
* @return Platform world wrapper
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@Nullable World<?> getPlatformWorld(@NonNull String worldName);
|
2020-07-10 12:21:29 +02:00
|
|
|
|
2020-07-10 22:12:37 +02:00
|
|
|
/**
|
|
|
|
* Get the {@link com.google.inject.Injector} instance used by PlotSquared
|
|
|
|
*
|
|
|
|
* @return Injector instance
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull Injector injector();
|
2020-07-10 22:12:37 +02:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the world utility implementation
|
|
|
|
*
|
|
|
|
* @return World utility
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull WorldUtil worldUtil() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(WorldUtil.class);
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the global block queue implementation
|
|
|
|
*
|
|
|
|
* @return Global block queue implementation
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull GlobalBlockQueue globalBlockQueue() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(GlobalBlockQueue.class);
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
2020-07-11 05:29:41 +02:00
|
|
|
* Get the {@link HybridUtils} implementation for the platform
|
2020-07-10 22:12:37 +02:00
|
|
|
*
|
2020-07-11 05:29:41 +02:00
|
|
|
* @return Hybrid utils
|
2020-07-10 22:12:37 +02:00
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull HybridUtils hybridUtils() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(HybridUtils.class);
|
2020-07-10 22:12:37 +02:00
|
|
|
}
|
|
|
|
|
2020-07-11 05:29:41 +02:00
|
|
|
/**
|
2021-05-15 20:39:16 +02:00
|
|
|
* Get the {@link SetupUtils} implementation for the platform
|
2020-07-11 05:29:41 +02:00
|
|
|
*
|
|
|
|
* @return Setup utils
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull SetupUtils setupUtils() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(SetupUtils.class);
|
2020-07-11 05:29:41 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the {@link EconHandler} implementation for the platform
|
2021-01-09 22:28:41 +01:00
|
|
|
*
|
2020-07-11 05:29:41 +02:00
|
|
|
* @return Econ handler
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull EconHandler econHandler() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(EconHandler.class);
|
2020-07-11 05:29:41 +02:00
|
|
|
}
|
|
|
|
|
2020-07-14 18:49:40 +02:00
|
|
|
/**
|
|
|
|
* Get the {@link RegionManager} implementation for the platform
|
|
|
|
*
|
|
|
|
* @return Region manager
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull RegionManager regionManager() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(RegionManager.class);
|
2020-07-14 18:49:40 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the {@link ChunkManager} implementation for the platform
|
|
|
|
*
|
|
|
|
* @return Region manager
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull ChunkManager chunkManager() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(ChunkManager.class);
|
2020-07-14 18:49:40 +02:00
|
|
|
}
|
2020-05-10 14:02:25 +02:00
|
|
|
|
2021-11-02 14:38:48 +01:00
|
|
|
/**
|
|
|
|
* Get the {@link PlotAreaManager} implementation.
|
|
|
|
*
|
|
|
|
* @return the PlotAreaManager
|
2022-01-24 21:46:01 +01:00
|
|
|
* @since 6.1.4
|
2021-11-02 14:38:48 +01:00
|
|
|
*/
|
|
|
|
@NonNull PlotAreaManager plotAreaManager();
|
|
|
|
|
2020-07-05 18:14:29 +02:00
|
|
|
/**
|
|
|
|
* Get the platform specific console {@link Audience}
|
|
|
|
*
|
|
|
|
* @return Console audience
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull Audience consoleAudience();
|
2020-07-05 18:14:29 +02:00
|
|
|
|
2020-12-05 18:41:25 +01:00
|
|
|
/**
|
|
|
|
* Get a formatted string containing all plugins on the server together
|
|
|
|
* with plugin metadata. Mainly for use in debug pastes
|
|
|
|
*
|
|
|
|
* @return Formatted string
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
@NonNull String pluginsFormatted();
|
2019-11-04 22:55:40 +01:00
|
|
|
|
2022-01-12 22:21:51 +01:00
|
|
|
/**
|
|
|
|
* Get the kind of WorldEdit implementation
|
|
|
|
*
|
|
|
|
* @return worldedit implementations
|
2022-01-14 11:14:00 +01:00
|
|
|
* @since 6.3.0
|
2022-01-12 22:21:51 +01:00
|
|
|
*/
|
|
|
|
@AnnotationHelper.ApiDescription(info = "Internal use only")
|
|
|
|
@NonNull String worldEditImplementations();
|
|
|
|
|
2020-08-16 13:49:16 +02:00
|
|
|
/**
|
|
|
|
* Load the caption maps
|
|
|
|
*/
|
|
|
|
void copyCaptionMaps();
|
|
|
|
|
2020-07-21 14:28:54 +02:00
|
|
|
/**
|
|
|
|
* Get the {@link PermissionHandler} implementation for the platform
|
|
|
|
*
|
|
|
|
* @return Permission handler
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull PermissionHandler permissionHandler() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(PermissionHandler.class);
|
2020-07-21 14:28:54 +02:00
|
|
|
}
|
|
|
|
|
2020-08-14 17:24:34 +02:00
|
|
|
/**
|
|
|
|
* Get the {@link ServicePipeline} implementation
|
|
|
|
*
|
|
|
|
* @return Service pipeline
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull ServicePipeline servicePipeline() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(ServicePipeline.class);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Get the {@link PlaceholderRegistry} implementation
|
|
|
|
*
|
|
|
|
* @return Placeholder registry
|
|
|
|
*/
|
2021-01-09 22:28:41 +01:00
|
|
|
default @NonNull PlaceholderRegistry placeholderRegistry() {
|
2020-12-05 18:41:25 +01:00
|
|
|
return injector().getInstance(PlaceholderRegistry.class);
|
2020-08-14 17:24:34 +02:00
|
|
|
}
|
|
|
|
|
2021-01-10 00:01:48 +01:00
|
|
|
/**
|
|
|
|
* Convert a component to a legacy string
|
|
|
|
*
|
|
|
|
* @param component Component to convert
|
|
|
|
* @return Converted string
|
|
|
|
*/
|
|
|
|
@NonNull String toLegacyPlatformString(@NonNull Component component);
|
2020-12-28 11:21:35 +01:00
|
|
|
|
2021-06-08 19:36:45 +02:00
|
|
|
/**
|
2022-06-11 16:16:06 +02:00
|
|
|
* Returns if the FastAsyncWorldEdit-PlotSquared hook is active/enabled
|
2021-06-08 19:36:45 +02:00
|
|
|
*
|
2022-06-11 16:16:06 +02:00
|
|
|
* @return status of FastAsyncWorldEdit-PlotSquared hook
|
2021-06-08 19:36:45 +02:00
|
|
|
*/
|
|
|
|
default boolean isFaweHooking() {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
2015-02-20 07:34:19 +01:00
|
|
|
}
|