PlotSquared/Core/src/main/java/com/plotsquared/core/PlotPlatform.java

364 lines
10 KiB
Java
Raw Normal View History

/*
* PlotSquared, a land and world management plugin for Minecraft.
* Copyright (C) IntellectualSites <https://intellectualsites.com>
* Copyright (C) IntellectualSites team and contributors
*
* 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 <https://www.gnu.org/licenses/>.
*/
2020-04-15 21:26:54 +02:00
package com.plotsquared.core;
import cloud.commandframework.services.ServicePipeline;
2020-07-10 22:12:37 +02:00
import com.google.inject.Injector;
import com.google.inject.Key;
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;
import com.plotsquared.core.location.World;
import com.plotsquared.core.permissions.PermissionHandler;
2020-04-15 21:26:54 +02:00
import com.plotsquared.core.player.PlotPlayer;
import com.plotsquared.core.plot.world.PlotAreaManager;
2020-07-10 22:12:37 +02:00
import com.plotsquared.core.queue.GlobalBlockQueue;
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;
import com.plotsquared.core.util.PlatformWorldManager;
2020-05-19 00:28:52 +02:00
import com.plotsquared.core.util.PlayerManager;
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;
import com.plotsquared.core.util.placeholders.PlaceholderRegistry;
2020-07-05 18:14:29 +02:00
import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
2020-07-14 19:34:44 +02:00
import java.io.File;
/**
* 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
/**
* Gets the directory which contains PlotSquared files. The directory may not exist.
2018-08-10 17:01:10 +02:00
*
* @return the PlotSquared directory
2015-07-28 08:06:19 +02:00
*/
@NonNull File getDirectory();
2016-03-23 02:41:37 +01:00
/**
* Gets the folder where all world data is stored.
2018-08-10 17:01:10 +02:00
*
* @return the world folder
*/
@NonNull File worldContainer();
2016-03-23 02:41:37 +01:00
2015-07-28 08:06:19 +02:00
/**
* Completely shuts down the plugin.
*/
void shutdown();
/**
* 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";
}
2015-07-28 08:06:19 +02:00
/**
* Gets the version of Minecraft that is running
*
* @return server version as array of numbers
2015-07-28 08:06:19 +02:00
*/
int[] serverVersion();
2016-03-23 02:41:37 +01:00
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
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
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
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
Implement extended world heights from Y-64 to Y319 #3473 (#3473) * Begin to implement extended world heights: - Implemented in Bukkit module (and where required in Core module) * Implement extended world heights into core module * Add min gen height to setup, * Default gen/build heights based on minecraft version * Few fixes * Fix up queues * Address comments * Make road schematic stuff slightly more efficient by sharing queues * Minor fixes, don't overlay error many times for the same y * Fix incorrect schematic paste height, undo changes to HybridUtils * Overhall regenallroads method to make it work, make sure BukkitChunkCoordinator can/will finish * Process chunks in order when regenerating all roads * Address comments * Address comments * Ground level//bedrock is at min gen height - Add comment on == rather than <= being used - It's because it's only checking for the bedrock layer being broken if that's disabled * Fix offset for min build height in SchematicHandler * Better javadoc Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com> * Address inclusivity issues for max world height * Javadocs/comments/deprecation * Use world min/max heights if present in QueueCoordinator * Address some deprecations for regions and biome setting * Add a count for chunks we're currently trying to load to not skip chunks at the end of a queue's edit * Use minGenHeight + 1 rather than build height in AugmentedUtils * Create utility method for layer index in GenChunk * Correct height in HybridUtils, also use minGenHeight + 1 * Don't magically split to 128 height in regeneration * Add utility methods for world height in QueueCoordinator * Clean up ClassicPlotManager road creation/removal * Start generation at min gen height if bedrock is disabled * min gen height is set in PlotArea * Add note on schem y normalisation * Improve plot getVolume method readability * Don't overly extend height when regenerating road region * y index utility method in ChunknQueueCoordinator * Layer index utility method in LocalChunk * Use version min/max heights if world not present in QueueCoordinator * Fix min -> max * Don't allow players to modify outside build height when using plot set / schematics. - Also fixes schematic height issues * Remove debug * Address comments * Switch loadingChunks to AtomicInteger to be safe (in case of multi-threaded) * Fix "security" issue that was already present * Ensure sign isn't physicsed Co-authored-by: Hannes Greule <SirYwell@users.noreply.github.com>
2022-03-05 19:03:39 +01:00
*/
int versionMaxHeight();
/**
* Gets the server implementation name and version
*
* @return server implementation and version as string
*/
@NonNull String serverImplementation();
2015-08-03 20:20:04 +02:00
/**
* Gets the native server code package prefix.
2018-08-10 17:01:10 +02:00
*
* @return The package prefix
2015-08-03 20:20:04 +02: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
*/
void setGenerator(@NonNull String world);
2016-03-23 02:41:37 +01:00
2015-07-28 08:06:19 +02: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
*/
void unregister(@NonNull PlotPlayer<?> player);
2016-03-23 02:41:37 +01:00
2015-07-28 08:06:19 +02:00
/**
* Gets the generator wrapper for a world (world) and generator (name).
2018-08-10 17:01:10 +02: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
*/
@Nullable GeneratorWrapper<?> getGenerator(
@NonNull String world,
@Nullable String name
);
2016-03-23 02:41:37 +01:00
/**
* Create a platform generator from a plot generator
*
* @param world World name
* @param generator Plot generator
* @return Platform generator wrapper
*/
@NonNull GeneratorWrapper<?> wrapPlotGenerator(
@NonNull String world,
@NonNull IndependentPlotGenerator generator
);
2016-03-23 02:41:37 +01:00
/**
* Usually HybridGen
2018-08-10 17:01:10 +02:00
*
* @return Default implementation generator
*/
default @NonNull IndependentPlotGenerator defaultGenerator() {
return injector().getInstance(Key.get(IndependentPlotGenerator.class, DefaultGenerator.class));
2020-07-10 22:12:37 +02:00
}
2020-05-10 14:02:25 +02:00
/**
* Get the backup manager instance
*
* @return Backup manager
*/
default @NonNull BackupManager backupManager() {
return injector().getInstance(BackupManager.class);
2020-07-10 22:12:37 +02:00
}
/**
* Get the platform specific world manager
*
* @return World manager
*/
default @NonNull PlatformWorldManager<?> worldManager() {
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
*/
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
/**
* Get a platform world wrapper from a world name
*
* @param worldName World name
* @return Platform world wrapper
*/
@Nullable World<?> getPlatformWorld(@NonNull String worldName);
2020-07-10 22:12:37 +02:00
/**
* Get the {@link com.google.inject.Injector} instance used by PlotSquared
*
* @return Injector instance
*/
@NonNull Injector injector();
2020-07-10 22:12:37 +02:00
/**
* Get the world utility implementation
*
* @return World utility
*/
default @NonNull WorldUtil worldUtil() {
return injector().getInstance(WorldUtil.class);
2020-07-10 22:12:37 +02:00
}
/**
* Get the global block queue implementation
*
* @return Global block queue implementation
*/
default @NonNull GlobalBlockQueue globalBlockQueue() {
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
*/
default @NonNull HybridUtils hybridUtils() {
return injector().getInstance(HybridUtils.class);
2020-07-10 22:12:37 +02:00
}
2020-07-11 05:29:41 +02:00
/**
* Get the {@link SetupUtils} implementation for the platform
2020-07-11 05:29:41 +02:00
*
* @return Setup utils
*/
default @NonNull SetupUtils setupUtils() {
return injector().getInstance(SetupUtils.class);
2020-07-11 05:29:41 +02:00
}
/**
* Get the {@link EconHandler} implementation for the platform
*
2020-07-11 05:29:41 +02:00
* @return Econ handler
*/
default @NonNull EconHandler econHandler() {
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
*/
default @NonNull RegionManager regionManager() {
return injector().getInstance(RegionManager.class);
2020-07-14 18:49:40 +02:00
}
/**
* Get the {@link ChunkManager} implementation for the platform
*
* @return Region manager
*/
default @NonNull ChunkManager chunkManager() {
return injector().getInstance(ChunkManager.class);
2020-07-14 18:49:40 +02:00
}
2020-05-10 14:02:25 +02:00
/**
* Get the {@link PlotAreaManager} implementation.
*
* @return the PlotAreaManager
* @since 6.1.4
*/
@NonNull PlotAreaManager plotAreaManager();
2020-07-05 18:14:29 +02:00
/**
* Get the platform specific console {@link Audience}
*
* @return Console audience
*/
@NonNull Audience consoleAudience();
2020-07-05 18:14:29 +02:00
/**
* Get a formatted string containing all plugins on the server together
* with plugin metadata. Mainly for use in debug pastes
*
* @return Formatted string
*/
@NonNull String pluginsFormatted();
2019-11-04 22:55:40 +01:00
/**
* Get the kind of WorldEdit implementation
*
* @return worldedit implementations
2022-01-14 11:14:00 +01:00
* @since 6.3.0
*/
@AnnotationHelper.ApiDescription(info = "Internal use only")
@NonNull String worldEditImplementations();
/**
* Load the caption maps
*/
void copyCaptionMaps();
/**
* Get the {@link PermissionHandler} implementation for the platform
*
* @return Permission handler
*/
default @NonNull PermissionHandler permissionHandler() {
return injector().getInstance(PermissionHandler.class);
}
/**
* Get the {@link ServicePipeline} implementation
*
* @return Service pipeline
*/
default @NonNull ServicePipeline servicePipeline() {
return injector().getInstance(ServicePipeline.class);
}
/**
* Get the {@link PlaceholderRegistry} implementation
*
* @return Placeholder registry
*/
default @NonNull PlaceholderRegistry placeholderRegistry() {
return injector().getInstance(PlaceholderRegistry.class);
}
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);
2021-06-08 19:36:45 +02:00
/**
* Returns if the FastAsyncWorldEdit-PlotSquared hook is active/enabled
2021-06-08 19:36:45 +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
}