├── settings.gradle ├── gradle └── wrapper │ ├── gradle-wrapper.jar │ └── gradle-wrapper.properties ├── renovate.json ├── Cosmos-Plugin ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ └── main │ │ ├── resources │ │ ├── metrics.yml │ │ ├── databases.yml │ │ ├── plugin.yml │ │ ├── menu │ │ │ ├── template-create-confirmation.yml │ │ │ ├── template-delete-confirmation.yml │ │ │ ├── template-creation.yml │ │ │ ├── template-editor.yml │ │ │ └── template-view.yml │ │ └── messages.yml │ │ └── java │ │ └── me │ │ └── illusion │ │ └── cosmos │ │ ├── CosmosBukkitPlugin.java │ │ ├── utilities │ │ ├── menu │ │ │ ├── selection │ │ │ │ ├── Selection.java │ │ │ │ ├── RectangularSelection.java │ │ │ │ ├── SlotSelection.java │ │ │ │ ├── MultiSelection.java │ │ │ │ ├── PatternMaskSelection.java │ │ │ │ └── HollowRectangularSelection.java │ │ │ ├── SwitchPredicate.java │ │ │ ├── math │ │ │ │ └── Point.java │ │ │ ├── pagination │ │ │ │ ├── PaginableTitle.java │ │ │ │ └── PaginableArea.java │ │ │ ├── element │ │ │ │ ├── Renderable.java │ │ │ │ └── MenuElement.java │ │ │ ├── registry │ │ │ │ ├── communication │ │ │ │ │ ├── UpdatableMenu.java │ │ │ │ │ └── UpdatableMenuRegistry.java │ │ │ │ └── meta │ │ │ │ │ ├── HiddenMenuData.java │ │ │ │ │ └── HiddenMenuTracker.java │ │ │ ├── button │ │ │ │ ├── RemovableItem.java │ │ │ │ ├── DecorationItem.java │ │ │ │ └── Button.java │ │ │ ├── base │ │ │ │ └── ConfigurableMenu.java │ │ │ ├── layer │ │ │ │ ├── BaseLayer.java │ │ │ │ └── PaginableLayer.java │ │ │ ├── mask │ │ │ │ └── PatternMask.java │ │ │ └── listener │ │ │ │ └── MenuListener.java │ │ ├── command │ │ │ ├── language │ │ │ │ ├── type │ │ │ │ │ ├── ParameterType.java │ │ │ │ │ ├── impl │ │ │ │ │ │ ├── FilteredParameterType.java │ │ │ │ │ │ ├── StringParameterType.java │ │ │ │ │ │ ├── IntegerParameterType.java │ │ │ │ │ │ ├── NumericalParameterType.java │ │ │ │ │ │ └── filtered │ │ │ │ │ │ │ └── TimeParameterType.java │ │ │ │ │ ├── Parameter.java │ │ │ │ │ └── ParameterTypes.java │ │ │ │ ├── parser │ │ │ │ │ ├── ArgumentType.java │ │ │ │ │ └── argument │ │ │ │ │ │ ├── ParameterArgument.java │ │ │ │ │ │ └── Argument.java │ │ │ │ ├── unit │ │ │ │ │ └── MinecraftTime.java │ │ │ │ └── data │ │ │ │ │ └── ObjectiveMetadata.java │ │ │ ├── command │ │ │ │ ├── impl │ │ │ │ │ ├── ExecutionContext.java │ │ │ │ │ └── AdvancedCommand.java │ │ │ │ ├── CommandUtilities.java │ │ │ │ ├── BukkitBaseCommand.java │ │ │ │ ├── compat │ │ │ │ │ └── SimpleCommandWrapper.java │ │ │ │ └── CommandManager.java │ │ │ └── legacy │ │ │ │ └── SimpleCommand.java │ │ ├── geometry │ │ │ ├── Point.java │ │ │ └── Pair.java │ │ ├── sql │ │ │ ├── SQLColumn.java │ │ │ ├── connection │ │ │ │ ├── SQLConnectionProvider.java │ │ │ │ └── impl │ │ │ │ │ ├── SQLiteConnectionProvider.java │ │ │ │ │ ├── MySQLConnectionProvider.java │ │ │ │ │ ├── MariaDBConnectionProvider.java │ │ │ │ │ └── PostgresConnectionProvider.java │ │ │ ├── ColumnType.java │ │ │ └── ColumnData.java │ │ ├── concurrency │ │ │ ├── FutureUtils.java │ │ │ └── MainThreadExecutor.java │ │ ├── time │ │ │ └── Time.java │ │ ├── item │ │ │ └── ItemConfigurationSerializer.java │ │ ├── collection │ │ │ └── ListUtils.java │ │ ├── hook │ │ │ └── WorldEditUtils.java │ │ ├── text │ │ │ └── TextUtils.java │ │ └── io │ │ │ └── FileUtils.java │ │ ├── database │ │ ├── base │ │ │ └── CosmosSQLQuery.java │ │ ├── impl │ │ │ ├── remote │ │ │ │ ├── MySQLDataContainer.java │ │ │ │ ├── MariaDBDataProvider.java │ │ │ │ └── PostgresDataContainer.java │ │ │ ├── SQLiteDataContainer.java │ │ │ └── MemoryDataContainer.java │ │ └── CosmosDataContainer.java │ │ ├── event │ │ ├── base │ │ │ └── CosmosEvent.java │ │ ├── area │ │ │ ├── CosmosPasteAreaEvent.java │ │ │ └── CosmosUnloadAreaEvent.java │ │ ├── session │ │ │ ├── CosmosCreateSessionEvent.java │ │ │ └── CosmosUnloadSessionEvent.java │ │ ├── CosmosDefaultContainerInitializedEvent.java │ │ └── CosmosTemplateMigrateEvent.java │ │ ├── world │ │ ├── pool │ │ │ ├── PooledWorldState.java │ │ │ ├── PooledWorld.java │ │ │ └── WorldPoolSettings.java │ │ └── VoidGenerator.java │ │ ├── metrics │ │ ├── CosmosMetric.java │ │ ├── database │ │ │ ├── MetricsDatabase.java │ │ │ └── impl │ │ │ │ └── InfluxMetricsDatabase.java │ │ └── impl │ │ │ └── LoadedSessionsMetric.java │ │ ├── template │ │ ├── data │ │ │ └── TemplateData.java │ │ ├── TemplatedArea.java │ │ ├── PastedArea.java │ │ └── impl │ │ │ ├── builtin │ │ │ ├── StructurePastedArea.java │ │ │ └── StructureTemplatedArea.java │ │ │ └── worldedit │ │ │ └── SchematicTemplatedArea.java │ │ ├── listener │ │ └── CosmosUnloadAreaListener.java │ │ ├── menu │ │ ├── sorting │ │ │ └── SortingOption.java │ │ └── generic │ │ │ └── GenericConfirmationMenu.java │ │ ├── command │ │ ├── CosmosTemplateViewMenuCommand.java │ │ ├── CosmosTemplateCreateCommand.java │ │ ├── CosmosTemplatePasteCommand.java │ │ ├── CosmosTemplateListCommand.java │ │ ├── CosmosImportCommand.java │ │ ├── CosmosTemplateSetCommand.java │ │ ├── CosmosTemplateDeleteCommand.java │ │ └── CosmosTestLatencyCommand.java │ │ ├── session │ │ ├── CosmosSessionHolderRegistry.java │ │ ├── task │ │ │ ├── UnloadTask.java │ │ │ └── UnloadRequest.java │ │ └── CosmosSession.java │ │ ├── file │ │ ├── CosmosDatabasesFile.java │ │ └── CosmosMetricsFile.java │ │ ├── grid │ │ ├── CosmosGridRegistry.java │ │ ├── CosmosGrid.java │ │ └── impl │ │ │ └── WorldPerAreaGrid.java │ │ ├── serialization │ │ ├── CosmosSerializer.java │ │ └── CosmosSerializerRegistry.java │ │ └── cache │ │ └── CosmosCache.java └── build.gradle ├── CosmosExamplePlugin ├── gradle │ └── wrapper │ │ ├── gradle-wrapper.jar │ │ └── gradle-wrapper.properties ├── src │ └── main │ │ ├── resources │ │ └── plugin.yml │ │ └── java │ │ └── me │ │ └── illusion │ │ └── example │ │ └── cosmosexampleplugin │ │ ├── listener │ │ ├── TemplateCacheListener.java │ │ └── PlayerJoinListener.java │ │ └── CosmosExamplePlugin.java └── build.gradle ├── LICENSE └── README.md /settings.gradle: -------------------------------------------------------------------------------- 1 | rootProject.name = 'Cosmos' 2 | include 'Cosmos-Plugin', 'CosmosExamplePlugin' -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IllusionTheDev/Cosmos/HEAD/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /renovate.json: -------------------------------------------------------------------------------- 1 | { 2 | "$schema": "https://docs.renovatebot.com/renovate-schema.json", 3 | "extends": [ 4 | "config:base" 5 | ] 6 | } 7 | -------------------------------------------------------------------------------- /Cosmos-Plugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IllusionTheDev/Cosmos/HEAD/Cosmos-Plugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /CosmosExamplePlugin/gradle/wrapper/gradle-wrapper.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/IllusionTheDev/Cosmos/HEAD/CosmosExamplePlugin/gradle/wrapper/gradle-wrapper.jar -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/metrics.yml: -------------------------------------------------------------------------------- 1 | enabled: false 2 | type: influx 3 | 4 | influx: 5 | host: 6 | port: 443 7 | bucket: 8 | token: 9 | org: 10 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/CosmosBukkitPlugin.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos; 2 | 3 | public class CosmosBukkitPlugin extends CosmosPlugin { 4 | 5 | } 6 | -------------------------------------------------------------------------------- /CosmosExamplePlugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: CosmosExamplePlugin 2 | version: '${version}' 3 | main: me.illusion.example.cosmosexampleplugin.CosmosExamplePlugin 4 | api-version: 1.19 5 | 6 | depend: 7 | - Cosmos -------------------------------------------------------------------------------- /gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/Selection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.List; 4 | 5 | public interface Selection { 6 | 7 | List getSlots(); 8 | 9 | } 10 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/SwitchPredicate.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu; 2 | 3 | /** 4 | * Created by Giovanni on 2/13/2023 5 | */ 6 | public interface SwitchPredicate { 7 | 8 | boolean switchIf(); 9 | } 10 | -------------------------------------------------------------------------------- /CosmosExamplePlugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | zipStoreBase=GRADLE_USER_HOME 5 | zipStorePath=wrapper/dists 6 | -------------------------------------------------------------------------------- /Cosmos-Plugin/gradle/wrapper/gradle-wrapper.properties: -------------------------------------------------------------------------------- 1 | distributionBase=GRADLE_USER_HOME 2 | distributionPath=wrapper/dists 3 | distributionUrl=https\://services.gradle.org/distributions/gradle-8.1.1-bin.zip 4 | networkTimeout=10000 5 | zipStoreBase=GRADLE_USER_HOME 6 | zipStorePath=wrapper/dists 7 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/database/base/CosmosSQLQuery.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.database.base; 2 | 3 | public enum CosmosSQLQuery { 4 | FETCH_TEMPLATE, 5 | FETCH_ALL, 6 | FETCH_ALL_NO_DATA, 7 | FETCH_TEMPLATE_SERIALIZER, 8 | STORE_TEMPLATE, 9 | DELETE_TEMPLATE 10 | } 11 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/math/Point.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.math; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class Point { 9 | 10 | private final int x; 11 | private final int y; 12 | 13 | } 14 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/ParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type; 2 | 3 | public interface ParameterType { 4 | 5 | boolean isType(String input); 6 | 7 | Type parse(String input); 8 | 9 | Type getDefaultValue(); 10 | 11 | } 12 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/base/CosmosEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event.base; 2 | 3 | import org.bukkit.Bukkit; 4 | import org.bukkit.event.Event; 5 | 6 | public abstract class CosmosEvent extends Event { 7 | 8 | public CosmosEvent() { 9 | super(!Bukkit.isPrimaryThread()); 10 | } 11 | 12 | } 13 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/world/pool/PooledWorldState.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.world.pool; 2 | 3 | public enum PooledWorldState implements Comparable { 4 | IN_USE, 5 | UNUSED, 6 | UNLOADED; 7 | 8 | public boolean isLoaded() { 9 | return this == IN_USE || this == UNUSED; 10 | } 11 | } -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/metrics/CosmosMetric.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.metrics; 2 | 3 | import java.util.Map; 4 | 5 | public interface CosmosMetric { 6 | 7 | String getName(); 8 | 9 | Map fetchMetrics(); 10 | 11 | default boolean supportsAsync() { 12 | return false; 13 | } 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/parser/ArgumentType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.parser; 2 | 3 | public enum ArgumentType { 4 | 5 | PARAMETER, 6 | TAG, 7 | LIST, 8 | STRING; 9 | 10 | public boolean isLiteral() { 11 | return this == TAG || this == STRING; 12 | } 13 | } 14 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/geometry/Point.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.geometry; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * Represents a point in 2D space 8 | */ 9 | @Data 10 | @AllArgsConstructor 11 | public class Point { 12 | 13 | private final int x; 14 | private final int y; 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/pagination/PaginableTitle.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.pagination; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | @Data 7 | @AllArgsConstructor 8 | public class PaginableTitle { 9 | 10 | private final String none; 11 | private final String left; 12 | private final String right; 13 | private final String all; 14 | 15 | } 16 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/world/pool/PooledWorld.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.world.pool; 2 | 3 | import java.util.UUID; 4 | import lombok.AllArgsConstructor; 5 | import lombok.Data; 6 | import lombok.Setter; 7 | 8 | @Data 9 | @AllArgsConstructor 10 | public class PooledWorld { 11 | 12 | private final UUID worldId; 13 | private final String worldName; 14 | 15 | @Setter 16 | private PooledWorldState state; 17 | } -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/databases.yml: -------------------------------------------------------------------------------- 1 | default: mysql 2 | 3 | mysql: 4 | fallback: file 5 | 6 | host: localhost 7 | port: 3306 8 | database: cosmos 9 | username: root 10 | password: '' 11 | 12 | table: cosmos 13 | 14 | mongodb: 15 | fallback: mysql 16 | 17 | ip: localhost 18 | port: 27017 19 | auth-source: admin 20 | username: root 21 | password: '' 22 | 23 | database: cosmos 24 | collection: cosmos_templates -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/plugin.yml: -------------------------------------------------------------------------------- 1 | name: Cosmos 2 | version: '${version}' 3 | main: me.illusion.cosmos.CosmosBukkitPlugin 4 | api-version: 1.16 5 | 6 | softdepend: 7 | - WorldEdit 8 | - FastAsyncWorldEdit 9 | 10 | # postgres and mariadb too 11 | libraries: 12 | - org.mongodb:mongodb-driver-sync:4.9.0 13 | - com.influxdb:influxdb-client-java:6.5.0 14 | - org.postgresql:postgresql:42.6.0 15 | - org.mariadb.jdbc:mariadb-java-client:3.1.4 16 | 17 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/sql/SQLColumn.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.sql; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Represents a column in a SQL table. 7 | */ 8 | @Data 9 | public class SQLColumn { 10 | 11 | private final ColumnData data; 12 | private final SQLTable table; 13 | 14 | public SQLColumn(SQLTable table, ColumnData data) { 15 | this.table = table; 16 | this.data = data; 17 | } 18 | 19 | 20 | } 21 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/command/impl/ExecutionContext.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.command.impl; 2 | 3 | import me.illusion.cosmos.utilities.command.language.CompiledObjective; 4 | import me.illusion.cosmos.utilities.command.language.data.ObjectiveMetadata; 5 | 6 | public abstract class ExecutionContext extends CompiledObjective { // Just a friendly rename 7 | 8 | public ExecutionContext(ObjectiveMetadata metadata) { 9 | super(metadata); 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/metrics/database/MetricsDatabase.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.metrics.database; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.CompletableFuture; 5 | import me.illusion.cosmos.utilities.time.Time; 6 | import org.bukkit.configuration.ConfigurationSection; 7 | 8 | public interface MetricsDatabase { 9 | 10 | CompletableFuture enable(ConfigurationSection section); 11 | 12 | Time getUpdateInterval(); 13 | 14 | String getName(); 15 | 16 | CompletableFuture pushMetric(String metricId, Map data); 17 | } 18 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/template/data/TemplateData.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.template.data; 2 | 3 | import lombok.AllArgsConstructor; 4 | import lombok.Data; 5 | 6 | /** 7 | * This is a basic data class that represents the display data of a TemplatedArea. 8 | * This does not contain the actual data of the template, as that would be too RAM intensive. 9 | */ 10 | @Data 11 | @AllArgsConstructor 12 | public class TemplateData { 13 | 14 | private final String templateName; 15 | private final String serializerName; 16 | private final String containerName; 17 | 18 | } 19 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/unit/MinecraftTime.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.unit; 2 | 3 | public enum MinecraftTime { 4 | TICKS(1), 5 | SECONDS(20), 6 | MINUTES(1200), 7 | HOURS(72000), 8 | DAYS(1728000), 9 | WEEKS(12096000), 10 | MONTHS(51840000), 11 | YEARS(622080000); 12 | 13 | private final int multiplier; 14 | 15 | MinecraftTime(int multiplier) { 16 | this.multiplier = multiplier; 17 | } 18 | 19 | public long asTicks() { 20 | return multiplier; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/menu/template-create-confirmation.yml: -------------------------------------------------------------------------------- 1 | title: "Creating: %TEMPLATE_NAME%" 2 | layout: 3 | - '. . . . . . . . .' 4 | - '. . cancel . . . confirm . .' 5 | - '. . . . . . . . .' 6 | 7 | items: 8 | cancel: 9 | type: "RED_CONCRETE" 10 | name: "&cCancel Creation" 11 | confirm: 12 | type: "GREEN_CONCRETE" 13 | name: "&cConfirm Deletion" 14 | lore: 15 | - "" 16 | - " &7Name: &e%TEMPLATE_NAME%" 17 | - " &7Serializer: &b%TEMPLATE_SERIALIZER%" 18 | - " &7Storing In: &a%TEMPLATE_CONTAINER%" 19 | - "" 20 | - "&eClick to Save!" 21 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/geometry/Pair.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.geometry; 2 | 3 | public class Pair { 4 | 5 | private final K key; 6 | private final V value; 7 | 8 | public Pair(K key, V value) { 9 | this.key = key; 10 | this.value = value; 11 | } 12 | 13 | public static Pair of(K key, V value) { 14 | return new Pair<>(key, value); 15 | } 16 | 17 | public K getKey() { 18 | return this.key; 19 | } 20 | 21 | public V getValue() { 22 | return this.value; 23 | } 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/concurrency/FutureUtils.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.concurrency; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | 5 | public class FutureUtils { 6 | 7 | /** 8 | * Omit the type of future 9 | * 10 | * @param future the future 11 | * @param the type of the future 12 | * @return a future that completes when the given future completes 13 | */ 14 | public static CompletableFuture omitType(CompletableFuture future) { 15 | return future.thenAccept(t -> { 16 | }); 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/impl/FilteredParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type.impl; 2 | 3 | import java.util.List; 4 | import me.illusion.cosmos.utilities.command.language.type.ParameterType; 5 | import me.illusion.cosmos.utilities.text.Placeholder; 6 | import org.bukkit.entity.Player; 7 | import org.jetbrains.annotations.Nullable; 8 | 9 | public interface FilteredParameterType extends ParameterType { 10 | 11 | List getAllValues(); 12 | 13 | @Nullable 14 | List> createPlaceholders(Object value); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/impl/StringParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type.impl; 2 | 3 | import me.illusion.cosmos.utilities.command.language.type.ParameterType; 4 | 5 | 6 | public class StringParameterType implements ParameterType { 7 | 8 | @Override 9 | public boolean isType(String input) { 10 | return true; 11 | } 12 | 13 | @Override 14 | public String parse(String input) { 15 | return input; 16 | } 17 | 18 | @Override 19 | public String getDefaultValue() { 20 | return ""; 21 | } 22 | } 23 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/menu/template-delete-confirmation.yml: -------------------------------------------------------------------------------- 1 | title: "Template Deletion" 2 | layout: 3 | - '. . . . . . . . .' 4 | - '. . cancel . . . confirm . .' 5 | - '. . . . . . . . .' 6 | 7 | items: 8 | cancel: 9 | type: "RED_CONCRETE" 10 | name: "&cReturn to Template View" 11 | confirm: 12 | type: "TNT" 13 | name: "&cConfirm Deletion" 14 | lore: 15 | - " " 16 | - " &7Template: &e%TEMPLATE_NAME%" 17 | - " &7Serializer: &b%TEMPLATE_SERIALIZER%" 18 | - " &7Container: &a%TEMPLATE_CONTAINER%" 19 | - " " 20 | - "&c&lTHIS ACTION IS PERMANENT!" 21 | - '' 22 | - "&cClick to Delete!" 23 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/element/Renderable.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.element; 2 | 3 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 4 | 5 | public abstract class Renderable { 6 | 7 | protected BaseMenu menu; 8 | private boolean active = true; 9 | 10 | public Renderable(BaseMenu menu) { 11 | this.menu = menu; 12 | } 13 | 14 | public boolean isActive() { 15 | return active; 16 | } 17 | 18 | public void setActive(boolean active) { 19 | this.active = active; 20 | forceUpdate(); 21 | } 22 | 23 | public abstract void forceUpdate(); 24 | 25 | } 26 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/listener/CosmosUnloadAreaListener.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.listener; 2 | 3 | import me.illusion.cosmos.CosmosPlugin; 4 | import me.illusion.cosmos.event.area.CosmosUnloadAreaEvent; 5 | import org.bukkit.event.EventHandler; 6 | import org.bukkit.event.Listener; 7 | 8 | public class CosmosUnloadAreaListener implements Listener { 9 | 10 | private final CosmosPlugin plugin; 11 | 12 | public CosmosUnloadAreaListener(CosmosPlugin plugin) { 13 | this.plugin = plugin; 14 | } 15 | 16 | @EventHandler 17 | private void onUnload(CosmosUnloadAreaEvent event) { 18 | plugin.getGridRegistry().handleUnload(event.getPastedArea()); 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/impl/IntegerParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type.impl; 2 | 3 | import me.illusion.cosmos.utilities.command.language.type.ParameterType; 4 | 5 | 6 | public class IntegerParameterType implements ParameterType { 7 | 8 | @Override 9 | public boolean isType(String input) { 10 | try { 11 | Integer.parseInt(input); 12 | return true; 13 | } catch (NumberFormatException e) { 14 | return false; 15 | } 16 | } 17 | 18 | @Override 19 | public Integer parse(String input) { 20 | return Integer.parseInt(input); 21 | } 22 | 23 | @Override 24 | public Integer getDefaultValue() { 25 | return 1; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/impl/NumericalParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type.impl; 2 | 3 | import me.illusion.cosmos.utilities.command.language.type.ParameterType; 4 | 5 | 6 | public class NumericalParameterType implements ParameterType { 7 | 8 | @Override 9 | public boolean isType(String input) { 10 | try { 11 | Double.parseDouble(input); 12 | return true; 13 | } catch (NumberFormatException e) { 14 | return false; 15 | } 16 | } 17 | 18 | @Override 19 | public Double parse(String input) { 20 | return Double.parseDouble(input); 21 | } 22 | 23 | @Override 24 | public Double getDefaultValue() { 25 | return 0d; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/area/CosmosPasteAreaEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event.area; 2 | 3 | import lombok.Getter; 4 | import me.illusion.cosmos.event.base.CosmosEvent; 5 | import me.illusion.cosmos.template.PastedArea; 6 | import org.bukkit.event.HandlerList; 7 | 8 | 9 | @Getter 10 | public class CosmosPasteAreaEvent extends CosmosEvent { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final PastedArea pastedArea; 15 | 16 | public CosmosPasteAreaEvent(PastedArea pastedArea) { 17 | this.pastedArea = pastedArea; 18 | } 19 | 20 | public static HandlerList getHandlerList() { 21 | return HANDLER_LIST; 22 | } 23 | 24 | @Override 25 | public HandlerList getHandlers() { 26 | return HANDLER_LIST; 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/area/CosmosUnloadAreaEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event.area; 2 | 3 | import lombok.Getter; 4 | import me.illusion.cosmos.event.base.CosmosEvent; 5 | import me.illusion.cosmos.template.PastedArea; 6 | import org.bukkit.event.HandlerList; 7 | 8 | @Getter 9 | public class CosmosUnloadAreaEvent extends CosmosEvent { 10 | 11 | private static final HandlerList HANDLER_LIST = new HandlerList(); 12 | 13 | private final PastedArea pastedArea; 14 | 15 | public CosmosUnloadAreaEvent(PastedArea pastedArea) { 16 | this.pastedArea = pastedArea; 17 | } 18 | 19 | public static HandlerList getHandlerList() { 20 | return HANDLER_LIST; 21 | } 22 | 23 | @Override 24 | public HandlerList getHandlers() { 25 | return HANDLER_LIST; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/element/MenuElement.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.element; 2 | 3 | import java.util.Collection; 4 | import java.util.Collections; 5 | import me.illusion.cosmos.utilities.text.Placeholder; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.inventory.InventoryClickEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public interface MenuElement { 11 | 12 | ItemStack getDisplayItem(); 13 | 14 | void handle(InventoryClickEvent event); 15 | 16 | MenuElement copy(); 17 | 18 | default Collection> getItemPlaceholders() { 19 | return Collections.emptyList(); 20 | } 21 | 22 | default MenuElement setItemPlaceholders(Collection> placeholders) { 23 | return this; 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/menu/sorting/SortingOption.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.menu.sorting; 2 | 3 | import java.util.Comparator; 4 | import me.illusion.cosmos.template.data.TemplateData; 5 | 6 | public enum SortingOption { 7 | TEMPLATE_NAME((one, two) -> one.getTemplateName().compareToIgnoreCase(two.getTemplateName())), 8 | SERIALIZER_NAME((one, two) -> one.getSerializerName().compareToIgnoreCase(two.getSerializerName())), 9 | CONTAINER_NAME((one, two) -> one.getContainerName().compareToIgnoreCase(two.getContainerName())); 10 | 11 | private final Comparator comparator; 12 | 13 | SortingOption(Comparator comparator) { 14 | this.comparator = comparator; 15 | } 16 | 17 | public Comparator getComparator() { 18 | return comparator; 19 | } 20 | } 21 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/Parameter.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type; 2 | 3 | public class Parameter { 4 | 5 | private final String name; 6 | private final ParameterType type; 7 | 8 | private final boolean optional; 9 | 10 | public Parameter(String name, ParameterType type, boolean optional) { 11 | this.name = name; 12 | this.type = type; 13 | this.optional = optional; 14 | } 15 | 16 | public String getName() { 17 | return name; 18 | } 19 | 20 | public ParameterType getType() { 21 | return type; 22 | } 23 | 24 | public boolean isOptional() { 25 | return optional; 26 | } 27 | 28 | public Type parse(String input) { 29 | return type.parse(input); 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/sql/connection/SQLConnectionProvider.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.sql.connection; 2 | 3 | import java.sql.Connection; 4 | import java.util.concurrent.CompletableFuture; 5 | import me.illusion.cosmos.utilities.sql.SQLTable; 6 | 7 | /** 8 | * Represents a connection provider for SQL. 9 | */ 10 | public interface SQLConnectionProvider { 11 | 12 | /** 13 | * Gets a connection to the database. If the connection is not valid, a new one will be created. 14 | * 15 | * @return a connection to the database 16 | */ 17 | CompletableFuture getConnection(); 18 | 19 | /** 20 | * Gets or creates a table in the database. 21 | * 22 | * @param name the name of the table 23 | * @return the table 24 | */ 25 | SQLTable getOrCreateTable(String name); 26 | 27 | 28 | } 29 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/session/CosmosCreateSessionEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event.session; 2 | 3 | import me.illusion.cosmos.event.base.CosmosEvent; 4 | import me.illusion.cosmos.session.CosmosSession; 5 | import org.bukkit.event.HandlerList; 6 | 7 | public class CosmosCreateSessionEvent extends CosmosEvent { 8 | 9 | private static final HandlerList HANDLER_LIST = new HandlerList(); 10 | 11 | private final CosmosSession session; 12 | 13 | public CosmosCreateSessionEvent(CosmosSession session) { 14 | this.session = session; 15 | } 16 | 17 | public static HandlerList getHandlerList() { 18 | return HANDLER_LIST; 19 | } 20 | 21 | @Override 22 | public HandlerList getHandlers() { 23 | return HANDLER_LIST; 24 | } 25 | 26 | public CosmosSession getSession() { 27 | return session; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/session/CosmosUnloadSessionEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event.session; 2 | 3 | import me.illusion.cosmos.event.base.CosmosEvent; 4 | import me.illusion.cosmos.session.CosmosSession; 5 | import org.bukkit.event.HandlerList; 6 | 7 | public class CosmosUnloadSessionEvent extends CosmosEvent { 8 | 9 | private static final HandlerList HANDLER_LIST = new HandlerList(); 10 | 11 | private final CosmosSession session; 12 | 13 | public CosmosUnloadSessionEvent(CosmosSession session) { 14 | this.session = session; 15 | } 16 | 17 | public static HandlerList getHandlerList() { 18 | return HANDLER_LIST; 19 | } 20 | 21 | @Override 22 | public HandlerList getHandlers() { 23 | return HANDLER_LIST; 24 | } 25 | 26 | public CosmosSession getSession() { 27 | return session; 28 | } 29 | } 30 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/CosmosDefaultContainerInitializedEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event; 2 | 3 | import lombok.Getter; 4 | import me.illusion.cosmos.database.CosmosDataContainer; 5 | import me.illusion.cosmos.event.base.CosmosEvent; 6 | import org.bukkit.event.HandlerList; 7 | 8 | @Getter 9 | public class CosmosDefaultContainerInitializedEvent extends CosmosEvent { 10 | 11 | private static final HandlerList HANDLER_LIST = new HandlerList(); 12 | 13 | private final CosmosDataContainer container; 14 | 15 | public CosmosDefaultContainerInitializedEvent(CosmosDataContainer container) { 16 | this.container = container; 17 | } 18 | 19 | public static HandlerList getHandlerList() { 20 | return HANDLER_LIST; 21 | } 22 | 23 | @Override 24 | public HandlerList getHandlers() { 25 | return HANDLER_LIST; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/sql/ColumnType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.sql; 2 | 3 | /** 4 | * Represents a column type in a SQL table. 5 | */ 6 | public enum ColumnType { 7 | VARCHAR, 8 | INT, 9 | DOUBLE, 10 | BOOLEAN, 11 | BLOB, 12 | TEXT, 13 | LONGTEXT, 14 | MEDIUMTEXT, 15 | TINYTEXT, 16 | LONG, 17 | MEDIUMINT, 18 | TINYINT, 19 | SMALLINT, 20 | FLOAT, 21 | DECIMAL, 22 | DATE, 23 | DATETIME, 24 | TIMESTAMP, 25 | TIME, 26 | YEAR, 27 | CHAR, 28 | ENUM, 29 | SET, 30 | BINARY, 31 | VARBINARY, 32 | TINYBLOB, 33 | MEDIUMBLOB, 34 | LONGBLOB, 35 | BIT, 36 | GEOMETRY, 37 | POINT, 38 | LINESTRING, 39 | POLYGON, 40 | MULTIPOINT, 41 | MULTILINESTRING, 42 | MULTIPOLYGON, 43 | GEOMETRYCOLLECTION, 44 | JSON, 45 | 46 | // postgres specific 47 | BYTEA 48 | } 49 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/menu/template-creation.yml: -------------------------------------------------------------------------------- 1 | title: "Template Creation" 2 | layout: 3 | - '. . . . a . . . .' 4 | - '. . . . . . . . .' 5 | - '. . . n . c . . .' 6 | - '# # # # # # # # #' 7 | - '# # # create # close # # #' 8 | 9 | items: 10 | create: 11 | type: "NETHER_STAR" 12 | name: "&eCreate a new template" 13 | close: 14 | type: "BARRIER" 15 | name: "&cClose" 16 | 17 | n: 18 | type: "BOOK" 19 | name: "&eName" 20 | lore: 21 | - "&7Change the name of the template" 22 | - " " 23 | - "&7Current name: &f%TEMPLATE_NAME%" 24 | 25 | c: 26 | type: "CHEST" 27 | name: "&eContainer" 28 | lore: 29 | - "&7Switch between available containers" 30 | - " " 31 | - "&7Current container: &f%TEMPLATE_CONTAINER%" 32 | a: 33 | type: "PAPER" 34 | name: "&a%TEMPLATE_NAME%" 35 | lore: 36 | - " &7Serializer: %TEMPLATE_SERIALIZER%" 37 | - " &7Container: %TEMPLATE_CONTAINER%" 38 | - " " 39 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/parser/argument/ParameterArgument.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.parser.argument; 2 | 3 | import java.util.List; 4 | import me.illusion.cosmos.utilities.command.language.parser.ArgumentType; 5 | import me.illusion.cosmos.utilities.command.language.type.ParameterType; 6 | 7 | public class ParameterArgument extends Argument { 8 | 9 | private final ParameterType type; 10 | 11 | public ParameterArgument(String name, ParameterType type, boolean optional, Object value) { 12 | super(name, value instanceof List ? ArgumentType.LIST : ArgumentType.PARAMETER, optional, value); 13 | this.type = type; 14 | } 15 | 16 | public ParameterType getType() { 17 | return type; 18 | } 19 | 20 | @Override 21 | public ParameterArgument clone() { 22 | return new ParameterArgument<>(getName(), type, isOptional(), getValue()); 23 | } 24 | } 25 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/ParameterTypes.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type; 2 | 3 | import me.illusion.cosmos.utilities.command.language.type.impl.IntegerParameterType; 4 | import me.illusion.cosmos.utilities.command.language.type.impl.NumericalParameterType; 5 | import me.illusion.cosmos.utilities.command.language.type.impl.StringParameterType; 6 | import me.illusion.cosmos.utilities.command.language.type.impl.filtered.TimeParameterType; 7 | import me.illusion.cosmos.utilities.command.language.unit.MinecraftTime; 8 | 9 | public class ParameterTypes { 10 | 11 | public static final ParameterType STRING = new StringParameterType(); 12 | public static final ParameterType INTEGER = new IntegerParameterType(); 13 | public static final ParameterType NUMERICAL = new NumericalParameterType(); 14 | public static final ParameterType MINECRAFT_TIME = new TimeParameterType(); 15 | 16 | } 17 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/command/CosmosTemplateViewMenuCommand.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.command; 2 | 3 | import me.illusion.cosmos.CosmosPlugin; 4 | import me.illusion.cosmos.menu.TemplateViewMenu; 5 | import me.illusion.cosmos.utilities.command.command.impl.AdvancedCommand; 6 | import me.illusion.cosmos.utilities.command.command.impl.ExecutionContext; 7 | import org.bukkit.command.CommandSender; 8 | import org.bukkit.entity.Player; 9 | 10 | public class CosmosTemplateViewMenuCommand extends AdvancedCommand { 11 | 12 | private final CosmosPlugin plugin; 13 | 14 | public CosmosTemplateViewMenuCommand(CosmosPlugin plugin) { 15 | super("cosmos templates view"); 16 | this.plugin = plugin; 17 | } 18 | 19 | @Override 20 | public void execute(CommandSender sender, ExecutionContext context) { 21 | if (!(sender instanceof Player player)) { 22 | return; 23 | } 24 | 25 | new TemplateViewMenu(plugin, player.getUniqueId()).open(); 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/time/Time.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.time; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | 5 | /** 6 | * Represents a time value. 7 | */ 8 | public class Time { 9 | 10 | private final int time; 11 | private final TimeUnit unit; 12 | 13 | public Time(int time, TimeUnit unit) { 14 | this.time = time; 15 | this.unit = unit; 16 | } 17 | 18 | /** 19 | * Converts the time to the specified unit. 20 | * 21 | * @param unit The unit to convert to 22 | * @return The converted time 23 | */ 24 | public long as(TimeUnit unit) { 25 | return unit.convert(time, this.unit); 26 | } 27 | 28 | /** 29 | * Converts the time to ticks. 30 | * 31 | * @return The converted time 32 | */ 33 | public long asTicks() { 34 | return as(TimeUnit.MILLISECONDS) / 50; 35 | } 36 | 37 | @Override 38 | public String toString() { 39 | return time + " " + unit.name().toLowerCase(); 40 | } 41 | } 42 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/world/VoidGenerator.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.world; 2 | 3 | import java.util.Random; 4 | import org.bukkit.generator.ChunkGenerator; 5 | import org.bukkit.generator.WorldInfo; 6 | 7 | /** 8 | * This class is responsible for generating a void world, which is used for pasting areas into. 9 | */ 10 | public class VoidGenerator extends ChunkGenerator { 11 | 12 | @Override 13 | public void generateSurface(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) { 14 | // Do nothing 15 | } 16 | 17 | @Override 18 | public void generateNoise(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) { 19 | 20 | } 21 | 22 | @Override 23 | public void generateBedrock(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) { 24 | 25 | } 26 | 27 | @Override 28 | public void generateCaves(WorldInfo worldInfo, Random random, int chunkX, int chunkZ, ChunkData chunkData) { 29 | 30 | } 31 | 32 | } 33 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/data/ObjectiveMetadata.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.data; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import lombok.Data; 6 | import me.illusion.cosmos.utilities.command.language.parser.argument.Argument; 7 | 8 | @Data 9 | public class ObjectiveMetadata { 10 | 11 | private final List> allArguments; 12 | private final List> arguments; 13 | private final String originalSyntax; 14 | 15 | public ObjectiveMetadata(List> allArguments, List> arguments, String originalSyntax) { 16 | this.allArguments = new ArrayList<>(); 17 | this.arguments = new ArrayList<>(); 18 | this.originalSyntax = originalSyntax; 19 | 20 | for (Argument argument : allArguments) { 21 | this.allArguments.add(argument.clone()); 22 | } 23 | 24 | for (Argument argument : arguments) { 25 | this.arguments.add(argument.clone()); 26 | } 27 | } 28 | } 29 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/registry/communication/UpdatableMenu.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.registry.communication; 2 | 3 | import me.illusion.cosmos.utilities.concurrency.MainThreadExecutor; 4 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.entity.Player; 7 | 8 | public interface UpdatableMenu { 9 | 10 | Player getViewer(); 11 | 12 | void refresh(); 13 | 14 | BaseMenu getMenu(); 15 | 16 | default void close() { 17 | Player viewer = getViewer(); 18 | 19 | if (viewer.getOpenInventory().getTopInventory().equals(getMenu().getInventory())) { 20 | if (Bukkit.isPrimaryThread()) { 21 | viewer.closeInventory(); 22 | } else { 23 | MainThreadExecutor.INSTANCE.execute(viewer::closeInventory); // fuck you bukkit 24 | } 25 | } 26 | } 27 | 28 | String getIdentifier(); // return menu.getOriginalName() ? 29 | 30 | default void open() { 31 | getMenu().open(); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/menu/template-editor.yml: -------------------------------------------------------------------------------- 1 | title: "Template Editor" 2 | layout: 3 | - '. . . . . . . . .' 4 | - '. . view-templates . . . create-template . .' 5 | - '. . . . . . . . .' 6 | - '. . . . close . . . .' 7 | 8 | items: 9 | view-templates: 10 | type: COMPASS 11 | name: '&eView Templates' 12 | lore: 13 | - '&8Currently Storing %NUMBER_OF_TEMPLATES% Templates' 14 | - '' 15 | - '&eClick to view all templates' 16 | # importTemplate: 17 | # type: CLOCK 18 | # name: '&eImport Templates' 19 | # lore: 20 | # - '&8Currently Storing %NUMBER_OF_TEMPLATES% Templates' 21 | # - '' 22 | # - '' 23 | # - '' 24 | # - '&eClick to import a template' 25 | create-template: 26 | type: PAPER 27 | name: '&eCreate Template' 28 | lore: 29 | - ' &8Currently Selected %BLOCKS_IN_REGION% Blocks' # <- this line hidden if no region selected 30 | - '' 31 | - '%TEMPLATE_CLICK_PROMPT%' #&eClick to Create a Template / &cMake a Worldedit Selection First! 32 | close: 33 | type: BARRIER 34 | name: "&cClose" 35 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/RectangularSelection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import lombok.Getter; 6 | import me.illusion.cosmos.utilities.menu.math.Point; 7 | 8 | @Getter 9 | public class RectangularSelection implements Selection { 10 | 11 | private final Point firstPoint; 12 | private final Point secondPoint; 13 | 14 | public RectangularSelection(Point firstPoint, Point secondPoint) { 15 | this.firstPoint = firstPoint; 16 | this.secondPoint = secondPoint; 17 | } 18 | 19 | @Override 20 | public List getSlots() { 21 | List slots = new ArrayList<>(); 22 | 23 | for (int x = firstPoint.getX(); x <= secondPoint.getX(); x++) { 24 | for (int y = firstPoint.getY(); y <= secondPoint.getY(); y++) { 25 | slots.add(getSlot(x, y)); 26 | } 27 | } 28 | 29 | return slots; 30 | } 31 | 32 | private int getSlot(int x, int y) { 33 | return y * 9 + x; 34 | } 35 | 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/session/CosmosSessionHolderRegistry.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.session; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import java.util.Map; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | /** 8 | * A simple session holder registry implementation, that uses a String identifier to store and retrieve session holders. This class is thread-safe. There is no 9 | * strict requirement to use this class, but any metric about sessions will fail to report without it. 10 | * 11 | * @author Illusion 12 | */ 13 | public class CosmosSessionHolderRegistry { 14 | 15 | private final Map sessionHolders = new ConcurrentHashMap<>(); 16 | 17 | public CosmosSessionHolder getHolder(String name) { 18 | return sessionHolders.get(name); 19 | } 20 | 21 | public void registerHolder(String identifier, CosmosSessionHolder holder) { 22 | sessionHolders.put(identifier, holder); 23 | } 24 | 25 | public ImmutableMap getHolders() { 26 | return ImmutableMap.copyOf(sessionHolders); 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/SlotSelection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | public class SlotSelection implements Selection { 7 | 8 | private final List slots; 9 | 10 | public SlotSelection(int slot) { 11 | this.slots = List.of(slot); 12 | } 13 | 14 | public SlotSelection(List slots) { 15 | this.slots = slots; 16 | } 17 | 18 | public SlotSelection(int... slots) { 19 | this.slots = new ArrayList<>(); 20 | 21 | for (int slot : slots) { 22 | this.slots.add(slot); 23 | } 24 | } 25 | 26 | public static SlotSelection of(int slot) { 27 | return new SlotSelection(slot); 28 | } 29 | 30 | public static SlotSelection of(List slots) { 31 | return new SlotSelection(slots); 32 | } 33 | 34 | public static SlotSelection of(int... slots) { 35 | return new SlotSelection(slots); 36 | } 37 | 38 | 39 | @Override 40 | public List getSlots() { 41 | return slots; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/button/RemovableItem.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.button; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Consumer; 5 | import me.illusion.cosmos.utilities.text.Placeholder; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.inventory.InventoryClickEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public class RemovableItem extends Button { 11 | 12 | public RemovableItem(ItemStack displayItem, 13 | Consumer clickTask, 14 | Consumer rightClickTask, 15 | Consumer leftClickTask, 16 | Collection> placeholders) { 17 | super(displayItem, clickTask, rightClickTask, leftClickTask, placeholders); 18 | } 19 | 20 | public RemovableItem(ItemStack displayItem) { 21 | super(displayItem); 22 | } 23 | 24 | public RemovableItem(ItemStack displayItem, 25 | Consumer clickTask) { 26 | super(displayItem, clickTask); 27 | } 28 | 29 | @Override 30 | public void handle(InventoryClickEvent event) { 31 | event.setCancelled(false); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/button/DecorationItem.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.button; 2 | 3 | import java.util.Collection; 4 | import java.util.function.Consumer; 5 | import me.illusion.cosmos.utilities.text.Placeholder; 6 | import org.bukkit.entity.Player; 7 | import org.bukkit.event.inventory.InventoryClickEvent; 8 | import org.bukkit.inventory.ItemStack; 9 | 10 | public class DecorationItem extends Button { 11 | 12 | public DecorationItem(ItemStack displayItem, 13 | Consumer clickTask, 14 | Consumer rightClickTask, 15 | Consumer leftClickTask, 16 | Collection> placeholders) { 17 | super(displayItem, clickTask, rightClickTask, leftClickTask, placeholders); 18 | } 19 | 20 | public DecorationItem(ItemStack displayItem) { 21 | super(displayItem); 22 | } 23 | 24 | public DecorationItem(ItemStack displayItem, 25 | Consumer clickTask) { 26 | super(displayItem, clickTask); 27 | } 28 | 29 | @Override 30 | public void handle(InventoryClickEvent event) { 31 | event.setCancelled(true); 32 | } 33 | } 34 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/MultiSelection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashSet; 5 | import java.util.List; 6 | 7 | public class MultiSelection implements Selection { 8 | 9 | private final List selections; 10 | 11 | public MultiSelection(List selections) { 12 | this.selections = selections; 13 | } 14 | 15 | public MultiSelection(Selection... selections) { 16 | this.selections = List.of(selections); 17 | } 18 | 19 | public static MultiSelection of(List selections) { 20 | return new MultiSelection(selections); 21 | } 22 | 23 | public static MultiSelection of(Selection... selections) { 24 | return new MultiSelection(selections); 25 | } 26 | 27 | @Override 28 | public List getSlots() { 29 | List slots = new ArrayList<>(); 30 | 31 | for (Selection selection : selections) { 32 | slots.addAll(selection.getSlots()); 33 | } 34 | 35 | // Remove duplicates 36 | slots = new ArrayList<>(new HashSet<>(slots)); 37 | 38 | return slots; 39 | } 40 | } 41 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/event/CosmosTemplateMigrateEvent.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.event; 2 | 3 | import lombok.Getter; 4 | import me.illusion.cosmos.database.CosmosDataContainer; 5 | import me.illusion.cosmos.event.base.CosmosEvent; 6 | import me.illusion.cosmos.template.TemplatedArea; 7 | import org.bukkit.event.HandlerList; 8 | 9 | @Getter 10 | public class CosmosTemplateMigrateEvent extends CosmosEvent { 11 | 12 | private static final HandlerList HANDLER_LIST = new HandlerList(); 13 | 14 | private final CosmosDataContainer sourceContainer; 15 | private final CosmosDataContainer targetContainer; 16 | private final TemplatedArea template; 17 | private final String templateId; 18 | 19 | public CosmosTemplateMigrateEvent(CosmosDataContainer sourceContainer, CosmosDataContainer targetContainer, TemplatedArea template, String templateId) { 20 | this.sourceContainer = sourceContainer; 21 | this.targetContainer = targetContainer; 22 | this.template = template; 23 | this.templateId = templateId; 24 | } 25 | 26 | public static HandlerList getHandlerList() { return HANDLER_LIST; } 27 | @Override 28 | public HandlerList getHandlers() { return HANDLER_LIST; } 29 | } 30 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/registry/meta/HiddenMenuData.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.registry.meta; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import lombok.Getter; 8 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 9 | 10 | @Getter 11 | public class HiddenMenuData { 12 | 13 | private final BaseMenu menu; 14 | private final Map meta = new HashMap<>(); 15 | 16 | private final List displayTasks = new ArrayList<>(); 17 | 18 | public HiddenMenuData(BaseMenu menu) { 19 | this.menu = menu; 20 | } 21 | 22 | public void addDisplayTask(Runnable task) { 23 | displayTasks.add(task); 24 | } 25 | 26 | public void runDisplayTasks() { 27 | displayTasks.forEach(Runnable::run); 28 | } 29 | 30 | public T getMeta(String key, Class type) { 31 | Object object = meta.get(key); 32 | 33 | if (object == null) { 34 | return null; 35 | } 36 | 37 | return type.cast(object); 38 | } 39 | 40 | public void addMeta(String key, Object value) { 41 | meta.put(key, value); 42 | } 43 | 44 | } 45 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/file/CosmosDatabasesFile.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.file; 2 | 3 | import me.illusion.cosmos.utilities.storage.YMLBase; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | import org.bukkit.plugin.java.JavaPlugin; 6 | 7 | /** 8 | * The databases.yml file contains login information for the databases that the templates will be stored in. 9 | */ 10 | public class CosmosDatabasesFile extends YMLBase { 11 | 12 | public CosmosDatabasesFile(JavaPlugin plugin) { 13 | super(plugin, "databases.yml"); 14 | } 15 | 16 | /** 17 | * Returns the configuration section for the specified database. 18 | * 19 | * @param name the name of the database. 20 | * @return the configuration section for the specified database. 21 | */ 22 | public ConfigurationSection getDatabase(String name) { 23 | return getConfiguration().getConfigurationSection(name); 24 | } 25 | 26 | /** 27 | * Obtains the default database specified in the databases.yml file. 28 | * 29 | * @return the default database specified in the databases.yml file. 30 | */ 31 | public String getDefault() { 32 | return getConfiguration().getString("default"); 33 | } 34 | } 35 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/metrics/impl/LoadedSessionsMetric.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.metrics.impl; 2 | 3 | import com.google.common.collect.ImmutableMap; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import me.illusion.cosmos.CosmosPlugin; 7 | import me.illusion.cosmos.metrics.CosmosMetric; 8 | import me.illusion.cosmos.session.CosmosSessionHolder; 9 | 10 | public class LoadedSessionsMetric implements CosmosMetric { 11 | 12 | private final CosmosPlugin plugin; 13 | 14 | public LoadedSessionsMetric(CosmosPlugin plugin) { 15 | this.plugin = plugin; 16 | } 17 | 18 | @Override 19 | public String getName() { 20 | return "loaded_sessions"; 21 | } 22 | 23 | @Override 24 | public Map fetchMetrics() { 25 | ImmutableMap holders = plugin.getSessionHolderRegistry().getHolders(); 26 | 27 | Map metrics = new HashMap<>(); 28 | 29 | for (Map.Entry entry : holders.entrySet()) { 30 | String name = entry.getKey(); 31 | CosmosSessionHolder holder = entry.getValue(); 32 | 33 | metrics.put(name, holder.getSessionCount()); 34 | } 35 | 36 | return metrics; 37 | } 38 | } 39 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/menu/template-view.yml: -------------------------------------------------------------------------------- 1 | title: "Viewing Templates" 2 | layout: 3 | - '. . . . . . . . .' 4 | - '. . . . . . . . .' 5 | - '. . . . . . . . .' 6 | - '. . . . . . . . .' 7 | - '# # # # # # # # #' 8 | - 'left # # create close sort # # right' 9 | 10 | sorting-placeholders: 11 | active: "&f->" 12 | inactive: "&7" 13 | 14 | items: 15 | create: 16 | type: "NETHER_STAR" 17 | name: "&eCreate a new template" 18 | left: 19 | type: "ARROW" 20 | name: "&ePrevious Page" 21 | right: 22 | type: "ARROW" 23 | name: "&eNext Page" 24 | close: 25 | type: "BARRIER" 26 | name: "&cClose" 27 | 28 | sort: 29 | type: "HOPPER" 30 | name: "&aView Templates By:" 31 | lore: 32 | - "&8Sorting %NUMBER_OF_TEMPLATES% templates!" 33 | - "" 34 | - "&7Sorting by: %SORTING_STATE%" 35 | - "" 36 | - "&eClick to sort!" 37 | active-item: 38 | type: "PAPER" 39 | name: "&a%TEMPLATE_NAME%" 40 | lore: 41 | # - "&8%CREATION_DATE%" 42 | #- "" 43 | #- " &7Owned By: %TEMPLATE_PLAYER%" 44 | - "" 45 | - " &7Serializer: %TEMPLATE_SERIALIZER%" 46 | - " &7Container: %TEMPLATE_CONTAINER%" 47 | - " " 48 | - "&eLeft Click to paste at your location!" 49 | - "&eRight Click to delete!" 50 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/sql/ColumnData.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.sql; 2 | 3 | import lombok.Data; 4 | 5 | /** 6 | * Represents a column in a SQL table. 7 | */ 8 | @Data 9 | public class ColumnData { 10 | 11 | private final String name; // the name of the column 12 | private final ColumnType type; // the type of the column 13 | 14 | private boolean primary; // if the column is a primary key 15 | private Object data; // the length of a varchar, or the precision of a decimal, or just null 16 | 17 | public ColumnData(String name, ColumnType type) { 18 | this.name = name; 19 | this.type = type; 20 | } 21 | 22 | public ColumnData(String name, ColumnType type, Object data) { 23 | this.name = name; 24 | this.type = type; 25 | this.data = data; 26 | } 27 | 28 | public ColumnData(String name, ColumnType type, Object data, boolean primary) { 29 | this.name = name; 30 | this.type = type; 31 | this.data = data; 32 | this.primary = primary; 33 | } 34 | 35 | /** 36 | * Sets the data of the column. 37 | * 38 | * @param primary The data of the column 39 | */ 40 | public void setPrimary(boolean primary) { 41 | this.primary = primary; 42 | } 43 | } 44 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/concurrency/MainThreadExecutor.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.concurrency; 2 | 3 | import java.util.concurrent.CountDownLatch; 4 | import java.util.concurrent.Executor; 5 | import org.bukkit.Bukkit; 6 | import org.bukkit.plugin.java.JavaPlugin; 7 | 8 | public final class MainThreadExecutor implements Executor { 9 | 10 | public static final MainThreadExecutor INSTANCE = new MainThreadExecutor(); 11 | private static JavaPlugin plugin; 12 | 13 | 14 | private MainThreadExecutor() { 15 | } 16 | 17 | public static void init(JavaPlugin main) { 18 | MainThreadExecutor.plugin = main; 19 | } 20 | 21 | @Override 22 | public void execute(Runnable runnable) { 23 | if (Bukkit.isPrimaryThread()) { 24 | runnable.run(); 25 | return; 26 | } 27 | 28 | CountDownLatch latch = new CountDownLatch(1); 29 | Runnable task = () -> { 30 | runnable.run(); 31 | latch.countDown(); 32 | }; 33 | 34 | Bukkit.getScheduler().runTask(plugin, task); 35 | 36 | try { 37 | latch.await(); 38 | } catch (InterruptedException e) { 39 | e.printStackTrace(); // if this happens, something is very very very very wrong 40 | } 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/grid/CosmosGridRegistry.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.grid; 2 | 3 | import com.google.common.collect.Sets; 4 | import java.util.ArrayList; 5 | import java.util.List; 6 | import java.util.Set; 7 | import java.util.concurrent.CompletableFuture; 8 | import me.illusion.cosmos.CosmosPlugin; 9 | import me.illusion.cosmos.template.PastedArea; 10 | 11 | public class CosmosGridRegistry { 12 | 13 | private final Set grids = Sets.newConcurrentHashSet(); 14 | private final CosmosPlugin plugin; 15 | 16 | public CosmosGridRegistry(CosmosPlugin plugin) { 17 | this.plugin = plugin; 18 | } 19 | 20 | public void register(CosmosGrid grid) { 21 | grids.add(grid); 22 | grid.init(plugin); 23 | } 24 | 25 | public void unregister(CosmosGrid grid) { 26 | grids.remove(grid); 27 | } 28 | 29 | public CompletableFuture unloadAll() { 30 | List> futures = new ArrayList<>(); 31 | 32 | for (CosmosGrid grid : grids) { 33 | futures.add(grid.unloadAll()); 34 | } 35 | 36 | return CompletableFuture.allOf(futures.toArray(new CompletableFuture[0])); 37 | } 38 | 39 | public void handleUnload(PastedArea area) { 40 | for (CosmosGrid grid : grids) { 41 | grid.registerUnload(area); 42 | } 43 | } 44 | 45 | } 46 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/world/pool/WorldPoolSettings.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.world.pool; 2 | 3 | import java.util.concurrent.TimeUnit; 4 | import lombok.Builder; 5 | import lombok.Builder.Default; 6 | import lombok.Getter; 7 | import me.illusion.cosmos.utilities.time.Time; 8 | import me.illusion.cosmos.world.VoidGenerator; 9 | import org.bukkit.generator.ChunkGenerator; 10 | import org.bukkit.util.Vector; 11 | 12 | @Builder 13 | @Getter 14 | public class WorldPoolSettings { 15 | 16 | @Default 17 | private int maxCachedWorlds = 5; // We'll keep this many worlds in the UNUSED state before unloading them 18 | 19 | @Default 20 | private int maxUnloadedWorlds = 25; // We'll delete worlds after this 21 | 22 | @Default 23 | private int preGeneratedWorlds = 2; // We'll keep this many worlds in a pre-generated buffer state (So when a world is requested, we can give it to them immediately, and then generate a new one in the background) 24 | 25 | @Default 26 | private ChunkGenerator chunkGenerator = new VoidGenerator(); 27 | 28 | @Default 29 | private Vector spawnLocation = new Vector(0, 128, 0); 30 | 31 | @Default 32 | private int batchDelayTicks = 50; // When creating multiple worlds, we'll leave *this* many ticks between each world creation 33 | 34 | @Default 35 | private Time deletionDelay = new Time(1, TimeUnit.SECONDS); // We'll wait this long between unloading and deleting worlds 36 | 37 | } 38 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/template/TemplatedArea.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.template; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | import me.illusion.cosmos.serialization.CosmosSerializer; 5 | import me.illusion.cosmos.utilities.geometry.Cuboid; 6 | import org.bukkit.Location; 7 | 8 | /** 9 | * A templated area is a "blueprint" of a map, which can be pasted at any given location. To create a templated area, use a {@link CosmosSerializer}. 10 | *

11 | * 12 | * @author Illusion 13 | */ 14 | public interface TemplatedArea { 15 | 16 | /** 17 | * Pastes the area at the given location, and returns a CompletableFuture which will be completed when the paste is done. Depending on the serializer, the 18 | * future may be completed immediately, and the area will be pasted in the main thread (WorldEdit). 19 | * 20 | * @param location The location to paste the area at 21 | * @return A future of a Pasted Area, which can be used to get the location of the area, and to undo the paste. 22 | */ 23 | CompletableFuture paste(Location location); 24 | 25 | /** 26 | * Obtains the dimensions of the area. 27 | * 28 | * @return The dimensions of the area 29 | */ 30 | Cuboid getDimensions(); 31 | 32 | /** 33 | * Obtains the serializer used to create this area. 34 | * 35 | * @return The serializer used to create this area 36 | */ 37 | CosmosSerializer getSerializer(); 38 | 39 | } 40 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/command/CosmosTemplateCreateCommand.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.command; 2 | 3 | import me.illusion.cosmos.CosmosPlugin; 4 | import me.illusion.cosmos.database.CosmosDataContainer; 5 | import me.illusion.cosmos.menu.TemplateCreationMenu; 6 | import me.illusion.cosmos.menu.generic.GenericConfirmationMenu; 7 | import me.illusion.cosmos.utilities.command.command.impl.AdvancedCommand; 8 | import me.illusion.cosmos.utilities.command.command.impl.ExecutionContext; 9 | import me.illusion.cosmos.utilities.storage.MessagesFile; 10 | import me.illusion.cosmos.utilities.text.Placeholder; 11 | import org.bukkit.command.CommandSender; 12 | import org.bukkit.entity.Player; 13 | 14 | public class CosmosTemplateCreateCommand extends AdvancedCommand { 15 | private final CosmosPlugin plugin; 16 | private final MessagesFile messages; 17 | 18 | public CosmosTemplateCreateCommand(CosmosPlugin plugin) { 19 | super("cosmos templates create"); 20 | 21 | this.plugin = plugin; 22 | this.messages = plugin.getMessages(); 23 | } 24 | 25 | @Override 26 | public boolean canExecute(CommandSender sender) { 27 | return sender instanceof Player; 28 | } 29 | 30 | @Override 31 | public void execute(CommandSender sender, ExecutionContext context) { 32 | 33 | if (!(sender instanceof Player player)) { 34 | return; 35 | } 36 | 37 | new TemplateCreationMenu(plugin, player.getUniqueId()); 38 | } 39 | } 40 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/template/PastedArea.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.template; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | import me.illusion.cosmos.utilities.geometry.Cuboid; 5 | import org.bukkit.Location; 6 | 7 | /** 8 | * A pasted area is an instance of a {@link TemplatedArea}, which has been pasted at a given location. It can be used to unload the area, and to get the 9 | * location of the area. 10 | *

11 | * 12 | * @author Illusion 13 | */ 14 | public interface PastedArea extends TemplatedArea { 15 | 16 | /** 17 | * Unloads the area, and returns a future which will be completed when the area is unloaded. The future may be completed immediately, and the area will be 18 | * unloaded in the main thread (WorldEdit). 19 | * 20 | * @return A future which will be completed when the area is unloaded 21 | */ 22 | CompletableFuture unload(); 23 | 24 | /** 25 | * Obtains the location of where the area was pasted. 26 | * 27 | * @return The location of the area 28 | */ 29 | Location getPasteLocation(); 30 | 31 | /** 32 | * Checks if the area contains the specified location. 33 | * 34 | * @param location The location to check 35 | * @return Whether the area contains the location 36 | */ 37 | default boolean containsLocation(Location location) { 38 | Cuboid areaCuboid = new Cuboid(getDimensions(), location); 39 | return areaCuboid.contains(location); 40 | } 41 | 42 | } 43 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/base/ConfigurableMenu.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.base; 2 | 3 | import java.util.List; 4 | import java.util.UUID; 5 | import me.illusion.cosmos.utilities.menu.configuration.ConfigurationApplicator; 6 | import me.illusion.cosmos.utilities.menu.element.MenuElement; 7 | import me.illusion.cosmos.utilities.menu.mask.PatternMask; 8 | import org.bukkit.configuration.file.FileConfiguration; 9 | import org.bukkit.inventory.ItemStack; 10 | 11 | public class ConfigurableMenu extends BaseMenu { 12 | 13 | private final ConfigurationApplicator applicator; 14 | 15 | 16 | public ConfigurableMenu(UUID playerId, String title, int rows, ConfigurationApplicator applicator) { 17 | super(playerId, title, rows); 18 | this.applicator = applicator; 19 | } 20 | 21 | public ConfigurationApplicator getApplicator() { 22 | return applicator; 23 | } 24 | 25 | public ItemStack getItem(String key) { 26 | return getApplicator().getItem(key); 27 | } 28 | 29 | public MenuElement getDecorationItem(String key) { 30 | return getApplicator().getDecorationItem(key); 31 | } 32 | 33 | public PatternMask getMask() { 34 | return getApplicator().getMask(); 35 | } 36 | 37 | public List getDescription() { 38 | return getApplicator().getDescription(); 39 | } 40 | 41 | public FileConfiguration getConfig() { 42 | return getApplicator().getConfig(); 43 | } 44 | 45 | 46 | } 47 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/parser/argument/Argument.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.parser.argument; 2 | 3 | import me.illusion.cosmos.utilities.command.language.parser.ArgumentType; 4 | 5 | public class Argument { 6 | 7 | private final String name; 8 | private final ArgumentType type; 9 | private boolean optional; 10 | 11 | private Object value; 12 | 13 | public Argument(String name, ArgumentType type, boolean optional, Object value) { 14 | this.name = name; 15 | this.type = type; 16 | this.optional = optional; 17 | this.value = value; 18 | } 19 | 20 | public String getName() { 21 | return name; 22 | } 23 | 24 | public ArgumentType getArgumentType() { 25 | return type; 26 | } 27 | 28 | public boolean isOptional() { 29 | return optional; 30 | } 31 | 32 | public void setOptional(boolean optional) { 33 | this.optional = optional; 34 | } 35 | 36 | public Object getValue() { 37 | return value; 38 | } 39 | 40 | public void setValue(Object value) { 41 | this.value = value; 42 | } 43 | 44 | public Argument clone() { 45 | return new Argument<>(name, type, optional, value); 46 | } 47 | 48 | @Override 49 | public String toString() { 50 | return "Argument{" + 51 | "name='" + name + '\'' + 52 | ", type=" + type + 53 | ", optional=" + optional + 54 | ", value=" + value + 55 | '}'; 56 | } 57 | } 58 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/item/ItemConfigurationSerializer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.item; 2 | 3 | import java.util.List; 4 | import java.util.function.Consumer; 5 | import org.bukkit.configuration.ConfigurationSection; 6 | 7 | public class ItemConfigurationSerializer { 8 | 9 | public static void applySection(ItemBuilder builder, ConfigurationSection section) { 10 | applyIfPresent(section, "amount", Integer.class, builder::amount); 11 | applyIfPresent(section, "name", String.class, builder::name); 12 | applyIfPresent(section, "lore", List.class, builder::lore); 13 | applyIfPresent(section, "enchantments", ConfigurationSection.class, builder::enchants); 14 | applyIfPresent(section, "flags", List.class, builder::flags); 15 | applyIfPresent(section, "unbreakable", Boolean.class, builder::unbreakable); 16 | applyIfPresent(section, "skull-hash", String.class, builder::skullHash); 17 | applyIfPresent(section, "skull", String.class, builder::skull); 18 | applyIfPresent(section, "model-data", Integer.class, builder::modelData); 19 | applyIfPresent(section, "glow", Boolean.class, builder::glowing); 20 | } 21 | 22 | private static void applyIfPresent(ConfigurationSection section, String key, Class clazz, Consumer consumer) { 23 | if (section.contains(key)) { 24 | T value = section.getObject(key, clazz); 25 | 26 | if (value == null) { 27 | return; 28 | } 29 | 30 | consumer.accept(value); 31 | } 32 | } 33 | 34 | } 35 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/session/task/UnloadTask.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.session.task; 2 | 3 | import java.time.Instant; 4 | import org.bukkit.Bukkit; 5 | import org.bukkit.plugin.java.JavaPlugin; 6 | 7 | /** 8 | * A task that will unload a session after a specified amount of time. This task is self-correcting, 9 | * meaning that if the server is lagging, it will correct itself by using recursion. 10 | * 11 | * @author Illusion 12 | */ 13 | public class UnloadTask implements Runnable { 14 | 15 | private final JavaPlugin plugin; 16 | private final UnloadRequest request; 17 | 18 | public UnloadTask(JavaPlugin plugin, UnloadRequest request) { 19 | this.plugin = plugin; 20 | this.request = request; 21 | 22 | run(); 23 | } 24 | 25 | @Override 26 | public void run() { 27 | if(request.getFuture().isDone()) { 28 | // Already completed 29 | return; 30 | } 31 | 32 | // Self-correcting recursion 33 | long currentEpoch = Instant.now().getEpochSecond(); 34 | long delay = request.getEpoch() - currentEpoch; 35 | 36 | long delayTicks = delay * 20; 37 | 38 | if (delayTicks < 5) { 39 | request.complete(); 40 | } else { 41 | Bukkit.getScheduler().runTaskLater(plugin, this, delayTicks / 2); // Re-run the task in half the remaining time, so we can self-correct 42 | } 43 | } 44 | 45 | /** 46 | * Cancels the unload task. 47 | */ 48 | public void cancel() { 49 | if (!request.getFuture().isDone()) { 50 | request.cancel(); 51 | } 52 | } 53 | } 54 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/layer/BaseLayer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.layer; 2 | 3 | import java.util.Collection; 4 | import java.util.HashMap; 5 | import java.util.Map; 6 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 7 | import me.illusion.cosmos.utilities.menu.element.MenuElement; 8 | import me.illusion.cosmos.utilities.menu.element.Renderable; 9 | import me.illusion.cosmos.utilities.menu.selection.Selection; 10 | import me.illusion.cosmos.utilities.text.Placeholder; 11 | import org.bukkit.entity.Player; 12 | 13 | public class BaseLayer extends Renderable { 14 | 15 | private final Map slots = new HashMap<>(); 16 | 17 | public BaseLayer(BaseMenu menu) { 18 | super(menu); 19 | } 20 | 21 | @Override 22 | public void forceUpdate() { 23 | for (Map.Entry entry : slots.entrySet()) { 24 | menu.setElement(entry.getKey(), entry.getValue()); 25 | } 26 | } 27 | 28 | public void applySelection(Selection selection, MenuElement element) { 29 | for (int slot : selection.getSlots()) { 30 | slots.put(slot, element.copy()); 31 | } 32 | } 33 | 34 | public void applyRawSelection(Selection selection, MenuElement element) { 35 | for (int slot : selection.getSlots()) { 36 | slots.put(slot, element); 37 | } 38 | } 39 | 40 | public void setItemPlaceholders(Collection> placeholders) { 41 | for (MenuElement element : slots.values()) { 42 | element.setItemPlaceholders(placeholders); 43 | } 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/layer/PaginableLayer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.layer; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 6 | import me.illusion.cosmos.utilities.menu.element.Renderable; 7 | import me.illusion.cosmos.utilities.menu.pagination.PaginableArea; 8 | 9 | public class PaginableLayer extends Renderable { 10 | 11 | private final List areas = new ArrayList<>(); 12 | private int page = 1; 13 | 14 | public PaginableLayer(BaseMenu menu) { 15 | super(menu); 16 | } 17 | 18 | @Override 19 | public void forceUpdate() { 20 | for (PaginableArea area : areas) { 21 | area.forceUpdate(menu, page); 22 | } 23 | } 24 | 25 | public void addArea(PaginableArea... area) { 26 | areas.addAll(List.of(area)); 27 | } 28 | 29 | public int getPage() { 30 | return page; 31 | } 32 | 33 | public void nextPage() { 34 | if (page >= getMaxPage()) { 35 | return; 36 | } 37 | 38 | page++; 39 | menu.forceUpdate(); 40 | } 41 | 42 | public void previousPage() { 43 | if (page == 1) { 44 | return; 45 | } 46 | page--; 47 | menu.forceUpdate(); 48 | } 49 | 50 | public int getMaxPage() { 51 | int max = 0; 52 | for (PaginableArea area : areas) { 53 | int areaMax = area.getPageCount(); 54 | if (areaMax > max) { 55 | max = areaMax; 56 | } 57 | } 58 | return max; 59 | } 60 | 61 | } 62 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/registry/meta/HiddenMenuTracker.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.registry.meta; 2 | 3 | import java.util.Map; 4 | import java.util.UUID; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | import java.util.function.Consumer; 7 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 8 | import org.bukkit.entity.Player; 9 | 10 | public class HiddenMenuTracker { 11 | 12 | private final Map hiddenMenus = new ConcurrentHashMap<>(); 13 | 14 | public void addHiddenMenu(UUID uuid, HiddenMenuData data) { 15 | hiddenMenus.put(uuid, data); 16 | } 17 | 18 | public HiddenMenuData getHiddenMenu(UUID uuid) { 19 | return hiddenMenus.get(uuid); 20 | } 21 | 22 | public void removeHiddenMenu(UUID uuid) { 23 | hiddenMenus.remove(uuid); 24 | } 25 | 26 | public boolean hasHiddenMenu(UUID uuid) { 27 | return hiddenMenus.containsKey(uuid); 28 | } 29 | 30 | public void clear() { 31 | hiddenMenus.clear(); 32 | } 33 | 34 | public void holdForInput(BaseMenu menu, Consumer action, boolean reopenMenu) { 35 | Player player = menu.getPlayer(); 36 | 37 | HiddenMenuData data = new HiddenMenuData(menu); 38 | data.addMeta("input-task", action); 39 | 40 | if (reopenMenu) { 41 | data.addDisplayTask(menu::open); 42 | } 43 | 44 | addHiddenMenu(player.getUniqueId(), data); 45 | 46 | player.closeInventory(); 47 | } 48 | 49 | public void holdForInput(BaseMenu menu, Consumer action) { 50 | holdForInput(menu, action, true); 51 | } 52 | 53 | } 54 | -------------------------------------------------------------------------------- /CosmosExamplePlugin/src/main/java/me/illusion/example/cosmosexampleplugin/listener/TemplateCacheListener.java: -------------------------------------------------------------------------------- 1 | package me.illusion.example.cosmosexampleplugin.listener; 2 | 3 | import me.illusion.cosmos.database.CosmosDataContainer; 4 | import me.illusion.cosmos.event.CosmosTemplateMigrateEvent; 5 | import me.illusion.cosmos.template.TemplatedArea; 6 | import me.illusion.example.cosmosexampleplugin.CosmosExamplePlugin; 7 | import org.bukkit.event.EventHandler; 8 | import org.bukkit.event.Listener; 9 | 10 | public class TemplateCacheListener implements Listener { 11 | 12 | private final CosmosExamplePlugin plugin; 13 | 14 | public TemplateCacheListener(CosmosExamplePlugin plugin) { 15 | this.plugin = plugin; 16 | } 17 | 18 | @EventHandler 19 | private void onMigrate(CosmosTemplateMigrateEvent event) { 20 | String templateId = event.getTemplateId(); 21 | TemplatedArea template = event.getTemplate(); 22 | 23 | CosmosDataContainer targetContainer = event.getTargetContainer(); 24 | String targetContainerName = targetContainer.getName(); 25 | 26 | if (!plugin.getCosmosPlugin().getContainerRegistry().getDefaultContainer().getName().equalsIgnoreCase(targetContainerName)) { 27 | return; // We want to see if the target container is the default container 28 | } 29 | 30 | if (!templateId.equalsIgnoreCase("skyblock")) { 31 | return; // We want to see if the template is the skyblock template 32 | } 33 | 34 | plugin.getCosmosPlugin().getTemplateCache() 35 | .register(templateId, template); // Register the template to the cache, that way we don't need to restart the server 36 | } 37 | 38 | } 39 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/file/CosmosMetricsFile.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.file; 2 | 3 | import me.illusion.cosmos.utilities.storage.YMLBase; 4 | import org.bukkit.configuration.ConfigurationSection; 5 | import org.bukkit.plugin.java.JavaPlugin; 6 | 7 | /** 8 | * The metrics.yml file contains login information for the metrics system. The metrics system does not actually report to bstats or any similar thing, but 9 | * instead pushes data to a database specified by the end-user, allowing them to view their own metrics internally through a visualizer like Grafana. 10 | */ 11 | public class CosmosMetricsFile extends YMLBase { 12 | 13 | public CosmosMetricsFile(JavaPlugin plugin) { 14 | super(plugin, "metrics.yml"); 15 | } 16 | 17 | /** 18 | * Returns whether the metrics system is enabled. 19 | * 20 | * @return whether the metrics system is enabled. 21 | */ 22 | public boolean isEnabled() { 23 | return getConfiguration().getBoolean("enabled"); 24 | } 25 | 26 | /** 27 | * Returns the default database type specified in the metrics.yml file. 28 | * 29 | * @return the default database type specified in the metrics.yml file. 30 | */ 31 | public String getDefaultType() { 32 | return getConfiguration().getString("default-type"); 33 | } 34 | 35 | /** 36 | * Returns the configuration section for the specified database type. 37 | * 38 | * @param name the name of the database type. 39 | * @return the configuration section for the specified database type. 40 | */ 41 | public ConfigurationSection getDatabaseSection(String name) { 42 | return getConfiguration().getConfigurationSection(name); 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /CosmosExamplePlugin/build.gradle: -------------------------------------------------------------------------------- 1 | plugins { 2 | id 'java' 3 | } 4 | 5 | group = 'me.illusion' 6 | version = '1.0-SNAPSHOT' 7 | 8 | repositories { 9 | mavenCentral() 10 | mavenLocal() 11 | maven { 12 | name = 'spigotmc-repo' 13 | url = 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' 14 | } 15 | maven { 16 | name = 'sonatype' 17 | url = 'https://oss.sonatype.org/content/groups/public/' 18 | } 19 | 20 | // worldedit 21 | maven { 22 | name = 'worldedit-repo' 23 | url = 'https://maven.enginehub.org/repo/' 24 | } 25 | 26 | } 27 | 28 | dependencies { 29 | implementation project(':Cosmos-Plugin') 30 | 31 | compileOnly 'org.spigotmc:spigot-api:1.19.3-R0.1-SNAPSHOT' 32 | 33 | implementation('org.projectlombok:lombok:1.18.26') 34 | annotationProcessor('org.projectlombok:lombok:1.18.26') 35 | 36 | // worldedit 37 | implementation('com.sk89q.worldedit:worldedit-bukkit:7.3.0-SNAPSHOT') 38 | } 39 | 40 | def targetJavaVersion = 17 41 | java { 42 | def javaVersion = JavaVersion.toVersion(targetJavaVersion) 43 | sourceCompatibility = javaVersion 44 | targetCompatibility = javaVersion 45 | if (JavaVersion.current() < javaVersion) { 46 | toolchain.languageVersion = JavaLanguageVersion.of(targetJavaVersion) 47 | } 48 | } 49 | 50 | tasks.withType(JavaCompile).configureEach { 51 | if (targetJavaVersion >= 10 || JavaVersion.current().isJava10Compatible()) { 52 | options.release = targetJavaVersion 53 | } 54 | } 55 | 56 | processResources { 57 | def props = [version: version] 58 | inputs.properties props 59 | filteringCharset 'UTF-8' 60 | filesMatching('plugin.yml') { 61 | expand props 62 | } 63 | } 64 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/PatternMaskSelection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import lombok.Builder; 6 | import me.illusion.cosmos.utilities.menu.mask.PatternMask; 7 | 8 | @Builder 9 | public class PatternMaskSelection implements Selection { 10 | 11 | private final PatternMask pattern; 12 | private final String mask; 13 | 14 | public PatternMaskSelection(PatternMask mask, String selection) { 15 | this.pattern = mask; 16 | this.mask = selection; 17 | } 18 | 19 | public static PatternMaskSelection of(PatternMask mask, String selection) { 20 | return new PatternMaskSelection(mask, selection); 21 | } 22 | 23 | @Override 24 | public List getSlots() { 25 | List slots = new ArrayList<>(); 26 | 27 | for (int row = 0; row < pattern.getPattern().size(); row++) { 28 | String line = pattern.getPattern().get(row); 29 | 30 | if (line.length() == 9) { 31 | char character = mask.charAt(0); 32 | 33 | for (int index = 0; index < line.length(); index++) { 34 | if (line.charAt(index) == character) { 35 | slots.add(index + (row * 9)); 36 | } 37 | } 38 | } else { 39 | String[] split = line.split(" "); 40 | 41 | for (int index = 0; index < Math.min(split.length, 9); index++) { 42 | if (split[index].equals(mask)) { 43 | slots.add(index + (row * 9)); 44 | } 45 | } 46 | } 47 | } 48 | 49 | return slots; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/grid/CosmosGrid.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.grid; 2 | 3 | import java.util.concurrent.CompletableFuture; 4 | import me.illusion.cosmos.CosmosPlugin; 5 | import me.illusion.cosmos.template.PastedArea; 6 | import me.illusion.cosmos.template.TemplatedArea; 7 | 8 | /** 9 | * A grid is an object responsible for calculating the location of a pasted area. 10 | *

11 | * 12 | * @author Illusion 13 | */ 14 | public interface CosmosGrid { 15 | 16 | /** 17 | * Calculates the location of the area, and pastes it. 18 | * 19 | * @param area The area to paste 20 | * @return A future of a Pasted Area, which can be used to get the location of the area, and to undo the paste. 21 | */ 22 | CompletableFuture paste(TemplatedArea area); 23 | 24 | /** 25 | * Calculates the location of a future area, and eventually pastes it. 26 | * 27 | * @param areaFuture The future of the area to paste 28 | * @return A future of a Pasted Area, which can be used to get the location of the area, and to undo the paste. 29 | */ 30 | default CompletableFuture paste(CompletableFuture areaFuture) { 31 | return areaFuture.thenCompose(this::paste); 32 | } 33 | 34 | /** 35 | * Unloads all pasted areas. 36 | * 37 | * @return A future which will be completed when all areas are unloaded. 38 | */ 39 | CompletableFuture unloadAll(); 40 | 41 | /** 42 | * Called when an area is unloaded. There is no guarantee that the area was pasted by this grid. 43 | * 44 | * @param area The area which was unloaded 45 | */ 46 | void registerUnload(PastedArea area); 47 | 48 | /** 49 | * Called when the grid is registered. 50 | */ 51 | default void init(CosmosPlugin plugin) { 52 | 53 | } 54 | 55 | } 56 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/language/type/impl/filtered/TimeParameterType.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.language.type.impl.filtered; 2 | 3 | 4 | import java.util.List; 5 | import java.util.Locale; 6 | import me.illusion.cosmos.utilities.command.language.type.impl.FilteredParameterType; 7 | import me.illusion.cosmos.utilities.command.language.unit.MinecraftTime; 8 | import me.illusion.cosmos.utilities.text.Placeholder; 9 | import org.bukkit.entity.Player; 10 | import org.jetbrains.annotations.Nullable; 11 | 12 | public class TimeParameterType implements FilteredParameterType { 13 | 14 | @Override 15 | public boolean isType(String input) { 16 | try { 17 | MinecraftTime.valueOf(input.toUpperCase(Locale.ROOT)); 18 | return true; 19 | } catch (IllegalArgumentException e) { 20 | return false; 21 | } 22 | } 23 | 24 | @Override 25 | public MinecraftTime parse(String input) { 26 | return MinecraftTime.valueOf(input.toUpperCase(Locale.ROOT)); 27 | } 28 | 29 | @Override 30 | public MinecraftTime getDefaultValue() { 31 | return MinecraftTime.TICKS; 32 | } 33 | 34 | @Override 35 | public List getAllValues() { 36 | return List.of(MinecraftTime.values()); 37 | } 38 | 39 | @Override 40 | public @Nullable List> createPlaceholders(Object input) { 41 | if (!(isType(input.toString()))) { 42 | return null; 43 | } 44 | 45 | MinecraftTime value = parse(input.toString()); 46 | 47 | return List.of( 48 | new Placeholder("name", beautify(value.name())) 49 | ); 50 | } 51 | 52 | private String beautify(String input) { 53 | return input.substring(0, 1).toUpperCase(Locale.ROOT) + input.substring(1).toLowerCase(Locale.ROOT); 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/collection/ListUtils.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.collection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.Collections; 6 | import java.util.List; 7 | import java.util.Random; 8 | import java.util.concurrent.ThreadLocalRandom; 9 | 10 | public final class ListUtils { 11 | 12 | private ListUtils() { 13 | throw new IllegalStateException("Utility class"); 14 | } 15 | 16 | public static T getRandom(Collection set) { 17 | int size = set.size(); 18 | int index = ThreadLocalRandom.current().nextInt(size); 19 | int i = 0; 20 | 21 | for (T t : set) { 22 | if (i == index) { 23 | return t; 24 | } 25 | 26 | i++; 27 | } 28 | 29 | return null; 30 | } 31 | 32 | public static T getRandom(List list) { 33 | int size = list.size(); 34 | 35 | if (size == 0) { 36 | return null; 37 | } 38 | 39 | if (size == 1) { 40 | return list.get(0); 41 | } 42 | 43 | Random random = ThreadLocalRandom.current(); 44 | 45 | return list.get(random.nextInt(size)); 46 | } 47 | 48 | public static List randomize(List list) { 49 | Collections.shuffle(list); 50 | return list; 51 | } 52 | 53 | public static void insertInList(List list, int index, ListType value) { 54 | if (index >= list.size()) { 55 | list.add(value); 56 | return; 57 | } 58 | 59 | List newList = new ArrayList<>(); 60 | for (int i = 0; i < list.size(); i++) { 61 | if (i == index) { 62 | newList.add(value); 63 | } 64 | 65 | newList.add(list.get(i)); 66 | } 67 | 68 | list.clear(); 69 | list.addAll(newList); 70 | } 71 | } 72 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/template/impl/builtin/StructurePastedArea.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.template.impl.builtin; 2 | 3 | import java.util.Random; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.ThreadLocalRandom; 6 | import me.illusion.cosmos.serialization.CosmosSerializer; 7 | import me.illusion.cosmos.template.PastedArea; 8 | import me.illusion.cosmos.utilities.geometry.Cuboid; 9 | import org.bukkit.Location; 10 | import org.bukkit.block.structure.Mirror; 11 | import org.bukkit.block.structure.StructureRotation; 12 | import org.bukkit.structure.Structure; 13 | 14 | public class StructurePastedArea implements PastedArea { 15 | 16 | private final Location pasteLocation; 17 | private final StructureTemplatedArea templatedArea; 18 | 19 | public StructurePastedArea(Location pasteLocation, StructureTemplatedArea templatedArea) { 20 | this.pasteLocation = pasteLocation; 21 | this.templatedArea = templatedArea; 22 | } 23 | 24 | @Override 25 | public CompletableFuture unload() { 26 | Structure empty = templatedArea.getEmptyStructure(); 27 | Location relative = pasteLocation.clone().subtract(templatedArea.getAnchor()); 28 | Random random = ThreadLocalRandom.current(); 29 | 30 | empty.place(relative, true, StructureRotation.NONE, Mirror.NONE, 0, 1, random); 31 | 32 | return CompletableFuture.completedFuture(null); 33 | } 34 | 35 | @Override 36 | public Location getPasteLocation() { 37 | return pasteLocation; 38 | } 39 | 40 | @Override 41 | public CompletableFuture paste(Location location) { 42 | return templatedArea.paste(location); 43 | } 44 | 45 | @Override 46 | public Cuboid getDimensions() { 47 | return templatedArea.getDimensions(); 48 | } 49 | 50 | @Override 51 | public CosmosSerializer getSerializer() { 52 | return templatedArea.getSerializer(); 53 | } 54 | } 55 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 |

Cosmos

2 |
3 | 4 | ![GitHub Repo stars](https://img.shields.io/github/stars/IllusionTheDev/Cosmos?style=for-the-badge) 5 | ![GitHub watchers](https://img.shields.io/github/watchers/IllusionTheDev/Cosmos?style=for-the-badge) 6 | ![GitHub issues](https://img.shields.io/github/issues/IllusionTheDev/Cosmos?style=for-the-badge) 7 | 8 |
9 | 10 | #### This project consists of a World Template Management System 11 | 12 | This project is in BETA, which means it is production ready, but bugs should be expected. 13 | 14 | ------------ 15 | 16 | ### Technologies Used: 17 | - SpigotAPI 18 | - Gradle 19 | - MongoDB 20 | - MySQL 21 | - SQLite 22 | - InfluxDB 23 | 24 | #### Plugin Hooks 25 | - WorldEdit 26 | 27 | ------------ 28 | 29 | ### Developer API 30 | Check the wiki. 31 | 32 | ------------ 33 | 34 | ### Some thoughts: 35 | Cosmos is meant to be used as an API, with its design being intentionally modular so other plugins can register their own data containers (for storing worlds through any given database, such as Amazon S3) and serializers (for pasting worlds through any given format, such as SWM or .schem). 36 | The idea behind Cosmos is that most plugins handle things like Arena Regeneration manually, and struggle to expand into more advanced structures that may involve saving a world to a database and loading it in another server. Cosmos is here to standardize that, and provide a simple interface to load any given template from any given source at any given time. 37 | 38 | Cosmos is production-ready, and provides a GUI for creating and managing templates. 39 | 40 | If you'd like to help with the project, even as someone without any code experience, here are some things that would greatly help me out: 41 | 42 | - Testing 43 | - Helping with the wiki 44 | - Writing issues 45 | - Planning 46 | - Donating (purely your choice, there's no benefit other than making me happy) 47 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/command/CommandUtilities.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.command; 2 | 3 | import java.lang.reflect.Constructor; 4 | import java.lang.reflect.Field; 5 | import java.lang.reflect.InvocationTargetException; 6 | import org.bukkit.Bukkit; 7 | import org.bukkit.Server; 8 | import org.bukkit.command.CommandMap; 9 | import org.bukkit.command.PluginCommand; 10 | import org.bukkit.plugin.Plugin; 11 | import org.bukkit.plugin.java.JavaPlugin; 12 | 13 | public class CommandUtilities { 14 | 15 | private static CommandMap commandMap; 16 | private static Constructor pluginCommandConstructor; 17 | 18 | static { 19 | try { 20 | Server server = Bukkit.getServer(); 21 | Field commandMapField = server.getClass().getDeclaredField("commandMap"); 22 | commandMapField.setAccessible(true); 23 | 24 | commandMap = (CommandMap) commandMapField.get(server); 25 | } catch (NoSuchFieldException | IllegalAccessException e) { 26 | e.printStackTrace(); 27 | } 28 | 29 | try { 30 | pluginCommandConstructor = PluginCommand.class.getDeclaredConstructor(String.class, Plugin.class); 31 | pluginCommandConstructor.setAccessible(true); 32 | } catch (NoSuchMethodException e) { 33 | e.printStackTrace(); 34 | } 35 | } 36 | 37 | public static void registerCommand(String base, JavaPlugin plugin, BukkitBaseCommand baseCommand) { 38 | try { 39 | PluginCommand pluginCommand = pluginCommandConstructor.newInstance(base, plugin); 40 | 41 | pluginCommand.setExecutor(baseCommand); 42 | pluginCommand.setTabCompleter(baseCommand); 43 | 44 | commandMap.register(base, pluginCommand); 45 | 46 | } catch (InstantiationException | IllegalAccessException | 47 | InvocationTargetException e) { 48 | e.printStackTrace(); 49 | } 50 | } 51 | 52 | } 53 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/command/impl/AdvancedCommand.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.command.impl; 2 | 3 | import java.util.HashMap; 4 | import java.util.Map; 5 | import java.util.function.Consumer; 6 | import me.illusion.cosmos.utilities.command.command.impl.AdvancedCommand.AdvancedExecution; 7 | import me.illusion.cosmos.utilities.command.language.AbstractObjectiveModel; 8 | import me.illusion.cosmos.utilities.command.language.data.ObjectiveMetadata; 9 | import org.bukkit.command.CommandSender; 10 | 11 | public abstract class AdvancedCommand extends AbstractObjectiveModel { 12 | 13 | private final Map> inputValidationMap = new HashMap<>(); 14 | 15 | public AdvancedCommand(String syntax) { 16 | super(syntax); 17 | } 18 | 19 | public void addInputValidation(String input, Consumer consumer) { 20 | inputValidationMap.put(input, consumer); 21 | } 22 | 23 | public abstract void execute(CommandSender sender, ExecutionContext context); 24 | 25 | @Override 26 | public final AdvancedExecution compile(ObjectiveMetadata metadata) { 27 | return new AdvancedExecution(metadata); 28 | } 29 | 30 | class AdvancedExecution extends ExecutionContext { 31 | 32 | public AdvancedExecution(ObjectiveMetadata metadata) { 33 | super(metadata); 34 | } 35 | 36 | @Override 37 | public void execute(CommandSender sender) { 38 | for (Map.Entry> entry : inputValidationMap.entrySet()) { 39 | String input = entry.getKey(); 40 | Consumer consumer = entry.getValue(); 41 | 42 | if (getParameter(input) == null) { 43 | consumer.accept(sender); 44 | return; 45 | } 46 | } 47 | 48 | AdvancedCommand.this.execute(sender, this); 49 | } 50 | } 51 | 52 | 53 | } 54 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/session/task/UnloadRequest.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.session.task; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.CompletableFuture; 5 | 6 | /** 7 | * Represents a request to unload a session. It contains the epoch of when the session should be unloaded, and a future which will complete when the session is 8 | * unloaded. This class is thread-safe. 9 | * 10 | * @author Illusion 11 | * @see UnloadTask 12 | */ 13 | public class UnloadRequest { 14 | 15 | private final UUID sessionId; 16 | private final long epoch; 17 | private final CompletableFuture future; 18 | 19 | /** 20 | * Creates an unload request with the specified session ID, epoch and future. 21 | * 22 | * @param sessionId The session ID 23 | * @param epoch The epoch 24 | * @param future The future 25 | */ 26 | public UnloadRequest(UUID sessionId, long epoch, CompletableFuture future) { 27 | this.sessionId = sessionId; 28 | this.epoch = epoch; 29 | this.future = future; 30 | } 31 | 32 | /** 33 | * Gets the session ID. 34 | * 35 | * @return The session ID 36 | */ 37 | public UUID getSessionId() { 38 | return sessionId; 39 | } 40 | 41 | /** 42 | * Gets the epoch of when the session should be unloaded. 43 | * 44 | * @return The epoch 45 | */ 46 | public long getEpoch() { 47 | return epoch; 48 | } 49 | 50 | /** 51 | * Gets the future which will complete when the session is unloaded. 52 | * 53 | * @return The future 54 | */ 55 | public CompletableFuture getFuture() { 56 | return future; 57 | } 58 | 59 | /** 60 | * Cancels the unload request. 61 | */ 62 | public void cancel() { 63 | future.complete(false); 64 | } 65 | 66 | /** 67 | * Completes the unload request. 68 | */ 69 | public void complete() { 70 | future.complete(true); 71 | } 72 | } 73 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/serialization/CosmosSerializer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.serialization; 2 | 3 | import java.io.File; 4 | import java.util.concurrent.CompletableFuture; 5 | import me.illusion.cosmos.template.TemplatedArea; 6 | import me.illusion.cosmos.utilities.geometry.Cuboid; 7 | import org.bukkit.Location; 8 | 9 | /** 10 | * A serializer is an object responsible for serializing and deserializing areas. An example of a serializer is the WorldEdit serializer, which serializes areas 11 | * to WorldEdit's Schematic format. 12 | *

13 | * 14 | * @author Illusion 15 | */ 16 | public interface CosmosSerializer { 17 | 18 | /** 19 | * Serializes an area to a byte array, which can be stored in a database. 20 | * 21 | * @param area The area to serialize 22 | * @return A future of the serialized data 23 | */ 24 | CompletableFuture serialize(TemplatedArea area); 25 | 26 | /** 27 | * Deserializes an area from a byte array. Make sure to use the same serializer as the one used to serialize the area, or else it will not work. 28 | * 29 | * @param data The data to deserialize 30 | * @return A future of the deserialized area 31 | */ 32 | CompletableFuture deserialize(byte[] data); 33 | 34 | /** 35 | * Creates a new area from a cuboid and an anchor location. (The anchor location is the location of the area's origin) 36 | * 37 | * @param bounds The bounds of the area 38 | * @param anchor The anchor location of the area 39 | * @return A future of the created area 40 | */ 41 | CompletableFuture createArea(Cuboid bounds, Location anchor); 42 | 43 | /** 44 | * Attempts to import an area from a file. This method should return null if the file is not supported. 45 | * 46 | * @param file The file to import from 47 | * @return A future of the imported area 48 | */ 49 | CompletableFuture tryImport(File file); 50 | 51 | /** 52 | * Obtains the name of the serializer. 53 | * 54 | * @return The name of the serializer 55 | */ 56 | String getName(); 57 | 58 | } 59 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/command/legacy/SimpleCommand.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.command.legacy; 2 | 3 | import java.util.ArrayList; 4 | import java.util.HashMap; 5 | import java.util.List; 6 | import java.util.Map; 7 | import org.bukkit.command.CommandSender; 8 | 9 | public interface SimpleCommand { 10 | 11 | /** 12 | * The command identifier, use a '.' to separate subcommands Example: island.teleport 13 | * 14 | * @return identifier 15 | */ 16 | String getIdentifier(); 17 | 18 | /** 19 | * The command aliases 20 | * 21 | * @return NULL if no aliases are present 22 | */ 23 | default String[] getAliases() { 24 | return new String[0]; 25 | } 26 | 27 | /** 28 | * The permission to execute the command 29 | * 30 | * @return EMPTY if no permission is present 31 | */ 32 | default String getPermission() { 33 | return ""; 34 | } 35 | 36 | /** 37 | * This is called after the permission checks 38 | * 39 | * @param sender - The command sender 40 | * @return TRUE if the sender can execute the command, FALSE otherwise 41 | */ 42 | default boolean canExecute(CommandSender sender) { 43 | return true; 44 | } 45 | 46 | default boolean hasPermission() { 47 | return !getPermission().isEmpty(); 48 | } 49 | 50 | default Map> tabCompleteWildcards() { 51 | return new HashMap<>(0); 52 | } 53 | 54 | /** 55 | * Executes the command 56 | * 57 | * @param sender - The command sender 58 | * @param args - The arguments external to the identifier 59 | */ 60 | void execute(CommandSender sender, String... args); 61 | 62 | default List getWildcards() { 63 | String identifier = getIdentifier(); 64 | List wildcards = new ArrayList<>(); 65 | 66 | String[] split = identifier.split("\\."); 67 | 68 | for (int index = 0; index < split.length; index++) { 69 | if (split[index].equals("*")) { 70 | wildcards.add(index); 71 | } 72 | } 73 | 74 | return wildcards; 75 | } 76 | } 77 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/resources/messages.yml: -------------------------------------------------------------------------------- 1 | messages: 2 | prefix: "&9Cosmos: &8»&7" 3 | 4 | command: 5 | invalid-args: "%prefix% &cInvalid args!" 6 | cannot-use: "%prefix% &cYou are not allowed to use this command" # If the command is restricted to the console, for example 7 | no-permission: "%prefix% &cYou do not have permission to use this command!" 8 | 9 | menu: 10 | template: 11 | set-name: "%prefix% Input the name of the template on chat!" 12 | template: 13 | created: "%prefix% &aSuccessfully created template %template%!" 14 | set-no-selection: "%prefix% &cYou need to make a WorldEdit selection first!" 15 | delete-not-found: "%prefix% &cTemplate %template% not found!" 16 | delete-success: "%prefix% &aSuccessfully deleted template %template%!" 17 | delete-cancelled: "%prefix% &cCancelled deleting template %template%!" 18 | 19 | import: 20 | invalid-serializer-arg: "%prefix% &cInvalid argument! Usage: /cosmos import " 21 | invalid-file-arg: "%prefix% &cInvalid argument! Usage: /cosmos import " 22 | invalid-serializer: "%prefix% &cInvalid serializer!" 23 | invalid-file: "%prefix% &cThe file %file% does not exist!" 24 | failed: "%prefix% &cFailed to import %serializer% from %file%!" 25 | success: "%prefix% &aSuccessfully imported %serializer% from %file%!" 26 | save-success: "%prefix% &aSuccessfully saved %serializer% to %file%!" 27 | 28 | migrate: 29 | invalid-template-arg: "%prefix% &cYou didn't provide a valid template to migrate from! Usage: /cosmos migrate " 30 | invalid-source-arg: "%prefix% &cYou didn't provide a source! Usage: /cosmos migrate " 31 | invalid-destination-arg: "%prefix% &cYou didn't provide a destination! Usage: /cosmos migrate " 32 | invalid-source: "%prefix% &cInvalid source %source%!" 33 | invalid-destination: "%prefix% &cInvalid destination %destination%!" 34 | success: "%prefix% &aSuccessfully migrated %source% to %destination%!" 35 | started: "%prefix% &aStarted migrating %source% to %destination%!" 36 | invalid-template: "%prefix% &cInvalid template %template%!" -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/database/impl/remote/MySQLDataContainer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.database.impl.remote; 2 | 3 | import java.util.Map; 4 | import me.illusion.cosmos.CosmosPlugin; 5 | import me.illusion.cosmos.database.base.CosmosSQLQuery; 6 | import me.illusion.cosmos.database.base.SQLDataContainer; 7 | import me.illusion.cosmos.utilities.sql.connection.SQLConnectionProvider; 8 | import me.illusion.cosmos.utilities.sql.connection.impl.MySQLConnectionProvider; 9 | import org.bukkit.configuration.ConfigurationSection; 10 | 11 | public class MySQLDataContainer extends SQLDataContainer { 12 | 13 | private static final String FETCH_TEMPLATE = "SELECT * FROM %s WHERE template_id = ?"; 14 | private static final String FETCH_TEMPLATE_SERIALIZER = "SELECT template_serializer FROM %s WHERE template_id = ?"; 15 | private static final String SAVE_TEMPLATE = "INSERT INTO %s (template_id, template_serializer, template_data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE template_serializer=VALUES(template_serializer), template_data=VALUES(template_data)"; 16 | private static final String DELETE_TEMPLATE = "DELETE FROM %s WHERE template_id = ?"; 17 | private static final String FETCH_ALL = "SELECT * FROM %s"; 18 | private static final String FETCH_ALL_NO_DATA = "SELECT template_id, template_serializer FROM %s"; 19 | 20 | public MySQLDataContainer(CosmosPlugin plugin) { 21 | super(plugin); 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "mysql"; 27 | } 28 | 29 | @Override 30 | public SQLConnectionProvider getSQLConnectionProvider(ConfigurationSection section) { 31 | return new MySQLConnectionProvider(section); 32 | } 33 | 34 | @Override 35 | protected Map getQueries() { 36 | return Map.of( 37 | CosmosSQLQuery.FETCH_ALL, FETCH_ALL, 38 | CosmosSQLQuery.FETCH_TEMPLATE, FETCH_TEMPLATE, 39 | CosmosSQLQuery.FETCH_TEMPLATE_SERIALIZER, FETCH_TEMPLATE_SERIALIZER, 40 | CosmosSQLQuery.STORE_TEMPLATE, SAVE_TEMPLATE, 41 | CosmosSQLQuery.DELETE_TEMPLATE, DELETE_TEMPLATE, 42 | CosmosSQLQuery.FETCH_ALL_NO_DATA, FETCH_ALL_NO_DATA 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/database/impl/remote/MariaDBDataProvider.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.database.impl.remote; 2 | 3 | import java.util.Map; 4 | import me.illusion.cosmos.CosmosPlugin; 5 | import me.illusion.cosmos.database.base.CosmosSQLQuery; 6 | import me.illusion.cosmos.database.base.SQLDataContainer; 7 | import me.illusion.cosmos.utilities.sql.connection.SQLConnectionProvider; 8 | import me.illusion.cosmos.utilities.sql.connection.impl.MariaDBConnectionProvider; 9 | import org.bukkit.configuration.ConfigurationSection; 10 | 11 | public class MariaDBDataProvider extends SQLDataContainer { 12 | 13 | private static final String FETCH_TEMPLATE = "SELECT * FROM %s WHERE template_id = ?"; 14 | private static final String FETCH_TEMPLATE_SERIALIZER = "SELECT template_serializer FROM %s WHERE template_id = ?"; 15 | private static final String SAVE_TEMPLATE = "INSERT INTO %s (template_id, template_serializer, template_data) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE template_serializer=VALUES(template_serializer), template_data=VALUES(template_data)"; 16 | private static final String DELETE_TEMPLATE = "DELETE FROM %s WHERE template_id = ?"; 17 | private static final String FETCH_ALL = "SELECT * FROM %s"; 18 | private static final String FETCH_ALL_NO_DATA = "SELECT template_id, template_serializer FROM %s"; 19 | 20 | public MariaDBDataProvider(CosmosPlugin plugin) { 21 | super(plugin); 22 | } 23 | 24 | @Override 25 | public String getName() { 26 | return "mariadb"; 27 | } 28 | 29 | @Override 30 | public SQLConnectionProvider getSQLConnectionProvider(ConfigurationSection section) { 31 | return new MariaDBConnectionProvider(section); 32 | } 33 | 34 | @Override 35 | protected Map getQueries() { 36 | return Map.of( 37 | CosmosSQLQuery.FETCH_ALL, FETCH_ALL, 38 | CosmosSQLQuery.FETCH_TEMPLATE, FETCH_TEMPLATE, 39 | CosmosSQLQuery.FETCH_TEMPLATE_SERIALIZER, FETCH_TEMPLATE_SERIALIZER, 40 | CosmosSQLQuery.STORE_TEMPLATE, SAVE_TEMPLATE, 41 | CosmosSQLQuery.DELETE_TEMPLATE, DELETE_TEMPLATE, 42 | CosmosSQLQuery.FETCH_ALL_NO_DATA, FETCH_ALL_NO_DATA 43 | ); 44 | } 45 | } 46 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/selection/HollowRectangularSelection.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.selection; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import me.illusion.cosmos.utilities.menu.math.Point; 6 | 7 | public class HollowRectangularSelection implements Selection { 8 | 9 | private final Point firstPoint; 10 | private final Point secondPoint; 11 | private int thickness = 1; 12 | 13 | public HollowRectangularSelection(Point firstPoint, Point secondPoint) { 14 | this.firstPoint = firstPoint; 15 | this.secondPoint = secondPoint; 16 | } 17 | 18 | public HollowRectangularSelection(Point firstPoint, Point secondPoint, int thickness) { 19 | this.firstPoint = firstPoint; 20 | this.secondPoint = secondPoint; 21 | this.thickness = thickness; 22 | } 23 | 24 | public int getThickness() { 25 | return thickness; 26 | } 27 | 28 | public void setThickness(int thickness) { 29 | this.thickness = thickness; 30 | } 31 | 32 | 33 | @Override 34 | public List getSlots() { 35 | List slots = new ArrayList<>(); 36 | 37 | for (int thickness = 0; thickness < this.thickness; thickness++) { 38 | Point firstPoint = new Point(this.firstPoint.getX() + thickness, this.firstPoint.getY() + thickness); 39 | Point secondPoint = new Point(this.secondPoint.getX() - thickness, this.secondPoint.getY() - thickness); 40 | 41 | slots.addAll(getSlots(firstPoint, secondPoint)); 42 | } 43 | 44 | return slots; 45 | } 46 | 47 | private int getSlot(int x, int y) { 48 | return y * 9 + x; 49 | } 50 | 51 | private List getSlots(Point firstPoint, Point secondPoint) { 52 | List slots = new ArrayList<>(); 53 | 54 | for (int x = firstPoint.getX(); x <= secondPoint.getX(); x++) { 55 | slots.add(getSlot(x, firstPoint.getY())); 56 | slots.add(getSlot(x, secondPoint.getY())); 57 | } 58 | 59 | for (int y = firstPoint.getY(); y <= secondPoint.getY(); y++) { 60 | slots.add(getSlot(firstPoint.getX(), y)); 61 | slots.add(getSlot(secondPoint.getX(), y)); 62 | } 63 | 64 | return slots; 65 | } 66 | } 67 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/mask/PatternMask.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.mask; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | import lombok.Getter; 6 | import me.illusion.cosmos.utilities.menu.selection.MultiSelection; 7 | import me.illusion.cosmos.utilities.menu.selection.PatternMaskSelection; 8 | import me.illusion.cosmos.utilities.menu.selection.Selection; 9 | 10 | @Getter 11 | public class PatternMask { 12 | 13 | private final List pattern; 14 | 15 | public PatternMask(List pattern) { 16 | this.pattern = pattern; 17 | } 18 | 19 | public PatternMask(String... pattern) { 20 | this.pattern = List.of(pattern); 21 | } 22 | 23 | public static PatternMask of(List pattern) { 24 | return new PatternMask(pattern); 25 | } 26 | 27 | public static PatternMask of(String... pattern) { 28 | return new PatternMask(pattern); 29 | } 30 | 31 | private boolean contains(char character) { 32 | for (String line : pattern) { 33 | if (line.contains(String.valueOf(character))) { 34 | return true; 35 | } 36 | } 37 | 38 | return false; 39 | } 40 | 41 | public PatternMaskSelection selection(char character) { 42 | return new PatternMaskSelection(this, String.valueOf(character)); 43 | } 44 | 45 | public PatternMaskSelection selection(String character) { 46 | return new PatternMaskSelection(this, character); 47 | } 48 | 49 | public MultiSelection multiSelection(char... characters) { 50 | return multiSelection(new String(characters)); 51 | } 52 | 53 | public MultiSelection multiSelection(String characters) { 54 | List selections = new ArrayList<>(); 55 | 56 | for (char character : characters.toCharArray()) { 57 | if (!contains(character)) { 58 | throw new IllegalArgumentException("The mask does not contain the character '" + character + "'"); 59 | } 60 | 61 | selections.add(selection(character)); 62 | } 63 | 64 | return new MultiSelection(selections); 65 | } 66 | 67 | } 68 | 69 | /* 70 | - 'e . . . . . . . e' 71 | - 'p . . . . . . . n' 72 | - 'p . . . . . . . n' 73 | - 'e . . . . . . . e' 74 | - 'e e e e e e e e e' 75 | */ -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/database/impl/SQLiteDataContainer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.database.impl; 2 | 3 | import java.io.File; 4 | import java.util.Map; 5 | import me.illusion.cosmos.CosmosPlugin; 6 | import me.illusion.cosmos.database.base.CosmosSQLQuery; 7 | import me.illusion.cosmos.database.base.SQLDataContainer; 8 | import me.illusion.cosmos.utilities.sql.connection.SQLConnectionProvider; 9 | import me.illusion.cosmos.utilities.sql.connection.impl.SQLiteConnectionProvider; 10 | import org.bukkit.configuration.ConfigurationSection; 11 | 12 | public class SQLiteDataContainer extends SQLDataContainer { 13 | 14 | private static final String FETCH_TEMPLATE = "SELECT * FROM %s WHERE template_id = ?"; 15 | private static final String FETCH_TEMPLATE_SERIALIZER = "SELECT template_serializer FROM %s WHERE template_id = ?"; 16 | private static final String SAVE_TEMPLATE = "INSERT OR REPLACE INTO %s (template_id, template_serializer, template_data) VALUES (?, ?, ?);"; 17 | private static final String DELETE_TEMPLATE = "DELETE FROM %s WHERE template_id = ?"; 18 | private static final String FETCH_ALL = "SELECT * FROM %s"; 19 | private static final String FETCH_ALL_NO_DATA = "SELECT template_id, template_serializer FROM %s"; 20 | 21 | private final File file; 22 | 23 | public SQLiteDataContainer(CosmosPlugin plugin) { 24 | super(plugin); 25 | this.file = new File(plugin.getDataFolder(), "database.db"); 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return "sqlite"; 31 | } 32 | 33 | 34 | @Override 35 | public SQLConnectionProvider getSQLConnectionProvider(ConfigurationSection section) { 36 | return new SQLiteConnectionProvider(file); 37 | } 38 | 39 | @Override 40 | protected Map getQueries() { 41 | return Map.of( 42 | CosmosSQLQuery.FETCH_ALL, FETCH_ALL, 43 | CosmosSQLQuery.FETCH_TEMPLATE, FETCH_TEMPLATE, 44 | CosmosSQLQuery.FETCH_TEMPLATE_SERIALIZER, FETCH_TEMPLATE_SERIALIZER, 45 | CosmosSQLQuery.STORE_TEMPLATE, SAVE_TEMPLATE, 46 | CosmosSQLQuery.DELETE_TEMPLATE, DELETE_TEMPLATE, 47 | CosmosSQLQuery.FETCH_ALL_NO_DATA, FETCH_ALL_NO_DATA 48 | ); 49 | } 50 | 51 | @Override 52 | public boolean requiresCredentials() { 53 | return false; 54 | } 55 | } 56 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/session/CosmosSession.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.session; 2 | 3 | import java.util.UUID; 4 | import java.util.concurrent.CompletableFuture; 5 | import lombok.Data; 6 | import lombok.Getter; 7 | import me.illusion.cosmos.database.CosmosDataContainer; 8 | import me.illusion.cosmos.template.PastedArea; 9 | import org.bukkit.Location; 10 | 11 | 12 | /** 13 | * A simple session implementation, that uses a UUID identifier and a pasted area. This class is thread-safe. 14 | * 15 | * @author Illusion 16 | * @see PastedArea 17 | */ 18 | @Getter 19 | @Data 20 | public class CosmosSession { 21 | 22 | private final UUID uuid; 23 | private final PastedArea pastedArea; 24 | 25 | /** 26 | * Unloads the session. 27 | * 28 | * @return A future which will complete when the session is unloaded 29 | */ 30 | public CompletableFuture unload() { 31 | return pastedArea.unload(); 32 | } 33 | 34 | /** 35 | * Saves the session to the specified container. 36 | * 37 | * @param container The container to save the session to 38 | * @return A future which will complete when the session is saved 39 | */ 40 | public CompletableFuture save(CosmosDataContainer container, boolean async) { 41 | CompletableFuture future = container.saveTemplate(uuid.toString(), pastedArea).exceptionally(ex -> { 42 | ex.printStackTrace(); 43 | return null; 44 | }); 45 | 46 | if (async) { 47 | return future; 48 | } 49 | 50 | future.join(); 51 | return CompletableFuture.completedFuture(null); 52 | } 53 | 54 | /** 55 | * Saves the session to the specified container, asynchronously. 56 | * 57 | * @param container The container to save the session to 58 | * @return A future which will complete when the session is saved 59 | */ 60 | public CompletableFuture save(CosmosDataContainer container) { 61 | return save(container, true); 62 | } 63 | 64 | /** 65 | * Checks if the session contains the specified location. 66 | * 67 | * @param location The location to check 68 | * @return Whether the session contains the location 69 | */ 70 | public boolean containsLocation(Location location) { 71 | return pastedArea.containsLocation(location); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/utilities/menu/pagination/PaginableArea.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.utilities.menu.pagination; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Collection; 5 | import java.util.List; 6 | import lombok.Getter; 7 | import me.illusion.cosmos.utilities.menu.base.BaseMenu; 8 | import me.illusion.cosmos.utilities.menu.button.Button; 9 | import me.illusion.cosmos.utilities.menu.element.MenuElement; 10 | import me.illusion.cosmos.utilities.menu.selection.Selection; 11 | import org.bukkit.Material; 12 | import org.bukkit.inventory.ItemStack; 13 | 14 | @Getter 15 | public class PaginableArea { 16 | 17 | private final List slots; 18 | private final List elements = new ArrayList<>(); 19 | private MenuElement emptyElement = new Button(new ItemStack(Material.AIR)); 20 | 21 | 22 | public PaginableArea(Selection selection) { 23 | this.slots = selection.getSlots(); 24 | } 25 | 26 | public PaginableArea(Selection selection, MenuElement emptyElement) { 27 | this(selection); 28 | this.emptyElement = emptyElement; 29 | } 30 | 31 | public void clearArea() { 32 | elements.clear(); 33 | } 34 | 35 | public void setEmptyElement( 36 | MenuElement emptyElement) { 37 | this.emptyElement = emptyElement; 38 | } 39 | 40 | public void addElement(MenuElement element) { 41 | elements.add(element); 42 | } 43 | 44 | 45 | public void addElement(Collection element) { 46 | for (MenuElement menuElement : element) { 47 | addElement(menuElement); 48 | } 49 | } 50 | 51 | public void removeElement(MenuElement element) { 52 | elements.remove(element); 53 | } 54 | 55 | public void forceUpdate(BaseMenu menu, int page) { 56 | int startIdx = (page - 1) * slots.size(); 57 | int endIdx = startIdx + slots.size(); 58 | 59 | for (int index = startIdx; index < endIdx; index++) { 60 | int slot = slots.get(index - startIdx); 61 | 62 | if (index >= elements.size()) { 63 | menu.setElement(slot, emptyElement); 64 | } else { 65 | menu.setElement(slot, elements.get(index)); 66 | } 67 | } 68 | } 69 | 70 | public int getPageCount() { 71 | return (int) Math.ceil((double) elements.size() / slots.size()); 72 | } 73 | 74 | } 75 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/cache/CosmosCache.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.cache; 2 | 3 | import java.util.Map; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.ConcurrentHashMap; 6 | 7 | /** 8 | * A simple cache implementation, that uses a String identifier to store and retrieve values. 9 | * 10 | * @param The type of the value 11 | */ 12 | public class CosmosCache { 13 | 14 | private final Map cache = new ConcurrentHashMap<>(); 15 | 16 | /** 17 | * Registers a value to the cache. 18 | * 19 | * @param identifier The identifier to register the value under 20 | * @param value The value to register 21 | */ 22 | public void register(String identifier, T value) { 23 | cache.put(identifier, value); 24 | } 25 | 26 | /** 27 | * Registers a value to the cache, using a future. 28 | * 29 | * @param identifier The identifier to register the value under 30 | * @param valueFuture The future which will complete with the value 31 | */ 32 | public void register(String identifier, CompletableFuture valueFuture) { 33 | valueFuture.thenAccept(value -> { 34 | if (value == null) { 35 | System.err.println("Failed to load area " + identifier); 36 | return; // the future failed to load the area, so we'll not cache it 37 | } 38 | 39 | System.out.println("Cached area " + identifier); 40 | cache.put(identifier, value); 41 | }); 42 | 43 | valueFuture.exceptionally(throwable -> { 44 | System.err.println("Failed to load area " + identifier); 45 | throwable.printStackTrace(); 46 | return null; 47 | }); 48 | } 49 | 50 | /** 51 | * Gets a value from the cache. 52 | * 53 | * @param identifier The identifier to get the value from 54 | * @return The value, or null if it does not exist 55 | */ 56 | public T get(String identifier) { 57 | return cache.get(identifier); 58 | } 59 | 60 | /** 61 | * Unregisters a value from the cache. 62 | * 63 | * @param identifier The identifier to unregister the value from 64 | */ 65 | public void unregister(String identifier) { 66 | cache.remove(identifier); 67 | } 68 | 69 | /** 70 | * Clears the cache. 71 | */ 72 | public void clear() { 73 | cache.clear(); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/template/impl/builtin/StructureTemplatedArea.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.template.impl.builtin; 2 | 3 | import java.util.Random; 4 | import java.util.concurrent.CompletableFuture; 5 | import java.util.concurrent.ThreadLocalRandom; 6 | import me.illusion.cosmos.serialization.CosmosSerializer; 7 | import me.illusion.cosmos.template.PastedArea; 8 | import me.illusion.cosmos.template.TemplatedArea; 9 | import me.illusion.cosmos.utilities.geometry.Cuboid; 10 | import org.bukkit.Location; 11 | import org.bukkit.block.structure.Mirror; 12 | import org.bukkit.block.structure.StructureRotation; 13 | import org.bukkit.structure.Structure; 14 | import org.bukkit.util.Vector; 15 | 16 | public class StructureTemplatedArea implements TemplatedArea { 17 | 18 | private final CosmosSerializer serializer; 19 | 20 | private final Structure structure; 21 | private final Structure emptyStructure; 22 | private final Vector anchor; 23 | 24 | public StructureTemplatedArea(CosmosSerializer serializer, Structure structure, Structure emptyStructure, Vector anchor) { 25 | this.serializer = serializer; 26 | this.structure = structure; 27 | this.emptyStructure = emptyStructure; 28 | this.anchor = anchor; 29 | } 30 | 31 | @Override 32 | public CompletableFuture paste(Location location) { 33 | Random random = ThreadLocalRandom.current(); // This shouldn't be used if I pass 1 as integrity 34 | 35 | Location relative = location.clone().subtract(anchor); 36 | structure.place(relative, true, StructureRotation.NONE, Mirror.NONE, 0, 1, random); 37 | 38 | return CompletableFuture.completedFuture(new StructurePastedArea(location, this)); 39 | } 40 | 41 | @Override 42 | public Cuboid getDimensions() { 43 | Vector size = structure.getSize(); 44 | 45 | // Anchor is an offset to the minimum point 46 | Vector minimum = anchor.clone().multiply(-1); 47 | Vector maximum = minimum.clone().add(size); 48 | 49 | return new Cuboid(minimum, maximum); 50 | } 51 | 52 | @Override 53 | public CosmosSerializer getSerializer() { 54 | return serializer; 55 | } 56 | 57 | public Vector getAnchor() { 58 | return anchor; 59 | } 60 | 61 | public Structure getEmptyStructure() { 62 | return emptyStructure; 63 | } 64 | 65 | public Structure getStructure() { 66 | return structure; 67 | } 68 | } 69 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/database/impl/remote/PostgresDataContainer.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.database.impl.remote; 2 | 3 | import java.util.Map; 4 | import me.illusion.cosmos.CosmosPlugin; 5 | import me.illusion.cosmos.database.base.CosmosSQLQuery; 6 | import me.illusion.cosmos.database.base.SQLDataContainer; 7 | import me.illusion.cosmos.utilities.sql.ColumnData; 8 | import me.illusion.cosmos.utilities.sql.ColumnType; 9 | import me.illusion.cosmos.utilities.sql.connection.SQLConnectionProvider; 10 | import me.illusion.cosmos.utilities.sql.connection.impl.PostgresConnectionProvider; 11 | import org.bukkit.configuration.ConfigurationSection; 12 | 13 | public class PostgresDataContainer extends SQLDataContainer { 14 | 15 | private static final String FETCH_TEMPLATE = "SELECT * FROM %s WHERE template_id = ?"; 16 | private static final String FETCH_TEMPLATE_SERIALIZER = "SELECT template_serializer FROM %s WHERE template_id = ?"; 17 | private static final String SAVE_TEMPLATE = "INSERT INTO %s (template_id, template_serializer, template_data) VALUES (?, ?, ?) ON CONFLICT (template_id) DO UPDATE SET template_serializer=EXCLUDED.template_serializer, template_data=EXCLUDED.template_data"; 18 | private static final String DELETE_TEMPLATE = "DELETE FROM %s WHERE template_id = ?"; 19 | private static final String FETCH_ALL = "SELECT * FROM %s"; 20 | private static final String FETCH_ALL_NO_DATA = "SELECT template_id, template_serializer FROM %s"; 21 | 22 | public PostgresDataContainer(CosmosPlugin plugin) { 23 | super(plugin); 24 | 25 | overrideColumn("template_data", new ColumnData("template_data", ColumnType.BYTEA)); 26 | } 27 | 28 | @Override 29 | public String getName() { 30 | return "postgres"; 31 | } 32 | 33 | @Override 34 | public SQLConnectionProvider getSQLConnectionProvider(ConfigurationSection section) { 35 | return new PostgresConnectionProvider(section); 36 | } 37 | 38 | @Override 39 | protected Map getQueries() { 40 | return Map.of( 41 | CosmosSQLQuery.FETCH_ALL, FETCH_ALL, 42 | CosmosSQLQuery.FETCH_TEMPLATE, FETCH_TEMPLATE, 43 | CosmosSQLQuery.FETCH_TEMPLATE_SERIALIZER, FETCH_TEMPLATE_SERIALIZER, 44 | CosmosSQLQuery.STORE_TEMPLATE, SAVE_TEMPLATE, 45 | CosmosSQLQuery.DELETE_TEMPLATE, DELETE_TEMPLATE, 46 | CosmosSQLQuery.FETCH_ALL_NO_DATA, FETCH_ALL_NO_DATA 47 | ); 48 | } 49 | } 50 | -------------------------------------------------------------------------------- /Cosmos-Plugin/src/main/java/me/illusion/cosmos/command/CosmosTemplatePasteCommand.java: -------------------------------------------------------------------------------- 1 | package me.illusion.cosmos.command; 2 | 3 | import me.illusion.cosmos.CosmosPlugin; 4 | import me.illusion.cosmos.database.CosmosDataContainer; 5 | import me.illusion.cosmos.utilities.command.command.impl.AdvancedCommand; 6 | import me.illusion.cosmos.utilities.command.command.impl.ExecutionContext; 7 | import me.illusion.cosmos.utilities.storage.MessagesFile; 8 | import org.bukkit.command.CommandSender; 9 | import org.bukkit.entity.Player; 10 | 11 | public class CosmosTemplatePasteCommand extends AdvancedCommand { 12 | 13 | private final CosmosPlugin plugin; 14 | private final MessagesFile messages; 15 | 16 | public CosmosTemplatePasteCommand(CosmosPlugin plugin) { 17 | super("cosmos templates paste