Bunch of Misc Fixes Reported in Discord

This commit is contained in:
Driftay 2019-10-27 17:24:17 -04:00
parent 77245e716f
commit bbed3f0bb0
6 changed files with 40 additions and 15 deletions

View File

@ -131,6 +131,7 @@ public class Conf {
public static boolean homesTeleportAllowedFromDifferentWorld = true;
public static double homesTeleportAllowedEnemyDistance = 32.0;
public static boolean homesTeleportIgnoreEnemiesIfInOwnTerritory = true;
public static boolean homesTeleportIgnoreEnemiesIfInNoClaimingWorld = true;
public static boolean disablePVPBetweenNeutralFactions = false;
public static boolean disablePVPForFactionlessPlayers = false;
public static boolean enablePVPAgainstFactionlessInAttackersLand = false;

View File

@ -12,6 +12,7 @@ import org.bukkit.Bukkit;
import org.bukkit.GameMode;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
import org.bukkit.scheduler.BukkitTask;
import java.util.List;
import java.util.concurrent.ConcurrentHashMap;
@ -21,7 +22,8 @@ public class CmdFly extends FCommand {
public static ConcurrentHashMap<String, Boolean> flyMap = new ConcurrentHashMap<String, Boolean>();
public static int id = -1;
public static int flyid = -1;
public static BukkitTask flyTask = null;
public CmdFly() {
super();
@ -57,7 +59,7 @@ public class CmdFly extends FCommand {
}
public static void startFlyCheck() {
flyid = Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> { //threw the exception for now, until I recode fly :( Cringe.
flyTask = Bukkit.getScheduler().runTaskTimerAsynchronously(FactionsPlugin.instance, () -> {
checkTaskState();
if (flyMap.keySet().size() != 0) {
for (String name : flyMap.keySet()) {
@ -84,7 +86,7 @@ public class CmdFly extends FCommand {
FLocation myFloc = new FLocation(player.getLocation());
if (Board.getInstance().getFactionAt(myFloc) != myFaction) {
if (!checkBypassPerms(fPlayer, player, Board.getInstance().getFactionAt(myFloc))) {
fPlayer.setFlying(false);
Bukkit.getScheduler().runTask(FactionsPlugin.instance, () -> fPlayer.setFFlying(false, false));
flyMap.remove(name);
}
}
@ -95,7 +97,7 @@ public class CmdFly extends FCommand {
}, 20L, 20L);
}
private static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
public static boolean checkBypassPerms(FPlayer fme, Player me, Faction toFac) {
if (toFac != fme.getFaction()) {
if (!me.hasPermission("factions.fly.wilderness") && toFac.isWilderness() || !me.hasPermission("factions.fly.safezone") && toFac.isSafeZone() || !me.hasPermission("factions.fly.warzone") && toFac.isWarZone()) {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
@ -119,7 +121,7 @@ public class CmdFly extends FCommand {
fme.msg(TL.COMMAND_FLY_NO_ACCESS, toFac.getTag(fme));
return false;
}
return me.hasPermission("factions.fly") && access != Access.DENY;
return me.hasPermission("factions.fly") && (access != Access.DENY || toFac.isSystemFaction());
}
return true;
}
@ -131,9 +133,9 @@ public class CmdFly extends FCommand {
}
public static void checkTaskState() {
if (flyMap.keySet().size() == 0) {
Bukkit.getScheduler().cancelTask(flyid);
flyid = -1;
if (flyMap.isEmpty()) {
flyTask.cancel();
flyTask = null;
}
}
@ -190,7 +192,7 @@ public class CmdFly extends FCommand {
context.doWarmUp(WarmUpUtil.Warmup.FLIGHT, TL.WARMUPS_NOTIFY_FLIGHT, "Fly", () -> {
fme.setFlying(true);
flyMap.put(fme.getPlayer().getName(), true);
if (flyid == -1) {
if (flyTask == null) {
startFlyCheck();
}
}, FactionsPlugin.getInstance().getConfig().getLong("warmups.f-fly", 0));

View File

@ -23,6 +23,7 @@ public class CmdHome extends FCommand {
public CmdHome() {
super();
this.aliases.add("home");
this.optionalArgs.put("home", "faction-name");
this.requirements = new CommandRequirements.Builder(Permission.HOME)
.playerOnly()
@ -44,6 +45,12 @@ public class CmdHome extends FCommand {
return;
}
if (context.args.size() == 1) {
Faction faction = context.argAsFaction(0);
if (faction == null) return;
context.faction = faction;
}
if (!context.faction.hasHome()) {
context.msg(TL.COMMAND_HOME_NOHOME.toString() + (context.fPlayer.getRole().value < Role.MODERATOR.value ? TL.GENERIC_ASKYOURLEADER.toString() : TL.GENERIC_YOUSHOULD.toString()));
context.sendMessage(FactionsPlugin.getInstance().cmdBase.cmdSethome.getUsageTemplate(context));
@ -73,7 +80,12 @@ public class CmdHome extends FCommand {
final Location loc = context.player.getLocation().clone();
// if player is not in a safe zone or their own faction territory, only allow teleport if no enemies are nearby
if (Conf.homesTeleportAllowedEnemyDistance > 0 && !faction.isSafeZone() && (!context.fPlayer.isInOwnTerritory() || !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)) {
if (Conf.homesTeleportAllowedEnemyDistance > 0
&& !faction.isSafeZone()
&& (!context.fPlayer.isInOwnTerritory()
|| !Conf.homesTeleportIgnoreEnemiesIfInOwnTerritory)
&& (!Conf.homesTeleportIgnoreEnemiesIfInNoClaimingWorld
|| !Conf.worldsNoClaiming.contains(context.fPlayer.getPlayer().getWorld().getName()))) {
World w = loc.getWorld();
double x = loc.getX();
double y = loc.getY();

View File

@ -110,7 +110,8 @@ public class FactionsBlockListener implements Listener {
me.msg(TL.ACTIONS_OWNEDTERRITORYDENY.toString().replace("{owners}", myFaction.getOwnerListString(loc)));
if (shouldHurt) {
player.damage(Conf.actionDeniedPainAmount);
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
if ((Board.getInstance().getFactionAt(loc).getTag(myFaction)) != null)
me.msg(TL.ACTIONS_NOPERMISSIONPAIN.toString().replace("{action}", action.toString()).replace("{faction}", Board.getInstance().getFactionAt(loc).getTag(myFaction)));
}
return false;
} else if (!landOwned && access == Access.DENY) { // If land is not owned but access is set to DENY anyway

View File

@ -576,6 +576,7 @@ public class FactionsPlayerListener implements Listener {
public void enableFly(FPlayer me) {
if (!me.getPlayer().hasPermission("factions.fly")) return;
me.setFFlying(true, false);
if (FactionsPlugin.getInstance().getConfig().getBoolean("ffly.AutoEnable")) {
me.setFlying(true);
@ -585,11 +586,11 @@ public class FactionsPlayerListener implements Listener {
CmdFly.startParticles();
}
}
if (CmdFly.flyid == -1) {
if (CmdFly.flyTask == null) CmdFly.startFlyCheck();
CmdFly.startFlyCheck();
}
}
}
//inspect
@EventHandler
@ -661,7 +662,9 @@ public class FactionsPlayerListener implements Listener {
FPlayer me = FPlayers.getInstance().getByPlayer(player);
// clear visualization
if (event.getFrom().getBlockX() != event.getTo().getBlockX() || event.getFrom().getBlockY() != event.getTo().getBlockY() || event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
if (event.getFrom().getBlockX() != event.getTo().getBlockX()
|| event.getFrom().getBlockY() != event.getTo().getBlockY()
|| event.getFrom().getBlockZ() != event.getTo().getBlockZ()) {
VisualizeUtil.clear(event.getPlayer());
if (me.isWarmingUp()) {
me.clearWarmup();
@ -670,7 +673,9 @@ public class FactionsPlayerListener implements Listener {
}
// quick check to make sure player is moving between chunks; good performance boost
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4 && event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4 && event.getFrom().getWorld() == event.getTo().getWorld()) {
if (event.getFrom().getBlockX() >> 4 == event.getTo().getBlockX() >> 4
&& event.getFrom().getBlockZ() >> 4 == event.getTo().getBlockZ() >> 4
&& event.getFrom().getWorld() == event.getTo().getWorld()) {
return;
}

View File

@ -970,6 +970,10 @@ public abstract class MemoryFPlayer implements FPlayer {
return true;
}
if (faction.isWilderness() || faction.isSafeZone() || faction.isWarZone()){
return CmdFly.checkBypassPerms(this, this.getPlayer(), faction);
}
Access access = faction.getAccess(this, PermissableAction.FLY);
return access == null || access == Access.UNDEFINED || access == Access.ALLOW;
}