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

This commit is contained in:
Kristian Knarvik 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

View File

@ -9,6 +9,7 @@
# language - The language file to load for messages
# rememberDestination - Whether to remember the cursor location between uses
# handleVehicles - Whether to allow vehicles through gates
# handleLeashedCreatures - Whether to allow creatures lead by a player to teleport with the player
# sortNetworkDestinations - Whether to sort network lists alphabetically
# protectEntrance - Whether to protect gate entrance material (More resource intensive. Only enable if using destroyable open/closed material)
# mainSignColor - The color used for drawing signs (Default: BLACK).
@ -49,6 +50,7 @@ gates:
functionality:
enableBungee: false
handleVehicles: true
handleLeashedCreatures: true
economy:
useEconomy: false
createCost: 0