From c29850eaaa449e2c2ab671409f40812fae7356de Mon Sep 17 00:00:00 2001 From: Driftay Date: Sat, 9 May 2020 14:04:17 -0400 Subject: [PATCH 1/6] Fixes NPE on Saving Task onDisable MPlugin, removed Async Throw for 1.15 in F Show --- pom.xml | 2 +- .../massivecraft/factions/cmd/CmdShow.java | 66 +++++++++---------- .../factions/event/PowerRegenEvent.java | 48 +++----------- .../listeners/FactionsEntityListener.java | 2 - .../massivecraft/factions/zcore/MPlugin.java | 4 +- .../factions/zcore/persist/MemoryFPlayer.java | 27 +++++--- src/main/resources/config.yml | 2 +- 7 files changed, 59 insertions(+), 92 deletions(-) diff --git a/pom.xml b/pom.xml index 52605daa..38855197 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.massivecraft Factions - 1.6.9.5-2.3.6-RC + 1.6.9.5-2.3.7-RC jar SaberFactions diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index 43204fc8..d1c0b62e 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -8,11 +8,9 @@ import com.massivecraft.factions.zcore.util.TL; import com.massivecraft.factions.zcore.util.TagReplacer; import com.massivecraft.factions.zcore.util.TagUtil; import mkremins.fanciful.FancyMessage; -import org.bukkit.scheduler.BukkitScheduler; import java.util.ArrayList; import java.util.List; -import java.util.Objects; public class CmdShow extends FCommand { @@ -85,42 +83,38 @@ public class CmdShow extends FCommand { return; // we only show header for non-normal factions } - List finalShow = show; - Faction finalFaction = faction; List fancy = new ArrayList<>(); - instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> { - for (String raw : finalShow) { - String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations - if (parsed == null) { - continue; // Due to minimal f show. - } - - if (context.fPlayer != null) { - parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); - } - - if (TagUtil.hasFancy(parsed)) { - List localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed); - if (localFancy != null) - fancy.addAll(localFancy); - - 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. - } - parsed = FactionsPlugin.getInstance().txt.parse(parsed); - FancyMessage localFancy = instance.txt.parseFancy(parsed); - fancy.add(localFancy); - } + for (String raw : show) { + String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations + if (parsed == null) { + continue; // Due to minimal f show. } - instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); - }); + + if (context.fPlayer != null) { + parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); + } + + if (TagUtil.hasFancy(parsed)) { + List localFancy = TagUtil.parseFancy(faction, context.fPlayer, parsed); + if (localFancy != null) + fancy.addAll(localFancy); + + 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. + } + parsed = FactionsPlugin.getInstance().txt.parse(parsed); + FancyMessage localFancy = instance.txt.parseFancy(parsed); + fancy.add(localFancy); + } + } + instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); } @Override diff --git a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java index eec49cf8..7189415c 100644 --- a/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java +++ b/src/main/java/com/massivecraft/factions/event/PowerRegenEvent.java @@ -1,6 +1,5 @@ package com.massivecraft.factions.event; -import com.massivecraft.factions.Conf; import com.massivecraft.factions.FPlayer; import com.massivecraft.factions.Faction; import org.bukkit.event.Cancellable; @@ -10,51 +9,20 @@ import org.bukkit.event.Cancellable; */ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable { - /** - * @author Illyria Team - */ - private boolean cancelled = false; - private double modified = 0; + private double delta; - public PowerRegenEvent(Faction f, FPlayer p) { + public PowerRegenEvent(Faction f, FPlayer p, double delta) { super(f, p); + this.delta = delta; } - /** - * Get the amount of power this player will regen by default - * - * @return power amount gained as a Double. - */ - public double getDefaultPowerGained() { - return fPlayer.getMillisPassed() * Conf.powerPerMinute / 60000; + public double getDelta() { + return delta; } - /** - * Get the amount of custom power this player will gain. Ignored if less than or equal to 0. - * - * @return Custom power as a double - */ - public double getCustomPower() { - return modified; - } - - /** - * Set the custom power gain for this event. - * - * @param gain Amount of power to be added to player. - */ - public void setCustomPower(Double gain) { - modified = gain; - } - - /** - * Get if we will be using the custom power gain instead of default. - * - * @return If we will process the event custom returned as a Boolean. - */ - public boolean usingCustomPower() { - return modified > 0; + public void setDelta(double delta) { + this.delta = delta; } @Override @@ -67,4 +35,4 @@ public class PowerRegenEvent extends FactionPlayerEvent implements Cancellable { this.cancelled = c; } -} +} \ No newline at end of file diff --git a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java index f9f25d3b..5f055dbf 100644 --- a/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java +++ b/src/main/java/com/massivecraft/factions/listeners/FactionsEntityListener.java @@ -259,8 +259,6 @@ 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 diff --git a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java index f4237482..cc7c4a9b 100644 --- a/src/main/java/com/massivecraft/factions/zcore/MPlugin.java +++ b/src/main/java/com/massivecraft/factions/zcore/MPlugin.java @@ -176,15 +176,13 @@ public abstract class MPlugin extends JavaPlugin { this.getServer().getScheduler().cancelTask(saveTask); saveTask = null; } - - this.getServer().getScheduler().cancelTasks(this); - // only save data if plugin actually loaded successfully if (loadSuccessful) { Factions.getInstance().forceSave(); FPlayers.getInstance().forceSave(); Board.getInstance().forceSave(); } + log("Disabled"); } diff --git a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java index 1b875826..14f4623e 100644 --- a/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java +++ b/src/main/java/com/massivecraft/factions/zcore/persist/MemoryFPlayer.java @@ -663,25 +663,34 @@ public abstract class MemoryFPlayer implements FPlayer { public void updatePower() { if (this.isOffline()) { losePowerFromBeingOffline(); - if (!Conf.powerRegenOffline) return; + if (!Conf.powerRegenOffline) { + return; + } } else if (hasFaction() && getFaction().isPowerFrozen()) { return; // Don't let power regen if faction power is frozen. } long now = System.currentTimeMillis(); - this.millisPassed = now - this.lastPowerUpdateTime; + long millisPassed = now - this.lastPowerUpdateTime; this.lastPowerUpdateTime = now; Player thisPlayer = this.getPlayer(); - if (thisPlayer != null && thisPlayer.isDead()) + if (thisPlayer != null && thisPlayer.isDead()) { return; // don't let dead players regain power until they respawn - PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this); - Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent)); + } - if (!powerRegenEvent.isCancelled()) - if (!powerRegenEvent.usingCustomPower()) - this.alterPower(millisPassed * Conf.powerPerMinute / 60000); // millisPerMinute : 60 * 1000 - else this.alterPower(+powerRegenEvent.getCustomPower()); + double delta = millisPassed * Conf.powerPerMinute / 60000; // millisPerMinute : 60 * 1000 + if (Bukkit.getPluginManager().getPlugin("FactionsPlugin") != null) { + Bukkit.getScheduler().runTask(FactionsPlugin.getInstance(), () -> { + PowerRegenEvent powerRegenEvent = new PowerRegenEvent(getFaction(), this, delta); + Bukkit.getServer().getPluginManager().callEvent(powerRegenEvent); + if (!powerRegenEvent.isCancelled()) { + this.alterPower(powerRegenEvent.getDelta()); + } + }); + } else { + this.alterPower(delta); + } } public void losePowerFromBeingOffline() { diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index d468e480..6ee3eb7b 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1250,7 +1250,7 @@ fupgrades: Members: Max-Level: 3 Members-Limit: - level-1: 5 #The Number Of Members It Will Increase By + level-1: 5 #The Number Of Members It Will Increase By level-2: 10 level-3: 15 Cost: From 4d05b4a376eb5712a26edf80f212bfec416ab4c9 Mon Sep 17 00:00:00 2001 From: Stefan923 Date: Sun, 10 May 2020 17:18:48 +0300 Subject: [PATCH 2/6] Fixed "RESET is not a style/color" error. --- .../massivecraft/factions/zcore/util/TextUtil.java | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java index 1b271c0d..335d8f92 100644 --- a/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java +++ b/src/main/java/com/massivecraft/factions/zcore/util/TextUtil.java @@ -65,10 +65,14 @@ public class TextUtil { text = ""; } ChatColor tempColor = ChatColor.getByChar(chars[i + 1]); - if (tempColor.isColor()) { - color = tempColor; - } else { - style = tempColor; + if (tempColor != null) { + if (tempColor == ChatColor.RESET) { + color = ChatColor.WHITE; + } else if (tempColor.isColor()) { + color = tempColor; + } else { + style = tempColor; + } } i++; // skip color char } else { From 67a9a6db284211df0d5716a4823200aa2dc218fb Mon Sep 17 00:00:00 2001 From: Aeris One Date: Sat, 16 May 2020 12:07:53 +0200 Subject: [PATCH 3/6] Update ja_JP.yml --- src/main/resources/lang/ja_JP.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/lang/ja_JP.yml b/src/main/resources/lang/ja_JP.yml index 102ecf77..038cb28c 100644 --- a/src/main/resources/lang/ja_JP.yml +++ b/src/main/resources/lang/ja_JP.yml @@ -89,8 +89,8 @@ COMMAND: INUSE: That tag is already in use. TOCREATE: to create a new faction FORCREATE: for creating a new faction - ERROR: There was an internal error while trying to create your faction. Please try again. - CREATED: %s created a new faction %s + ERROR: 'There was an internal error while trying to create your faction. Please try again.' + CREATED: '%s created a new faction %s' CREATEDLOG: ' は新しい党派を造りました: ' YOUSHOULD: 'You should now: %s' DEINVITE: From c22e3a52270fd38637a7afb8340041fc069806c7 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 19 May 2020 06:22:09 -0400 Subject: [PATCH 4/6] F Show Async Calling --- .../massivecraft/factions/cmd/CmdShow.java | 60 ++++++++++--------- .../cmd/relational/FRelationCommand.java | 6 +- 2 files changed, 35 insertions(+), 31 deletions(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java index d1c0b62e..6de26d8a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/CmdShow.java +++ b/src/main/java/com/massivecraft/factions/cmd/CmdShow.java @@ -84,37 +84,41 @@ public class CmdShow extends FCommand { } List fancy = new ArrayList<>(); - for (String raw : show) { - String parsed = TagUtil.parsePlain(faction, context.fPlayer, raw); // use relations - if (parsed == null) { - continue; // Due to minimal f show. - } - - if (context.fPlayer != null) { - parsed = TagUtil.parsePlaceholders(context.fPlayer.getPlayer(), parsed); - } - - if (TagUtil.hasFancy(parsed)) { - List localFancy = TagUtil.parseFancy(faction, context.fPlayer, parsed); - if (localFancy != null) - fancy.addAll(localFancy); - - 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(); + List finalShow = show; + Faction finalFaction = faction; + instance.getServer().getScheduler().runTaskAsynchronously(instance, () -> { + for (String raw : finalShow) { + String parsed = TagUtil.parsePlain(finalFaction, context.fPlayer, raw); // use relations + if (parsed == null) { + continue; // Due to minimal f show. } - 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 localFancy = TagUtil.parseFancy(finalFaction, context.fPlayer, parsed); + if (localFancy != null) + fancy.addAll(localFancy); + + 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. + } + parsed = FactionsPlugin.getInstance().txt.parse(parsed); + FancyMessage localFancy = instance.txt.parseFancy(parsed); + fancy.add(localFancy); } - parsed = FactionsPlugin.getInstance().txt.parse(parsed); - FancyMessage localFancy = instance.txt.parseFancy(parsed); - fancy.add(localFancy); } - } - instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); + instance.getServer().getScheduler().runTask(instance, () -> context.sendFancyMessage(fancy)); + }); } @Override diff --git a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java index f39a7044..37274b7a 100644 --- a/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java +++ b/src/main/java/com/massivecraft/factions/cmd/relational/FRelationCommand.java @@ -39,9 +39,9 @@ public abstract class FRelationCommand extends FCommand { @Override public void perform(CommandContext context) { Faction them = context.argAsFaction(0); - if (them == null) { - return; - } + if (them == null) return; + + if(!context.faction.isNormal()) return; if (!them.isNormal()) { context.msg(TL.COMMAND_RELATIONS_ALLTHENOPE); From 0d08ff4cec0613341bb7131e3cb474a6098d270a Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 19 May 2020 06:27:20 -0400 Subject: [PATCH 5/6] Wild Updates --- src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java index f25ac123..8a21ff8c 100644 --- a/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java +++ b/src/main/java/com/massivecraft/factions/cmd/wild/CmdWild.java @@ -11,7 +11,6 @@ import com.massivecraft.factions.util.wait.WaitedTask; import com.massivecraft.factions.zcore.util.TL; import org.bukkit.Bukkit; import org.bukkit.Location; -import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Player; import org.bukkit.event.player.PlayerTeleportEvent; From 7e6646b4df197f1199b704cd22595352627ae272 Mon Sep 17 00:00:00 2001 From: Driftay Date: Tue, 19 May 2020 06:28:05 -0400 Subject: [PATCH 6/6] Config Fix for default worlds --- src/main/resources/config.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index 3c5e62ba..01f5ef74 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -1448,7 +1448,7 @@ Wild: Zones: # You may create your own zones here please just follow the original format # Close: - World: World + World: world Range: MinX: -200 MaxX: 200 @@ -1463,7 +1463,7 @@ Wild: Name: '&cLow Range' Slot: 1 Medium: - World: World + World: world Range: MinX: -400 MaxX: 400 @@ -1478,7 +1478,7 @@ Wild: Name: '&cMedium Range' Slot: 4 Far: - World: World + World: world Range: MinX: -800 MaxX: 800