diff options
author | ementalo <suror@gmx.co.uk> | 2011-12-08 23:43:09 +0000 |
---|---|---|
committer | ementalo <suror@gmx.co.uk> | 2011-12-08 23:43:09 +0000 |
commit | 95d5217f588f11f3477e57420c3c678d4f7e4293 (patch) | |
tree | 8d9d3fbbcd8a11df9c3423db25ce9a69779c1edb | |
parent | 52b1017bdaf31acc01dfcb3ff15b19c5e1f6ea62 (diff) | |
download | Essentials-95d5217f588f11f3477e57420c3c678d4f7e4293.tar Essentials-95d5217f588f11f3477e57420c3c678d4f7e4293.tar.gz Essentials-95d5217f588f11f3477e57420c3c678d4f7e4293.tar.lz Essentials-95d5217f588f11f3477e57420c3c678d4f7e4293.tar.xz Essentials-95d5217f588f11f3477e57420c3c678d4f7e4293.zip |
Allow timeout of /tpa /tpahere requests
Adds new config setting tpa-accept-cancellation
Test #781
-rw-r--r-- | Essentials/src/com/earth2me/essentials/ISettings.java | 2 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/Settings.java | 6 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/User.java | 7 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandtpa.java | 4 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java | 4 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java | 7 | ||||
-rw-r--r-- | Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java | 4 | ||||
-rw-r--r-- | Essentials/src/config.yml | 4 | ||||
-rw-r--r-- | Essentials/src/messages.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_da.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_de.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_en.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_es.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_fr.properties | 2 | ||||
-rw-r--r-- | Essentials/src/messages_nl.properties | 2 |
15 files changed, 52 insertions, 0 deletions
diff --git a/Essentials/src/com/earth2me/essentials/ISettings.java b/Essentials/src/com/earth2me/essentials/ISettings.java index 97c5070b5..5c53a6790 100644 --- a/Essentials/src/com/earth2me/essentials/ISettings.java +++ b/Essentials/src/com/earth2me/essentials/ISettings.java @@ -151,4 +151,6 @@ public interface ISettings extends IConf public boolean getDisableItemPickupWhileAfk(); public Priority getRespawnPriority(); + + long getTpaAcceptCancellation(); } diff --git a/Essentials/src/com/earth2me/essentials/Settings.java b/Essentials/src/com/earth2me/essentials/Settings.java index d374e5130..682eedaf9 100644 --- a/Essentials/src/com/earth2me/essentials/Settings.java +++ b/Essentials/src/com/earth2me/essentials/Settings.java @@ -606,4 +606,10 @@ public class Settings implements ISettings } return Priority.Normal; } + + @Override + public long getTpaAcceptCancellation() + { + return config.getLong("tpa-accept-cancellation", 0); + } } diff --git a/Essentials/src/com/earth2me/essentials/User.java b/Essentials/src/com/earth2me/essentials/User.java index 2ef59eb88..d07351758 100644 --- a/Essentials/src/com/earth2me/essentials/User.java +++ b/Essentials/src/com/earth2me/essentials/User.java @@ -19,6 +19,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser private transient User teleportRequester; private transient boolean teleportRequestHere; private transient final Teleport teleport; + private transient long teleportRequestTime; private transient long lastOnlineActivity; private transient long lastActivity = System.currentTimeMillis(); private boolean hidden = false; @@ -222,6 +223,7 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser public void requestTeleport(final User player, final boolean here) { + teleportRequestTime = System.currentTimeMillis(); teleportRequester = player; teleportRequestHere = here; } @@ -537,4 +539,9 @@ public class User extends UserData implements Comparable<User>, IReplyTo, IUser { return ess.getPermissionsHandler().canBuild(base, getGroup()); } + + public long getTeleportRequestTime() + { + return teleportRequestTime; + } } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java index 5b810e611..34195d51a 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpa.java @@ -31,6 +31,10 @@ public class Commandtpa extends EssentialsCommand player.sendMessage(_("teleportRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); player.sendMessage(_("typeTpdeny")); + if (ess.getSettings().getTpaAcceptCancellation() != 0) + { + player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation())); + } } user.sendMessage(_("requestSent", player.getDisplayName())); } diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java index 7a5d078f3..c0abdc1ad 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaall.java @@ -50,6 +50,10 @@ public class Commandtpaall extends EssentialsCommand player.requestTeleport(user, true); player.sendMessage(_("teleportHereRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); + if (ess.getSettings().getTpaAcceptCancellation() != 0) + { + player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation())); + } } catch (Exception ex) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java index 954f3f038..0cece3310 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpaccept.java @@ -27,6 +27,13 @@ public class Commandtpaccept extends EssentialsCommand throw new Exception(_("noPendingRequest")); } + long timeout = ess.getSettings().getTpaAcceptCancellation(); + if (timeout != 0 && (System.currentTimeMillis() - user.getTeleportRequestTime()) / 1000 > timeout) + { + user.requestTeleport(null, false); + throw new Exception(_("requestTimedOut")); + } + final Trade charge = new Trade(this.getName(), ess); if (user.isTeleportRequestHere()) { diff --git a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java index 751fc628c..376c2be44 100644 --- a/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java +++ b/Essentials/src/com/earth2me/essentials/commands/Commandtpahere.java @@ -28,6 +28,10 @@ public class Commandtpahere extends EssentialsCommand player.requestTeleport(user, true); player.sendMessage(_("teleportHereRequest", user.getDisplayName())); player.sendMessage(_("typeTpaccept")); + if (ess.getSettings().getTpaAcceptCancellation() != 0) + { + player.sendMessage(_("teleportRequestTimeoutInfo", ess.getSettings().getTpaAcceptCancellation())); + } user.sendMessage(_("requestSent", player.getDisplayName())); } } diff --git a/Essentials/src/config.yml b/Essentials/src/config.yml index 019c0ef7a..ff77db9e0 100644 --- a/Essentials/src/config.yml +++ b/Essentials/src/config.yml @@ -273,6 +273,10 @@ sethome-multiple: # essentials.sethome.multiple.staff staff: 10 +#Set timeout in seconds for players to accept tpa before request is cancelled. +#Set to 0 for no timeout +tpa-accept-cancellation: 0 + ############################################################ # +------------------------------------------------------+ # # | EssentialsEco | # diff --git a/Essentials/src/messages.properties b/Essentials/src/messages.properties index b9e27b959..f8f2c6d42 100644 --- a/Essentials/src/messages.properties +++ b/Essentials/src/messages.properties @@ -402,3 +402,5 @@ year=year years=years youAreHealed=\u00a77You have been healed. youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_da.properties b/Essentials/src/messages_da.properties index d44f66c72..617eb8a68 100644 --- a/Essentials/src/messages_da.properties +++ b/Essentials/src/messages_da.properties @@ -402,3 +402,5 @@ year=\u00e5r years=\u00e5r youAreHealed=\u00a77Du er blevet healed. Halleluja! youHaveNewMail=\u00a7cDu har {0} flaskeposter!\u00a7f Type \u00a77/mail read for at se din flaskepost. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_de.properties b/Essentials/src/messages_de.properties index 5de616099..4f55eca80 100644 --- a/Essentials/src/messages_de.properties +++ b/Essentials/src/messages_de.properties @@ -402,3 +402,5 @@ year=Jahr years=Jahre youAreHealed=\u00a77Du wurdest geheilt. youHaveNewMail=\u00a7cDu hast {0} Nachrichten!\u00a7f Schreibe \u00a77/mail read\u00a7f um deine Nachrichten anzuzeigen. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_en.properties b/Essentials/src/messages_en.properties index 72d095524..ace13c8c4 100644 --- a/Essentials/src/messages_en.properties +++ b/Essentials/src/messages_en.properties @@ -402,3 +402,5 @@ year=year years=years youAreHealed=\u00a77You have been healed. youHaveNewMail=\u00a7cYou have {0} messages!\u00a7f Type \u00a77/mail read\u00a7f to view your mail. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_es.properties b/Essentials/src/messages_es.properties index fc6b13eb1..cb1b331c9 100644 --- a/Essentials/src/messages_es.properties +++ b/Essentials/src/messages_es.properties @@ -402,3 +402,5 @@ year=año years=años youAreHealed=\u00a77Has sido curado. youHaveNewMail=\u00a7cTienes {0} mensajes!\u00a7f Pon \u00a77/mail read\u00a7f para ver tus emails no leidos!. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_fr.properties b/Essentials/src/messages_fr.properties index 97e87b14b..c6549798b 100644 --- a/Essentials/src/messages_fr.properties +++ b/Essentials/src/messages_fr.properties @@ -402,3 +402,5 @@ year=ann\u00e9e years=ann\u00e9es youAreHealed=\u00a77Vous avez \u00e9t\u00e9 soign\u00e9. youHaveNewMail=\u00a7cVous avez {0} messages ! \u00a7fEntrez \u00a77/mail read\u00a7f pour voir votre courrier. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. diff --git a/Essentials/src/messages_nl.properties b/Essentials/src/messages_nl.properties index c92952adb..338f00709 100644 --- a/Essentials/src/messages_nl.properties +++ b/Essentials/src/messages_nl.properties @@ -402,3 +402,5 @@ year=jaar years=jaren youAreHealed=\u00a77Je bent genezen. youHaveNewMail=\u00a7cJe hebt {0} berichten!\u00a7f Type \u00a77/mail read\u00a7f om je berichten te bekijken. +requestTimedOut=\u00a7cTeleport request has timed out +teleportRequestTimeoutInfo=\u00a77This request will timeout after {0} seconds. |