Added timeout to stealth mode!

This commit is contained in:
ProSavage 2018-08-26 22:27:55 -05:00
parent 94c4ee815a
commit 36efd8a24e
3 changed files with 27 additions and 4 deletions

View File

@ -1,7 +1,10 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.P;
import com.massivecraft.factions.integration.Econ;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
public class CmdStealth extends FCommand {
public CmdStealth() {
@ -20,9 +23,26 @@ public class CmdStealth extends FCommand {
public void perform() {
if (myFaction != null && !myFaction.isWilderness() && !myFaction.isSafeZone() && !myFaction.isWarZone() && myFaction.isNormal()) {
fme.setStealth(!fme.isStealthEnabled());
// Sends Enable/Disable Message
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
if (fme.isStealthEnabled()) {
fme.setStealth(false);
} else {
fme.setStealth(true);
Bukkit.getScheduler().scheduleSyncDelayedTask(P.p, new Runnable() {
@Override
public void run() {
if (fme.isStealthEnabled()) {
fme.setStealth(false);
fme.msg(TL.COMMAND_STEALTH_DISABLE);
}
}
// We multiplied by 20 here because the value is in ticks.
}, P.p.getConfig().getInt("stealth-timeout") * 20);
}
fme.sendMessage(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE.toString().replace("{timeout}", P.p.getConfig().getInt("stealth-timeout") + "") : TL.COMMAND_STEALTH_DISABLE.toString());
} else {
fme.msg(TL.COMMAND_STEALTH_MUSTBEMEMBER);
}

View File

@ -637,8 +637,8 @@ public enum TL {
COMMAND_STATUS_DESCRIPTION("Show the status of a player"),
COMMAND_STEALTH_DESCRIPTION("Enable and Disable Stealth Mode"),
COMMAND_STEALTH_ENABLE( "&2Stealth &8» &7You will no longer disable nearby players fly."),
COMMAND_STEALTH_DISABLE("&2Stealth &8» &7You will now disable other nearby players fly."),
COMMAND_STEALTH_ENABLE( "&cStealth &7» &7You will no longer disable nearby players in /f fly for {timeout} seconds."),
COMMAND_STEALTH_DISABLE("&2Stealth &8» &7You will now disable other nearby players in /f fly."),
COMMAND_STEALTH_MUSTBEMEMBER("&2Stealth &8» &4You must be in a faction to use this command"),
COMMAND_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"),

View File

@ -72,6 +72,9 @@ ffly:
# This will set the timeout for the stealth in seconds.
stealth-timeout: 300
# If a player leaves fly (out of territory or took damage)
# how long should they not take fall damage for?
# Set to 0 to have them always take fall damage.