Skip to content

Commit 4db61f0

Browse files
authored
GH-897 Fix dependency injector configuration class instance handling of plugin config (#897)
* innit * Fix logic, add additional comments to clarify the usage. * Another fix * Fix configuration not supplying for Beans * Rollback logic for rtp * Rollback rtp config
1 parent 046c0df commit 4db61f0

File tree

6 files changed

+10
-8
lines changed

6 files changed

+10
-8
lines changed

eternalcore-core/src/main/java/com/eternalcode/core/EternalCore.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.eternalcode.core;
22

33
import com.eternalcode.core.compatibility.CompatibilityService;
4+
import com.eternalcode.core.configuration.ReloadableConfig;
5+
import com.eternalcode.core.configuration.compatibility.ConfigurationCompatibilityV21_2;
46
import com.eternalcode.core.injector.DependencyInjector;
57
import com.eternalcode.core.injector.annotations.component.Component;
68
import com.eternalcode.core.injector.annotations.component.ConfigurationFile;
@@ -78,6 +80,8 @@ public EternalCore(Plugin plugin) {
7880
beanFactory.addCandidate(beanCandidate);
7981
}
8082

83+
beanFactory.initializeCandidates(ConfigurationCompatibilityV21_2.class); // TODO: Remove this when the cdn will be fixed
84+
beanFactory.initializeCandidates(ReloadableConfig.class); // TODO: Remove this when the cdn will be fixed
8185
beanFactory.initializeCandidates();
8286

8387
this.publisher = beanFactory.getDependency(Publisher.class);

eternalcore-core/src/main/java/com/eternalcode/core/configuration/compatibility/ConfigurationCompatibilityV21_2.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,10 @@
77
import com.eternalcode.core.injector.annotations.component.Controller;
88
import com.eternalcode.core.publish.Subscribe;
99

10+
// TODO: Make this package private
1011
@Controller
1112
@Compatibility(from = @Version(minor = 21, patch = 2))
12-
class ConfigurationCompatibilityV21_2 {
13+
public class ConfigurationCompatibilityV21_2 {
1314

1415
@Subscribe
1516
void onConfigSettingsSetup(ConfigurationSettingsSetupEvent event) {

eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportSettingsImpl.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public class RandomTeleportSettingsImpl implements RandomTeleportSettings, Migra
3131
"# If you want to use a static radius, set the type to STATIC_RADIUS and set the radius here.",
3232
"# If you using WORLD_BORDER_RADIUS, this value will be ignored."
3333
})
34-
public RandomTeleportRadiusConfig radius = new RandomTeleportRadiusConfig(5000, 5000, 5000, 5000);
34+
public RandomTeleportRadiusConfig radius = new RandomTeleportRadiusConfig(-5000, 5000, -5000, 5000);
3535
@Deprecated public Integer randomTeleportRadius = null;
3636

3737
@Description("# Teleport to a specific world, if left empty it will teleport to the player's current world")

eternalcore-core/src/main/java/com/eternalcode/core/feature/randomteleport/RandomTeleportTaskService.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,9 @@ class RandomTeleportTaskService {
4242

4343
CompletableFuture<RandomTeleportResult> createTeleport(Player player) {
4444
World world = resolveWorld(player, randomTeleportSettings);
45-
RandomTeleportRadius radius = this.randomTeleportSettings.radius();
4645
return this.randomTeleportSafeLocationService.getSafeRandomLocation(
4746
world,
48-
radius,
47+
this.randomTeleportSettings.radius(),
4948
this.randomTeleportSettings.teleportAttempts()
5049
).thenCompose(location -> this.createTeleport(player, location));
5150
}

eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyBeanCandidate.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@ public LazyBeanCandidate(String name, Supplier<Object> instanceSupplier) {
1515

1616
@Override
1717
public boolean isCandidate(Class<?> clazz) {
18-
Class<?> type = this.getInstance().getClass();
19-
20-
return clazz.isAssignableFrom(type);
18+
return clazz.isAssignableFrom(getType());
2119
}
2220

2321
@Override

eternalcore-core/src/main/java/com/eternalcode/core/injector/bean/LazyFieldBeanCandidate.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ public LazyFieldBeanCandidate(Supplier<Object> instance, Field field, Bean bean)
2828
}
2929

3030
public LazyFieldBeanCandidate(DependencyInjector dependencyInjector, Class<?> componentClass, Field field, Bean bean) {
31-
this(() -> dependencyInjector.newInstance(componentClass), field, bean);
31+
this(() -> dependencyInjector.getDependencyProvider().getDependency(componentClass), field, bean);
3232
}
3333

3434
@Override

0 commit comments

Comments
 (0)