mirror of
https://github.com/Multiverse/Multiverse-Core.git
synced 2024-11-25 20:16:06 +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();
|
String getFirstSpawnLocation();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets alwaysSpawnDestination
|
* Sets whether join destination should be enabled.
|
||||||
* @param alwaysSpawnWorld The new value
|
* @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
|
* @return alwaysSpawnLocation
|
||||||
*/
|
*/
|
||||||
String getJoinDestination();
|
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.
|
* 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
|
@Override
|
||||||
public void setJoinDestination(String alwaysSpawnWorld) {
|
public void setEnableJoinDestination(boolean enableJoinDestination) {
|
||||||
configHandle.set(configNodes.JOIN_DESTINATION, alwaysSpawnWorld);
|
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
|
@Override
|
||||||
@ -196,16 +206,6 @@ public class MVCoreConfig implements MVConfig {
|
|||||||
return configHandle.get(configNodes.JOIN_DESTINATION);
|
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
|
@Override
|
||||||
public void setUseCustomPortalSearch(boolean useDefaultPortalSearch) {
|
public void setUseCustomPortalSearch(boolean useDefaultPortalSearch) {
|
||||||
configHandle.set(configNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch);
|
configHandle.set(configNodes.USE_CUSTOM_PORTAL_SEARCH, useDefaultPortalSearch);
|
||||||
|
@ -120,14 +120,14 @@ class MVCoreConfigNodes {
|
|||||||
.name("first-spawn-location")
|
.name("first-spawn-location")
|
||||||
.build());
|
.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("")
|
||||||
.comment("Enables always-spawn-destination")
|
.comment("Enables join-destination below.")
|
||||||
.defaultValue(false)
|
.defaultValue(false)
|
||||||
.name("enable-join-destination")
|
.name("enable-join-destination")
|
||||||
.build());
|
.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("")
|
||||||
.comment("Sets the destination that Multiverse will use to spawn players on every login")
|
.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")
|
.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 Plugin plugin;
|
||||||
private final MVCoreConfig config;
|
private final MVCoreConfig config;
|
||||||
private final Provider<WorldManager> worldManagerProvider;
|
private final Provider<WorldManager> worldManagerProvider;
|
||||||
private final SafeTTeleporter safeTTeleporter;
|
private final SafeTTeleporter safetyTeleporter;
|
||||||
private final Server server;
|
private final Server server;
|
||||||
private final TeleportQueue teleportQueue;
|
private final TeleportQueue teleportQueue;
|
||||||
private final MVEconomist economist;
|
private final MVEconomist economist;
|
||||||
@ -74,7 +74,7 @@ public class MVPlayerListener implements InjectableListener {
|
|||||||
MultiverseCore plugin,
|
MultiverseCore plugin,
|
||||||
MVCoreConfig config,
|
MVCoreConfig config,
|
||||||
Provider<WorldManager> worldManagerProvider,
|
Provider<WorldManager> worldManagerProvider,
|
||||||
SafeTTeleporter safeTTeleporter,
|
SafeTTeleporter safetyTeleporter,
|
||||||
Server server,
|
Server server,
|
||||||
TeleportQueue teleportQueue,
|
TeleportQueue teleportQueue,
|
||||||
MVEconomist economist,
|
MVEconomist economist,
|
||||||
@ -85,7 +85,7 @@ public class MVPlayerListener implements InjectableListener {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = config;
|
this.config = config;
|
||||||
this.worldManagerProvider = worldManagerProvider;
|
this.worldManagerProvider = worldManagerProvider;
|
||||||
this.safeTTeleporter = safeTTeleporter;
|
this.safetyTeleporter = safetyTeleporter;
|
||||||
this.server = server;
|
this.server = server;
|
||||||
this.teleportQueue = teleportQueue;
|
this.teleportQueue = teleportQueue;
|
||||||
this.economist = economist;
|
this.economist = economist;
|
||||||
@ -212,14 +212,8 @@ public class MVPlayerListener implements InjectableListener {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Location joinDestinationLocation = joinDestination.getLocation(player);
|
|
||||||
if (joinDestinationLocation == null) {
|
|
||||||
Logging.finer("Not teleporting " + player.getName() + " because joinDestination is null");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Finally, teleport the player
|
// 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!!!
|
// REMEMBER! getTo MAY be NULL HERE!!!
|
||||||
// If the player was actually outside of the portal, adjust the from location
|
// If the player was actually outside of the portal, adjust the from location
|
||||||
if (event.getFrom().getWorld().getBlockAt(event.getFrom()).getType() != Material.NETHER_PORTAL) {
|
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: Fix this. Currently, we only check for PORTAL blocks. I'll have to figure out what
|
||||||
// TODO: we want to do here.
|
// TODO: we want to do here.
|
||||||
if (newloc != null) {
|
if (newloc != null) {
|
||||||
@ -360,7 +354,7 @@ public class MVPlayerListener implements InjectableListener {
|
|||||||
new Runnable() {
|
new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
safeTTeleporter.safelyTeleportAsync(getCommandManager().getCommandIssuer(player), player, parsedDestination);
|
safetyTeleporter.safelyTeleportAsync(getCommandManager().getCommandIssuer(player), player, parsedDestination);
|
||||||
}
|
}
|
||||||
}, 1L);
|
}, 1L);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user