Showing Dropping Anvil Something (Ignore)
This commit is contained in:
@@ -11,87 +11,87 @@ import org.bukkit.Bukkit;
|
||||
|
||||
public class UtilFly {
|
||||
|
||||
public static void run() {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
public static void run() {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||
for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
if (fp.isFlying())
|
||||
fp.checkIfNearbyEnemies();
|
||||
}
|
||||
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(FactionsPlugin.getInstance(), () -> {
|
||||
for (FPlayer fp : FPlayers.getInstance().getOnlinePlayers()) {
|
||||
if (fp.isFlying())
|
||||
fp.checkIfNearbyEnemies();
|
||||
}
|
||||
}, 0, FactionsPlugin.getInstance().getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
|
||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
fp.getPlayer().setAllowFlight(fly);
|
||||
fp.getPlayer().setFlying(fly);
|
||||
fp.setFlying(fly);
|
||||
fp.getPlayer().setAllowFlight(fly);
|
||||
fp.getPlayer().setFlying(fly);
|
||||
fp.setFlying(fly);
|
||||
|
||||
|
||||
if (!silent) {
|
||||
if (!damage) {
|
||||
fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
||||
} else {
|
||||
fp.msg(TL.COMMAND_FLY_DAMAGE);
|
||||
}
|
||||
}
|
||||
if (!silent) {
|
||||
if (!damage) {
|
||||
fp.msg(TL.COMMAND_FLY_CHANGE, fly ? "enabled" : "disabled");
|
||||
} else {
|
||||
fp.msg(TL.COMMAND_FLY_DAMAGE);
|
||||
}
|
||||
}
|
||||
|
||||
setFallDamage(fp, fly, damage);
|
||||
}
|
||||
setFallDamage(fp, fly, damage);
|
||||
}
|
||||
|
||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||
if (!FactionsPlugin.getInstance().getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
if (me.isAdminBypassing() && me.isFlying() && me.getPlayer().hasPermission("factions.fly.enemy-bypass"))
|
||||
return;
|
||||
if (me.isAdminBypassing() && me.isFlying() && me.getPlayer().hasPermission("factions.fly.enemy-bypass"))
|
||||
return;
|
||||
|
||||
if (!me.isFlying()) {
|
||||
if (me.isAdminBypassing() || me.getPlayer().hasPermission("factions.fly.enemy-bypass")) {
|
||||
UtilFly.setFly(me, true, true, false);
|
||||
return;
|
||||
}
|
||||
if (!me.isFlying()) {
|
||||
if (me.isAdminBypassing() || me.getPlayer().hasPermission("factions.fly.enemy-bypass")) {
|
||||
UtilFly.setFly(me, true, true, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) {
|
||||
UtilFly.setFly(me, true, false, false);
|
||||
} else {
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.isWilderness() && me.canflyinWilderness()) || (factionTo.isWarZone() && me.canflyinWarzone())
|
||||
|| (factionTo.isSafeZone() && me.canflyinSafezone()) || (relationTo == Relation.ENEMY && me.canflyinEnemy())
|
||||
|| (relationTo == Relation.ALLY && me.canflyinAlly()) || (relationTo == Relation.TRUCE && me.canflyinTruce())
|
||||
|| (relationTo == Relation.NEUTRAL && me.canflyinNeutral())) {
|
||||
if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) {
|
||||
UtilFly.setFly(me, true, false, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.equals(me.getFaction()) && !me.getPlayer().hasPermission("factions.fly"))
|
||||
|| (factionTo.isWilderness() && !me.canflyinWilderness()) || (factionTo.isWarZone() && !me.canflyinWarzone())
|
||||
|| (factionTo.isSafeZone() && !me.canflyinSafezone()) || (relationTo == Relation.ENEMY && !me.canflyinEnemy())
|
||||
|| (relationTo == Relation.ALLY && !me.canflyinAlly()) || (relationTo == Relation.TRUCE && !me.canflyinTruce())
|
||||
|| (relationTo == Relation.NEUTRAL && !me.canflyinNeutral())) {
|
||||
UtilFly.setFly(me, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.isWilderness() && me.canflyinWilderness()) || (factionTo.isWarZone() && me.canflyinWarzone())
|
||||
|| (factionTo.isSafeZone() && me.canflyinSafezone()) || (relationTo == Relation.ENEMY && me.canflyinEnemy())
|
||||
|| (relationTo == Relation.ALLY && me.canflyinAlly()) || (relationTo == Relation.TRUCE && me.canflyinTruce())
|
||||
|| (relationTo == Relation.NEUTRAL && me.canflyinNeutral())) {
|
||||
UtilFly.setFly(me, true, false, false);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
Relation relationTo = factionTo.getRelationTo(me);
|
||||
if ((factionTo.equals(me.getFaction()) && !me.getPlayer().hasPermission("factions.fly"))
|
||||
|| (factionTo.isWilderness() && !me.canflyinWilderness()) || (factionTo.isWarZone() && !me.canflyinWarzone())
|
||||
|| (factionTo.isSafeZone() && !me.canflyinSafezone()) || (relationTo == Relation.ENEMY && !me.canflyinEnemy())
|
||||
|| (relationTo == Relation.ALLY && !me.canflyinAlly()) || (relationTo == Relation.TRUCE && !me.canflyinTruce())
|
||||
|| (relationTo == Relation.NEUTRAL && !me.canflyinNeutral())) {
|
||||
UtilFly.setFly(me, false, false, false);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) {
|
||||
if (!fly) {
|
||||
if (!damage) {
|
||||
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||
}
|
||||
public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) {
|
||||
if (!fly) {
|
||||
if (!damage) {
|
||||
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||
}
|
||||
|
||||
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
||||
if (cooldown > 0) {
|
||||
fp.setTakeFallDamage(false);
|
||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> fp.setTakeFallDamage(true), 20L * cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
int cooldown = FactionsPlugin.getInstance().getConfig().getInt("fly-falldamage-cooldown", 3);
|
||||
if (cooldown > 0) {
|
||||
fp.setTakeFallDamage(false);
|
||||
Bukkit.getScheduler().runTaskLater(FactionsPlugin.getInstance(), () -> fp.setTakeFallDamage(true), 20L * cooldown);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user