Merge branch '1.6.x' of https://github.com/ProSavage/SavageFactions into 1.6.x
This commit is contained in:
commit
0a41d15a0b
@ -12,39 +12,30 @@ import java.util.Iterator;
|
||||
|
||||
public class UtilFly {
|
||||
|
||||
public static ArrayList<FPlayer> playersFlying;
|
||||
|
||||
static {
|
||||
playersFlying = SavageFactions.playersFlying;
|
||||
}
|
||||
|
||||
public UtilFly() {
|
||||
}
|
||||
public static ArrayList<FPlayer> playersFlying = SavageFactions.playersFlying;
|
||||
|
||||
public static void run() {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
|
||||
playersFlying.clear();
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, new Runnable() {
|
||||
public void run() {
|
||||
Iterator var2 = UtilFly.playersFlying.iterator();
|
||||
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
while (var2.hasNext()) {
|
||||
FPlayer fp = (FPlayer) var2.next();
|
||||
if (fp != null) {
|
||||
playersFlying.clear();
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncRepeatingTask(SavageFactions.plugin, () -> {
|
||||
for (FPlayer fp : playersFlying) {
|
||||
if (fp != null)
|
||||
fp.checkIfNearbyEnemies();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}, 0L, (long) SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
}, 0, SavageFactions.plugin.getConfig().getInt("fly-task-interval", 10));
|
||||
}
|
||||
|
||||
public static void setFly(FPlayer fp, boolean fly, boolean silent, boolean damage) {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
|
||||
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
fp.getPlayer().setAllowFlight(fly);
|
||||
fp.getPlayer().setFlying(fly);
|
||||
fp.setFlying(fly);
|
||||
|
||||
if (fly) {
|
||||
playersFlying.add(fp);
|
||||
} else {
|
||||
@ -61,54 +52,56 @@ public class UtilFly {
|
||||
|
||||
setFallDamage(fp, fly, damage);
|
||||
}
|
||||
}
|
||||
|
||||
public static void checkFly(FPlayer me, Faction factionTo) {
|
||||
if (SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight")) {
|
||||
if (!me.isAdminBypassing() || !me.isFlying()) {
|
||||
Relation relationTo;
|
||||
if (!SavageFactions.plugin.getConfig().getBoolean("enable-faction-flight"))
|
||||
return;
|
||||
|
||||
if (me.isAdminBypassing() && me.isFlying())
|
||||
return;
|
||||
|
||||
if (!me.isFlying()) {
|
||||
if (me.isAdminBypassing()) {
|
||||
setFly(me, true, false, false);
|
||||
UtilFly.setFly(me, true, false, false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (factionTo == me.getFaction() && me.getPlayer().hasPermission("factions.fly")) {
|
||||
setFly(me, true, false, false);
|
||||
UtilFly.setFly(me, true, false, false);
|
||||
} else {
|
||||
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()) {
|
||||
setFly(me, true, false, false);
|
||||
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 {
|
||||
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()) {
|
||||
setFly(me, false, false, false);
|
||||
}
|
||||
}
|
||||
|
||||
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(final FPlayer fp, boolean fly, boolean damage) {
|
||||
public static void setFallDamage(FPlayer fp, boolean fly, boolean damage) {
|
||||
if (!fly) {
|
||||
if (!damage) {
|
||||
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", String.valueOf(SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3))));
|
||||
fp.sendMessage(TL.COMMAND_FLY_COOLDOWN.toString().replace("{amount}", SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3) + ""));
|
||||
}
|
||||
|
||||
int cooldown = SavageFactions.plugin.getConfig().getInt("fly-falldamage-cooldown", 3);
|
||||
if (cooldown > 0) {
|
||||
fp.setTakeFallDamage(false);
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, new Runnable() {
|
||||
public void run() {
|
||||
fp.setTakeFallDamage(true);
|
||||
Bukkit.getScheduler().runTaskLater(SavageFactions.plugin, () -> fp.setTakeFallDamage(true), 20L * cooldown);
|
||||
}
|
||||
}
|
||||
}, 20L * (long) cooldown);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user