mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-22 02:25:41 +01:00
Refactor join-destination config and use async teleport
This commit is contained in:
parent
dc3ec52d74
commit
b78941c0a0
@ -127,29 +127,29 @@ public interface MVConfig {
|
||||
String getFirstSpawnLocation();
|
||||
|
||||
/**
|
||||
* Sets alwaysSpawnDestination
|
||||
* @param alwaysSpawnWorld The new value
|
||||
* Sets whether join destination should be enabled.
|
||||
* @param enableJoinDestination The new value
|
||||
*/
|
||||
void setJoinDestination(String alwaysSpawnWorld);
|
||||
void setEnableJoinDestination(boolean enableJoinDestination);
|
||||
|
||||
/**
|
||||
* Gets alwaysSpawnDestination
|
||||
* Gets enableJoinDestination.
|
||||
* @return enableJoinDestination
|
||||
*/
|
||||
boolean getEnableJoinDestination();
|
||||
|
||||
/**
|
||||
* Sets alwaysSpawnDestination.
|
||||
* @param alwaysSpawnDestination The new value
|
||||
*/
|
||||
void setJoinDestination(String alwaysSpawnDestination);
|
||||
|
||||
/**
|
||||
* Gets alwaysSpawnDestination.
|
||||
* @return alwaysSpawnLocation
|
||||
*/
|
||||
String getJoinDestination();
|
||||
|
||||
/**
|
||||
* Sets alwaysSpawnDestination
|
||||
* @param enableAlwaysSpawnDestination The new value
|
||||
*/
|
||||
void setEnableJoinDestination(boolean enableAlwaysSpawnDestination);
|
||||
|
||||
/**
|
||||
* Gets enableAlwaysSpawnDestination
|
||||
* @return enableAlwaysSpawnDestination
|
||||
*/
|
||||
boolean getEnableJoinDestination();
|
||||
|
||||
/**
|
||||
* Sets whether or not to let Bukkit determine portal search radius on its own or if Multiverse should give input.
|
||||
*
|
||||
|
@ -183,8 +183,18 @@ public class MVCoreConfig implements MVConfig {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJoinDestination(String alwaysSpawnWorld) {
|
||||
configHandle.set(configNodes.JOIN_DESTINATION, alwaysSpawnWorld);
|
||||
public void setEnableJoinDestination(boolean enableJoinDestination) {
|
||||
configHandle.set(configNodes.ENABLE_JOIN_DESTINATION, enableJoinDestination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableJoinDestination() {
|
||||
return configHandle.get(configNodes.ENABLE_JOIN_DESTINATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setJoinDestination(String alwaysSpawnDestination) {
|
||||
configHandle.set(configNodes.JOIN_DESTINATION, alwaysSpawnDestination);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -196,16 +206,6 @@ public class MVCoreConfig implements MVConfig {
|
||||
return configHandle.get(configNodes.JOIN_DESTINATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setEnableJoinDestination(boolean enableJoinDestination) {
|
||||
configHandle.set(configNodes.ENABLE_JOIN_DESTINATION, enableJoinDestination);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean getEnableJoinDestination() {
|
||||
return configHandle.get(configNodes.ENABLE_JOIN_DESTINATION);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setUseCustomPortalSearch(boolean useDefaultPortalSearch) {
|
||||
configHandle.set(configNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch);
|
||||
|
@ -120,14 +120,14 @@ class MVCoreConfigNodes {
|
||||
.name("first-spawn-location")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<Boolean> ENABLE_JOIN_DESTINATION = node(ConfigNode.builder("spawn.enable-join-destination", Boolean.class)
|
||||
final ConfigNode<Boolean> ENABLE_JOIN_DESTINATION = node(ConfigNode.builder("spawn.enable-join-destination", Boolean.class)
|
||||
.comment("")
|
||||
.comment("Enables always-spawn-destination")
|
||||
.comment("Enables join-destination below.")
|
||||
.defaultValue(false)
|
||||
.name("enable-join-destination")
|
||||
.build());
|
||||
|
||||
public final ConfigNode<String> JOIN_DESTINATION = node(ConfigNode.builder("spawn.join-destination", String.class)
|
||||
final ConfigNode<String> JOIN_DESTINATION = node(ConfigNode.builder("spawn.join-destination", String.class)
|
||||
.comment("")
|
||||
.comment("Sets the destination that Multiverse will use to spawn players on every login")
|
||||
.comment("Set the above enable-join-destination to false to disable")
|
||||
|
@ -58,7 +58,7 @@ public class MVPlayerListener implements InjectableListener {
|
||||
private final Plugin plugin;
|
||||
private final MVCoreConfig config;
|
||||
private final Provider<WorldManager> worldManagerProvider;
|
||||
private final SafeTTeleporter safeTTeleporter;
|
||||
private final SafeTTeleporter safetyTeleporter;
|
||||
private final Server server;
|
||||
private final TeleportQueue teleportQueue;
|
||||
private final MVEconomist economist;
|
||||
@ -74,7 +74,7 @@ public class MVPlayerListener implements InjectableListener {
|
||||
MultiverseCore plugin,
|
||||
MVCoreConfig config,
|
||||
Provider<WorldManager> worldManagerProvider,
|
||||
SafeTTeleporter safeTTeleporter,
|
||||
SafeTTeleporter safetyTeleporter,
|
||||
Server server,
|
||||
TeleportQueue teleportQueue,
|
||||
MVEconomist economist,
|
||||
@ -85,7 +85,7 @@ public class MVPlayerListener implements InjectableListener {
|
||||
this.plugin = plugin;
|
||||
this.config = config;
|
||||
this.worldManagerProvider = worldManagerProvider;
|
||||
this.safeTTeleporter = safeTTeleporter;
|
||||
this.safetyTeleporter = safetyTeleporter;
|
||||
this.server = server;
|
||||
this.teleportQueue = teleportQueue;
|
||||
this.economist = economist;
|
||||
@ -212,14 +212,8 @@ public class MVPlayerListener implements InjectableListener {
|
||||
return;
|
||||
}
|
||||
|
||||
Location joinDestinationLocation = joinDestination.getLocation(player);
|
||||
if (joinDestinationLocation == null) {
|
||||
Logging.finer("Not teleporting " + player.getName() + " because joinDestination is null");
|
||||
return;
|
||||
}
|
||||
|
||||
// Finally, teleport the player
|
||||
player.teleport(joinDestinationLocation);
|
||||
safetyTeleporter.teleportAsync(getCommandManager().getCommandIssuer(player), player, joinDestination);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -308,7 +302,7 @@ public class MVPlayerListener implements InjectableListener {
|
||||
// REMEMBER! getTo MAY be NULL HERE!!!
|
||||
// If the player was actually outside of the portal, adjust the from location
|
||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.NETHER_PORTAL) {
|
||||
Location newloc = this.safeTTeleporter.findPortalBlockNextTo(event.getFrom());
|
||||
Location newloc = this.safetyTeleporter.findPortalBlockNextTo(event.getFrom());
|
||||
// TODO: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
||||
// TODO: we want to do here.
|
||||
if (newloc != null) {
|
||||
@ -360,7 +354,7 @@ public class MVPlayerListener implements InjectableListener {
|
||||
new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
safeTTeleporter.safelyTeleportAsync(getCommandManager().getCommandIssuer(player), player, parsedDestination);
|
||||
safetyTeleporter.safelyTeleportAsync(getCommandManager().getCommandIssuer(player), player, parsedDestination);
|
||||
}
|
||||
}, 1L);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user