Skip to content
This repository was archived by the owner on Jul 7, 2023. It is now read-only.

Commit 36efd8a

Browse files
committed
Added timeout to stealth mode!
1 parent 94c4ee8 commit 36efd8a

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

src/main/java/com/massivecraft/factions/cmd/CmdStealth.java

+22-2
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
package com.massivecraft.factions.cmd;
22

3+
import com.massivecraft.factions.P;
4+
import com.massivecraft.factions.integration.Econ;
35
import com.massivecraft.factions.struct.Permission;
46
import com.massivecraft.factions.zcore.util.TL;
7+
import org.bukkit.Bukkit;
58

69
public class CmdStealth extends FCommand {
710
public CmdStealth() {
@@ -20,9 +23,26 @@ public CmdStealth() {
2023

2124
public void perform() {
2225
if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) {
23-
fme.setStealth(!fme.isStealthEnabled());
26+
27+
2428
// Sends Enable/Disable Message
25-
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
29+
if (fme.isStealthEnabled()) {
30+
fme.setStealth(false);
31+
} else {
32+
fme.setStealth(true);
33+
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
34+
@Override
35+
public void run() {
36+
if (fme.isStealthEnabled()) {
37+
fme.setStealth(false);
38+
fme.msg(TL.COMMAND_STEALTH_DISABLE);
39+
}
40+
}
41+
// We multiplied by 20 here because the value is in ticks.
42+
}, P.p.getConfig().getInt("stealth-timeout") * 20);
43+
}
44+
45+
fme.sendMessage(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE.toString().replace("{timeout}", P.p.getConfig().getInt("stealth-timeout") + "") : TL.COMMAND_STEALTH_DISABLE.toString());
2646
} else {
2747
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
2848
}

src/main/java/com/massivecraft/factions/zcore/util/TL.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -637,8 +637,8 @@ public enum TL {
637637
COMMAND_STATUS_DESCRIPTION("Show the status of a player"),
638638

639639
COMMAND_STEALTH_DESCRIPTION("Enable and Disable Stealth Mode"),
640-
COMMAND_STEALTH_ENABLE( "&2Stealth &8» &7You will no longer disable nearby players fly."),
641-
COMMAND_STEALTH_DISABLE("&2Stealth &8» &7You will now disable other nearby players fly."),
640+
COMMAND_STEALTH_ENABLE( "&cStealth &7» &7You will no longer disable nearby players in /f fly for {timeout} seconds."),
641+
COMMAND_STEALTH_DISABLE("&2Stealth &8» &7You will now disable other nearby players in /f fly."),
642642
COMMAND_STEALTH_MUSTBEMEMBER("&2Stealth &8» &4You must be in a faction to use this command"),
643643

644644
COMMAND_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"),

src/main/resources/config.yml

+3
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,9 @@ ffly:
7272

7373

7474

75+
# This will set the timeout for the stealth in seconds.
76+
stealth-timeout: 300
77+
7578
# If a player leaves fly (out of territory or took damage)
7679
# how long should they not take fall damage for?
7780
# Set to 0 to have them always take fall damage.

0 commit comments

Comments
 (0)