Skip to content

Commit 3a9eb88

Browse files
authored
Merge pull request #3151 from Multiverse/ben/mv5/block-safety
ben/mv5/block-safety
2 parents 03dc8e4 + d83d6c6 commit 3a9eb88

File tree

13 files changed

+464
-28
lines changed

13 files changed

+464
-28
lines changed

src/main/java/org/mvplugins/multiverse/core/api/BlockSafety.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
/**
1111
* Used to get block/location-related information.
1212
*/
13+
@Deprecated
1314
@Contract
1415
public interface BlockSafety {
1516
/**

src/main/java/org/mvplugins/multiverse/core/api/MVConfig.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,14 @@ public interface MVConfig {
112112
*/
113113
void setFirstSpawnOverride(boolean firstSpawnOverride);
114114

115+
void setSafeLocationHorizontalSearchRadius(int searchRadius);
116+
117+
int getSafeLocationHorizontalSearchRadius();
118+
119+
void setSafeLocationVerticalSearchRadius(int searchRadius);
120+
121+
int getSafeLocationVerticalSearchRadius();
122+
115123
/**
116124
* Gets firstSpawnOverride.
117125
* @return firstSpawnOverride.

src/main/java/org/mvplugins/multiverse/core/config/MVCoreConfig.java

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,26 @@ public void setFirstSpawnOverride(boolean firstSpawnOverride) {
189189
configHandle.set(configNodes.FIRST_SPAWN_OVERRIDE, firstSpawnOverride);
190190
}
191191

192+
@Override
193+
public void setSafeLocationHorizontalSearchRadius(int searchRadius) {
194+
configHandle.set(configNodes.SAFE_LOCATION_HORIZONTAL_SEARCH_RADIUS, searchRadius);
195+
}
196+
197+
@Override
198+
public int getSafeLocationHorizontalSearchRadius() {
199+
return configHandle.get(configNodes.SAFE_LOCATION_HORIZONTAL_SEARCH_RADIUS);
200+
}
201+
202+
@Override
203+
public void setSafeLocationVerticalSearchRadius(int searchRadius) {
204+
configHandle.set(configNodes.SAFE_LOCATION_VERTICAL_SEARCH_RADIUS, searchRadius);
205+
}
206+
207+
@Override
208+
public int getSafeLocationVerticalSearchRadius() {
209+
return configHandle.get(configNodes.SAFE_LOCATION_VERTICAL_SEARCH_RADIUS);
210+
}
211+
192212
@Override
193213
public boolean getFirstSpawnOverride() {
194214
return configHandle.get(configNodes.FIRST_SPAWN_OVERRIDE);

src/main/java/org/mvplugins/multiverse/core/config/MVCoreConfigNodes.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -130,6 +130,24 @@ private <N extends Node> N node(N node) {
130130
.name("teleport-intercept")
131131
.build());
132132

133+
final ConfigNode<Integer> SAFE_LOCATION_HORIZONTAL_SEARCH_RADIUS = node(ConfigNode.builder("teleport.safe-location-horizontal-search-radius", Integer.class)
134+
.comment("")
135+
.comment("Sets the horizontal (x and z-axis) search radius for finding a safe location to teleport to.")
136+
.comment("Increasing this value will widen the search area at the cost of performance.")
137+
.comment("To disable, set to 0.")
138+
.defaultValue(3)
139+
.name("safe-location-horizontal-search-radius")
140+
.build());
141+
142+
final ConfigNode<Integer> SAFE_LOCATION_VERTICAL_SEARCH_RADIUS = node(ConfigNode.builder("teleport.safe-location-vertical-search-radius", Integer.class)
143+
.comment("")
144+
.comment("Sets the vertical (y-axis) search radius for finding a safe location to teleport to.")
145+
.comment("Increasing this value will widen the search area at the cost of performance.")
146+
.comment("To disable, set to 0.")
147+
.defaultValue(3)
148+
.name("safe-location-vertical-search-radius")
149+
.build());
150+
133151
private final ConfigHeaderNode SPAWN_HEADER = node(ConfigHeaderNode.builder("spawn")
134152
.comment("")
135153
.comment("")

src/main/java/org/mvplugins/multiverse/core/listeners/MVPlayerListener.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
package org.mvplugins.multiverse.core.listeners;
99

1010
import java.util.Map;
11-
import java.util.Optional;
1211
import java.util.concurrent.ConcurrentHashMap;
1312

1413
import com.dumptruckman.minecraft.util.Logging;
@@ -24,22 +23,20 @@
2423
import org.bukkit.event.EventHandler;
2524
import org.bukkit.event.EventPriority;
2625
import org.bukkit.event.player.PlayerChangedWorldEvent;
27-
import org.bukkit.event.player.PlayerJoinEvent;
2826
import org.bukkit.event.player.PlayerPortalEvent;
2927
import org.bukkit.event.player.PlayerRespawnEvent;
3028
import org.bukkit.event.player.PlayerTeleportEvent;
3129
import org.bukkit.plugin.Plugin;
32-
import org.jetbrains.annotations.NotNull;
3330
import org.jvnet.hk2.annotations.Service;
3431

3532
import org.mvplugins.multiverse.core.MultiverseCore;
36-
import org.mvplugins.multiverse.core.api.BlockSafety;
3733
import org.mvplugins.multiverse.core.commandtools.MVCommandManager;
3834
import org.mvplugins.multiverse.core.config.MVCoreConfig;
3935
import org.mvplugins.multiverse.core.destination.DestinationInstance;
4036
import org.mvplugins.multiverse.core.destination.DestinationsProvider;
4137
import org.mvplugins.multiverse.core.economy.MVEconomist;
4238
import org.mvplugins.multiverse.core.event.MVRespawnEvent;
39+
import org.mvplugins.multiverse.core.teleportation.AdvancedBlockSafety;
4340
import org.mvplugins.multiverse.core.teleportation.AsyncSafetyTeleporter;
4441
import org.mvplugins.multiverse.core.teleportation.TeleportQueue;
4542
import org.mvplugins.multiverse.core.utils.result.ResultChain;
@@ -58,7 +55,7 @@ public class MVPlayerListener implements CoreListener {
5855
private final Plugin plugin;
5956
private final MVCoreConfig config;
6057
private final Provider<WorldManager> worldManagerProvider;
61-
private final BlockSafety blockSafety;
58+
private final AdvancedBlockSafety blockSafety;
6259
private final AsyncSafetyTeleporter safetyTeleporter;
6360
private final Server server;
6461
private final TeleportQueue teleportQueue;
@@ -75,7 +72,7 @@ public class MVPlayerListener implements CoreListener {
7572
MultiverseCore plugin,
7673
MVCoreConfig config,
7774
Provider<WorldManager> worldManagerProvider,
78-
BlockSafety blockSafety,
75+
AdvancedBlockSafety blockSafety,
7976
AsyncSafetyTeleporter safetyTeleporter,
8077
Server server,
8178
TeleportQueue teleportQueue,
@@ -317,6 +314,7 @@ public void playerPortalCheck(PlayerPortalEvent event) {
317314
return;
318315
}
319316
}
317+
320318
/**
321319
* This method is called when a player actually portals via a vanilla style portal.
322320
* @param event The Event that was fired.

0 commit comments

Comments
 (0)