From 7d8d9d895933cca5254ea005b47c3d3b04787506 Mon Sep 17 00:00:00 2001 From: Joshua Popoff Date: Thu, 12 Dec 2013 22:03:15 -0800 Subject: Add the ability to disable teleport safety. Requested by a few people - teleport safety isn't always a good thing for some servers. Request is cancelled if not safe. --- Essentials/src/com/earth2me/essentials/ISettings.java | 2 ++ Essentials/src/com/earth2me/essentials/Settings.java | 14 ++++++++++++++ Essentials/src/com/earth2me/essentials/Teleport.java | 11 ++++++++++- Essentials/src/config.yml | 4 ++++ Essentials/src/messages.properties | 1 + Essentials/src/messages_cs.properties | 1 + Essentials/src/messages_da.properties | 1 + Essentials/src/messages_de.properties | 1 + Essentials/src/messages_en.properties | 1 + Essentials/src/messages_es.properties | 1 + Essentials/src/messages_fi.properties | 1 + Essentials/src/messages_fr.properties | 1 + Essentials/src/messages_hu.properties | 1 + Essentials/src/messages_it.properties | 1 + Essentials/src/messages_lt.properties | 1 + Essentials/src/messages_nl.properties | 1 + Essentials/src/messages_pl.properties | 1 + Essentials/src/messages_pt.properties | 1 + Essentials/src/messages_ro.properties | 1 + Essentials/src/messages_ru.properties | 2 +- Essentials/src/messages_sv.properties | 1 + Essentials/src/messages_tr.properties | 1 + Essentials/src/messages_zh.properties | 1 + Essentials/src/messages_zh_HK.properties | 1 + Essentials/src/messages_zh_TW.properties | 1 + 25 files changed, 51 insertions(+), 2 deletions(-) diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 96962ee3a..b48cf7d91 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -80,6 +80,8 @@ public interface ISettings extends IConf BigDecimal getStartingBalance(); + boolean isTeleportSafetyEnabled(); + double getTeleportCooldown(); double getTeleportDelay(); diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index 3ce7b9b99..93e245f72 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -95,6 +95,19 @@ public class Settings implements net.ess3.api.ISettings return chatRadius; } + private boolean teleportSafety; + + public boolean _isTeleportSafetyEnabled() + { + return config.getBoolean("teleport-safety", true); + } + + @Override + public boolean isTeleportSafetyEnabled() + { + return teleportSafety; + } + @Override public double getTeleportDelay() { @@ -487,6 +500,7 @@ public class Settings implements net.ess3.api.ISettings config.load(); noGodWorlds = new HashSet(config.getStringList("no-god-in-worlds")); enabledSigns = _getEnabledSigns(); + teleportSafety = _isTeleportSafetyEnabled(); teleportInvulnerabilityTime = _getTeleportInvulnerability(); teleportInvulnerability = _isTeleportInvulnerability(); disableItemPickupWhileAfk = _getDisableItemPickupWhileAfk(); diff --git a/Essentials/src/com/earth2me/essentials/Teleport.java b/Essentials/src/com/earth2me/essentials/Teleport.java index b33db4c4a..82b8f8cf6 100644 --- a/Essentials/src/com/earth2me/essentials/Teleport.java +++ b/Essentials/src/com/earth2me/essentials/Teleport.java @@ -7,6 +7,7 @@ import java.util.Calendar; import java.util.GregorianCalendar; import net.ess3.api.IEssentials; import net.ess3.api.IUser; +import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerRespawnEvent; @@ -96,7 +97,15 @@ public class Teleport implements net.ess3.api.ITeleport { cancel(false); teleportee.setLastLocation(); - teleportee.getBase().teleport(LocationUtil.getSafeDestination(teleportee, target.getLocation()), cause); + Location safeDestination = LocationUtil.getSafeDestination(teleportee, target.getLocation()); + if (ess.getSettings().isTeleportSafetyEnabled() || (target.getLocation().getBlockX() == safeDestination.getBlockX() && target.getLocation().getBlockY() == safeDestination.getBlockY() && target.getLocation().getBlockZ() == safeDestination.getBlockZ())) + { + teleportee.getBase().teleport(safeDestination, cause); + } + else + { + throw new Exception(_("unsafeTeleportDestination")); + } } //The teleportPlayer function is used when you want to normally teleportPlayer someone to a location or player. diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index fa185f1c7..32f867656 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -41,6 +41,10 @@ change-displayname: true # Do not edit this setting unless you know what you are doing! #add-prefix-suffix: false +# Should players be teleported to the closest safe destination when teleporting? +# If this is disabled, unsafe teleports will be cancelled. +teleport-safety: true + # The delay, in seconds, required between /home, /tp, etc. teleport-cooldown: 0 diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index a6abc7b9f..e82036360 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -532,3 +532,4 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_cs.properties b/Essentials/src/messages_cs.properties index f947ef354..433b5205d 100644 --- a/Essentials/src/messages_cs.properties +++ b/Essentials/src/messages_cs.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a7Nemuzes docasne zabanovat hrace, kteri nejsou pripoje mayNotJailOffline=\u00a7Nemuzes uveznit hrace, kteri nejsou pripojeni. muteExemptOffline=\u00a7Nemuzes umlcet hrace, kteri nejsou pripojeni. ignoreExempt=\u00a74Nemuzes ignorovat tohoto hrace. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index 283a13e61..b6495fc1c 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Du kan ikke midlertidigt bandlyse offline spillere. mayNotJailOffline=\u00a74Du kan ikke s\u00e6tte offline spillere i f\u00e6ngsel. muteExemptOffline=\u00a74Du kan ikke g\u00f8re offline spillere tavse. ignoreExempt=\u00a74Du kan ikke ignorere den spiller. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 1e5048223..56b3204e0 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Du darfst abgemeldete Spieler nicht tempor\u00e4r ba mayNotJailOffline=\u00a74Du darfst abgemeldete Spieler nicht einsperren. muteExemptOffline=\u00a74Du darfst abgemeldete Spieler nicht stummschalten. ignoreExempt=\u00a74Du kannst diesen Spieler nicht ignorieren. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 01d016eb5..510c31a58 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You may not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index 9be23f21c..6abbaf5a5 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74No puedes banear temporalmente a jugadores que no es mayNotJailOffline=\u00a74No puedes encarcelar a jugadores que no est\u00e1n conectados. muteExemptOffline=\u00a74No puedes silenciar a jugadores que no est\u00e1n conectados. ignoreExempt=\u00a74No puedes ignorar a este jugador. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_fi.properties b/Essentials/src/messages_fi.properties index 66fbf2780..8e131e130 100644 --- a/Essentials/src/messages_fi.properties +++ b/Essentials/src/messages_fi.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 8cf5ea575..e19368a96 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Vous ne pouvez pas bannir temporairement les joueurs mayNotJailOffline=\u00a74Vous ne pouvez pas emprisonner les joueurs d\u00e9connect\u00e9s. muteExemptOffline=\u00a74Vous ne pouvez pas rendre muets les joueurs d\u00e9connect\u00e9s. ignoreExempt=\u00a74Vous ne pouvez pas ignorer ce joueur. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_hu.properties b/Essentials/src/messages_hu.properties index 4b33cad92..102f7101c 100644 --- a/Essentials/src/messages_hu.properties +++ b/Essentials/src/messages_hu.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Nem tempbannolhatsz Offline j\u00e1t\u00e9kost. mayNotJailOffline=\u00a74Nem b\u00f6rt\u00f6n\u00f6zhetsz be Offline j\u00e1t\u00e9kost. muteExemptOffline=\u00a74Nem n\u00e9m\u00edthatsz le Offline j\u00e1t\u00e9kost. ignoreExempt=\u00a74Nem hagyhatod figyelmen k\u00edv\u0171l ezt a j\u00e1t\u00e9kost. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_it.properties b/Essentials/src/messages_it.properties index 8e3ec8e7d..a71c5f251 100644 --- a/Essentials/src/messages_it.properties +++ b/Essentials/src/messages_it.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Non puoi dare un ban temporaneo ad un giocatore che mayNotJailOffline=\u00a74Non puoi imprigionare un giocatore che e'' offline. muteExemptOffline=\u00a74Non puoi silenziare un giocatore che e'' offline. ignoreExempt=\u00a74Non puoi ignorare quel giocatore. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_lt.properties b/Essentials/src/messages_lt.properties index 527fe8249..f46e75194 100644 --- a/Essentials/src/messages_lt.properties +++ b/Essentials/src/messages_lt.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Tu negali uzblokuoti laikinai neprisijungusiu zaidej mayNotJailOffline=\u00a74Tu negali pasodinti i kalejima neprisijungusiu zaideju. muteExemptOffline=\u00a74Tu negali uztildyti neprisijungusiu zaideju. ignoreExempt=\u00a74Tu negali ignoruoti sio zaidejo. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index 31402033b..07ec1eddf 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Je mag geen offline players tijdelijk bannen mayNotJailOffline=\u00a74Je mag geen offline spelers in de gevangenis zetten. muteExemptOffline=\u00a74Je mag geen offline players dempen ignoreExempt=\u00a74Je kan die speler niet negeren. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_pl.properties b/Essentials/src/messages_pl.properties index a4499f50d..10d7a1cc1 100644 --- a/Essentials/src/messages_pl.properties +++ b/Essentials/src/messages_pl.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Nie mozesz tymczasowo zablokowac graczy offline. mayNotJailOffline=\u00a74Nie mozesz wrzucic do wiezienia graczy offline. muteExemptOffline=\u00a74Nie mozesz wyciszyc graczy offline. ignoreExempt=\u00a74Nie mozesz ignorowac tego gracza. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_pt.properties b/Essentials/src/messages_pt.properties index 947024577..a7e2f61fb 100644 --- a/Essentials/src/messages_pt.properties +++ b/Essentials/src/messages_pt.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74Voce nao pode banir temporariamente jogadores descon mayNotJailOffline=\u00a74Voce nao pode prender jogadores desconectados. muteExemptOffline=\u00a74Voce nao pode silenciar jogadores desconectados. ignoreExempt=\u00a74Voce nao pode ignorar aquele jogador. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_ro.properties b/Essentials/src/messages_ro.properties index 9ff9b9454..f5bacbc16 100644 --- a/Essentials/src/messages_ro.properties +++ b/Essentials/src/messages_ro.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_ru.properties b/Essentials/src/messages_ru.properties index b99123377..b4f6e8475 100644 --- a/Essentials/src/messages_ru.properties +++ b/Essentials/src/messages_ru.properties @@ -532,4 +532,4 @@ tempbanExemptOffline=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u mayNotJailOffline=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u043f\u043e\u0441\u0430\u0434\u0438\u0442\u044c \u0432 \u0442\u044e\u0440\u044c\u043c\u0443 \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u043e\u0444\u0444\u043b\u0430\u0439\u043d\u0435. muteExemptOffline=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0437\u0430\u0442\u043a\u043d\u0443\u0442\u044c \u0438\u0433\u0440\u043e\u043a\u0430 \u0432 \u043e\u0444\u0444\u043b\u0430\u0439\u043d\u0435. ignoreExempt=\u00a74\u0412\u044b \u043d\u0435 \u043c\u043e\u0436\u0435\u0442\u0435 \u0438\u0433\u043d\u043e\u0440\u0438\u0440\u043e\u0432\u0430\u0442\u044c \u044d\u0442\u043e\u0433\u043e \u0438\u0433\u0440\u043e\u043a\u0430. - +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_sv.properties b/Essentials/src/messages_sv.properties index 223175815..ba16d4eb8 100644 --- a/Essentials/src/messages_sv.properties +++ b/Essentials/src/messages_sv.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74YOU kan inte tempor\u00e4rt banna urkopplad spelare. mayNotJailOffline=\u00a74DU kan inte f\u00e4ngelse urkopplad-spelare. muteExemptOffline=\u00a74DU kan inte st\u00e4nga av urkopplad-spelare. ignoreExempt=\u00a74DU kan inte ignorera den spelaren. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_tr.properties b/Essentials/src/messages_tr.properties index 997d4126a..ad6cd42e4 100644 --- a/Essentials/src/messages_tr.properties +++ b/Essentials/src/messages_tr.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_zh.properties b/Essentials/src/messages_zh.properties index af238c05b..38ea0106e 100644 --- a/Essentials/src/messages_zh.properties +++ b/Essentials/src/messages_zh.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74\u4f60\u53ef\u80fd\u65e0\u6cd5\u4e34\u65f6\u5c01\u79 mayNotJailOffline=\u00a74\u4f60\u53ef\u80fd\u65e0\u6cd5\u76d1\u7981\u5df2\u79bb\u7ebf\u73a9\u5bb6. muteExemptOffline=\u00a74\u4f60\u53ef\u80fd\u65e0\u6cd5\u7981\u8a00\u5df2\u79bb\u7ebf\u73a9\u5bb6. ignoreExempt=\u00a74\u4f60\u65e0\u6cd5\u5ffd\u7565\u90a3\u4e2a\u73a9\u5bb6. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_zh_HK.properties b/Essentials/src/messages_zh_HK.properties index c5b74e3e8..53814c096 100644 --- a/Essentials/src/messages_zh_HK.properties +++ b/Essentials/src/messages_zh_HK.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. diff --git a/Essentials/src/messages_zh_TW.properties b/Essentials/src/messages_zh_TW.properties index d4397da62..228251489 100644 --- a/Essentials/src/messages_zh_TW.properties +++ b/Essentials/src/messages_zh_TW.properties @@ -532,4 +532,5 @@ tempbanExemptOffline=\u00a74You may not tempban offline players. mayNotJailOffline=\u00a74You may not jail offline players. muteExemptOffline=\u00a74You may not mute offline players. ignoreExempt=\u00a74You can not ignore that player. +unsafeTeleportDestination=\u00a74The location you are attempting to teleport to is not safe. -- cgit v1.2.3