Skip to content

Commit

Permalink
Merge branch 'master' into add-possibility-to-set-warp-permissions
Browse files Browse the repository at this point in the history
  • Loading branch information
vLuckyyy committed Jan 12, 2025
2 parents 7eb3bfc + 8439bf0 commit 1dbc78f
Show file tree
Hide file tree
Showing 81 changed files with 641 additions and 302 deletions.
8 changes: 4 additions & 4 deletions .github/HOW_USE_DI.md → .github/HOW_USE_TO_DI.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ public class UserCommand {
#### 7. Subscriber
```java
@Controller // <- marks a class that will be registered as an event subscriber.
public class UserSubscriber implements Subscriber {
public class UserSubscriber {

private final UserService exampleService;

Expand All @@ -126,12 +126,12 @@ public class UserSubscriber implements Subscriber {
}
```

#### 8. BeanSetup
BeanSetup is a class that allows you to register beans in the bean container.
#### 8. Setup
Setup is an annotation that allows you to register beans in the bean container.
It is used to register dependencies that are cannot be registered in the bean container using annotations. e.g. MiniMessage, AdventureProvider, HikariDataSource, etc.
```java

@BeanSetup // <- marks a class that will be registered as a bean holder.
@Setup // <- marks a class that will be registered as a bean holder.
public class UserBeanSetup {

@Bean // <- marks a method that will be registered as a bean. (dependency)
Expand Down
8 changes: 4 additions & 4 deletions .github/workflows/gradle.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ jobs:
fail-fast: false
steps:
- name: Checkout
uses: actions/[email protected].1
uses: actions/[email protected].2
- name: 'Set up JDK ${{ matrix.java }}'
uses: actions/setup-java@v4.4.0
uses: actions/setup-java@v4.6.0
with:
distribution: adopt
java-version: '${{ matrix.java }}'
- name: Cache Gradle
uses: actions/cache@v4.1.1
uses: actions/cache@v4.2.0
with:
path: ~/.gradle/caches
key: >-
Expand All @@ -35,7 +35,7 @@ jobs:
- name: Build the Jar
run: './gradlew clean eternalcore-plugin:shadowJar'
- name: Upload a Build Artifact
uses: actions/upload-artifact@v4.4.3
uses: actions/upload-artifact@v4.6.0
with:
name: 'EternalCore'
path: eternalcore-plugin/build/libs/EternalCore*.jar
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ EternalCore is your ultimate companion for enhancing your Minecraft server exper

## :information_source: Information

- EternalCore fully supports Minecraft's latest minor versions starting from each major version, starting from 1.17 onward, e.g. `1.17.1`, `1.18.2`, `1.19.4`, `1.20.6`, `1.21.1`.
- Requires **Java 17 or later** to work properly. For older versions of Java, this may affect the functionality of the plugin.
- EternalCore fully supports Minecraft's latest minor versions starting from each major version, starting from 1.17 onward, e.g. `1.17.1`, `1.18.2`, `1.19.4`, `1.20.6`, `1.21.4`.
- Requires **Java 21 or later** to work properly. For older versions of Java, this may affect the functionality of the plugin.
- If you have any questions, perhaps you will find a solution to them in our [documentation](https://docs.eternalcode.pl/eternalcore/introduction.html), you can also ask us about it on [discord](https://discord.gg/FQ7jmGBd6c).

## :hammer_and_wrench: Development Builds
Expand Down Expand Up @@ -80,15 +80,15 @@ For Maven projects use:

For Gradle projects use:
```kts
compileOnly("com.eternalcode:eternalcore-api:1.4.0")
compileOnly("com.eternalcode:eternalcore-api:1.5.0")
```

For Maven projects use:
```xml
<dependency>
<groupId>com.eternalcode</groupId>
<artifactId>eternalcore-api</artifactId>
<version>1.4.0</version>
<version>1.5.0</version>
<scope>provided</scope>
</dependency>
```
Expand All @@ -97,7 +97,7 @@ For Maven projects use:

## :building_construction: Building

To build EternalCore, follow these steps (Make sure you have **JDK 17 or higher**):
To build EternalCore, follow these steps (Make sure you have **JDK 21 or higher**):

```shell
./gradlew clean eternalcore-plugin:shadowJar
Expand Down
4 changes: 2 additions & 2 deletions buildSrc/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ repositories {

dependencies {
implementation("net.kyori:blossom:1.3.1")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.3")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.0.21")
implementation("com.gradleup.shadow:shadow-gradle-plugin:8.3.5")
implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:2.1.0")
implementation("net.minecrell:plugin-yml:0.6.0")
}

Expand Down
35 changes: 17 additions & 18 deletions buildSrc/src/main/kotlin/Versions.kt
Original file line number Diff line number Diff line change
@@ -1,53 +1,52 @@
object Versions {

const val SPIGOT_API = "1.19.4-R0.1-SNAPSHOT"
const val PAPER_API = "1.19.4-R0.1-SNAPSHOT"
const val SPIGOT_API = "1.21.3-R0.1-SNAPSHOT"
const val PAPER_API = "1.21.3-R0.1-SNAPSHOT"

const val ETERNALCODE_COMMONS = "1.1.5"
const val MULTIFICATION = "1.1.4"
const val MULTIFICATION = "1.2.1"

const val JETBRAINS_ANNOTATIONS = "26.0.1"
const val PLACEHOLDER_API = "2.11.6"
const val LOMBOK = "1.18.34"
const val LOMBOK = "1.18.36"
const val GIT_CHECK = "1.0.0"

const val PAPERLIB = "1.0.8"
const val ADVENTURE_PLATFORM = "4.3.4"
const val ADVENTURE_TEXT_MINIMESSAGE = "4.18.0-SNAPSHOT"
const val ADVENTURE_TEXT_MINIMESSAGE = "4.18.0"
const val ADVENTURE_PLATFORM_FACET = "4.3.4"
const val CDN_CONFIGS = "1.14.5"

const val MARIA_DB = "3.4.1"
const val MARIA_DB = "3.5.1"
const val POSTGRESQL = "42.7.4"
const val H2 = "2.1.214"
const val H2 = "2.3.232"
const val ORMLITE = "6.1"
const val HIKARI_CP = "6.0.0"
const val HIKARI_CP = "6.2.1"

const val LITE_COMMANDS = "3.8.0"
const val LITE_COMMANDS = "3.9.7"
const val LITE_SKULL_API = "1.3.0"

const val GUAVA = "33.3.1-jre"
const val GUAVA = "33.4.0-jre"
const val GSON = "2.11.0"

const val EXPRESSIBLE = "1.3.6"
const val PANDA_UTILITIES = "0.5.3-alpha"
const val APACHE_COMMONS = "2.17.0"
const val APACHE_COMMONS = "2.18.0"

const val TRIUMPH_GUI = "3.1.10"
const val TRIUMPH_GUI = "3.1.11"

const val BSTATS = "3.1.0"
const val PIXEL_WIDTH = "1.1.0"

const val CAFFEINE = "3.1.8"

const val SPOTIFY_COMPLETABLE_FUTURES = "0.3.6"

// tests
const val EXPRESSIBLE_JUNIT = "1.3.6"
const val GROOVY_ALL = "3.0.22"
const val JUNIT_JUPITER_API = "5.11.2"
const val JUNIT_JUPITER_PARAMS = "5.11.2"
const val JUNIT_JUPITER_ENGINE = "5.11.2"
const val MOCKITO_CORE = "5.14.2"
const val GROOVY_ALL = "3.0.23"
const val JUNIT_JUPITER_API = "5.11.4"
const val JUNIT_JUPITER_PARAMS = "5.11.4"
const val JUNIT_JUPITER_ENGINE = "5.11.4"
const val MOCKITO_CORE = "5.15.2"

}
8 changes: 4 additions & 4 deletions buildSrc/src/main/kotlin/eternalcode-java.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@ plugins {
}

group = "com.eternalcode"
version = "1.4.0"
version = "1.5.0"

checkstyle {
toolVersion = "10.18.2"
toolVersion = "10.21.1"

configFile = file("${rootDir}/config/checkstyle/checkstyle.xml")
configProperties["checkstyle.suppressions.file"] = "${rootDir}/config/checkstyle/suppressions.xml"
Expand All @@ -21,7 +21,7 @@ configurations.named("checkstyle") {
resolutionStrategy {
capabilitiesResolution {
withCapability("com.google.collections:google-collections") {
select("com.google.guava:guava:33.3.1-jre")
select("com.google.guava:guava:33.4.0-jre")
}
}
}
Expand All @@ -35,5 +35,5 @@ java {
tasks.withType<JavaCompile>() {
options.compilerArgs = listOf("-Xlint:deprecation", "-parameters")
options.encoding = "UTF-8"
options.release = 17
options.release = 21
}
2 changes: 1 addition & 1 deletion buildSrc/src/main/kotlin/eternalcore-publish.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ plugins {
}

group = "com.eternalcode"
version = "1.4.0"
version = "1.5.0"

java {
withSourcesJar()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ void onHomeTeleport(HomeTeleportEvent event) {

player.sendMessage("Teleporting to home...");

if (player.hasPotionEffect(PotionEffectType.SLOW)) {
if (player.hasPotionEffect(PotionEffectType.SLOWNESS)) {
player.sendMessage("You are slowed down!");
player.teleport(player.getWorld().getSpawnLocation());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@ public class Delay<T> {

private final Supplier<Duration> delaySettings;

@Deprecated
public Delay(DelaySettings delaySettings) {
this((Supplier<Duration>) () -> delaySettings.delay());
}

public Delay(Supplier<Duration> delayProvider) {
this.delaySettings = delayProvider;

Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,27 +1,35 @@
package com.eternalcode.core;

import com.eternalcode.core.configuration.ReloadableConfig;
import com.eternalcode.core.compatibility.CompatibilityService;
import com.eternalcode.core.injector.DependencyInjector;
import com.eternalcode.core.injector.annotations.component.Component;
import com.eternalcode.core.injector.annotations.component.ConfigurationFile;
import com.eternalcode.core.injector.annotations.component.Controller;
import com.eternalcode.core.injector.annotations.component.Repository;
import com.eternalcode.core.injector.annotations.component.Service;
import com.eternalcode.core.injector.annotations.component.Setup;
import com.eternalcode.core.injector.annotations.component.Task;
import com.eternalcode.core.injector.annotations.lite.LiteArgument;
import com.eternalcode.core.injector.annotations.lite.LiteCommandEditor;
import com.eternalcode.core.injector.annotations.lite.LiteContextual;
import com.eternalcode.core.injector.annotations.lite.LiteHandler;
import com.eternalcode.core.injector.bean.BeanCandidate;
import com.eternalcode.core.injector.bean.BeanFactory;
import com.eternalcode.core.injector.bean.BeanHolder;
import com.eternalcode.core.injector.bean.LazyFieldBeanCandidate;
import com.eternalcode.core.injector.bean.BeanCandidatePriorityProvider;
import com.eternalcode.core.injector.bean.processor.BeanProcessor;
import com.eternalcode.core.injector.bean.processor.BeanProcessorFactory;
import com.eternalcode.core.injector.scan.DependencyScanner;
import com.eternalcode.core.injector.scan.DependencyScannerFactory;
import com.eternalcode.core.publish.Publisher;
import com.eternalcode.core.publish.event.EternalInitializeEvent;
import com.eternalcode.core.publish.event.EternalShutdownEvent;
import net.dzikoysk.cdn.entity.Contextual;
import dev.rollczi.litecommands.annotations.command.Command;
import dev.rollczi.litecommands.annotations.command.RootCommand;
import org.bukkit.Server;
import org.bukkit.plugin.Plugin;
import org.bukkit.plugin.PluginDescriptionFile;
import org.bukkit.plugin.PluginManager;

import java.io.File;
import java.lang.reflect.Field;
import java.util.List;
import java.util.logging.Logger;

class EternalCore {
Expand All @@ -32,6 +40,7 @@ class EternalCore {
public EternalCore(Plugin plugin) {
this.eternalCoreEnvironment = new EternalCoreEnvironment(plugin.getLogger());

CompatibilityService compatibilityService = new CompatibilityService();
BeanProcessor beanProcessor = BeanProcessorFactory.defaultProcessors(plugin);
BeanFactory beanFactory = new BeanFactory(beanProcessor)
.withCandidateSelf()
Expand All @@ -40,19 +49,35 @@ public EternalCore(Plugin plugin) {
.addCandidate(Logger.class, () -> plugin.getLogger())
.addCandidate(PluginDescriptionFile.class, () -> plugin.getDescription())
.addCandidate(File.class, () -> plugin.getDataFolder())
.addCandidate(PluginManager.class, () -> plugin.getServer().getPluginManager());

DependencyInjector dependencyInjector = new DependencyInjector(beanFactory);
DependencyScanner scanner = DependencyScannerFactory.createDefault(dependencyInjector);

beanFactory.addCandidate(DependencyInjector.class, () -> dependencyInjector);
.addCandidate(PluginManager.class, () -> plugin.getServer().getPluginManager())
.priorityProvider(new BeanCandidatePriorityProvider());

DependencyInjector injector = new DependencyInjector(beanFactory);
DependencyScanner scanner = new DependencyScanner(injector)
.includeType(type -> compatibilityService.isCompatible(type))
.includeAnnotations(
Component.class,
Service.class,
Repository.class,
Task.class,
Controller.class,
ConfigurationFile.class,
Setup.class,

Command.class,
RootCommand.class,
LiteArgument.class,
LiteHandler.class,
LiteContextual.class,
LiteCommandEditor.class
);

beanFactory.addCandidate(DependencyInjector.class, () -> injector);

for (BeanCandidate beanCandidate : scanner.scan(EternalCore.class.getPackage())) {
beanFactory.addCandidate(beanCandidate);
}

this.loadConfigContextual(beanFactory);

beanFactory.initializeCandidates();

this.publisher = beanFactory.getDependency(Publisher.class);
Expand All @@ -67,22 +92,4 @@ public void disable() {
EternalCoreApiProvider.deinitialize();
}

private void loadConfigContextual(BeanFactory beanFactory) {
List<BeanHolder<ReloadableConfig>> beans = beanFactory
.initializeCandidates(ReloadableConfig.class)
.getBeans(ReloadableConfig.class);

for (BeanHolder<ReloadableConfig> bean : beans) {
ReloadableConfig config = bean.get();

for (Field field : config.getClass().getDeclaredFields()) {
if (!field.getType().isAnnotationPresent(Contextual.class)) {
continue;
}

beanFactory.addCandidate(new LazyFieldBeanCandidate(config, field));
}
}
}

}
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.eternalcode.core.bridge;

import com.eternalcode.core.injector.annotations.Bean;
import com.eternalcode.core.injector.annotations.component.BeanSetup;
import com.eternalcode.core.injector.annotations.component.Setup;
import com.eternalcode.core.placeholder.PlaceholderRegistry;
import java.util.logging.Logger;
import org.bukkit.Server;
import org.bukkit.plugin.PluginDescriptionFile;

@BeanSetup
@Setup
class BridgeManagerInitializer {

@Bean
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import com.eternalcode.commons.adventure.AdventureLegacyColorPreProcessor;
import com.eternalcode.commons.adventure.AdventureUrlPostProcessor;
import com.eternalcode.core.injector.annotations.Bean;
import com.eternalcode.core.injector.annotations.component.BeanSetup;
import com.eternalcode.core.injector.annotations.component.Setup;
import net.kyori.adventure.platform.AudienceProvider;
import net.kyori.adventure.platform.bukkit.BukkitAudiences;
import net.kyori.adventure.text.minimessage.MiniMessage;
import org.bukkit.plugin.Plugin;

@BeanSetup
@Setup
class AdventureSetup {

@Bean
Expand Down
Loading

0 comments on commit 1dbc78f

Please sign in to comment.