Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.eternalcode.core.configuration.AbstractConfigurationFile;
import com.eternalcode.core.database.DatabaseConfig;
import com.eternalcode.core.database.DatabaseSettings;
import com.eternalcode.core.feature.teleport.settings.TeleportConfig;
import com.eternalcode.core.feature.teleport.settings.TeleportSettings;
import com.eternalcode.core.util.date.DateConfig;
import com.eternalcode.core.util.date.DateSettings;
import com.eternalcode.core.feature.afk.AfkConfig;
Expand Down Expand Up @@ -137,6 +139,12 @@ public class PluginConfiguration extends AbstractConfigurationFile {
@Comment("# Settings for player home management")
HomesConfig homes = new HomesConfig();

@Bean(proxied = TeleportSettings.class)
@Comment("")
@Comment("# Teleport configuration")
@Comment("# Settings for teleportation task")
TeleportConfig teleport = new TeleportConfig();

@Bean(proxied = ChatSettings.class)
@Comment("")
@Comment("# Chat Configuration")
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.eternalcode.core.feature.teleport;

import com.eternalcode.commons.bukkit.position.PositionAdapter;
import com.eternalcode.core.feature.teleport.settings.TeleportSettings;
import com.eternalcode.core.injector.annotations.Inject;
import com.eternalcode.core.injector.annotations.component.Task;
import com.eternalcode.core.notice.NoticeService;
Expand All @@ -25,18 +26,21 @@ class TeleportTask implements Runnable {
private final NoticeService noticeService;
private final TeleportTaskService teleportTaskService;
private final TeleportService teleportService;
private final TeleportSettings teleportSettings;
private final Server server;

@Inject
TeleportTask(
NoticeService noticeService,
TeleportTaskService teleportTaskService,
TeleportService teleportService,
TeleportSettings teleportSettings,
Server server
) {
this.noticeService = noticeService;
this.teleportTaskService = teleportTaskService;
this.teleportService = teleportService;
this.teleportSettings = teleportSettings;
this.server = server;
}

Expand All @@ -54,7 +58,7 @@ public void run() {
continue;
}

if (this.hasPlayerMovedDuringTeleport(player, teleport)) {
if (this.teleportSettings.movementCancelsTeleport() && this.hasPlayerMovedDuringTeleport(player, teleport)) {
this.teleportTaskService.removeTeleport(uuid);
teleport.completeResult(TeleportResult.MOVED_DURING_TELEPORT);

Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
package com.eternalcode.core.feature.teleport.settings;

import eu.okaeri.configs.OkaeriConfig;
import eu.okaeri.configs.annotation.Comment;
import lombok.Getter;
import lombok.experimental.Accessors;

@Getter
@Accessors(fluent = true)
public class TeleportConfig extends OkaeriConfig implements TeleportSettings {

@Comment({
"# If true, the teleportation will be cancelled if the player moves during the teleportation process."
})
public boolean movementCancelsTeleport = true;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.eternalcode.core.feature.teleport.settings;

public interface TeleportSettings {
boolean movementCancelsTeleport();
}