Fly Changes, And Message Persistence

This commit is contained in:
Driftay 2019-11-28 02:09:21 -05:00
parent e244b469aa
commit f5e9ce3d90
4 changed files with 22 additions and 8 deletions

View File

@ -115,6 +115,7 @@ public class Conf {
public static boolean logMoneyTransactions = true; public static boolean logMoneyTransactions = true;
public static boolean logPlayerCommands = true; public static boolean logPlayerCommands = true;
// prevent some potential exploits // prevent some potential exploits
public static boolean denyFlightIfInNoClaimingWorld = false;
public static boolean preventCreeperGlitch = true; public static boolean preventCreeperGlitch = true;
public static boolean handleExploitObsidianGenerators = true; public static boolean handleExploitObsidianGenerators = true;
public static boolean handleExploitEnderPearlClipping = true; public static boolean handleExploitEnderPearlClipping = true;
@ -540,6 +541,10 @@ public class Conf {
defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true)); defaultFactionPermissions.put("MODERATOR", new DefaultPermissions(true));
defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false)); defaultFactionPermissions.put("NORMAL MEMBER", new DefaultPermissions(false));
defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false)); defaultFactionPermissions.put("RECRUIT", new DefaultPermissions(false));
defaultFactionPermissions.put("ALLY", new DefaultPermissions(false));
defaultFactionPermissions.put("ENEMY", new DefaultPermissions(false));
defaultFactionPermissions.put("TRUCE", new DefaultPermissions(false));
defaultFactionPermissions.put("NEUTRAL", new DefaultPermissions(false));
} }
public static void load() { public static void load() {

View File

@ -97,6 +97,9 @@ public class CmdFly extends FCommand {
} }
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) { public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
if (Conf.denyFlightIfInNoClaimingWorld && !Conf.worldsNoClaiming.isEmpty() && Conf.worldsNoClaiming.stream().anyMatch(me.getWorld().getName()::equalsIgnoreCase))
return false;
if (toFac != fme.getFaction()) { if (toFac != fme.getFaction()) {
if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) { if (!me.hasPermission(Permission.FLY_WILD.node) && toFac.isWilderness() || !me.hasPermission(Permission.FLY_SAFEZONE.node) && toFac.isSafeZone() || !me.hasPermission(Permission.FLY_WARZONE.node) && toFac.isWarZone()) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme)); fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
@ -182,7 +185,7 @@ public class CmdFly extends FCommand {
} }
if (fme.canFlyAtLocation()) if (fme.canFlyAtLocation()) {
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> { context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
fme.setFlying(true); fme.setFlying(true);
flyMap.put(fme.getPlayer().getName(), true); flyMap.put(fme.getPlayer().getName(), true);
@ -194,6 +197,9 @@ public class CmdFly extends FCommand {
startFlyCheck(); startFlyCheck();
} }
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0)); }, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));
} else {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(fme.getLastStoodAt()).getTag());
}
} }
@Override @Override

View File

@ -553,9 +553,14 @@ public class FactionsPlayerListener implements Listener {
return string; return string;
} }
public void enableFly(FPlayer me) { public void checkCanFly(FPlayer me) {
if (!FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable")) return; // Looks prettier sorry if (me.isFlying() && (!me.canFlyAtLocation() || me.checkIfNearbyEnemies())) {
if (!me.canFlyAtLocation()) return; me.setFFlying(false, false);
me.msg(TL.COMMAND_FLY_NO_ACCESS, Board.getInstance().getFactionAt(me.getLastStoodAt()).getTag());
return;
}
if (me.isFlying() || !FactionsPlugin.instance.getConfig().getBoolean("ffly.AutoEnable"))
return;
me.setFFlying(true, false); me.setFFlying(true, false);
CmdFly.flyMap.put(me.getName(), true); CmdFly.flyMap.put(me.getName(), true);
if (CmdFly.particleTask == null) if (CmdFly.particleTask == null)
@ -729,9 +734,7 @@ public class FactionsPlayerListener implements Listener {
}, 5); }, 5);
} }
} }
if (!me.isFlying()) { this.checkCanFly(me);
enableFly(me);
}
if (me.getAutoClaimFor() != null) { if (me.getAutoClaimFor() != null) {
me.attemptClaim(me.getAutoClaimFor(), newLocation, true); me.attemptClaim(me.getAutoClaimFor(), newLocation, true);

View File

@ -1225,7 +1225,7 @@ public abstract class MemoryFPlayer implements FPlayer {
} }
// if economy is enabled and they're not on the bypass list, make sure they can pay // if economy is enabled and they're not on the bypass list, make sure they can pay
boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone(); boolean mustPay = Econ.shouldBeUsed() && !this.isAdminBypassing() && !forFaction.isSafeZone() && !forFaction.isWarZone() && (Conf.econCostClaimWilderness != 0);
double cost = 0.0; double cost = 0.0;
EconomyParticipator payee = null; EconomyParticipator payee = null;
if (mustPay) { if (mustPay) {