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) { 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() { public TimerManager getTimerManager() {

View File

@ -78,34 +78,38 @@ public class CmdShow extends FCommand {
return; // we only show header for non-normal factions return; // we only show header for non-normal factions
} }
for (String raw : show) { List<String> finalShow = show;
String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations Faction finalFaction = faction;
if (parsed == null) { FactionsPlugin.getInstance().getServer().getScheduler().runTaskAsynchronously(FactionsPlugin.instance, () -> {
continue; // Due to minimal f show. for (String raw : finalShow) {
} String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations
if (parsed == null) {
if (context.fPlayer != null) { continue; // Due to minimal f show.
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(faction, context.fPlayer, parsed);
if (fancy != null)
context.sendFancyMessage(fancy);
continue;
}
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {
if (parsed.contains("{ig}")) {
// replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
} }
if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it. if (context.fPlayer != null) {
parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed);
}
if (TagUtil.hasFancy(parsed)) {
List<FancyMessage> fancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed);
if (fancy != null)
context.sendFancyMessage(fancy);
continue;
}
if (!parsed.contains("{notFrozen}") && !parsed.contains("{notPermanent}")) {
if (parsed.contains("{ig}")) {
// replaces all variables with no home TL
parsed = parsed.substring(0, parsed.indexOf("{ig}")) + TL.COMMAND_SHOW_NOHOME.toString();
}
if (parsed.contains("%")) {
parsed = parsed.replaceAll("%", ""); // Just in case it got in there before we disallowed it.
}
context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
} }
context.msg(FactionsPlugin.getInstance().txt.parse(parsed));
} }
} });
} }
@Override @Override

View File

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