Prevents teleportation of a leashed creature with a passenger

This commit is contained in:
2021-11-25 03:54:09 +01:00
parent f92fd2de5d
commit b2bb995d7e
2 changed files with 15 additions and 6 deletions

View File

@ -257,15 +257,22 @@ public abstract class Teleporter {
* @return <p>False if the player has leashed any creatures that cannot go through the portal</p>
*/
public static boolean noLeashedCreaturesPreventTeleportation(Player player) {
//Find any nearby leashed entities to teleport with the player
List<Creature> nearbyCreatures = getLeashedCreatures(player);
//Disallow creatures with passengers to prevent smuggling
for (Creature creature : nearbyCreatures) {
if (!creature.getPassengers().isEmpty()) {
return false;
}
}
//If it's enabled, there is no problem
if (Stargate.getGateConfig().handleLeashedCreatures()) {
return true;
} else {
return nearbyCreatures.isEmpty();
}
//Find any nearby leashed entities to teleport with the player
List<Creature> nearbyEntities = getLeashedCreatures(player);
return nearbyEntities.isEmpty();
}
/**