Adds a config option to disable leashed creatures from teleporting with a player

This commit is contained in:
2021-11-01 18:44:10 +01:00
parent 20c3c93c06
commit aff0082906
3 changed files with 18 additions and 1 deletions

View File

@ -13,6 +13,7 @@ public final class StargateGateConfig {
private int maxGatesEachNetwork = 0;
private boolean rememberDestination = false;
private boolean handleVehicles = true;
private boolean handleLeashedCreatures = true;
private boolean sortNetworkDestinations = false;
private boolean protectEntrance = false;
private boolean enableBungee = true;
@ -76,6 +77,15 @@ public final class StargateGateConfig {
return handleVehicles;
}
/**
* Gets whether leashed creatures should be teleported with a teleporting player
*
* @return <p>Whether leashed creatures should be handled</p>
*/
public boolean handleLeashedCreatures() {
return handleLeashedCreatures;
}
/**
* Gets whether the list of destinations within a network should be sorted
*
@ -142,6 +152,7 @@ public final class StargateGateConfig {
//Functionality
handleVehicles = newConfig.getBoolean("gates.functionality.handleVehicles");
handleLeashedCreatures = newConfig.getBoolean("gates.functionality.handleLeashedCreatures");
enableBungee = newConfig.getBoolean("gates.functionality.enableBungee");
//Integrity
@ -173,5 +184,4 @@ public final class StargateGateConfig {
Stargate.logWarning("You have specified an invalid color in your config.yml. Defaulting to BLACK and WHITE");
PortalSignDrawer.setColors(ChatColor.BLACK, ChatColor.WHITE);
}
}

View File

@ -256,6 +256,11 @@ public abstract class Teleporter {
* @param origin <p>The portal the player is teleporting from</p>
*/
protected void teleportLeashedCreatures(Player player, Portal origin) {
//If this feature is disabled, just return
if (!Stargate.getGateConfig().handleLeashedCreatures()) {
return;
}
//Find any nearby leashed entities to teleport with the player
List<Creature> nearbyEntities = getLeashedCreatures(player);
//Teleport all creatures leashed by the player to the portal the player is to exit from