Grace Check in checkForExplosion Method & Added a Async Task On Show.

NOTE: Ran 100 Alts Running /f who every second whilst all being in my faction with 0 lag or errors with LuckPerms
This commit is contained in:
Driftay 2020-05-07 05:11:28 -04:00
parent 33761fee2b
commit b8c695c2f4
3 changed files with 33 additions and 26 deletions

View File

@ -585,7 +585,7 @@ public class FactionsPlugin extends MPlugin {
public String getPrimaryGroup(OfflinePlayer player) {
return (perms == null || !perms.hasGroupSupport()) ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
return perms == null || !perms.hasGroupSupport() ? " " : perms.getPrimaryGroup(Bukkit.getWorlds().get(0).toString(), player);
}
public TimerManager getTimerManager() {

View File

@ -78,8 +78,11 @@ public class CmdShow extends FCommand {
return; // we only show header for non-normal factions
}
for (String raw : show) {
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations
List<String> finalShow = show;
Faction finalFaction = faction;
FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
for (String raw : finalShow) {
String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
if (parsed == null) {
continue; // Due to minimal f show.
}
@ -89,7 +92,7 @@ public class CmdShow extends FCommand {
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
List<FancyMessage> fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
if (fancy != null)
context.sendFancyMessage(fancy);
@ -106,6 +109,7 @@ public class CmdShow extends FCommand {
context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
}
}
});
}
@Override

View File

@ -4,6 +4,7 @@ import com.massivecraft.factions.*;
import com.massivecraft.factions.event.PowerLossEvent;
import com.massivecraft.factions.struct.Relation;
import com.massivecraft.factions.util.MiscUtil;
import com.massivecraft.factions.util.timer.type.GraceTimer;
import com.massivecraft.factions.zcore.util.TL;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -258,6 +259,8 @@ public class FactionsEntityListener implements Listener {
private boolean checkExplosionForBlock(Entity boomer, Block block) {
Faction faction = Board.getInstance().getFactionAt(new FLocation(block.getLocation()));
if(FactionsPlugin.getInstance().getTimerManager().graceTimer.getRemaining() > 0) return false;
if (faction.noExplosionsInTerritory() || (faction.isPeaceful() && Conf.peacefulTerritoryDisableBoom))
return false;
// faction is peaceful and has explosions set to disabled