[Feature] Add config optn. to disable jail free tp

Adds the teleport-back-when-freed-from-jail configuration option. When
set to true (default), as with previous versions will teleport the
player which was jailed back to their previous position when freed. When
false, Essentials will not teleport the player anywhere, leaving them
where they are.

Closes #1947
This commit is contained in:
Joseph Hirschfeld 2018-04-01 22:37:19 -04:00
parent b2a5280971
commit 70387f73f6
No known key found for this signature in database
GPG Key ID: 0F2D193B0EC71954
4 changed files with 24 additions and 5 deletions

View File

@ -306,4 +306,6 @@ public interface ISettings extends IConf {
List<String> getDefaultEnabledConfirmCommands();
boolean isConfirmCommandEnabledByDefault(String commandName);
boolean isTeleportBackWhenFreedFromJail();
}

View File

@ -533,6 +533,7 @@ public class Settings implements net.ess3.api.ISettings {
currencyFormat = _getCurrencyFormat();
unprotectedSigns = _getUnprotectedSign();
defaultEnabledConfirmCommands = _getDefaultEnabledConfirmCommands();
teleportBackWhenFreedFromJail = _isTeleportBackWhenFreedFromJail();
}
private List<Integer> itemSpawnBl = new ArrayList<Integer>();
@ -1439,4 +1440,15 @@ public class Settings implements net.ess3.api.ISettings {
public boolean isConfirmCommandEnabledByDefault(String commandName) {
return getDefaultEnabledConfirmCommands().contains(commandName.toLowerCase());
}
private boolean teleportBackWhenFreedFromJail;
private boolean _isTeleportBackWhenFreedFromJail() {
return config.getBoolean("teleport-back-when-freed-from-jail", true);
}
@Override
public boolean isTeleportBackWhenFreedFromJail() {
return teleportBackWhenFreedFromJail;
}
}

View File

@ -514,12 +514,14 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
setJailed(false);
sendMessage(tl("haveBeenReleased"));
setJail(null);
try {
getTeleport().back();
} catch (Exception ex) {
if (ess.getSettings().isTeleportBackWhenFreedFromJail()) {
try {
getTeleport().respawn(null, TeleportCause.PLUGIN);
} catch (Exception ex1) {
getTeleport().back();
} catch (Exception ex) {
try {
getTeleport().respawn(null, TeleportCause.PLUGIN);
} catch (Exception ex1) {
}
}
}
return true;

View File

@ -522,6 +522,9 @@ default-enabled-confirm-commands:
#- pay
#- clearinventory
# Whether or not to teleport a player back to their previous position after they have been freed from jail.
teleport-back-when-freed-from-jail: true
############################################################
# +------------------------------------------------------+ #
# | EssentialsHome | #