F Stealth Added

Signed-off-by: Driftay <saser_elite@yahoo.com>
This commit is contained in:
Driftay 2018-07-30 12:05:28 -04:00
parent 51f157931f
commit 751f46e57e
9 changed files with 76 additions and 15 deletions

View File

@ -20,6 +20,8 @@ public class Conf {
public static final transient boolean DYNMAP_STYLE_BOOST = false;
public static List<String> baseCommandAliases = new ArrayList<>();
public static boolean allowNoSlashCommand = true;
public static Set<String> allowedStealthFactions = new LinkedHashSet<>();
// Colors
public static ChatColor colorMember = ChatColor.GREEN;
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
@ -76,7 +78,7 @@ public class Conf {
public static String allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s";
public static String truceChatFormat = ChatColor.DARK_PURPLE + "%s:" + ChatColor.WHITE + " %s";
public static String modChatFormat = ChatColor.RED + "%s:" + ChatColor.WHITE + " %s";
public static int enemyFlyCheckRadius = 16;
public static int stealthFlyCheckRadius = 32;
public static boolean noEnderpearlsInFly = false;
public static boolean broadcastDescriptionChanges = false;
public static boolean broadcastTagChanges = false;

View File

@ -27,6 +27,11 @@ import java.util.List;
*/
public interface FPlayer extends EconomyParticipator {
boolean isStealthEnabled();
void setStealth(boolean isStealthEnabled);
void login();
void logout();

View File

@ -206,7 +206,7 @@ public class CmdFly extends FCommand {
if (entities.get(i) instanceof Player) {
Player eplayer = (Player) entities.get(i);
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer.getRelationTo(fme) == Relation.ENEMY) {
if (efplayer.getRelationTo(fme) == Relation.ENEMY && !efplayer.isStealthEnabled()) {
fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
return;
}
@ -214,6 +214,7 @@ public class CmdFly extends FCommand {
}
if (args.size() == 0) {
toggleFlight(!fme.isFlying(), me);
} else if (args.size() == 1) {

View File

@ -0,0 +1,43 @@
package com.massivecraft.factions.cmd;
import com.massivecraft.factions.Faction;
import com.massivecraft.factions.struct.Permission;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.ChatColor;
public class CmdStealth extends FCommand {
public CmdStealth() {
this.aliases.add("ninja");
this.aliases.add("stealth");
this.permission = Permission.STEALTH.node;
this.disableOnLock = true;
this.senderMustBePlayer = true;
this.senderMustBeMember = false;
this.senderMustBeModerator = false;
this.senderMustBeColeader = false;
this.senderMustBeAdmin = false;
}
public void perform() {
//Grabs Faction
Faction faction = fme.getFaction();
if (faction != null && !faction.getId().equalsIgnoreCase("0") && !faction.getId().equalsIgnoreCase("none") && !faction.getId().equalsIgnoreCase("safezone") && !faction.getId().equalsIgnoreCase("warzone")) {
//Grabs Boolean From FPlayer
fme.setStealth(!fme.isStealthEnabled());
//Sends Enable/Disable Message
fme.msg(fme.isStealthEnabled() ? TL.COMMAND_STEALTH_ENABLE : TL.COMMAND_STEALTH_DISABLE);
} else {
//Send "Needed Faction" Message
fme.sendMessage(ChatColor.RED + "You must be in a faction to use this command");
}
}
@Override
public TL getUsageTranslation() {
return TL.COMMAND_STEALTH_DESCRIPTION;
}
}

View File

@ -51,6 +51,7 @@ public class FCmdRoot extends FCommand {
public CmdSethome cmdSethome = new CmdSethome();
public CmdShow cmdShow = new CmdShow();
public CmdStatus cmdStatus = new CmdStatus();
public CmdStealth cmdStealth = new CmdStealth();
public CmdStuck cmdStuck = new CmdStuck();
public CmdTag cmdTag = new CmdTag();
public CmdTitle cmdTitle = new CmdTitle();
@ -166,6 +167,7 @@ public class FCmdRoot extends FCommand {
this.addSubCommand(this.cmdSethome);
this.addSubCommand(this.cmdShow);
this.addSubCommand(this.cmdStatus);
this.addSubCommand(this.cmdStealth);
this.addSubCommand(this.cmdStuck);
this.addSubCommand(this.cmdTag);
this.addSubCommand(this.cmdTitle);

View File

@ -76,6 +76,7 @@ public enum Permission {
SETHOME_ANY("sethome.any"),
SHOW("show"),
STATUS("status"),
STEALTH("stealth"),
STUCK("stuck"),
TAG("tag"),
TNT("tnt"),

View File

@ -79,11 +79,19 @@ public abstract class MemoryFPlayer implements FPlayer {
protected transient boolean loginPvpDisabled;
protected transient long lastFrostwalkerMessage;
protected transient boolean shouldTakeFallDamage = true;
protected boolean isStealthEnabled = false;
boolean playerAlerts = false;
boolean inspectMode = false;
public MemoryFPlayer() {
}
public boolean isStealthEnabled() {
return this.isStealthEnabled;
}
public void setStealth(boolean stealth) {
this.isStealthEnabled = stealth;
}
public MemoryFPlayer(String id) {
this.id = id;
@ -1028,24 +1036,17 @@ public abstract class MemoryFPlayer implements FPlayer {
}
@Override
public boolean checkIfNearbyEnemies() {
public boolean checkIfNearbyEnemies(){
Player me = this.getPlayer();
int radius = Conf.enemyFlyCheckRadius;
int radius = Conf.stealthFlyCheckRadius;
for (Entity e : me.getNearbyEntities(radius, 255, radius)) {
if (e == null) {
continue;
}
if (e == null) { continue; }
if (e instanceof Player) {
Player eplayer = (((Player) e).getPlayer());
if (eplayer == null) {
continue;
}
if (eplayer == null) { continue; }
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
if (efplayer == null) {
continue;
}
if (this.getRelationTo(efplayer).equals(Relation.ENEMY)) {
if (efplayer == null) { continue; }
if (Conf.allowedStealthFactions != null && !efplayer.isStealthEnabled()) {
this.setFlying(false);
this.msg(TL.COMMAND_FLY_ENEMY_NEAR);
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));

View File

@ -632,6 +632,10 @@ public enum TL {
COMMAND_STATUS_AGOSUFFIX(" ago."),
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_STUCK_TIMEFORMAT("m 'minutes', s 'seconds.'"),
COMMAND_STUCK_CANCELLED("<a>Teleport cancelled because you were damaged"),
COMMAND_STUCK_OUTSIDE("<a>Teleport cancelled because you left <i>%1$d <a>block radius"),

View File

@ -318,5 +318,7 @@ permissions:
description: create banner
factions.killholos:
description: kill invisible holograms
factions.stealth:
description: Enter faction stealth mode
factions.coords:
description: broadcast your coords to the player