F Stealth Added
Signed-off-by: Driftay <saser_elite@yahoo.com>
This commit is contained in:
parent
51f157931f
commit
751f46e57e
@ -20,6 +20,8 @@ public class Conf {
|
|||||||
public static final transient boolean DYNMAP_STYLE_BOOST = false;
|
public static final transient boolean DYNMAP_STYLE_BOOST = false;
|
||||||
public static List<String> baseCommandAliases = new ArrayList<>();
|
public static List<String> baseCommandAliases = new ArrayList<>();
|
||||||
public static boolean allowNoSlashCommand = true;
|
public static boolean allowNoSlashCommand = true;
|
||||||
|
public static Set<String> allowedStealthFactions = new LinkedHashSet<>();
|
||||||
|
|
||||||
// Colors
|
// Colors
|
||||||
public static ChatColor colorMember = ChatColor.GREEN;
|
public static ChatColor colorMember = ChatColor.GREEN;
|
||||||
public static ChatColor colorAlly = ChatColor.LIGHT_PURPLE;
|
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 allianceChatFormat = ChatColor.LIGHT_PURPLE + "%s:" + ChatColor.WHITE + " %s";
|
||||||
public static String truceChatFormat = ChatColor.DARK_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 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 noEnderpearlsInFly = false;
|
||||||
public static boolean broadcastDescriptionChanges = false;
|
public static boolean broadcastDescriptionChanges = false;
|
||||||
public static boolean broadcastTagChanges = false;
|
public static boolean broadcastTagChanges = false;
|
||||||
|
@ -27,6 +27,11 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
public interface FPlayer extends EconomyParticipator {
|
public interface FPlayer extends EconomyParticipator {
|
||||||
|
|
||||||
|
boolean isStealthEnabled();
|
||||||
|
|
||||||
|
void setStealth(boolean isStealthEnabled);
|
||||||
|
|
||||||
void login();
|
void login();
|
||||||
|
|
||||||
void logout();
|
void logout();
|
||||||
|
@ -206,7 +206,7 @@ public class CmdFly extends FCommand {
|
|||||||
if (entities.get(i) instanceof Player) {
|
if (entities.get(i) instanceof Player) {
|
||||||
Player eplayer = (Player) entities.get(i);
|
Player eplayer = (Player) entities.get(i);
|
||||||
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
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);
|
fme.msg(TL.COMMAND_FLY_CHECK_ENEMY);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -214,6 +214,7 @@ public class CmdFly extends FCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (args.size() == 0) {
|
if (args.size() == 0) {
|
||||||
toggleFlight(!fme.isFlying(), me);
|
toggleFlight(!fme.isFlying(), me);
|
||||||
} else if (args.size() == 1) {
|
} else if (args.size() == 1) {
|
||||||
|
43
src/main/java/com/massivecraft/factions/cmd/CmdStealth.java
Normal file
43
src/main/java/com/massivecraft/factions/cmd/CmdStealth.java
Normal 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;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -51,6 +51,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
public CmdSethome cmdSethome = new CmdSethome();
|
public CmdSethome cmdSethome = new CmdSethome();
|
||||||
public CmdShow cmdShow = new CmdShow();
|
public CmdShow cmdShow = new CmdShow();
|
||||||
public CmdStatus cmdStatus = new CmdStatus();
|
public CmdStatus cmdStatus = new CmdStatus();
|
||||||
|
public CmdStealth cmdStealth = new CmdStealth();
|
||||||
public CmdStuck cmdStuck = new CmdStuck();
|
public CmdStuck cmdStuck = new CmdStuck();
|
||||||
public CmdTag cmdTag = new CmdTag();
|
public CmdTag cmdTag = new CmdTag();
|
||||||
public CmdTitle cmdTitle = new CmdTitle();
|
public CmdTitle cmdTitle = new CmdTitle();
|
||||||
@ -166,6 +167,7 @@ public class FCmdRoot extends FCommand {
|
|||||||
this.addSubCommand(this.cmdSethome);
|
this.addSubCommand(this.cmdSethome);
|
||||||
this.addSubCommand(this.cmdShow);
|
this.addSubCommand(this.cmdShow);
|
||||||
this.addSubCommand(this.cmdStatus);
|
this.addSubCommand(this.cmdStatus);
|
||||||
|
this.addSubCommand(this.cmdStealth);
|
||||||
this.addSubCommand(this.cmdStuck);
|
this.addSubCommand(this.cmdStuck);
|
||||||
this.addSubCommand(this.cmdTag);
|
this.addSubCommand(this.cmdTag);
|
||||||
this.addSubCommand(this.cmdTitle);
|
this.addSubCommand(this.cmdTitle);
|
||||||
|
@ -76,6 +76,7 @@ public enum Permission {
|
|||||||
SETHOME_ANY("sethome.any"),
|
SETHOME_ANY("sethome.any"),
|
||||||
SHOW("show"),
|
SHOW("show"),
|
||||||
STATUS("status"),
|
STATUS("status"),
|
||||||
|
STEALTH("stealth"),
|
||||||
STUCK("stuck"),
|
STUCK("stuck"),
|
||||||
TAG("tag"),
|
TAG("tag"),
|
||||||
TNT("tnt"),
|
TNT("tnt"),
|
||||||
|
@ -79,11 +79,19 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
protected transient boolean loginPvpDisabled;
|
protected transient boolean loginPvpDisabled;
|
||||||
protected transient long lastFrostwalkerMessage;
|
protected transient long lastFrostwalkerMessage;
|
||||||
protected transient boolean shouldTakeFallDamage = true;
|
protected transient boolean shouldTakeFallDamage = true;
|
||||||
|
protected boolean isStealthEnabled = false;
|
||||||
boolean playerAlerts = false;
|
boolean playerAlerts = false;
|
||||||
boolean inspectMode = false;
|
boolean inspectMode = false;
|
||||||
|
|
||||||
public MemoryFPlayer() {
|
public MemoryFPlayer() {
|
||||||
}
|
}
|
||||||
|
public boolean isStealthEnabled() {
|
||||||
|
return this.isStealthEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setStealth(boolean stealth) {
|
||||||
|
this.isStealthEnabled = stealth;
|
||||||
|
}
|
||||||
|
|
||||||
public MemoryFPlayer(String id) {
|
public MemoryFPlayer(String id) {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
@ -1028,24 +1036,17 @@ public abstract class MemoryFPlayer implements FPlayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean checkIfNearbyEnemies() {
|
public boolean checkIfNearbyEnemies(){
|
||||||
Player me = this.getPlayer();
|
Player me = this.getPlayer();
|
||||||
int radius = Conf.enemyFlyCheckRadius;
|
int radius = Conf.stealthFlyCheckRadius;
|
||||||
for (Entity e : me.getNearbyEntities(radius, 255, radius)) {
|
for (Entity e : me.getNearbyEntities(radius, 255, radius)) {
|
||||||
if (e == null) {
|
if (e == null) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (e instanceof Player) {
|
if (e instanceof Player) {
|
||||||
Player eplayer = (((Player) e).getPlayer());
|
Player eplayer = (((Player) e).getPlayer());
|
||||||
if (eplayer == null) {
|
if (eplayer == null) { continue; }
|
||||||
continue;
|
|
||||||
}
|
|
||||||
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
FPlayer efplayer = FPlayers.getInstance().getByPlayer(eplayer);
|
||||||
if (efplayer == null) {
|
if (efplayer == null) { continue; }
|
||||||
continue;
|
if (Conf.allowedStealthFactions != null && !efplayer.isStealthEnabled()) {
|
||||||
}
|
|
||||||
if (this.getRelationTo(efplayer).equals(Relation.ENEMY)) {
|
|
||||||
|
|
||||||
this.setFlying(false);
|
this.setFlying(false);
|
||||||
this.msg(TL.COMMAND_FLY_ENEMY_NEAR);
|
this.msg(TL.COMMAND_FLY_ENEMY_NEAR);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
|
Bukkit.getServer().getPluginManager().callEvent(new FPlayerStoppedFlying(this));
|
||||||
|
@ -632,6 +632,10 @@ public enum TL {
|
|||||||
COMMAND_STATUS_AGOSUFFIX(" ago."),
|
COMMAND_STATUS_AGOSUFFIX(" ago."),
|
||||||
COMMAND_STATUS_DESCRIPTION("Show the status of a player"),
|
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_TIMEFORMAT("m 'minutes', s 'seconds.'"),
|
||||||
COMMAND_STUCK_CANCELLED("<a>Teleport cancelled because you were damaged"),
|
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"),
|
COMMAND_STUCK_OUTSIDE("<a>Teleport cancelled because you left <i>%1$d <a>block radius"),
|
||||||
|
@ -318,5 +318,7 @@ permissions:
|
|||||||
description: create banner
|
description: create banner
|
||||||
factions.killholos:
|
factions.killholos:
|
||||||
description: kill invisible holograms
|
description: kill invisible holograms
|
||||||
|
factions.stealth:
|
||||||
|
description: Enter faction stealth mode
|
||||||
factions.coords:
|
factions.coords:
|
||||||
description: broadcast your coords to the player
|
description: broadcast your coords to the player
|
||||||
|
Loading…
Reference in New Issue
Block a user